Search in sources :

Example 71 with JDialog

use of javax.swing.JDialog in project cayenne by apache.

the class DataDomainGraphTab method rebuild.

/**
 * Rebuilds graph, deleting existing if needed
 */
public void rebuild() {
    if (domain != null) {
        JOptionPane pane = new JOptionPane("Rebuilding graph from domain will cause all user" + " changes to be lost. Continue?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);
        JDialog dialog = pane.createDialog(Application.getFrame(), "Confirm Rebuild");
        dialog.setVisible(true);
        if (pane.getValue().equals(JOptionPane.YES_OPTION)) {
            getGraphRegistry().getGraphMap(domain).remove(getSelectedType());
            itemStateChanged(null);
        }
    }
}
Also used : JOptionPane(javax.swing.JOptionPane) JDialog(javax.swing.JDialog)

Example 72 with JDialog

use of javax.swing.JDialog in project cayenne by apache.

the class OverwriteDialog method show.

public void show() {
    JOptionPane pane = new JOptionPane("Do you want to overwrite an existing file: " + file, JOptionPane.QUESTION_MESSAGE);
    pane.setOptions(OPTIONS);
    JDialog dialog = pane.createDialog(parent, "File exists");
    dialog.setVisible(true);
    Object selectedValue = pane.getValue();
    result = (selectedValue != null) ? selectedValue.toString() : CANCEL;
}
Also used : JOptionPane(javax.swing.JOptionPane) JDialog(javax.swing.JDialog)

Example 73 with JDialog

use of javax.swing.JDialog in project knime-core by knime.

the class NodeDialog method initDialog.

/*
     * Inits the underlying dialog with title and icon.
     */
private JDialog initDialog(final String title) {
    JFrame dummy = new JFrame();
    if (KNIMEConstants.KNIME16X16 != null) {
        dummy.setIconImage(KNIMEConstants.KNIME16X16.getImage());
    }
    // init underlying dialog
    JDialog dialog = new JDialog(dummy);
    dialog.setTitle(title);
    dialog.setModal(true);
    // dialog.setResizable(false);
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    dialog.addWindowListener(new WindowAdapter() {

        /**
         * Invoked when the window close icon X is pressed.
         */
        @Override
        public void windowClosed(final WindowEvent e) {
            onClose(e);
        }

        /**
         * Invoked when the window is opened.
         */
        @Override
        public void windowOpened(final WindowEvent we) {
            onOpen(we);
        }
    });
    return dialog;
}
Also used : JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) JDialog(javax.swing.JDialog)

Example 74 with JDialog

use of javax.swing.JDialog in project knime-core by knime.

the class ColorLegendTab method createChangeColorButton.

/**
 * Creates a button which opens a color chooser with the current color
 * preselected, updates the color mapping and informs the listeners.
 *
 * @param colName column name
 * @param currColor current color
 * @return a button with the above described functionality
 */
private JButton createChangeColorButton(final String colName, final Color currColor) {
    JButton btn = new JButton("Change...");
    final JColorChooser chooser = new JColorChooser(currColor);
    final ActionListener okListener = new ActionListener() {

        /**
         * {@inheritDoc}
         */
        public void actionPerformed(final ActionEvent arg0) {
            // set the new color in the mapping
            m_mapping.put(colName, chooser.getColor());
            // update the legend
            update(m_mapping);
            // inform the listener about a change
            for (ChangeListener listener : m_listener) {
                listener.stateChanged(new ChangeEvent(this));
            }
        }
    };
    btn.addActionListener(new ActionListener() {

        /**
         * {@inheritDoc}
         */
        public void actionPerformed(final ActionEvent e) {
            JDialog dialog = JColorChooser.createDialog(ColorLegendTab.this, "Select new color", true, chooser, okListener, null);
            dialog.setVisible(true);
        }
    });
    return btn;
}
Also used : ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) ChangeListener(javax.swing.event.ChangeListener) JColorChooser(javax.swing.JColorChooser) JDialog(javax.swing.JDialog)

Example 75 with JDialog

use of javax.swing.JDialog in project vcell by virtualcell.

the class PDEDataViewer method sendTimeSeriesImageJ.

