Author: lemovice
Date: Mon Dec  2 21:00:57 2013
New Revision: 4692

Log:
correct gedcom ecxeption in case of existing event

Modified:
   
trunk/AncestrisExtensions/editors.genealogyeditor/src/ancestris/modules/editors/genealogyeditor/panels/EventEditorPanel.form
   
trunk/AncestrisExtensions/editors.genealogyeditor/src/ancestris/modules/editors/genealogyeditor/panels/EventEditorPanel.java

Modified: 
trunk/AncestrisExtensions/editors.genealogyeditor/src/ancestris/modules/editors/genealogyeditor/panels/EventEditorPanel.form
==============================================================================
--- 
trunk/AncestrisExtensions/editors.genealogyeditor/src/ancestris/modules/editors/genealogyeditor/panels/EventEditorPanel.form
        (original)
+++ 
trunk/AncestrisExtensions/editors.genealogyeditor/src/ancestris/modules/editors/genealogyeditor/panels/EventEditorPanel.form
        Mon Dec  2 21:00:57 2013
@@ -57,20 +57,15 @@
                   <EmptySpace max="-2" attributes="0"/>
                   <Component id="dateLabel" min="-2" max="-2" attributes="0"/>
                   <EmptySpace min="-2" max="-2" attributes="0"/>
-                  <Component id="aDateBean" max="32767" attributes="0"/>
+                  <Component id="aDateBean" pref="377" max="32767" 
attributes="0"/>
                   <EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
               </Group>
               <Group type="102" alignment="0" attributes="0">
                   <Group type="103" groupAlignment="0" max="-2" attributes="0">
-                      <Group type="102" alignment="0" attributes="0">
-                          <Component id="eventPlaceLabel" min="-2" max="-2" 
attributes="0"/>
-                          <EmptySpace min="-2" pref="44" max="-2" 
attributes="0"/>
-                      </Group>
-                      <Group type="102" alignment="1" attributes="0">
-                          <Component id="eventDescriptionLabel" min="-2" 
max="-2" attributes="0"/>
-                          <EmptySpace max="-2" attributes="0"/>
-                      </Group>
+                      <Component id="eventDescriptionLabel" max="32767" 
attributes="0"/>
+                      <Component id="eventPlaceLabel" max="32767" 
attributes="0"/>
                   </Group>
+                  <EmptySpace max="-2" attributes="0"/>
                   <Group type="103" groupAlignment="0" attributes="0">
                       <Component id="eventDescriptionScrollPane" alignment="1" 
max="32767" attributes="0"/>
                       <Group type="102" alignment="0" attributes="0">
@@ -93,7 +88,7 @@
                       <Component id="eventIdLabel" alignment="3" min="-2" 
max="-2" attributes="0"/>
                       <Component id="eventIDTextField" alignment="3" min="-2" 
max="-2" attributes="0"/>
                   </Group>
-                  <EmptySpace max="-2" attributes="0"/>
+                  <EmptySpace min="-2" max="-2" attributes="0"/>
                   <Group type="103" groupAlignment="0" attributes="0">
                       <Group type="103" alignment="1" groupAlignment="3" 
attributes="0">
                           <Component id="eventTypeLabel" alignment="3" 
min="-2" max="-2" attributes="0"/>
@@ -104,25 +99,23 @@
                           <Component id="aDateBean" alignment="2" min="-2" 
max="-2" attributes="0"/>
                       </Group>
                   </Group>
-                  <EmptySpace max="-2" attributes="0"/>
-                  <Group type="103" groupAlignment="0" max="-2" attributes="0">
+                  <EmptySpace min="-2" max="-2" attributes="0"/>
+                  <Group type="103" groupAlignment="0" attributes="0">
                       <Group type="102" attributes="0">
                           <Component id="eventDescriptionLabel" min="-2" 
max="-2" attributes="0"/>
                           <EmptySpace min="-2" pref="127" max="-2" 
attributes="0"/>
                       </Group>
                       <Group type="102" attributes="0">
                           <Component id="eventDescriptionScrollPane" 
