public static PropertyUIDescriptor buildUIDescriptor(
      ToolParameterDescriptor prop,
      String[] columnsMembers,
      ToolAdapterOperatorDescriptor opDescriptor,
      BindingContext context,
      ActionListener deleteActionListener,
      ActionListener editActionListener,
      PropertyMemberUIWrapper.CallBackAfterEdit callback) {
    PropertyUIDescriptor descriptor = new PropertyUIDescriptor();

    AbstractButton delButton =
        ToolButtonFactory.createButton(
            UIUtils.loadImageIcon("/org/esa/snap/resources/images/icons/DeleteShapeTool16.gif"),
            false);
    delButton.addActionListener(deleteActionListener);
    descriptor.setDelButton(delButton);
    AbstractButton editButton = new JButton("...");
    editButton.addActionListener(editActionListener);
    descriptor.setEditButton(editButton);

    HashMap<String, PropertyMemberUIWrapper> UIcomponentsMap = new HashMap<>();
    for (String col : columnsMembers) {
      if (!col.equals("del")) {
        UIcomponentsMap.put(
            col,
            PropertyMemberUIWrapperFactory.buildPropertyWrapper(
                col, prop, opDescriptor, context, callback));
      }
    }
    descriptor.setUIcomponentsMap(UIcomponentsMap);

    return descriptor;
  }
  private void initContentPanel() {

    moreOptionsPane = new MoreOptionsPane(this, formModel.isMoreOptionsFormCollapsedOnInit());

    resetButton = createButton("org/esa/snap/rcp/icons/Undo24.gif");
    resetButton.setName("ResetButton");
    resetButton.setToolTipText("Reset to defaults"); /*I18N*/
    resetButton.addActionListener(wrapWithAutoApplyActionListener(e -> resetToDefaults()));

    multiApplyButton = createButton("org/esa/snap/rcp/icons/MultiAssignBands24.gif");
    multiApplyButton.setName("MultiApplyButton");
    multiApplyButton.setToolTipText("Apply to other bands"); /*I18N*/
    multiApplyButton.addActionListener(e -> applyMultipleColorPaletteDef());

    importButton = createButton("tango/22x22/actions/document-open.png");
    importButton.setName("ImportButton");
    importButton.setToolTipText("Import colour palette from text file."); /*I18N*/
    importButton.addActionListener(
        e -> {
          importColorPaletteDef();
          applyChanges();
        });
    importButton.setEnabled(true);

    exportButton = createButton("tango/22x22/actions/document-save-as.png");
    exportButton.setName("ExportButton");
    exportButton.setToolTipText("Save colour palette to text file."); /*I18N*/
    exportButton.addActionListener(
        e -> {
          exportColorPaletteDef();
          childForm.updateFormModel(getFormModel());
        });
    exportButton.setEnabled(true);

    helpButton = createButton("tango/22x22/apps/help-browser.png");
    helpButton.setToolTipText("Help."); /*I18N*/
    helpButton.setName("helpButton");
    helpButton.addActionListener(e -> toolView.getHelpCtx().display());

    editorPanel = new JPanel(new BorderLayout(4, 4));
    toolButtonsPanel = GridBagUtils.createPanel();

    contentPanel = new JPanel(new BorderLayout(4, 4));
    contentPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    contentPanel.setPreferredSize(new Dimension(320, 200));
    contentPanel.add(editorPanel, BorderLayout.CENTER);
    contentPanel.add(toolButtonsPanel, BorderLayout.EAST);

    setProductSceneView(SnapApp.getDefault().getSelectedProductSceneView());

    SnapApp.getDefault().getSelectionSupport(ProductSceneView.class).addHandler(this);
  }
