Esempio n. 1
0
 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()));
 }
Esempio n. 2
0
 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"));
   }
 }
Esempio n. 3
0
 /** 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();
   }
 }
Esempio n. 4
0
 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));
 }
Esempio n. 5
0
  /** 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());
    }
  }
Esempio n. 6
0
 /** Gets the tip of the day dialof off or on. */
 public static boolean getTipOfTheDay() {
   String tip = (String) Env.getUserProperty(Env.TIP_STR);
   if (tip == null) {
     setTipOfTheDay(true);
     return true;
   }
   return (new Boolean(tip)).booleanValue();
 }
Esempio n. 7
0
 /** @return whether or not to show extended tool tips */
 public static boolean showExtendedDescriptions() {
   String extended = (String) Env.getUserProperty(Env.EXTENDED_POPUP);
   if (extended == null) {
     setExtendedDescriptions(false);
     return false;
   }
   return (new Boolean(extended)).booleanValue();
 }
Esempio n. 8
0
 /** @return whether or not to show extended tool tips */
 public static boolean showNodeEditIcons() {
   String icons = (String) Env.getUserProperty(Env.NODE_EDIT_ICONS);
   if (icons == null) {
     setNodeEditIcons(true);
     return true;
   }
   return (new Boolean(icons)).booleanValue();
 }
Esempio n. 9
0
 /** @return the state of popup desciptions */
 public static boolean showPopUpDescriptions() {
   String popup = (String) Env.getUserProperty(Env.POPUP_DESC_STR);
   if (popup == null) {
     setPopUpDescriptions(true);
     return true;
   }
   return (new Boolean(popup)).booleanValue();
 }
Esempio n. 10
0
 /** @return whether cables are smooth */
 public static boolean isSmoothCables() {
   String state = (String) Env.getUserProperty("smoothcables");
   if (state == null) {
     setAutoConnect(true);
     return true;
   } else {
     return (new Boolean(state)).booleanValue();
   }
 }
Esempio n. 11
0
 /** @return whether restore from last state at startup is set, defaults to false */
 public static boolean restoreLast() {
   String state = (String) Env.getUserProperty("restoreLast");
   if (state == null) {
     setRestoreLast(false);
     return false;
   } else {
     return (new Boolean(state)).booleanValue();
   }
 }
Esempio n. 12
0
 /** @return true if auto connecting of tasks is enabled */
 public static boolean isAutoConnect() {
   String state = (String) Env.getUserProperty("autoconnect");
   if (state == null) {
     setAutoConnect(false);
     return false;
   } else {
     return (new Boolean(state)).booleanValue();
   }
 }
Esempio n. 13
0
 /** 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);
   }
 }
Esempio n. 14
0
  /** 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);
  }
Esempio n. 15
0
 /**
  * loads default colours for the types from the system's type file. This is used when Triana is
  * first run.
  */
 public static void loadDefaultColours() {
   Vector<String> types = Env.getTrianaTypesAndDefaultColors();
   for (int i = 0; i < types.size(); ++i) {
     Color c;
     Vector<String> sv = FileUtils.splitLine(types.get(i));
     if (sv.size() == 4) // they have a colour
     {
       c =
           new Color(
               Integer.parseInt(sv.get(1)),
               Integer.parseInt(sv.get(2)),
               Integer.parseInt(sv.get(3)));
     } else {
       c = new Color(0, 0, 0);
     } // set to black if no colour is set
     if (sv.size() != 0) {
       cableColours.put(sv.get(0), c);
     }
   }
 }
Esempio n. 16
0
 /** Sets the tip of the day number. */
 public static void setTipOfTheDay(int num) {
   Env.setUserProperty(Env.TIP_NUM_STR, String.valueOf(num));
 }
Esempio n. 17
0
 /** Set whether or not to display extended tool tips. */
 public static void setExtendedDescriptions(boolean state) {
   Env.setUserProperty(Env.EXTENDED_POPUP, String.valueOf(state));
 }
Esempio n. 18
0
 /** @return the color table map. */
 public static Hashtable getColorTable() {
   return (Hashtable) Env.getUserProperty(Env.COLOR_TABLE_STR);
 }
Esempio n. 19
0
 public static ColorTableEntry[] getColorTableEntries() {
   return Env.getColorTableEntries();
 }
Esempio n. 20
0
 /**
  * Sets the Color Table property so it can be saved
  *
  * @param entry
  */
 public static void setColorTableEntry(ColorTableEntry entry) {
   Env.setColorTableEntry(entry);
 }
Esempio n. 21
0
 /** Sets the tip of the day dialof to off or on. */
 public static void setTipOfTheDay(boolean state) {
   Env.setUserProperty(Env.TIP_STR, String.valueOf(state));
 }
Esempio n. 22
0
  /** 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);
  }
Esempio n. 23
0
 /** @return the HTML editor command i.e. the editor chosen by the user */
 public static String getHTMLEditorCommand() {
   return (String) Env.getUserProperty(Env.HELP_EDITOR_STR);
 }
Esempio n. 24
0
 /** sets the java editor command i.e. the editor chosen by the user */
 public static void setJavaEditorCommand(String cmd) {
   Env.setUserProperty(Env.CODE_EDITOR_STR, cmd);
 }
Esempio n. 25
0
 /** @return the java editor command i.e. the editor chosen by the user */
 public static String getJavaEditorCommand() {
   return (String) Env.getUserProperty(Env.CODE_EDITOR_STR);
 }
Esempio n. 26
0
 /** Set whether or not to display extended tool tips. */
 public static void setNodeEditIcons(boolean state) {
   Env.setUserProperty(Env.NODE_EDIT_ICONS, String.valueOf(state));
 }
Esempio n. 27
0
/**
 * 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;
  }
}
Esempio n. 28
0
 /** sets the HTML editor command i.e. the editor chosen by the user */
 public static void setHTMLEditorCommand(String cmd) {
   Env.setUserProperty(Env.HELP_EDITOR_STR, cmd);
 }
Esempio n. 29
0
 /** @return the HTML viewer command i.e. the editor chosen by the user */
 public static String getHTMLViewerCommand() {
   return (String) Env.getUserProperty(Env.HELP_VIEWER_STR);
 }
Esempio n. 30
0
 /** sets the HTML viewer command i.e. the editor chosen by the user */
 public static void setHTMLViewerCommand(String cmd) {
   Env.setUserProperty(Env.HELP_VIEWER_STR, cmd);
 }