001: package org.objectweb.salome_tmf.ihm.main;
002:
003: import java.awt.BorderLayout;
004: import java.awt.Color;
005: import java.awt.Cursor;
006: import java.awt.Dimension;
007: import java.awt.FlowLayout;
008: import java.awt.Font;
009: import java.awt.event.ActionEvent;
010: import java.awt.event.ActionListener;
011:
012: import javax.swing.BoxLayout;
013: import javax.swing.JButton;
014: import javax.swing.JLabel;
015: import javax.swing.JMenu;
016: import javax.swing.JMenuBar;
017: import javax.swing.JMenuItem;
018: import javax.swing.JPanel;
019: import javax.swing.JTabbedPane;
020: import javax.swing.event.ChangeEvent;
021: import javax.swing.event.ChangeListener;
022:
023: import org.objectweb.salome_tmf.data.DataConstants;
024: import org.objectweb.salome_tmf.ihm.languages.Language;
025: import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
026: import org.objectweb.salome_tmf.plugins.UICompCst;
027:
028: public class DataPanel extends JPanel {
029: JTabbedPane dataSpace;
030:
031: JLabel projetNameData;
032:
033: //changeListenerPanel dataMultiUserChangeListenerPanel;
034:
035: JMenu dataToolsMenu;
036:
037: EnvironmentView pEnvView;
038: ParameterView dataParameterView;
039: AttachmentView projectAttachmentView;
040:
041: BaseIHM pBaseIHM;
042: SalomeTMFContext pSalomeTMFContext;
043: int t_x = 1024;
044: int t_y = 768;
045: JTabbedPane tabs;
046:
047: public DataPanel(SalomeTMFContext m_SalomeTMFContext,
048: BaseIHM m_BaseIHM, JTabbedPane m_tabs, int x, int y) {
049: super (new BorderLayout());
050: pSalomeTMFContext = m_SalomeTMFContext;
051: pBaseIHM = m_BaseIHM;
052: tabs = m_tabs;
053: t_x = x;
054: t_y = y;
055: }
056:
057: public void initCoponent() {
058:
059: dataToolsMenu = new JMenu(Language.getInstance().getText(
060: "Outils"));
061: pSalomeTMFContext.UIComponentsMap.put(
062: UICompCst.DATA_TOOLS_MENU, dataToolsMenu);
063:
064: projetNameData = new JLabel();
065: projetNameData.setFont(new Font(null, Font.BOLD, 18));
066: JPanel namePanelData = new JPanel(new FlowLayout(
067: FlowLayout.LEFT));
068: namePanelData.add(projetNameData);
069:
070: /*
071: dataMultiUserChangeListenerPanel = new changeListenerPanel();
072: dataMultiUserChangeListenerPanel.setPreferredSize(new Dimension(70,25));
073: JPanel dataMultiUserPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
074: dataMultiUserPanel.add(dataMultiUserChangeListenerPanel);
075: */
076:
077: JPanel dataTopPanel = new JPanel(new BorderLayout());
078: dataTopPanel.add(namePanelData, BorderLayout.WEST);
079: //dataTopPanel.add(dataMultiUserPanel, BorderLayout.EAST);
080:
081: add(dataTopPanel, BorderLayout.NORTH);
082: createDataPlane();
083: }
084:
085: /**
086: * Méthode qui crée la vue sur les données
087: */
088: public void createDataPlane() {
089:
090: //JPanel context = new JPanel();
091:
092: //JMenuItem refreshItem = new JMenuItem("Rafraichir");
093: JMenu refreshItem = new JMenu(Language.getInstance().getText(
094: "Rafraichir"));
095: /*JMenuItem refreshItem = new JMenuItem(Language.getInstance().getText("Rafraichir"));
096: refreshItem.addActionListener(new ActionListener() {
097: public void actionPerformed(ActionEvent e) {
098: tabs.setCursor(new Cursor(Cursor.WAIT_CURSOR));
099: DataModel.reloadFromBase(true);
100: //TestMethods.refreshFromBase();
101: tabs.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
102: }
103: });
104: */
105:
106: JMenuItem refreshItemAll = new JMenuItem(Language.getInstance()
107: .getText("Tout"));
108: refreshItemAll.addActionListener(new ActionListener() {
109: public void actionPerformed(ActionEvent e) {
110: //TestMethods.refreshTestTree();
111: tabs.setCursor(new Cursor(Cursor.WAIT_CURSOR));
112: DataModel.reloadFromBase(true);
113: tabs.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
114: }
115: });
116:
117: JMenuItem refreshItemCamp = new JMenuItem(Language
118: .getInstance().getText("Vue_des_données"));
119: refreshItemCamp.addActionListener(new ActionListener() {
120: public void actionPerformed(ActionEvent e) {
121: //TestMethods.refreshTestTree();
122: tabs.setCursor(new Cursor(Cursor.WAIT_CURSOR));
123: try {
124: DataModel.reloadDataPlan();
125: } catch (Exception ex) {
126: ex.printStackTrace();
127: DataModel.reloadFromBase(true);
128: }
129: tabs.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
130: }
131: });
132:
133: refreshItem.add(refreshItemAll);
134: refreshItem.add(refreshItemCamp);
135:
136: // Mapping entre objets graphiques et constantes
137: pSalomeTMFContext.addToUIComponentsMap(
138: UICompCst.DATA_MANAGEMENT_REFRESH_ITEM, refreshItem);
139: // Add this component as static component
140: UICompCst.staticUIComps
141: .add(UICompCst.DATA_MANAGEMENT_REFRESH_ITEM);
142:
143: dataToolsMenu.add(refreshItem);
144:
145: // Sous menu pour changer le mot de passe
146: //JMenuItem changePwdItem = new JMenuItem("Changer le mot de passe");
147: JMenuItem changePwdItem = new JMenuItem(Language.getInstance()
148: .getText("Changer_le_mot_de_passe"));
149: changePwdItem.addActionListener(new ActionListener() {
150: public void actionPerformed(ActionEvent e) {
151: new ChangePwdWindow(pSalomeTMFContext.ptrFrame).show();
152: }
153: });
154:
155: dataToolsMenu.add(changePwdItem);
156:
157: JMenuBar menuBar = new JMenuBar();
158: menuBar.add(dataToolsMenu);
159:
160: JButton quitTestButton = new JButton(Language.getInstance()
161: .getText("Quitter"));
162: quitTestButton.addActionListener(new ActionListener() {
163: public void actionPerformed(ActionEvent e) {
164: pBaseIHM.quit(true, true);
165: }
166: });
167:
168: JPanel upButtonsPanel = new JPanel();
169: upButtonsPanel.setLayout(new BoxLayout(upButtonsPanel,
170: BoxLayout.Y_AXIS));
171:
172: JPanel pnl = new JPanel();
173: pnl.setBackground(Color.WHITE);
174:
175: // Mapping entre objets graphiques et constantes
176: pSalomeTMFContext
177: .addToUIComponentsMap(
178: UICompCst.DATA_MANAGEMENT_BUTTONS_PANEL,
179: upButtonsPanel);
180: // Add this component as static component
181: UICompCst.staticUIComps
182: .add(UICompCst.DATA_MANAGEMENT_BUTTONS_PANEL);
183:
184: pEnvView = new EnvironmentView();
185: ParameterView pParamview;
186: dataParameterView = new ParameterView(false,
187: DataConstants.PARAMETER);
188: dataParameterView.setName(Language.getInstance().getText(
189: "Vue_des_données"));
190: projectAttachmentView = new AttachmentView(pBaseIHM,
191: DataConstants.PROJECT, DataConstants.PROJECT, null,
192: DataConstants.NORMAL_SIZE_FOR_ATTACH, null);
193:
194: dataSpace = new JTabbedPane();
195: dataSpace.addTab(Language.getInstance().getText(
196: "Environnements"), pEnvView);
197: dataSpace.addTab(Language.getInstance().getText("Paramètres"),
198: dataParameterView);
199: dataSpace.addTab(Language.getInstance().getText(
200: "attachement_project"), projectAttachmentView);
201: dataSpace.addChangeListener(new ChangeListener() {
202: public void stateChanged(ChangeEvent e) {
203: if (dataSpace.getSelectedComponent().equals(
204: projectAttachmentView))
205: try {
206: DataModel.reloadProjectAttachement();
207: } catch (Exception ex) {
208:
209: }
210: DataModel.initAttachmentTable(DataModel
211: .getCurrentProject()
212: .getAttachmentMapFromModel().values());
213: }
214: });
215:
216: //createEnvironment(context);
217: //createParameter(parameters, false);
218:
219: add(dataSpace, BorderLayout.CENTER);
220: menuBar.setMaximumSize(new Dimension(t_x, 10));
221: upButtonsPanel.add(menuBar);
222: upButtonsPanel.add(dataSpace);
223:
224: add(upButtonsPanel, BorderLayout.CENTER);
225:
226: }
227:
228: /*private JPanel createAttachmentView(int type) {
229: //panel.setLayout(new BorderLayout());
230: int realType;
231: if (type == DataConstants.MANUAL_TEST || type == DataConstants.AUTOMATIC_TEST) {
232: realType = DataConstants.TEST;
233: } else {
234: realType = type;
235: }
236: //AttachmentView view = new AttachmentView(this, type , realType, null, NORMAL_SIZE_FOR_ATTACH, null, null, null);
237: projectAttachmentView = new AttachmentView(pBaseIHM, type , realType, null, DataConstants.NORMAL_SIZE_FOR_ATTACH, null);
238:
239: } // Fin de la m?thode createAutomaticTestAttachment/1
240: */
241:
242: /**
243: * Méthode qui crée la vue sur les environnements
244: *@param panel le panel qui contient la vue
245: */
246: /* public void createEnvironment() {
247: pEnvView = new EnvironmentView();
248: //panel.setLayout(new BorderLayout());
249: //panel.add(view, BorderLayout.CENTER);
250: }*/
251:
252: /** Méthode qui crée la vue sur les param?tres des test manuels.
253: * @param panel le panel qui contient la vue.
254: */
255: /* private JPanel createParameterPanel(boolean use) {
256: ParameterView pParamview;
257:
258: pParamview = new ParameterView(use, DataConstants.PARAMETER);
259: pParamview.setName(Language.getInstance().getText("Vue_des_données"));
260: return pParamview;
261: //dataParameterView = pParamview;
262: //panel.setLayout(new BorderLayout());
263: //panel.add(pParamview, BorderLayout.CENTER);
264:
265: }*/
266:
267: /****************************************************************************************************************/
268:
269: void loadModel(String strProject, String strLogin) {
270: //dataMultiUserChangeListenerPanel.reset();
271: dataParameterView.giveAccessToIhmParameterView();
272: projetNameData.setText(Language.getInstance().getText(
273: "Projet_:_")
274: + DataModel.getCurrentProject().getNameFromModel());
275: projectAttachmentView.giveAccessToIhmScriptView();
276: }
277:
278: void reloadModel() {
279: //dataMultiUserChangeListenerPanel.reset();
280: dataParameterView.giveAccessToIhmParameterView();
281: projetNameData.setText(Language.getInstance().getText(
282: "Projet_:_")
283: + DataModel.getCurrentProject().getNameFromModel());
284: projectAttachmentView.giveAccessToIhmScriptView();
285: }
286: }
|