Beispiel #3
0
  /** creates the menu and tool items */
  protected void createMenuAndToolItems() {

    // creating the listener to the menu and tool items
    ActionListener listener =
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {

            notifyDrawingMode();

            if (e.getSource().equals(shapeCreatorMenuItem)) {

              shapeCreatorToolItem.removeActionListener(this);
              shapeCreatorToolItem.setSelected(true);
              shapeCreatorToolItem.addActionListener(this);
            }
          }
        };

    // getting the icons for the items
    shapeCreatorIcon = ResourcesManager.getIcon(shapeModuleId, false);
    shapeCreatorDisabledIcon = ResourcesManager.getIcon(shapeModuleId, true);

    // creating the menu item
    shapeCreatorMenuItem = new JMenuItem(itemLabel, shapeCreatorIcon);
    shapeCreatorMenuItem.setDisabledIcon(shapeCreatorDisabledIcon);
    shapeCreatorMenuItem.addActionListener(listener);
    shapeCreatorMenuItem.setEnabled(false);

    // creating the tool item
    shapeCreatorToolItem = new JToggleButton(shapeCreatorIcon);
    shapeCreatorToolItem.setDisabledIcon(shapeCreatorDisabledIcon);
    shapeCreatorToolItem.setToolTipText(itemToolTip);
    shapeCreatorToolItem.addActionListener(listener);
    shapeCreatorToolItem.setEnabled(false);

    // adding the listener to the switches between the svg handles
    final HandlesManager svgHandleManager = Editor.getEditor().getHandlesManager();

    svgHandleManager.addHandlesListener(
        new HandlesListener() {

          @Override
          public void handleChanged(SVGHandle currentHandle, Set<SVGHandle> handles) {

            boolean isDrawingEnabled = isDrawingEnabled(currentHandle);

            shapeCreatorMenuItem.setEnabled(isDrawingEnabled);
            shapeCreatorToolItem.setEnabled(isDrawingEnabled);
            SelectionInfoManager selectionManager = Editor.getEditor().getSelectionManager();

            if (selectionManager.getDrawingShape() != null
                && selectionManager.getDrawingShape().equals(AbstractShape.this)) {

              selectionManager.setToRegularMode();
            }
          }
        });
  }
Beispiel #4
0
 /** Adds the specified ActionListener to all possible buttons. */
 public void addSelectionListener(ActionListener listener) {
   Enumeration<AbstractButton> elements = GROUP.getElements();
   for (; elements.hasMoreElements(); ) {
     AbstractButton button = elements.nextElement();
     button.addActionListener(listener);
   }
 }
 public void setShdPopupOnBtnClick(boolean shdPopup) {
   this.shdPopup = shdPopup;
   if (shdPopup) {
     main.addActionListener(pl);
   } else {
     main.removeActionListener(pl);
   }
 }
 // TODO 1.5: Remove in 1.5
 protected void installPreviousButtonListenersFromSuper(Component c) {
   AbstractButton sc = (AbstractButton) super.createPreviousButton();
   ActionListener[] als = sc.getActionListeners();
   MouseListener[] mls = sc.getMouseListeners();
   if (c instanceof AbstractButton) {
     ((AbstractButton) c).addActionListener(als[0]);
   }
   c.addMouseListener(mls[0]);
 }
 public SelecteurImage(int id) {
   setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
   this.id = id;
   setPreferredSize(new Dimension(125, 125));
   ouvrir = new Bouton("Ouvrir...");
   ouvrir.addActionListener(this);
   image = new PanelImage();
   add(image);
   add(ouvrir);
 }
  /**
   * Utility method for initializing a Window for displaying a JXErrorPane. This is particularly
   * useful because the differences between JFrame and JDialog are so minor. removed.
   */
  private void initWindow(final Window w, final JXErrorPane pane) {
    w.setLayout(new BorderLayout());
    w.add(pane, BorderLayout.CENTER);
    final Action closeAction = new CloseAction(w);
    closeButton.addActionListener(closeAction);
    final ResizeWindow resizeListener = new ResizeWindow(w);
    // make sure this action listener is last (or, oddly, the first in the list)
    ActionListener[] list = detailButton.getActionListeners();
    for (ActionListener a : list) {
      detailButton.removeActionListener(a);
    }
    detailButton.addActionListener(resizeListener);
    for (ActionListener a : list) {
      detailButton.addActionListener(a);
    }

    if (w instanceof JFrame) {
      final JFrame f = (JFrame) w;
      f.getRootPane().setDefaultButton(closeButton);
      f.setResizable(true);
      f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
      KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
      f.getRootPane().registerKeyboardAction(closeAction, ks, JComponent.WHEN_IN_FOCUSED_WINDOW);
    } else if (w instanceof JDialog) {
      final JDialog d = (JDialog) w;
      d.getRootPane().setDefaultButton(closeButton);
      d.setResizable(true);
      d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
      KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
      d.getRootPane().registerKeyboardAction(closeAction, ks, JComponent.WHEN_IN_FOCUSED_WINDOW);
    }

    w.addWindowListener(
        new WindowAdapter() {
          public void windowClosed(WindowEvent e) {
            // remove the action listener
            closeButton.removeActionListener(closeAction);
            detailButton.removeActionListener(resizeListener);
            exitIfFatal();
          }
        });
    w.pack();
  }
 private AbstractButton makeCustomButton(String name, ActionListener listener) {
   String toolTip = jEdit.getProperty(name.concat(".label"));
   AbstractButton b = new RolloverButton(GUIUtilities.loadIcon(jEdit.getProperty(name + ".icon")));
   if (listener != null) {
     b.addActionListener(listener);
     b.setEnabled(true);
   } else {
     b.setEnabled(false);
   }
   b.setToolTipText(toolTip);
   return b;
 }
