r1070 - trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util
Author: tchemit Date: 2008-02-18 15:34:45 +0000 (Mon, 18 Feb 2008) New Revision: 1070 Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ShowListTabAbstractAction.java Log: mod?\195?\168le r?\195?\169cup?\195?\169r?\195?\169 uniquement apres construction de l'ui Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ShowListTabAbstractAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ShowListTabAbstractAction.java 2008-02-18 15:33:04 UTC (rev 1069) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ShowListTabAbstractAction.java 2008-02-18 15:34:45 UTC (rev 1070) @@ -74,22 +74,19 @@ tabbedPane.setSelectedComponent(ui); return false; } - - ListTabModel model = (ListTabModel) getModel(); - - MetaData[] data = model.getList(); - - if (data == null) { - // first coming here, init model - model.initTabModel(getContext(), remote); - } + return true; } protected void initFirstUsage(final JListTab ui, final ListTabModel model) { detailAction = (ShowDetailTabAction) SimExplorerActionManager.newAction("showTab_detail", (AbstractButton) null); synchronizeAction = (ShowSynchronizeTabAction) SimExplorerActionManager.newAction("showTab_synchronize", (AbstractButton) null); + MetaData[] data = model.getList(); + if (data == null) { + // first coming here, init model + model.initTabModel(getContext(), remote, (ListTableModel) ((JListTab) getUI()).getTable().getModel()); + } ui.getShowTab_synchronize().setHideActionText(false); ui.getExportElement().setHideActionText(false); ui.getDownloadElement().setHideActionText(false); @@ -121,7 +118,7 @@ if (e.getClickCount() == 2) { try { // synchronization du meta selectionne - synchSelected(ui, getRowAtPoint(ui, e.getPoint()), ui.getTable().getSelectionModel(), model); + synchSelected(ui, getRowAtPoint(ui, e.getPoint()), ui.getTable().getSelectionModel(), model); // lancement de l'action d'affichage du tab detailAction.actionPerformed(new ActionEvent(e.getSource(), ActionEvent.ACTION_FIRST, "showTab_detail")); } catch (Exception e1) { @@ -159,17 +156,23 @@ } protected void synchSelected(final JListTab ui, int rowAtPoint, ListSelectionModel selectionModel, ListTabModel model) { + // if empty list, this is quick + if (model.isEmpty()) { + model.setSelectedIndex(-1); + model.synch(null); + return; + } DataEntityModel entityModel; if (rowAtPoint == -1 || model.getSelectedIndex() != rowAtPoint || selectionModel.isSelectionEmpty() || selectionModel.getMinSelectionIndex() != rowAtPoint) { if (rowAtPoint == -1) { rowAtPoint = 0; } - if (ui.getTable().getSelectedRow() != rowAtPoint) { + if (ui.getTable().getSelectedRow() != rowAtPoint) { // select the row - boolean wasEnabled =listMetaSelectionListener.enabled; - listMetaSelectionListener.enabled=false; + boolean wasEnabled = listMetaSelectionListener.enabled; + listMetaSelectionListener.enabled = false; selectionModel.setSelectionInterval(rowAtPoint, rowAtPoint); - listMetaSelectionListener.enabled=wasEnabled; + listMetaSelectionListener.enabled = wasEnabled; } // the model is not yet ready model.setSelectedIndex(rowAtPoint);
participants (1)
-
tchemit@users.labs.libre-entreprise.org