/**
  * Renvoit le JPanel de gauche, avec le titre du champ. Utilisé dans le cas où il n'y a pas
  * d'enfants.
  */
 private JPanel getPanelGauche() {
   panelGauche = new JPanel(new FlowLayout(FlowLayout.LEFT));
   final JButton baide = new JButton(new ActionAide(refNoeud));
   baide.setFont(baide.getFont().deriveFont((float) 9));
   if (System.getProperty("os.name").startsWith("Mac OS")) {
     baide.setText("?");
     if ("10.5".compareTo(System.getProperty("os.version")) <= 0)
       baide.putClientProperty("JButton.buttonType", "help");
     else baide.putClientProperty("JButton.buttonType", "toolbar");
   } else {
     baide.setIcon(new ImageIcon(ImageKeeper.loadImage("images/aide.png")));
     baide.setMargin(new Insets(0, 0, 0, 0));
     baide.setBorderPainted(false);
     baide.setContentAreaFilled(false);
   }
   String documentation = getDocumentation();
   if (documentation != null) baide.setToolTipText(documentation);
   if (documentation == null && attribut) baide.setEnabled(false);
   panelGauche.add(baide);
   labelTitre = new JLabel(getTitre());
   if (affParent != null) {
     if (obligatoire()) labelTitre.setForeground(couleurObligatoire);
     else labelTitre.setForeground(couleurFacultatif);
   }
   panelGauche.add(labelTitre);
   return (panelGauche);
 }
Exemplo n.º 2
0
 void setCopyright(String copyright) {
   Component c = null;
   if (copyrightUrl == null) {
     JLabel l = new JLabel("(" + copyright + ")");
     c = l;
     gc.insets.bottom = 0;
   } else {
     JButton b = new JButton(copyright != null ? copyright : "Copyright");
     b.setFont(b.getFont().deriveFont(Font.ITALIC));
     b.setForeground(Color.blue);
     b.setBackground(background);
     b.setContentAreaFilled(false);
     b.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.blue));
     b.addActionListener(
         new ActionListener() {
           public void actionPerformed(ActionEvent e) {
             loadCopyright();
           }
         });
     c = b;
     gc.insets.bottom = 5;
   }
   gb.setConstraints(c, gc);
   getPanel().add(c);
 }
  public static void setJButtonSizesTheSame(final JButton[] btns) {
    if (btns == null) {
      throw new IllegalArgumentException();
    }

    final Dimension maxSize = new Dimension(0, 0);
    for (int i = 0; i < btns.length; ++i) {
      final JButton btn = btns[i];
      final FontMetrics fm = btn.getFontMetrics(btn.getFont());
      final Rectangle2D bounds = fm.getStringBounds(btn.getText(), btn.getGraphics());
      final int boundsHeight = (int) bounds.getHeight();
      final int boundsWidth = (int) bounds.getWidth();
      maxSize.width = boundsWidth > maxSize.width ? boundsWidth : maxSize.width;
      maxSize.height = boundsHeight > maxSize.height ? boundsHeight : maxSize.height;
    }

    final Insets insets = btns[0].getInsets();
    maxSize.width += insets.left + insets.right;
    maxSize.height += insets.top + insets.bottom;

    for (int i = 0; i < btns.length; ++i) {
      final JButton btn = btns[i];
      btn.setPreferredSize(maxSize);
    }

    initComponentHeight(btns);
  }
 /** Panel avec le titre de l'élément, et les boutons d'aide et d'attributs de l'élément */
 private JPanel getPanelTitre() {
   final JButton baide = new JButton(new ActionAide(refNoeud));
   baide.setFont(baide.getFont().deriveFont((float) 9));
   if (System.getProperty("os.name").startsWith("Mac OS")) {
     baide.setText("?");
     if ("10.5".compareTo(System.getProperty("os.version")) <= 0)
       baide.putClientProperty("JButton.buttonType", "help");
     else baide.putClientProperty("JButton.buttonType", "toolbar");
   } else {
     baide.setIcon(new ImageIcon(ImageKeeper.loadImage("images/aide.png")));
     baide.setMargin(new Insets(0, 0, 0, 0));
     baide.setBorderPainted(false);
     baide.setContentAreaFilled(false);
   }
   String documentation = getDocumentation();
   if (documentation != null) baide.setToolTipText(documentation);
   final JPanel panelTitre = new JPanel();
   panelTitre.add(baide);
   final JLabel labelTitre = new JLabel(getTitre());
   Color couleurTitre;
   if (affParent != null) {
     if (obligatoire()) couleurTitre = couleurObligatoire;
     else couleurTitre = couleurFacultatif;
   } else couleurTitre = panelEnfants.getForeground();
   labelTitre.setForeground(couleurTitre);
   panelTitre.add(labelTitre);
   panelTitre.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
   final JPanel panelNord = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
   panelNord.add(panelTitre);
   return (panelNord);
 }
 /**
  * Creates a JButton with an X
  *
  * @return the button
  */
 private JButton createXButton() {
   JButton closeButton = new JButton("X");
   closeButton.setOpaque(false);
   closeButton.setMargin(null);
   closeButton.setFont(closeButton.getFont().deriveFont(Font.BOLD).deriveFont((float) 10));
   closeButton.setBorder(new EmptyBorder(1, 1, 1, 1));
   return closeButton;
 }
Exemplo n.º 6
0
  // Method to build the dialog box for help.
  private void buildDialogBox() {
    // Set the JDialog window properties.
    setTitle("Stack Trace Detail");
    setResizable(false);
    setSize(dialogWidth, dialogHeight);

    // Append the stack trace output to the display area.
    displayArea.append(eStackTrace);

    // Create horizontal and vertical scrollbars for box.
    displayBox = Box.createHorizontalBox();
    displayBox = Box.createVerticalBox();

    // Add a JScrollPane to the Box.
    displayBox.add(new JScrollPane(displayArea));

    // Define behaviors of container.
    c.setLayout(null);
    c.add(displayBox);
    c.add(okButton);

    // Set scroll pane bounds.
    displayBox.setBounds(
        (dialogWidth / 2) - ((displayAreaWidth / 2) + 2),
        (top + (offsetMargin / 2)),
        displayAreaWidth,
        displayAreaHeight);

    // Set the behaviors, bounds and action listener for the button.
    okButton.setBounds(
        (dialogWidth / 2) - (buttonWidth / 2),
        (displayAreaHeight + offsetMargin),
        buttonWidth,
        buttonHeight);

    // Set the font to the platform default Font for the object with the
    // properties of bold and font size of 11.
    okButton.setFont(new Font(okButton.getFont().getName(), Font.BOLD, 11));

    // The class implements the ActionListener interface and therefore
    // provides an implementation of the actionPerformed() method.  When a
    // class implements ActionListener, the instance handler returns an
    // ActionListener.  The ActionListener then performs actionPerformed()
    // method on an ActionEvent.
    okButton.addActionListener(this);

    // Set the screen and display dialog window in relation to screen size.
    setLocation((dim.width / 2) - (dialogWidth / 2), (dim.height / 2) - (dialogHeight / 2));

    // Display JDialog.
    show();
  } // End of buildDialogBox method.
