コード例 #1
0
  /**
   * Creates a new mode (controller), activates the toolbars, title and deactivates all actions.
   *
   * @param mode
   * @return false if the change was not successful.
   */
  public boolean changeToMode(String mode) {
    if (getMode() != null && mode.equals(getMode().toString())) {
      return true;
    }

    // Check if the mode is available and create ModeController.
    Mode newmode = modescreator.getMode(mode);
    if (newmode == null) {
      errorMessage(getResourceString("mode_na") + ": " + mode);
      return false;
    }

    if (getMode() != null && getMode().getModeToolBar() != null) {
      toolbar.remove(getMode().getModeToolBar());
    }
    /* other toolbars are to be removed too. */
    if (getMode() != null && getMode().getLeftToolBar() != null) {
      getFrame().getContentPane().remove(getMode().getLeftToolBar());
    }

    if (getMapModule() != null) {
      getMapModuleManager().setMapModule(null);
    }
    this.mode = newmode;

    if (getMode().getModeToolBar() != null) {
      toolbar.add(getMode().getModeToolBar());
      getMode().getModeToolBar().repaint();
    }
    /* new left toolbar. */
    if (getMode().getLeftToolBar() != null) {
      getFrame().getContentPane().add(getMode().getLeftToolBar(), BorderLayout.WEST);
      getMode().getLeftToolBar().repaint();
    }
    toolbar.validate();
    toolbar.repaint();

    setTitle();
    getMode().activate();

    getFrame().getFreeMindMenuBar().updateMenus();

    if (getMapModule() == null) {
      setAllActions(false);
    }

    Object[] messageArguments = {getMode().toString()};
    MessageFormat formatter = new MessageFormat(getResourceString("mode_status"));
    getFrame().out(formatter.format(messageArguments));

    return true;
  }
コード例 #2
0
  public CKSyntaxPaneTest() {
    JFrame f = new JFrame("Party"); // CKSytaxPaneTest.class.getName());
    final Container c = f.getContentPane();
    c.setLayout(new BorderLayout());

    // DefaultSyntaxKit.initKit();

    final JEditorPane codeEditor = new JEditorPane();
    JScrollPane scrPane = new JScrollPane(codeEditor);
    // codeEditor.setContentType("text/python");
    codeEditor.setEditorKit(new PythonSyntaxKit());
    // codeEditor.setText("public static void main(String[] args) {\n}");

    // toolbar is part of the editor kit--ausome!
    JToolBar jToolBar1 = new javax.swing.JToolBar();
    jToolBar1.setRollover(true);
    jToolBar1.setFocusable(false);

    EditorKit kit = codeEditor.getEditorKit();
    if (kit instanceof DefaultSyntaxKit) {
      DefaultSyntaxKit defaultSyntaxKit = (DefaultSyntaxKit) kit;
      defaultSyntaxKit.addToolBarActions(codeEditor, jToolBar1);
    }
    jToolBar1.validate();
    c.add(jToolBar1, BorderLayout.PAGE_START);

    c.add(scrPane, BorderLayout.CENTER);
    // c.add(codeEditor, BorderLayout.CENTER);

    // create console for output?
    JTextPane tpane = new JTextPane();
    c.add(tpane, BorderLayout.LINE_START);
    c.doLayout();

    f.setSize(800, 600);
    f.setVisible(true);
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  }
コード例 #3
0
  /**
   * Create a toolbar containing the given tools (if any).
   *
   * @param template Conta
   */
  protected void changeToolBar(JComponent[] template, IControlCenterPlugin selplugin) {
    // Setup the tool bar.
    if (toolbar == null) {
      toolbar = new JToolBar("Main Toolbar");
      getContentPane().add(BorderLayout.NORTH, toolbar);
      // Add standard entries (after gap).
      toolbar.add(Box.createGlue());
      toolcnt++;
      toolbar.addSeparator();
      toolcnt++;

      // ButtonGroup bg = new ButtonGroup();
      IControlCenterPlugin[] plugins = controlcenter.getPlugins();
      for (int i = 0; i < plugins.length; i++) {
        final IControlCenterPlugin plugin = plugins[i];
        // final JToggleButton button = new JToggleButton(new PluginAction(plugins[i]));
        final JButton button = new JButton(new PluginAction(plugins[i]));
        Icon ic = plugin.getToolIcon(selplugin.getName().equals(plugins[i].getName()));
        if (ic != null) button.setIcon(ic);
        else button.setText(plugins[i].getName());
        button.setText("A");
        button.putClientProperty("plugin", plugins[i]);
        button.setBorder(null);
        button.setText(null);
        button.setMinimumSize(BUTTON_DIM);
        button.setHorizontalAlignment(SwingConstants.CENTER);
        button.setVerticalAlignment(SwingConstants.CENTER);
        button.setToolTipText(plugins[i].getName());
        button
            .getModel()
            .addItemListener(
                new ItemListener() {
                  public void itemStateChanged(ItemEvent e) {
                    // System.out.println(plugin.getName()+" :"+button.isSelected());
                    button.setIcon(plugin.getToolIcon(button.isSelected()));
                  }
                });
        //	            if(plugins[i].getHelpID()!=null)
        //	            	SHelp.setupHelp(button, plugins[i].getHelpID());

        // bg.add(button);
        toolbar.add(button);
        toolcnt++;
      }
      toolbar.addSeparator();
      toolcnt++;
      toolbar.add(new JadexLogoButton(toolbar));
      toolcnt++;
    } else {
      while (toolbar.getComponentCount() > toolcnt) {
        //				Component	comp	= toolbar.getComponent(0);
        toolbar.remove(0);
        // if(lasttoolbar!=null)
        //	lasttoolbar.add(comp);
      }
    }

    for (int i = 0; template != null && i < template.length; i++) toolbar.add(template[i], i);
    // lasttoolbar	= template;

    // Select plugins
    for (int i = 0; i < toolbar.getComponentCount(); i++) {
      JComponent comp = (JComponent) toolbar.getComponent(i);
      if (comp.getClientProperty("plugin") != null) {
        IControlCenterPlugin pl = (IControlCenterPlugin) comp.getClientProperty("plugin");
        ((JButton) comp).setIcon(pl.getToolIcon(pl.equals(selplugin)));
        // ((JToggleButton)comp).setSelected(pluginname.equals(comp.getClientProperty("pluginname")));
      }
    }

    toolbar.validate();
    toolbar.repaint();

    // If toolbar has been dropped out -> pack the window (hack???).
    Container root = toolbar;
    while (root.getParent() != null && !(root instanceof Window)) root = root.getParent();
    if (root != null && !(root instanceof JFrame)) {
      ((Window) root).pack();
    }
  }