Author: tchemit Date: 2008-01-22 02:45:23 +0000 (Tue, 22 Jan 2008) New Revision: 373 Added: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/PaginationModel.java Removed: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/bean/ApplicationBean.java trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/bean/ListApplicationBean.java Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DetailTabModel.java trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/ListTabModel.java trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/SynchronizeTabModel.java Log: suppression des beans (on utilise uniquement les model d'ui) Deleted: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/bean/ApplicationBean.java =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/bean/ApplicationBean.java 2008-01-22 02:12:16 UTC (rev 372) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/bean/ApplicationBean.java 2008-01-22 02:45:23 UTC (rev 373) @@ -1,112 +0,0 @@ -/* -* \#\#% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, -* Tony Chemit -* -* 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.bean; - -import fr.cemagref.simexplorer.is.entities.metadata.MetaDataEntity; -import fr.cemagref.simexplorer.is.entities.metadata.Version; -import fr.cemagref.simexplorer.is.contenttype.ContentType; - -import java.util.Map; -import java.util.Date; - -/** - * Le bean qui contient le détail d'une application, ses métat données, ses - * versions. - * <p/> - * - * @author chemit - */ -public class ApplicationBean { - - protected MetaDataEntity data; - - protected Version[] versions; - - public MetaDataEntity getData() { - return data; - } - - public void setData(MetaDataEntity data) { - this.data = data; - } - - public Version[] getVersions() { - return versions; - } - - public void setVersions(Version[] versions) { - this.versions = versions; - } - - public Map<String, ContentType> getAttachments() { - return getData().getAttachments(); - } - - public Date getCreationDate() { - return getData().getCreationDate(); - } - - public String getDescription() { - return getData().getDescription(); - } - - public Map<String, String> getDescriptors() { - return getData().getDescriptors(); - } - - public String getType() { - return getData().getType(); - } - - public boolean isLatest() { - return getData().isLatest(); - } - - public String getHash() { - return getData().getHash(); - } - - public String getName() { - return getData().getName(); - } - - public String getParentDataUuid() { - return getData().getParentDataUuid(); - } - - public String getParentDataVersion() { - return getData().getParentDataVersion(); - } - - public String getParentVersionUuid() { - return getData().getParentVersionUuid(); - } - - public String getParentVersionVersion() { - return getData().getParentVersionVersion(); - } - - public String getUuid() { - return getData().getUuid(); - } - - public Version getVersion() { - return getData().getVersion(); - } -} \ No newline at end of file Deleted: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/bean/ListApplicationBean.java =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/bean/ListApplicationBean.java 2008-01-22 02:12:16 UTC (rev 372) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/bean/ListApplicationBean.java 2008-01-22 02:45:23 UTC (rev 373) @@ -1,84 +0,0 @@ -/* -* \#\#% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, -* Tony Chemit -* -* 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.bean; - -import fr.cemagref.simexplorer.is.entities.metadata.MetaDataEntity; - -/** - * Le bean qui contient la liste des meta données des applications, - * ainsi que la position du premier élément de la liste dans le flux d'origin, - * le model de pagination - * <p/> - * On conserve enfin ici aussi la requete de recherche'index du premier élément de la dans le flux - * - * @author chemit - */ -public class ListApplicationBean { - - protected String query; - - protected PaginationBean pagination; - - protected MetaDataEntity[] list; - - public MetaDataEntity[] getList() { - return list; - } - - public String getQuery() { - return query; - } - - public void setQuery(String query) { - this.query = query; - } - - public PaginationBean getPagination() { - return pagination; - } - - public void setPagination(PaginationBean pagination) { - this.pagination = pagination; - } - - public void setList(MetaDataEntity[] list) { - this.list = list; - } - - public MetaDataEntity get(int index) { - checkSize(index); - return getList()[index]; - } - - private void checkSize(int index) { - if (isEmpty() || size() < index) { - throw new IllegalStateException(getClass() + " has size " + size() + " and was required index " + index); - } - } - - public boolean isEmpty() { - return getList().length == 0; - } - - public int size() { - return isEmpty() ? 0 : list.length; - } - - -} Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DetailTabModel.java =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DetailTabModel.java 2008-01-22 02:12:16 UTC (rev 372) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DetailTabModel.java 2008-01-22 02:45:23 UTC (rev 373) @@ -18,10 +18,15 @@ * \#\#% */ package fr.cemagref.simexplorer.is.ui.swing.model; +import fr.cemagref.simexplorer.is.contenttype.ContentType; +import fr.cemagref.simexplorer.is.entities.metadata.MetaDataEntity; +import fr.cemagref.simexplorer.is.entities.metadata.Version; import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab; -import fr.cemagref.simexplorer.is.ui.swing.bean.ApplicationBean; import jaxx.runtime.builder.TabModel; +import java.util.Date; +import java.util.Map; + /** * Le model pour un Tab contenant le détail d'une application * @@ -31,11 +36,12 @@ protected SimExplorerTab tab; - protected ApplicationBean bean; - private static final long serialVersionUID = 4851121531481734868L; + protected MetaDataEntity bean; + protected Version[] versions; + public String getName() { return tab.name(); } @@ -44,15 +50,80 @@ return tab; } - public ApplicationBean getBean() { + public MetaDataEntity getBean() { return bean; } + public Version[] getVersions() { + return versions; + } + + public void setVersions(Version[] versions) { + this.versions = versions; + } + + public Map<String, ContentType> getAttachments() { + return getBean().getAttachments(); + } + + public Date getCreationDate() { + return getBean().getCreationDate(); + } + + public String getDescription() { + return getBean().getDescription(); + } + + public Map<String, String> getDescriptors() { + return getBean().getDescriptors(); + } + + public String getType() { + return getBean().getType(); + } + + public boolean isLatest() { + return getBean().isLatest(); + } + + public String getHash() { + return getBean().getHash(); + } + + public String getApplicationName() { + return getBean().getName(); + } + + public String getParentDataUuid() { + return getBean().getParentDataUuid(); + } + + public String getParentDataVersion() { + return getBean().getParentDataVersion(); + } + + public String getParentVersionUuid() { + return getBean().getParentVersionUuid(); + } + + public String getParentVersionVersion() { + return getBean().getParentVersionVersion(); + } + + public String getUuid() { + return getBean().getUuid(); + } + + public Version getVersion() { + return getBean().getVersion(); + } + public void setName(String name) { this.tab = SimExplorerTab.valueOf(name); } - public void setBean(ApplicationBean bean) { + public void setBean(MetaDataEntity bean) { this.bean = bean; } + } \ No newline at end of file Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/ListTabModel.java =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/ListTabModel.java 2008-01-22 02:12:16 UTC (rev 372) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/ListTabModel.java 2008-01-22 02:45:23 UTC (rev 373) @@ -18,8 +18,9 @@ * \#\#% */ package fr.cemagref.simexplorer.is.ui.swing.model; +import fr.cemagref.simexplorer.is.entities.metadata.MetaDataEntity; import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab; -import fr.cemagref.simexplorer.is.ui.swing.bean.ListApplicationBean; +import fr.cemagref.simexplorer.is.ui.swing.model.PaginationModel; import jaxx.runtime.builder.TabModel; /** @@ -31,8 +32,13 @@ protected SimExplorerTab tab; - protected ListApplicationBean list; + protected String query; + protected PaginationModel pagination; + + protected MetaDataEntity[] list; + + private static final long serialVersionUID = -3623331875470531459L; public String getName() { @@ -43,15 +49,57 @@ return tab; } - public ListApplicationBean getList() { + public String getQuery() { + return query; + } + + public MetaDataEntity[] getList() { return list; } + public PaginationModel getPagination() { + return pagination; + } + + public MetaDataEntity get(int index) { + checkSize(index); + return getList()[index]; + } + + public boolean isEmpty() { + return list == null || getList().length == 0; + } + + public int size() { + return isEmpty() ? 0 : list.length; + } + + private void checkSize(int index) { + if (isEmpty() || size() < index) { + throw new IllegalStateException(getClass() + " has size " + size() + " and was required index " + index); + } + } + + @Override + public String toString() { + String s = super.toString(); + return s.substring(s.lastIndexOf(".") + 1) + "<size: " + size() + ">"; + } + + 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 setList(ListApplicationBean list) { + + public void setList(MetaDataEntity[] list) { this.list = list; } } Copied: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/PaginationModel.java (from rev 354, trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/bean/PaginationBean.java) =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/PaginationModel.java (rev 0) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/PaginationModel.java 2008-01-22 02:45:23 UTC (rev 373) @@ -0,0 +1,96 @@ +/* +* \#\#% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, +* Tony Chemit +* +* 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; + +/** + * Le modèle de pagination d'une liste + * + * @author tony + */ +public class PaginationModel { + + /** the index */ + long firstIndex; + + /** size of the total flow */ + long size; + + /** size of a page */ + int width; + + public long getFirstIndex() { + return firstIndex; + } + + public long getSize() { + return size; + } + + public int getWidth() { + return width; + } + + public boolean hasNext() { + return size - firstIndex > width; + } + + public boolean hasPrevious() { + return firstIndex >= width; + } + + public int getCurrentPage() { + int page = (int) (firstIndex / width); + if (page > 0 && firstIndex % width > 0) { + page++; + } + return page; + } + + public int getNbPages() { + return (int) (size / width); + } + + public void increment() { + if (firstIndex + width > size) { + firstIndex = size - width; + return; + } + firstIndex += width; + } + + public void decrement() { + if (firstIndex < width) { + firstIndex = 0; + } else { + firstIndex -= width; + } + } + + public void setFirstIndex(long firstIndex) { + this.firstIndex = firstIndex; + } + + public void setSize(long size) { + this.size = size; + } + + public void setWidth(int width) { + this.width = width; + } +} Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/SynchronizeTabModel.java =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/SynchronizeTabModel.java 2008-01-22 02:12:16 UTC (rev 372) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/SynchronizeTabModel.java 2008-01-22 02:45:23 UTC (rev 373) @@ -18,8 +18,8 @@ * \#\#% */ package fr.cemagref.simexplorer.is.ui.swing.model; +import fr.cemagref.simexplorer.is.entities.metadata.MetaDataEntity; import fr.cemagref.simexplorer.is.ui.swing.SimExplorerTab; -import fr.cemagref.simexplorer.is.ui.swing.bean.ListApplicationBean; import jaxx.runtime.builder.TabModel; /** @@ -31,8 +31,8 @@ protected SimExplorerTab tab; - protected ListApplicationBean listLocal; - protected ListApplicationBean listRemote; + protected MetaDataEntity[] listLocal; + protected MetaDataEntity[] listRemote; private static final long serialVersionUID = -3623331875470531459L; @@ -44,11 +44,11 @@ return tab; } - public ListApplicationBean getListLocal() { + public MetaDataEntity[] getListLocal() { return listLocal; } - public ListApplicationBean getListRemote() { + public MetaDataEntity[] getListRemote() { return listRemote; } @@ -56,11 +56,11 @@ this.tab = SimExplorerTab.valueOf(name); } - public void setListLocal(ListApplicationBean listLocal) { + public void setListLocal(MetaDataEntity[] listLocal) { this.listLocal = listLocal; } - public void setListRemote(ListApplicationBean listRemote) { + public void setListRemote(MetaDataEntity[] listRemote) { this.listRemote = listRemote; } } \ No newline at end of file
participants (1)
-
tchemit@users.labs.libre-entreprise.org