Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe

Commits:

3 changed files:

Changes:

  • client/src/main/java/fr/ird/observe/client/ui/dcprefs/FloatingObjectReferencesUI.jaxx
    ... ... @@ -31,32 +31,34 @@
    31 31
     
    
    32 32
       <FloatingObjectReferencesUIModel id="model" initializer="getContextValue(FloatingObjectReferencesUIModel.class)"/>
    
    33 33
     
    
    34
    -  <JPanel id="referencePanel" layout="{new BorderLayout()}">
    
    35
    -    <BeanComboBox id='references' constructorParams='this' genericType='FloatingObjectReference'
    
    36
    -                  constraints='BorderLayout.NORTH'/>
    
    37 34
     
    
    38
    -    <JLabel id="noReferenceSelected" constraints='BorderLayout.CENTER'/>
    
    39
    -    <Table id="referenceForm" constraints='BorderLayout.SOUTH' fill="both">
    
    40
    -      <row>
    
    41
    -        <cell anchor='west'>
    
    42
    -          <JLabel text='observe.common.name'/>
    
    43
    -        </cell>
    
    44
    -        <cell weightx='1' fill="both" anchor='east'>
    
    45
    -          <JTextField id="referenceName" onKeyReleased="model.setModified(true);"/>
    
    46
    -        </cell>
    
    47
    -      </row>
    
    35
    +  <JSplitPane id="referencePanel">
    
    36
    +    <JList id='references' genericType="FloatingObjectReference"/>
    
    48 37
     
    
    49
    -      <row>
    
    50
    -        <cell columns='2'>
    
    51
    -          <JPanel layout="{new GridLayout(1, 0)}">
    
    52
    -            <JButton id="saveAction"/>
    
    53
    -            <JButton id="deleteAction"/>
    
    54
    -          </JPanel>
    
    55
    -        </cell>
    
    56
    -      </row>
    
    57
    -    </Table>
    
    58
    -  </JPanel>
    
    38
    +    <JPanel id="referenceContentPanel" layout="{new BorderLayout()}">
    
    39
    +
    
    40
    +      <JLabel id="noReferenceSelected" constraints='BorderLayout.CENTER'/>
    
    41
    +      <Table id="referenceForm" constraints='BorderLayout.SOUTH' fill="both">
    
    42
    +        <row>
    
    43
    +          <cell anchor='west'>
    
    44
    +            <JLabel text='observe.common.name'/>
    
    45
    +          </cell>
    
    46
    +          <cell weightx='1' fill="both" anchor='east'>
    
    47
    +            <JTextField id="referenceName" onKeyReleased="model.setModified(true);"/>
    
    48
    +          </cell>
    
    49
    +        </row>
    
    59 50
     
    
    51
    +        <row>
    
    52
    +          <cell columns='2'>
    
    53
    +            <JPanel layout="{new GridLayout(1, 0)}">
    
    54
    +              <JButton id="saveAction"/>
    
    55
    +              <JButton id="deleteAction"/>
    
    56
    +            </JPanel>
    
    57
    +          </cell>
    
    58
    +        </row>
    
    59
    +      </Table>
    
    60
    +    </JPanel>
    
    61
    +  </JSplitPane>
    
    60 62
       <JPanel constraints='BorderLayout.SOUTH' layout="{new GridLayout(1, 0)}">
    
    61 63
         <JButton id="quitAction"/>
    
    62 64
       </JPanel>
    

  • client/src/main/java/fr/ird/observe/client/ui/dcprefs/FloatingObjectReferencesUI.jcss
    ... ... @@ -19,9 +19,6 @@
    19 19
      * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    20 20
      * #L%
    
    21 21
      */
    
    22
    -#references {
    
    23
    -  selectedItem: {model.getReference()};
    
    24
    -}
    
    25 22
     
    
    26 23
     #noReferenceSelected {
    
    27 24
       visible: true;
    

  • client/src/main/java/fr/ird/observe/client/ui/dcprefs/FloatingObjectReferencesUIHandler.java
    ... ... @@ -23,9 +23,9 @@ package fr.ird.observe.client.ui.dcprefs;
    23 23
      */
    
    24 24
     
    
    25 25
     import fr.ird.observe.client.ObserveSwingApplicationContext;
    
    26
    -import fr.ird.observe.client.ui.ObserveKeyStrokes;
    
    27 26
     import fr.ird.observe.client.ui.actions.UIActionSupport;
    
    28 27
     import fr.ird.observe.client.ui.content.ObserveActionMap;
    
    28
    +import fr.ird.observe.client.ui.util.UIHelper;
    
    29 29
     import fr.ird.observe.services.dto.FloatingObjectReference;
    
    30 30
     import java.awt.BorderLayout;
    
    31 31
     import java.util.LinkedList;
    
    ... ... @@ -33,12 +33,11 @@ import java.util.List;
    33 33
     import java.util.Objects;
    
    34 34
     import java.util.Set;
    
    35 35
     import javax.swing.AbstractButton;
    
    36
    -import javax.swing.JComponent;
    
    36
    +import javax.swing.DefaultListModel;
    
    37 37
     import javax.swing.SwingUtilities;
    
    38 38
     import org.nuiton.decorator.Decorator;
    
    39
    -import org.nuiton.decorator.JXPathDecorator;
    
    40 39
     import org.nuiton.jaxx.runtime.spi.UIHandler;
    
    41
    -import org.nuiton.jaxx.widgets.select.BeanComboBox;
    
    40
    +import org.nuiton.jaxx.runtime.swing.renderer.DecoratorListCellRenderer;
    
    42 41
     
    
    43 42
     
    
    44 43
     import static fr.ird.observe.client.ui.content.ContentUIInitializer.OBSERVE_ACTION;
    
    ... ... @@ -74,35 +73,50 @@ public class FloatingObjectReferencesUIHandler implements UIHandler<FloatingObje
    74 73
     
    
    75 74
             }
    
    76 75
     
    
    77
    -        Decorator<FloatingObjectReference> remoteDecorator = ObserveSwingApplicationContext.get().getDecoratorService().getDecoratorByType(FloatingObjectReference.class);
    
    78
    -        ui.getReferences().init((JXPathDecorator<FloatingObjectReference>) remoteDecorator, ui.getModel().getReferences());
    
    76
    +        Decorator<FloatingObjectReference> decorator = ObserveSwingApplicationContext.get().getDecoratorService().getDecoratorByType(FloatingObjectReference.class);
    
    77
    +        ui.getReferences().setCellRenderer(new DecoratorListCellRenderer<>(decorator));
    
    79 78
     
    
    80
    -        ui.getModel().addPropertyChangeListener(FloatingObjectReferencesUIModel.PROPERTY_REFERENCES, evt -> ui.getReferences().setData((List<FloatingObjectReference>) evt.getNewValue()));
    
    79
    +        DefaultListModel<FloatingObjectReference> listModel = new DefaultListModel<>();
    
    80
    +        ui.getModel().getReferences().forEach(listModel::addElement);
    
    81
    +        ui.getReferences().setModel(listModel);
    
    82
    +        ui.getReferences().addListSelectionListener(evt -> {
    
    83
    +            if (ui.getReferences().isSelectionEmpty()) {
    
    81 84
     
    
    82
    -        ui.getReferences().addPropertyChangeListener(BeanComboBox.PROPERTY_SELECTED_ITEM, evt -> {
    
    85
    +                ui.getModel().setReference(null);
    
    86
    +            } else {
    
    87
    +                ui.getModel().setReference(ui.getReferences().getSelectedValue());
    
    88
    +            }
    
    89
    +        });
    
    90
    +
    
    91
    +        ui.getModel().addPropertyChangeListener(FloatingObjectReferencesUIModel.PROPERTY_REFERENCES, evt -> {
    
    92
    +            List newValue = (List) evt.getNewValue();
    
    93
    +
    
    94
    +            listModel.clear();
    
    95
    +            for (Object reference : newValue) {
    
    96
    +                listModel.addElement((FloatingObjectReference) reference);
    
    97
    +            }
    
    98
    +        });
    
    99
    +
    
    100
    +        ui.getModel().addPropertyChangeListener(FloatingObjectReferencesUIModel.PROPERTY_REFERENCE, evt -> {
    
    83 101
     
    
    84 102
                 FloatingObjectReference oldValue = (FloatingObjectReference) evt.getOldValue();
    
    85
    -            FloatingObjectReference newValue = (FloatingObjectReference) evt.getNewValue();
    
    86
    -            ui.getModel().setReference(newValue);
    
    87 103
     
    
    88 104
                 if (ui.getModel().getReference() == null) {
    
    89
    -                ui.getReferencePanel().remove(ui.getReferenceForm());
    
    90
    -                ui.getReferencePanel().add(ui.getNoReferenceSelected(), BorderLayout.CENTER);
    
    105
    +                ui.getReferenceContentPanel().remove(ui.getReferenceForm());
    
    106
    +                ui.getReferenceContentPanel().add(ui.getNoReferenceSelected(), BorderLayout.CENTER);
    
    91 107
                 } else {
    
    92 108
                     if (oldValue == null) {
    
    93 109
                         ui.getReferenceForm().setVisible(true);
    
    94
    -                    ui.getReferencePanel().remove(ui.getNoReferenceSelected());
    
    95
    -                    ui.getReferencePanel().add(ui.getReferenceForm(), BorderLayout.CENTER);
    
    110
    +                    ui.getReferenceContentPanel().remove(ui.getNoReferenceSelected());
    
    111
    +                    ui.getReferenceContentPanel().add(ui.getReferenceForm(), BorderLayout.CENTER);
    
    112
    +                    UIHelper.askFocus(ui.getReferenceName());
    
    96 113
                     }
    
    97 114
                     ui.getModel().setModified(false);
    
    98 115
                 }
    
    99 116
                 SwingUtilities.invokeLater(ui::repaint);
    
    100 117
             });
    
    101 118
     
    
    102
    -        ui.getReferences().getCombobox().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
    
    103
    -                .put(ObserveKeyStrokes.KEY_STROKE_DELETE, "none");
    
    104
    -
    
    105
    -        ObserveKeyStrokes.addKeyStrokeFromMnemonic(ui);
    
    119
    +        UIHelper.askFocus(ui.getQuitAction());
    
    106 120
         }
    
    107 121
     
    
    108 122
         protected void init(ObserveActionMap actionMap, AbstractButton editor) {
    
    ... ... @@ -112,7 +126,6 @@ public class FloatingObjectReferencesUIHandler implements UIHandler<FloatingObje
    112 126
                 return;
    
    113 127
             }
    
    114 128
     
    
    115
    -        // on a trouve une action commune
    
    116 129
             UIActionSupport action = (UIActionSupport) actionMap.get(actionId);
    
    117 130
             Objects.requireNonNull(action, "action [" + actionId + "] not found for ui " + ui.getClass().getName());
    
    118 131