Author: mmichaud
Date: 2009-03-12 11:14:39 -0700 (Thu, 12 Mar 2009)
New Revision: 16230
Modified:
core3/work-swing-impl/trunk/src/main/java/org/cytoscape/work/internal/tunables/GuiTunableInterceptor.java
Log:
Modified:
core3/work-swing-impl/trunk/src/main/java/org/cytoscape/work/internal/tunables/GuiTunableInterceptor.java
===================================================================
---
core3/work-swing-impl/trunk/src/main/java/org/cytoscape/work/internal/tunables/GuiTunableInterceptor.java
2009-03-12 18:11:11 UTC (rev 16229)
+++
core3/work-swing-impl/trunk/src/main/java/org/cytoscape/work/internal/tunables/GuiTunableInterceptor.java
2009-03-12 18:14:39 UTC (rev 16230)
@@ -1,7 +1,9 @@
package org.cytoscape.work.internal.tunables;
+import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
+import java.awt.Container;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@@ -12,7 +14,6 @@
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
-
import org.cytoscape.work.internal.tunables.utils.*;
import org.cytoscape.work.*;
import org.cytoscape.work.Tunable.Param;
@@ -21,13 +22,16 @@
public class GuiTunableInterceptor extends
SpringTunableInterceptor<Guihandler> {
- private Component parent;
+ private Component parent=null;
private Map<java.util.List<Guihandler>,JPanel> panelMap;
-
+ private JPanel r = new JPanel(new BorderLayout());
+ private java.util.List<Guihandler> lh;
+ private boolean m;
public GuiTunableInterceptor(HandlerFactory<Guihandler> factory) {
super( factory );
panelMap = new HashMap<java.util.List<Guihandler>,JPanel>();
+ //this.parent=parent;
}
public void setParent(Component c) {
@@ -35,14 +39,14 @@
}
public boolean createUI(Object... proxyObjs) {
- Object[] objs = convertSpringProxyObjs( proxyObjs );
+ Object[] objs = convertSpringProxyObjs( proxyObjs );
- java.util.List<Guihandler> lh = new ArrayList<Guihandler>();
+ //java.util.List<Guihandler> lh = new ArrayList<Guihandler>();
+ lh = new ArrayList<Guihandler>();
for ( Object o : objs ) {
if ( !handlerMap.containsKey( o ) )
throw new IllegalArgumentException("No Tunables
exist for Object yet!");
lh.addAll( handlerMap.get(o).values() );
-
}
if ( lh.size() <= 0 )
@@ -89,6 +93,8 @@
for ( Guihandler h : lh )
h.notifyDependents();
+
+ if(parent==null){
//Custom button text
Object[] buttons = {"OK","Cancel"};
int n = JOptionPane.showOptionDialog(parent,
@@ -99,17 +105,49 @@
null,
buttons,
buttons[0]);
+ // process the values set in the gui : USELESS BECAUSE OF
LISTENERS
+ if ( n == JOptionPane.OK_OPTION ){
+ for ( Guihandler h : lh ) h.handle();
+ return true;
+ }
+ else
+ return false;
-
- // process the values set in the gui : USELESS BECAUSE OF
LISTENERS
- if ( n == JOptionPane.OK_OPTION ){
- for ( Guihandler h : lh ) h.handle();
- return true;
}
- else
- return false;
+ else{
+// JPanel buttonPanel = new JPanel();
+// JButton okButton = new JButton("OK");
+// okButton.setActionCommand("ok");
+// okButton.addActionListener(new myActionListener());
+// okButton.setToolTipText("Click to validate");
+// JButton cancelButton = new JButton("Cancel");
+// cancelButton.setActionCommand("cancel");
+// cancelButton.addActionListener(new myActionListener());
+// cancelButton.setToolTipText("Cancel all previous
actions");
+// buttonPanel.add(okButton);
+// buttonPanel.add(cancelButton);
+
+ int nbPanel = ((Container)
parent).getComponentCount()-1;
+ JPanel buttonBox = (JPanel) ((Container)
parent).getComponent(nbPanel);
+ ((JPanel)parent).remove(nbPanel);
+ ((JPanel)parent).add(panelMap.get(lh));
+ ((JPanel)parent).add(buttonBox);
+ return m;
+ }
}
+ public void Handle(){
+ for(Guihandler h: lh)h.handle();
+ }
+
+// private class myActionListener implements ActionListener{
+// public void actionPerformed(ActionEvent ae){
+// if(ae.getActionCommand() == "ok"){ for(Guihandler h:
lh)h.handle();m=true;}
+// else m=false;
+// ((JPanel)parent).remove(r);
+// ((JPanel)parent).repaint();
+// }
+// }
private JPanel createJPanel(String title, Guihandler gh) {
@@ -146,4 +184,6 @@
ret.setLayout(new BoxLayout(ret,BoxLayout.PAGE_AXIS));
return ret;
}
+
+
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en
-~----------~----~----~----~------~----~------~--~---