Beispiel #10
0
  public void addActions(JPanel buttPanel) {

    AbstractAction netcdfAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            String location = ds.getLocation();
            if (location == null) location = "test";
            int pos = location.lastIndexOf(".");
            if (pos > 0) location = location.substring(0, pos);

            String filename = fileChooser.chooseFilenameToSave(location + ".nc");
            if (filename == null) return;
            writeNetCDF(filename);
          }
        };
    BAMutil.setActionProperties(netcdfAction, "netcdf", "Write netCDF-3 file", false, 'S', -1);
    BAMutil.addActionToContainer(buttPanel, netcdfAction);

    AbstractAction ncstreamAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            String location = ds.getLocation();
            if (location == null) location = "test";
            int pos = location.lastIndexOf(".");
            if (pos > 0) location = location.substring(0, pos);

            String filename = fileChooser.chooseFilenameToSave(location + ".ncs");
            if (filename == null) return;
            writeNcstream(filename);
          }
        };
    BAMutil.setActionProperties(ncstreamAction, "netcdf", "Write ncstream file", false, 'S', -1);
    BAMutil.addActionToContainer(buttPanel, ncstreamAction);

    AbstractButton compareButton = BAMutil.makeButtcon("Select", "Compare to another file", false);
    compareButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            compareDataset();
          }
        });
    buttPanel.add(compareButton);

    AbstractAction attAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            showAtts();
          }
        };
    BAMutil.setActionProperties(attAction, "FontDecr", "global attributes", false, 'A', -1);
    BAMutil.addActionToContainer(buttPanel, attAction);
  }
Beispiel #11
0
  /**
   * Set the specified button such that it alternates between being selected and not whenever it is
   * pushed.
   */
  public static synchronized void setToggling(AbstractButton b) {
    if (_toggler == null) {
      _toggler =
          new ActionListener() {
            public void actionPerformed(ActionEvent event) {
              AbstractButton but = (AbstractButton) event.getSource();
              but.setSelected(!but.isSelected());
            }
          };
    }

    b.addActionListener(_toggler);
  }
  @Override
  public AbstractButton createButton(
      Class<? extends AbstractButton> buttonClass, ActionListener target, String textID) {
    AbstractButton button = createEmptyButton(buttonClass, textID);

    // For catching key actions which requires immediate drawing(e.g., for catching Ctrl pressed)
    ScreenUpdater screenUpdater = ScreenUpdater.getInstance();
    button.addKeyListener(screenUpdater.new KeyListener());

    button.addActionListener(target);

    return button;
  }
 private AbstractButton createButton(
     String text, ImageIcon icon, String toolTip, ActionListener actionListener) {
   AbstractButton button = new JButton(text, icon);
   button.setMaximumSize(buttonDimension);
   button.setPreferredSize(buttonDimension);
   if (toolTip != null) {
     button.setToolTipText(toolTip);
   }
   if (actionListener != null) {
     button.addActionListener(actionListener);
   }
   return button;
 }
  public ImportFileDialog(final String defaultValue, final DialogBuilder dialogBuilder) {
    setLayout(new GridBagLayout());

    _importDir = defaultValue;

    final GridBagConstraints c = new GridBagConstraints();
    c.gridy = 1;
    c.insets = new Insets(5, 5, 5, 5);
    c.anchor = GridBagConstraints.NORTHWEST;

    _dialogBuilder = dialogBuilder;

    final Component label = new JLabel("Import BugCollection from: ");

    c.weightx = 0;
    c.gridwidth = 2;
    add(label, c);
    _importFile = new JTextField("");
    _importFile.setEditable(false);
    _importFile.setPreferredSize(new Dimension(200, 20));
    c.weightx = 1;
    c.gridwidth = 1;
    add(_importFile, c);

    final AbstractButton browseButton = new JButton("Browse");
    browseButton.addActionListener(new MyFileChooserActionListener());
    c.weightx = 0;
    add(browseButton, c);

    c.gridx = GridBagConstraints.RELATIVE;
    c.gridy = 2;
    c.gridheight = 2;

    dialogBuilder.setCenterPanel(this);

    _importFile.getDocument().addDocumentListener(new MyDocumentAdapter());
    if (!_importFile.getText().isEmpty()) {
      _selectedFile = new File(_importFile.getText());
    }
    _importFile.addHierarchyListener(
        new HierarchyListener() {
          public void hierarchyChanged(final HierarchyEvent e) {
            if (_importFile.isVisible()) {
              _dialogBuilder.setOkActionEnabled(validateFile(_importFile.getDocument()));
            }
          }
        });
    _dialogBuilder.setOkActionEnabled(_selectedFile != null && _selectedFile.isDirectory());
  }
