001 package hep.aida.ref.sql.JAS3Plugin;
002
003 // JAS
004 import org.freehep.jas.plugin.tree.DefaultFTreeNodeAdapter;
005 import org.freehep.jas.plugin.tree.FTreeNode;
006
007 // FreeHEP
008 import org.freehep.util.commanddispatcher.CommandSourceAdapter;
009 import org.freehep.application.studio.Studio;
010 import org.freehep.application.PropertyUtilities;
011
012 // Swing
013 import javax.swing.JMenu;
014 import javax.swing.JMenuItem;
015 import javax.swing.JPopupMenu;
016
017 /** <code>SQLTupleColumnAdapter</code> handles {@link hep.aida.ref.sql.SQLTuple}
018 * columns.
019 * <p><font color="#880088">
020 * $Id: SQLTupleColumnAdapter.java,v 1.6 2007/05/23 16:38:44 hrivnac Exp $
021 * <pre>
022 * $Log: SQLTupleColumnAdapter.java,v $
023 * Revision 1.6 2007/05/23 16:38:44 hrivnac
024 * logical connections for Plotter; better UML
025 *
026 * Revision 1.5 2005/10/10 10:05:33 hrivnac
027 * prepared for 1.0.2
028 *
029 * Revision 1.4 2005/09/29 14:31:32 hrivnac
030 * clouds and profiles added
031 *
032 * Revision 1.3 2005/09/29 13:02:39 hrivnac
033 * histograms can be plotted in a different way in JAS3
034 *
035 * Revision 1.2 2005/09/29 09:22:59 hrivnac
036 * jas3 plugin improved
037 *
038 * Revision 1.1 2005/09/28 22:49:55 hrivnac
039 * added SQLTuple-aware projections
040 *
041 * </pre>
042 * </font></p>
043 * @opt attributes
044 * @opt operations
045 * @opt types
046 * @opt visibility
047 * @version $Id: SQLTupleColumnAdapter.java,v 1.6 2007/05/23 16:38:44 hrivnac Exp $
048 * @author <a href="mailto:Julius.Hrivnac@cern.ch">J.Hrivnac</a> */
049 public class SQLTupleColumnAdapter extends DefaultFTreeNodeAdapter {
050
051 /** Create and attach {@link Studio} with hight pripority = 300.
052 * @param app The attached {@link Studio}.
053 * @param commands The associated {@link SQLTupleCommands}. */
054 SQLTupleColumnAdapter(Studio app, SQLTupleCommands commands) {
055 super(300);
056 _app = app;
057 _commands = commands;
058 }
059
060 /** Add <em>Projector</em> action into popup menu.
061 * @param nodes The selected {@link FTreeNode}s.
062 * @param menu The current {@link JPopupMenu}.
063 * @return The updated {@link JPopupMenu}. */
064 public JPopupMenu modifyPopupMenu(FTreeNode[] nodes, JPopupMenu menu) {
065 // Separator
066 if (menu.getSubElements().length != 0) {
067 menu.addSeparator();
068 }
069 // Histograms
070 JMenu histMenu = new JMenu("Histogram Projector");
071 menu.add(histMenu);
072 JMenuItem itemH0 = new JMenuItem("Project Histogram In Current Region");
073 _app.getCommandTargetManager().add(new CommandSourceAdapter(itemH0));
074 histMenu.add(itemH0);
075 JMenuItem itemH1 = new JMenuItem("Project Histogram In New Region");
076 _app.getCommandTargetManager().add(new CommandSourceAdapter(itemH1));
077 histMenu.add(itemH1);
078 JMenuItem itemH2 = new JMenuItem("Project Histogram In New Page");
079 _app.getCommandTargetManager().add(new CommandSourceAdapter(itemH2));
080 histMenu.add(itemH2);
081 JMenuItem itemH3 = new JMenuItem("Project Histogram Overlay");
082 _app.getCommandTargetManager().add(new CommandSourceAdapter(itemH3));
083 histMenu.add(itemH3);
084 // Clouds
085 JMenu cloudMenu = new JMenu("Cloud Projector");
086 menu.add(cloudMenu);
087 JMenuItem itemC0 = new JMenuItem("Project Cloud In Current Region");
088 _app.getCommandTargetManager().add(new CommandSourceAdapter(itemC0));
089 cloudMenu.add(itemC0);
090 JMenuItem itemC1 = new JMenuItem("Project Cloud In New Region");
091 _app.getCommandTargetManager().add(new CommandSourceAdapter(itemC1));
092 cloudMenu.add(itemC1);
093 JMenuItem itemC2 = new JMenuItem("Project Cloud In New Page");
094 _app.getCommandTargetManager().add(new CommandSourceAdapter(itemC2));
095 cloudMenu.add(itemC2);
096 JMenuItem itemC3 = new JMenuItem("Project Cloud Overlay");
097 _app.getCommandTargetManager().add(new CommandSourceAdapter(itemC3));
098 cloudMenu.add(itemC3);
099 // Profiles
100 JMenu profMenu = new JMenu("Profile Projector");
101 menu.add(profMenu);
102 JMenuItem itemP0 = new JMenuItem("Project Profile In Current Region");
103 _app.getCommandTargetManager().add(new CommandSourceAdapter(itemP0));
104 profMenu.add(itemP0);
105 JMenuItem itemP1 = new JMenuItem("Project Profile In New Region");
106 _app.getCommandTargetManager().add(new CommandSourceAdapter(itemP1));
107 profMenu.add(itemP1);
108 JMenuItem itemP2 = new JMenuItem("Project Profile In New Page");
109 _app.getCommandTargetManager().add(new CommandSourceAdapter(itemP2));
110 profMenu.add(itemP2);
111 JMenuItem itemP3 = new JMenuItem("Project Profile Overlay");
112 _app.getCommandTargetManager().add(new CommandSourceAdapter(itemP3));
113 profMenu.add(itemP3);
114 // Return
115 return menu;
116 }
117
118 /** Activate <em>Projector</em> command on double click.
119 * @param node The selected {@link FTreeNode}.
120 * @return <code>true</code>.
121 * @throws IllegalArgumentException if selected double click is not defined. */
122 public boolean doubleClick(FTreeNode node) throws IllegalArgumentException {
123 int dclick = PropertyUtilities.getInteger(_app.getUserProperties(),
124 "org.freehep.jas.extension.tupleexplorer.doubleClick",
125 0);
126 switch (dclick) {
127 case 0:
128 _commands.onProjectHistogramInCurrentRegion();
129 break;
130 case 1:
131 _commands.onProjectHistogramInNewRegion();
132 break;
133 case 2:
134 _commands.onProjectHistogramInNewPage();
135 break;
136 case 3:
137 _commands.onProjectHistogramOverlay();
138 break;
139 default:
140 throw new IllegalArgumentException("Illegal selection on double click " + dclick);
141 }
142 return true;
143 }
144
145 private Studio _app;
146
147 private SQLTupleCommands _commands;
148
149 }
150