Exemplo n.º 7
0
  public RollResultView() {

    this.setOpaque(true);
    this.setLayout(new BorderLayout());
    this.setBorder(BorderFactory.createLineBorder(Color.black, BORDER_WIDTH));

    // add the title label to the panel
    titleLabel = new JLabel("Roll Results");
    Font titleLabelFont = titleLabel.getFont();
    titleLabelFont = titleLabelFont.deriveFont(titleLabelFont.getStyle(), TITLE_TEXT_SIZE);
    titleLabel.setFont(titleLabelFont);
    this.add(titleLabel, BorderLayout.NORTH);

    // add the button to the panel
    okayButton = new JButton("Okay");
    okayButton.addActionListener(actionListener);
    Font okayButtonFont = okayButton.getFont();
    okayButtonFont = okayButtonFont.deriveFont(okayButtonFont.getStyle(), BUTTON_TEXT_SIZE);
    okayButton.setFont(okayButtonFont);
    this.add(okayButton, BorderLayout.SOUTH);

    // create the rollLabel
    rollLabel =
        new JLabel(
            "ERROR: YOU FORGOT TO SET THE ROLL VALUE BEFORE DISPLAYING THIS WINDOW... NAUGHTY, NAUGHTY");
    Font rollLabelFont = rollLabel.getFont();
    rollLabelFont = rollLabelFont.deriveFont(rollLabelFont.getStyle(), LABEL_TEXT_SIZE);
    rollLabel.setFont(rollLabelFont);
    rollLabel.setHorizontalAlignment(SwingConstants.CENTER);
    rollLabel.setBorder(BorderFactory.createEmptyBorder(25, 0, 25, 0));

    // create the picture
    picture =
        new ImageIcon(
            ImageUtils.loadImage("images/resources/resources.png")
                .getScaledInstance(250, 250, Image.SCALE_SMOOTH));
    pictureLabel = new JLabel();
    pictureLabel.setIcon(picture);

    // create the center label
    centerPanel = new JPanel();
    centerPanel.setLayout(new BorderLayout());
    centerPanel.add(pictureLabel, BorderLayout.NORTH);
    centerPanel.add(Box.createRigidArea(new Dimension(25, 25)));
    centerPanel.add(rollLabel, BorderLayout.SOUTH);
    this.add(centerPanel, BorderLayout.CENTER);

    // add some spacing
    this.add(Box.createRigidArea(new Dimension(50, 50)), BorderLayout.EAST);
    this.add(Box.createRigidArea(new Dimension(50, 50)), BorderLayout.WEST);
  }
    /** Constructor. */
    public FileChooserCellEditor() {
      super(new JTextField());
      setClickCountToStart(CLICK_COUNT_TO_START);

      // Using a JButton as the editor component
      button = new JButton();
      button.setBackground(Color.white);
      button.setFont(button.getFont().deriveFont(Font.PLAIN));
      button.setBorder(null);

      // Dialog which will do the actual editing
      fileChooser = new JFileChooser();
      fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    }
Exemplo n.º 9
0
    // Method to build the dialog box for help.
    private void buildDialogBox() {
      // Set the JDialog window properties.
      setTitle("Learning about Java");
      setResizable(false);
      setSize(dialogWidth, dialogHeight);

      // Define behaviors of container.
      c.setLayout(null);
      c.setBackground(Color.cyan);
      c.add(image);
      c.add(okButton);

      // Set the bounds for the image.
      image.setBounds(
          (dialogWidth / 2) - (imageWidth / 2),
          (top + (offsetMargin / 2)),
          imageWidth,
          imageHeight);

      // Set the behaviors, bounds and action listener for the button.
      okButton.setBounds(
          (dialogWidth / 2) - (buttonWidth / 2),
          (imageHeight + (int) 1.5 * offsetMargin),
          buttonWidth,
          buttonHeight);

      // Set the font to the platform default Font for the object with the
      // properties of bold and font size of 11.
      okButton.setFont(new Font(okButton.getFont().getName(), Font.BOLD, 11));

      // Set foreground and background of JButton(s).
      okButton.setForeground(Color.white);
      okButton.setBackground(Color.blue);

      // The class implements the ActionListener interface and therefore
      // provides an implementation of the actionPerformed() method.  When a
      // class implements ActionListener, the instance handler returns an
      // ActionListener.  The ActionListener then performs actionPerformed()
      // method on an ActionEvent.
      okButton.addActionListener(this);

      // Set the screen and display dialog window in relation to screen size.
      dim = tk.getScreenSize();
      setLocation((dim.width / 2) - (dialogWidth / 2), (dim.height / 2) - (dialogHeight / 2));

      // Display the dialog.
      show();
    } // End of buildDialogBox method.
  /**
   * Set up the expander button to display qualifier values.
   *
   * @param butt - expander button
   * @param qualifier - the qualifer that is being displayed
   * @param qualifierValueBox - Box containing the values
   * @param qualifierNameCheckBox - JCheckBox for the given qualifier
   * @param pane
   * @return
   */
  private Vector<JCheckBox> setExpanderButton(
      final JButton butt,
      final Qualifier qualifier,
      final Box qualifierValueBox,
      final JCheckBox qualifierNameCheckBox) {
    butt.setMargin(new Insets(0, 0, 0, 0));
    butt.setHorizontalAlignment(SwingConstants.RIGHT);
    butt.setHorizontalTextPosition(SwingConstants.RIGHT);
    butt.setBorderPainted(false);
    butt.setFont(butt.getFont().deriveFont(Font.BOLD));
    butt.setForeground(TransferAnnotationTool.STEEL_BLUE);

    butt.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (butt.getText().equals("+")) butt.setText("-");
            else butt.setText("+");

            qualifierValueBox.setVisible(butt.getText().equals("-"));
            revalidate();
          }
        });

    // set-up qualifier values list
    qualifierValueBox.setVisible(false);
    final Vector<JCheckBox> qualifierValuesCheckBox = new Vector<JCheckBox>();
    final StringVector values = qualifier.getValues();
    if (values != null) {
      for (int i = 0; i < values.size(); i++) {
        final JCheckBox cb = new JCheckBox(values.get(i), qualifierNameCheckBox.isSelected());
        cb.setFont(cb.getFont().deriveFont(Font.ITALIC));
        qualifierValueBox.add(cb);
        qualifierValuesCheckBox.add(cb);
      }
    }
    return qualifierValuesCheckBox;
  }
Exemplo n.º 11
0
    public void startDrop(PieceType pieceType, CatanColor pieceColor, boolean isCancelAllowed) {

      this.setOpaque(false);
      this.setLayout(new BorderLayout());
      this.setBorder(BorderFactory.createLineBorder(Color.black, BORDER_WIDTH));

      label = new JLabel(getLabelText(pieceType), JLabel.CENTER);
      label.setOpaque(true);
      label.setBackground(Color.white);
      Font labelFont = label.getFont();
      labelFont = labelFont.deriveFont(labelFont.getStyle(), LABEL_TEXT_SIZE);
      label.setFont(labelFont);

      map = mainMap.copy();
      map.setController(getController());

      int prefWidth = (int) (mainMap.getScale() * mainMap.getPreferredSize().getWidth());
      int prefHeight = (int) (mainMap.getScale() * mainMap.getPreferredSize().getHeight());
      Dimension prefSize = new Dimension(prefWidth, prefHeight);
      map.setPreferredSize(prefSize);

      this.add(label, BorderLayout.NORTH);
      this.add(map, BorderLayout.CENTER);

      if (isCancelAllowed) {

        cancelButton = new JButton("Cancel");
        Font buttonFont = cancelButton.getFont();
        buttonFont = buttonFont.deriveFont(buttonFont.getStyle(), BUTTON_TEXT_SIZE);
        cancelButton.setFont(buttonFont);
        cancelButton.addActionListener(cancelButtonListener);
        this.add(cancelButton, BorderLayout.SOUTH);
      }

      map.startDrop(pieceType, pieceColor);
    }
Exemplo n.º 12
0
    private void initComponents() {
      label1 = new JLabel();
      comboBox1 = new JComboBox();
      button1 = new JButton();

      // ======== this ========
      setTitle("SneakyFarmer");
      Container contentPane = getContentPane();
      contentPane.setLayout(null);

      // ---- label1 ----
      label1.setText("Which herb to farm:");
      label1.setFont(label1.getFont().deriveFont(label1.getFont().getSize() + 1f));
      contentPane.add(label1);
      label1.setBounds(10, 10, 125, 35);

      // ---- comboBox1 ----
      comboBox1.setModel(
          new DefaultComboBoxModel(
              new String[] {
                "Guam",
                "Marrentill",
                "Tarromin",
                "Harralander",
                "Ranarr",
                "Toadflax",
                "Irit",
                "Avantoe",
                "Kwuarm",
                "Snapdragon",
                "Cadantine",
                "Lantadyme",
                "Dwarf Weed",
                "Torstol"
              }));
      contentPane.add(comboBox1);
      comboBox1.setBounds(135, 10, 90, 35);

      // ---- button1 ----
      button1.setText("Start Farming!");
      button1.setFont(button1.getFont().deriveFont(button1.getFont().getSize() + 7f));
      contentPane.add(button1);
      button1.setBounds(10, 50, 215, 35);
      button1.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              startActionPerformed(e);
            }
          });

      { // compute preferred size
        Dimension preferredSize = new Dimension();
        for (int i = 0; i < contentPane.getComponentCount(); i++) {
          Rectangle bounds = contentPane.getComponent(i).getBounds();
          preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
          preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
        }
        Insets insets = contentPane.getInsets();
        preferredSize.width += insets.right;
        preferredSize.height += insets.bottom;
        contentPane.setMinimumSize(preferredSize);
        contentPane.setPreferredSize(preferredSize);
      }
      pack();
      setLocationRelativeTo(getOwner());
    }
