public void init() {
    JPanel main_jp = new BorderJPanel();
    BoxLayout boxLayout = new BoxLayout(main_jp, BoxLayout.Y_AXIS);
    main_jp.setLayout(boxLayout);
    main_jp.setBackground(Util.PANEL_COLOR);

    number = new JLabelJTextFieldComponent("  *", "仓库编号:", 30);
    name = new JLabelJTextFieldComponent("  *", "仓库名称:", 30);
    location = new JLabelJTextFieldComponent("  *", "仓库地址:", 30);
    manager = new JLabelJComboBoxComponent("*", "仓库管理员:", new String[] {}, 188);
    manager.addElement(new IDNameBean("0", "请选择"));
    priority = new JLabelJTextFieldComponent("*", "仓库优先级:", "(数字越大,越在前面)", 15);
    note = new JLabelJTextAreaComponent("    备    注:", 23, 3);

    number.getText().setText(UUID.GenUUID15());
    number.getText().setEditable(false);
    priority.getText().setText("0");

    main_jp.add(number);
    main_jp.add(name);
    main_jp.add(location);
    main_jp.add(manager);
    main_jp.add(priority);
    main_jp.add(note);

    JPanel p1 = new JPanel();
    sureButton = new RPJButtonWhite("保存(Ctrl+S)");
    cancelButton = new RPJButtonWhite("取消(Ctrl+Q)");
    p1.add(sureButton);
    p1.add(cancelButton);
    p1.setOpaque(false);
    main_jp.add(p1);
    this.add(main_jp);
    main_jp.setCursor(Util.CURSOR_DEFAULT);
  }
  protected void setup(
      final AnAction action,
      JPanel root,
      final JLabel name,
      final JLabel description,
      JLabel icon) {
    name.setText(action.getTemplatePresentation().getText());
    name.setUI(DarculaWelcomeScreenLabelUI.createUI(name));
    name.setForeground(UIUtil.getPanelBackground());
    description.setUI(DarculaWelcomeScreenLabelUI.createUI(description));
    // icon.setIcon(action.getTemplatePresentation().getIcon());
    final String text = action.getTemplatePresentation().getDescription();
    final String html =
        XmlStringUtil.wrapInHtml(
            MessageFormat.format(text, ApplicationNamesInfo.getInstance().getFullProductName()));
    root.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    description.setText(html);
    description.setForeground(Gray._200);
    description.setEnabled(false);
    root.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseEntered(MouseEvent e) {
            description.setEnabled(true);
            name.setForeground(new Color(0xE09600));
          }

          @Override
          public void mouseExited(MouseEvent e) {
            description.setEnabled(false);
            name.setForeground(UIUtil.getPanelBackground());
          }

          @Override
          public void mouseClicked(MouseEvent e) {
            final ActionManager actionManager = ActionManager.getInstance();
            AnActionEvent evt =
                new AnActionEvent(
                    null,
                    DataManager.getInstance().getDataContext(e.getComponent()),
                    ActionPlaces.WELCOME_SCREEN,
                    action.getTemplatePresentation(),
                    actionManager,
                    0);
            action.beforeActionPerformedUpdate(evt);
            if (evt.getPresentation().isEnabled()) {
              action.actionPerformed(evt);
            }
          }
        });
  }
