Author: tchemit
Date: 2008-02-16 20:12:51 +0000 (Sat, 16 Feb 2008)
New Revision: 1033
Added:
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/QueryModel.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/SimExplorerTabModel.java
Modified:
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorer.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ListTabRefreshHelper.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerTab.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerTabFactory.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DetailTabModel.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/ListTabModel.java
trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/SynchronizeTabModel.java
Log:
extraction model commun au model d'onglet : SimExplorerTabModel
definition du model de recherche (pour la rechercher avancee) : QueryModel
utilisation du model de Recherche dans le modele de l'onglet de liste
utilisation des SimTabFactory plutot que l'interface TabFactory
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorer.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorer.java 2008-02-16 18:59:21 UTC (rev 1032)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/SimExplorer.java 2008-02-16 20:12:51 UTC (rev 1033)
@@ -18,16 +18,14 @@
* ##% */
package fr.cemagref.simexplorer.is.ui;
+import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException;
+import fr.cemagref.simexplorer.is.ui.swing.MainUIRefreshHelper;
import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager;
import fr.cemagref.simexplorer.is.ui.swing.SimExplorerMainUI;
import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
-import fr.cemagref.simexplorer.is.ui.swing.MainUIRefreshHelper;
import fr.cemagref.simexplorer.is.ui.swing.actions.ConnectAction;
import fr.cemagref.simexplorer.is.ui.swing.actions.ImportAction;
import fr.cemagref.simexplorer.is.ui.swing.util.ErrorDialog;
-import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel;
-import fr.cemagref.simexplorer.is.ui.swing.model.SynchronizeTabModel;
-import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException;
import org.codelutin.i18n.I18n;
import org.codelutin.option.ui.ConfigTableModel;
import org.codelutin.option.ui.ConfigUI;
@@ -35,8 +33,8 @@
import javax.swing.AbstractButton;
import java.awt.event.ActionEvent;
import java.io.IOException;
-import java.io.StringWriter;
import java.io.PrintWriter;
+import java.io.StringWriter;
/**
* L'application principale
@@ -84,12 +82,12 @@
ui = null;
SimExplorerActionManager.resetCache();
ConfigUI.reloadUI();
- errorDialog=null;
+ errorDialog = null;
SimExplorerTab.getFactory().resetCache();
// remove listeners on detail tab model
- ((DetailTabModel) SimExplorerTab.detail.getModel()).removePropertyChangeListeners();
- // remove listeners on synchronize tab model
- ((SynchronizeTabModel) SimExplorerTab.synchronize.getModel()).removePropertyChangeListeners();
+ for (SimExplorerTab tab : SimExplorerTab.values()) {
+ tab.removePropertyChangeListeners();
+ }
ConnectAction connectAction = (ConnectAction) SimExplorerActionManager.newAction("connect", (AbstractButton) null);
connectAction.disposeUI();
ImportAction importAction = (ImportAction) SimExplorerActionManager.newAction("importElement", (AbstractButton) null);
@@ -156,7 +154,7 @@
if (conf.isShowRemoteTab()) {
// show remote tab
mainUI.getToggleTab_remote().doClick();
- }
+ }
}
mainUI.setVisible(true);
}
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ListTabRefreshHelper.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ListTabRefreshHelper.java 2008-02-16 18:59:21 UTC (rev 1032)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/ListTabRefreshHelper.java 2008-02-16 20:12:51 UTC (rev 1033)
@@ -56,18 +56,12 @@
public void run() {
// refresh search text
- ui.getSearchText().setText(model.getQuery());
+ ui.getSearchText().setText(model.getQuery().getQuery());
// refresh search actions
refreshSearchActions(ui, model);
- // refresh changePage combobox
- refreshChangePageCombo(ui, model);
-
- // refresh changeSizor combo
- refreshChangeSizorCombo(ui, model);
-
- // refresh pagination buttons
+ // refresh pagination actions
refreshPagination(ui, model.getPagination());
// table data model may have changed, must revalidate
@@ -100,7 +94,7 @@
boolean isConnected = SimExplorer.getContext().isConnected();
boolean enabled = isConnected && EntityHelper.Action.EXPORT.accept(data);
- MainUIRefreshHelper.refreshExportAction(enabled,model.isRemote(),text,ui.getExportElement());
+ MainUIRefreshHelper.refreshExportAction(enabled, model.isRemote(), text, ui.getExportElement());
tooltip = _("simexplorer.action.show.detail.tooltip", text);
MainUIRefreshHelper.updateButton(ui.getShowTab_detail(), true, tooltip);
@@ -117,20 +111,28 @@
*/
public static void refreshSearchActions(JListTab ui, ListTabModel model) {
String text = ui.getSearchText().getText();
- ui.getSearch().setEnabled(model.hasQuery() || !text.isEmpty());
- ui.getResetSearch().setEnabled(model.hasQuery() || !text.isEmpty());
+ boolean hasQuery = model.getQuery().hasQuery();
+ ui.getSearch().setEnabled(hasQuery || !text.isEmpty());
+ ui.getResetSearch().setEnabled(hasQuery || !text.isEmpty());
}
public static void refreshPagination(JListTab ui, PaginationModel pagination) {
+
+ // refresh changePage combobox
+ refreshChangePageCombo(ui, pagination);
+
+ // refresh changeSizor combo
+ refreshChangeSizorCombo(ui, pagination);
+
int page = pagination.getCurrentPage();
boolean notLast = page + 1 < pagination.getNbPages();
ui.getGoNextPage().setEnabled(notLast);
ui.getGoLastPage().setEnabled(notLast);
}
- public static void refreshChangeSizorCombo(JListTab ui, ListTabModel model) {
+ public static void refreshChangeSizorCombo(JListTab ui, PaginationModel pagination) {
JComboBox combo = ui.getChangeSizor();
- String s = model.getPagination().getWidth() + "";
+ String s = pagination.getWidth() + "";
if (!s.equals(String.valueOf(combo.getSelectedItem()))) {
combo.setEnabled(false);
combo.setSelectedItem(s);
@@ -138,9 +140,9 @@
}
}
- public static void refreshChangePageCombo(JListTab ui, ListTabModel model) {
+ public static void refreshChangePageCombo(JListTab ui, PaginationModel pagination) {
JComboBox combo = ui.getGoPage();
- long size = model.getPagination().getNbPages();
+ long size = pagination.getNbPages();
combo.setEnabled(false);
//System.out.println("page old size : " + combo.getItemCount() + " new size : " + size);
if (size < combo.getItemCount()) {
@@ -154,7 +156,7 @@
}
//System.out.println("new page size : " + combo.getItemCount());
- combo.setSelectedIndex(model.getPagination().getCurrentPage());
+ combo.setSelectedIndex(pagination.getCurrentPage());
boolean b = combo.getItemCount() > 1;
combo.setEnabled(b);
ui.getCurrentPage().setEnabled(b);
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerTab.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerTab.java 2008-02-16 18:59:21 UTC (rev 1032)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerTab.java 2008-02-16 20:12:51 UTC (rev 1033)
@@ -20,13 +20,11 @@
import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel;
import fr.cemagref.simexplorer.is.ui.swing.model.ListTabModel;
+import fr.cemagref.simexplorer.is.ui.swing.model.SimExplorerTabModel;
import fr.cemagref.simexplorer.is.ui.swing.model.SynchronizeTabModel;
+import jaxx.runtime.builder.TabContentConfig;
import jaxx.runtime.swing.JAXXTab;
-import jaxx.runtime.builder.TabContentConfig;
-import jaxx.runtime.builder.TabFactory;
-import jaxx.runtime.builder.TabModel;
-import javax.swing.JComponent;
import javax.swing.JTabbedPane;
/**
@@ -73,9 +71,9 @@
)synchronize;
/** l'usine de tabs */
- private static TabFactory factory;
+ private static SimExplorerTabFactory factory;
- public static TabFactory getFactory() {
+ public static SimExplorerTabFactory getFactory() {
if (factory == null) {
factory = new SimExplorerTabFactory();
}
@@ -86,7 +84,7 @@
return getFactory().getUI(name());
}
- public TabModel getModel() {
+ public SimExplorerTabModel getModel() {
return getFactory().getModel(name());
}
@@ -95,6 +93,13 @@
return ui != null && getFactory().getTabIndex(container, ui) > -1;
}
+ public boolean isTabSelected(JTabbedPane container) {
+ if (!isTabVisible(container)) {
+ return false;
+ }
+ return getFactory().getTabIndex(container, getUI()) == container.getSelectedIndex();
+ }
+
public int getTabIndex(JTabbedPane container) {
JAXXTab ui = getUI();
return ui == null ? -1 : getFactory().getTabIndex(container, ui);
@@ -108,4 +113,7 @@
getFactory().closeTab(container, name());
}
+ public void removePropertyChangeListeners() {
+ getModel().removePropertyChangeListeners();
+ }
}
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerTabFactory.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerTabFactory.java 2008-02-16 18:59:21 UTC (rev 1032)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerTabFactory.java 2008-02-16 20:12:51 UTC (rev 1033)
@@ -18,13 +18,14 @@
* ##% */
package fr.cemagref.simexplorer.is.ui.swing;
+import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException;
import fr.cemagref.simexplorer.is.ui.SimExplorer;
-import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException;
+import fr.cemagref.simexplorer.is.ui.swing.model.SimExplorerTabModel;
import fr.cemagref.simexplorer.is.ui.swing.util.MyTabHeader;
import jaxx.runtime.JAXXObject;
-import jaxx.runtime.swing.JAXXTab;
import jaxx.runtime.builder.TabContentConfig;
import jaxx.runtime.builder.TabFactory;
+import jaxx.runtime.swing.JAXXTab;
import static org.codelutin.i18n.I18n._;
import javax.swing.AbstractButton;
@@ -60,7 +61,7 @@
}
protected void initTab(JAXXTab tab, String tabName, TabContentConfig config) {
- SimExplorerActionManager.loadActions((JAXXObject) tab, getTab(tabName));
+ SimExplorerActionManager.loadActions((JAXXObject) tab, getTab(tabName));
}
protected SimExplorerTab getTab(String tabName) {
@@ -68,6 +69,11 @@
}
@Override
+ public SimExplorerTabModel getModel(String tabName) {
+ return (SimExplorerTabModel) super.getModel(tabName);
+ }
+
+ @Override
protected JComponent addTabHeader(final JTabbedPane container,
String tabName,
TabContentConfig tab,
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DetailTabModel.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DetailTabModel.java 2008-02-16 18:59:21 UTC (rev 1032)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DetailTabModel.java 2008-02-16 20:12:51 UTC (rev 1033)
@@ -22,14 +22,9 @@
import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
import fr.cemagref.simexplorer.is.entities.metadata.Version;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
-import jaxx.runtime.builder.TabModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-
/**
* Le model pour un Tab contenant le détail d'une application.
* <p/>
@@ -37,13 +32,11 @@
*
* @author chemit
*/
-public class DetailTabModel implements TabModel {
+public class DetailTabModel extends SimExplorerTabModel {
- public enum Properties {
- SELECTED_NODE_PROPERTY_CHANGED,
- SELECTED_VERSION_INDEX_PROPERTY_CHANGED,
- SELECTED_ATTACHMENT_INDEX_PROPERTY_CHANGED
- }
+ public static final String SELECTED_NODE_PROPERTY_CHANGED = "selectedNodePropertyChanged";
+ public static final String SELECTED_VERSION_INDEX_PROPERTY_CHANGED = "selectedVersionIndexPropertyChanged";
+ public static final String SELECTED_ATTACHMENT_INDEX_PROPERTY_CHANGED = "selectedAttachmentIndexPropertyChanged";
private static final int HISTORY_CAPACITY = 20;
@@ -51,12 +44,6 @@
static protected Log log = LogFactory.getLog(DetailTabModel.class);
- /** ? */
- protected SimExplorerTab tab;
-
- /** flag pour savoir si on est dans le cas local ou remote */
- protected boolean remote;
-
/** le LoggableElement root de l'arbre de navigation */
protected LoggableElement rootNode;
@@ -93,14 +80,6 @@
protected HistoryModel<LoggableElementTreeNode> history;
- public String getName() {
- return tab.name();
- }
-
- public boolean isRemote() {
- return remote;
- }
-
public LoggableElement getRootNode() {
return rootNode;
}
@@ -140,14 +119,6 @@
return history;
}
- public void setRemote(boolean remote) {
- this.remote = remote;
- }
-
- public void setName(String name) {
- this.tab = SimExplorerTab.valueOf(name);
- }
-
public void setRootNode(LoggableElement rootNode) {
this.rootNode = rootNode;
}
@@ -156,7 +127,7 @@
LoggableElement oldSelectedNode = this.selectedNode;
this.selectedNode = selectedNode;
// ui must build a list of versions for this node (if not null)
- firePropertyChange(Properties.SELECTED_NODE_PROPERTY_CHANGED, oldSelectedNode, selectedNode);
+ firePropertyChange(SELECTED_NODE_PROPERTY_CHANGED, oldSelectedNode, selectedNode);
}
public void setSelectedVersion(Version version) {
@@ -164,14 +135,14 @@
Integer oldSelectedVersionIndex = this.selectedVersionIndex;
this.selectedVersionIndex = index;
// ui must update detail panel for the selected node and version
- firePropertyChange(Properties.SELECTED_VERSION_INDEX_PROPERTY_CHANGED, oldSelectedVersionIndex, selectedVersionIndex);
+ firePropertyChange(SELECTED_VERSION_INDEX_PROPERTY_CHANGED, oldSelectedVersionIndex, selectedVersionIndex);
}
public void setSelectedAttachmentIndex(Integer selectedAttachmentIndex) {
Integer oldSelectedAttachmentIndex = this.selectedAttachmentIndex;
this.selectedAttachmentIndex = selectedAttachmentIndex;
// ui must update button downloadAttachment accessibility
- firePropertyChange(Properties.SELECTED_ATTACHMENT_INDEX_PROPERTY_CHANGED, oldSelectedAttachmentIndex, selectedAttachmentIndex);
+ firePropertyChange(SELECTED_ATTACHMENT_INDEX_PROPERTY_CHANGED, oldSelectedAttachmentIndex, selectedAttachmentIndex);
}
public void clear() {
@@ -200,6 +171,7 @@
}
public void reset() {
+ super.reset();
rootNode = null;
resetSelectedNode();
}
@@ -216,57 +188,4 @@
selectedAttachmentIndex = null;
}
- protected PropertyChangeSupport changeSupport;
-
- public synchronized void addPropertyChangeListener(Properties propertyName, PropertyChangeListener listener) {
- if (listener == null) {
- return;
- }
- if (changeSupport == null) {
- changeSupport = new PropertyChangeSupport(this);
- }
- changeSupport.addPropertyChangeListener(propertyName.name(), listener);
- }
-
- public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
- if (listener == null) {
- return;
- }
- if (changeSupport == null) {
- changeSupport = new PropertyChangeSupport(this);
- }
- changeSupport.addPropertyChangeListener(listener);
- }
-
- public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
- if (listener == null || changeSupport == null) {
- return;
- }
- changeSupport.removePropertyChangeListener(listener);
- }
-
- public synchronized void removePropertyChangeListeners() {
- if (changeSupport == null) {
- return;
- }
- for (PropertyChangeListener listener : getPropertyChangeListeners()) {
- changeSupport.removePropertyChangeListener(listener);
- }
- }
-
- public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
- if (changeSupport == null) {
- return new PropertyChangeListener[0];
- }
- return changeSupport.getPropertyChangeListeners();
- }
-
- public void firePropertyChange(Properties propertyName, Object oldValue, Object newValue) {
- if (changeSupport == null || (oldValue == null && newValue == null) ||
- (oldValue != null && oldValue.equals(newValue))) {
- return;
- }
- changeSupport.firePropertyChange(propertyName.name(), oldValue, newValue);
- }
-
}
\ No newline at end of file
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/ListTabModel.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/ListTabModel.java 2008-02-16 18:59:21 UTC (rev 1032)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/ListTabModel.java 2008-02-16 20:12:51 UTC (rev 1033)
@@ -21,62 +21,52 @@
import fr.cemagref.simexplorer.is.entities.metadata.MetaData;
import fr.cemagref.simexplorer.is.ui.SimExplorerContext;
import fr.cemagref.simexplorer.is.ui.StorageServiceHelper;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
-import jaxx.runtime.builder.TabModel;
/**
* Le model pour un Tab contenant une liste d'application
*
* @author chemit
*/
-public class ListTabModel implements TabModel {
+public class ListTabModel extends SimExplorerTabModel {
- protected SimExplorerTab tab;
+ protected QueryModel query;
- protected String query;
-
protected PaginationModel pagination;
protected MetaData[] list;
- protected boolean onlyLatest;
-
- protected int dateOrder;
-
protected int selectedIndex;
- protected boolean remote;
-
private static final long serialVersionUID = -3623331875470531459L;
- public String getName() {
- return tab.name();
+ public MetaData[] getList() {
+ return list;
}
- public SimExplorerTab getTab() {
- return tab;
+ public PaginationModel getPagination() {
+ if (pagination == null) {
+ pagination = new PaginationModel();
+ }
+ return pagination;
}
- public boolean isRemote() {
- return remote;
- }
-
- public boolean hasQuery() {
- return query != null && !query.isEmpty();
- }
-
- public String getQuery() {
+ public QueryModel getQuery() {
+ if (query == null) {
+ query = new QueryModel();
+ }
return query;
}
- public MetaData[] getList() {
- return list;
+ @Override
+ public void reset() {
+ super.reset();
+ list = null;
+ selectedIndex = -1;
+ query = null;
+ pagination = null;
+ query = null;
}
- public PaginationModel getPagination() {
- return pagination;
- }
-
public MetaData get(int index) {
checkSize(index);
return getList()[index];
@@ -94,14 +84,6 @@
return selectedIndex;
}
- public int getDateOrder() {
- return dateOrder;
- }
-
- public boolean isOnlyLatest() {
- return onlyLatest;
- }
-
@Override
public String toString() {
String s = super.toString();
@@ -113,60 +95,61 @@
//TODO should fire a property_changed
}
- public void setQuery(String query) {
- this.query = query;
- }
-
public void setPagination(PaginationModel pagination) {
this.pagination = pagination;
}
- public void setName(String name) {
- this.tab = SimExplorerTab.valueOf(name);
+ public void setQuery(QueryModel query) {
+ this.query = query;
}
public void setList(MetaData[] list) {
this.list = list;
}
- public void setOnlyLatest(boolean onlyLatest) {
- this.onlyLatest = onlyLatest;
- }
+ public void initTabModel(SimExplorerContext context, boolean remote) throws Exception {
+ // first local query, build model
- public void setDateOrder(int dateOrder) {
- this.dateOrder = dateOrder;
+ setRemote(remote);
+
+ updateTabModel(context, remote);
}
- public void initTabModel(boolean remote, SimExplorerContext context) throws Exception {
- // first local query, build model
- String query = getQuery();
- this.remote = remote;
- long size = StorageServiceHelper.getCount(context, remote, query, isOnlyLatest());
+ public void updateTabModel(SimExplorerContext context, boolean remote) throws Exception {
+
// init pagination
- PaginationModel paginationModel = new PaginationModel();
- paginationModel.setFirstIndex(0);
- paginationModel.setSize(size);
- // utilisation sizor par défaut
- paginationModel.setWidth(context.getConfig().getSizor());
- setPagination(paginationModel);
+ PaginationModel paginationModel;
+ paginationModel = pagination == null ? initPagination(context, remote) : pagination;
+ // init query model
+ QueryModel queryModel;
+ queryModel = getQuery();
+
// obtain datas from service
- MetaData[] data = StorageServiceHelper.getData(context, remote, isOnlyLatest(), query, (int) paginationModel.getFirstIndex(), paginationModel.getWidth(), getDateOrder());
+ MetaData[] data = StorageServiceHelper.getData(context, remote, queryModel.isOnlyLatest(), queryModel.getQuery(), (int) paginationModel.getFirstIndex(), paginationModel.getWidth(), queryModel.getDateOrder());
// save in model
setList(data);
}
- public void updateTabModel(boolean remote, SimExplorerContext context) throws Exception {
+ protected PaginationModel initPagination(SimExplorerContext context, boolean remote) {
+ QueryModel queryModel;
+ queryModel = getQuery();
+ String query = queryModel.getQuery();
+ // get size list
+ long size = StorageServiceHelper.getCount(context, remote, query, queryModel.isOnlyLatest());
+
// init pagination
PaginationModel paginationModel = getPagination();
+ paginationModel.setFirstIndex(0);
+ paginationModel.setSize(size);
+ // utilisation sizor par défaut
+ paginationModel.setWidth(context.getConfig().getSizor());
- // obtain datas from service
- MetaData[] data = StorageServiceHelper.getData(context, remote, isOnlyLatest(), getQuery(), (int) paginationModel.getFirstIndex(), paginationModel.getWidth(), getDateOrder());
-
- // save in model
- setList(data);
+ // save pagination in model
+ setPagination(paginationModel);
+ return paginationModel;
}
private void checkSize(int index) {
Added: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/QueryModel.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/QueryModel.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/QueryModel.java 2008-02-16 20:12:51 UTC (rev 1033)
@@ -0,0 +1,81 @@
+/*
+* ##% Copyright (C) 2007, 2008 Code Lutin, Tony Chemit, Gabriel Landais
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package fr.cemagref.simexplorer.is.ui.swing.model;
+
+import java.io.Serializable;
+
+/**
+ * Le modele d'une recherche sur des loggable element.
+ *
+ * @author chemit
+ */
+public class QueryModel implements Serializable {
+
+ protected boolean simpleQuery = true;
+
+ protected String query;
+
+ protected boolean onlyLatest = true;
+
+ protected int dateOrder = -1;
+
+ private static final long serialVersionUID = -5018101346037499469L;
+
+ public boolean hasQuery() {
+ return query != null && !query.isEmpty();
+ }
+
+ public int getDateOrder() {
+ return dateOrder;
+ }
+
+ public boolean isOnlyLatest() {
+ return onlyLatest;
+ }
+
+ public String getQuery() {
+ return query;
+ }
+
+ public boolean isSimpleQuery() {
+ return simpleQuery;
+ }
+
+ public void setDateOrder(int dateOrder) {
+ this.dateOrder = dateOrder;
+ }
+
+ public void setOnlyLatest(boolean onlyLatest) {
+ this.onlyLatest = onlyLatest;
+ }
+
+ public void setQuery(String query) {
+ this.query = query;
+ }
+
+ public void setSimpleQuery(boolean simpleQuery) {
+ this.simpleQuery = simpleQuery;
+ }
+
+ public void reset() {
+ simpleQuery = true;
+ query = null;
+ onlyLatest = true;
+ dateOrder = -1;
+ }
+}
Added: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/SimExplorerTabModel.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/SimExplorerTabModel.java (rev 0)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/SimExplorerTabModel.java 2008-02-16 20:12:51 UTC (rev 1033)
@@ -0,0 +1,116 @@
+/*
+* ##% Copyright (C) 2007, 2008 Code Lutin, Tony Chemit, Gabriel Landais
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* ##% */
+package fr.cemagref.simexplorer.is.ui.swing.model;
+
+import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
+import jaxx.runtime.builder.TabModel;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+/**
+ * Le model d'onglet de l'application
+ *
+ * @author chemit
+ * @see TabModel
+ * @see SimExplorerTab
+ */
+public abstract class SimExplorerTabModel implements TabModel {
+
+ /** l'onglet associé au model */
+ protected SimExplorerTab tab;
+
+ /** flag pour savoir si la source est remote ou non */
+ protected Boolean remote;
+
+ /** support pourles changements des propriétés */
+ protected PropertyChangeSupport changeSupport;
+
+ private static final long serialVersionUID = 4136959472154027361L;
+
+ public String getName() {
+ return tab.name();
+ }
+
+ public boolean isRemote() {
+ return remote;
+ }
+
+ public void setName(String name) {
+ this.tab = SimExplorerTab.valueOf(name);
+ }
+
+ public void setRemote(boolean remote) {
+ this.remote = remote;
+ }
+
+ public void reset() {
+ remote = null;
+ }
+
+ public synchronized void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ if (listener == null) {
+ return;
+ }
+ if (changeSupport == null) {
+ changeSupport = new PropertyChangeSupport(this);
+ }
+ changeSupport.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
+ if (listener == null) {
+ return;
+ }
+ if (changeSupport == null) {
+ changeSupport = new PropertyChangeSupport(this);
+ }
+ changeSupport.addPropertyChangeListener(listener);
+ }
+
+ public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
+ if (listener == null || changeSupport == null) {
+ return;
+ }
+ changeSupport.removePropertyChangeListener(listener);
+ }
+
+ public synchronized void removePropertyChangeListeners() {
+ if (changeSupport == null) {
+ return;
+ }
+ for (PropertyChangeListener listener : getPropertyChangeListeners()) {
+ changeSupport.removePropertyChangeListener(listener);
+ }
+ }
+
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
+ if (changeSupport == null) {
+ return new PropertyChangeListener[0];
+ }
+ return changeSupport.getPropertyChangeListeners();
+ }
+
+ public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ if (changeSupport == null || (oldValue == null && newValue == null) ||
+ (oldValue != null && oldValue.equals(newValue))) {
+ return;
+ }
+ changeSupport.firePropertyChange(propertyName, oldValue, newValue);
+ }
+}
Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/SynchronizeTabModel.java
===================================================================
--- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/SynchronizeTabModel.java 2008-02-16 18:59:21 UTC (rev 1032)
+++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/SynchronizeTabModel.java 2008-02-16 20:12:51 UTC (rev 1033)
@@ -19,29 +19,18 @@
package fr.cemagref.simexplorer.is.ui.swing.model;
import fr.cemagref.simexplorer.is.entities.data.LoggableElement;
-import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab;
-import jaxx.runtime.builder.TabModel;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-
/**
* Le model pour un Tab contenant 2 listes d'applications
*
* @author chemit
*/
-public class SynchronizeTabModel implements TabModel {
+public class SynchronizeTabModel extends SimExplorerTabModel {
- public enum Properties {
- SELECTED_LOCAL_NODE_PROPERTY_CHANGED,
- SELECTED_REMOTE_NODE_PROPERTY_CHANGED
- }
+ public static final String SELECTED_LOCAL_NODE_PROPERTY_CHANGED = "selectedLocalNodePropertyChanged";
- protected SimExplorerTab tab;
+ public static final String SELECTED_REMOTE_NODE_PROPERTY_CHANGED = "selectedRemoteNodePropertyChanged";
- /** flag pour savoir si la source est remote ou non */
- protected boolean remote;
-
private static final long serialVersionUID = -3623331875470531459L;
/** l'élément source de la demande de synchronisation */
@@ -50,18 +39,12 @@
/** l'élément destination de la demande de synchronisation */
protected LoggableElement source;
+ /** l'élément dans l'arbre de navigation sélectionné dans l'abre distant */
protected LoggableElement remoteSelectedNode;
+ /** l'élément dans l'arbre de navigation sélectionné dans l'abre local */
protected LoggableElement localSelectedNode;
- public String getName() {
- return tab.name();
- }
-
- public boolean isRemote() {
- return remote;
- }
-
public LoggableElement getSource() {
return source;
}
@@ -78,14 +61,6 @@
return remoteSelectedNode;
}
- public void setName(String name) {
- this.tab = SimExplorerTab.valueOf(name);
- }
-
- public void setRemote(boolean remote) {
- this.remote = remote;
- }
-
public void setSource(LoggableElement source) {
this.source = source;
}
@@ -97,70 +72,22 @@
public void setLocalSelectedNode(LoggableElement localSelectedNode) {
LoggableElement oldSelectedNode = this.localSelectedNode;
this.localSelectedNode = localSelectedNode;
- firePropertyChange(Properties.SELECTED_LOCAL_NODE_PROPERTY_CHANGED, oldSelectedNode, localSelectedNode);
+ firePropertyChange(SELECTED_LOCAL_NODE_PROPERTY_CHANGED, oldSelectedNode, localSelectedNode);
}
public void setRemoteSelectedNode(LoggableElement remoteSelectedNode) {
LoggableElement oldSelectedNode = this.remoteSelectedNode;
this.remoteSelectedNode = remoteSelectedNode;
- firePropertyChange(Properties.SELECTED_REMOTE_NODE_PROPERTY_CHANGED, oldSelectedNode, remoteSelectedNode);
+ firePropertyChange(SELECTED_REMOTE_NODE_PROPERTY_CHANGED, oldSelectedNode, remoteSelectedNode);
}
public void resetSelectedNodes() {
localSelectedNode = remoteSelectedNode = null;
}
- protected PropertyChangeSupport changeSupport;
-
- public synchronized void addPropertyChangeListener(Properties propertyName, PropertyChangeListener listener) {
- if (listener == null) {
- return;
- }
- if (changeSupport == null) {
- changeSupport = new PropertyChangeSupport(this);
- }
- changeSupport.addPropertyChangeListener(propertyName.name(), listener);
+ public void reset() {
+ super.reset();
+ resetSelectedNodes();
+ source = destination = null;
}
-
- public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
- if (listener == null) {
- return;
- }
- if (changeSupport == null) {
- changeSupport = new PropertyChangeSupport(this);
- }
- changeSupport.addPropertyChangeListener(listener);
- }
-
- public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
- if (listener == null || changeSupport == null) {
- return;
- }
- changeSupport.removePropertyChangeListener(listener);
- }
-
- public synchronized void removePropertyChangeListeners() {
- if (changeSupport == null) {
- return;
- }
- for (PropertyChangeListener listener : getPropertyChangeListeners()) {
- changeSupport.removePropertyChangeListener(listener);
- }
- }
-
- public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
- if (changeSupport == null) {
- return new PropertyChangeListener[0];
- }
- return changeSupport.getPropertyChangeListeners();
- }
-
- public void firePropertyChange(Properties propertyName, Object oldValue, Object newValue) {
- if (changeSupport == null || (oldValue == null && newValue == null) ||
- (oldValue != null && oldValue.equals(newValue))) {
- return;
- }
- changeSupport.firePropertyChange(propertyName.name(), oldValue, newValue);
- }
-
}
\ No newline at end of file