View Javadoc

1   /***
2    * Created on Feb 17, 2006, Copyright UC Regents
3    */
4   package org.telscenter.pas.authortool.main;
5   
6   import java.awt.BorderLayout;
7   import java.awt.Container;
8   import java.awt.FlowLayout;
9   import java.awt.Font;
10  import java.awt.GridLayout;
11  import java.awt.event.ActionEvent;
12  import java.awt.event.ActionListener;
13  import java.io.IOException;
14  
15  import javax.swing.BorderFactory;
16  import javax.swing.ButtonGroup;
17  import javax.swing.JButton;
18  import javax.swing.JDialog;
19  import javax.swing.JFrame;
20  import javax.swing.JLabel;
21  import javax.swing.JPanel;
22  import javax.swing.JRadioButton;
23  
24  import org.telscenter.pas.authortool.common.colors.PasColors;
25  import org.telscenter.pas.common.ui.CommonUI;
26  import org.telscenter.pas.steps.actions.DialogSaveAction;
27  
28  
29  
30  /***
31   * @author aperritano
32   *
33   */
34  public class AuthoringStarterDialog {
35  
36  
37  	public static void showStarterDialog() {
38  		
39  		final JDialog dialog = new JDialog();
40  		
41  		//create info panel
42  		final JPanel mainPanel = new JPanel();
43  		
44  		final JPanel contentPanel = new JPanel(new BorderLayout(0,0));
45  		
46  		
47  		final JLabel infoLabel = new JLabel("Select the type of Curnit Authoring:");
48  		infoLabel.setFont(infoLabel.getFont().deriveFont(Font.BOLD));
49  		
50  		
51  		
52  		final JPanel radioButtonPanel = new JPanel(new GridLayout(3,1));
53  		
54  		radioButtonPanel.add(infoLabel);
55  		radioButtonPanel.setOpaque(false);
56  		
57  		final JRadioButton newCurnitButton = new JRadioButton("Create a New Curnit");
58  		newCurnitButton.setSelected(true);
59  		newCurnitButton.setOpaque(false);
60  		
61  		final JRadioButton existingCurnitButton = new JRadioButton("Edit an Existing Curnit");
62  		existingCurnitButton.setOpaque(false);	
63  		
64  		final ButtonGroup buttonGroup = new ButtonGroup();
65  		buttonGroup.add(newCurnitButton);
66  		buttonGroup.add(existingCurnitButton);
67  		
68  		radioButtonPanel.add(newCurnitButton);
69  		radioButtonPanel.add(existingCurnitButton);
70  		radioButtonPanel.setBorder(BorderFactory.createEmptyBorder(5	, 5, 5,5));
71  		contentPanel.add(radioButtonPanel,BorderLayout.CENTER);
72  		contentPanel.setBorder(BorderFactory.createLineBorder(PasColors.authoringStarterDialogBorderColor, 2));
73  		contentPanel.setBackground(org.telscenter.pas.authortool.common.util.CommonUI.sailOrange);
74  		
75  		mainPanel.setLayout(new BorderLayout(0,0));
76  		mainPanel.setBackground(org.telscenter.pas.authortool.common.util.CommonUI.sailOrange);
77  		mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
78  		mainPanel.add(contentPanel,BorderLayout.CENTER);
79  		
80  		final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
81  		buttonPanel.setOpaque(false);
82  		
83  		final JButton okButton = new JButton("Ok");
84  		okButton.addActionListener(new ActionListener() {
85  
86  			public void actionPerformed(final ActionEvent e) {
87  				if( newCurnitButton.isSelected() )
88  					//FIXME go to new curnit wizard
89  					dialog.dispose();
90  				else if( existingCurnitButton.isSelected() ) {
91  					final String[] args = new String[0];
92  					try {
93  						AuthoringShellMain.main(args);
94  					} catch (final IOException e1) {
95  						// TODO Auto-generated catch block
96  						e1.printStackTrace();
97  					}
98  					dialog.dispose();
99  				}// if
100 				
101 			}});
102 		CommonUI.makeEnhancedButton(okButton);
103 		
104 		final JButton cancelButton = new JButton(new DialogSaveAction("Cancel"));
105 		CommonUI.makeEnhancedButton(cancelButton);
106 		
107 		buttonPanel.add(okButton);
108 		buttonPanel.add(cancelButton);
109 		
110 		mainPanel.add(buttonPanel,BorderLayout.SOUTH);
111 		
112 		dialog.setTitle("SAIL Authoring Tool");
113 		dialog.setModal(true);
114 		final Container contentPane = dialog.getContentPane();
115 		contentPane.setLayout(new BorderLayout(0,0));
116 		contentPane.add(mainPanel, BorderLayout.CENTER);
117 		
118 //		updateValue.putValue(AbstractAction.NAME, "Save RIM");
119 //		JButton updateValueButton = new JButton(updateValue);
120 //		
121 //		JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
122 //		buttonPanel.setBackground(editor.getDefaultBackgroundColor());
123 //		buttonPanel.add(updateValueButton);
124 		
125 		//contentPane.add(buttonPanel, BorderLayout.SOUTH);
126 		dialog.pack();
127 		dialog.setVisible(true);
128 		
129 		
130 		
131 	}
132 	
133 	
134 	
135 	
136 	
137 	public static void main(final String[] args) {
138 		
139 		final JFrame frame = new JFrame("test");
140 
141 		final Container contentPane = frame.getContentPane();
142 
143 		final JButton showButton = new JButton("show ui");
144 
145 		showButton.addActionListener(new ActionListener() {
146 
147 			public void actionPerformed(final ActionEvent e) {
148 
149 				AuthoringStarterDialog.showStarterDialog();
150 			}
151 
152 		});
153 		contentPane.add(showButton);
154 
155 		frame.setSize(200, 200);
156 		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
157 		frame.setVisible(true);
158 		
159 		
160 	}
161 	
162 }