diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2014-10-07 09:18:33 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2014-10-07 09:18:33 +0200 |
| commit | 5e4034b5cba89460a62fa958fc78c2b85acb3d5f (patch) | |
| tree | aa8e32f014801459ad65acdf45eee70d16008fe6 /src/main/java/org/cristalise/gui/lifecycle/chooser | |
| parent | a5a9d90ec6714ad6a9358c35ca7093e5868373f7 (diff) | |
Repackage to org.cristalise
Diffstat (limited to 'src/main/java/org/cristalise/gui/lifecycle/chooser')
4 files changed, 406 insertions, 0 deletions
diff --git a/src/main/java/org/cristalise/gui/lifecycle/chooser/ActivityChooser.java b/src/main/java/org/cristalise/gui/lifecycle/chooser/ActivityChooser.java new file mode 100644 index 0000000..d63a2c5 --- /dev/null +++ b/src/main/java/org/cristalise/gui/lifecycle/chooser/ActivityChooser.java @@ -0,0 +1,195 @@ +/*
+ * Created on 1 sept. 2003
+ *
+ * To change the template for this generated file go to Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package org.cristalise.gui.lifecycle.chooser;
+
+import java.awt.Container;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Image;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.HashMap;
+
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+import org.cristalise.gui.ImageLoader;
+import org.cristalise.kernel.utils.Language;
+import org.cristalise.kernel.utils.Logger;
+
+
+/**
+ * @author Developpement
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class ActivityChooser extends JFrame
+{
+ private LDAPFileChooser mLDAPFileChooserActivity = null;
+
+ private JButton mButtonOK = null;
+
+ private JButton mButtonCancel = null;
+
+ private JPanel mJPanelVertical = null;
+
+ private JPanel mJPanelHorizontal = null;
+
+ private String mMessage = "Choose or modify";
+
+ private WorkflowDialogue mParent = null;
+
+ private JLabel label = null;
+
+ HashMap<String, Object> mhashmap = null;
+
+ public ActivityChooser(String message, String title, Image img, WorkflowDialogue parent, HashMap<String, Object> hashmap)
+ {
+ super(title);
+ mMessage = message;
+ img = ImageLoader.findImage("graph/newvertex_large.png").getImage();
+ setIconImage(img);
+ mParent = parent;
+ mhashmap = hashmap;
+ initialize();
+ }
+
+ private JButton getJButtonOK()
+ {
+ if (mButtonOK == null)
+ mButtonOK = new JButton(Language.translate("OK"));
+ return mButtonOK;
+ }
+
+ private JButton getJButtonCancel()
+ {
+ if (mButtonCancel == null)
+ mButtonCancel = new JButton(Language.translate("Cancel"));
+ return mButtonCancel;
+ }
+
+ private LDAPFileChooser getLDAPFileChooserActivity()
+ {
+ if (mLDAPFileChooserActivity == null)
+ {
+ try
+ {
+ mLDAPFileChooserActivity = new LDAPFileChooser(LDAPFileChooser.ACTIVITY_CHOOSER);
+ mLDAPFileChooserActivity.setName("LDAPFileChooserRouting");
+ mLDAPFileChooserActivity.setEditable(false);
+ //mLDAPFileChooserActivity.setBounds(125, 13, 400, 19);
+ } catch (Exception mExc)
+ {
+ Logger.error(mExc);
+ }
+ }
+ return mLDAPFileChooserActivity;
+ }
+
+ private void initialize()
+ {
+ getJButtonOK().addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ Logger.debug(5, "mLDAPFileChooserActivity.getEntryName()" + mLDAPFileChooserActivity.getEntryName());
+ setCursor(new Cursor(Cursor.WAIT_CURSOR));
+ mParent.loadThisWorkflow(mLDAPFileChooserActivity.getEntryName(), mhashmap);
+ setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
+ close();
+ }
+ });
+ getJButtonCancel().addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ close();
+ }
+ });
+ //getContentPane().add(getJPanelVertical());
+ Container contentPane = getContentPane();
+ contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
+ contentPane.add(getJPanelVertical());
+ contentPane.add(getJPanelHorizontal());
+ contentPane.add(Box.createGlue());
+ Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
+ setLocation((d.width - getWidth()) / 2, (d.height - getHeight()) / 2);
+ setResizable(true);
+ pack();
+ setSize(new Dimension(getWidth(), getJButtonCancel().getHeight() + getLDAPFileChooserActivity().getHeight() + label.getHeight() + 100));
+ setVisible(true);
+ setVisible(true);
+ }
+
+ private void close()
+ {
+ mParent = null;
+ this.setEnabled(false);
+ this.setVisible(false);
+ }
+
+ private JPanel getJPanelVertical()
+ {
+ if (mJPanelVertical == null)
+ {
+ try
+ {
+ Logger.debug(8, "Panel button");
+ mJPanelVertical = new JPanel();
+ mJPanelVertical.setName("JPanelV");
+ mJPanelVertical.setLayout(new BoxLayout(mJPanelVertical, BoxLayout.Y_AXIS));
+ label = new JLabel(mMessage);
+ JPanel labelP = new JPanel();
+ labelP.setLayout(new BoxLayout(labelP, BoxLayout.X_AXIS));
+ labelP.add(label);
+ labelP.add(Box.createGlue());
+ mJPanelVertical.add(labelP);
+ mJPanelVertical.add(Box.createRigidArea(new Dimension(0, 5)));
+ mJPanelVertical.add(getLDAPFileChooserActivity(), getLDAPFileChooserActivity().getName());
+ //mJPanelVertical.add(Box.createRigidArea(new Dimension(0,
+ // 10)));
+ mJPanelVertical.add(Box.createGlue());
+ mJPanelVertical.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ mJPanelVertical.setVisible(true);
+ } catch (java.lang.Throwable mExc)
+ {
+ //handleException(mExc);
+ }
+ }
+ return mJPanelVertical;
+ }
+
+ private JPanel getJPanelHorizontal()
+ {
+ if (mJPanelHorizontal == null)
+ {
+ try
+ {
+ Logger.debug(8, "Panel button");
+ mJPanelHorizontal = new JPanel();
+ mJPanelHorizontal.setName("JPanelH");
+ mJPanelHorizontal.setLayout(new BoxLayout(mJPanelHorizontal, BoxLayout.X_AXIS));
+ mJPanelHorizontal.add(getJButtonOK(), getJButtonOK().getName());
+ mJPanelHorizontal.add(Box.createRigidArea(new Dimension(10, 0)));
+ mJPanelHorizontal.add(getJButtonCancel(), getJButtonCancel().getName());
+ mJPanelHorizontal.setVisible(true);
+ } catch (java.lang.Throwable mExc)
+ {
+ //handleException(mExc);
+ }
+ }
+ return mJPanelHorizontal;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/org/cristalise/gui/lifecycle/chooser/LDAPEntryChooser.java b/src/main/java/org/cristalise/gui/lifecycle/chooser/LDAPEntryChooser.java new file mode 100644 index 0000000..90c759f --- /dev/null +++ b/src/main/java/org/cristalise/gui/lifecycle/chooser/LDAPEntryChooser.java @@ -0,0 +1,71 @@ +package org.cristalise.gui.lifecycle.chooser;
+/**
+ * @version $Revision: 1.2 $ $Date: 2005/12/01 14:23:15 $
+ * @author $Author: abranson $
+ */
+
+import java.awt.Dimension;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+
+import javax.swing.JComboBox;
+
+import org.cristalise.gui.MainFrame;
+import org.cristalise.kernel.lookup.DomainPath;
+import org.cristalise.kernel.process.Gateway;
+
+
+public class LDAPEntryChooser extends JComboBox
+{
+
+ DomainPath mDomainPath = null;
+ ArrayList<String> allItems = new ArrayList<String>();
+
+ public LDAPEntryChooser(DomainPath domPath, boolean editable)
+ {
+ super();
+ setEditable(editable);
+ mDomainPath = domPath;
+ initialise();
+ }
+
+ private void initialise()
+ {
+ try
+ {
+ Iterator<?> children = Gateway.getLookup().search(mDomainPath, "*");
+ while (children.hasNext())
+ {
+ DomainPath domPath = (DomainPath)children.next();
+ allItems.add(domPath.getName());
+ }
+ }
+ catch (Exception ex)
+ {
+ MainFrame.exceptionDialog(ex);
+ }
+
+ Collections.sort(allItems);
+ addItem("");
+ for (String element : allItems) {
+ addItem(element);
+ }
+
+ }
+
+ public void reload()
+ {
+ removeAllItems();
+ initialise();
+ }
+
+ @Override
+ public synchronized Dimension getSize()
+ {
+ if (Gateway.getProperties().getInt("ResizeCombo") > 0)
+ return new Dimension(super.getSize().width<400?400:super.getSize().width,super.getSize().height);
+ return super.getSize();
+ }
+
+}
diff --git a/src/main/java/org/cristalise/gui/lifecycle/chooser/LDAPFileChooser.java b/src/main/java/org/cristalise/gui/lifecycle/chooser/LDAPFileChooser.java new file mode 100644 index 0000000..ed594f4 --- /dev/null +++ b/src/main/java/org/cristalise/gui/lifecycle/chooser/LDAPFileChooser.java @@ -0,0 +1,120 @@ +package org.cristalise.gui.lifecycle.chooser;
+import java.awt.Dimension;
+import java.awt.event.ItemListener;
+
+import javax.swing.BoxLayout;
+import javax.swing.JPanel;
+
+import org.cristalise.kernel.lookup.DomainPath;
+import org.cristalise.kernel.persistency.ClusterStorage;
+import org.cristalise.kernel.utils.Logger;
+
+
+//import fr.agilium.gui.tabs.wfPropertiesViewer.JPanelTabbedProperties;
+/**
+ * @version $Revision: 1.2 $ $Date: 2005/06/27 15:16:12 $
+ * @author $Author: abranson $
+ */
+
+public class LDAPFileChooser extends JPanel
+{
+ public static String SCRIPT_CHOOSER = "Script";
+ public static String SCHEMA_CHOOSER = "Schema";
+ public static String ACTIVITY_CHOOSER = "Activity";
+ private String chooserMode = null;
+ public LDAPEntryChooser mLec;
+ private boolean mEditable = false;
+ DomainPath domainPath;
+ String itemQuery = null;
+ boolean showversion = true;
+
+ public LDAPFileChooser(String choose)
+ {
+ super();
+ chooserMode = choose;
+ initialise();
+ }
+
+ private void initialise()
+ {
+ if (chooserMode.equals(SCHEMA_CHOOSER))
+ {
+ itemQuery = ClusterStorage.VIEWPOINT + "/Schema/all";
+ domainPath = new DomainPath("/desc/OutcomeDesc/");
+ }
+ else if (chooserMode.equals(SCRIPT_CHOOSER))
+ {
+ itemQuery = ClusterStorage.VIEWPOINT + "/Script/all";
+ domainPath = new DomainPath("/desc/Script/");
+ }
+ else if (chooserMode.equals(ACTIVITY_CHOOSER))
+ {
+ domainPath = new DomainPath("/desc/ActivityDesc/");
+ showversion = false;
+ }
+ else
+ return;
+ mLec = new LDAPEntryChooser(domainPath, mEditable);
+
+ mLec.setPreferredSize(new Dimension(220, 19));
+ mLec.setMaximumSize(new Dimension(3000, 22));
+ mLec.setMinimumSize(new Dimension(50, 19));
+ //mLec.getRenderer().getListCellRendererComponent();
+
+ BoxLayout blyt = new BoxLayout(this, BoxLayout.X_AXIS);
+ setLayout(blyt);
+ add(mLec);
+ mLec.setVisible(true);
+ this.validate();
+ this.setVisible(true);
+
+ }
+
+ public String getEntryName()
+ {
+ return (String) mLec.getSelectedItem();
+ }
+
+ public void addItemListener(ItemListener il)
+ {
+ mLec.addItemListener(il);
+ }
+ public void setSelectedItem(String name, String version)
+ {
+ Logger.debug(5,"setSelectedItem " + name + " " + version);
+ if (name == null||name.equals("-1")) name="";
+ mLec.setSelectedItem(name);
+ }
+
+ public void reload()
+ {
+ mLec.reload();
+ }
+
+ public void removeAllItems()
+ {
+ mLec.removeAllItems();
+ }
+
+ /**
+ * @param b
+ */
+ public void setEditable(boolean b)
+ {
+ mEditable = b;
+ mLec.setEditable(b);
+ }
+
+ @Override
+ public void updateUI()
+ {
+ if (mLec!=null) mLec.updateUI();
+ super.updateUI();
+ }
+
+ @Override
+ public void setEnabled(boolean enabled)
+ {
+ mLec.setEnabled(enabled);
+ }
+}
diff --git a/src/main/java/org/cristalise/gui/lifecycle/chooser/WorkflowDialogue.java b/src/main/java/org/cristalise/gui/lifecycle/chooser/WorkflowDialogue.java new file mode 100644 index 0000000..7ee6b5f --- /dev/null +++ b/src/main/java/org/cristalise/gui/lifecycle/chooser/WorkflowDialogue.java @@ -0,0 +1,20 @@ +/*
+ * Created on 2 sept. 2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package org.cristalise.gui.lifecycle.chooser;
+
+import java.util.HashMap;
+
+/**
+ * @author Developpement
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public interface WorkflowDialogue
+{
+ public void loadThisWorkflow(String name, HashMap<String, Object> mhashmap);
+}
|
