Пример #1
0
  public Fenetre() {
    setTitle("menu de l'application");
    setSize(800, 600);
    /* creation barre de menu*/
    barreMenus = new JMenuBar();
    setJMenuBar(barreMenus);
    barreMenus.setBackground(Color.orange); // COULEUR DU MENU
    /* creation menu Fichier et ses options */
    Fichier = new JMenu("Fichier");
    barreMenus.add(Fichier); // ajoute le fichier a la barre de menu
    // sous menu fermer
    Fermer = new JMenuItem("Fermer");
    Fichier.add(Fermer); // ajoute le sous menu fermer a l'onglet fichier
    Fermer.addActionListener(ec);
    Fermer.setForeground(Color.black); // COULEUR DU SOUS MENU
    Fermer.setBackground(Color.white);

    Connexion = new JMenu("Connexion");
    barreMenus.add(Connexion);
    // sous menu lancer
    Lancer = new JMenuItem("Lancer la connexion");
    Connexion.add(Lancer);
    Lancer.addActionListener(ec); // permet de mettre un écouteur sur le sous menu
    Lancer.setForeground(Color.black); // COULEUR DU SOUS MENU text couleur
    Lancer.setBackground(Color.white); // fond du sous menu

    mResa = new JMenu("réserver salle");
    barreMenus.add(mResa);
    resa = new JMenuItem("nouvelle resérvation");
    mResa.add(resa); // ajoute le sous menu "nouvelle resérvation" a l'onglet "réserver salle"
    resa.addActionListener(ec);
    resa.setForeground(Color.black); // COULEUR DU SOUS MENU text couleur
    resa.setBackground(Color.white); // fond du sous menu

    dateHeure = new JMenu("date et heure");
    barreMenus.add(dateHeure);
    date = new JMenuItem("date et heure");
    dateHeure.add(date);
    date.addActionListener(ec); // bouton surprise
    date.setForeground(Color.black); // COULEUR DU SOUS MENU text couleur
    date.setBackground(Color.white); // fond du sous menu

    this.setLocationRelativeTo(null); // fenetre afficher au centre de l'écran
    container.setLayout(new BorderLayout());

    // JLabel label = new JLabel("Bienvenue sur le site");
    JLabel label1 =
        new JLabel(
            "<html> MAISONS DES LIGUES<br><br> misson réservation<br><br>Cette application vous"
                + " permettra de vous connecter à notre base de données mrbs.</center><br> Vous pourrez rechercher des chambres  "
                + "ainsi que le lieu de l'hotel.</html>");
    container.add(label1, BorderLayout.CENTER);

    this.setContentPane(container); // ajout container à la fenetre
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
Пример #2
0
  /**
   * Adds a single item to this roles popup menu.
   *
   * <p>This method is used by ClassTarget to add some standard menus as well as by the roles to add
   * menus. It should be overridden with caution.
   *
   * @param menu the popup menu the item is to be added to
   * @param action the action to be registered with this menu item
   * @param itemString the String to be displayed on menu item
   * @param enabled boolean value representing whether item should be enabled
   */
  public void addMenuItem(JPopupMenu menu, Action action, boolean enabled) {
    JMenuItem item;

    item = new JMenuItem();
    item.setAction(action);
    item.setFont(PrefMgr.getPopupMenuFont());
    item.setForeground(envOpColour);
    item.setEnabled(enabled);

    menu.add(item);
  }
Пример #3
0
  public void refreshPopupItems() {
    if (!showPopUp) {
      return;
    }
    macrosPopup.removeAll();
    TextArea ta = OJ.editor.getTextArea();
    String macros_text = ta.getText();
    int caretPos = ta.getCaretPosition();
    String menuStrings = UtilsOJ.extractFunctions(macros_text, caretPos);
    String[] lines = menuStrings.split("\n");
    Font theFont = new java.awt.Font("MS Sans Serif", 0, 12); // NOI18N

    for (int jj = 0; jj < lines.length; jj++) {
      String line = lines[jj];
      if (line.length() > 5) {
        int lineNo = Integer.parseInt(line.substring(0, 5).trim());
        char kind = line.charAt(6);
        char caret = line.charAt(7);
        String title = line.substring(8, line.length());
        Color color = new Color(0, 0, 255);

        if (kind == 'f') {
          color = new Color(0, 100, 0);
          title = "    " + title;
        }
        if (kind == 'b') {
          color = new Color(200, 0, 80);
          title = "    " + title;
        }

        JMenuItem thisItem = new javax.swing.JMenuItem(title);
        thisItem.setAlignmentX((float) lineNo / 1000000);
        thisItem.setForeground(color);
        if (caret == '*') {
          thisItem.setBackground(new Color(255, 255, 188));
        }
        thisItem.setFont(theFont);
        macrosPopup.add(thisItem);
        thisItem.addActionListener(itemAction);
      }
    }
  }
Пример #4
0
  @Override
  protected void setTitle(String str) {

    AbstractAction titleAction =
        new AbstractAction() {
          private static final long serialVersionUID = 1L;

          public void actionPerformed(ActionEvent e) {

            if (selectedGeos.size() < 2) {
              if (view.getMode() == EuclidianConstants.MODE_MOVE) { // change
                // selection
                // to
                // geo
                // clicked

                app.getSelectionManager().clearSelectedGeos(false); // repaint
                // done
                // next
                // step
                app.getSelectionManager().addSelectedGeo(getGeo());

              } else { // use geo clicked to process mode
                Hits hits = new Hits();
                hits.add(getGeo());
                view.getEuclidianController().processMode(hits, false);
              }
            }
          }
        };

    JMenuItem title = wrappedPopup.add(titleAction);
    title.setText(str);
    title.setFont(((AppD) app).getBoldFont());
    title.setBackground(bgColor);
    title.setForeground(fgColor);

    title.setIcon(((AppD) app).getEmptyIcon());
    title.setBorder(BorderFactory.createEmptyBorder(5, 0, 2, 15));
  }
Пример #5
0
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    mainPanel = new javax.swing.JPanel();
    menuBar = new javax.swing.JMenuBar();
    javax.swing.JMenu fileMenu = new javax.swing.JMenu();
    conectarItem = new javax.swing.JMenuItem();
    javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
    jMenu1 = new javax.swing.JMenu();
    cobradasMenuItem = new javax.swing.JMenuItem();
    javax.swing.JMenu helpMenu = new javax.swing.JMenu();
    javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
    statusPanel = new javax.swing.JPanel();
    javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
    statusMessageLabel = new javax.swing.JLabel();
    statusAnimationLabel = new javax.swing.JLabel();
    progressBar = new javax.swing.JProgressBar();

    mainPanel.setName("mainPanel"); // NOI18N

    menuBar.setName("menuBar"); // NOI18N

    org.jdesktop.application.ResourceMap resourceMap =
        org.jdesktop.application.Application.getInstance(amltpvclient.AmltpvClientApp.class)
            .getContext()
            .getResourceMap(AmltpvViewClient.class);
    fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
    fileMenu.setFont(resourceMap.getFont("fileMenu.font")); // NOI18N
    fileMenu.setName("fileMenu"); // NOI18N

    conectarItem.setFont(resourceMap.getFont("conectarItem.font")); // NOI18N
    conectarItem.setForeground(resourceMap.getColor("conectarItem.foreground")); // NOI18N
    conectarItem.setText(resourceMap.getString("conectarItem.text")); // NOI18N
    conectarItem.setName("conectarItem"); // NOI18N
    conectarItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            conectarItemActionPerformed(evt);
          }
        });
    fileMenu.add(conectarItem);

    javax.swing.ActionMap actionMap =
        org.jdesktop.application.Application.getInstance(amltpvclient.AmltpvClientApp.class)
            .getContext()
            .getActionMap(AmltpvViewClient.class, this);
    exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
    exitMenuItem.setFont(resourceMap.getFont("exitMenuItem.font")); // NOI18N
    exitMenuItem.setForeground(resourceMap.getColor("exitMenuItem.foreground")); // NOI18N
    exitMenuItem.setText(resourceMap.getString("exitMenuItem.text")); // NOI18N
    exitMenuItem.setName("exitMenuItem"); // NOI18N
    exitMenuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            exitMenuItemActionPerformed(evt);
          }
        });
    fileMenu.add(exitMenuItem);

    menuBar.add(fileMenu);

    jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
    jMenu1.setFont(resourceMap.getFont("jMenu1.font")); // NOI18N
    jMenu1.setName("jMenu1"); // NOI18N

    cobradasMenuItem.setFont(resourceMap.getFont("cobradasMenuItem.font")); // NOI18N
    cobradasMenuItem.setForeground(resourceMap.getColor("cobradasMenuItem.foreground")); // NOI18N
    cobradasMenuItem.setText(resourceMap.getString("cobradasMenuItem.text")); // NOI18N
    cobradasMenuItem.setName("cobradasMenuItem"); // NOI18N
    cobradasMenuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            cobradasMenuItemActionPerformed(evt);
          }
        });
    jMenu1.add(cobradasMenuItem);

    menuBar.add(jMenu1);

    helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
    helpMenu.setFont(resourceMap.getFont("helpMenu.font")); // NOI18N
    helpMenu.setName("helpMenu"); // NOI18N

    aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
    aboutMenuItem.setFont(resourceMap.getFont("aboutMenuItem.font")); // NOI18N
    aboutMenuItem.setForeground(resourceMap.getColor("aboutMenuItem.foreground")); // NOI18N
    aboutMenuItem.setName("aboutMenuItem"); // NOI18N
    helpMenu.add(aboutMenuItem);

    menuBar.add(helpMenu);

    statusPanel.setName("statusPanel"); // NOI18N

    statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

    statusMessageLabel.setName("statusMessageLabel"); // NOI18N

    statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

    progressBar.setName("progressBar"); // NOI18N

    javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
    statusPanel.setLayout(statusPanelLayout);
    statusPanelLayout.setHorizontalGroup(
        statusPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(
                statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
            .addGroup(
                statusPanelLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(statusMessageLabel)
                    .addPreferredGap(
                        javax.swing.LayoutStyle.ComponentPlacement.RELATED, 230, Short.MAX_VALUE)
                    .addComponent(
                        progressBar,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(statusAnimationLabel)
                    .addContainerGap()));
    statusPanelLayout.setVerticalGroup(
        statusPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                statusPanelLayout
                    .createSequentialGroup()
                    .addComponent(
                        statusPanelSeparator,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        2,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(
                        javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        Short.MAX_VALUE)
                    .addGroup(
                        statusPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(statusMessageLabel)
                            .addComponent(statusAnimationLabel)
                            .addComponent(
                                progressBar,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(3, 3, 3)));

    setComponent(mainPanel);
    setMenuBar(menuBar);
    setStatusBar(statusPanel);
  } // </editor-fold>//GEN-END:initComponents
Пример #6
0
  public Check() {
    super(
        "Substance test with very very very very very very very very very very very very very very long title");

    final ClassLoader cl = Thread.currentThread().getContextClassLoader();
    if (UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) {
      setIconImage(
          SubstanceLogo.getLogoImage(
              SubstanceLookAndFeel.getCurrentSkin(this.getRootPane())
                  .getColorScheme(
                      DecorationAreaType.PRIMARY_TITLE_PANE,
                      ColorSchemeAssociationKind.FILL,
                      ComponentState.ENABLED)));
    }
    SubstanceLookAndFeel.registerSkinChangeListener(
        new SkinChangeListener() {
          @Override
          public void skinChanged() {
            SwingUtilities.invokeLater(
                new Runnable() {
                  @Override
                  public void run() {
                    setIconImage(
                        SubstanceLogo.getLogoImage(
                            SubstanceLookAndFeel.getCurrentSkin(Check.this.getRootPane())
                                .getColorScheme(
                                    DecorationAreaType.PRIMARY_TITLE_PANE,
                                    ColorSchemeAssociationKind.FILL,
                                    ComponentState.ENABLED)));
                  }
                });
          }
        });

    setLayout(new BorderLayout());

    jtp = new JTabbedPane();
    try {
      mainTabPreviewPainter = new MyMainTabPreviewPainter();
      jtp.putClientProperty(LafWidget.TABBED_PANE_PREVIEW_PAINTER, mainTabPreviewPainter);
    } catch (Throwable e) {
    }
    jtp.getModel().addChangeListener(new TabSwitchListener());

    final JXPanel jxPanel = new JXPanel(new BorderLayout());
    toolbar = getToolbar("", 22, true);
    jxPanel.add(toolbar, BorderLayout.NORTH);

    JXStatusBar statusBar = getStatusBar(jxPanel, jtp);
    this.add(statusBar, BorderLayout.SOUTH);

    taskPaneContainer =
        new JXTaskPaneContainer() {
          @Override
          public boolean getScrollableTracksViewportWidth() {
            return false;
          }
        };
    taskPaneContainer.setScrollableTracksViewportHeight(false);
    taskPaneContainer.setScrollableTracksViewportWidth(false);

    mainTaskPane = new JXTaskPane();
    mainTaskPane.setLayout(new BorderLayout());
    JPanel mainControlPanel =
        ControlPanelFactory.getMainControlPanel(this, jtp, mainTabPreviewPainter, toolbar);
    // mainControlPanel.setOpaque(false);
    mainTaskPane.add(mainControlPanel, BorderLayout.CENTER);
    mainTaskPane.setTitle("General settings");
    mainTaskPane.setIcon(getIcon("JFrameColor16"));
    mainTaskPane.setCollapsed(true);
    taskPaneContainer.add(mainTaskPane);

    JPanel dialogControlPanel = ControlPanelFactory.getDialogControlPanel(this);
    JXTaskPane dialogTaskPane = new JXTaskPane();
    dialogTaskPane.setLayout(new BorderLayout());
    dialogTaskPane.add(dialogControlPanel, BorderLayout.CENTER);
    dialogTaskPane.setTitle("Frames & Dialogs");
    dialogTaskPane.setIcon(getIcon("JDialogColor16"));
    dialogTaskPane.setCollapsed(true);
    // dialogTaskPane.setOpaque(false);
    taskPaneContainer.add(dialogTaskPane);

    currentSpecificTaskPane = null;

    final JScrollPane scrollPane =
        new JScrollPane(
            taskPaneContainer,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    SubstanceLookAndFeel.setDecorationType(scrollPane, DecorationAreaType.GENERAL);
    // scrollPane.setOpaque(false);
    // scrollPane.getViewport().setOpaque(false);

    JPanel mainPanel = new JPanel();
    mainPanel.add(scrollPane);
    mainPanel.add(jtp);
    mainPanel.setLayout(
        new LayoutManager() {
          @Override
          public void addLayoutComponent(String name, Component comp) {}

          @Override
          public Dimension minimumLayoutSize(Container parent) {
            Dimension min1 = scrollPane.getMinimumSize();
            Dimension min2 = jtp.getMinimumSize();
            return new Dimension(min1.width + min2.width, min1.height + min2.height);
          }

          @Override
          public void layoutContainer(Container parent) {
            // give 30% width to task pane container and
            // 70% width to the tabbed pane with controls.
            int width = parent.getWidth();
            int height = parent.getHeight();
            scrollPane.setBounds(0, 0, (int) (0.3 * width), height);
            jtp.setBounds((int) (0.3 * width), 0, width - (int) (0.3 * width), height);
          }

          @Override
          public Dimension preferredLayoutSize(Container parent) {
            Dimension pref1 = scrollPane.getPreferredSize();
            Dimension pref2 = jtp.getPreferredSize();
            return new Dimension(pref1.width + pref2.width, pref1.height + pref2.height);
          }

          @Override
          public void removeLayoutComponent(Component comp) {}
        });
    jxPanel.add(mainPanel, BorderLayout.CENTER);

    this.add(jxPanel, BorderLayout.CENTER);

    setPreferredSize(new Dimension(400, 400));
    this.setSize(getPreferredSize());
    setMinimumSize(getPreferredSize());

    ButtonsPanel buttonsPanel = new ButtonsPanel();
    jtp.addTab("Buttons", getIcon("JButtonColor16"), buttonsPanel);
    getRootPane().setDefaultButton(buttonsPanel.defaultButton);

    jtp.addTab("Combo box", getIcon("JComboBoxColor16"), new CombosPanel());

    jtp.addTab("Scroll pane", getIcon("JScrollPaneColor16"), new ScrollPanel());

    TabCloseCallback closeCallback =
        new TabCloseCallback() {
          @Override
          public TabCloseKind onAreaClick(
              JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) {
            if (mouseEvent.getButton() != MouseEvent.BUTTON3) return TabCloseKind.NONE;
            if (mouseEvent.isShiftDown()) {
              return TabCloseKind.ALL;
            }
            return TabCloseKind.THIS;
          }

          @Override
          public TabCloseKind onCloseButtonClick(
              JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) {
            if (mouseEvent.isAltDown()) {
              return TabCloseKind.ALL_BUT_THIS;
            }
            if (mouseEvent.isShiftDown()) {
              return TabCloseKind.ALL;
            }
            return TabCloseKind.THIS;
          }

          @Override
          public String getAreaTooltip(JTabbedPane tabbedPane, int tabIndex) {
            return null;
          }

          @Override
          public String getCloseButtonTooltip(JTabbedPane tabbedPane, int tabIndex) {
            StringBuffer result = new StringBuffer();
            result.append("<html><body>");
            result.append("Mouse click closes <b>" + tabbedPane.getTitleAt(tabIndex) + "</b> tab");
            result.append(
                "<br><b>Alt</b>-Mouse click closes all tabs but <b>"
                    + tabbedPane.getTitleAt(tabIndex)
                    + "</b> tab");
            result.append("<br><b>Shift</b>-Mouse click closes all tabs");
            result.append("</body></html>");
            return result.toString();
          }
        };

    try {
      TabPanel tp = new TabPanel();
      tp.jtp.putClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_CALLBACK, closeCallback);
      jtp.addTab("Tabs", getIcon("JTabbedPaneColor16"), tp);
    } catch (NoClassDefFoundError ncdfe) {
    }

    jtp.addTab("Split", new SplitPanel());

    jtp.addTab("Desktop", getIcon("JDesktopPaneColor16"), new DesktopPanel());

    jtp.addTab("Text fields", getIcon("JTextPaneColor16"), new TextFieldsPanel());

    jtp.addTab("Table", getIcon("JTableColor16"), new TablePanel());

    try {
      jtp.addTab("List", getIcon("JListColor16"), new ListPanel());
    } catch (NoClassDefFoundError ncdfe) {
    }

    jtp.addTab("Slider", getIcon("JSliderColor16"), new SliderPanel());

    jtp.addTab("Progress bar", getIcon("JProgressBarColor16"), new ProgressBarPanel());

    jtp.addTab("Spinner", getIcon("JSpinnerColor16"), new SpinnerPanel());

    jtp.addTab("Tree", getIcon("JTreeColor16"), new TreePanel());

    jtp.addTab("File tree", getIcon("JTreeColor16"), new FileTreePanel());

    jtp.addTab("Cards", new CardPanel());

    JPanel verticalButtonPanel = new JPanel();
    verticalButtonPanel.setLayout(new GridLayout(1, 3));
    verticalButtonPanel.add(new JButton("Vert button 1"));
    verticalButtonPanel.add(new JButton("Vert button 2"));
    JPanel smallVerticalButtonPanel = new JPanel();
    smallVerticalButtonPanel.setLayout(new GridLayout(4, 4));
    for (int row = 0; row < 4; row++) {
      for (int col = 0; col < 4; col++) {
        JButton vertButton = new JButton("vert");
        vertButton.setToolTipText("Vertical button " + row + ":" + col);
        smallVerticalButtonPanel.add(vertButton);
      }
    }
    verticalButtonPanel.add(smallVerticalButtonPanel);
    jtp.addTab("V-Buttons", verticalButtonPanel);

    jtp.addTab("Colored", new ColoredControlsPanel());

    jtp.addTab("Colorized", new ColorizedControlsPanel());

    jtp.addTab("Cells", new CellsPanel());

    jtp.addTab("Sizes", new SizesPanel());

    jtp.addTab("H-Align", new HAlignmentPanel());

    jtp.addTab("V-Align", new VAlignmentPanel());

    // sample menu bar
    JMenuBar jmb = new JMenuBar();
    if (UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) {
      jmb.add(SampleMenuFactory.getSkinMenu());
      jmb.add(SampleMenuFactory.getTransformMenu());
    }
    JMenu coloredMenu = new JMenu("Colors");
    coloredMenu.setMnemonic('0');
    JMenuItem coloredMI = new JMenuItem("Italic red");
    coloredMI.setFont(coloredMI.getFont().deriveFont(Font.ITALIC));
    coloredMI.setForeground(Color.red);
    coloredMenu.add(coloredMI);
    JRadioButtonMenuItem coloredRBMI = new JRadioButtonMenuItem("Bold green");
    coloredRBMI.setFont(coloredRBMI.getFont().deriveFont(Font.BOLD));
    coloredRBMI.setForeground(Color.green);
    coloredMenu.add(coloredRBMI);
    JCheckBoxMenuItem coloredCBMI = new JCheckBoxMenuItem("Big blue");
    coloredCBMI.setFont(coloredCBMI.getFont().deriveFont(32f));
    coloredCBMI.setForeground(Color.blue);
    coloredMenu.add(coloredCBMI);
    JMenu coloredM = new JMenu("Always big magenta");
    coloredM.setForeground(Color.magenta);
    coloredM.setFont(coloredM.getFont().deriveFont(24f));
    coloredMenu.add(coloredM);
    jmb.add(coloredMenu);

    JMenu testMenu = SampleMenuFactory.getTestMenu();
    jmb.add(testMenu);

    JMenu jm4 = new JMenu("Disabled");
    jm4.add(new JMenuItem("dummy4"));
    jm4.setMnemonic('4');
    jmb.add(jm4);
    jm4.setEnabled(false);

    // LAF changing
    jmb.add(SampleMenuFactory.getLookAndFeelMenu(this));
    setJMenuBar(jmb);

    TabCloseCallback closeCallbackMain =
        new TabCloseCallback() {
          @Override
          public TabCloseKind onAreaClick(
              JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) {
            if (mouseEvent.getButton() != MouseEvent.BUTTON2) return TabCloseKind.NONE;
            if (mouseEvent.isShiftDown()) {
              return TabCloseKind.ALL;
            }
            return TabCloseKind.THIS;
          }

          @Override
          public TabCloseKind onCloseButtonClick(
              JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) {
            if (mouseEvent.isAltDown()) {
              return TabCloseKind.ALL_BUT_THIS;
            }
            if (mouseEvent.isShiftDown()) {
              return TabCloseKind.ALL;
            }
            return TabCloseKind.THIS;
          }

          @Override
          public String getAreaTooltip(JTabbedPane tabbedPane, int tabIndex) {
            return null;
          }

          @Override
          public String getCloseButtonTooltip(JTabbedPane tabbedPane, int tabIndex) {
            StringBuffer result = new StringBuffer();
            result.append("<html><body>");
            result.append("Mouse click closes <b>" + tabbedPane.getTitleAt(tabIndex) + "</b> tab");
            result.append(
                "<br><b>Alt</b>-Mouse click closes all tabs but <b>"
                    + tabbedPane.getTitleAt(tabIndex)
                    + "</b> tab");
            result.append("<br><b>Shift</b>-Mouse click closes all tabs");
            result.append("</body></html>");
            return result.toString();
          }
        };

    jtp.putClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_CALLBACK, closeCallbackMain);
    SubstanceLookAndFeel.registerTabCloseChangeListener(
        new TabCloseListener() {
          @Override
          public void tabClosed(JTabbedPane tabbedPane, Component tabComponent) {
            out("Closed tab");
          }

          @Override
          public void tabClosing(JTabbedPane tabbedPane, Component tabComponent) {
            out("Closing tab");
          }
        });

    SubstanceLookAndFeel.registerTabCloseChangeListener(
        jtp,
        new VetoableTabCloseListener() {
          @Override
          public void tabClosed(JTabbedPane tabbedPane, Component tabComponent) {
            out("Closed tab - specific");
          }

          @Override
          public void tabClosing(JTabbedPane tabbedPane, Component tabComponent) {
            out("Closing tab - specific");
          }

          @Override
          public boolean vetoTabClosing(JTabbedPane tabbedPane, Component tabComponent) {
            int userCloseAnswer =
                JOptionPane.showConfirmDialog(
                    Check.this,
                    "Are you sure you want to close '"
                        + tabbedPane.getTitleAt(tabbedPane.indexOfComponent(tabComponent))
                        + "' tab?",
                    "Confirm dialog",
                    JOptionPane.YES_NO_OPTION);
            return (userCloseAnswer == JOptionPane.NO_OPTION);
          }
        });

    SubstanceLookAndFeel.registerTabCloseChangeListener(
        jtp,
        new VetoableMultipleTabCloseListener() {
          @Override
          public void tabsClosed(JTabbedPane tabbedPane, Set<Component> tabComponents) {
            out("Closed " + tabComponents.size() + " tabs - specific");
          }

          @Override
          public void tabsClosing(JTabbedPane tabbedPane, Set<Component> tabComponents) {
            out("Closing " + tabComponents.size() + " tabs - specific");
          }

          @Override
          public boolean vetoTabsClosing(JTabbedPane tabbedPane, Set<Component> tabComponents) {
            int userCloseAnswer =
                JOptionPane.showConfirmDialog(
                    Check.this,
                    "Are you sure you want to close " + tabComponents.size() + " tabs?",
                    "Confirm dialog",
                    JOptionPane.YES_NO_OPTION);
            return (userCloseAnswer == JOptionPane.NO_OPTION);
          }
        });

    addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentResized(ComponentEvent e) {
            System.out.println("Size " + getSize());
          }
        });
  }