Beispiel #15
0
  private AbstractButton getMenuEntry(AppAction action) {

    AbstractButton b = createButton(action);
    if (action instanceof ExitToolbarAction) {
      b.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              hideThreadrunning = false;
              TrayIconPopup.this.dispose();
            }
          });
    }
    // resizecomps.add(b);
    return b;
  }
Beispiel #16
0
 /**
  * Configure the specified button to cause the specified property to cycle through the specified
  * values whenever the button is pressed.
  */
 public static ActionListener cycleToProperty(
     final String property, final PrefsConfig config, AbstractButton button, final int[] values) {
   ActionListener al =
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           // get the current value and find out where it is in the list
           int oldval = config.getValue(property, values[0]);
           // if it's not even in the list, newidx will be 0
           int newidx = (1 + IntListUtil.indexOf(values, oldval)) % values.length;
           config.setValue(property, values[newidx]);
         }
       };
   button.addActionListener(al);
   return al;
 }
 private void prepareButton(
     AbstractButton button,
     String actionKey,
     String buttonLabelText,
     String toolTipText,
     URL url) {
   Action action =
       new AbstractAction(actionKey) {
         public void actionPerformed(ActionEvent evt) {}
       };
   button.setAction(action);
   button.setActionCommand(actionKey);
   button.setIcon(new ImageIcon(url));
   button.setText(buttonLabelText);
   button.setToolTipText(toolTipText);
   button.addActionListener(this);
 }
Beispiel #18
0
  /**
   * Descripción de Método
   *
   * @param button
   * @param cmd
   * @param file
   */
  private void setButton(AbstractButton button, String cmd, String file) {
    String text = Msg.getMsg(m_ctx, cmd);

    button.setToolTipText(text);
    button.setActionCommand(cmd);

    //

    ImageIcon ii24 = Env.getImageIcon(file + "24.gif");

    if (ii24 != null) {
      button.setIcon(ii24);
    }

    button.setMargin(AppsAction.BUTTON_INSETS);
    button.setPreferredSize(AppsAction.BUTTON_SIZE);
    button.addActionListener(this);
  } // setButton
Beispiel #19
0
 public static AbstractButton makeCustomButton(
     String name, ActionListener listener, boolean flip) {
   String toolTip = getProperty(name.concat(".label"));
   ImageIcon icon = loadIcon(name + ".icon");
   if (flip && icon != null) {
     Image img = icon.getImage();
     BufferedImage bimg = horizontalflip(img);
     icon = new ImageIcon(bimg);
   }
   AbstractButton b = new RolloverButton(icon);
   if (listener != null) {
     b.addActionListener(listener);
     b.setEnabled(true);
   } else {
     b.setEnabled(false);
   }
   b.setToolTipText(toolTip);
   return b;
 }
    /**
     * @param windowToClose
     * @param jList
     * @param abDone
     * @param resultCodeListenable can be 'null'
     */
    private AListening(
        final Window windowToClose,
        final JList jList,
        final JProgressBar jpb,
        final AbstractButton abDone,
        final OneArgumentListenable<Integer> resultCodeListenable) {
      this.fWindowToClose = windowToClose;
      this.jList = jList;
      this.jProgressBar = jpb;
      this.ab_Done = abDone;

      this.fResultCodeCompletionCallback =
          (resultCodeListenable != null)
              ? resultCodeListenable
              : new OneArgumentListenable<Integer>() {
                @Override
                public void listen(Integer event) {}
              }; // anonymous class

      abDone.addActionListener(this);
    }
  /** Creates the And/Or radio buttons, their button group and a panel for them */
  private JComponent createLogicalButtons() {

    andButton = new JRadioButton(I18N.getString("AttributeResearchPanel.logicalAnd"));
    andButton.setBorder(BorderFactory.createEmptyBorder(2, 10, 2, 10));
    andButton.setActionCommand(logicalRelationships[0]);
    andButton.doClick();

    orButton = new JRadioButton(I18N.getString("AttributeResearchPanel.logicalOr"));
    orButton.setBorder(BorderFactory.createEmptyBorder(2, 10, 5, 10));
    orButton.setActionCommand(logicalRelationships[1]);

    ActionListener bal =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JRadioButton rb = (JRadioButton) e.getSource();
            currentRelationship = rb.getActionCommand();
          }
        };
    andButton.addActionListener(bal);
    orButton.addActionListener(bal);

    ButtonGroup bg = new ButtonGroup();
    bg.add(andButton);
    bg.add(orButton);
    JPanel b = new JPanel();
    LayoutManager lm = new BoxLayout(b, BoxLayout.PAGE_AXIS);
    b.setLayout(lm);
    b.setAlignmentX(Component.LEFT_ALIGNMENT);
    b.setBorder(
        BorderFactory.createTitledBorder(I18N.getString("AttributeResearchPanel.logicalLink")));

    // add a bit of space
    b.add(Box.createRigidArea(new Dimension(20, 10)));
    b.add(andButton);
    b.add(Box.createRigidArea(new Dimension(20, 10)));
    b.add(orButton);
    b.setPreferredSize(new Dimension(150, 100));

    return b;
  }