Example #3
0
  /**
   * Creates the list of interaction partners displayed in the top part of the {@link RegIntTab}
   *
   * @param parent The {@link JScrollPane} containing either the regulators or the targets of the
   *     selected element
   * @param map The map of interaction partners, either regulators or targets, also found in results
   * @param results The entire {@link ResultsObj}. Must have map as either its regulator or target
   *     map
   * @param builder The {@link PanelBuilder} that will include this pathway
   * @return the list of interaction partners (in pathway form for expression visualization)
   */
  private VPathwaySwing createPathway(
      JScrollPane parent, Map<Xref, Interaction> map, ResultsObj results, PanelBuilder builder) {
    VPathwaySwing vPathwaySwing = new VPathwaySwing(parent);
    VPathway vPathway = vPathwaySwing.createVPathway();
    vPathway.setEditMode(false);
    Pathway sourcePw = new Pathway();
    Map<Xref, Interaction> sorted = sortXrefs(map);
    x = 0;
    for (Xref xref : sorted.keySet()) {
      PathwayElement pwe = createPathwayELement(xref);
      sourcePw.add(pwe);

      JLabel linkout = new JLabel(icon);
      JPanel linkoutPane = new JPanel();
      linkout.addMouseListener(new InfoButtonListener(xref, results, plugin));
      linkoutPane.add(linkout);
      linkoutPane.setCursor(new Cursor(Cursor.HAND_CURSOR));
      linkoutPane.setVisible(true);

      List<File> uniqueFiles = new ArrayList<File>();
      for (File intFile : sorted.get(xref).getFiles()) {
        if (!uniqueFiles.contains(intFile)
            && RegIntPreferences.getPreferences().getSelectedIntFiles().contains(intFile)) {
          uniqueFiles.add(intFile);
        }
      }
      builder.addLabel(
          uniqueFiles.size()
              + "/"
              + RegIntPreferences.getPreferences().getSelectedIntFiles().size(),
          cc.xy(6, y));

      builder.add(linkoutPane, cc.xy(4, y));
      y = y + 2;
      x++;
    }
    vPathway.fromModel(sourcePw);
    vPathway.setSelectionEnabled(false);
    vPathway.addVPathwayListener(plugin.getDesktop().getVisualizationManager());
    return vPathwaySwing;
  }