max="32767" attributes="0"/>
-                          <EmptySpace max="-2" attributes="0"/>
+                          <EmptySpace min="-2" max="-2" attributes="0"/>
                       </Group>
                   </Group>
                   <Group type="103" groupAlignment="0" attributes="0">
-                      <Component id="addPlaceButton" alignment="0" min="-2" 
max="-2" attributes="0"/>
-                      <Component id="editPlaceButton" alignment="0" min="-2" 
max="-2" attributes="0"/>
-                      <Component id="removePlaceButton" alignment="0" min="-2" 
max="-2" attributes="0"/>
-                      <Group type="103" alignment="0" groupAlignment="3" 
attributes="0">
-                          <Component id="eventPlaceLabel" alignment="3" 
min="-2" max="-2" attributes="0"/>
-                          <Component id="eventPlaceTextField" alignment="3" 
min="-2" max="-2" attributes="0"/>
-                      </Group>
+                      <Component id="eventPlaceLabel" min="-2" max="-2" 
attributes="0"/>
+                      <Component id="eventPlaceTextField" min="-2" max="-2" 
attributes="0"/>
+                      <Component id="addPlaceButton" min="-2" max="-2" 
attributes="0"/>
+                      <Component id="editPlaceButton" min="-2" max="-2" 
attributes="0"/>
+                      <Component id="removePlaceButton" min="-2" max="-2" 
attributes="0"/>
                   </Group>
               </Group>
           </Group>

Modified: 
trunk/AncestrisExtensions/editors.genealogyeditor/src/ancestris/modules/editors/genealogyeditor/panels/EventEditorPanel.java
==============================================================================
--- 
trunk/AncestrisExtensions/editors.genealogyeditor/src/ancestris/modules/editors/genealogyeditor/panels/EventEditorPanel.java
        (original)
+++ 
trunk/AncestrisExtensions/editors.genealogyeditor/src/ancestris/modules/editors/genealogyeditor/panels/EventEditorPanel.java
        Mon Dec  2 21:00:57 2013
@@ -19,6 +19,7 @@
     private EventsTypeComboBoxModelModel eventsTypeComboBoxModelModel = new 
EventsTypeComboBoxModelModel();
     private PropertyEvent mEvent = null;
     private Property mRoot;