Beispiel #22
0
  /**
   * Create a label to describe this theme template.
   *
   * @return Guess.
   */
  public Component getButton() {

    final MyTheme theme = this;
    final ToolTip toolTip = new ToolTip("  ~ " + toString() + " ~  ");

    AbstractButton button =
        new JButton() {

          @Override
          public void updateUI() {

            super.updateUI();
            toolTip.updateUI();

            if (theme.getLookAndFeel().equals(ShadeConfig.theme.get()))
              setBackground(lookAndFeel.getBase());
            else setBackground(lookAndFeel.getBright());
          }
        };
    button.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {

            ShadeConfig.theme.set(theme.getLookAndFeel());
            ShadeConfig.getUi().execute(BasicRequest.THEME);

            if (theme == CUSTOM)
              if (customThemeDialog(ShadeConfig.getUi().getFrame()))
                ShadeConfig.getUi().execute(BasicRequest.THEME);
          }
        });
    button.setPreferredSize(new Dimension(20, 20));
    button.setAlignmentX(0);
    toolTip.setContent(button);

    return button;
  }
 /**
  * Shifts the screen view to the left.
  *
  * @return
  */
 protected AbstractButton getLeftButton() {
   if (leftButton == null) {
     leftButton = new JButton("Left");
     ImageIcon leftIcon = null;
     java.net.URL imgURL = null;
     try {
       imgURL = this.getClass().getResource("/images/leftArrow20.jpg");
       leftIcon = new ImageIcon(imgURL);
       leftButton.setIcon(leftIcon);
       leftButton.setText(null);
     } catch (NullPointerException npe) {
       System.out.println("Failed to load in the icon [" + imgURL + "]");
     }
     leftButton.addActionListener(
         new ActionListener() {
           public void actionPerformed(ActionEvent ae) {
             view.shiftLeft();
           }
         });
   }
   return leftButton;
 }