// private Hashtable<String, JLabel> sendTimeSeriesLabels = new Hashtable<>();
// @Override
// public void exportMessage(ExportEvent event) {
// super.exportMessage(event);
// if(sendTimeSeriesLabels.size() > 0){
// JLabel messgLabel = sendTimeSeriesLabels.values().iterator().next();
// SwingUtilities.invokeLater(new Runnable() {
// @Override
// public void run() {
// messgLabel.setText(event.getMessageData().toString());
// }
// });
// }
// }
private void sendTimeSeriesImageJ() {
    final JPanel mainJPanel = new JPanel();
    BoxLayout mainBL = new BoxLayout(mainJPanel, BoxLayout.Y_AXIS);
    mainJPanel.setLayout(mainBL);
    final boolean[] response = new boolean[] { false };
    MiniTimePanel timeJPanel = new MiniTimePanel();
    final JLabel messgLabel = new JLabel("time points to export:" + (timeJPanel.jcb_time_end.getSelectedIndex() - timeJPanel.jcb_time_begin.getSelectedIndex() + 1));
    JRadioButton slicebtn = new JRadioButton("Slice " + getPDEDataContextPanel1().getSlice() + " only");
    slicebtn.setSelected(true);
    JPanel messageAndSlicePanel = null;
    if (getPdeDataContext().getCartesianMesh().getGeometryDimension() == 3) {
        messageAndSlicePanel = new JPanel();
        ((FlowLayout) messageAndSlicePanel.getLayout()).setAlignment(FlowLayout.LEFT);
        ButtonGroup buttonGroup = new ButtonGroup();
        JRadioButton allslicebtn = new JRadioButton("All slices");
        buttonGroup.add(slicebtn);
        buttonGroup.add(allslicebtn);
        messageAndSlicePanel.add(messgLabel);
        messageAndSlicePanel.add(slicebtn);
        messageAndSlicePanel.add(allslicebtn);
    }
    ActionListener okAction = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (((Double) timeJPanel.jcb_time_begin.getSelectedItem()).compareTo((Double) timeJPanel.jcb_time_end.getSelectedItem()) > 0) {
                PopupGenerator.showErrorDialog(PDEDataViewer.this, "Selected 'Begin Time' must be less than or equal to 'End Time'");
                return;
            }
            response[0] = true;
            BeanUtils.disposeParentWindow(mainJPanel);
        }
    };
    ActionListener cancelAction = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            BeanUtils.disposeParentWindow(mainJPanel);
        }
    };
    final OkCancelSubPanel okCancelJPanel = new OkCancelSubPanel(okAction, cancelAction);
    ActionListener rangeListener = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int range = timeJPanel.jcb_time_end.getSelectedIndex() - timeJPanel.jcb_time_begin.getSelectedIndex() + 1;
            okCancelJPanel.okButton.setEnabled(range > 0);
            messgLabel.setText((range < 0 ? "Error: begin time must be < end time" : "time points to export:" + (range)));
        }
    };
    timeJPanel.jcb_time_end.addActionListener(rangeListener);
    timeJPanel.jcb_time_begin.addActionListener(rangeListener);
    okCancelJPanel.okButton.setEnabled(true);
    mainJPanel.add(timeJPanel);
    mainJPanel.add((messageAndSlicePanel == null ? messgLabel : messageAndSlicePanel));
    mainJPanel.add(okCancelJPanel);
    Frame dialogOwner = JOptionPane.getFrameForComponent(this);
    JOptionPane inputDialog = new JOptionPane(mainJPanel, JOptionPane.PLAIN_MESSAGE, 0, null, new Object[0]);
    final JDialog d = inputDialog.createDialog(dialogOwner, "'" + getSimulationModelInfo().getContextName() + "':'" + getSimulationModelInfo().getSimulationName() + "':'" + getPdeDataContext().getVariableName() + "'");
    d.setResizable(true);
    d.setModal(true);
    d.pack();
    d.setVisible(true);
    // }
    if (!response[0]) {
        return;
    }
    ExportSpecs exportSpecs = new ExportSpecs(getPdeDataContext().getVCDataIdentifier(), ExportFormat.IMAGEJ, new VariableSpecs(new String[] { getPdeDataContext().getDataIdentifier().getName() }, ExportConstants.VARIABLE_MULTI), new TimeSpecs(timeJPanel.jcb_time_begin.getSelectedIndex(), timeJPanel.jcb_time_end.getSelectedIndex(), getPdeDataContext().getTimePoints(), ExportConstants.TIME_RANGE), new GeometrySpecs(null, getPDEDataContextPanel1().getNormalAxis(), getPDEDataContextPanel1().getSlice(), (slicebtn.isSelected() ? ExportConstants.GEOMETRY_SLICE : ExportConstants.GEOMETRY_FULL)), new RasterSpecs(ExportConstants.NRRD_BY_VARIABLE, false), getSimulationModelInfo().getSimulationName(), getSimulationModelInfo().getContextName());
    getDataViewerManager().startExport(this, ((ClientPDEDataContext) getPdeDataContext()).getDataManager().getOutputContext(), exportSpecs);
}
Also used : JPanel(javax.swing.JPanel) Frame(java.awt.Frame) JRadioButton(javax.swing.JRadioButton) FlowLayout(java.awt.FlowLayout) RasterSpecs(cbit.vcell.export.server.RasterSpecs) ActionEvent(java.awt.event.ActionEvent) ExportSpecs(cbit.vcell.export.server.ExportSpecs) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) GeometrySpecs(cbit.vcell.export.server.GeometrySpecs) JOptionPane(javax.swing.JOptionPane) Point(java.awt.Point) SinglePoint(cbit.vcell.geometry.SinglePoint) VariableSpecs(cbit.vcell.export.server.VariableSpecs) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ClientPDEDataContext(cbit.vcell.simdata.ClientPDEDataContext) TimeSpecs(cbit.vcell.export.server.TimeSpecs) JDialog(javax.swing.JDialog)

Aggregations

JDialog (javax.swing.JDialog)181 JButton (javax.swing.JButton)70 JPanel (javax.swing.JPanel)61 ActionEvent (java.awt.event.ActionEvent)51 ActionListener (java.awt.event.ActionListener)39 JLabel (javax.swing.JLabel)39 JOptionPane (javax.swing.JOptionPane)34 BorderLayout (java.awt.BorderLayout)30 Dimension (java.awt.Dimension)27 JScrollPane (javax.swing.JScrollPane)27 JFrame (javax.swing.JFrame)23 BoxLayout (javax.swing.BoxLayout)21 FlowLayout (java.awt.FlowLayout)19 JCheckBox (javax.swing.JCheckBox)15 AbstractAction (javax.swing.AbstractAction)14 WindowEvent (java.awt.event.WindowEvent)13 JComponent (javax.swing.JComponent)12 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)11 WindowAdapter (java.awt.event.WindowAdapter)11 IOException (java.io.IOException)10