0001: //
0002: // This file is part of the prose package.
0003: //
0004: // The contents of this file are subject to the Mozilla Public License
0005: // Version 1.1 (the "License"); you may not use this file except in
0006: // compliance with the License. You may obtain a copy of the License at
0007: // http://www.mozilla.org/MPL/
0008: //
0009: // Software distributed under the License is distributed on an "AS IS" basis,
0010: // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
0011: // for the specific language governing rights and limitations under the
0012: // License.
0013: //
0014: // The Original Code is prose.
0015: //
0016: // The Initial Developer of the Original Code is Andrei Popovici. Portions
0017: // created by Andrei Popovici are Copyright (C) 2002 Andrei Popovici.
0018: // All Rights Reserved.
0019: //
0020: // Contributor(s):
0021: /*
0022: * JFrame.java
0023: *
0024: * Created on December 9, 2002, 2:17 PM
0025: */
0026:
0027: package ch.ethz.prose.tools;
0028:
0029: import java.rmi.*;
0030: import java.net.*;
0031:
0032: import java.awt.Font;
0033: import java.awt.BorderLayout;
0034: import java.awt.GridLayout;
0035: import java.awt.Insets;
0036: import java.awt.event.WindowAdapter;
0037: import java.awt.event.ActionEvent;
0038: import java.awt.event.ActionListener;
0039: import java.awt.Dimension;
0040: import java.awt.event.WindowEvent;
0041: import java.util.Iterator;
0042: import java.util.Vector;
0043: import java.awt.FlowLayout;
0044:
0045: import java.io.ObjectOutputStream;
0046: import java.io.FileOutputStream;
0047: import java.io.FileInputStream;
0048: import java.io.ObjectInputStream;
0049:
0050: import javax.swing.border.TitledBorder;
0051: import javax.swing.JFileChooser;
0052: import javax.swing.JFrame;
0053: import javax.swing.JPanel;
0054: import javax.swing.JLabel;
0055: import java.awt.Color;
0056: import javax.swing.BoxLayout;
0057: import javax.swing.JOptionPane;
0058: import javax.swing.JTabbedPane;
0059: import javax.swing.Box;
0060: import javax.swing.JSplitPane;
0061:
0062: import java.util.*;
0063:
0064: /**
0065: *
0066: * @author pschoch
0067: */
0068: public class JMultipleProseClient extends javax.swing.JFrame {
0069:
0070: private static final long serialVersionUID = 3618700803251122489L;
0071: private MultipleClientModel myModel;
0072: private JFileChooser commonFileChooser;
0073:
0074: /** Creates new form JFrame */
0075: public JMultipleProseClient() {
0076:
0077: myModel = new MultipleClientModel(this );
0078: initComponents();
0079: try {
0080: customizeComponents();
0081: } catch (java.rmi.NotBoundException noProseThere) {
0082: throw new Error(
0083: "It is not possible for a remote exception to occur upon startup. Please report this bug to PROSE");
0084: } catch (java.net.MalformedURLException wrongUrl) {
0085: throw new Error(
0086: "It is not possible for a remote exception to occur upon startup. Please report this bug to PROSE");
0087: } catch (java.rmi.RemoteException cannotContact) {
0088: throw new Error(
0089: "It is not possible for a remote exception to occur upon startup. Please report this bug to PROSE");
0090: }
0091:
0092: }
0093:
0094: private void refreshConnectedVMs() {
0095: Iterator i = myModel.getAllVM().iterator();
0096: while (i.hasNext()) {
0097: WorksheetSingleClientModel m = (WorksheetSingleClientModel) i
0098: .next();
0099: try {
0100: m.refresh();
0101: jTabbedPane1.setEnabledAt(jTabbedPane1.indexOfTab(m
0102: .getName()), true);
0103: } catch (Exception e) {
0104: jTabbedPane1.setEnabledAt(jTabbedPane1.indexOfTab(m
0105: .getName()), false);
0106: }
0107: }
0108: }
0109:
0110: /** This method is called from within the constructor to
0111: * initialize the form.
0112: * WARNING: Do NOT modify this code. The content of this method is
0113: * always regenerated by the Form Editor.
0114: */
0115: private void initComponents() {//GEN-BEGIN:initComponents
0116:
0117: mainSplitPane = new javax.swing.JSplitPane();
0118:
0119: jPanelSelectionInto = new JPanel();
0120: groupByGroup = new javax.swing.ButtonGroup();
0121: selectionVsAllGroup = new javax.swing.ButtonGroup();
0122: jPanel1 = new javax.swing.JPanel();
0123: jToolBar1 = new javax.swing.JToolBar();
0124: jToolBar2 = new javax.swing.JToolBar();
0125: jToolBar3 = new javax.swing.JToolBar();
0126: cutButton = new javax.swing.JButton();
0127: copyButton = new javax.swing.JButton();
0128: pasteButton = new javax.swing.JButton();
0129: jTabbedPane1 = new javax.swing.JTabbedPane();
0130: boxes = new javax.swing.JPanel();
0131: checkBoxPanel = new javax.swing.JPanel();
0132: selectAspectButton = new javax.swing.JCheckBox();
0133: selectCrosscutButton = new javax.swing.JCheckBox();
0134: selectJoinpointButton = new javax.swing.JCheckBox();
0135: radioBoxPanel = new javax.swing.JPanel();
0136: groupByAspectButton = new javax.swing.JRadioButton();
0137: groupByCrosscutButton = new javax.swing.JRadioButton();
0138: groupByJoinpointButton = new javax.swing.JRadioButton();
0139: textAreaScroller = new javax.swing.JScrollPane();
0140: textArea = new javax.swing.JTextArea();
0141: buttons = new javax.swing.JPanel();
0142: queryButton = new javax.swing.JButton();
0143: allAspectsButton = new javax.swing.JButton();
0144: allJoinpointsButton = new javax.swing.JButton();
0145: jPanel4Classpath = new javax.swing.JPanel();
0146:
0147: jPanel4Classpath = new javax.swing.JPanel();
0148: jp4CpathLabel = new javax.swing.JLabel();
0149: jp4CpathField = new javax.swing.JTextField();
0150: jp4EditCpathButton = new javax.swing.JButton();
0151: jp4AddCpathDir = new javax.swing.JFileChooser();
0152:
0153: jp5ConsolePane = new javax.swing.JPanel();
0154: jp5ConsoleArea = new javax.swing.JTextPane();
0155: jp5ConsoleScroll = new javax.swing.JScrollPane();
0156:
0157: jp6transactionPane = new javax.swing.JPanel();
0158: jp6StartTx = new javax.swing.JButton();
0159: jp6CommitTx = new javax.swing.JButton();
0160: jp6AbortTx = new javax.swing.JButton();
0161:
0162: jp7refreshVMButton = new javax.swing.JButton();
0163:
0164: jp8QueryToolbar = new javax.swing.JButton();
0165:
0166: jPanel3Insertion = new javax.swing.JPanel();
0167: jPanel2 = new javax.swing.JPanel();
0168: jLabel1 = new javax.swing.JLabel();
0169: classTextField = new javax.swing.JTextField();
0170: chooseClass = new javax.swing.JButton();
0171: jLabel2 = new javax.swing.JLabel();
0172: useSelectionRadio = new javax.swing.JRadioButton();
0173: useAllRadio = new javax.swing.JRadioButton();
0174: jLabel3 = new javax.swing.JLabel();
0175: insertAspect = new javax.swing.JButton();
0176: jMenuBar1 = new javax.swing.JMenuBar();
0177: menuFile = new javax.swing.JMenu();
0178:
0179: loadItem = new javax.swing.JMenuItem();
0180: saveItem = new javax.swing.JMenuItem();
0181:
0182: quitItem = new javax.swing.JMenuItem();
0183: menuEdit = new javax.swing.JMenu();
0184: copyItem = new javax.swing.JMenuItem();
0185: pasteItem = new javax.swing.JMenuItem();
0186: cutItem = new javax.swing.JMenuItem();
0187: menuVM = new javax.swing.JMenu();
0188: addVMItem = new javax.swing.JMenuItem();
0189: removeVMItem = new javax.swing.JMenuItem();
0190:
0191: getContentPane().setLayout(new BorderLayout());
0192: //getContentPane().setLayout(new BoxLayout(getContentPane(),BoxLayout.Y_AXIS));
0193: getContentPane().add(mainSplitPane, BorderLayout.CENTER);
0194:
0195: // mainSplitPane.setDividerLocation(0.2);
0196: mainSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
0197: mainSplitPane.setDividerSize(5);
0198: mainSplitPane.setPreferredSize(new Dimension(1200, 500));
0199: mainSplitPane.setMinimumSize(new Dimension(1200, 500));
0200:
0201: setTitle("Prose Workbench");
0202: jPanel1.setLayout(new BoxLayout(jPanel1, BoxLayout.Y_AXIS));
0203: jPanel1.setMinimumSize(new java.awt.Dimension(400, 250));
0204: jPanel1.setPreferredSize(new java.awt.Dimension(1200, 250));
0205: jPanel1.setMaximumSize(new java.awt.Dimension(2000, 300));
0206: cutButton.setIcon(new javax.swing.ImageIcon(
0207: getClass().getResource(
0208: "/toolbarButtonGraphics/general/Cut24.gif")));
0209: cutButton.setToolTipText("Cut Aspect");
0210: cutButton.setFont(new java.awt.Font("Dialog", 0, 11));
0211: cutButton
0212: .addActionListener(new java.awt.event.ActionListener() {
0213: public void actionPerformed(
0214: java.awt.event.ActionEvent evt) {
0215: cutButtonActionPerformed(evt);
0216: }
0217: });
0218:
0219: jToolBar1.add(cutButton);
0220:
0221: copyButton.setIcon(new javax.swing.ImageIcon(getClass()
0222: .getResource(
0223: "/toolbarButtonGraphics/general/Copy24.gif")));
0224: copyButton.setToolTipText("Copy");
0225: copyButton
0226: .addActionListener(new java.awt.event.ActionListener() {
0227: public void actionPerformed(
0228: java.awt.event.ActionEvent evt) {
0229: copyButtonActionPerformed(evt);
0230: }
0231: });
0232:
0233: jToolBar1.add(copyButton);
0234:
0235: pasteButton.setIcon(new javax.swing.ImageIcon(getClass()
0236: .getResource(
0237: "/toolbarButtonGraphics/general/Paste24.gif")));
0238: pasteButton.setToolTipText("Paste");
0239: pasteButton
0240: .addActionListener(new java.awt.event.ActionListener() {
0241: public void actionPerformed(
0242: java.awt.event.ActionEvent evt) {
0243: pasteButtonActionPerformed(evt);
0244: }
0245: });
0246:
0247: jToolBar1.add(pasteButton);
0248:
0249: jTabbedPane1
0250: .setPreferredSize(new java.awt.Dimension(1200, 800));
0251: jTabbedPane1.setMinimumSize(new java.awt.Dimension(400, 200));
0252: jTabbedPane1.setAlignmentX(0.0F);
0253: jTabbedPane1.setMaximumSize(new Dimension(2000, 2000));
0254: jTabbedPane1
0255: .addChangeListener(new javax.swing.event.ChangeListener() {
0256: public void stateChanged(
0257: javax.swing.event.ChangeEvent evt) {
0258: jTabbedPane1StateChanged(evt);
0259: }
0260: });
0261:
0262: mainSplitPane.setLeftComponent(jTabbedPane1);
0263:
0264: //gridBagConstraints);
0265:
0266: boxes.setLayout(new FlowLayout(FlowLayout.LEFT));
0267:
0268: boxes.setBorder(new javax.swing.border.EmptyBorder(
0269: new java.awt.Insets(8, 8, 8, 8)));
0270: boxes.setPreferredSize(new java.awt.Dimension(300, 100));
0271: boxes.setMinimumSize(new java.awt.Dimension(572, 100));
0272: boxes.setMaximumSize(new java.awt.Dimension(2000, 100));
0273: checkBoxPanel.setLayout(new java.awt.GridLayout(3, 0, 0, 5));
0274:
0275: checkBoxPanel.setBorder(new javax.swing.border.CompoundBorder(
0276: new javax.swing.border.EtchedBorder(null,
0277: java.awt.Color.gray),
0278: new javax.swing.border.EmptyBorder(new java.awt.Insets(
0279: 3, 9, 3, 3))));
0280: checkBoxPanel.setMaximumSize(new java.awt.Dimension(160, 82));
0281: checkBoxPanel.setPreferredSize(new java.awt.Dimension(160, 82));
0282: checkBoxPanel.setMinimumSize(new java.awt.Dimension(160, 82));
0283: selectAspectButton
0284: .setToolTipText("Select to view 'Aspects' in the result");
0285: selectAspectButton.setModel(myModel.getSelectAspect());
0286: selectAspectButton
0287: .setFont(new java.awt.Font("Luxi Sans", 1, 12));
0288: selectAspectButton.setText("Select Aspects");
0289: selectAspectButton
0290: .setBorder(new javax.swing.border.EmptyBorder(
0291: new java.awt.Insets(2, 2, 2, 2)));
0292: selectAspectButton
0293: .addActionListener(new java.awt.event.ActionListener() {
0294: public void actionPerformed(
0295: java.awt.event.ActionEvent evt) {
0296: selectAspectButtonActionPerformed(evt);
0297: }
0298: });
0299:
0300: checkBoxPanel.add(selectAspectButton);
0301:
0302: selectCrosscutButton
0303: .setToolTipText("Select to view 'Crosscuts' in the result");
0304: selectCrosscutButton.setModel(myModel.getSelectCrosscut());
0305: selectCrosscutButton.setFont(new java.awt.Font("Luxi Sans", 1,
0306: 12));
0307: selectCrosscutButton.setText("Select Crosscuts");
0308: selectCrosscutButton.setPreferredSize(new java.awt.Dimension(
0309: 130, 20));
0310: selectCrosscutButton
0311: .setBorder(new javax.swing.border.EmptyBorder(
0312: new java.awt.Insets(2, 2, 2, 2)));
0313: selectCrosscutButton.setMaximumSize(new java.awt.Dimension(130,
0314: 20));
0315: selectCrosscutButton.setMinimumSize(new java.awt.Dimension(130,
0316: 20));
0317: selectCrosscutButton
0318: .addActionListener(new java.awt.event.ActionListener() {
0319: public void actionPerformed(
0320: java.awt.event.ActionEvent evt) {
0321: selectCrosscutButtonActionPerformed(evt);
0322: }
0323: });
0324:
0325: checkBoxPanel.add(selectCrosscutButton);
0326:
0327: selectJoinpointButton
0328: .setToolTipText("Select to view 'Joinpoints' in the result");
0329: selectJoinpointButton.setModel(myModel.getSelectJoinpoint());
0330: selectJoinpointButton.setFont(new java.awt.Font("Luxi Sans", 1,
0331: 12));
0332: selectJoinpointButton.setText("Select Joinpoints");
0333: selectJoinpointButton.setPreferredSize(new java.awt.Dimension(
0334: 130, 20));
0335: selectJoinpointButton
0336: .setBorder(new javax.swing.border.EmptyBorder(
0337: new java.awt.Insets(2, 2, 2, 2)));
0338: selectJoinpointButton.setMaximumSize(new java.awt.Dimension(
0339: 130, 20));
0340: selectJoinpointButton.setMinimumSize(new java.awt.Dimension(
0341: 130, 20));
0342: selectJoinpointButton
0343: .addActionListener(new java.awt.event.ActionListener() {
0344: public void actionPerformed(
0345: java.awt.event.ActionEvent evt) {
0346: selectJoinpointButtonActionPerformed(evt);
0347: }
0348: });
0349:
0350: checkBoxPanel.add(selectJoinpointButton);
0351:
0352: boxes.add(checkBoxPanel);
0353:
0354: radioBoxPanel.setLayout(new java.awt.GridLayout(3, 0, 0, 5));
0355:
0356: radioBoxPanel.setBorder(new javax.swing.border.CompoundBorder(
0357: new javax.swing.border.EtchedBorder(null,
0358: java.awt.Color.gray),
0359: new javax.swing.border.EmptyBorder(new java.awt.Insets(
0360: 3, 9, 3, 3))));
0361: radioBoxPanel.setPreferredSize(new java.awt.Dimension(160, 82));
0362: radioBoxPanel.setMinimumSize(new java.awt.Dimension(160, 82));
0363: radioBoxPanel.setMaximumSize(new java.awt.Dimension(160, 82));
0364: groupByAspectButton.setModel(myModel.getGroupByAspect());
0365: groupByAspectButton
0366: .setFont(new java.awt.Font("LuxiSans", 1, 12));
0367: groupByAspectButton.setText("Group by Aspect");
0368: groupByGroup.add(groupByAspectButton);
0369: groupByAspectButton.setPreferredSize(new java.awt.Dimension(
0370: 130, 20));
0371: groupByAspectButton
0372: .setBorder(new javax.swing.border.EmptyBorder(
0373: new java.awt.Insets(20, 2, 20, 2)));
0374: groupByAspectButton.setMaximumSize(new java.awt.Dimension(130,
0375: 20));
0376: groupByAspectButton.setMargin(new java.awt.Insets(20, 2, 2, 2));
0377: groupByAspectButton.setMinimumSize(new java.awt.Dimension(130,
0378: 20));
0379: groupByAspectButton.setBorderPainted(true);
0380: groupByAspectButton
0381: .addActionListener(new java.awt.event.ActionListener() {
0382: public void actionPerformed(
0383: java.awt.event.ActionEvent evt) {
0384: groupByAspectButtonActionPerformed(evt);
0385: }
0386: });
0387:
0388: radioBoxPanel.add(groupByAspectButton);
0389:
0390: groupByCrosscutButton.setFont(new java.awt.Font("Luxi Sans", 1,
0391: 12));
0392: groupByCrosscutButton.setText("Group by Crosscut");
0393: groupByCrosscutButton.setModel(myModel.getGroupByCrosscut());
0394: groupByGroup.add(groupByCrosscutButton);
0395: groupByCrosscutButton.setPreferredSize(new java.awt.Dimension(
0396: 130, 20));
0397: groupByCrosscutButton
0398: .setBorder(new javax.swing.border.EmptyBorder(
0399: new java.awt.Insets(2, 2, 2, 2)));
0400: groupByCrosscutButton.setMaximumSize(new java.awt.Dimension(
0401: 130, 20));
0402: groupByCrosscutButton
0403: .setMargin(new java.awt.Insets(20, 2, 2, 2));
0404: groupByCrosscutButton.setMinimumSize(new java.awt.Dimension(
0405: 130, 20));
0406: groupByCrosscutButton
0407: .addActionListener(new java.awt.event.ActionListener() {
0408: public void actionPerformed(
0409: java.awt.event.ActionEvent evt) {
0410: groupByCrosscutButtonActionPerformed(evt);
0411: }
0412: });
0413:
0414: radioBoxPanel.add(groupByCrosscutButton);
0415:
0416: groupByJoinpointButton.setFont(new java.awt.Font("Luxi Sans",
0417: 1, 12));
0418:
0419: groupByJoinpointButton.setText("Group by Joinpoint");
0420:
0421: groupByJoinpointButton.setModel(myModel.getGroupByJoinpoint());
0422:
0423: groupByGroup.add(groupByJoinpointButton);
0424:
0425: groupByJoinpointButton.setPreferredSize(new java.awt.Dimension(
0426: 130, 20));
0427:
0428: groupByJoinpointButton
0429: .setBorder(new javax.swing.border.EmptyBorder(
0430: new java.awt.Insets(2, 2, 2, 2)));
0431:
0432: groupByJoinpointButton.setMaximumSize(new java.awt.Dimension(
0433: 130, 20));
0434:
0435: groupByJoinpointButton.setMargin(new java.awt.Insets(20, 2, 2,
0436: 2));
0437:
0438: groupByJoinpointButton.setMinimumSize(new java.awt.Dimension(
0439: 130, 20));
0440:
0441: groupByJoinpointButton
0442: .addActionListener(new java.awt.event.ActionListener() {
0443: public void actionPerformed(
0444: java.awt.event.ActionEvent evt) {
0445: groupByJoinpointButtonActionPerformed(evt);
0446: }
0447: });
0448:
0449: radioBoxPanel.add(groupByJoinpointButton);
0450:
0451: boxes.add(radioBoxPanel);
0452:
0453: buttons.setLayout(new GridLayout(3, 2, 5, 5));
0454: // buttons.setPreferredSize(new java.awt.Dimension(100, 80));
0455: // buttons.setMinimumSize(new java.awt.Dimension(100, 80));
0456:
0457: queryButton
0458: .setToolTipText("Send the selected Items to the AspectManager and get the Result");
0459: queryButton.setFont(new java.awt.Font("Luxi Sans", 1, 14));
0460: queryButton.setText("query");
0461: queryButton.setPreferredSize(new java.awt.Dimension(30, 23));
0462: queryButton.setBorder(new javax.swing.border.BevelBorder(
0463: javax.swing.border.BevelBorder.RAISED,
0464: java.awt.Color.lightGray, java.awt.Color.white,
0465: java.awt.Color.darkGray, java.awt.Color.gray));
0466: queryButton.setMaximumSize(new java.awt.Dimension(160, 128));
0467: queryButton
0468: .setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
0469: queryButton.setMinimumSize(new java.awt.Dimension(30, 23));
0470: queryButton
0471: .addActionListener(new java.awt.event.ActionListener() {
0472: public void actionPerformed(
0473: java.awt.event.ActionEvent evt) {
0474: queryButtonActionPerformed(evt);
0475: }
0476: });
0477: buttons.add(new JLabel("query: sected cells"));
0478: buttons.add(queryButton);
0479:
0480: jp8QueryToolbar.setText("Q");
0481: jp8QueryToolbar.setFont(new java.awt.Font("Luxi Sans",
0482: Font.BOLD, 18));
0483: jp8QueryToolbar.setForeground(new Color(0x765f91));
0484: jp8QueryToolbar
0485: .addActionListener(new java.awt.event.ActionListener() {
0486: public void actionPerformed(
0487: java.awt.event.ActionEvent evt) {
0488: queryButtonActionPerformed(evt);
0489: }
0490: });
0491:
0492: Dimension buttonDimension = new Dimension(50, 23);
0493: Dimension labelDimension = new Dimension(100, 23);
0494:
0495: allAspectsButton
0496: .setToolTipText("Retrieve all Aspects inserted in this AspectManager");
0497: allAspectsButton.setFont(new java.awt.Font("Luxi Sans", 1, 12));
0498: allAspectsButton.setText("query");
0499: allAspectsButton
0500: .setPreferredSize(new java.awt.Dimension(30, 23));
0501: allAspectsButton.setBorder(new javax.swing.border.BevelBorder(
0502: javax.swing.border.BevelBorder.RAISED,
0503: java.awt.Color.lightGray, java.awt.Color.white,
0504: java.awt.Color.darkGray, java.awt.Color.gray));
0505: allAspectsButton
0506: .setMaximumSize(new java.awt.Dimension(128, 32));
0507: allAspectsButton.setMinimumSize(new java.awt.Dimension(30, 23));
0508: allAspectsButton
0509: .addActionListener(new java.awt.event.ActionListener() {
0510: public void actionPerformed(
0511: java.awt.event.ActionEvent evt) {
0512: allAspectsButtonActionPerformed(evt);
0513: }
0514: });
0515: buttons.add(new JLabel("query: all aspects"));
0516: buttons.add(allAspectsButton);
0517:
0518: allJoinpointsButton
0519: .setToolTipText("Retrieve all Joinpoints inserted in this AspectManager");
0520: allJoinpointsButton.setFont(new java.awt.Font("Luxi Sans", 1,
0521: 12));
0522: allJoinpointsButton.setText("query");
0523: allJoinpointsButton.setPreferredSize(new java.awt.Dimension(50,
0524: 23));
0525: allJoinpointsButton
0526: .setBorder(new javax.swing.border.BevelBorder(
0527: javax.swing.border.BevelBorder.RAISED,
0528: java.awt.Color.lightGray, java.awt.Color.white,
0529: java.awt.Color.darkGray, java.awt.Color.gray));
0530: allJoinpointsButton.setMaximumSize(new java.awt.Dimension(128,
0531: 32));
0532: allJoinpointsButton.setMinimumSize(new java.awt.Dimension(30,
0533: 23));
0534: allJoinpointsButton
0535: .addActionListener(new java.awt.event.ActionListener() {
0536: public void actionPerformed(
0537: java.awt.event.ActionEvent evt) {
0538: allJoinpointsButtonActionPerformed(evt);
0539: }
0540: });
0541:
0542: buttons.add(new JLabel("query: all joinpoints"));
0543: buttons.add(allJoinpointsButton);
0544:
0545: boxes.add(buttons);
0546: boxes.add(Box.createHorizontalGlue());
0547:
0548: jPanel1.add(textAreaScroller);
0549:
0550: jPanel1.add(boxes);
0551:
0552: textAreaScroller
0553: .setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
0554: textAreaScroller.setPreferredSize(new java.awt.Dimension(500,
0555: 39));
0556: textAreaScroller.setMinimumSize(new java.awt.Dimension(50, 39));
0557: textAreaScroller.setMaximumSize(new java.awt.Dimension(2000,
0558: 100));
0559: textArea.setWrapStyleWord(true);
0560: textArea.setLineWrap(true);
0561: textArea.setEditable(false);
0562: textArea.setRows(5);
0563: textArea.setFont(new java.awt.Font("Courier", 0, 11));
0564: textArea.setPreferredSize(new java.awt.Dimension(0, 70));
0565: textArea.setMargin(new java.awt.Insets(3, 3, 3, 3));
0566: textArea.setMinimumSize(new java.awt.Dimension(50, 40));
0567: textAreaScroller.setViewportView(textArea);
0568:
0569: jPanel3Insertion.setLayout(new FlowLayout(FlowLayout.LEFT));
0570: // jPanel3Insertion.setLayout(new BoxLayout(jPanel3Insertion,javax.swing.BoxLayout.X_AXIS));
0571:
0572: JPanel classPathAndAspect = new JPanel();
0573: classPathAndAspect.setMaximumSize(new Dimension(1000, 100));
0574: classPathAndAspect.setLayout(new BoxLayout(classPathAndAspect,
0575: BoxLayout.Y_AXIS));
0576: classPathAndAspect.add(Box.createVerticalGlue());
0577: classPathAndAspect.add(jPanel2);
0578: classPathAndAspect.add(Box.createVerticalGlue());
0579: classPathAndAspect.add(jPanel4Classpath);
0580: classPathAndAspect.add(Box.createVerticalGlue());
0581:
0582: jPanel3Insertion.add(Box.createHorizontalStrut(10));
0583: jPanel3Insertion.add(classPathAndAspect);
0584: // jPanel3Insertion.add(Box.createHorizontalStrut(10));
0585: // jPanel3Insertion.add(jPanelSelectionInto);
0586: jPanel3Insertion.add(Box.createHorizontalGlue());
0587:
0588: // jPanel3Insertion.add(Box.createHorizontalGlue());
0589: jPanel3Insertion.setBorder(new javax.swing.border.EmptyBorder(
0590: new java.awt.Insets(8, 8, 8, 8)));
0591:
0592: jPanel3Insertion.setPreferredSize(new java.awt.Dimension(541,
0593: 100));
0594: jPanel3Insertion
0595: .setMinimumSize(new java.awt.Dimension(541, 100));
0596: jPanel3Insertion.setMaximumSize(new java.awt.Dimension(2000,
0597: 100));
0598:
0599: jp5ConsoleArea.setDocument(myModel.getConsole());
0600: jp5ConsoleArea
0601: .setPreferredSize(new java.awt.Dimension(500, 100));
0602: jp5ConsoleArea.setMinimumSize(new java.awt.Dimension(300, 100));
0603: jp5ConsoleArea.setBackground(new Color(0xf9efe8));
0604:
0605: // jp5ConsoleArea.setLineWrap(true);
0606: // jp5ConsoleArea.setColumns(80);
0607: // jp5ConsoleArea.setRows(20);
0608: jp5ConsoleScroll.add(jp5ConsoleArea);
0609: jp5ConsoleArea.revalidate();
0610: jp5ConsoleScroll.setViewportView(jp5ConsoleArea);
0611: jp5ConsolePane.add(jp5ConsoleScroll);
0612:
0613: jp5ConsolePane.setBorder(new javax.swing.border.TitledBorder(
0614: "Console"));
0615: jp5ConsolePane.setLayout(new javax.swing.BoxLayout(
0616: jp5ConsolePane, javax.swing.BoxLayout.Y_AXIS));
0617: jp5ConsolePane
0618: .setMaximumSize(new java.awt.Dimension(1200, 210));
0619: jp5ConsolePane
0620: .setPreferredSize(new java.awt.Dimension(510, 210));
0621:
0622: jp5ConsoleArea.setEditable(false);
0623:
0624: jPanel2.setLayout(new BoxLayout(jPanel2, BoxLayout.X_AXIS));
0625: jLabel1.setText("Aspect class ");
0626: jLabel1.setPreferredSize(new Dimension(100, 23));
0627: jLabel1.setMaximumSize(new Dimension(100, 23));
0628: jLabel1.setMinimumSize(new Dimension(100, 23));
0629: jPanel2.add(jLabel1);
0630:
0631: classTextField.setDocument(myModel.getAspectClassNameModel());
0632: classTextField.setMaximumSize(new java.awt.Dimension(330, 23));
0633: classTextField
0634: .setPreferredSize(new java.awt.Dimension(330, 23));
0635: classTextField.setMinimumSize(new java.awt.Dimension(330, 23));
0636: classTextField
0637: .addActionListener(new java.awt.event.ActionListener() {
0638: public void actionPerformed(
0639: java.awt.event.ActionEvent evt) {
0640: classTextFieldActionPerformed(evt);
0641: }
0642: });
0643:
0644: jPanel2.add(classTextField);
0645: jPanel2.add(insertAspect);
0646: chooseClass.setText("...");
0647: chooseClass.setMaximumSize(new Dimension(75, 23));
0648: chooseClass.setPreferredSize(new Dimension(75, 23));
0649: chooseClass
0650: .addActionListener(new java.awt.event.ActionListener() {
0651: public void actionPerformed(
0652: java.awt.event.ActionEvent evt) {
0653: chooseClassActionPerformed(evt);
0654: }
0655: });
0656:
0657: jPanelSelectionInto.setLayout(new BoxLayout(
0658: jPanelSelectionInto, BoxLayout.Y_AXIS));
0659: jPanelSelectionInto.setBorder(new TitledBorder(
0660: "aspect insertion target"));
0661: jPanelSelectionInto.add(useSelectionRadio);
0662: jPanelSelectionInto.add(useAllRadio);
0663:
0664: //jLabel2.setText(" target VM ");
0665: // jPanel2.add(jLabel2);
0666:
0667: useSelectionRadio.setText("selected VM");
0668: useSelectionRadio.setModel(myModel.getInsertInSelection());
0669: selectionVsAllGroup.add(useSelectionRadio);
0670: useSelectionRadio.setActionCommand("sel");
0671: useSelectionRadio
0672: .addActionListener(new java.awt.event.ActionListener() {
0673: public void actionPerformed(
0674: java.awt.event.ActionEvent evt) {
0675: useSelectionRadioActionPerformed(evt);
0676: }
0677: });
0678:
0679: // jPanel2.add(useSelectionRadio);
0680:
0681: useAllRadio.setText("all VMs");
0682: useAllRadio.setModel(myModel.getInsertInAllVM());
0683: selectionVsAllGroup.add(useAllRadio);
0684: useAllRadio.setActionCommand("all");
0685: // jPanel2.add(useAllRadio);
0686:
0687: jPanel4Classpath.setLayout(new javax.swing.BoxLayout(
0688: jPanel4Classpath, javax.swing.BoxLayout.X_AXIS));
0689: jPanel4Classpath.add(jp4CpathLabel);
0690: jPanel4Classpath.add(jp4CpathField);
0691: jPanel4Classpath.add(chooseClass);
0692: jPanel4Classpath.add(javax.swing.Box.createHorizontalGlue());
0693: jp4CpathField.setDocument(getModel().getClasspathModel());
0694:
0695: jp4CpathField.setMinimumSize(new java.awt.Dimension(330, 23));
0696: jp4CpathField.setPreferredSize(new java.awt.Dimension(330, 23));
0697: jp4CpathField.setMaximumSize(new java.awt.Dimension(330, 23));
0698: jp4CpathLabel.setText("Classpath ");
0699: jp4CpathLabel.setMaximumSize(new Dimension(100, 23));
0700: jp4CpathLabel.setPreferredSize(new Dimension(100, 23));
0701: jp4CpathLabel.setMinimumSize(new Dimension(100, 23));
0702:
0703: // jp7refreshVMButton.setText("Refresh");
0704: jp7refreshVMButton
0705: .setIcon(new javax.swing.ImageIcon(
0706: getClass()
0707: .getResource(
0708: "/toolbarButtonGraphics/general/Refresh24.gif")));
0709: // jp7refreshVMButton.setMargin(new Insets(7,2,6,2));
0710: jp7refreshVMButton.addActionListener(new ActionListener() {
0711: public void actionPerformed(java.awt.event.ActionEvent evt) {
0712: refreshConnectedVMs();
0713: }
0714: });
0715:
0716: jp6StartTx.setText("Start TX");
0717: jp6StartTx.setMargin(new Insets(7, 2, 6, 2));
0718: jp6StartTx.addActionListener(new ActionListener() {
0719: public void actionPerformed(java.awt.event.ActionEvent evt) {
0720: startTxActionPerformed(evt);
0721: }
0722: });
0723:
0724: jp6CommitTx.setText("Commit TX");
0725: jp6CommitTx.setMargin(new Insets(7, 2, 6, 2));
0726: jp6CommitTx.setBackground(new Color(0x39964));
0727: jp6CommitTx.addActionListener(new ActionListener() {
0728: public void actionPerformed(java.awt.event.ActionEvent evt) {
0729: commitTxActionPerformed(evt);
0730: }
0731: });
0732:
0733: jp6AbortTx.setText("Abort TX");
0734: jp6AbortTx.setMargin(new Insets(7, 2, 6, 2));
0735: jp6AbortTx.setBackground(new Color(0xf95e5e));
0736: jp6AbortTx.addActionListener(new ActionListener() {
0737: public void actionPerformed(java.awt.event.ActionEvent evt) {
0738: abortTxActionPerformed(evt);
0739: }
0740: });
0741: jToolBar1.addSeparator();
0742: jToolBar1.add(jp6StartTx);
0743: jToolBar1.add(jp6CommitTx);
0744: jToolBar1.add(jp6AbortTx);
0745: jToolBar1.addSeparator();
0746: jToolBar1.add(jp7refreshVMButton);
0747: jToolBar1.addSeparator();
0748: jToolBar1.add(jp8QueryToolbar);
0749:
0750: getContentPane().add(jToolBar1, BorderLayout.NORTH);
0751:
0752: //jToolBar1.add(Box.createHorizontalGlue());
0753:
0754: jPanel2.add(jLabel3);
0755: insertAspect.setText("insert");
0756: insertAspect.setMaximumSize(new Dimension(75, 23));
0757: insertAspect.setPreferredSize(new Dimension(75, 23));
0758:
0759: insertAspect
0760: .addActionListener(new java.awt.event.ActionListener() {
0761: public void actionPerformed(
0762: java.awt.event.ActionEvent evt) {
0763: insertAspectActionPerformed(evt);
0764: }
0765: });
0766: jPanel2.add(Box.createHorizontalGlue());
0767:
0768: jPanel1.add(jPanel3Insertion);
0769:
0770: Box resizablePanel1 = new Box(BoxLayout.X_AXIS);
0771: //resizablePanel1.setMaximumSize(new java.awt.Dimension(2000, 300));
0772: //resizablePanel1.setPreferredSize(new Dimension(541,300));
0773: // resizablePanel1.add(jPanel1);
0774: resizablePanel1.add(Box.createVerticalStrut(200));
0775: mainSplitPane.setRightComponent(jPanel1);
0776:
0777: // jToolBar3.add(jp5ConsolePane);
0778: getContentPane().add(jp5ConsolePane, BorderLayout.SOUTH);
0779:
0780: menuFile.setMnemonic('F');
0781: menuFile.setText("File");
0782:
0783: loadItem.setText("Load conf");
0784: loadItem.addActionListener(new java.awt.event.ActionListener() {
0785: public void actionPerformed(java.awt.event.ActionEvent evt) {
0786: loadMenuAction(evt);
0787: }
0788: });
0789:
0790: saveItem.setText("Save conf");
0791: saveItem.addActionListener(new java.awt.event.ActionListener() {
0792: public void actionPerformed(java.awt.event.ActionEvent evt) {
0793: saveMenuAction(evt);
0794: }
0795: });
0796:
0797: quitItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
0798: java.awt.event.KeyEvent.VK_F4,
0799: java.awt.event.InputEvent.ALT_MASK));
0800: quitItem.setText("Quit");
0801: quitItem.addActionListener(new java.awt.event.ActionListener() {
0802: public void actionPerformed(java.awt.event.ActionEvent evt) {
0803: quitMenuAction(evt);
0804: }
0805: });
0806:
0807: menuFile.add(saveItem);
0808: menuFile.add(loadItem);
0809: menuFile.add(quitItem);
0810:
0811: jMenuBar1.add(menuFile);
0812:
0813: menuEdit.setMnemonic('E');
0814: menuEdit.setText("Edit");
0815: copyItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
0816: java.awt.event.KeyEvent.VK_C,
0817: java.awt.event.InputEvent.CTRL_MASK));
0818: copyItem.setText("Copy");
0819: copyItem.addActionListener(new java.awt.event.ActionListener() {
0820: public void actionPerformed(java.awt.event.ActionEvent evt) {
0821: copyButtonActionPerformed(evt);
0822: }
0823: });
0824:
0825: menuEdit.add(copyItem);
0826:
0827: pasteItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
0828: java.awt.event.KeyEvent.VK_V,
0829: java.awt.event.InputEvent.CTRL_MASK));
0830: pasteItem.setText("Paste");
0831: pasteItem
0832: .addActionListener(new java.awt.event.ActionListener() {
0833: public void actionPerformed(
0834: java.awt.event.ActionEvent evt) {
0835: pasteButtonActionPerformed(evt);
0836: }
0837: });
0838:
0839: menuEdit.add(pasteItem);
0840:
0841: cutItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
0842: java.awt.event.KeyEvent.VK_X,
0843: java.awt.event.InputEvent.CTRL_MASK));
0844: cutItem.setText("Cut");
0845: cutItem.addActionListener(new java.awt.event.ActionListener() {
0846: public void actionPerformed(java.awt.event.ActionEvent evt) {
0847: cutButtonActionPerformed(evt);
0848: }
0849: });
0850:
0851: menuEdit.add(cutItem);
0852:
0853: jMenuBar1.add(menuEdit);
0854:
0855: menuVM.setMnemonic('V');
0856: menuVM.setText("VM");
0857: addVMItem.setText("Add VM");
0858: addVMItem
0859: .addActionListener(new java.awt.event.ActionListener() {
0860: public void actionPerformed(
0861: java.awt.event.ActionEvent evt) {
0862: addVMAction(evt);
0863: }
0864: });
0865:
0866: menuVM.add(addVMItem);
0867:
0868: removeVMItem.setText("Remove VM");
0869: removeVMItem
0870: .addActionListener(new java.awt.event.ActionListener() {
0871: public void actionPerformed(
0872: java.awt.event.ActionEvent evt) {
0873: removeVMAction(evt);
0874: }
0875: });
0876:
0877: menuVM.add(removeVMItem);
0878:
0879: jMenuBar1.add(menuVM);
0880:
0881: setJMenuBar(jMenuBar1);
0882:
0883: }//GEN-END:initComponents
0884:
0885: private void useSelectionRadioActionPerformed(
0886: java.awt.event.ActionEvent evt) {
0887: // Add your handling code here:
0888: }//GEN-LAST:event_useSelectionRadioActionPerformed
0889:
0890: private void insertAspectActionPerformed(
0891: java.awt.event.ActionEvent evt) {
0892: try {
0893: myModel.insertAspect();
0894: jp5ConsoleArea.revalidate();
0895: } catch (Exception e) {
0896: showException(this , e);
0897: }
0898:
0899: }//GEN-LAST:event_insertAspectActionPerformed
0900:
0901: private void chooseClassActionPerformed(
0902: java.awt.event.ActionEvent evt) {
0903: // Start the file browser
0904: int returnVal = commonFileChooser.showOpenDialog(this );
0905: if (returnVal == JFileChooser.APPROVE_OPTION) {
0906: commonFileChooser.setCurrentDirectory(commonFileChooser
0907: .getSelectedFile().getParentFile());
0908: myModel.appendToClasspath(commonFileChooser
0909: .getSelectedFile().getAbsolutePath());
0910: }
0911:
0912: }//GEN-LAST:event_chooseClassActionPerformed
0913:
0914: private void classTextFieldActionPerformed(
0915: java.awt.event.ActionEvent evt) {
0916:
0917: }
0918:
0919: private void cutButtonActionPerformed(java.awt.event.ActionEvent evt) {
0920:
0921: Object[] options = { "Insert", "Cancel" };
0922: int n = JOptionPane
0923: .showConfirmDialog(
0924: this ,
0925: "You will delete several elements permanently from PROSE!",
0926: "Confirmation Message",
0927: JOptionPane.YES_NO_OPTION,
0928: JOptionPane.INFORMATION_MESSAGE);
0929: if (n == 1)
0930: return;
0931:
0932: try {
0933: myModel.cutSelection();
0934: } catch (Exception e) {
0935: showException(this , e);
0936: }
0937: }
0938:
0939: private void pasteButtonActionPerformed(
0940: java.awt.event.ActionEvent evt) {
0941: Object[] options = { "Insert", "Cancel" };
0942: int n = JOptionPane
0943: .showConfirmDialog(
0944: this ,
0945: "You will insert several element permanently into PROSE!",
0946: "Confirmation Message",
0947: JOptionPane.YES_NO_OPTION,
0948: JOptionPane.INFORMATION_MESSAGE);
0949: if (n == 1)
0950: return;
0951:
0952: try {
0953: myModel.pasteSelection();
0954: } catch (Exception e) {
0955: showException(this , e);
0956: }
0957: }
0958:
0959: private void copyButtonActionPerformed(
0960: java.awt.event.ActionEvent evt) {
0961: try {
0962: myModel.copySelection();
0963: } catch (Exception e) {
0964: showException(this , e);
0965: }
0966: }
0967:
0968: protected void newTextAreaContent(String content) {
0969: textArea.setText(content);
0970: }
0971:
0972: private void jTabbedPane1StateChanged(
0973: javax.swing.event.ChangeEvent evt) {
0974: JTabbedPane tabbedPane = (JTabbedPane) evt.getSource();
0975: if (tabbedPane.getSelectedComponent() != null)
0976: ((JWorksheetProseClientPane) tabbedPane
0977: .getSelectedComponent()).select();
0978: }
0979:
0980: private void removeVMAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeVMAction
0981: /* if (jTabbedPane1.getTabCount() <= 1)
0982: {
0983: JOptionPane.showMessageDialog(this, "You can't remove the last Tab!",
0984: "Tab warning", JOptionPane.WARNING_MESSAGE);
0985: return;
0986: }
0987: */
0988:
0989: JRemoveVMDialog removeVMDialog = new JRemoveVMDialog(this ,
0990: false);
0991: removeVMDialog.setVisible(true);
0992: }//GEN-LAST:event_removeVMAction
0993:
0994: private void addVMAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addVMAction
0995: AddVMDialog addVMDialog = new AddVMDialog(this , false);
0996: addVMDialog.setVisible(true);
0997: }//GEN-LAST:event_addVMAction
0998:
0999: private void startTxActionPerformed(ActionEvent event) {
1000: try {
1001: myModel.startTransaction();
1002: jp6StartTx.setEnabled(false);
1003: jp6AbortTx.setEnabled(true);
1004: jp6CommitTx.setEnabled(true);
1005: } catch (Exception e) {
1006: showException(this , e);
1007: }
1008: }
1009:
1010: private void commitTxActionPerformed(ActionEvent evt) {
1011: try {
1012: myModel.commitTransaction(false);
1013: jp6StartTx.setEnabled(true);
1014: jp6AbortTx.setEnabled(false);
1015: jp6CommitTx.setEnabled(false);
1016: } catch (Exception e) {
1017: int n = JOptionPane
1018: .showConfirmDialog(
1019: this ,
1020: "An error occurred during the commit of the current transaction\n"
1021: + "\nError message: \n---------------------\n"
1022: + e.getMessage()
1023: + "\n---------------------\n"
1024: + "\n Proceed with commit? By answering 'NO', you may later perform"
1025: + "\n additional operations or abort the transaction. By answering 'YES'"
1026: + "\n all active nodes will commit, while disonnected nodes are left"
1027: + "\n out of this transaction",
1028: "Errors during commit",
1029: JOptionPane.YES_NO_OPTION);
1030: if (n == JOptionPane.NO_OPTION)
1031: return;
1032: else if (n == JOptionPane.YES_OPTION) {
1033: try {
1034: myModel.commitTransaction(true);
1035: } catch (Exception e1) {
1036: showException(this , e);
1037: }
1038: jp6StartTx.setEnabled(true);
1039: jp6AbortTx.setEnabled(false);
1040: jp6CommitTx.setEnabled(false);
1041:
1042: }
1043: }
1044:
1045: }
1046:
1047: private void abortTxActionPerformed(ActionEvent evt) {
1048: try {
1049: myModel.abortTransaction(true);
1050: } catch (Exception e) {
1051: showException(this , e);
1052: }
1053: jp6StartTx.setEnabled(true);
1054: jp6AbortTx.setEnabled(false);
1055: jp6CommitTx.setEnabled(false);
1056: }
1057:
1058: private void selectJoinpointButtonActionPerformed(
1059: java.awt.event.ActionEvent evt) {
1060: try {
1061: myModel.getActualTableModel().setDisplayJoinpoint();
1062: } catch (Exception e) {
1063: showException(this , e);
1064: }
1065: }//GEN-LAST:event_selectJoinpointButtonActionPerformed
1066:
1067: private void selectCrosscutButtonActionPerformed(
1068: java.awt.event.ActionEvent evt) {
1069: try {
1070: myModel.getActualTableModel().setDisplayCrosscut();
1071: } catch (Exception e) {
1072: showException(this , e);
1073: }
1074: }//GEN-LAST:event_selectCrosscutButtonActionPerformed
1075:
1076: private void selectAspectButtonActionPerformed(
1077: java.awt.event.ActionEvent evt) {
1078: try {
1079: myModel.getActualTableModel().setDisplayAspect();
1080: } catch (Exception e) {
1081: showException(this , e);
1082: }
1083: }//GEN-LAST:event_selectAspectButtonActionPerformed
1084:
1085: private void groupByJoinpointButtonActionPerformed(
1086: java.awt.event.ActionEvent evt) {
1087:
1088: try {
1089: myModel.getActualTableModel().setGroupByJoinpoint();
1090: } catch (Exception e) {
1091: showException(this , e);
1092: }
1093:
1094: }//GEN-LAST:event_groupByJoinpointButtonActionPerformed
1095:
1096: private void groupByCrosscutButtonActionPerformed(
1097: java.awt.event.ActionEvent evt) {
1098: try {
1099: myModel.getActualTableModel().setGroupByCrosscut();
1100: } catch (Exception e) {
1101: showException(this , e);
1102: }
1103: }//GEN-LAST:event_groupByCrosscutButtonActionPerformed
1104:
1105: private void allJoinpointsButtonActionPerformed(
1106: java.awt.event.ActionEvent evt) {
1107: try {
1108: myModel.getActualTableModel().allJoinpoints();
1109: this .validate();
1110: } catch (Exception e) {
1111: showException(this , e);
1112: }
1113: }
1114:
1115: private void allAspectsButtonActionPerformed(
1116: java.awt.event.ActionEvent evt) {
1117: try {
1118: myModel.getActualTableModel().allAspects();
1119: this .validate();
1120: } catch (Exception e) {
1121: showException(this , e);
1122: }
1123: }
1124:
1125: private void queryButtonActionPerformed(
1126: java.awt.event.ActionEvent evt) {
1127: try {
1128: if (myModel.getActualTableModel().data == null) {
1129: JOptionPane
1130: .showMessageDialog(
1131: this ,
1132: "Please press button 'AllAspects' or 'AllJoinpoints' first.",
1133: "query information",
1134: JOptionPane.INFORMATION_MESSAGE);
1135: return;
1136: }
1137:
1138: if (myModel.getActualTableModel().selectedCells.length == 0) {
1139: JOptionPane.showMessageDialog(this ,
1140: "No cells are selected.", "query warning",
1141: JOptionPane.WARNING_MESSAGE);
1142: return;
1143: }
1144: if (myModel.getActualTableModel().select == 0) {
1145: JOptionPane
1146: .showMessageDialog(
1147: this ,
1148: "At least one 'Select'-Checkbox must be enabled.",
1149: "query warning",
1150: JOptionPane.WARNING_MESSAGE);
1151: return;
1152: }
1153:
1154: for (int i = 0; i < myModel.getActualTableModel().selectedCells.length; i++)
1155: if ((((Vector) myModel.getActualTableModel().data
1156: .get(myModel.getActualTableModel().selectedCells[i]))
1157: .get(myModel.getActualTableModel()
1158: .getSelectedColumn()) == null)
1159: || (((Vector) myModel.getActualTableModel().data
1160: .get(myModel.getActualTableModel().selectedCells[i]))
1161: .get(
1162: myModel.getActualTableModel()
1163: .getSelectedColumn())
1164: .toString().equals("#NULL#"))) {
1165: JOptionPane.showMessageDialog(this ,
1166: "It is not allowed to select empty cells!",
1167: "query warning",
1168: JOptionPane.WARNING_MESSAGE);
1169: return;
1170: }
1171: if (myModel.getActualTableModel().isMixedSelection()) {
1172: JOptionPane
1173: .showMessageDialog(
1174: this ,
1175: "Don't mix pasted content with normal content for querying",
1176: "query warning",
1177: JOptionPane.WARNING_MESSAGE);
1178: return;
1179: }
1180:
1181: myModel.getActualTableModel().query();
1182: this .validate();
1183: } catch (Exception e) {
1184: showException(this , e);
1185: }
1186: }
1187:
1188: //GEN-LAST:event_queryButtonActionPerformed
1189:
1190: private void groupByAspectButtonActionPerformed(
1191: java.awt.event.ActionEvent evt) {
1192: try {
1193: myModel.getActualTableModel().setGroupByAspect();
1194: } catch (Exception e) {
1195: showException(this , e);
1196: }
1197: }//GEN-LAST:event_groupByAspectButtonActionPerformed
1198:
1199: /** Exit the Application */
1200: private void quitMenuAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_quitMenuAction
1201: exitGUI();
1202: }//GEN-LAST:event_quitMenuAction
1203:
1204: private void loadMenuAction(java.awt.event.ActionEvent evt) {
1205: JFileChooser chooser = new JFileChooser();
1206: int returnVal = chooser.showOpenDialog(this );
1207: if (returnVal == JFileChooser.APPROVE_OPTION) {
1208: try {
1209: memoFromFile(chooser.getSelectedFile());
1210: } catch (Exception e) {
1211: showException(this , e);
1212: }
1213: }
1214: }
1215:
1216: private void saveMenuAction(java.awt.event.ActionEvent evt) {
1217: JFileChooser chooser = new JFileChooser();
1218: int returnVal = chooser.showSaveDialog(this );
1219: if (returnVal == JFileChooser.APPROVE_OPTION) {
1220: try {
1221: memoToFile(chooser.getSelectedFile());
1222: } catch (Exception e) {
1223: showException(this , e);
1224: }
1225: }
1226: }
1227:
1228: private void customizeComponents() throws java.rmi.RemoteException,
1229: java.rmi.NotBoundException, java.net.MalformedURLException {
1230: this .addWindowListener(new WindowAdapter() {
1231: public void windowClosing(WindowEvent e) {
1232: exitGUI();
1233: }
1234: });
1235: commonFileChooser = new JFileChooser();
1236: commonFileChooser
1237: .setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
1238: }
1239:
1240: protected JWorksheetProseClientPane getTab(String name) {
1241: int at = jTabbedPane1.indexOfTab(name);
1242: if (at != -1)
1243: return (JWorksheetProseClientPane) jTabbedPane1
1244: .getComponentAt(at);
1245: else
1246: return null;
1247: }
1248:
1249: protected void addTab(String n, String host, String port,
1250: boolean doRefresh) throws MalformedURLException,
1251: NotBoundException, RemoteException,
1252: IllegalUserInputException, java.net.UnknownHostException {
1253: if (n == null || n.trim().equals(""))
1254: throw new IllegalUserInputException("Please specify a name");
1255: if (getTab(n) != null)
1256: throw new IllegalUserInputException("The name '" + n
1257: + "' is already used!");
1258: if (host == null || host.trim().equals(""))
1259: throw new IllegalUserInputException("Please specify a host");
1260: if (port == null || port.trim().equals(""))
1261: throw new IllegalUserInputException("Please specify a port");
1262:
1263: JWorksheetProseClientPane newWindow = new JWorksheetProseClientPane(
1264: this , n, host, port);
1265: newWindow.setDividerLocation(0.5);
1266: newWindow.setDividerSize(5);
1267: jTabbedPane1.addTab(n, newWindow);
1268:
1269: newWindow.customizeTable(newWindow.getLeftTable());
1270: newWindow.customizeTable(newWindow.getRightTable());
1271:
1272: jTabbedPane1.setSelectedComponent(newWindow);
1273: newWindow.select();
1274: jTabbedPane1.setEnabledAt(jTabbedPane1.indexOfTab(n), false);
1275: if (doRefresh) {
1276: ((WorksheetSingleClientModel) newWindow.getLeftTable()
1277: .getModel()).refresh();
1278: ((WorksheetSingleClientModel) newWindow.getRightTable()
1279: .getModel()).refresh();
1280: jTabbedPane1.setEnabledAt(jTabbedPane1.indexOfTab(n), true);
1281: }
1282: }
1283:
1284: public static void showException(java.awt.Component ctx, Exception e) {
1285:
1286: if (e.getClass().equals(java.rmi.NotBoundException.class)) {
1287: JOptionPane
1288: .showMessageDialog(
1289: ctx,
1290: "The please verify that the remote prose vm is correctly started",
1291: "connection error",
1292: JOptionPane.ERROR_MESSAGE);
1293: } else if (e.getClass().equals(NotBoundException.class)) {
1294: JOptionPane.showMessageDialog(ctx,
1295: "Please verify that the remote prose vm is correctly started.\nCause:"
1296: + e.getMessage(), "connection error",
1297: JOptionPane.ERROR_MESSAGE);
1298: } else if (e.getClass().equals(java.rmi.RemoteException.class)) {
1299: JOptionPane.showMessageDialog(ctx,
1300: "Connection error. Remote prose (host, port) "
1301: + "is not responding.\nCause:"
1302: + e.getMessage(), "connection errror",
1303: JOptionPane.ERROR_MESSAGE);
1304: } else if (e.getClass().equals(IllegalUserInputException.class)) {
1305: JOptionPane.showMessageDialog(ctx, e.getMessage(),
1306: "Illegal input", JOptionPane.ERROR_MESSAGE);
1307: } else if (e.getClass().equals(java.rmi.ConnectException.class)) {
1308: JOptionPane.showMessageDialog(ctx,
1309: "Cannot connect to the specified address. \n Cause:"
1310: + e.getMessage(), "connection error",
1311: JOptionPane.ERROR_MESSAGE);
1312: } else if (e.getClass().equals(PasteAspectsException.class)) {
1313: JOptionPane.showMessageDialog(ctx,
1314: "Problems encoutered during aspect insertion:\n"
1315: + e.getMessage(), "weaving warning",
1316: JOptionPane.WARNING_MESSAGE);
1317: } else if (e.getClass().equals(WithdrawAspectsException.class)) {
1318: JOptionPane.showMessageDialog(ctx,
1319: "Problems encoutered during aspect deletion:\n"
1320: + e.getMessage(), "unweaving warning",
1321: JOptionPane.WARNING_MESSAGE);
1322: } else if (e.getClass().equals(TableSelectionException.class)) {
1323: JOptionPane.showMessageDialog(ctx, e.getMessage(),
1324: "selection warning", JOptionPane.WARNING_MESSAGE);
1325: } else if (e.getClass()
1326: .equals(TransactionFinishException.class)) {
1327: JOptionPane.showMessageDialog(ctx, e.getMessage(),
1328: "transaction warning", JOptionPane.WARNING_MESSAGE);
1329: } else if (e.getClass().equals(
1330: java.rmi.UnknownHostException.class)) {
1331: JOptionPane.showMessageDialog(ctx, e.getMessage(),
1332: "unknown host", JOptionPane.WARNING_MESSAGE);
1333: } else {
1334: e.printStackTrace();
1335: JOptionPane.showMessageDialog(ctx, "Unknown exeception:"
1336: + e.toString(), "unknown error",
1337: JOptionPane.ERROR_MESSAGE);
1338: }
1339: }
1340:
1341: protected void removeTab(String name) {
1342: JWorksheetProseClientPane jpw = getTab(name);
1343: if (jTabbedPane1.getSelectedIndex() == jTabbedPane1
1344: .indexOfTab(name)) {
1345: jTabbedPane1.remove(jpw);
1346: if (jTabbedPane1.getTabCount() > 0) {
1347: jTabbedPane1.setSelectedIndex(0);
1348: ((JWorksheetProseClientPane) jTabbedPane1
1349: .getComponentAt(0)).select();
1350: }
1351: } else
1352: jTabbedPane1.remove(jpw);
1353: myModel.removeVM(name);
1354: }
1355:
1356: public MultipleClientModel getModel() {
1357: return myModel;
1358: }
1359:
1360: private void exitGUI() {
1361: System.exit(0);
1362: }
1363:
1364: /**
1365: * @param args the command line arguments
1366: */
1367: public static void main(String args[]) {
1368: JFrame f = new JMultipleProseClient();
1369: f.pack();
1370: //f.show(); // deprecated since JDK 1.5
1371: f.setVisible(true); // replaces show()
1372: }
1373:
1374: static class TabInfo implements java.io.Serializable {
1375: String tname;
1376: String thost;
1377: String tport;
1378:
1379: public boolean equals(Object obj) {
1380: return obj instanceof TabInfo
1381: && TabInfo.this .tname.equals(((TabInfo) obj).tname);
1382: }
1383:
1384: public int hashCode() {
1385: return tname.hashCode();
1386: }
1387: }
1388:
1389: public void memoToFile(java.io.File f)
1390: throws java.io.FileNotFoundException,
1391: java.io.OptionalDataException, java.io.IOException {
1392: String classPath = myModel.getClasspath();
1393: String aspectName = myModel.getAspectClassName();
1394: Set h = new HashSet();
1395: Iterator i = myModel.getAllVM().iterator();
1396: while (i.hasNext()) {
1397: WorksheetSingleClientModel m = (WorksheetSingleClientModel) i
1398: .next();
1399: TabInfo t = new TabInfo();
1400: t.tname = m.getName();
1401: t.thost = m.getHost();
1402: t.tport = m.getPort();
1403: h.add(t);
1404: }
1405: ObjectOutputStream objOut = new ObjectOutputStream(
1406: new FileOutputStream(f));
1407: objOut.writeObject(classPath);
1408: objOut.writeObject(aspectName);
1409: objOut.writeObject(h);
1410: objOut.close();
1411: }
1412:
1413: public void memoFromFile(java.io.File f)
1414: throws java.io.FileNotFoundException,
1415: java.io.OptionalDataException,
1416: java.net.MalformedURLException, java.io.IOException,
1417: java.rmi.NotBoundException, IllegalUserInputException {
1418: ObjectInputStream oi = new ObjectInputStream(
1419: new FileInputStream(f));
1420: try {
1421: String classPath = (String) oi.readObject();
1422: String aspectName = (String) oi.readObject();
1423: Set h = (Set) oi.readObject();
1424:
1425: jp4CpathField.setText(classPath);
1426: classTextField.setText(aspectName);
1427:
1428: Iterator i = h.iterator();
1429: while (i.hasNext()) {
1430: TabInfo t = (TabInfo) i.next();
1431: addTab(t.tname, t.thost, t.tport, false);
1432: }
1433: } catch (ClassNotFoundException e) {
1434: throw new Error("All classes here are known");
1435: }
1436: refreshConnectedVMs();
1437: }
1438:
1439: // Variables declaration - do not modify//GEN-BEGIN:variables
1440:
1441: private javax.swing.JSplitPane mainSplitPane;
1442:
1443: private javax.swing.JTabbedPane jTabbedPane1;
1444: private javax.swing.JScrollPane textAreaScroller;
1445: private javax.swing.JButton pasteButton;
1446: private javax.swing.JToolBar jToolBar1;
1447: private javax.swing.JToolBar jToolBar3;
1448: private javax.swing.JToolBar jToolBar2;
1449: private javax.swing.JRadioButton groupByAspectButton;
1450: private javax.swing.JCheckBox selectJoinpointButton;
1451: private javax.swing.JButton insertAspect;
1452: private javax.swing.ButtonGroup groupByGroup;
1453: private javax.swing.JMenu menuEdit;
1454: private javax.swing.JMenuItem copyItem;
1455: private javax.swing.JMenuItem quitItem;
1456: private javax.swing.JRadioButton useSelectionRadio;
1457: private javax.swing.JPanel checkBoxPanel;
1458: private javax.swing.JPanel radioBoxPanel;
1459: private javax.swing.JRadioButton groupByJoinpointButton;
1460: private javax.swing.JButton allJoinpointsButton;
1461: private javax.swing.JMenuBar jMenuBar1;
1462: private javax.swing.JButton chooseClass;
1463: private javax.swing.JCheckBox selectCrosscutButton;
1464: private javax.swing.JTextField classTextField;
1465: private javax.swing.JTextArea textArea;
1466: private javax.swing.JMenuItem pasteItem;
1467: private javax.swing.JPanel buttons;
1468: private javax.swing.JButton copyButton;
1469: private javax.swing.JPanel jPanel3Insertion;
1470: private javax.swing.JLabel jp4CpathLabel;
1471: private javax.swing.JPanel jPanel4Classpath;
1472: private javax.swing.JTextField jp4CpathField;
1473: private javax.swing.JButton jp4EditCpathButton;
1474: private javax.swing.JFileChooser jp4AddCpathDir;
1475:
1476: private javax.swing.JPanel jp5ConsolePane;
1477: private javax.swing.JScrollPane jp5ConsoleScroll;
1478: private javax.swing.JTextPane jp5ConsoleArea;
1479:
1480: private javax.swing.JPanel jPanel2;
1481: private javax.swing.JPanel jPanel1;
1482: private javax.swing.JCheckBox selectAspectButton;
1483: private javax.swing.JButton queryButton;
1484: private javax.swing.JMenuItem removeVMItem;
1485: private javax.swing.JButton allAspectsButton;
1486: private javax.swing.JButton cutButton;
1487: private javax.swing.JMenu menuVM;
1488: private javax.swing.JPanel boxes;
1489: private javax.swing.JLabel jLabel3;
1490: private javax.swing.JLabel jLabel2;
1491: private javax.swing.JLabel jLabel1;
1492: private javax.swing.JMenu menuFile;
1493: private javax.swing.ButtonGroup selectionVsAllGroup;
1494: private javax.swing.JMenuItem cutItem;
1495: private javax.swing.JMenuItem addVMItem;
1496: private javax.swing.JRadioButton useAllRadio;
1497: private javax.swing.JRadioButton groupByCrosscutButton;
1498:
1499: private javax.swing.JPanel jPanelSelectionInto = new JPanel();
1500:
1501: private javax.swing.JPanel jp6transactionPane;
1502: private javax.swing.JButton jp6StartTx;
1503: private javax.swing.JButton jp6CommitTx;
1504: private javax.swing.JButton jp6AbortTx;
1505:
1506: private javax.swing.JButton jp7refreshVMButton;
1507: private javax.swing.JButton jp8QueryToolbar;
1508:
1509: private javax.swing.JMenuItem saveItem;
1510: private javax.swing.JMenuItem loadItem;
1511: // End of variables declaration//GEN-END:variables
1512:
1513: }
|