|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 package com.nokia.carbide.cpp.internal.pi.visual; |
|
19 |
|
20 import java.awt.BorderLayout; |
|
21 import java.awt.GridLayout; |
|
22 import java.awt.event.ActionEvent; |
|
23 import java.awt.event.ActionListener; |
|
24 |
|
25 import javax.swing.JButton; |
|
26 import javax.swing.JLabel; |
|
27 import javax.swing.JPanel; |
|
28 import javax.swing.JTextField; |
|
29 |
|
30 public class SynchroniseDialog extends JPanel |
|
31 { |
|
32 private static final long serialVersionUID = -7841684215277143128L; |
|
33 private JPanel buttonPanel = null; |
|
34 private JPanel gppPanel = null; |
|
35 private JLabel gppLabel = null; |
|
36 private JTextField gppField = null; |
|
37 private JButton okButton = null; |
|
38 private JButton cancelButton = null; |
|
39 private PICompositePanel composite = null; |
|
40 |
|
41 /** |
|
42 * This is the default constructor |
|
43 */ |
|
44 public SynchroniseDialog(PICompositePanel aComposite) |
|
45 { |
|
46 super(); |
|
47 try { |
|
48 composite = aComposite; |
|
49 ButtonListener cbl = new ButtonListener(); |
|
50 initialize(); |
|
51 |
|
52 getOkButton().addActionListener(cbl); |
|
53 getCancelButton().addActionListener(cbl); |
|
54 } |
|
55 catch(Exception ex) { |
|
56 ex.printStackTrace(); |
|
57 } |
|
58 } |
|
59 |
|
60 public String getGppFileName() |
|
61 { |
|
62 if (gppField.isEnabled()) |
|
63 return gppField.getText(); |
|
64 else |
|
65 return ""; //$NON-NLS-1$ |
|
66 } |
|
67 |
|
68 /** |
|
69 * This method initializes jButton2 |
|
70 * |
|
71 * @return javax.swing.JButton |
|
72 */ |
|
73 private JButton getOkButton() |
|
74 { |
|
75 if (okButton == null) |
|
76 { |
|
77 okButton = new JButton(); |
|
78 okButton.setText(Messages.getString("SynchroniseDialog.ok")); //$NON-NLS-1$ |
|
79 okButton.setActionCommand("ok"); //$NON-NLS-1$ |
|
80 } |
|
81 return okButton; |
|
82 } |
|
83 |
|
84 /** |
|
85 * This method initializes jButton2 |
|
86 * |
|
87 * @return javax.swing.JButton |
|
88 */ |
|
89 private JButton getCancelButton() |
|
90 { |
|
91 if (cancelButton == null) |
|
92 { |
|
93 cancelButton = new JButton(); |
|
94 cancelButton.setText(Messages.getString("SynchroniseDialog.cancel")); //$NON-NLS-1$ |
|
95 cancelButton.setActionCommand("cancel"); //$NON-NLS-1$ |
|
96 } |
|
97 return cancelButton; |
|
98 } |
|
99 |
|
100 /** |
|
101 * This method initializes this |
|
102 * |
|
103 * @return void |
|
104 */ |
|
105 private void initialize() |
|
106 { |
|
107 java.awt.GridLayout gridLayout = new GridLayout(2, 1); |
|
108 this.setLayout(gridLayout); |
|
109 this.add(getGppPanel(), null); |
|
110 this.add(getButtonPanel(), null); |
|
111 } |
|
112 |
|
113 private JPanel getGppPanel() |
|
114 { |
|
115 if (gppPanel == null) |
|
116 { |
|
117 gppPanel = new JPanel(); |
|
118 gppLabel = new JLabel(); |
|
119 gppField = new JTextField(); |
|
120 |
|
121 gppPanel.setLayout(new BorderLayout()); |
|
122 gppLabel.setText(Messages.getString("SynchroniseDialog.value")); //$NON-NLS-1$ |
|
123 gppPanel.setBorder(javax.swing.BorderFactory |
|
124 .createEtchedBorder(javax.swing.border.EtchedBorder.RAISED)); |
|
125 gppPanel.add(gppLabel, java.awt.BorderLayout.NORTH); |
|
126 gppPanel.add(gppField, java.awt.BorderLayout.CENTER); |
|
127 } |
|
128 return gppPanel; |
|
129 } |
|
130 |
|
131 |
|
132 /** |
|
133 * This method initializes jPanel2 |
|
134 * |
|
135 * @return javax.swing.JPanel |
|
136 */ |
|
137 private JPanel getButtonPanel() |
|
138 { |
|
139 if (buttonPanel == null) |
|
140 { |
|
141 buttonPanel = new JPanel(); |
|
142 buttonPanel.setBorder(javax.swing.BorderFactory |
|
143 .createEtchedBorder(javax.swing.border.EtchedBorder.RAISED)); |
|
144 buttonPanel.add(getOkButton(), java.awt.BorderLayout.CENTER); |
|
145 buttonPanel.add(getCancelButton(), java.awt.BorderLayout.EAST); |
|
146 } |
|
147 return buttonPanel; |
|
148 } |
|
149 |
|
150 class ButtonListener implements ActionListener |
|
151 { |
|
152 public void actionPerformed(ActionEvent ae) |
|
153 { |
|
154 if (ae.getActionCommand().equals("ok")) //$NON-NLS-1$ |
|
155 { |
|
156 composite.synchroniseOk(); |
|
157 } |
|
158 else if (ae.getActionCommand().equals("cancel")) //$NON-NLS-1$ |
|
159 { |
|
160 composite.synchroniseCancel(); |
|
161 } |
|
162 } |
|
163 } |
|
164 } |