package org.cipres.dcmgui; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Frame; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JSeparator; /** *

Title: DcmGUI

*

Description: GUI for running divide and conquer tree searches * based on Alex Borchers code in CIPRES_TOP/cipres-examples/cipresapp * Wizard style base on http://java.sun.com/developer/technicalArticles/GUI/swing/wizard/ * Copyright 1994-2006 Sun Microsystems, Inc. All Rights Reserved. * (http://developers.sun.com/license/berkeley_license.html) *

* *

Copyright: Copyright (c) 2004

*

Company: Florida State University

* @author Mark Holder * @version 1.0 */ public class DcmGui { private DcmGuiModel dcmGuiModel; private DcmGuiController dcmController; private JDialog dcmGuiDialog; private JPanel cardPanel; private CardLayout cardLayout; private JButton backButton; private JButton nextButton; private JButton cancelButton; public DcmGui(Frame owner) { dcmGuiModel = new DcmGuiModel(); dcmGuiDialog = new JDialog(owner); dcmController = new DcmGuiController(); initComponents(); } private void initComponents() { // Code omitted JPanel buttonPanel = new JPanel(); Box buttonBox = new Box(BoxLayout.X_AXIS); cardPanel = new JPanel(); //cardPanel.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10))); cardLayout = new CardLayout(); cardPanel.setLayout(cardLayout); backButton = new JButton(); nextButton = new JButton(); cancelButton = new JButton(); backButton.addActionListener(dcmController); nextButton.addActionListener(dcmController); cancelButton.addActionListener(dcmController); buttonPanel.setLayout(new BorderLayout()); buttonPanel.add(new JSeparator(), BorderLayout.NORTH); //buttonBox.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10))); buttonBox.add(backButton); buttonBox.add(Box.createHorizontalStrut(10)); buttonBox.add(nextButton); buttonBox.add(Box.createHorizontalStrut(30)); buttonBox.add(cancelButton); buttonPanel.add(buttonBox, java.awt.BorderLayout.EAST); dcmGuiDialog.getContentPane().add(buttonPanel, java.awt.BorderLayout.SOUTH); dcmGuiDialog.getContentPane().add(cardPanel, java.awt.BorderLayout.CENTER); } public JDialog getDialog() { return this.dcmGuiDialog; } public DcmGuiModel getModel() { return this.dcmGuiModel; } public static void main(String[] args) { JFrame frame = new JFrame(); DcmGui dcmGui = new DcmGui(frame); dcmGui.getDialog().setTitle("DCM Wizard"); DcmGuiPanelDescriptor descriptor1 = new DcmGuiPanelDescriptor(); dcmGui.registerWizardPanel(DcmGuiPanelDescriptor.IDENTIFIER, descriptor1); WizardPanelDescriptor descriptor2 = new TestPanel2Descriptor(); wizard.registerWizardPanel(DcmGuiPanelDescriptor.IDENTIFIER, descriptor2); WizardPanelDescriptor descriptor3 = new TestPanel3Descriptor(); wizard.registerWizardPanel(DcmGuiPanelDescriptor.IDENTIFIER, descriptor3); wizard.setCurrentPanel(DcmGuiPanelDescriptor.IDENTIFIER); int ret = wizard.showModalDialog(); System.out.println("Dialog return code is (0=Finish,1=Cancel,2=Error): " + ret); System.out.println("Second panel selection is: " + (((TestPanel2)descriptor2.getPanelComponent()).getRadioButtonSelected())); System.exit(0); */ } } /* public class DcmGui { private static final String APPLICATION_NAME = "cipres.dcm.gui"; private static Logger logger = CipresLogger.initializeLogger(APPLICATION_NAME, DcmGui.class.getName()); boolean packFrame = false; //Construct the application public DcmGui(String[] args) { UiHome frame; // Todo: TL - null args is no longer used this way. See comment // further down in the file. // // Main is passed null when configuration is required. if (args == null) { frame = new UiHome(); } else { frame = new UiHome(args); } //Validate frames that have preset sizes //Pack frames that have useful preferred size info, e.g. from their layout if (packFrame) { frame.pack(); } else { frame.validate(); } //Center the window Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = frame.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } frame.setLocation( (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); frame.setVisible(true); // Todo: TL - this code is no longer used, though we may want to use it // again after rewriting the preference setter to handle the service // configuration. //@mth //if paup and/or python used prompt user to set their paths Config config = Config.getInstance(); if (args == null && (config.isPaupUsed() || config.isPythonUsed() || config.isRaxmlUsed())) { JOptionPane.showMessageDialog(frame, "Select 'Set Preferences' from the 'Tools' menu to configure Cipres.", "Cipres Configuration Required", JOptionPane.PLAIN_MESSAGE); } } //Main method public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); //this method isn't doing anything //LookFeel.setColorScheme(); // Fail fast if we can't initialize the basic components. Config config = Config.getInstance(); if (config == null) { System.exit( -1); } if (org.cipres.communication.Facilitator.initializeAndConfigure(APPLICATION_NAME, args, null) == false) { // user declined to initialize services. System.exit(0); } new DcmGui(args); } catch (Exception e) { logger.fatal("", e); System.exit( -1); } } } */