Пример #7
0
  /**
   * @param netView
   * @param view a View&lt;CyNode&gt;, View&lt;CyEdge&gt; or View&lt;CyNetwork&gt; object
   * @return
   */
  public CyMenuItem build(final CyNetworkView netView, final View<? extends CyIdentifiable> view) {
    final Class<? extends CyIdentifiable> targetClass = view.getModel().getClass();
    final Queue<VisualLexiconNode> queue =
        new PriorityQueue<VisualLexiconNode>(50, new VisualLexiconNodeComparator());
    final Map<VisualLexiconNode, JMenuItem> menuMap = new HashMap<VisualLexiconNode, JMenuItem>();

    final JMenu rootJMenu = new JMenu(ROOT_MENU_LABEL);

    final CyMenuItem rootMenu = new CyMenuItem(rootJMenu, ROOT_GRAVITY);
    queue.addAll(root.getChildren());
    menuMap.put(root, rootMenu.getMenuItem());

    // Node size, width and height
    JMenuItem menuItemNodeSize = null;
    JMenuItem menuItemNodeWidth = null;
    JMenuItem menuItemNodeHeight = null;

    final Set<VisualLexiconNode> nextNodes = new HashSet<VisualLexiconNode>();

    while (!queue.isEmpty()) {
      final VisualLexiconNode curretNode = queue.poll();
      final VisualProperty<?> vp = curretNode.getVisualProperty();

      if (vp.getTargetDataType().isAssignableFrom(targetClass)) {
        final Collection<VisualLexiconNode> children = curretNode.getChildren();
        nextNodes.addAll(children);

        final JMenuItem menu;
        if (children.isEmpty() && PropertySheetUtil.isCompatible(vp)) {
          final boolean lock = view.isDirectlyLocked(vp);
          if (lock) {
            menu = new JMenu(vp.getDisplayName());
            final JMenuItem clear = new JMenuItem("Clear");
            clear.addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    view.clearValueLock(vp);
                    netView.updateView();
                  }
                });

            final JMenuItem edit = new JMenuItem("Edit Bypass");
            edit.addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    applBypassValue(netView, view, vp);
                  }
                });
            menu.add(clear);
            menu.add(edit);

            // Update color
            menu.setForeground(ENABLED_COLOR);
            menu.setIcon(ENABLED_ICON);
            menu.setFont(ENABLED_FONT);
            VisualLexiconNode parent = curretNode.getParent();

            while (parent != root) {
              JMenuItem enabledPath = menuMap.get(parent);
              enabledPath.setForeground(ENABLED_COLOR);
              enabledPath.setIcon(ENABLED_ICON);
              enabledPath.setFont(ENABLED_FONT);
              parent = parent.getParent();
            }

            rootJMenu.setIcon(ENABLED_ICON);
            rootJMenu.setForeground(ENABLED_COLOR);
            rootJMenu.setFont(ENABLED_FONT);

            vpSet.add(vp);
          } else {
            menu = new JMenuItem(vp.getDisplayName());
            menu.addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    applBypassValue(netView, view, vp);
                  }
                });

            if (vp.getDisplayName()
                .equalsIgnoreCase(BasicVisualLexicon.NODE_WIDTH.getDisplayName())) {
              menuItemNodeWidth = menu;
            }
            if (vp.getDisplayName()
                .equalsIgnoreCase(BasicVisualLexicon.NODE_HEIGHT.getDisplayName())) {
              menuItemNodeHeight = menu;
            }
          }
        } else {

          menu = new JMenu(vp.getDisplayName());

          if (vp.getDisplayName().equalsIgnoreCase(BasicVisualLexicon.NODE_SIZE.getDisplayName())) {
            menuItemNodeSize = menu;
            vp_nodeSize = vp;
          }
        }

        if (PropertySheetUtil.isCompatible(vp)) {
          menuMap.get(curretNode.getParent()).add(menu);
          menuMap.put(curretNode, menu);
        }
      }

      if (queue.isEmpty()) {
        queue.addAll(nextNodes);
        nextNodes.clear();
      }
    }

    // handle node size
    if (menuItemNodeSize != null) {
      //
      JMenuItem menuItemNodeSize1 = new JMenuItem(vp_nodeSize.getDisplayName());
      menuItemNodeSize1.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              applBypassValue(netView, view, vp_nodeSize);
            }
          });

      menuItemNodeSize.add(menuItemNodeSize1);

      // Check if nose size is locked
      boolean nodeSizeIsLocked = false;
      java.util.Iterator it =
          vmm.getCurrentVisualStyle().getAllVisualPropertyDependencies().iterator();
      while (it.hasNext()) {
        org.cytoscape.view.vizmap.VisualPropertyDependency dep =
            (org.cytoscape.view.vizmap.VisualPropertyDependency) it.next();

        if (dep.getDisplayName().equalsIgnoreCase("Lock node width and height")
            && dep.isDependencyEnabled()) {
          nodeSizeIsLocked = true;
        }
      }

      if (nodeSizeIsLocked) {
        // In case the Node size is locked, disable menuItem Node_width and Nod_height
        if (menuItemNodeWidth != null) menuItemNodeWidth.setEnabled(false);
        if (menuItemNodeHeight != null) menuItemNodeHeight.setEnabled(false);
      } else {
        // In case the Node size is not locked, disable menuItem Node_size
        if (menuItemNodeSize1 != null) menuItemNodeSize1.setEnabled(false);
      }
    }

    final JSeparator separator = new JSeparator();
    final JMenuItem resetMenu = new JMenuItem("Reset All");
    resetMenu.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            clearAll(netView, view);
          }
        });

    rootJMenu.add(separator);
    rootJMenu.add(resetMenu);

    return rootMenu;
  }
Пример #8
0
 private void addMenuItem(JPopupMenu menu, Action action) {
   JMenuItem item = menu.add(action);
   item.setFont(PrefMgr.getPopupMenuFont());
   item.setForeground(envOpColour);
 }