Search in sources :

Example 26 with JDialog

use of javax.swing.JDialog in project EnrichmentMapApp by BaderLab.

the class PostAnalysisPanelMediator method showDialog.

@SuppressWarnings("serial")
public void showDialog(Component parent, CyNetworkView netView) {
    final EnrichmentMap map = emManager.getEnrichmentMap(netView.getModel().getSUID());
    invokeOnEDT(() -> {
        final PostAnalysisInputPanel panel = panelFactory.create(map);
        final JDialog dialog = new JDialog(swingApplication.getJFrame(), "Add Signature Gene Sets", ModalityType.APPLICATION_MODAL);
        dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        JButton helpButton = SwingUtil.createOnlineHelpButton(EnrichmentMapBuildProperties.USER_MANUAL_URL, "Online Manual...", serviceRegistrar);
        JButton resetButton = new JButton("Reset");
        resetButton.addActionListener(e -> panel.reset());
        JButton closeButton = new JButton(new AbstractAction("Close") {

            @Override
            public void actionPerformed(ActionEvent e) {
                dialog.dispose();
            }
        });
        JButton runButton = new JButton(new AbstractAction("Add") {

            @Override
            public void actionPerformed(ActionEvent e) {
                if (panel.isReady()) {
                    Optional<PostAnalysisParameters> params = buildPostAnalysisParameters(panel, map, dialog);
                    if (params.isPresent()) {
                        addGeneSets(netView, params.get());
                        dialog.dispose();
                    } else {
                        JOptionPane.showMessageDialog(panel, "Could not run post analysis.", "EnrichmentMap: Error", JOptionPane.WARNING_MESSAGE);
                    }
                }
            }
        });
        JPanel buttonPanel = LookAndFeelUtil.createOkCancelPanel(runButton, closeButton, helpButton, resetButton);
        dialog.getContentPane().add(panel, BorderLayout.CENTER);
        dialog.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
        LookAndFeelUtil.setDefaultOkCancelKeyStrokes(dialog.getRootPane(), runButton.getAction(), closeButton.getAction());
        dialog.getRootPane().setDefaultButton(runButton);
        dialog.pack();
        dialog.setLocationRelativeTo(swingApplication.getJFrame());
        dialog.setVisible(true);
    });
}
Also used : JPanel(javax.swing.JPanel) Optional(java.util.Optional) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) AbstractAction(javax.swing.AbstractAction) JDialog(javax.swing.JDialog)

Example 27 with JDialog

use of javax.swing.JDialog in project EnrichmentMapApp by BaderLab.

the class LegendPanelMediator method init.

@AfterInjection
@SuppressWarnings("serial")
private void init() {
    invokeOnEDTAndWait(() -> {
        dialog = new JDialog(swingApplication.getJFrame(), "EnrichmentMap Legend", ModalityType.MODELESS);
        dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        dialog.setMinimumSize(new Dimension(440, 380));
        JButton closeButton = new JButton(new AbstractAction("Close") {

            @Override
            public void actionPerformed(ActionEvent e) {
                dialog.dispose();
            }
        });
        creationParamsButton.addActionListener(e -> showCreationParamsDialog());
        JPanel bottomPanel = LookAndFeelUtil.createOkCancelPanel(null, closeButton, creationParamsButton);
        dialog.getContentPane().add(legendPanelProvider.get(), BorderLayout.CENTER);
        dialog.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
        LookAndFeelUtil.setDefaultOkCancelKeyStrokes(dialog.getRootPane(), null, closeButton.getAction());
        dialog.getRootPane().setDefaultButton(closeButton);
        dialog.setLocationRelativeTo(swingApplication.getJFrame());
    });
}
Also used : JPanel(javax.swing.JPanel) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) AbstractAction(javax.swing.AbstractAction) JDialog(javax.swing.JDialog) AfterInjection(org.baderlab.csplugins.enrichmentmap.AfterInjection)

Example 28 with JDialog

use of javax.swing.JDialog in project adempiere by adempiere.

the class ConfirmPanel method addActionListener.

//	getRefreshButton
/**************************************************************************
	 *	Add Action Listener
	 *  <code>
	 *  if (e.getActionCommand().equals(ConfirmPanel.A_OK))
	 *  </code>
	 *  @param al listener
	 */
public void addActionListener(ActionListener al) {
    ((AppsAction) bOK.getAction()).setDelegate(al);
    ((AppsAction) bCancel.getAction()).setDelegate(al);
    //
    if (bRefresh != null)
        ((AppsAction) bRefresh.getAction()).setDelegate(al);
    if (bReset != null)
        ((AppsAction) bReset.getAction()).setDelegate(al);
    if (bCustomize != null)
        ((AppsAction) bCustomize.getAction()).setDelegate(al);
    if (bHistory != null)
        ((AppsAction) bHistory.getAction()).setDelegate(al);
    if (bZoom != null)
        ((AppsAction) bZoom.getAction()).setDelegate(al);
    //	Set OK as default Button
    JRootPane rootpane = null;
    if (al instanceof JDialog)
        rootpane = ((JDialog) al).getRootPane();
    else if (al instanceof JFrame)
        rootpane = ((JFrame) al).getRootPane();
    if (rootpane != null)
        rootpane.setDefaultButton(bOK);
}
Also used : JFrame(javax.swing.JFrame) JRootPane(javax.swing.JRootPane) JDialog(javax.swing.JDialog)

Example 29 with JDialog

use of javax.swing.JDialog in project adempiere by adempiere.

