Ejemplo n.º 1
0
  /** Opens a new window with a drawing view. */
  protected void open(DrawingView newDrawingView) {
    getVersionControlStrategy().assertCompatibleVersion();
    setUndoManager(new UndoManager());
    fIconkit = new Iconkit(this);
    getContentPane().setLayout(new BorderLayout());

    // status line must be created before a tool is set
    fStatusLine = createStatusLine();
    getContentPane().add(fStatusLine, BorderLayout.SOUTH);

    // create dummy tool until the default tool is activated during toolDone()
    setTool(new NullTool(this), "");
    setView(newDrawingView);
    JComponent contents = createContents(view());
    contents.setAlignmentX(LEFT_ALIGNMENT);

    JToolBar tools = createToolPalette();
    createTools(tools);

    JPanel activePanel = new JPanel();
    activePanel.setAlignmentX(LEFT_ALIGNMENT);
    activePanel.setAlignmentY(TOP_ALIGNMENT);
    activePanel.setLayout(new BorderLayout());
    activePanel.add(tools, BorderLayout.NORTH);
    activePanel.add(contents, BorderLayout.CENTER);

    getContentPane().add(activePanel, BorderLayout.CENTER);

    JMenuBar mb = new JMenuBar();
    createMenus(mb);
    setJMenuBar(mb);

    Dimension d = defaultSize();
    if (d.width > mb.getPreferredSize().width) {
      setSize(d.width, d.height);
    } else {
      setSize(mb.getPreferredSize().width, d.height);
    }
    addListeners();
    setVisible(true);
    fStorageFormatManager = createStorageFormatManager();

    toolDone();
  }
Ejemplo n.º 2
0
  /**
   * Fired by a view when the figure seleciton changes. Since Commands and Tools are Actions and
   * they are registered to hear these events, they will handle themselves. So selection sensitive
   * menuitems will update their own states.
   *
   * @see DrawingEditor
   */
  public void figureSelectionChanged(DrawingView view) {
    JMenuBar mb = getJMenuBar();
    CommandMenu editMenu = (CommandMenu) mb.getMenu(EDIT_MENU);
    // make sure it does exist
    if (editMenu != null) {
      editMenu.checkEnabled();
    }
    CommandMenu alignmentMenu = (CommandMenu) mb.getMenu(ALIGNMENT_MENU);
    // make sure it does exist
    if (alignmentMenu != null) {
      alignmentMenu.checkEnabled();
    }

    JMenu attributeMenu = mb.getMenu(ATTRIBUTES_MENU);
    // make sure it does exist
    if (attributeMenu != null) {
      for (int i = 0; i < attributeMenu.getItemCount(); i++) {
        JMenuItem currentMenu = attributeMenu.getItem(i);
        if (currentMenu instanceof CommandMenu) {
          ((CommandMenu) currentMenu).checkEnabled();
        }
      }
    }
  }
Ejemplo n.º 3
0
 protected void addMenuIfPossible(JMenuBar mb, JMenu newMenu) {
   if (newMenu != null) {
     mb.add(newMenu);
   }
 }