+    private boolean mEventTypeCanChange = false;
 
     /**
      * Creates new form EventEditorPanel
@@ -27,8 +28,6 @@
         initComponents();
         eventIdLabel.setVisible(false);
         eventIDTextField.setVisible(false);
-        eventDescriptionLabel.setVisible(false);
-        eventDescriptionScrollPane.setVisible(false);
         aDateBean.setPreferHorizontal(true);
     }
 
@@ -137,16 +136,13 @@
                 
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                 .addComponent(dateLabel)
                 
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addComponent(aDateBean, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                .addComponent(aDateBean, javax.swing.GroupLayout.DEFAULT_SIZE, 
377, Short.MAX_VALUE)
                 .addGap(6, 6, 6))
             .addGroup(jPanel1Layout.createSequentialGroup()
                 
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
 false)
-                    .addGroup(jPanel1Layout.createSequentialGroup()
-                        .addComponent(eventPlaceLabel)
-                        .addGap(44, 44, 44))
-                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, 
jPanel1Layout.createSequentialGroup()
-                        .addComponent(eventDescriptionLabel)
-                        
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
+                    .addComponent(eventDescriptionLabel, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
Short.MAX_VALUE)
+                    .addComponent(eventPlaceLabel, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
Short.MAX_VALUE))
+                
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                 
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addComponent(eventDescriptionScrollPane, 
javax.swing.GroupLayout.Alignment.TRAILING)
                     .addGroup(jPanel1Layout.createSequentialGroup()
@@ -173,7 +169,7 @@
                         .addComponent(dateLabel)
                         .addComponent(aDateBean, 
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.PREFERRED_SIZE)))
                 
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
 false)
+                
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(jPanel1Layout.createSequentialGroup()
                         .addComponent(eventDescriptionLabel)
                         .addGap(127, 127, 127))
@@ -181,12 +177,11 @@
                         .addComponent(eventDescriptionScrollPane)
                         
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                 
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addComponent(eventPlaceLabel)
+                    .addComponent(eventPlaceTextField, 
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.PREFERRED_SIZE)
                     .addComponent(addPlaceButton)
                     .addComponent(editPlaceButton)
-                    .addComponent(removePlaceButton)
-                    
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
-                        .addComponent(eventPlaceLabel)
-                        .addComponent(eventPlaceTextField, 
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.PREFERRED_SIZE))))
+                    .addComponent(removePlaceButton)))
         );
 
         javax.swing.GroupLayout sourcesPanelLayout = new 
javax.swing.GroupLayout(sourcesPanel);
@@ -319,24 +314,26 @@
     }//GEN-LAST:event_removePlaceButtonActionPerformed
 
     private void eventTypeComboBoxActionPerformed(java.awt.event.ActionEvent 
evt) {//GEN-FIRST:event_eventTypeComboBoxActionPerformed
-        try {
-            if (mEvent != null) {
-                mRoot.getGedcom().undoUnitOfWork();
-            }
-            mRoot.getGedcom().doUnitOfWork(new UnitOfWork() {
+        if (mEventTypeCanChange == true) {
+            try {
+                if (mEvent != null) {
+                    mRoot.getGedcom().undoUnitOfWork();
+                }
+                mRoot.getGedcom().doUnitOfWork(new UnitOfWork() {
 
-                @Override
-                public void perform(Gedcom gedcom) throws GedcomException {
-                    mEvent = (PropertyEvent) 
mRoot.addProperty(PropertyTag2Name.getPropertyTag(eventTypeComboBox.getSelectedItem().toString()),
 "");
-                    PropertyDate date = (PropertyDate) 
mEvent.getProperty("DATE");
-                    if (date == null) {
-                        date = (PropertyDate) mEvent.addProperty("DATE", "");
+                    @Override
+                    public void perform(Gedcom gedcom) throws GedcomException {
+                        mEvent = (PropertyEvent) 
mRoot.addProperty(PropertyTag2Name.getPropertyTag(eventTypeComboBox.getSelectedItem().toString()),
 "");
+                        PropertyDate date = (PropertyDate) 
mEvent.getProperty("DATE");
+                        if (date == null) {
+                            date = (PropertyDate) mEvent.addProperty("DATE", 
"");
+                        }
+                        aDateBean.setContext(date);
                     }
-                    aDateBean.setContext(date);
-                }
-            }); // end of doUnitOfWork
-        } catch (GedcomException ex) {
-            Exceptions.printStackTrace(ex);
+                }); // end of doUnitOfWork
+            } catch (GedcomException ex) {
+                Exceptions.printStackTrace(ex);
+            }
         }
     }//GEN-LAST:event_eventTypeComboBoxActionPerformed
     // Variables declaration - do not modify//GEN-BEGIN:variables
@@ -370,7 +367,7 @@
     public void set(Property root, PropertyEvent event) {
         this.mRoot = root;
         this.mEvent = event;
-        if (event != null) {
+        if (mEvent != null) {
             
eventTypeComboBox.setSelectedItem(PropertyTag2Name.getTagName(mEvent.getTag()));
             eventTypeComboBox.setEnabled(false);
             eventDescriptionTextArea.setText(mEvent.getDisplayValue());
@@ -425,6 +422,7 @@
                         aDateBean.setContext(date);
                     }
                 }); // end of doUnitOfWork
+                mEventTypeCanChange = true;
             } catch (GedcomException ex) {
                 Exceptions.printStackTrace(ex);
             }

---------------------------------------------------------------------
Site Web Ancestris : http://www.ancestris.org

<*> Pour vous desinscrire de cette liste, envoyez un mail a :
              [email protected]
<*> Pour obtenir de l'aide sur les commandes de la liste :
              [email protected]

Pour obtenir tous les messages lies a ce fil de discussion, cliquez sur le 
lien ci-dessous, cela ouvrira votre logiciel de messagerie. Il vous suffira 
d'envoyer le message :
              [email protected]

Reply via email to