Exemplo n.º 13
0
  /** Initializes the components composing the display. */
  private void initComponents() {
    toReplace = new ArrayList<FileAnnotationData>();
    IconManager icons = IconManager.getInstance();
    filter = SHOW_ALL;
    filterButton = new JButton(NAMES[SHOW_ALL]);
    filterButton.setToolTipText("Filter tags and attachments.");
    UIUtilities.unifiedButtonLookAndFeel(filterButton);
    Font font = filterButton.getFont();
    filterButton.setFont(font.deriveFont(font.getStyle(), font.getSize() - 2));

    filterButton.setIcon(icons.getIcon(IconManager.UP_DOWN_9_12));

    filterButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    filterButton.addMouseListener(
        new MouseAdapter() {

          /**
           * Brings up the menu.
           *
           * @see MouseListener#mouseReleased(MouseEvent)
           */
          public void mouseReleased(MouseEvent me) {
            Object source = me.getSource();
            if (source instanceof Component) displayMenu((Component) source, me.getPoint());
          }
        });

    otherRating = new JLabel();
    otherRating.setBackground(UIUtilities.BACKGROUND_COLOR);
    font = otherRating.getFont();
    otherRating.setFont(font.deriveFont(Font.ITALIC, font.getSize() - 2));
    content = new JPanel();
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    content.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    tagFlag = false;
    docFlag = false;
    tagNames = new ArrayList<String>();
    tagsDocList = new ArrayList<DocComponent>();
    filesDocList = new ArrayList<DocComponent>();
    existingTags = new HashMap<String, TagAnnotationData>();

    addTagsButton = new JButton(icons.getIcon(IconManager.PLUS_12));
    UIUtilities.unifiedButtonLookAndFeel(addTagsButton);
    addTagsButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    addTagsButton.setToolTipText("Add Tags.");
    addTagsButton.addActionListener(controller);
    addTagsButton.setActionCommand("" + EditorControl.ADD_TAGS);
    addDocsButton = new JButton(icons.getIcon(IconManager.PLUS_12));
    addDocsButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    addDocsButton.setToolTipText("Attach a document.");
    addDocsButton.addMouseListener(
        new MouseAdapter() {

          public void mouseReleased(MouseEvent e) {
            if (addDocsButton.isEnabled()) {
              Point p = e.getPoint();
              createDocSelectionMenu().show(addDocsButton, p.x, p.y);
            }
          }
        });
    UIUtilities.unifiedButtonLookAndFeel(addDocsButton);

    removeTagsButton = new JButton(icons.getIcon(IconManager.MINUS_12));
    UIUtilities.unifiedButtonLookAndFeel(removeTagsButton);
    removeTagsButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    removeTagsButton.setToolTipText("Unlink Tags.");
    removeTagsButton.addMouseListener(controller);
    removeTagsButton.setActionCommand("" + EditorControl.REMOVE_TAGS);
    removeDocsButton = new JButton(icons.getIcon(IconManager.MINUS_12));
    UIUtilities.unifiedButtonLookAndFeel(removeDocsButton);
    removeDocsButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    removeDocsButton.setToolTipText("Unlink Attachments.");
    removeDocsButton.addMouseListener(controller);
    removeDocsButton.setActionCommand("" + EditorControl.REMOVE_DOCS);

    selectedValue = 0;
    initialValue = selectedValue;
    rating = new RatingComponent(selectedValue, RatingComponent.MEDIUM_SIZE);
    rating.setOpaque(false);
    rating.setBackground(UIUtilities.BACKGROUND_COLOR);
    rating.addPropertyChangeListener(this);
    unrateButton = new JButton(icons.getIcon(IconManager.MINUS_12));
    UIUtilities.unifiedButtonLookAndFeel(unrateButton);
    unrateButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    unrateButton.setToolTipText("Unrate.");
    unrateButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            rating.setValue(0);
            view.saveData(true);
          }
        });
    tagsPane = new JPanel();
    tagsPane.setLayout(new BoxLayout(tagsPane, BoxLayout.Y_AXIS));
    tagsPane.setBackground(UIUtilities.BACKGROUND_COLOR);
    DocComponent doc = new DocComponent(null, model);
    tagsDocList.add(doc);
    tagsPane.add(doc);
    docPane = new JPanel();
    docPane.setLayout(new BoxLayout(docPane, BoxLayout.Y_AXIS));
    docPane.setBackground(UIUtilities.BACKGROUND_COLOR);
    docRef = docPane;
    doc = new DocComponent(null, model);
    filesDocList.add(doc);
    docPane.add(doc);
    publishedBox = new JCheckBox();
    publishedBox.setBackground(UIUtilities.BACKGROUND_COLOR);
    publishedBox.addItemListener(
        new ItemListener() {

          public void itemStateChanged(ItemEvent e) {
            firePropertyChange(EditorControl.SAVE_PROPERTY, Boolean.FALSE, Boolean.TRUE);
          }
        });
  }
Exemplo n.º 14
0
    private void initComponents() {
        webView = WebpagePanel.forURL(launcher.getNewsURL(), false);
        splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, instanceScroll, webView);

        configureFeaturesCheck.setSelected(false);
        instancesTable.setModel(instancesModel);
        launchButton.setFont(launchButton.getFont().deriveFont(Font.BOLD));
        splitPane.setDividerLocation(200);
        splitPane.setDividerSize(4);
        SwingHelper.flattenJSplitPane(splitPane);
        buttonsPanel.addElement(refreshButton);
        buttonsPanel.addElement(configureFeaturesCheck);
        buttonsPanel.addGlue();
        buttonsPanel.addElement(optionsButton);
        buttonsPanel.addElement(launchButton);
        container.setLayout(new BorderLayout());
        container.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
        container.add(splitPane, BorderLayout.CENTER);
        add(buttonsPanel, BorderLayout.SOUTH);
        add(container, BorderLayout.CENTER);

        instancesModel.addTableModelListener(new TableModelListener() {
            @Override
            public void tableChanged(TableModelEvent e) {
                if (instancesTable.getRowCount() > 0) {
                    instancesTable.setRowSelectionInterval(0, 0);
                }
            }
        });

        instancesTable.addMouseListener(new DoubleClickToButtonAdapter(launchButton));

        refreshButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                loadInstances();
                checkLauncherUpdate();
            }
        });

        optionsButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                showOptions();
            }
        });

        launchButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                launch();
            }
        });

        instancesTable.addMouseListener(new PopupMouseAdapter() {
            @Override
            protected void showPopup(MouseEvent e) {
                int index = instancesTable.rowAtPoint(e.getPoint());
                Instance selected = null;
                if (index >= 0) {
                    instancesTable.setRowSelectionInterval(index, index);
                    selected = launcher.getInstances().get(index);
                }
                popupInstanceMenu(e.getComponent(), e.getX(), e.getY(), selected);
            }
        });
    }
