Search in sources :

Example 1 with ShowFlagsPanel

use of org.micromanager.internal.utils.ShowFlagsPanel in project micro-manager by micro-manager.

the class PropertyEditor method createComponents.

private void createComponents() {
    setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/org/micromanager/icons/microscope.gif")));
    setLayout(new MigLayout("fill, insets 2, flowy"));
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            flags_.save(PropertyEditor.class);
        }

        @Override
        public void windowOpened(WindowEvent e) {
            // restore values from the previous session
            data_.update(false);
            data_.fireTableStructureChanged();
        }
    });
    setTitle("Device Property Browser");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final JButton refreshButton = new JButton("Refresh", new ImageIcon(getClass().getResource("/org/micromanager/icons/arrow_refresh.png")));
    Font defaultFont = new Font("Arial", Font.PLAIN, 10);
    add(new ShowFlagsPanel(data_, flags_, core_, core_.getSystemStateCache()), "split 2, aligny top, gapbottom 10");
    refreshButton.setFont(defaultFont);
    refreshButton.addActionListener((ActionEvent e) -> {
        refresh(false);
    });
    add(refreshButton, "width 100!, center, wrap");
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setViewportView(table_);
    scrollPane.setFont(defaultFont);
    scrollPane.setBorder(new BevelBorder(BevelBorder.LOWERED));
    add(scrollPane, "span, grow, push, wrap");
}
Also used : JScrollPane(javax.swing.JScrollPane) ImageIcon(javax.swing.ImageIcon) BevelBorder(javax.swing.border.BevelBorder) ActionEvent(java.awt.event.ActionEvent) MigLayout(net.miginfocom.swing.MigLayout) WindowEvent(java.awt.event.WindowEvent) JButton(javax.swing.JButton) ShowFlagsPanel(org.micromanager.internal.utils.ShowFlagsPanel) WindowAdapter(java.awt.event.WindowAdapter) Font(java.awt.Font)

Example 2 with ShowFlagsPanel

use of org.micromanager.internal.utils.ShowFlagsPanel in project micro-manager by micro-manager.

the class ConfigDialog method initializeWidgets.

protected void initializeWidgets() {
    if (showFlagsPanelVisible_) {
        flags_.load(ConfigDialog.class);
        Configuration cfg;
        try {
            if (presetName_.length() == 0) {
                cfg = new Configuration();
            } else {
                cfg = core_.getConfigState(groupName_, presetName_);
            }
            showFlagsPanel_ = new ShowFlagsPanel(data_, flags_, core_, cfg);
            add(showFlagsPanel_, "skip " + numRowsBeforeFilters_ + ", aligny top, span 1 3, wrap");
        } catch (Exception e) {
            ReportingUtils.showError(e);
        }
    }
    final JPanel topMidPanel = new JPanel(new MigLayout("flowx, insets 0 6 0 0, gap 2"));
    instructionsTextArea_ = new JTextArea();
    instructionsTextArea_.setFont(new Font("Arial", Font.PLAIN, 12));
    instructionsTextArea_.setWrapStyleWord(true);
    instructionsTextArea_.setText(instructionsText_);
    instructionsTextArea_.setEditable(false);
    instructionsTextArea_.setOpaque(false);
    topMidPanel.add(instructionsTextArea_, "gaptop 2, wrap");
    nameFieldLabel_ = new JLabel(nameFieldLabelText_);
    nameFieldLabel_.setFont(new Font("Arial", Font.BOLD, 12));
    topMidPanel.add(nameFieldLabel_, "split 2, alignx right");
    nameField_ = new JTextField();
    nameField_.setFont(new Font("Arial", Font.PLAIN, 12));
    // nameField_.setFont(new Font("Arial", Font.BOLD, 16));
    // should consider increasing font size for entry field for readability,
    // but would want to do it in multiple places for consistency
    nameField_.setText(initName_);
    nameField_.setEditable(true);
    nameField_.setSelectionStart(0);
    nameField_.setSelectionEnd(nameField_.getText().length());
    int fieldWidth = showPixelSize_ ? 90 : 180;
    topMidPanel.add(nameField_, "width " + fieldWidth + "!, gaptop 2, wrap");
    if (showPixelSize_) {
        JLabel pixelSizeFieldLabel = new JLabel(pixelSizeFieldLabelText_);
        pixelSizeFieldLabel.setFont(new Font("Arial", Font.BOLD, 12));
        topMidPanel.add(pixelSizeFieldLabel, "split 2, alignx right");
        pixelSizeField_ = new JTextField();
        pixelSizeField_.setFont(new Font("Arial", Font.PLAIN, 12));
        pixelSizeField_.setText(pixelSize_);
        pixelSizeField_.setEditable(true);
        pixelSizeField_.setSelectionStart(0);
        pixelSizeField_.setSelectionEnd(pixelSizeField_.getText().length());
        topMidPanel.add(pixelSizeField_, "width " + fieldWidth + "!, gaptop 2, wrap");
    }
    JPanel topRightPanel = new JPanel(new MigLayout("flowy, insets 0 6 0 0, gap 2"));
    okButton_ = new JButton("OK");
    okButton_.addActionListener(e -> {
        if (table_.isEditing() && table_.getCellEditor() != null) {
            table_.getCellEditor().stopCellEditing();
        }
        okChosen();
    });
    topRightPanel.add(okButton_, "gapleft push, split 2, width 90!");
    cancelButton_ = new JButton("Cancel");
    cancelButton_.addActionListener(e -> dispose());
    topRightPanel.add(cancelButton_, "width 90!");
    add(topMidPanel, "flowx, split 2");
    add(topRightPanel, "gapleft push, flowx");
    // Override x button to make it have same behavior as Cancel button
    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            dispose();
        }
    });
}
Also used : JPanel(javax.swing.JPanel) JTextArea(javax.swing.JTextArea) Configuration(mmcorej.Configuration) MigLayout(net.miginfocom.swing.MigLayout) ShowFlagsPanel(org.micromanager.internal.utils.ShowFlagsPanel) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) WindowAdapter(java.awt.event.WindowAdapter) JTextField(javax.swing.JTextField) Font(java.awt.Font) WindowEvent(java.awt.event.WindowEvent)

Aggregations

Font (java.awt.Font)2 WindowAdapter (java.awt.event.WindowAdapter)2 WindowEvent (java.awt.event.WindowEvent)2 JButton (javax.swing.JButton)2 MigLayout (net.miginfocom.swing.MigLayout)2 ShowFlagsPanel (org.micromanager.internal.utils.ShowFlagsPanel)2 ActionEvent (java.awt.event.ActionEvent)1 ImageIcon (javax.swing.ImageIcon)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 JTextArea (javax.swing.JTextArea)1 JTextField (javax.swing.JTextField)1 BevelBorder (javax.swing.border.BevelBorder)1 Configuration (mmcorej.Configuration)1