Index: topia/src/java/org/codelutin/topia/ui/swing/SelectionButtonsPanel.java diff -u topia/src/java/org/codelutin/topia/ui/swing/SelectionButtonsPanel.java:1.2 topia/src/java/org/codelutin/topia/ui/swing/SelectionButtonsPanel.java:1.3 --- topia/src/java/org/codelutin/topia/ui/swing/SelectionButtonsPanel.java:1.2 Wed Aug 11 07:10:38 2004 +++ topia/src/java/org/codelutin/topia/ui/swing/SelectionButtonsPanel.java Thu Sep 2 15:42:54 2004 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * - * Mise a jour: $Date: 2004/08/11 07:10:38 $ + * Mise a jour: $Date: 2004/09/02 15:42:54 $ * par : $Author: mazelier $ */ @@ -42,8 +42,9 @@ public class SelectionButtonsPanel extends TopiaPanel{ // SelectionButtonsPanel + JButton buttonAdd = new JButton("Add"); JButton buttonSelectAll = new JButton("Select All"); - JButton buttonReset = new JButton("Reset"); + JButton buttonRemoveSelection = new JButton("Remove Selection"); JButton buttonOk = new JButton("Ok"); JButton buttonCancel = new JButton("Cancel"); @@ -64,25 +65,34 @@ setLayout(layout); - //Bouton Select All + //Bouton Add constraint.gridx=0; constraint.gridy=0; constraint.fill=GridBagConstraints.HORIZONTAL; + addButton(buttonAdd, layout, constraint); + // Ajout d'un event + Object l = EventHandler.create(ActionListener.class, this, "on_add"); + buttonAdd.addActionListener((ActionListener)l); + + //Bouton Select All + constraint.gridx=1; + constraint.gridy=0; + constraint.fill=GridBagConstraints.HORIZONTAL; addButton(buttonSelectAll, layout, constraint); // Ajout d'un event - Object l = EventHandler.create(ActionListener.class, this, "on_selectAll"); + l = EventHandler.create(ActionListener.class, this, "on_selectAll"); buttonSelectAll.addActionListener((ActionListener)l); - //Bouton Reset - constraint.gridx=1; + //Bouton RemoveSelection + constraint.gridx=2; constraint.gridy=0; - addButton(buttonReset, layout, constraint); + addButton(buttonRemoveSelection, layout, constraint); // Ajout d'un event - l = EventHandler.create(ActionListener.class, this, "on_reset"); - buttonReset.addActionListener((ActionListener)l); + l = EventHandler.create(ActionListener.class, this, "on_removeSelection"); + buttonRemoveSelection.addActionListener((ActionListener)l); //Bouton Ok - constraint.gridx=2; + constraint.gridx=3; constraint.gridy=0; addButton(buttonOk, layout, constraint); // Ajout d'un event @@ -90,7 +100,7 @@ buttonOk.addActionListener((ActionListener)l); //Bouton Cancel - constraint.gridx=3; + constraint.gridx=4; constraint.gridy=0; addButton(buttonCancel, layout, constraint); // Ajout d'un event Index: topia/src/java/org/codelutin/topia/ui/swing/TopiaTableModel.java diff -u topia/src/java/org/codelutin/topia/ui/swing/TopiaTableModel.java:1.5 topia/src/java/org/codelutin/topia/ui/swing/TopiaTableModel.java:1.6 --- topia/src/java/org/codelutin/topia/ui/swing/TopiaTableModel.java:1.5 Sun Aug 15 13:57:17 2004 +++ topia/src/java/org/codelutin/topia/ui/swing/TopiaTableModel.java Thu Sep 2 15:42:54 2004 @@ -79,11 +79,11 @@ this.persistenceService = persistenceService; this.persistenceService.addTopiaEntityListener(this); } - + public TopiaPersistenceService getPersistenceService() { return this.persistenceService; } - + public void setContext(TopiaContext context) throws TopiaException{ this.context = context; eventOccured(); @@ -123,7 +123,7 @@ throw new TopiaException ("TopiaTableModel : Can't execute TopiaQuery", eee); } } - + public void eventOccured() throws TopiaException { // TODO : rafraichissement nb column, data, ... fetchData(); Index: topia/src/java/org/codelutin/topia/ui/swing/ActionEntityPanel.java diff -u /dev/null topia/src/java/org/codelutin/topia/ui/swing/ActionEntityPanel.java:1.1 --- /dev/null Thu Sep 2 15:42:59 2004 +++ topia/src/java/org/codelutin/topia/ui/swing/ActionEntityPanel.java Thu Sep 2 15:42:54 2004 @@ -0,0 +1,125 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * 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. + *##%*/ + +/* * + * ActionEntityPanel.java + * + * Created: Sep 2, 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/09/02 15:42:54 $ + * par : $Author: mazelier $ + */ + +package org.codelutin.topia.ui.swing; + +import com.l2fprod.common.swing.JLinkButton; + +import org.codelutin.topia.TopiaPersistenceService; +import org.codelutin.topia.TopiaQuery; +import org.codelutin.topia.TopiaEntity; +import org.codelutin.topia.TopiaException; + +import java.awt.GridBagLayout; +import java.awt.GridBagConstraints; + +import java.util.List; + +import javax.swing.JTextField; +import javax.swing.JComboBox; +import javax.swing.JButton; +import java.util.Iterator; + +import org.codelutin.chorem.UIContext; +import java.util.logging.Logger; +import java.util.logging.Level; + +public class ActionEntityPanel extends TopiaPanel{ // ActionEntityPanel + + protected UIContext uicontext = null; + protected TopiaPersistenceService ps = null; + + public ActionEntityPanel(UIContext uicontext, TopiaPersistenceService ps){ + super(); + this.uicontext = uicontext; + this.ps = ps; + init(); + } + + public void init() { + + GridBagLayout layout = new GridBagLayout(); + GridBagConstraints constraint = new GridBagConstraints(); + + setLayout(layout); + + constraint.gridx=0; + constraint.gridy=0; + constraint.fill=GridBagConstraints.HORIZONTAL; + constraint.gridwidth=3; + try{ + TopiaQuery query = ps.newQuery().orderby("_creationDate_ desc"); + List listFields = ps.find(query); + + // add listFields of LinkButton to the Panel + for(Iterator i = listFields.iterator(); i.hasNext();){ + constraint.gridy++; + TopiaEntity field = (TopiaEntity)i.next(); + ShowAction fieldAction = new ShowAction(uicontext, field); + JLinkButton linkButton = new JLinkButton(fieldAction); + add(linkButton, constraint); + } + + // add search + constraint.gridy++; + constraint.gridwidth=1; + }catch(TopiaException eee){ + Logger.getLogger("ActionEntityPanel.init").log(Level.WARNING, "Impossible de recuperer le resultat de la requete"); + } + + // add the combo + constraint.gridx=0; + String [] items = ps.getFieldNames(); + JComboBox combo = new JComboBox(items); + add(combo, constraint); + + // add the textfield + constraint.gridx=1; + JTextField textfield = new JTextField(); + add(textfield, constraint); + + // add the button Search + constraint.gridx=2; + SearchAction searchAction = new SearchAction(uicontext, ps, combo, textfield); + JButton button = new JButton(searchAction); + add(button, constraint); + + // add the linkbutton new + constraint.gridx=0; + constraint.gridy++; + constraint.gridwidth=3; + NewAction newAction = new NewAction(uicontext, ps); + JLinkButton newLinkButton = new JLinkButton(newAction); + add(newLinkButton, constraint); + + } +} // ActionEntityPanel + Index: topia/src/java/org/codelutin/topia/ui/swing/NewAction.java diff -u /dev/null topia/src/java/org/codelutin/topia/ui/swing/NewAction.java:1.1 --- /dev/null Thu Sep 2 15:42:59 2004 +++ topia/src/java/org/codelutin/topia/ui/swing/NewAction.java Thu Sep 2 15:42:54 2004 @@ -0,0 +1,72 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * 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. + *##%*/ + +/* * + * NewAction.java + * + * Created: Sep 2, 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/09/02 15:42:54 $ + * par : $Author: mazelier $ + */ + +package org.codelutin.topia.ui.swing; + +import javax.swing.AbstractAction; + +import org.codelutin.topia.TopiaPersistenceService; +import org.codelutin.topia.TopiaEntity; +import org.codelutin.topia.TopiaException; + +import java.awt.event.ActionEvent; + +import org.codelutin.chorem.UIContext; +import java.util.logging.Logger; +import java.util.logging.Level; + +public class NewAction extends AbstractAction { // NewAction + + protected UIContext uicontext = null; + protected TopiaPersistenceService ps = null; + protected TopiaEntity newEntity = null; + + public NewAction(UIContext uicontext, TopiaPersistenceService ps){ + super("New"); + this.uicontext = uicontext; + this.ps = ps; + init(); + } + + public void init(){ + try{ + newEntity = ps.create(); + putValue("newEntity", newEntity); + }catch(TopiaException eee){ + Logger.getLogger("newAction.init").log(Level.WARNING, "Impossible de creer une nouvelle entite"); + } + } + + public void actionPerformed(ActionEvent e){ + uicontext.edit(getValue("newEntity")); + } +} // NewAction + Index: topia/src/java/org/codelutin/topia/ui/swing/SearchAction.java diff -u /dev/null topia/src/java/org/codelutin/topia/ui/swing/SearchAction.java:1.1 --- /dev/null Thu Sep 2 15:42:59 2004 +++ topia/src/java/org/codelutin/topia/ui/swing/SearchAction.java Thu Sep 2 15:42:54 2004 @@ -0,0 +1,83 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * 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. + *##%*/ + +/* * + * SearchAction.java + * + * Created: Sep 2, 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/09/02 15:42:54 $ + * par : $Author: mazelier $ + */ + +package org.codelutin.topia.ui.swing; + +import javax.swing.AbstractAction; + +import org.codelutin.topia.TopiaPersistenceService; +import org.codelutin.topia.TopiaQuery; +import org.codelutin.topia.TopiaException; + +import java.util.List; +import java.awt.event.ActionEvent; +import javax.swing.JTextField; +import javax.swing.JComboBox; + +import org.codelutin.chorem.UIContext; +import java.util.logging.Logger; +import java.util.logging.Level; + +public class SearchAction extends AbstractAction{ // SearchAction + + protected UIContext uicontext = null; + protected TopiaPersistenceService ps = null; + protected JComboBox combo = null; + protected JTextField textfield = null; + + public SearchAction(UIContext uicontext, TopiaPersistenceService ps, JComboBox combo, JTextField textfield){ + super("Search"); + this.uicontext = uicontext; + this.ps = ps; + this.combo = combo; + this.textfield = textfield; + init(); + } + + public void init(){ + + } + + public void actionPerformed(ActionEvent e){ + try{ + String field = (String)combo.getSelectedItem(); + String condition = field + "=" + textfield.getText(); + TopiaQuery query = ps.newQuery().where(condition); + List resultSearch = ps.find(query); + uicontext.showList(ps, resultSearch); + }catch(TopiaException eee){ + Logger.getLogger("SearchAction.actionPerformed").log(Level.WARNING, "Impossible de recuperer le resultat de la requete"); + } + } + + +} // SearchAction + Index: topia/src/java/org/codelutin/topia/ui/swing/ShowAction.java diff -u /dev/null topia/src/java/org/codelutin/topia/ui/swing/ShowAction.java:1.1 --- /dev/null Thu Sep 2 15:42:59 2004 +++ topia/src/java/org/codelutin/topia/ui/swing/ShowAction.java Thu Sep 2 15:42:54 2004 @@ -0,0 +1,65 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * 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. + *##%*/ + +/* * + * ShowAction.java + * + * Created: Sep 2, 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/09/02 15:42:54 $ + * par : $Author: mazelier $ + */ + +package org.codelutin.topia.ui.swing; + +import javax.swing.AbstractAction; + +import org.codelutin.topia.TopiaPersistenceService; +import org.codelutin.topia.TopiaQuery; +import org.codelutin.topia.TopiaEntity; + +import java.awt.event.ActionEvent; + +import org.codelutin.chorem.UIContext; + +public class ShowAction extends AbstractAction{ // ShowAction + + protected UIContext uicontext = null; + protected TopiaEntity entity = null; + + public ShowAction(UIContext uicontext, TopiaEntity entity){ + super(entity.toString()); + this.uicontext = uicontext; + this.entity = entity; + init(); + } + + public void init(){ + putValue("object", entity); + } + + public void actionPerformed(ActionEvent e){ + uicontext.show(getValue("object")); + } + +} // ShowAction + Index: topia/src/java/org/codelutin/topia/ui/swing/TaskGroupPanel.java diff -u /dev/null topia/src/java/org/codelutin/topia/ui/swing/TaskGroupPanel.java:1.1 --- /dev/null Thu Sep 2 15:42:59 2004 +++ topia/src/java/org/codelutin/topia/ui/swing/TaskGroupPanel.java Thu Sep 2 15:42:54 2004 @@ -0,0 +1,55 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * 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. + *##%*/ + +/* * + * TaskGroupPanel.java + * + * Created: Sep 1, 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/09/02 15:42:54 $ + * par : $Author: mazelier $ + */ + +package org.codelutin.topia.ui.swing; + +import com.l2fprod.common.swing.JTaskPaneGroup; + +import org.codelutin.topia.TopiaPersistenceService; +import org.codelutin.chorem.UIContext; + +public class TaskGroupPanel extends JTaskPaneGroup { // TaskGroupPanel + + public TaskGroupPanel(){ + super(); + init(); + } + + public void init() { + setOpaque(true); + +// UIContext uicontext = new UIContext(); +// TopiaPersistenceService ps = ???; +// ActionEntityPanel panel = new ActionEntityPanel(uiconstext, ps); +// add(panel); + } +} // TaskGroupPanel +