Beispiel #24
0
  /**
   * Default constructor.
   *
   * @param man view manager
   */
  public TextView(final ViewNotifier man) {
    super(TEXTVIEW, man);
    border(5).layout(new BorderLayout(0, 5));

    header = new BaseXHeader(RESULT);

    home = BaseXButton.command(GUIMenuCmd.C_HOME, gui);
    home.setEnabled(false);

    text = new TextPanel(false, gui);
    text.setSyntax(new SyntaxXML());
    search = new SearchEditor(gui, text);

    final AbstractButton save = BaseXButton.get("c_save", SAVE, false, gui);
    final AbstractButton find = search.button(FIND);

    final BaseXBack buttons = new BaseXBack(false);
    buttons.layout(new TableLayout(1, 3, 1, 0)).border(0, 0, 4, 0);
    buttons.add(save);
    buttons.add(home);
    buttons.add(find);

    final BaseXBack b = new BaseXBack(false).layout(new BorderLayout());
    b.add(buttons, BorderLayout.WEST);
    b.add(header, BorderLayout.EAST);
    add(b, BorderLayout.NORTH);

    add(search, BorderLayout.CENTER);

    save.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            save();
          }
        });
    refreshLayout();
  }
 public void addActionListener(ActionListener l) {
   main.addActionListener(l);
   listener = l;
 }
  public HexagonViewerAdvance(String[] args) {
    FormPanel panel = new FormPanel("ise/ct/plugins/HexagonViewerForm.jfrm");
    super.add(panel);

    // add references to configurable components on form
    worldMap = panel.getComponentByName("HexagonViewerImage");

    statusTitle = panel.getComponentByName("StatusTitle");
    fileTitle = panel.getLabel("FileTitle");
    fileProgress = panel.getProgressBar("FileProgress");
    iterationTitle = panel.getLabel("IterationTitle");
    iterationProgress = panel.getProgressBar("IterationProgress");
    cycleTitle = panel.getLabel("CycleTitle");
    cycleProgress = panel.getProgressBar("CycleProgress");

    currentTitle = panel.getComponentByName("CurrentTitle");
    commentTitle = panel.getLabel("CommentTitle");
    commentLabel = panel.getLabel("CommentLabel");
    phaseTitle = panel.getLabel("PhaseTitle");
    phaseLabel = panel.getLabel("PhaseLabel");
    turnTitle = panel.getLabel("TurnTitle");
    turnProgress = panel.getProgressBar("TurnProgress");

    showPaths = panel.getCheckBox("ShowPaths");
    showPaths.setActionCommand("showpaths");
    showPaths.setSelected(true);
    doShowPaths = true;
    showPaths.addItemListener(this);

    playButton = panel.getButton("PlayButton");
    stepButton = panel.getButton("StepButton");
    endButton = panel.getButton("EndButton");
    playButton.setActionCommand("play");
    stepButton.setActionCommand("step");
    endButton.setActionCommand("end");
    playButton.addItemListener(this);
    stepButton.addItemListener(this);
    endButton.addItemListener(this);
    playButton.setEnabled(true);
    stepButton.setEnabled(true);
    endButton.setEnabled(true);

    playButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            JButton s = (JButton) ae.getSource();
            if (s.getText().equalsIgnoreCase("Pause")) {
              s.setText("Play");
              Simulator.controlPanel.paused = true;
              Simulator.controlPanel.step = false;
            } else {
              s.setText("Pause");
              Simulator.controlPanel.paused = false;
              Simulator.controlPanel.step = false;
            }
          }
        });

    stepButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            playButton.setText("Play");
            Simulator.controlPanel.paused = true;
            Simulator.controlPanel.step = true;
          }
        });

    endButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            Simulator.experimentLength = Simulator.cycle;
            Simulator.controlPanel.paused = false;
          }
        });

    cycleTitle = panel.getLabel("CycleTitle");
    phaseTitle = panel.getLabel("PhaseTitle");
    inspectorTitle = panel.getLabel("InspectorTitle");
    cycleProgress = panel.getProgressBar("CycleProgress");

    seperator1 = panel.getComponentByName("Seperator1");
    seperator2 = panel.getComponentByName("Seperator2");
    seperator3 = panel.getComponentByName("Seperator3");
    seperator4 = panel.getComponentByName("Seperator4");

    // inspector JScrollPane and JTree
    inspectorScrollPane = panel.getComponentByName("InspectorScrollPane");
    inspectorTree = new JTree();
    inspectorTree.setRowHeight(iconSize);
    inspectorTree.setCellRenderer(
        new DefaultTreeCellRenderer() {
          private static final long serialVersionUID = 1L;

          public Icon getLeafIcon() {
            Icon icon;
            if (this.getText().equals(AUCTION_NAME)) {
              icon = new ImageIcon(createAuctionIcon(iconSize, iconSize));
            } else {
              icon = new ImageIcon(createAgentIcon(this.getText(), iconSize, iconSize));
            }
            return icon;
          }
        });

    getRootPane().setDefaultButton((JButton) playButton);
    super.addComponentListener(this); // resize events etc.

    // set the parameters this frame
    setSize(600, 500);
    setLocation(200, 100);
    setTitle("Hexagon Viewer Advance");
    setVisible(true);
  }
 // IButtonGroup Implementations
 public void add(AbstractButton button) {
   button.addActionListener(actionListener);
   bg.add(button);
   super.add(button);
 }
  /**
   * Creates and initializes the components which make up the aggregate combo box. This method is
   * called as part of the UI installation process.
   */
  protected void installComponents() {
    iconLabel = new JLabel(pane.getIcon());

    errorMessage = new JEditorPane();
    errorMessage.setEditable(false);
    errorMessage.setContentType("text/html");
    errorMessage.setEditorKitForContentType("text/plain", new StyledEditorKit());
    errorMessage.setEditorKitForContentType("text/html", new HTMLEditorKit());

    errorMessage.setOpaque(false);
    errorMessage.putClientProperty(JXEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);

    closeButton =
        new JButton(
            UIManagerExt.getString(CLASS_NAME + ".ok_button_text", errorMessage.getLocale()));

    reportButton = new EqualSizeJButton(pane.getActionMap().get(JXErrorPane.REPORT_ACTION_KEY));

    detailButton =
        new EqualSizeJButton(
            UIManagerExt.getString(CLASS_NAME + ".details_expand_text", errorMessage.getLocale()));

    details = new JXEditorPane();
    details.setContentType("text/html");
    details.putClientProperty(JXEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
    details.setTransferHandler(createDetailsTransferHandler(details));
    detailsScrollPane = new JScrollPane(details);
    detailsScrollPane.setPreferredSize(new Dimension(10, 250));
    details.setEditable(false);
    detailsPanel = new JPanel();
    detailsPanel.setVisible(false);
    copyToClipboardButton =
        new JButton(
            UIManagerExt.getString(
                CLASS_NAME + ".copy_to_clipboard_button_text", errorMessage.getLocale()));
    copyToClipboardListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            details.copy();
          }
        };
    copyToClipboardButton.addActionListener(copyToClipboardListener);

    detailsPanel.setLayout(createDetailPanelLayout());
    detailsPanel.add(detailsScrollPane);
    detailsPanel.add(copyToClipboardButton);

    // Create error scroll pane. Make sure this happens before call to createErrorPaneLayout() in
    // case any extending
    // class wants to manipulate the component there.
    errorScrollPane = new JScrollPane(errorMessage);
    errorScrollPane.setBorder(new EmptyBorder(0, 0, 5, 0));
    errorScrollPane.setOpaque(false);
    errorScrollPane.getViewport().setOpaque(false);

    // initialize the gui. Most of this code is similar between Mac and PC, but
    // where they differ protected methods have been written allowing the
    // mac implementation to alter the layout of the dialog.
    pane.setLayout(createErrorPaneLayout());

    // An empty border which constitutes the padding from the edge of the
    // dialog to the content. All content that butts against this border should
    // not be padded.
    Insets borderInsets = new Insets(16, 24, 16, 17);
    pane.setBorder(
        BorderFactory.createEmptyBorder(
            borderInsets.top, borderInsets.left, borderInsets.bottom, borderInsets.right));

    // add the JLabel responsible for displaying the icon.
    // TODO: in the future, replace this usage of a JLabel with a JXImagePane,
    // which may add additional "coolness" such as allowing the user to drag
    // the image off the dialog onto the desktop. This kind of coolness is common
    // in the mac world.
    pane.add(iconLabel);
    pane.add(errorScrollPane);
    pane.add(closeButton);
    pane.add(reportButton);
    reportButton.setVisible(false); // not visible by default
    pane.add(detailButton);
    pane.add(detailsPanel);

    // make the buttons the same size
    EqualSizeJButton[] buttons =
        new EqualSizeJButton[] {(EqualSizeJButton) detailButton, (EqualSizeJButton) reportButton};
    ((EqualSizeJButton) reportButton).setGroup(buttons);
    ((EqualSizeJButton) detailButton).setGroup(buttons);

    reportButton.setMinimumSize(reportButton.getPreferredSize());
    detailButton.setMinimumSize(detailButton.getPreferredSize());

    // set the event handling
    detailListener = new DetailsClickEvent();
    detailButton.addActionListener(detailListener);
  }
