public PasteIntoAction(ToolSelectionHandler selhandler, ToolTable tools) { this.selectionHandler = selhandler; this.tooltable = tools; putValue(SHORT_DESCRIPTION, Env.getString("PasteIntoTip")); putValue(ACTION_COMMAND_KEY, Env.getString("PasteInto")); putValue(NAME, Env.getString("PasteInto") + "..."); putValue(SMALL_ICON, GUIEnv.getIcon("pasteinto.png")); putValue( ACCELERATOR_KEY, KeyStroke.getKeyStroke( KeyEvent.VK_I, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); }
public ToolImportAction(SelectionManager selhandler, int displayOption, ToolTable tools) { super(); this.tools = tools; this.selectionHandler = selhandler; putValue(SHORT_DESCRIPTION, Env.getString("ToolImport")); putValue(ACTION_COMMAND_KEY, Env.getString("ToolImport")); if ((displayOption == DISPLAY_ICON) || (displayOption == DISPLAY_BOTH)) { putValue(SMALL_ICON, GUIEnv.getIcon("toolimport.png")); } if ((displayOption == DISPLAY_NAME) || (displayOption == DISPLAY_BOTH)) { putValue(NAME, Env.getString("ToolImport")); } }
/** Invoked when an action occurs. */ public void actionPerformed(ActionEvent e) { String label = e.getActionCommand(); if (label.equals(Env.getString("newUnit"))) { newTool(); } else if (label.equals(Env.getString("compileGenerate"))) { compile(); } else if (label.equals(Env.getString("compileAll"))) { rebuildAllTools(); } else if (label.equals(Env.getString("editToolBoxPaths"))) { editToolBoxPaths(); } else if (label.equals(Env.getString("generateCommandLineApp"))) { generateCommandLine(); } }
public ToolImportAction( SelectionManager selhandler, int displayOption, JMenu parentMenu, ToolTable tools) { this(selhandler, displayOption, tools); char mnem = MenuMnemonics.getInstance().getNextMnemonic(parentMenu, Env.getString("ToolImport")); putValue(MNEMONIC_KEY, new Integer(mnem)); }
/** Invoked when an action occurs. */ public void actionPerformed(ActionEvent event) { Tool[] tools = selectionHandler.getSelectedTools(); if (tools.length > 0) { PasteHandler handler = new PasteHandler(tooltable, Env.getString("PasteInto") + "..."); handler.handlePaste(tools, tools[0].getToolPackage()); } }
/** Static method to display an HTML page using the default web browser. */ public static void openURL(String url) { if (getHTMLViewerCommand().equals(Env.getString("defaultViewer"))) { if (Help.tryActualFile(url) == -1) { Help.setFile(url); } } else { showEditorFor(getHTMLViewerCommand(), url); } }
/** initialises the layout */ private void initLayout() { setLayout(new BorderLayout()); populateCompType(); initCompPanel(); JLabel complabel = new JLabel(Env.getString("component")); complabel.setBorder(new EmptyBorder(0, 0, 0, 3)); JPanel typepanel = new JPanel(new BorderLayout()); typepanel.add(comptype, BorderLayout.WEST); JPanel compcont = new JPanel(new BorderLayout()); compcont.add(complabel, BorderLayout.WEST); compcont.add(typepanel, BorderLayout.CENTER); compcont.setBorder(new EmptyBorder(0, 0, 10, 0)); JLabel deflabel = new JLabel(Env.getString("defaultValue")); deflabel.setBorder(new EmptyBorder(0, 0, 0, 3)); JPanel defpanel = new JPanel(new BorderLayout()); defpanel.add(defval, BorderLayout.WEST); defval.addFocusListener(this); JPanel defcont = new JPanel(new BorderLayout()); defcont.add(compcont, BorderLayout.NORTH); defcont.add(deflabel, BorderLayout.WEST); defcont.add(defpanel, BorderLayout.CENTER); defcont.setBorder(new EmptyBorder(0, 0, 3, 0)); JPanel cont = new JPanel(new BorderLayout()); cont.add(defcont, BorderLayout.NORTH); cont.add(comppanel, BorderLayout.CENTER); JPanel maincont = new JPanel(new BorderLayout()); maincont.add(cont, BorderLayout.NORTH); add(maincont, BorderLayout.WEST); }
/** * A panel for defining gui builder interface components * * @author Ian Wang * @version $Revision: 4048 $ */ public class BuilderPanel extends JPanel implements ItemListener, FocusListener { /** current componenet types available */ private static final String[] COMPONENT_TYPES = { Env.getString("textfield"), Env.getString("label"), Env.getString("choice"), Env.getString("checkbox"), Env.getString("scroller"), Env.getString("intscroller"), Env.getString("filechooser"), Env.getString("hidden") }; /** combo box for selecting component type */ private JComboBox comptype = new JComboBox(new DefaultComboBoxModel()); /** the main panel for editing the current component */ private JPanel comppanel; /** the card layout that manages the comppanel */ private CardLayout complayout; /** the panels for each of the available components */ private TextFieldPanel textfield; private LabelPanel label; private ChoicePanel choice; private CheckBoxPanel checkbox; private ScrollerPanel scroller; private ScrollerPanel intscroller; private FileChooserPanel filechooser; private HiddenPanel hidden; /** the text field for setting the current default value */ private JTextField defval = new JTextField(15); /** a hashtable of component panels keyed by type */ private Hashtable comppanels = new Hashtable(); /** a hashtable of the components for each parameter */ private Hashtable params = new Hashtable(); /** a hashtable of the gui builder strings for each parameter */ private Hashtable guilines = new Hashtable(); /** the current parameter */ private String curparam; /** the main gui panel */ private GUIPanel guipanel; /** a flag indicating whether a change in comp type is relayed back to the main gui panel */ private boolean guicallback = true; public BuilderPanel(GUIPanel guipanel) { this.guipanel = guipanel; initLayout(); } /** initialises the layout */ private void initLayout() { setLayout(new BorderLayout()); populateCompType(); initCompPanel(); JLabel complabel = new JLabel(Env.getString("component")); complabel.setBorder(new EmptyBorder(0, 0, 0, 3)); JPanel typepanel = new JPanel(new BorderLayout()); typepanel.add(comptype, BorderLayout.WEST); JPanel compcont = new JPanel(new BorderLayout()); compcont.add(complabel, BorderLayout.WEST); compcont.add(typepanel, BorderLayout.CENTER); compcont.setBorder(new EmptyBorder(0, 0, 10, 0)); JLabel deflabel = new JLabel(Env.getString("defaultValue")); deflabel.setBorder(new EmptyBorder(0, 0, 0, 3)); JPanel defpanel = new JPanel(new BorderLayout()); defpanel.add(defval, BorderLayout.WEST); defval.addFocusListener(this); JPanel defcont = new JPanel(new BorderLayout()); defcont.add(compcont, BorderLayout.NORTH); defcont.add(deflabel, BorderLayout.WEST); defcont.add(defpanel, BorderLayout.CENTER); defcont.setBorder(new EmptyBorder(0, 0, 3, 0)); JPanel cont = new JPanel(new BorderLayout()); cont.add(defcont, BorderLayout.NORTH); cont.add(comppanel, BorderLayout.CENTER); JPanel maincont = new JPanel(new BorderLayout()); maincont.add(cont, BorderLayout.NORTH); add(maincont, BorderLayout.WEST); } /** populates the comptype combo box with the COMPONENT_TYPES */ private void populateCompType() { DefaultComboBoxModel model = (DefaultComboBoxModel) comptype.getModel(); for (int count = 0; count < COMPONENT_TYPES.length; count++) { model.addElement(COMPONENT_TYPES[count]); } comptype.addItemListener(this); } /** adds panels for editing the various components to comppanel */ private void initCompPanel() { complayout = new CardLayout(); comppanel = new JPanel(complayout); textfield = new TextFieldPanel(); label = new LabelPanel(); choice = new ChoicePanel(); checkbox = new CheckBoxPanel(); scroller = new ScrollerPanel(ScrollerPanel.SCROLLER); intscroller = new ScrollerPanel(ScrollerPanel.INT_SCROLLER); filechooser = new FileChooserPanel(); hidden = new HiddenPanel(); comppanel.add(textfield, Env.getString("textfield")); comppanel.add(label, Env.getString("label")); comppanel.add(choice, Env.getString("choice")); comppanel.add(checkbox, Env.getString("checkbox")); comppanel.add(scroller, Env.getString("scroller")); comppanel.add(intscroller, Env.getString("intscroller")); comppanel.add(filechooser, Env.getString("filechooser")); comppanel.add(hidden, Env.getString("hidden")); comppanels.put(Env.getString("textfield"), textfield); comppanels.put(Env.getString("label"), label); comppanels.put(Env.getString("choice"), choice); comppanels.put(Env.getString("checkbox"), checkbox); comppanels.put(Env.getString("scroller"), scroller); comppanels.put(Env.getString("intscroller"), intscroller); comppanels.put(Env.getString("filechooser"), filechooser); comppanels.put(Env.getString("hidden"), hidden); } /** Sets the current parameter */ public void setCurrentParameter(String param) { comptype.setEnabled(param != null); defval.setEnabled(param != null); defval.setText(""); if (curparam != null) { guilines.put(curparam, getGUILine(curparam)); } curparam = param; if (param != null) { guicallback = false; if (!params.containsKey(param)) { initParam(param); } Enumeration enumeration = comppanels.elements(); ComponentPanelInterface comp; while (enumeration.hasMoreElements()) { comp = (ComponentPanelInterface) enumeration.nextElement(); comp.reset(param); } defval.setText(guipanel.getDefaultValue(param)); comptype.setSelectedItem(params.get(param)); if (guilines.containsKey(param)) { ((ComponentPanelInterface) comppanels.get(params.get(param))) .setGUIBuilderStr((String) guilines.get(param)); } ((ComponentPanelInterface) comppanels.get(params.get(param))) .notifyDefaultValue(guipanel.getDefaultValue(param)); guicallback = true; } } /** @return the current parameter */ public String getCurrentParameter() { return curparam; } /** @return the component type for the specified parameter */ public String getComponent(String param) { if (!params.containsKey(param)) { initParam(param); } return (String) params.get(param); } /** @return the gui line for the specified parameter */ public String getGUILine(String param) { if (param.equals(curparam)) { return ((ComponentPanelInterface) comppanels.get(comptype.getSelectedItem())) .getGUIBuilderStr(param); } else if (guilines.containsKey(param)) { return (String) guilines.get(param); } else { String temp = curparam; setCurrentParameter(param); String line = getGUILine(param); setCurrentParameter(temp); return line; } } /** Sets the gui line for the specified parameter */ public void setGUILine(String param, String guiline) { guilines.put(param, guiline); if (param.equals(curparam)) { ((ComponentPanelInterface) comppanels.get(comptype.getSelectedItem())) .setGUIBuilderStr(guiline); } } /** initialises a parmeter to the default component */ private void initParam(String param) { params.put(param, comptype.getModel().getElementAt(0)); } public void itemStateChanged(ItemEvent event) { if (event.getSource() == comptype) { String comp = (String) comptype.getSelectedItem(); complayout.show(comppanel, comp); if (guicallback) { params.put(curparam, comp); guipanel.updateGUIComponent(comp); ((ComponentPanelInterface) comppanels.get(comp)).notifyDefaultValue(defval.getText()); } } } public void focusGained(FocusEvent event) {} public void focusLost(FocusEvent event) { if ((curparam != null) && (event.getSource() == defval)) { guipanel.setDefaultValue(curparam, defval.getText()); ((ComponentPanelInterface) comppanels.get(params.get(curparam))) .notifyDefaultValue(defval.getText()); } } public static final String[] splitString(String line) { ArrayList list = new ArrayList(); list.add(line.substring(0, line.indexOf(" $title ")).trim()); String rest = line.substring(line.indexOf(" $title ") + 8).trim(); ; while (rest.indexOf(' ') > -1) { list.add(rest.substring(0, rest.indexOf(' '))); rest = rest.substring(rest.indexOf(' ') + 1).trim(); } list.add(rest.trim()); String[] str = new String[list.size()]; Iterator iter = list.iterator(); for (int count = 0; count < str.length; count++) { str[count] = (String) iter.next(); } return str; } }
/** adds panels for editing the various components to comppanel */ private void initCompPanel() { complayout = new CardLayout(); comppanel = new JPanel(complayout); textfield = new TextFieldPanel(); label = new LabelPanel(); choice = new ChoicePanel(); checkbox = new CheckBoxPanel(); scroller = new ScrollerPanel(ScrollerPanel.SCROLLER); intscroller = new ScrollerPanel(ScrollerPanel.INT_SCROLLER); filechooser = new FileChooserPanel(); hidden = new HiddenPanel(); comppanel.add(textfield, Env.getString("textfield")); comppanel.add(label, Env.getString("label")); comppanel.add(choice, Env.getString("choice")); comppanel.add(checkbox, Env.getString("checkbox")); comppanel.add(scroller, Env.getString("scroller")); comppanel.add(intscroller, Env.getString("intscroller")); comppanel.add(filechooser, Env.getString("filechooser")); comppanel.add(hidden, Env.getString("hidden")); comppanels.put(Env.getString("textfield"), textfield); comppanels.put(Env.getString("label"), label); comppanels.put(Env.getString("choice"), choice); comppanels.put(Env.getString("checkbox"), checkbox); comppanels.put(Env.getString("scroller"), scroller); comppanels.put(Env.getString("intscroller"), intscroller); comppanels.put(Env.getString("filechooser"), filechooser); comppanels.put(Env.getString("hidden"), hidden); }