Exemplo n.º 1
0
  void windowMenu_menuSelected(MenuEvent e) {
    // <<TODO:MAINTAINABILITY>> This algorithm is not robust. It assumes
    // the Window
    // menu has exactly one "regular" menu item (newWindowMenuItem). [Jon
    // Aquino]
    if (windowMenu.getItemCount() > 0
        && windowMenu.getItem(0) != null
        && windowMenu
            .getItem(0)
            .getText()
            .equals(AbstractPlugIn.createName(CloneWindowPlugIn.class))) {
      JMenuItem newWindowMenuItem = windowMenu.getItem(0);
      windowMenu.removeAll();
      windowMenu.add(newWindowMenuItem);
      windowMenu.addSeparator();
    } else {
      // ezLink doesn't have a Clone Window menu [Jon Aquino]
      windowMenu.removeAll();
    }

    // final TaskComponent[] frames = (TaskComponent[]) desktopPane.getAllFrames();
    final JInternalFrame[] frames = desktopPane.getAllFrames();
    for (int i = 0; i < frames.length; i++) {
      JMenuItem menuItem = new JMenuItem();
      // Increase truncation threshold from 20 to 40, for eziLink [Jon
      // Aquino]
      menuItem.setText(GUIUtil.truncateString(frames[i].getTitle(), 40));
      associate(menuItem, frames[i]);
      windowMenu.add(menuItem);
    }
    if (windowMenu.getItemCount() == 0) {
      // For ezLink [Jon Aquino]
      windowMenu.add(new JMenuItem("(No Windows)"));
    }
  }
Exemplo n.º 2
0
 private void associate(JMenuItem menuItem, final JInternalFrame frame) {
   menuItem.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           try {
             activateFrame((JInternalFrame) frame);
           } catch (Throwable t) {
             handleThrowable(t);
           }
         }
       });
 }
Exemplo n.º 3
0
  private void jbInit() throws Exception {
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    this.setIconImage(icon.getImage());
    this.addComponentListener(
        new java.awt.event.ComponentAdapter() {
          public void componentShown(ComponentEvent e) {
            this_componentShown(e);
          }
        });
    this.getContentPane().setLayout(borderLayout1);
    this.addWindowListener(
        new java.awt.event.WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            this_windowClosing(e);
          }
        });
    this.setJMenuBar(menuBar);

    // This size is chosen so that when the user hits the Info tool, the
    // window
    // fits between the lower edge of the TaskFrame and the lower edge of
    // the
    // WorkbenchFrame. See the call to #setSize in InfoFrame. [Jon Aquino]
    setSize(900, 665);

    // OUTLINE_DRAG_MODE is excruciatingly slow in JDK 1.4.1, so don't use
    // it.
    // (although it's supposed to be fixed in 1.4.2, which has not yet been
    // released). (see Sun Java Bug ID 4665237). [Jon Aquino]
    // desktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
    messageLabel.setOpaque(true);
    memoryLabel.setText("jLabel1");
    wmsLabel.setHorizontalAlignment(SwingConstants.LEFT);
    wmsLabel.setText(" ");
    this.getContentPane().add(statusPanel, BorderLayout.SOUTH);
    exitMenuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            exitMenuItem_actionPerformed(e);
          }
        });
    windowMenu.addMenuListener(
        new javax.swing.event.MenuListener() {
          public void menuCanceled(MenuEvent e) {}

          public void menuDeselected(MenuEvent e) {}

          public void menuSelected(MenuEvent e) {
            windowMenu_menuSelected(e);
          }
        });
    coordinateLabel.setBorder(BorderFactory.createLoweredBevelBorder());
    wmsLabel.setBorder(BorderFactory.createLoweredBevelBorder());
    coordinateLabel.setText(" ");
    statusPanel.setLayout(gridBagLayout1);
    statusPanel.setBorder(BorderFactory.createRaisedBevelBorder());
    messageLabel.setBorder(BorderFactory.createLoweredBevelBorder());
    messageLabel.setText(" ");
    timeLabel.setBorder(BorderFactory.createLoweredBevelBorder());
    timeLabel.setText(" ");
    memoryLabel.setBorder(BorderFactory.createLoweredBevelBorder());
    memoryLabel.setText(" ");
    menuBar.add(fileMenu);
    menuBar.add(windowMenu);
    getContentPane().add(toolBar, BorderLayout.NORTH);
    getContentPane().add(desktopPane, BorderLayout.CENTER);
    fileMenu.addSeparator();
    fileMenu.add(exitMenuItem);
    statusPanel.add(
        coordinateLabel,
        new GridBagConstraints(
            5,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));
    statusPanel.add(
        timeLabel,
        new GridBagConstraints(
            2,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));
    statusPanel.add(
        messageLabel,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));

    // Give memoryLabel the 1.0 weight. All the rest should have their
    // sizes
    // configured using #configureStatusLabel. [Jon Aquino]
    statusPanel.add(
        memoryLabel,
        new GridBagConstraints(
            3,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));
    statusPanel.add(
        wmsLabel,
        new GridBagConstraints(
            4,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));
  }