001: /*
002: * SalomeTMF is a Test Management Framework
003: * Copyright (C) 2005 France Telecom R&D
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: *
019: * @author Fayçal SOUGRATI, Vincent Pautret, Marche Mikael
020: *
021: * Contact: mikael.marche@rd.francetelecom.com
022: */
023:
024: package org.objectweb.salome_tmf.ihm.main;
025:
026: import java.awt.BorderLayout;
027: import java.awt.Container;
028: import java.awt.Dimension;
029: import java.awt.GraphicsConfiguration;
030: import java.awt.GraphicsDevice;
031: import java.awt.GraphicsEnvironment;
032: import java.awt.Rectangle;
033: import java.awt.event.ActionListener;
034: import java.util.HashMap;
035:
036: import javax.swing.JButton;
037: import javax.swing.JDialog;
038: import javax.swing.JPanel;
039:
040: import org.objectweb.salome_tmf.data.DataConstants;
041: import org.objectweb.salome_tmf.data.WithAttachment;
042: import org.objectweb.salome_tmf.ihm.languages.Language;
043:
044: public class AttachmentViewWindow extends JDialog implements
045: DataConstants, ActionListener {
046:
047: AttachmentView attachView;
048:
049: int sourceType;
050:
051: WithAttachment concernedExecutionOrResult;
052:
053: JButton validationButton;
054: JButton cancelButton;
055: public boolean cancelPerformed;
056:
057: HashMap oldAttachMap;
058: int t_x = 1024;
059: int t_y = 768;
060:
061: static AttachmentViewWindow pAttachmentViewWindow = null;
062:
063: //public AttachmentViewWindow(JApplet app, int type, WithAttachment executionOrResult, Execution exec, ExecutionResult execResult, Test observedTest) {
064: public AttachmentViewWindow(BaseIHM app, int type,
065: WithAttachment executionOrResult) {
066:
067: super (SalomeTMFContext.getInstance().ptrFrame, true);
068: try {
069: GraphicsEnvironment ge = GraphicsEnvironment
070: .getLocalGraphicsEnvironment();
071: GraphicsDevice[] gs = ge.getScreenDevices();
072: GraphicsDevice gd = gs[0];
073: GraphicsConfiguration[] gc = gd.getConfigurations();
074: Rectangle r = gc[0].getBounds();
075: t_x = r.width;
076: t_y = r.height;
077: } catch (Exception E) {
078:
079: }
080:
081: pAttachmentViewWindow = this ;
082: cancelPerformed = false;
083: //attachView = new AttachmentView(app, type, type, executionOrResult, SMALL_SIZE_FOR_ATTACH, exec, execResult, observedTest);
084: // attachView = new AttachmentView(app, type, type, executionOrResult, SMALL_SIZE_FOR_ATTACH, this);
085: attachView = new AttachmentView(app, type, type,
086: executionOrResult, NORMAL_SIZE_FOR_ATTACH, this );
087:
088: validationButton = new JButton(Language.getInstance().getText(
089: "Valider"));
090: validationButton.addActionListener(this );
091:
092: cancelButton = new JButton(Language.getInstance().getText(
093: "Annuler"));
094: cancelButton.addActionListener(this );
095:
096: JPanel buttonsPanel = new JPanel();
097: buttonsPanel.add(validationButton);
098: buttonsPanel.add(cancelButton);
099:
100: initData(type, executionOrResult);
101:
102: Container contentPaneFrame = this .getContentPane();
103: contentPaneFrame.add(attachView, BorderLayout.CENTER);
104: contentPaneFrame.add(buttonsPanel, BorderLayout.SOUTH);
105:
106: setSize(600, 500);
107: this .setTitle(Language.getInstance().getText("Attachements"));
108:
109: /*this.pack();
110: this.setLocationRelativeTo(this.getParent());
111: this.setVisible(true);**/
112: centerScreen();
113:
114: } // Fin du constructeur AttachmentViewWindow/3
115:
116: void centerScreen() {
117: Dimension dim = getToolkit().getScreenSize();
118: this .pack();
119: Rectangle abounds = getBounds();
120: setLocation((dim.width - abounds.width) / 2,
121: (dim.height - abounds.height) / 2);
122: this .setVisible(true);
123: requestFocus();
124: }
125:
126: private void initData(int type, WithAttachment executionOrResult) {
127: sourceType = type;
128: concernedExecutionOrResult = executionOrResult;
129: oldAttachMap = executionOrResult
130: .getCopyOfAttachmentMapFromModel();
131: }
132:
133: public void actionPerformed(java.awt.event.ActionEvent e) {
134: Object source = e.getSource();
135: if (source.equals(cancelButton)) {
136: cancelPerformed(e);
137: } else if (source.equals(validationButton)) {
138: validationPerformed(e);
139: }
140: }
141:
142: void validationPerformed(java.awt.event.ActionEvent e) {
143: cancelPerformed = false;
144: //concernedExecutionOrResult.setAttachmentMapInModel(attachView.getAttachmentMap());
145: AttachmentViewWindow.this .dispose();
146: pAttachmentViewWindow = null;
147: }
148:
149: void cancelPerformed(java.awt.event.ActionEvent e) {
150: cancelPerformed = true;
151: concernedExecutionOrResult
152: .setAttachmentMapInModel(oldAttachMap);
153: AttachmentViewWindow.this .dispose();
154: pAttachmentViewWindow = null;
155: }
156:
157: static void cache(boolean cache) {
158: if (pAttachmentViewWindow != null) {
159: pAttachmentViewWindow.setVisible(cache);
160: }
161:
162: }
163:
164: } // Fin de la classe AttachmentViewWindow
|