Beispiel #29
0
  private void guiSetup() throws IOException {
    setContentPane(root);

    // control
    commandMap.put(btnForward, Command.FORWARD);
    commandMap.put(btnBackward, Command.BACKWARD);
    commandMap.put(btnLeft, Command.TURN_LEFT);
    commandMap.put(btnRight, Command.TURN_RIGHT);
    commandMap.put(btnStop, Command.STOP);

    // Servo && Camera
    commandMap.put(btnServoDown, Command.SERVO_DOWN);
    commandMap.put(btnServoLeft, Command.SERVO_LEFT);
    commandMap.put(btnServoRight, Command.SERVO_RIGHT);
    commandMap.put(btnServoUp, Command.SERVO_UP);
    commandMap.put(btnCamera, Command.TOGGLE_CAMERA);

    // LEDs
    commandMap.put(btnLeftLed, Command.TOGGLE_LEFT_BLINK);
    commandMap.put(btnRightLed, Command.TOGGLE_RIGHT_BLINK);
    commandMap.put(btnLED, Command.TOGGLE_LED);

    // speeds
    commandMap.put(btnSpeed1, Command.SPEED);
    commandMap.put(btnSpeed2, Command.SPEED);
    commandMap.put(btnSpeed3, Command.SPEED);
    commandMap.put(btnSpeed4, Command.SPEED);
    commandMap.put(btnSpeed5, Command.SPEED);

    // debugs
    commandMap.put(btnLF, Command.LEFT_FORWARD);
    commandMap.put(btnLB, Command.LEFT_BACKWARD);
    commandMap.put(btnLP, Command.LEFT_PAUSE);
    commandMap.put(btnRF, Command.RIGHT_FORWARD);
    commandMap.put(btnRB, Command.RIGHT_BACKWARD);
    commandMap.put(btnRP, Command.RIGHT_PAUSE);

    for (AbstractButton button : commandMap.keySet()) {
      button.addActionListener(this);
    }
    btnQuit.addActionListener(this);
    btnConnection.addActionListener(this);
    btnReset.addActionListener(this);
    btnShutdown.addActionListener(this);

    /*
            btnForward.addActionListener (this);
            btnLeft.addActionListener (this);
            btnBackward.addActionListener (this);
            btnRight.addActionListener (this);
            btnStop.addActionListener (this);

            btnSpeed1.addActionListener (this);
            btnSpeed2.addActionListener (this);
            btnSpeed3.addActionListener (this);
            btnSpeed4.addActionListener (this);
            btnSpeed5.addActionListener (this);
            btnLeftLed.addActionListener (this);
            btnRightLed.addActionListener (this);
            btnServoLeft.addActionListener (this);
            btnServoUp.addActionListener (this);
            btnServoRight.addActionListener (this);
            btnServoDown.addActionListener (this);
            btnLED.addActionListener (this);
            btnCamera.addActionListener (this);
            btnLF.addActionListener (this);
            btnLB.addActionListener (this);
            btnLP.addActionListener (this);
            btnRF.addActionListener (this);
            btnRB.addActionListener (this);
            btnRP.addActionListener (this);
    */

    ButtonGroup group1 = new ButtonGroup();
    group1.add(btnSpeed1);
    group1.add(btnSpeed2);
    group1.add(btnSpeed3);
    group1.add(btnSpeed4);
    group1.add(btnSpeed5);
    btnSpeed3.setSelected(true);

    setButtonStatus(false);
  }
  public void Initialize() {

    setIJCal();
    setPreferredLocation();

    buttonPanel_ = new Panel();

    AbstractButton saveButton = new JButton("Save");
    saveButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            new FileSaver(getImagePlus()).save();
          }
        });
    buttonPanel_.add(saveButton);

    AbstractButton saveAsButton = new JButton("Save As...");
    saveAsButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            new FileSaver(getImagePlus()).saveAsTiff();
          }
        });
    buttonPanel_.add(saveAsButton);

    add(buttonPanel_);
    pack();

    // add window listeners
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            finalizeClosing();

            if (contrastDlg_ != null) contrastDlg_.dispose();
            savePosition();
            // ToDo: implement winAccesslock_;
            // remember LUT so that a new window can be opened with the
            // same LUT
            if (getImagePlus().getProcessor().isPseudoColorLut())
              currentColorModel_ = getImagePlus().getProcessor().getColorModel();

            if (contrastPanel_ != null) contrastPanel_.setImagePlus(null, null, null);
            // remember old color model
            if (getImagePlus().getProcessor().isPseudoColorLut())
              currentColorModel_ = getImagePlus().getProcessor().getColorModel();
            WindowManager.removeWindow(getImagePlus().getWindow());
          }
        });
    addWindowListener(
        new WindowAdapter() {
          public void windowClosed(WindowEvent e) {}
        });

    addWindowListener(
        new WindowAdapter() {
          public void windowOpened(WindowEvent e) {
            getCanvas().requestFocus();
            finalizeOpening();
          }
        });

    addWindowListener(
        new WindowAdapter() {
          public void windowGainedFocus(WindowEvent e) {
            updateHistogram();
          }
        });

    addWindowListener(
        new WindowAdapter() {
          public void windowActivated(WindowEvent e) {
            updateHistogram();
          }
        });
    setIconImage(
        SwingResourceManager.getImage(
            MMStudioMainFrame.class, "/org/micromanager/icons/camera.png"));

    setIJCal();
  }