Exemplo n.º 15
0
  /**
   * Fill the given panel by adding all necessary components to the different locations.
   *
   * @param panel The container to fill. Must have an BorderLayout.
   */
  public void fillPanel(Container panel) {
    panel.add(this, BorderLayout.CENTER);
    JToolBar jb = new JToolBar(JToolBar.VERTICAL);
    jb.setFloatable(false);
    toolBarActions.setAlignmentX(0.5f);
    jb.add(toolBarActions);
    listAllMapModesButton.setAlignmentX(0.5f);
    listAllMapModesButton.setBorder(null);
    listAllMapModesButton.setFont(listAllMapModesButton.getFont().deriveFont(Font.PLAIN));
    jb.add(listAllMapModesButton);

    if (Main.pref.getBoolean("sidetoolbar.togglevisible", true)) {
      jb.addSeparator(new Dimension(0, 18));
      toolBarToggle.setAlignmentX(0.5f);
      jb.add(toolBarToggle);
      listAllToggleDialogsButton.setAlignmentX(0.5f);
      listAllToggleDialogsButton.setBorder(null);
      listAllToggleDialogsButton.setFont(
          listAllToggleDialogsButton.getFont().deriveFont(Font.PLAIN));
      jb.add(listAllToggleDialogsButton);
    }

    final Component toToggle;
    if (Main.pref.getBoolean("sidetoolbar.scrollable", true)) {
      final ScrollViewport svp = new ScrollViewport(jb, ScrollViewport.VERTICAL_DIRECTION);
      toToggle = svp;
      panel.add(svp, BorderLayout.WEST);
      jb.addMouseWheelListener(
          new MouseWheelListener() {

            public void mouseWheelMoved(MouseWheelEvent e) {
              svp.scroll(0, e.getUnitsToScroll() * 5);
            }
          });
    } else {
      toToggle = jb;
      panel.add(jb, BorderLayout.WEST);
    }
    toToggle.setVisible(Main.pref.getBoolean("sidetoolbar.visible", true));

    jb.addMouseListener(
        new PopupMenuLauncher(
            new JPopupMenu() {

              {
                add(
                    new AbstractAction(tr("Hide edit toolbar")) {

                      @Override
                      public void actionPerformed(ActionEvent e) {
                        Main.pref.put("sidetoolbar.visible", false);
                      }
                    });
              }
            }));

    Main.pref.addPreferenceChangeListener(
        new Preferences.PreferenceChangedListener() {

          @Override
          public void preferenceChanged(PreferenceChangeEvent e) {
            if ("sidetoolbar.visible".equals(e.getKey())) {
              toToggle.setVisible(Main.pref.getBoolean("sidetoolbar.visible"));
            }
          }
        });

    if (statusLine != null && Main.pref.getBoolean("statusline.visible", true)) {
      panel.add(statusLine, BorderLayout.SOUTH);
    }
  }
Exemplo n.º 16
0
  /**
   * Fill the given panel by adding all necessary components to the different locations.
   *
   * @param panel The container to fill. Must have an BorderLayout.
   */
  public void fillPanel(Container panel) {
    panel.add(this, BorderLayout.CENTER);

    /** sideToolBar: add map modes icons */
    if (Main.pref.getBoolean("sidetoolbar.mapmodes.visible", true)) {
      toolBarActions.setAlignmentX(0.5f);
      toolBarActions.setInheritsPopupMenu(true);
      sideToolBar.add(toolBarActions);
      listAllMapModesButton.setAlignmentX(0.5f);
      listAllMapModesButton.setBorder(null);
      listAllMapModesButton.setFont(listAllMapModesButton.getFont().deriveFont(Font.PLAIN));
      listAllMapModesButton.setInheritsPopupMenu(true);
      sideToolBar.add(listAllMapModesButton);
    }

    /** sideToolBar: add toggle dialogs icons */
    if (Main.pref.getBoolean("sidetoolbar.toggledialogs.visible", true)) {
      ((JToolBar) sideToolBar).addSeparator(new Dimension(0, 18));
      toolBarToggle.setAlignmentX(0.5f);
      toolBarToggle.setInheritsPopupMenu(true);
      sideToolBar.add(toolBarToggle);
      listAllToggleDialogsButton.setAlignmentX(0.5f);
      listAllToggleDialogsButton.setBorder(null);
      listAllToggleDialogsButton.setFont(
          listAllToggleDialogsButton.getFont().deriveFont(Font.PLAIN));
      listAllToggleDialogsButton.setInheritsPopupMenu(true);
      sideToolBar.add(listAllToggleDialogsButton);
    }

    /** sideToolBar: add dynamic popup menu */
    sideToolBar.setComponentPopupMenu(
        new JPopupMenu() {
          static final int staticMenuEntryCount = 2;
          JCheckBoxMenuItem doNotHide =
              new JCheckBoxMenuItem(
                  new AbstractAction(tr("Do not hide toolbar")) {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                      boolean sel = ((JCheckBoxMenuItem) e.getSource()).getState();
                      Main.pref.put("sidetoolbar.always-visible", sel);
                    }
                  });

          {
            addPopupMenuListener(
                new PopupMenuListener() {
                  @Override
                  public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
                    final Object src = ((JPopupMenu) e.getSource()).getInvoker();
                    if (src instanceof IconToggleButton) {
                      insert(new Separator(), 0);
                      insert(
                          new AbstractAction() {
                            {
                              putValue(NAME, tr("Hide this button"));
                              putValue(
                                  SHORT_DESCRIPTION,
                                  tr("Click the arrow at the bottom to show it again."));
                            }

                            @Override
                            public void actionPerformed(ActionEvent e) {
                              ((IconToggleButton) src).setButtonHidden(true);
                              validateToolBarsVisibility();
                            }
                          },
                          0);
                    }
                    doNotHide.setSelected(Main.pref.getBoolean("sidetoolbar.always-visible", true));
                  }

                  @Override
                  public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
                    while (getComponentCount() > staticMenuEntryCount) {
                      remove(0);
                    }
                  }

                  @Override
                  public void popupMenuCanceled(PopupMenuEvent e) {}
                });

            add(
                new AbstractAction(tr("Hide edit toolbar")) {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    Main.pref.put("sidetoolbar.visible", false);
                  }
                });
            add(doNotHide);
          }
        });
    ((JToolBar) sideToolBar).setFloatable(false);

    /** sideToolBar: decide scroll- and visibility */
    if (Main.pref.getBoolean("sidetoolbar.scrollable", true)) {
      final ScrollViewport svp = new ScrollViewport(sideToolBar, ScrollViewport.VERTICAL_DIRECTION);
      svp.addMouseWheelListener(
          new MouseWheelListener() {
            @Override
            public void mouseWheelMoved(MouseWheelEvent e) {
              svp.scroll(0, e.getUnitsToScroll() * 5);
            }
          });
      sideToolBar = svp;
    }
    sideToolBar.setVisible(Main.pref.getBoolean("sidetoolbar.visible", true));
    sidetoolbarPreferencesChangedListener =
        new Preferences.PreferenceChangedListener() {
          @Override
          public void preferenceChanged(PreferenceChangeEvent e) {
            if ("sidetoolbar.visible".equals(e.getKey())) {
              sideToolBar.setVisible(Main.pref.getBoolean("sidetoolbar.visible"));
            }
          }
        };
    Main.pref.addPreferenceChangeListener(sidetoolbarPreferencesChangedListener);

    /** sideToolBar: add it to the panel */
    panel.add(sideToolBar, BorderLayout.WEST);

    /** statusLine: add to panel */
    if (statusLine != null && Main.pref.getBoolean("statusline.visible", true)) {
      panel.add(statusLine, BorderLayout.SOUTH);
    }
  }
  public AnnotationSidePanel(final Browser br, final Fab4 f) {
    super(new BorderLayout(5, 3));
    bro = br;
    fab = f;
    final PersonalAnnos bu = (PersonalAnnos) Fab4utils.getBe("Personal", br.getRoot().getLayers());
    // JPanel icos = new JPanel(new FlowLayout(FlowLayout.CENTER,3,2));
    setBorder(new LineBorder(AnnotationSidePanel.publicColor, 2));
    JPanel topp = new JPanel(new BorderLayout(4, 1));
    annotationPaneLabel = new JComboBox(new String[] {"Public notes", "Private notes"});
    annotationPaneLabel.setToolTipText("Choose if public or private");
    annotationPaneLabel.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) loadRemoteCombo();
          }
        });
    annotationPaneLabel.setFont(annotationPaneLabel.getFont().deriveFont(Font.BOLD));

    topp.add(BorderLayout.NORTH, annotationPaneLabel);
    JPanel south = new JPanel(new FlowLayout(FlowLayout.CENTER, 1, 1));
    final JTextField tt = new JTextField("type search");
    tt.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(java.awt.event.MouseEvent e) {
            if (e.getButton() == java.awt.event.MouseEvent.BUTTON1) tt.selectAll();
          }
        });
    tt.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent arg0) {
            if (arg0.getKeyChar() == '\n') {
              String txt = ((JTextField) arg0.getSource()).getText();
              search(txt);
            }
          }
        });
    JButton lb = new JButton(FabIcons.getIcons().ICOLIGHT);
    lb.setToolTipText("Search in the annotations");
    lb.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            search(tt.getText());
          }
        });
    south.add(tt);
    south.add(lb);

    // TODO: do a better search, separate window
    JComboBox cb = new JComboBox(new String[] {"Date", "Author", "Trust", "Position"});
    cb.setToolTipText("Sort notes by:");
    cb.setEditable(false);
    JPanel t = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 1));
    t.add(new JLabel("sort"));
    t.add(cb);
    topp.add(BorderLayout.SOUTH, t);

    // int wi = bHideAnno.getPreferredSize().width*3+20;
    // wi = Math.max(wi,annotationPaneLabel.getPreferredSize().width);
    int hei =
        annotationPaneLabel.getPreferredSize().height + /*
		 * bHideAnno.getPreferredSize
		 * ().height
		 */ +10 + tt.getPreferredSize().height;
    Dimension dim = new Dimension(annotationPaneLabel.getPreferredSize().width, hei);
    topp.setPreferredSize(dim);
    topp.setMinimumSize(dim);
    topp.setMaximumSize(dim);

    annoUserList = new JList();
    annoUserList.setAutoscrolls(true);
    annoUserList.setBackground(new Color(255, 255, 230));
    annoUserList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    bdeleAnno = new JButton("Delete", FabIcons.getIcons().ICODEL);
    bdeleAnno.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            for (int i : annoUserList.getSelectedIndices())
              br.eventq(PersonalAnnos.MSG_DELETE, bu.user.get(i));
          }
        });
    bdeleAnno.setToolTipText("Delete selected notes");
    if (bu != null) {
      annoUserList.setModel(bu.user);
      Component[] t1 = new Component[1];
      t1[0] = bdeleAnno;
      bu.addUIElementsToFab4List(annoUserList, t1, cb);
    }
    bdeleAnno.setEnabled(false);
    add(topp, BorderLayout.NORTH);
    JScrollPane scrollPane = new JScrollPane(annoUserList);
    add(scrollPane, BorderLayout.CENTER);
    annoUserList.addListSelectionListener(
        new ListSelectionListener() {

          public void valueChanged(ListSelectionEvent e) {
            Object[] index = annoUserList.getSelectedValues();
            if (index.length > 0) bCopy.setEnabled(true);
            else bCopy.setEnabled(false);
            nsel.setText("" + index.length);
          }
        });

    JPanel ppp = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 1));
    bCopy = new JButton("Copy  ", FabIcons.getIcons().ICOPUB);
    Font nf = bCopy.getFont();
    nf.deriveFont((float) (nf.getSize2D() * 0.8));
    bCopy.setFont(nf);
    bCopy.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            br.eventq(PersonalAnnos.MSG_COPY, "");
          }
        });
    bCopy.setToolTipText("Copies the selected notes to the server or local database");
    ppp.add(bCopy);
    bCopy.setEnabled(false);

    bdeleAnno.setFont(nf);

    ppp.add(bdeleAnno);
    ppp.setPreferredSize(
        new Dimension(ppp.getPreferredSize().width, bdeleAnno.getPreferredSize().height * 2 + 3));

    nsel = new JLabel(" ");
    nsel.setFont(nf);
    ppp.add(nsel);
    add(ppp, BorderLayout.SOUTH);
  }
