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

Commits:

5 changed files:

Changes:

  • client/src/main/java/fr/ird/observe/client/ui/ObserveMainUI.jaxx
    ... ... @@ -121,8 +121,6 @@
    121 121
     
    
    122 122
       <ClientDataContext id='dataContext' initializer='ObserveSwingApplicationContext.get().getDataContext()'/>
    
    123 123
     
    
    124
    -  <CardLayout2 id='contentLayout'/>
    
    125
    -
    
    126 124
       <CardLayout2Ext id='bodyLayout' constructorParams='this, "body"'/>
    
    127 125
     
    
    128 126
       <ObserveBlockingLayerUI id='busyBlockLayerUI'/>
    
    ... ... @@ -260,8 +258,8 @@ protected void finalize() throws Throwable {
    260 258
     
    
    261 259
             <!-- right up : content -->
    
    262 260
     
    
    263
    -        <JPanel id="content">
    
    264
    -          <JPanel id="emptySelection" constraints='"emptySelection"' layout="{new BorderLayout()}">
    
    261
    +        <JPanel id="content" layout="{new BorderLayout()}">
    
    262
    +          <JPanel id="emptySelection" layout="{new BorderLayout()}" constraints="BorderLayout.CENTER">
    
    265 263
                 <JLabel id="emptySelectionLabel" constraints="BorderLayout.CENTER"/>
    
    266 264
               </JPanel>
    
    267 265
             </JPanel>
    

  • client/src/main/java/fr/ird/observe/client/ui/ObserveMainUI.jcss
    ... ... @@ -328,10 +328,6 @@ JSplitPane {
    328 328
       resizeWeight: 0.80;
    
    329 329
     }
    
    330 330
     
    
    331
    -#contentLayout {
    
    332
    -  useOnlyVisibleComponentDimension: true;
    
    333
    -}
    
    334
    -
    
    335 331
     #navigationView {
    
    336 332
       title: "observe.view.navigation";
    
    337 333
     }
    

  • client/src/main/java/fr/ird/observe/client/ui/ObserveMainUIInitializer.java
    ... ... @@ -62,7 +62,6 @@ import javax.swing.border.Border;
    62 62
     import javax.swing.border.LineBorder;
    
    63 63
     import javax.swing.event.TreeSelectionEvent;
    
    64 64
     import javax.swing.tree.TreePath;
    
    65
    -import java.awt.Component;
    
    66 65
     import java.awt.Container;
    
    67 66
     import java.awt.Cursor;
    
    68 67
     import java.awt.event.KeyEvent;
    
    ... ... @@ -88,8 +87,6 @@ public class ObserveMainUIInitializer {
    88 87
         /** Logger */
    
    89 88
         private static final Log log = LogFactory.getLog(ObserveMainUIInitializer.class);
    
    90 89
     
    
    91
    -    private static final String EMPTY_SELECTION = "emptySelection";
    
    92
    -
    
    93 90
         private final ObserveMainUI ui;
    
    94 91
         private Border focusBorder;
    
    95 92
         private Border noFocusBorder;
    
    ... ... @@ -183,25 +180,15 @@ public class ObserveMainUIInitializer {
    183 180
             }
    
    184 181
             if (ui.getNavigationUI().getTree().isSelectionEmpty()) {
    
    185 182
                 log.debug("No selection, show empty panel...");
    
    186
    -
    
    187
    -            boolean foundEmptySelection = false;
    
    188
    -            for (Component component : ui.getContent().getComponents()) {
    
    189
    -                if (component.getName().equals(EMPTY_SELECTION)) {
    
    190
    -                    foundEmptySelection = true;
    
    191
    -                }
    
    192
    -            }
    
    193
    -            if (!foundEmptySelection) {
    
    194
    -                ui.getContent().add(ui.getEmptySelection(), EMPTY_SELECTION);
    
    195
    -            }
    
    196
    -            ui.getContentLayout().show(ui.getContent(), EMPTY_SELECTION);
    
    183
    +            ui.getContentUIManager().removeSelectedContentUI();
    
    197 184
                 return;
    
    198 185
             }
    
    199 186
     
    
    200 187
             TreePath path = event.getPath();
    
    201 188
             NavigationTreeNodeSupport node = (NavigationTreeNodeSupport) path.getLastPathComponent();
    
    202
    -        ContentUIManager manager = ui.getContentUIManager();
    
    203 189
     
    
    204 190
             // obtain the ui type to show
    
    191
    +        @SuppressWarnings("unchecked")
    
    205 192
             Class<? extends ContentUI<?, ?>> uiClass = node.getContentClass();
    
    206 193
             if (log.isDebugEnabled()) {
    
    207 194
                 log.debug("new selected path = " + node + ", ui = " + uiClass);
    
    ... ... @@ -525,7 +512,7 @@ public class ObserveMainUIInitializer {
    525 512
         public void cleanNavigationUI(ProgressModel progressModel) {
    
    526 513
     
    
    527 514
             // reset content uis
    
    528
    -        ui.getContentLayout().reset(ui.getContent());
    
    515
    +        ui.getContentUIManager().removeSelectedContentUI();
    
    529 516
             progressModel.incrementsCurrentStep();
    
    530 517
     
    
    531 518
             // clean messages
    

  • client/src/main/java/fr/ird/observe/client/ui/content/ContentUIManager.java
    ... ... @@ -6,15 +6,15 @@
    6 6
      * %%
    
    7 7
      * This program is free software: you can redistribute it and/or modify
    
    8 8
      * it under the terms of the GNU General Public License as
    
    9
    - * published by the Free Software Foundation, either version 3 of the 
    
    9
    + * published by the Free Software Foundation, either version 3 of the
    
    10 10
      * License, or (at your option) any later version.
    
    11
    - * 
    
    11
    + *
    
    12 12
      * This program is distributed in the hope that it will be useful,
    
    13 13
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    14 14
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    15 15
      * GNU General Public License for more details.
    
    16
    - * 
    
    17
    - * You should have received a copy of the GNU General Public 
    
    16
    + *
    
    17
    + * You should have received a copy of the GNU General Public
    
    18 18
      * License along with this program.  If not, see
    
    19 19
      * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    20 20
      * #L%
    
    ... ... @@ -26,14 +26,15 @@ import fr.ird.observe.client.ObserveSwingSessionHelper;
    26 26
     import fr.ird.observe.client.ui.ObserveMainUI;
    
    27 27
     import fr.ird.observe.client.ui.util.UIHelper;
    
    28 28
     import fr.ird.observe.dto.AbstractObserveDto;
    
    29
    -import java.awt.Component;
    
    30
    -import java.lang.reflect.Constructor;
    
    31
    -import javax.swing.JPanel;
    
    32 29
     import org.apache.commons.logging.Log;
    
    33 30
     import org.apache.commons.logging.LogFactory;
    
    34 31
     import org.nuiton.jaxx.runtime.JAXXContext;
    
    35 32
     import org.nuiton.jaxx.runtime.context.JAXXInitialContext;
    
    36
    -import org.nuiton.jaxx.runtime.swing.CardLayout2;
    
    33
    +
    
    34
    +import javax.swing.JPanel;
    
    35
    +import java.awt.BorderLayout;
    
    36
    +import java.awt.Component;
    
    37
    +import java.lang.reflect.Constructor;
    
    37 38
     
    
    38 39
     /**
    
    39 40
      * Manager des ecrans d'editions
    
    ... ... @@ -46,30 +47,21 @@ public class ContentUIManager {
    46 47
         /** Logger */
    
    47 48
         private static final Log log = LogFactory.getLog(ContentUIManager.class);
    
    48 49
     
    
    49
    -    public <U extends ContentUI<?, ?>> U getContent(Class<U> uiClass) {
    
    50
    -
    
    51
    -        CardLayout2 layout = getLayout();
    
    50
    +    public <U extends ContentUI<?, ?>> U getContent() {
    
    52 51
             JPanel layoutContent = getLayoutContent();
    
    53
    -        String constraints = uiClass.getName();
    
    54
    -
    
    55
    -        if (!layout.contains(constraints)) {
    
    56
    -
    
    57
    -            // pas trouvé
    
    52
    +        Component currentContent = layoutContent.getComponent(0);
    
    53
    +        if (!(currentContent instanceof ContentUI)) {
    
    58 54
                 return null;
    
    59 55
             }
    
    60
    -
    
    61
    -        @SuppressWarnings("unchecked") U content = (U) layout.getComponent(layoutContent, constraints);
    
    62
    -
    
    56
    +        @SuppressWarnings("unchecked") U content = (U) currentContent;
    
    63 57
             if (log.isDebugEnabled()) {
    
    64
    -            log.debug("Will use existing content [" + constraints + "] : " + content.getClass().getName());
    
    58
    +            log.debug(String.format("Will use existing content: %s", content.getClass().getName()));
    
    65 59
             }
    
    66 60
             return content;
    
    67 61
         }
    
    68 62
     
    
    69 63
         public <U extends ContentUI<?, ?>> U createContent(Class<U> uiClass) {
    
    70 64
     
    
    71
    -        String constraints = uiClass.getName();
    
    72
    -
    
    73 65
             U result;
    
    74 66
             try {
    
    75 67
                 Constructor<U> constructor = uiClass.getConstructor(JAXXContext.class);
    
    ... ... @@ -84,9 +76,10 @@ public class ContentUIManager {
    84 76
             try {
    
    85 77
     
    
    86 78
                 // ajout du content dans son parent
    
    87
    -            getLayoutContent().add(result, constraints);
    
    79
    +            getLayoutContent().removeAll();
    
    80
    +            getLayoutContent().add(result, BorderLayout.CENTER);
    
    88 81
                 if (log.isDebugEnabled()) {
    
    89
    -                log.debug("Add new content [" + constraints + "] : " + result.getClass().getName());
    
    82
    +                log.debug(String.format("Add new content: %s", result.getClass().getName()));
    
    90 83
                 }
    
    91 84
     
    
    92 85
                 getMainUI().getModel().attachFocusOnBody(result);
    
    ... ... @@ -117,8 +110,8 @@ public class ContentUIManager {
    117 110
             } catch (Exception e) {
    
    118 111
                 UIHelper.handlingError(e);
    
    119 112
             } finally {
    
    120
    -
    
    121
    -            getLayout().show(getLayoutContent(), constraints);
    
    113
    +            getLayoutContent().removeAll();
    
    114
    +            getLayoutContent().add(content, BorderLayout.CENTER);
    
    122 115
                 getMainUI().getHandler().updateContentSize();
    
    123 116
     
    
    124 117
                 content.opened();
    
    ... ... @@ -127,7 +120,8 @@ public class ContentUIManager {
    127 120
         }
    
    128 121
     
    
    129 122
         public void close() {
    
    130
    -        getLayout().reset(getLayoutContent());
    
    123
    +        getLayoutContent().removeAll();
    
    124
    +        getLayoutContent().add(getMainUI().getEmptySelection(), BorderLayout.CENTER);
    
    131 125
         }
    
    132 126
     
    
    133 127
         public ContentUI<?, ?> getSelectedContentUI() {
    
    ... ... @@ -162,13 +156,12 @@ public class ContentUIManager {
    162 156
         }
    
    163 157
     
    
    164 158
         public void removeSelectedContentUI() {
    
    165
    -
    
    166 159
             ContentUI<?, ?> selectedContentUI = getSelectedContentUI();
    
    167 160
             if (selectedContentUI != null) {
    
    168
    -            getLayout().removeLayoutComponent(selectedContentUI, selectedContentUI.getClass().getName());
    
    169
    -            getLayoutContent().remove(selectedContentUI);
    
    161
    +            getLayoutContent().removeAll();
    
    170 162
                 selectedContentUI.destroy();
    
    171 163
             }
    
    164
    +        getLayoutContent().add(getMainUI().getEmptySelection(), BorderLayout.CENTER);
    
    172 165
         }
    
    173 166
     
    
    174 167
         public void restartEdit() {
    
    ... ... @@ -211,25 +204,22 @@ public class ContentUIManager {
    211 204
             return getMainUI().getContent();
    
    212 205
         }
    
    213 206
     
    
    214
    -    private CardLayout2 getLayout() {
    
    215
    -        return getMainUI().getContentLayout();
    
    216
    -    }
    
    207
    +//    private CardLayout2 getLayout() {
    
    208
    +//        return getMainUI().getContentLayout();
    
    209
    +//    }
    
    217 210
     
    
    218 211
         private ObserveMainUI getMainUI() {
    
    219 212
             return ObserveSwingApplicationContext.get().getMainUI();
    
    220 213
         }
    
    221 214
     
    
    222 215
         private ContentUI<?, ?> getSelectedContentUI(ObserveMainUI ui) {
    
    223
    -
    
    224 216
             if (ui == null) {
    
    225 217
                 // no ui, so no modification
    
    226 218
                 return null;
    
    227 219
             }
    
    228
    -
    
    229 220
             ContentUI<?, ?> result = null;
    
    230
    -        CardLayout2 layout = ui.getContentLayout();
    
    231 221
             JPanel container = ui.getContent();
    
    232
    -        Component currentContent = layout.getVisibleComponent(container);
    
    222
    +        Component currentContent = container.getComponent(0);
    
    233 223
             if (currentContent instanceof ContentUI<?, ?>) {
    
    234 224
                 result = (ContentUI<?, ?>) currentContent;
    
    235 225
             }
    

  • client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationUI.jcss
    ... ... @@ -65,3 +65,7 @@ JButton {
    65 65
       actionIcon:generate;
    
    66 66
       toolTipText:"observe.tree.action.configure.tip";
    
    67 67
     }
    
    68
    +
    
    69
    +#tree {
    
    70
    +  font-size:11;
    
    71
    +}