Example #4
0
  public EditorPanel(ParticleValue value, String name, String description) {
    this.name = name;
    this.value = value;
    this.description = description;

    initializeComponents();

    titlePanel.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent event) {
            if (!activeButton.isVisible()) return;
            activeButton.setSelected(!activeButton.isSelected());
            updateActive();
          }
        });
    activeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            updateActive();
          }
        });
    advancedButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            advancedPanel.setVisible(advancedButton.isSelected());
          }
        });

    if (value != null) {
      activeButton.setSelected(value.isActive());
      updateActive();
    }

    boolean alwaysActive = value == null ? true : value.isAlwaysActive();
    activeButton.setVisible(!alwaysActive);
    if (alwaysActive) contentPanel.setVisible(true);
    if (alwaysActive) titlePanel.setCursor(null);
  }
  /**
   * Creates and adds the edit panel for the currently selected annotation to the process renderer.
   */
  private void createEditPanel() {
    final WorkflowAnnotation selected = model.getSelected();
    Rectangle2D loc = selected.getLocation();

    // panel containing buttons
    editPanel = new JPanel();
    editPanel.setCursor(Cursor.getDefaultCursor());
    editPanel.setLayout(new BoxLayout(editPanel, BoxLayout.LINE_AXIS));
    updateEditPanelPosition(loc, false);
    editPanel.setOpaque(true);
    editPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    // consume mouse events so focus is not lost
    editPanel.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseReleased(MouseEvent e) {
            e.consume();
          }

          @Override
          public void mousePressed(MouseEvent e) {
            e.consume();
          }

          @Override
          public void mouseClicked(MouseEvent e) {
            e.consume();
          }
        });

    // add alignment controls
    final List<JButton> alignmentButtonList = new LinkedList<JButton>();
    for (AnnotationAlignment align : AnnotationAlignment.values()) {
      final Action action = align.makeAlignmentChangeAction(model, model.getSelected());
      final JButton alignButton = new JButton();
      alignButton.setIcon((Icon) action.getValue(Action.SMALL_ICON));
      alignButton.setBorderPainted(false);
      alignButton.setBorder(null);
      alignButton.setFocusable(false);
      if (align == selected.getStyle().getAnnotationAlignment()) {
        alignButton.setBackground(Color.LIGHT_GRAY);
      }
      alignButton.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
              removeColorPanel();
              colorButton.setBackground(null);
              for (JButton button : alignmentButtonList) {
                button.setBackground(null);
              }
              alignButton.setBackground(Color.LIGHT_GRAY);

              int caretPos = editPane.getCaretPosition();
              // remember if we were at last position because doc length can change after 1st
              // save
              boolean lastPos = caretPos == editPane.getDocument().getLength();
              int selStart = editPane.getSelectionStart();
              int selEnd = editPane.getSelectionEnd();
              // change alignment and save current comment
              action.actionPerformed(e);
              saveEdit(selected);
              // reload edit pane with changes
              editPane.setText(AnnotationDrawUtils.createStyledCommentString(selected));
              // special handling for documents of length 1 to avoid not being able to type
              if (editPane.getDocument().getLength() == 1) {
                caretPos = 1;
              } else if (lastPos) {
                caretPos = editPane.getDocument().getLength();
              } else {
                caretPos = Math.min(editPane.getDocument().getLength(), caretPos);
              }
              editPane.setCaretPosition(caretPos);
              if (selEnd - selStart > 0) {
                editPane.setSelectionStart(selStart);
                editPane.setSelectionEnd(selEnd);
              }
              editPane.requestFocusInWindow();
            }
          });
      editPanel.add(alignButton);
      alignmentButtonList.add(alignButton);
    }

    // add small empty space
    editPanel.add(Box.createHorizontalStrut(2));

    // add color controls
    colorOverlay = new JDialog(ApplicationFrame.getApplicationFrame());
    colorOverlay.setCursor(Cursor.getDefaultCursor());
    colorOverlay
        .getRootPane()
        .setLayout(new BoxLayout(colorOverlay.getRootPane(), BoxLayout.LINE_AXIS));
    colorOverlay.setUndecorated(true);
    colorOverlay.getRootPane().setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
    colorOverlay.setFocusable(false);
    colorOverlay.setAutoRequestFocus(false);
    // consume mouse events so focus is not lost
    colorOverlay.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseReleased(MouseEvent e) {
            e.consume();
          }

          @Override
          public void mousePressed(MouseEvent e) {
            e.consume();
          }

          @Override
          public void mouseClicked(MouseEvent e) {
            e.consume();
          }
        });

    for (final AnnotationColor color : AnnotationColor.values()) {
      final Action action = color.makeColorChangeAction(model, selected);
      JButton colChangeButton = new JButton();
      colChangeButton.setText(null);
      colChangeButton.setBorderPainted(false);
      colChangeButton.setBorder(null);
      colChangeButton.setFocusable(false);
      final Icon icon =
          SwingTools.createIconFromColor(
              color.getColor(), Color.BLACK, 16, 16, new Rectangle2D.Double(1, 1, 14, 14));
      colChangeButton.setIcon(icon);
      colChangeButton.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
              // change color and save current comment
              action.actionPerformed(e);
              saveEdit(selected);
              // set edit pane bg color
              editPane.requestFocusInWindow();
              if (color == AnnotationColor.TRANSPARENT) {
                editPane.setBackground(Color.WHITE);
              } else {
                editPane.setBackground(color.getColorHighlight());
              }

              // adapt color of main button, remove color panel
              colorButton.setIcon(icon);
              if (removeColorPanel()) {
                colorButton.setBackground(null);
                view.repaint();
              }
            }
          });

      colorOverlay.getRootPane().add(colChangeButton);
    }

    colorButton = new JButton("\u25BE");
    colorButton.setBorderPainted(false);
    colorButton.setFocusable(false);
    AnnotationColor color = selected.getStyle().getAnnotationColor();
    colorButton.setIcon(
        SwingTools.createIconFromColor(
            color.getColor(), Color.BLACK, 16, 16, new Rectangle2D.Double(1, 1, 14, 14)));
    colorButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (removeColorPanel()) {
              colorButton.setBackground(null);
              view.repaint();
              return;
            }

            updateColorPanelPosition();
            colorOverlay.setVisible(true);
            colorButton.setBackground(Color.LIGHT_GRAY);
            editPane.requestFocusInWindow();
            view.repaint();
          }
        });
    editPanel.add(colorButton);

    // add separator
    JLabel separator =
        new JLabel() {

          private static final long serialVersionUID = 1L;

          @Override
          public void paintComponent(Graphics g) {
            Graphics2D g2 = (Graphics2D) g;

            g2.setColor(Color.LIGHT_GRAY);
            g2.drawLine(2, 0, 2, 20);
          }
        };
    separator.setText(" "); // dummy text to show label
    editPanel.add(separator);

    // add delete button
    final JButton deleteButton =
        new JButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.workflow.annotation.delete.label"));
    deleteButton.setForeground(Color.RED);
    deleteButton.setContentAreaFilled(false);
    deleteButton.setFocusable(false);
    deleteButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            model.deleteAnnotation(selected);
            removeEditor();
          }
        });
    deleteButton.addMouseListener(
        new MouseAdapter() {

          @Override
          @SuppressWarnings({"unchecked", "rawtypes"})
          public void mouseExited(MouseEvent e) {
            Font font = deleteButton.getFont();
            Map attributes = font.getAttributes();
            attributes.put(TextAttribute.UNDERLINE, -1);
            deleteButton.setFont(font.deriveFont(attributes));
          }

          @SuppressWarnings({"unchecked", "rawtypes"})
          @Override
          public void mouseEntered(MouseEvent e) {
            Font font = deleteButton.getFont();
            Map attributes = font.getAttributes();
            attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
            deleteButton.setFont(font.deriveFont(attributes));
          }
        });
    editPanel.add(deleteButton);

    // add panel to view
    view.add(editPanel);
  }
 /**
  * {@inheritDoc}
  *
  * @see java.awt.Component#setCursor(java.awt.Cursor)
  */
 @Override
 public void setCursor(Cursor cursor) {
   super.setCursor(cursor);
   _canvas.setCursor(cursor);
 }