Exemplo n.º 18
0
  private void buildConvoActions() {
    if (convoButtons != null) {
      if (!convoButtons.isEmpty()) {
        Iterator it = convoButtons.iterator();
        while (it.hasNext()) {
          JButton b = (JButton) it.next();
          remove(b);
        }
      }
      convoButtons = null;
    }

    if ((convoFlags > 0) && (fconvolution != null)) {
      JButton but = null;
      convoButtons = new ArrayList<JButton>();

      if ((convoFlags & DLIC.DLIC_FLAG_E) == DLIC.DLIC_FLAG_E) {
        TealAction efAction =
            new TealAction("Electric Field:  Grass Seeds", String.valueOf(DLIC.DLIC_FLAG_E), this);
        sharedActions.add(efAction);
        but = new JButton(efAction);
        but.setFont(but.getFont().deriveFont(Font.BOLD));
        convoButtons.add(but);
        add(but);
      }

      if ((convoFlags & DLIC.DLIC_FLAG_B) == DLIC.DLIC_FLAG_B) {
        TealAction mfAction =
            new TealAction("Magnetic Field:  Iron Filings", String.valueOf(DLIC.DLIC_FLAG_B), this);
        sharedActions.add(mfAction);
        but = new JButton(mfAction);
        but.setFont(but.getFont().deriveFont(Font.BOLD));
        convoButtons.add(but);
        add(but);
      }

      if ((convoFlags & DLIC.DLIC_FLAG_G) == DLIC.DLIC_FLAG_G) {
        TealAction gAction = new TealAction("Gravity", String.valueOf(DLIC.DLIC_FLAG_G), this);
        sharedActions.add(gAction);
        but = new JButton(gAction);
        convoButtons.add(but);
        add(but);
      }

      if ((convoFlags & DLIC.DLIC_FLAG_P) == DLIC.DLIC_FLAG_P) {
        TealAction pAction = new TealAction("Pauli Forces", String.valueOf(DLIC.DLIC_FLAG_P), this);
        sharedActions.add(pAction);
        but = new JButton(pAction);
        convoButtons.add(but);
        add(but);
      }

      if ((convoFlags & DLIC.DLIC_FLAG_EP) == DLIC.DLIC_FLAG_EP) {
        TealAction epAction =
            new TealAction("Electric Potential", String.valueOf(DLIC.DLIC_FLAG_EP), this);
        sharedActions.add(epAction);
        but = new JButton(epAction);
        but.setFont(but.getFont().deriveFont(Font.BOLD));
        convoButtons.add(but);
        add(but);
      }

      if ((convoFlags & DLIC.DLIC_FLAG_BP) == DLIC.DLIC_FLAG_BP) {
        TealAction mpAction =
            new TealAction("Magnetic Potential", String.valueOf(DLIC.DLIC_FLAG_BP), this);
        sharedActions.add(mpAction);
        but = new JButton(mpAction);
        convoButtons.add(but);
        add(but);
      }

      if ((convoFlags & DLIC.DLIC_FLAG_EF) == DLIC.DLIC_FLAG_EF) {
        TealAction efAction =
            new TealAction("Electic Flux", String.valueOf(DLIC.DLIC_FLAG_EF), this);
        sharedActions.add(efAction);
        but = new JButton(efAction);
        convoButtons.add(but);
        add(but);
      }

      if ((convoFlags & DLIC.DLIC_FLAG_BF) == DLIC.DLIC_FLAG_BF) {
        TealAction mfAction =
            new TealAction("Magnetic Flux", String.valueOf(DLIC.DLIC_FLAG_BF), this);
        sharedActions.add(mfAction);
        but = new JButton(mfAction);
        convoButtons.add(but);
        add(but);
      }

      if (convoProgress == null) {
        convoProgress = new ProgressBar();
        fconvolution.addProgressEventListener(convoProgress);
        add(convoProgress);
      }
    }
  }
  public ProgressBarGeneticDialog(
      MainWindowInnerInterface mainWindow, DataLayerFacade dataLayer, Graph graph) {
    super(
        (JFrame) mainWindow,
        dataLayer.getString("GENETIC_ALGORITHM_RUNNING"),
        ModalityType.APPLICATION_MODAL);

    // create genetic graph from graph
    this.geneticGraph =
        new GeneticGraph(
            graph,
            graph.getAbstractHwComponentsCount()); // graph.getAbstractHwComponentsCount() * 2

    this.dataLayer = dataLayer;

    this.setLocationRelativeTo((JFrame) mainWindow);

    mainPanel = new JPanel(new BorderLayout());

    controlPanel = new JPanel();

    cancelButton = new JButton(dataLayer.getString("CANCEL"));
    cancelButton.addActionListener((ActionListener) this);
    cancelButton.setActionCommand(CANCEL_COMMAND);
    cancelButton.setEnabled(true);

    enoughQuality = new JButton(dataLayer.getString("ENOUGH_QUALITY"));
    enoughQuality.addActionListener((ActionListener) this);
    enoughQuality.setActionCommand(ENOUGH_QUALITY_COMMAND);
    enoughQuality.setEnabled(false);

    progressBar = new JProgressBar();
    progressBar.setIndeterminate(true);

    controlPanel.add(cancelButton);
    // controlPanel.add(enoughQuality);
    controlPanel.add(progressBar);

    taskOutput = new JTextArea(10, 35);
    taskOutput.setMargin(new Insets(5, 5, 5, 5));
    taskOutput.setEditable(false);
    DefaultCaret caret = (DefaultCaret) taskOutput.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    taskOutput.setFont(cancelButton.getFont());

    mainPanel.add(controlPanel, BorderLayout.PAGE_START);
    mainPanel.add(new JScrollPane(taskOutput), BorderLayout.CENTER);

    mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 20, 20, 20));

    this.add(mainPanel);

    this.setSize(new Dimension(400, 300));
    this.setResizable(false);

    this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    this.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            doCancelAction();
          }
        });
  }