the class PrintUtil method dump.

//	dump
/**
	 * 	Dump Stream Print Services
	 * 	@param docFlavor flavor
	 */
public static void dump(DocFlavor docFlavor) {
    System.out.println();
    System.out.println("DocFlavor=" + docFlavor);
    PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
    PrintService[] pss = PrintServiceLookup.lookupPrintServices(docFlavor, pras);
    for (int i = 0; i < pss.length; i++) {
        PrintService ps = pss[i];
        System.out.println("- " + ps);
        System.out.println("  Factory=" + ps.getServiceUIFactory());
        ServiceUIFactory uiF = pss[i].getServiceUIFactory();
        if (uiF != null) {
            System.out.println("about");
            JDialog about = (JDialog) uiF.getUI(ServiceUIFactory.ABOUT_UIROLE, ServiceUIFactory.JDIALOG_UI);
            about.setVisible(true);
            System.out.println("admin");
            JDialog admin = (JDialog) uiF.getUI(ServiceUIFactory.ADMIN_UIROLE, ServiceUIFactory.JDIALOG_UI);
            admin.setVisible(true);
            System.out.println("main");
            JDialog main = (JDialog) uiF.getUI(ServiceUIFactory.MAIN_UIROLE, ServiceUIFactory.JDIALOG_UI);
            main.setVisible(true);
            System.out.println("reserved");
            JDialog res = (JDialog) uiF.getUI(ServiceUIFactory.RESERVED_UIROLE, ServiceUIFactory.JDIALOG_UI);
            res.setVisible(true);
        }
        //
        DocFlavor[] dfs = pss[i].getSupportedDocFlavors();
        System.out.println("  - Supported Doc Flavors");
        for (int j = 0; j < dfs.length; j++) System.out.println("    -> " + dfs[j]);
        //	Attribute
        Class[] attCat = pss[i].getSupportedAttributeCategories();
        System.out.println("  - Supported Attribute Categories");
        for (int j = 0; j < attCat.length; j++) System.out.println("    -> " + attCat[j].getName() + " = " + pss[i].getDefaultAttributeValue((Class<? extends Attribute>) attCat[j]));
    //
    }
}
Also used : Attribute(javax.print.attribute.Attribute) DocFlavor(javax.print.DocFlavor) HashPrintRequestAttributeSet(javax.print.attribute.HashPrintRequestAttributeSet) JDialog(javax.swing.JDialog) HashPrintRequestAttributeSet(javax.print.attribute.HashPrintRequestAttributeSet) PrintRequestAttributeSet(javax.print.attribute.PrintRequestAttributeSet) PrintService(javax.print.PrintService) ServiceUIFactory(javax.print.ServiceUIFactory)

Example 30 with JDialog

use of javax.swing.JDialog in project adempiere by adempiere.

the class ADialog method error.

//	warn (int, String)
/**************************************************************************
	 *	Display error with error icon
	 *	@param	WindowNo	Number of Window
	 *  @param  c           Container (owner)
	 *	@param	AD_Message	Message to be translated
	 *	@param	msg			Additional message
	 */
public static void error(int WindowNo, Container c, String AD_Message, String msg) {
    log.info(AD_Message + " - " + msg);
    if (CLogMgt.isLevelFinest())
        Trace.printStack();
    Properties ctx = Env.getCtx();
    StringBuffer out = new StringBuffer();
    if (AD_Message != null && !AD_Message.equals(""))
        out.append(Msg.getMsg(ctx, AD_Message));
    if (msg != null && msg.length() > 0)
        out.append("\n").append(msg);
    //
    Window parent = Env.getParent(c);
    if (parent == null)
        parent = Env.getWindow(WindowNo);
    //
    if (showDialog && parent != null) {
        if (parent instanceof JFrame)
            new ADialogDialog((JFrame) parent, Env.getHeader(ctx, WindowNo), out.toString(), JOptionPane.ERROR_MESSAGE);
        else if (parent instanceof JDialog)
            new ADialogDialog((JDialog) parent, Env.getHeader(ctx, WindowNo), out.toString(), JOptionPane.ERROR_MESSAGE);
    } else
        JOptionPane.showMessageDialog(Env.getWindow(WindowNo), //	message
        out.toString() + "\n", //	title
        Env.getHeader(ctx, WindowNo), JOptionPane.ERROR_MESSAGE);
}
Also used : Window(java.awt.Window) JFrame(javax.swing.JFrame) Properties(java.util.Properties) JDialog(javax.swing.JDialog)

Aggregations

JDialog (javax.swing.JDialog)141 JButton (javax.swing.JButton)65 JPanel (javax.swing.JPanel)50 ActionEvent (java.awt.event.ActionEvent)42 JLabel (javax.swing.JLabel)35 ActionListener (java.awt.event.ActionListener)30 BorderLayout (java.awt.BorderLayout)24 JScrollPane (javax.swing.JScrollPane)24 JFrame (javax.swing.JFrame)20 Dimension (java.awt.Dimension)18 BoxLayout (javax.swing.BoxLayout)18 JCheckBox (javax.swing.JCheckBox)15 FlowLayout (java.awt.FlowLayout)14 AbstractAction (javax.swing.AbstractAction)14 JOptionPane (javax.swing.JOptionPane)13 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)11 WindowEvent (java.awt.event.WindowEvent)11 IOException (java.io.IOException)10 JProgressBar (javax.swing.JProgressBar)10 WindowAdapter (java.awt.event.WindowAdapter)9