Example #7
0
 private void initializeComponents() {
   setLayout(new GridBagLayout());
   {
     titlePanel = new JPanel(new GridBagLayout());
     add(
         titlePanel,
         new GridBagConstraints(
             1,
             0,
             1,
             1,
             1.0,
             0.0,
             GridBagConstraints.WEST,
             GridBagConstraints.HORIZONTAL,
             new Insets(3, 0, 3, 0),
             0,
             0));
     titlePanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
     {
       JLabel label = new JLabel(name);
       titlePanel.add(
           label,
           new GridBagConstraints(
               0,
               0,
               1,
               1,
               1.0,
               0.0,
               GridBagConstraints.WEST,
               GridBagConstraints.NONE,
               new Insets(3, 6, 3, 6),
               0,
               0));
       label.setFont(label.getFont().deriveFont(Font.BOLD));
     }
     {
       advancedButton = new JToggleButton("Advanced");
       titlePanel.add(
           advancedButton,
           new GridBagConstraints(
               1,
               0,
               1,
               1,
               0.0,
               0.0,
               GridBagConstraints.CENTER,
               GridBagConstraints.NONE,
               new Insets(0, 0, 0, 6),
               0,
               0));
       advancedButton.setVisible(false);
     }
     {
       activeButton = new JToggleButton("Active");
       titlePanel.add(
           activeButton,
           new GridBagConstraints(
               2,
               0,
               1,
               1,
               0.0,
               0.0,
               GridBagConstraints.CENTER,
               GridBagConstraints.NONE,
               new Insets(0, 0, 0, 6),
               0,
               0));
     }
   }
   {
     contentPanel = new JPanel(new GridBagLayout());
     add(
         contentPanel,
         new GridBagConstraints(
             1,
             1,
             1,
             1,
             0.0,
             0.0,
             GridBagConstraints.CENTER,
             GridBagConstraints.BOTH,
             new Insets(0, 6, 6, 6),
             0,
             0));
     contentPanel.setVisible(false);
   }
   {
     advancedPanel = new JPanel(new GridBagLayout());
     add(
         advancedPanel,
         new GridBagConstraints(
             1,
             2,
             1,
             1,
             0.0,
             0.0,
             GridBagConstraints.CENTER,
             GridBagConstraints.BOTH,
             new Insets(0, 6, 6, 6),
             0,
             0));
     advancedPanel.setVisible(false);
   }
 }
 private void resetCursorAllComponents() {
   mainPanel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
   // Spinner nicht verändern, da sonst Pfeile nicht mehr korrekt angezeigt werden
 }
 private void setWaitCursorAllComponents() {
   Cursor waitCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
   mainPanel.setCursor(waitCursor);
   // Spinner nicht verändern, da sonst Pfeile nicht mehr korrekt angezeigt werden
 }