Exemplo n.º 20
0
  public void run() {
    try {
      final JButton createBucket = new JButton("Create Bucket");
      final JButton close = new JButton("Close");
      final JLabel blank = new JLabel(" ");
      final JLabel blank2 = new JLabel(" ");
      final JLabel blank3 = new JLabel(" ");
      final JTextField bucketName = new JTextField();
      final JTextField regionName = new JTextField(mainFrame.cred.getRegion());
      final JLabel name = new JLabel("Bucket Name:");
      final JLabel region_name = new JLabel("Region Name:");
      bucketName.setMaximumSize(new Dimension(200, 20));
      regionName.setMaximumSize(new Dimension(200, 20));
      name.setBackground(Color.WHITE);
      name.setForeground(Color.GRAY);
      name.setFont(name.getFont().deriveFont(14.0f));
      region_name.setBackground(Color.WHITE);
      region_name.setForeground(Color.GRAY);
      region_name.setFont(region_name.getFont().deriveFont(14.0f));
      createBucket.setBackground(Color.white);
      createBucket.setForeground(Color.BLUE);
      createBucket.setFont(createBucket.getFont().deriveFont(14.0f));
      createBucket.setBorder(null);
      close.setBackground(Color.white);
      close.setBorder(null);
      close.setForeground(Color.BLUE);
      close.setFont(close.getFont().deriveFont(14.0f));

      createBucket.setIcon(mainFrame.genericEngine);
      close.setIcon(mainFrame.genericEngine);

      jPanel15.setVisible(false);
      createBucket.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent e) {
              if (bucketName.getText().length() < 3) {
                close.doClick();
              } else {
                MakeBucketThread bt =
                    new MakeBucketThread(
                        mainFrame.cred.getAccess_key(),
                        mainFrame.cred.getSecret_key(),
                        bucketName.getText().toLowerCase(),
                        mainFrame.cred.getEndpoint(),
                        regionName.getText(),
                        mainFrame);
                bt.startc(
                    mainFrame.cred.getAccess_key(),
                    mainFrame.cred.getSecret_key(),
                    bucketName.getText().toLowerCase(),
                    mainFrame.cred.getEndpoint(),
                    regionName.getText(),
                    mainFrame);
                close.doClick();
              }
            }
          });

      close.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent e) {
              mainFrame.jPanel14.removeAll();
              mainFrame.jPanel14.repaint();
              mainFrame.jPanel14.revalidate();
              mainFrame.jPanel14.validate();
              mainFrame.drawBuckets();
            }
          });

      mainFrame.jPanel14.removeAll();
      mainFrame.jPanel14.setLayout(new BoxLayout(mainFrame.jPanel14, BoxLayout.Y_AXIS));
      mainFrame.jPanel14.add(name);
      mainFrame.jPanel14.add(bucketName);
      mainFrame.jPanel14.add(blank3);
      mainFrame.jPanel14.add(region_name);
      mainFrame.jPanel14.add(regionName);
      mainFrame.jPanel14.add(blank);
      mainFrame.jPanel14.add(createBucket);
      mainFrame.jPanel14.add(close);
      mainFrame.jPanel14.repaint();
      mainFrame.jPanel14.revalidate();
      mainFrame.jPanel14.validate();

    } catch (Exception makebucket) {
      jTextArea1.append("\n" + makebucket.getMessage());
    }
    mainFrame.calibrateTextArea();
  }
Exemplo n.º 21
0
  private void initComponent() {
    // TODO Auto-generated method stub

    top = new JPanel();

    nodeGraph = new JPanel();
    FRLayout<String, String> graphLayout = new FRLayout<String, String>(graph);
    nodeGraphView = new VisualizationViewer<String, String>(graphLayout);

    // nodeGraphView.setBackground(new Color(228,247,186));
    // nodeGraphView.setBackground(new Color(178,204,255));
    nodeGraphView.setBackground(new Color(255, 216, 216));

    nodeGraphView
        .getRenderContext()
        .setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<String>(
                nodeGraphView.getPickedEdgeState(), Color.black, Color.GREEN));
    nodeGraphView
        .getRenderContext()
        .setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(
                nodeGraphView.getPickedVertexState(),
                new Color(67, 116, 217),
                new Color(5, 0, 153)));
    final AbstractModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
    nodeGraphView.setGraphMouse(graphMouse);

    nodeGraphProtocolFilter = new JPanel();
    nodeGraph.add(nodeGraphProtocolFilter);
    nodeGraph.add(nodeGraphView);

    nodeGraphInform = new JPanel();
    nodeGraphMap = new SatelliteVisualizationViewer<String, String>(nodeGraphView);
    // nodeGraphMap.getRenderContext().setEdgeDrawPaintTransformer(new
    // PickableEdgePaintTransformer<String>(nodeGraphMap.getPickedEdgeState(), Color.black,
    // Color.GREEN));
    nodeGraphMap
        .getRenderContext()
        .setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(
                nodeGraphMap.getPickedVertexState(),
                new Color(67, 116, 217),
                new Color(5, 0, 153)));

    nodeTrafficTableModel = new NodeTrafficTableModel();
    TableColumnModel columnModel = new DefaultTableColumnModel();
    TableColumn column = new TableColumn(0);
    column.setHeaderValue("IP");
    columnModel.addColumn(column);

    column = new TableColumn(1);
    column.setHeaderValue("PORT");
    columnModel.addColumn(column);

    column = new TableColumn(2);
    column.setHeaderValue("PACKETS");
    columnModel.addColumn(column);

    column = new TableColumn(3);
    column.setHeaderValue("BYTES");
    columnModel.addColumn(column);

    column = new TableColumn(4);
    column.setHeaderValue("LEVEL");
    columnModel.addColumn(column);

    DefaultTableCellRenderer cellAlign = new DefaultTableCellRenderer();
    cellAlign.setHorizontalAlignment(JLabel.RIGHT);

    nodeTrafficTable = new JTable(nodeTrafficTableModel, columnModel);
    /*
       nodeTrafficTable.getColumn("IP").setCellRenderer(cellAlign);
       nodeTrafficTable.getColumn("IP").setPreferredWidth(90);
       nodeTrafficTable.getColumn("PORT").setCellRenderer(cellAlign);
       nodeTrafficTable.getColumn("PORT").setPreferredWidth(30);
       nodeTrafficTable.getColumn("PACKETS").setCellRenderer(cellAlign);
       nodeTrafficTable.getColumn("PACKETS").setPreferredWidth(60);
       nodeTrafficTable.getColumn("BYTES").setCellRenderer(cellAlign);
       nodeTrafficTable.getColumn("BYTES").setPreferredWidth(60);
       nodeTrafficTable.getColumn("LEVEL").setCellRenderer(cellAlign);
       nodeTrafficTable.getColumn("LEVEL").setPreferredWidth(5);
    */
    nodeGraphicTable = new JTable(nodeGraphicTableModel);

    nodeGraphProtocolView = new JScrollPane(nodeTrafficTable);
    // nodeGraphProtocolView.setLayout(new BorderLayout());
    // nodeGraphProtocolView.add(nodeTrafficTable);

    nodeGraphInform.add(nodeGraphMap);
    nodeGraphInform.add(nodeGraphProtocolView);

    top.add(nodeGraph);
    top.add(nodeGraphInform);
    this.add(top);

    trafficGraph = new ChartPanel(trafficChart);
    trafficGraph.setFocusable(false);
    trafficChart.getLegend().setPosition(RectangleEdge.LEFT);

    this.add(trafficGraph);

    graphVerticalSizeBt = new JButton("::::::::△▽::::::::");
    graphVerticalSizeBt.setFont(graphVerticalSizeBt.getFont().deriveFont(10.0f));
    graphVerticalSizeBt.addMouseMotionListener(new GraphVerticalSizeMotionListener());
    graphVerticalSizeBt.addActionListener(new GraphVerticalSizeMotionListener());
    this.add(graphVerticalSizeBt);

    graphHorizontalSizeBt = new JButton();
    graphHorizontalSizeBt.setEnabled(false);
    top.add(graphHorizontalSizeBt);
  }
Exemplo n.º 22
0
  /** Creates the GUI. */
  protected void createGUI() {
    JButton throwaway = new JButton("by"); // $NON-NLS-1$
    throwaway.setBorder(LibraryBrowser.buttonBorder);
    int h = throwaway.getPreferredSize().height;
    sharedFont = throwaway.getFont();

    // create collections list
    ListModel collectionListModel =
        new AbstractListModel() {
          public int getSize() {
            return library.pathList.size();
          }

          public Object getElementAt(int i) {
            String path = library.pathList.get(i);
            return library.pathToNameMap.get(path);
          }
        };
    collectionList = new JList(collectionListModel);
    collectionList.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            refreshGUI();
          }
        });
    collectionList.setFixedCellHeight(h);
    collectionList.setFont(sharedFont);
    collectionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    // create import list
    ListModel importListModel =
        new AbstractListModel() {
          public int getSize() {
            return library.importedPathList.size();
          }

          public Object getElementAt(int i) {
            String path = library.importedPathList.get(i);
            return library.importedPathToLibraryMap.get(path).getName();
          }
        };
    guestList = new JList(importListModel);
    guestList.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            refreshGUI();
          }
        });
    guestList.setFont(sharedFont);
    guestList.setFixedCellHeight(h);
    guestList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    // create name action, field and label
    nameAction =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String path = pathField.getText();
            String prev = library.pathToNameMap.get(path);
            String input = nameField.getText().trim();
            if (input == null || input.equals("") || input.equals(prev)) { // $NON-NLS-1$
              return;
            }
            library.renameCollection(path, input);
            browser.refreshCollectionsMenu();
            collectionList.repaint();
            refreshGUI();
          }
        };
    nameField = new LibraryTreePanel.EntryField();
    nameField.addActionListener(nameAction);
    nameField.addFocusListener(
        new FocusAdapter() {
          public void focusGained(FocusEvent e) {
            nameField.selectAll();
          }

          public void focusLost(FocusEvent e) {
            nameAction.actionPerformed(null);
          }
        });
    nameField.setBackground(Color.white);

    nameLabel = new JLabel();
    nameLabel.setFont(sharedFont);
    nameLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 2));
    nameLabel.setHorizontalAlignment(SwingConstants.TRAILING);

    // create path action, field and label
    //		pathAction = new ActionListener() {
    //      public void actionPerformed(ActionEvent e) {
    //	    	int i = collectionList.getSelectedIndex();
    //      	String path = library.pathList.get(i);
    //  			String name = library.pathToNameMap.get(path);
    //      	String input = pathField.getText().trim();
    //        if(input==null || input.equals("") || input.equals(path)) { //$NON-NLS-1$
    //          return;
    //        }
    //        library.pathList.remove(i);
    //        library.pathList.add(i, input);
    //        library.pathToNameMap.remove(path);
    //        library.pathToNameMap.put(input, name);
    //
    //        browser.refreshCollectionsMenu();
    //  			collectionList.repaint();
    //  			refreshGUI();
    //     	}
    //    };
    pathField = new LibraryTreePanel.EntryField();
    pathField.setEditable(false);
    //  	pathField.addActionListener(pathAction);
    //  	pathField.addFocusListener(new FocusAdapter() {
    //      public void focusGained(FocusEvent e) {
    //      	pathField.selectAll();
    //      }
    //      public void focusLost(FocusEvent e) {
    //      	pathAction.actionPerformed(null);
    //      }
    //    });
    pathField.setBackground(Color.white);

    pathLabel = new JLabel();
    pathLabel.setFont(sharedFont);
    pathLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 2));
    pathLabel.setHorizontalAlignment(SwingConstants.TRAILING);

    // create buttons
    okButton = new JButton();
    okButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setVisible(false);
          }
        });

    moveUpButton = new JButton();
    moveUpButton.setOpaque(false);
    moveUpButton.setBorder(LibraryBrowser.buttonBorder);
    moveUpButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            boolean isImports = tabbedPane.getSelectedComponent() == importsPanel;
            JList list = isImports ? guestList : collectionList;
            ArrayList<String> paths = isImports ? library.importedPathList : library.pathList;
            int i = list.getSelectedIndex();
            String path = paths.get(i);
            paths.remove(path);
            paths.add(i - 1, path);
            list.setSelectedIndex(i - 1);
            browser.refreshCollectionsMenu();
            browser.refreshGUI();
          }
        });
    moveDownButton = new JButton();
    moveDownButton.setOpaque(false);
    moveDownButton.setBorder(LibraryBrowser.buttonBorder);
    moveDownButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            boolean isImports = tabbedPane.getSelectedComponent() == importsPanel;
            JList list = isImports ? guestList : collectionList;
            ArrayList<String> paths = isImports ? library.importedPathList : library.pathList;
            int i = list.getSelectedIndex();
            String path = paths.get(i);
            paths.remove(path);
            paths.add(i + 1, path);
            list.setSelectedIndex(i + 1);
            browser.refreshCollectionsMenu();
            browser.refreshGUI();
          }
        });
    addButton = new JButton();
    addButton.setOpaque(false);
    addButton.setBorder(LibraryBrowser.buttonBorder);
    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            boolean imported = tabbedPane.getSelectedComponent() == importsPanel;
            String message =
                imported
                    ? ToolsRes.getString("LibraryBrowser.Dialog.AddLibrary.Message")
                    : //$NON-NLS-1$
                    ToolsRes.getString(
                        "LibraryBrowser.Dialog.AddCollection.Message"); //$NON-NLS-1$
            String title =
                imported
                    ? ToolsRes.getString("LibraryBrowser.Dialog.AddLibrary.Title")
                    : //$NON-NLS-1$
                    ToolsRes.getString("LibraryBrowser.Dialog.AddCollection.Title"); // $NON-NLS-1$

            Object input =
                JOptionPane.showInputDialog(
                    browser, message, title, JOptionPane.QUESTION_MESSAGE, null, null, null);

            if (input == null || input.equals("")) { // $NON-NLS-1$
              return;
            }
            String path = input.toString();
            path = XML.forwardSlash(path);
            path = ResourceLoader.getNonURIPath(path);

            if (tabbedPane.getSelectedComponent() == collectionsPanel) {
              boolean isResource = false;
              if (!path.startsWith("http") && new File(path).isDirectory()) { // $NON-NLS-1$
                isResource = true;
              } else {
                XMLControl control = new XMLControlElement(path);
                if (!control.failedToRead()
                    && control.getObjectClass() == LibraryCollection.class) {
                  isResource = true;
                }
              }
              if (isResource) {
                browser.addToCollections(path);
                ListModel model = collectionList.getModel();
                collectionList.setModel(model);
                refreshGUI();
                collectionList.repaint();
                collectionList.setSelectedIndex(library.pathList.size() - 1);
                browser.refreshCollectionsMenu();
                return;
              }
            }
            if (tabbedPane.getSelectedComponent() == importsPanel) {
              boolean isLibrary = false;
              XMLControl control = new XMLControlElement(path);
              if (!control.failedToRead() && control.getObjectClass() == Library.class) {
                isLibrary = true;
              }
              if (isLibrary) {
                Library newLibrary = new Library();
                newLibrary.browser = LibraryManager.this.browser;
                control.loadObject(newLibrary);
                if (library.importLibrary(path, newLibrary)) {
                  ListModel model = guestList.getModel();
                  guestList.setModel(model);
                  refreshGUI();
                  guestList.repaint();
                  guestList.setSelectedIndex(library.importedPathList.size() - 1);
                  browser.refreshCollectionsMenu();
                }
                return;
              }
            }

            String s =
                ToolsRes.getString(
                    "LibraryBrowser.Dialog.CollectionNotFound.Message"); //$NON-NLS-1$
            JOptionPane.showMessageDialog(
                LibraryManager.this,
                s + ":\n" + path, // $NON-NLS-1$
                ToolsRes.getString("LibraryBrowser.Dialog.CollectionNotFound.Title"), // $NON-NLS-1$
                JOptionPane.WARNING_MESSAGE);
          }
        });
    removeButton = new JButton();
    removeButton.setOpaque(false);
    removeButton.setBorder(LibraryBrowser.buttonBorder);
    removeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            boolean isImports = tabbedPane.getSelectedComponent() == importsPanel;
            JList list = isImports ? guestList : collectionList;
            ArrayList<String> paths = isImports ? library.importedPathList : library.pathList;
            int i = list.getSelectedIndex();
            String path = paths.get(i);
            paths.remove(path);
            if (isImports) library.importedPathToLibraryMap.remove(path);
            else library.pathToNameMap.remove(path);
            list.repaint();
            if (i >= paths.size()) {
              list.setSelectedIndex(paths.size() - 1);
            }
            browser.refreshCollectionsMenu();
            refreshGUI();
            browser.refreshGUI();
          }
        });
    // create all and none buttons
    allButton = new JButton();
    allButton.setOpaque(false);
    allButton.setBorder(LibraryBrowser.buttonBorder);
    allButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            for (SearchCheckBox next : checkboxes) {
              next.setSelected(true);
            }
          }
        });
    noneButton = new JButton();
    noneButton.setOpaque(false);
    noneButton.setBorder(LibraryBrowser.buttonBorder);
    noneButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            for (SearchCheckBox next : checkboxes) {
              next.setSelected(false);
            }
          }
        });

    clearCacheButton = new JButton();
    clearCacheButton.setOpaque(false);
    clearCacheButton.setBorder(LibraryBrowser.buttonBorder);
    clearCacheButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            File cache = ResourceLoader.getOSPCache();
            ResourceLoader.clearOSPCache(cache, false);
            refreshCacheTab();
            tabbedPane.repaint();
          }
        });

    setCacheButton = new JButton();
    setCacheButton.setOpaque(false);
    setCacheButton.setBorder(LibraryBrowser.buttonBorder);
    setCacheButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            File newCache = ResourceLoader.chooseOSPCache(browser);
            ResourceLoader.setOSPCache(newCache);
            refreshCacheTab();
          }
        });
    Border emptyInside = BorderFactory.createEmptyBorder(1, 2, 1, 2);
    Border etched = BorderFactory.createEtchedBorder();
    Border buttonbarBorder = BorderFactory.createCompoundBorder(etched, emptyInside);

    libraryButtonbar = new JToolBar();
    libraryButtonbar.setFloatable(false);
    libraryButtonbar.setBorder(buttonbarBorder);
    libraryButtonbar.add(moveUpButton);
    libraryButtonbar.add(moveDownButton);
    libraryButtonbar.add(addButton);
    libraryButtonbar.add(removeButton);

    nameBox = Box.createHorizontalBox();
    nameBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 4));
    nameBox.add(nameLabel);
    nameBox.add(nameField);
    pathBox = Box.createHorizontalBox();
    pathBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 4));
    pathBox.add(pathLabel);
    pathBox.add(pathField);
    libraryEditBox = Box.createVerticalBox();
    libraryEditBox.add(nameBox);
    libraryEditBox.add(pathBox);

    // create and assemble tabs
    // collections tab
    collectionsPanel = new JPanel(new BorderLayout());
    JScrollPane scroller = new JScrollPane(collectionList);
    scroller.setViewportBorder(etched);
    scroller.getVerticalScrollBar().setUnitIncrement(8);
    collectionsTitleBorder = BorderFactory.createTitledBorder(""); // $NON-NLS-1$
    scroller.setBorder(collectionsTitleBorder);
    collectionsPanel.add(scroller, BorderLayout.CENTER);
    collectionsPanel.add(libraryEditBox, BorderLayout.SOUTH);
    collectionsPanel.add(libraryButtonbar, BorderLayout.NORTH);

    // imports tab
    importsPanel = new JPanel(new BorderLayout());
    scroller = new JScrollPane(guestList);
    scroller.setViewportBorder(etched);
    scroller.getVerticalScrollBar().setUnitIncrement(8);
    importsTitleBorder = BorderFactory.createTitledBorder(""); // $NON-NLS-1$
    scroller.setBorder(importsTitleBorder);
    importsPanel.add(scroller, BorderLayout.CENTER);

    // search tab
    searchPanel = new JPanel(new BorderLayout());
    searchBox = Box.createVerticalBox();
    searchBox.setBackground(Color.white);
    searchBox.setOpaque(true);
    refreshSearchTab();

    scroller = new JScrollPane(searchBox);
    scroller.setViewportBorder(etched);
    scroller.getVerticalScrollBar().setUnitIncrement(8);
    searchTitleBorder = BorderFactory.createTitledBorder(""); // $NON-NLS-1$
    scroller.setBorder(searchTitleBorder);
    searchPanel.add(scroller, BorderLayout.CENTER);
    JToolBar searchButtonbar = new JToolBar();
    searchButtonbar.setFloatable(false);
    searchButtonbar.setBorder(buttonbarBorder);
    searchButtonbar.add(allButton);
    searchButtonbar.add(noneButton);
    searchPanel.add(searchButtonbar, BorderLayout.NORTH);

    // cache tab
    cachePanel = new JPanel(new BorderLayout());
    cacheBox = Box.createVerticalBox();
    cacheBox.setBackground(Color.white);
    cacheBox.setOpaque(true);
    refreshCacheTab();

    scroller = new JScrollPane(cacheBox);
    scroller.setViewportBorder(etched);
    scroller.getVerticalScrollBar().setUnitIncrement(8);
    cacheTitleBorder = BorderFactory.createTitledBorder(""); // $NON-NLS-1$
    scroller.setBorder(cacheTitleBorder);
    cachePanel.add(scroller, BorderLayout.CENTER);
    JToolBar cacheButtonbar = new JToolBar();
    cacheButtonbar.setFloatable(false);
    cacheButtonbar.setBorder(buttonbarBorder);
    cacheButtonbar.add(clearCacheButton);
    cacheButtonbar.add(setCacheButton);
    cachePanel.add(cacheButtonbar, BorderLayout.NORTH);

    // create tabbedPane
    tabbedPane = new JTabbedPane();
    tabbedPane.addTab("", collectionsPanel); // $NON-NLS-1$
    //		tabbedPane.addTab("", importsPanel); //$NON-NLS-1$
    tabbedPane.addTab("", searchPanel); // $NON-NLS-1$
    tabbedPane.addTab("", cachePanel); // $NON-NLS-1$

    // add change listener last
    tabbedPane.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (tabbedPane.getSelectedComponent() == collectionsPanel) {
              collectionsPanel.add(libraryButtonbar, BorderLayout.NORTH);
              collectionsPanel.add(libraryEditBox, BorderLayout.SOUTH);
              refreshGUI();
            } else if (tabbedPane.getSelectedComponent() == importsPanel) {
              importsPanel.add(libraryButtonbar, BorderLayout.NORTH);
              importsPanel.add(libraryEditBox, BorderLayout.SOUTH);
              refreshGUI();
            }
          }
        });

    Border space = BorderFactory.createEmptyBorder(0, 2, 0, 2);
    listButtonBorder = BorderFactory.createCompoundBorder(etched, space);

    // assemble content pane
    JPanel contentPane = new JPanel(new BorderLayout());
    setContentPane(contentPane);
    contentPane.add(tabbedPane, BorderLayout.CENTER);
    JPanel south = new JPanel();
    south.add(okButton);
    contentPane.add(south, BorderLayout.SOUTH);
  }