Package ch.ethz.prose.tools

Source Code of ch.ethz.prose.tools.JMultipleProseClient$TabInfo

//
//  This file is part of the prose package.
//
//  The contents of this file are subject to the Mozilla Public License
//  Version 1.1 (the "License"); you may not use this file except in
//  compliance with the License. You may obtain a copy of the License at
//  http://www.mozilla.org/MPL/
//
//  Software distributed under the License is distributed on an "AS IS" basis,
//  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
//  for the specific language governing rights and limitations under the
//  License.
//
//  The Original Code is prose.
//
//  The Initial Developer of the Original Code is Andrei Popovici. Portions
//  created by Andrei Popovici are Copyright (C) 2002 Andrei Popovici.
//  All Rights Reserved.
//
//  Contributor(s):
//  $Id: JMultipleProseClient.java,v 1.3 2008/11/18 11:43:39 anicoara Exp $
//  ==============================================================
//

package ch.ethz.prose.tools;

import java.rmi.*;
import java.net.*;

import java.awt.Font;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.WindowAdapter;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Dimension;
import java.awt.event.WindowEvent;
import java.util.Iterator;
import java.util.Vector;
import java.awt.FlowLayout;

import java.io.ObjectOutputStream;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.io.ObjectInputStream;

import javax.swing.border.TitledBorder;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Color;
import javax.swing.BoxLayout;
import javax.swing.JOptionPane;
import javax.swing.JTabbedPane;
import javax.swing.Box;
import javax.swing.JSplitPane;

import java.util.*;

/**
* @author  pschoch
*/
public class JMultipleProseClient extends javax.swing.JFrame {

  private static final long serialVersionUID = 3618700803251122489L;
  private MultipleClientModel myModel;
  private JFileChooser commonFileChooser;


  /** Creates new form JFrame */
  public JMultipleProseClient() {

    myModel = new MultipleClientModel(this);
    initComponents();
    try {
      customizeComponents();
    }
    catch (java.rmi.NotBoundException noProseThere) {
      throw new Error("It is not possible for a remote exception to occur upon startup. Please report this bug to PROSE");
    }
    catch (java.net.MalformedURLException wrongUrl) {
      throw new Error("It is not possible for a remote exception to occur upon startup. Please report this bug to PROSE");
    }
    catch (java.rmi.RemoteException cannotContact) {
      throw new Error("It is not possible for a remote exception to occur upon startup. Please report this bug to PROSE");
    }

  }

  private void refreshConnectedVMs() {
    Iterator i = myModel.getAllVM().iterator();
    while (i.hasNext()) {
      WorksheetSingleClientModel m = (WorksheetSingleClientModel)i.next();
      try {
        m.refresh();
        jTabbedPane1.setEnabledAt(jTabbedPane1.indexOfTab(m.getName()),true);
      }
      catch (Exception e) {
        jTabbedPane1.setEnabledAt(jTabbedPane1.indexOfTab(m.getName()),false);
      }
    }
  }

  /**
   * This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  private void initComponents() {//GEN-BEGIN:initComponents

    mainSplitPane = new javax.swing.JSplitPane();

    jPanelSelectionInto = new JPanel();
    groupByGroup = new javax.swing.ButtonGroup();
    selectionVsAllGroup = new javax.swing.ButtonGroup();
    jPanel1 = new javax.swing.JPanel();
    jToolBar1 = new javax.swing.JToolBar();
    jToolBar2 = new javax.swing.JToolBar();
    jToolBar3 = new javax.swing.JToolBar();
    cutButton = new javax.swing.JButton();
    copyButton = new javax.swing.JButton();
    pasteButton = new javax.swing.JButton();
    jTabbedPane1 = new javax.swing.JTabbedPane();
    boxes = new javax.swing.JPanel();
    checkBoxPanel = new javax.swing.JPanel();
    selectAspectButton = new javax.swing.JCheckBox();
    selectCrosscutButton = new javax.swing.JCheckBox();
    selectJoinpointButton = new javax.swing.JCheckBox();
    radioBoxPanel = new javax.swing.JPanel();
    groupByAspectButton = new javax.swing.JRadioButton();
    groupByCrosscutButton = new javax.swing.JRadioButton();
    groupByJoinpointButton = new javax.swing.JRadioButton();
    textAreaScroller = new javax.swing.JScrollPane();
    textArea = new javax.swing.JTextArea();
    buttons = new javax.swing.JPanel();
    queryButton = new javax.swing.JButton();
    allAspectsButton = new javax.swing.JButton();
    allJoinpointsButton = new javax.swing.JButton();
    jPanel4Classpath = new javax.swing.JPanel();

    jPanel4Classpath   = new javax.swing.JPanel();
    jp4CpathLabel      = new javax.swing.JLabel();
    jp4CpathField      = new javax.swing.JTextField();
    jp4EditCpathButton = new javax.swing.JButton();
    jp4AddCpathDir     = new javax.swing.JFileChooser();

    jp5ConsolePane     = new javax.swing.JPanel();
    jp5ConsoleArea     = new javax.swing.JTextPane();
    jp5ConsoleScroll   = new javax.swing.JScrollPane();

    jp6transactionPane = new javax.swing.JPanel();
    jp6StartTx         = new javax.swing.JButton();
    jp6CommitTx        = new javax.swing.JButton();
    jp6AbortTx         = new javax.swing.JButton();

    jp7refreshVMButton = new javax.swing.JButton();

    jp8QueryToolbar = new javax.swing.JButton();

    jPanel3Insertion= new javax.swing.JPanel();
    jPanel2 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    classTextField = new javax.swing.JTextField();
    chooseClass = new javax.swing.JButton();
    jLabel2 = new javax.swing.JLabel();
    useSelectionRadio = new javax.swing.JRadioButton();
    useAllRadio = new javax.swing.JRadioButton();
    jLabel3 = new javax.swing.JLabel();
    insertAspect = new javax.swing.JButton();
    jMenuBar1 = new javax.swing.JMenuBar();
    menuFile = new javax.swing.JMenu();

    loadItem = new javax.swing.JMenuItem();
    saveItem = new javax.swing.JMenuItem();

    quitItem = new javax.swing.JMenuItem();
    menuEdit = new javax.swing.JMenu();
    copyItem = new javax.swing.JMenuItem();
    pasteItem = new javax.swing.JMenuItem();
    cutItem = new javax.swing.JMenuItem();
    menuVM = new javax.swing.JMenu();
    addVMItem = new javax.swing.JMenuItem();
    removeVMItem = new javax.swing.JMenuItem();


    getContentPane().setLayout(new BorderLayout());
    //getContentPane().setLayout(new BoxLayout(getContentPane(),BoxLayout.Y_AXIS));
    getContentPane().add(mainSplitPane,BorderLayout.CENTER);


    //  mainSplitPane.setDividerLocation(0.2);
    mainSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    mainSplitPane.setDividerSize(5);
    mainSplitPane.setPreferredSize(new Dimension(1200,500));
    mainSplitPane.setMinimumSize(new Dimension(1200,500));

    setTitle("Prose Workbench");
    jPanel1.setLayout(new BoxLayout(jPanel1,BoxLayout.Y_AXIS));
    jPanel1.setMinimumSize(new java.awt.Dimension(400, 250));
    jPanel1.setPreferredSize(new java.awt.Dimension(1200, 250));
    jPanel1.setMaximumSize(new java.awt.Dimension(2000,300));
    cutButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Cut24.gif")));
    cutButton.setToolTipText("Cut Aspect");
    cutButton.setFont(new java.awt.Font("Dialog", 0, 11));
    cutButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        cutButtonActionPerformed(evt);
      }
    });

    jToolBar1.add(cutButton);

    copyButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Copy24.gif")));
    copyButton.setToolTipText("Copy");
    copyButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        copyButtonActionPerformed(evt);
      }
    });

    jToolBar1.add(copyButton);

    pasteButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Paste24.gif")));
    pasteButton.setToolTipText("Paste");
    pasteButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        pasteButtonActionPerformed(evt);
      }
    });

    jToolBar1.add(pasteButton);


    jTabbedPane1.setPreferredSize(new java.awt.Dimension(1200, 800));
    jTabbedPane1.setMinimumSize(new java.awt.Dimension(400, 200));
    jTabbedPane1.setAlignmentX(0.0F);
    jTabbedPane1.setMaximumSize(new Dimension(2000,2000));
    jTabbedPane1.addChangeListener(new javax.swing.event.ChangeListener() {
      public void stateChanged(javax.swing.event.ChangeEvent evt) {
        jTabbedPane1StateChanged(evt);
      }
    });


    mainSplitPane.setLeftComponent(jTabbedPane1);

    //gridBagConstraints);

    boxes.setLayout(new FlowLayout(FlowLayout.LEFT));

    boxes.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(8, 8, 8, 8)));
    boxes.setPreferredSize(new java.awt.Dimension(300, 100));
    boxes.setMinimumSize(new java.awt.Dimension(572, 100));
    boxes.setMaximumSize(new java.awt.Dimension(2000, 100));
    checkBoxPanel.setLayout(new java.awt.GridLayout(3, 0, 0, 5));

    checkBoxPanel.setBorder(new javax.swing.border.CompoundBorder(new javax.swing.border.EtchedBorder(null, java.awt.Color.gray), new javax.swing.border.EmptyBorder(new java.awt.Insets(3, 9, 3, 3))));
    checkBoxPanel.setMaximumSize(new java.awt.Dimension(160, 82));
    checkBoxPanel.setPreferredSize(new java.awt.Dimension(160, 82));
    checkBoxPanel.setMinimumSize(new java.awt.Dimension(160, 82));
    selectAspectButton.setToolTipText("Select to view 'Aspects' in the result");
    selectAspectButton.setModel(myModel.getSelectAspect());
    selectAspectButton.setFont(new java.awt.Font("Luxi Sans", 1, 12));
    selectAspectButton.setText("Select Aspects");
    selectAspectButton.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(2, 2, 2, 2)));
    selectAspectButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        selectAspectButtonActionPerformed(evt);
      }
    });

    checkBoxPanel.add(selectAspectButton);

    selectCrosscutButton.setToolTipText("Select to view 'Crosscuts' in the result");
    selectCrosscutButton.setModel(myModel.getSelectCrosscut());
    selectCrosscutButton.setFont(new java.awt.Font("Luxi Sans", 1, 12));
    selectCrosscutButton.setText("Select Crosscuts");
    selectCrosscutButton.setPreferredSize(new java.awt.Dimension(130, 20));
    selectCrosscutButton.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(2, 2, 2, 2)));
    selectCrosscutButton.setMaximumSize(new java.awt.Dimension(130, 20));
    selectCrosscutButton.setMinimumSize(new java.awt.Dimension(130, 20));
    selectCrosscutButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        selectCrosscutButtonActionPerformed(evt);
      }
    });

    checkBoxPanel.add(selectCrosscutButton);

    selectJoinpointButton.setToolTipText("Select to view 'Joinpoints' in the result");
    selectJoinpointButton.setModel(myModel.getSelectJoinpoint());
    selectJoinpointButton.setFont(new java.awt.Font("Luxi Sans", 1, 12));
    selectJoinpointButton.setText("Select Joinpoints");
    selectJoinpointButton.setPreferredSize(new java.awt.Dimension(130, 20));
    selectJoinpointButton.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(2, 2, 2, 2)));
    selectJoinpointButton.setMaximumSize(new java.awt.Dimension(130, 20));
    selectJoinpointButton.setMinimumSize(new java.awt.Dimension(130, 20));
    selectJoinpointButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        selectJoinpointButtonActionPerformed(evt);
      }
    });

    checkBoxPanel.add(selectJoinpointButton);

    boxes.add(checkBoxPanel);

    radioBoxPanel.setLayout(new java.awt.GridLayout(3, 0, 0, 5));

    radioBoxPanel.setBorder(new javax.swing.border.CompoundBorder(new javax.swing.border.EtchedBorder(null, java.awt.Color.gray), new javax.swing.border.EmptyBorder(new java.awt.Insets(3, 9, 3, 3))));
    radioBoxPanel.setPreferredSize(new java.awt.Dimension(160, 82));
    radioBoxPanel.setMinimumSize(new java.awt.Dimension(160, 82));
    radioBoxPanel.setMaximumSize(new java.awt.Dimension(160, 82));
    groupByAspectButton.setModel(myModel.getGroupByAspect());
    groupByAspectButton.setFont(new java.awt.Font("LuxiSans", 1, 12));
    groupByAspectButton.setText("Group by Aspect");
    groupByGroup.add(groupByAspectButton);
    groupByAspectButton.setPreferredSize(new java.awt.Dimension(130, 20));
    groupByAspectButton.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(20, 2, 20, 2)));
    groupByAspectButton.setMaximumSize(new java.awt.Dimension(130, 20));
    groupByAspectButton.setMargin(new java.awt.Insets(20, 2, 2, 2));
    groupByAspectButton.setMinimumSize(new java.awt.Dimension(130, 20));
    groupByAspectButton.setBorderPainted(true);
    groupByAspectButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        groupByAspectButtonActionPerformed(evt);
      }
    });

    radioBoxPanel.add(groupByAspectButton);

    groupByCrosscutButton.setFont(new java.awt.Font("Luxi Sans", 1, 12));
    groupByCrosscutButton.setText("Group by Crosscut");
    groupByCrosscutButton.setModel(myModel.getGroupByCrosscut());
    groupByGroup.add(groupByCrosscutButton);
    groupByCrosscutButton.setPreferredSize(new java.awt.Dimension(130, 20));
    groupByCrosscutButton.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(2, 2, 2, 2)));
    groupByCrosscutButton.setMaximumSize(new java.awt.Dimension(130, 20));
    groupByCrosscutButton.setMargin(new java.awt.Insets(20, 2, 2, 2));
    groupByCrosscutButton.setMinimumSize(new java.awt.Dimension(130, 20));
    groupByCrosscutButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        groupByCrosscutButtonActionPerformed(evt);
      }
    });

    radioBoxPanel.add(groupByCrosscutButton);

    groupByJoinpointButton.setFont(new java.awt.Font("Luxi Sans", 1, 12));

    groupByJoinpointButton.setText("Group by Joinpoint");

    groupByJoinpointButton.setModel(myModel.getGroupByJoinpoint());

    groupByGroup.add(groupByJoinpointButton);

    groupByJoinpointButton.setPreferredSize(new java.awt.Dimension(130, 20));

    groupByJoinpointButton.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(2, 2, 2, 2)));

    groupByJoinpointButton.setMaximumSize(new java.awt.Dimension(130, 20));


    groupByJoinpointButton.setMargin(new java.awt.Insets(20, 2, 2, 2));

    groupByJoinpointButton.setMinimumSize(new java.awt.Dimension(130, 20));


    groupByJoinpointButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        groupByJoinpointButtonActionPerformed(evt);
      }
    });

    radioBoxPanel.add(groupByJoinpointButton);

    boxes.add(radioBoxPanel);


    buttons.setLayout(new GridLayout(3,2,5,5));
    //        buttons.setPreferredSize(new java.awt.Dimension(100, 80));
    //        buttons.setMinimumSize(new java.awt.Dimension(100, 80));

    queryButton.setToolTipText("Send the selected Items to the AspectManager and get the Result");
    queryButton.setFont(new java.awt.Font("Luxi Sans", 1, 14));
    queryButton.setText("query");
    queryButton.setPreferredSize(new java.awt.Dimension(30,23 ));
    queryButton.setBorder(new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.RAISED, java.awt.Color.lightGray, java.awt.Color.white, java.awt.Color.darkGray, java.awt.Color.gray));
    queryButton.setMaximumSize(new java.awt.Dimension(160, 128));
    queryButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    queryButton.setMinimumSize(new java.awt.Dimension(30, 23));
    queryButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        queryButtonActionPerformed(evt);
      }
    });
    buttons.add(new JLabel("query: sected cells"));
    buttons.add(queryButton);

    jp8QueryToolbar.setText("Q");
    jp8QueryToolbar.setFont(new java.awt.Font("Luxi Sans", Font.BOLD, 18));
    jp8QueryToolbar.setForeground(new Color(0x765f91));
    jp8QueryToolbar.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        queryButtonActionPerformed(evt);
      }
    });



    Dimension buttonDimension = new Dimension(50,23);
    Dimension labelDimension = new Dimension(100,23);




    allAspectsButton.setToolTipText("Retrieve all Aspects inserted in this AspectManager");
    allAspectsButton.setFont(new java.awt.Font("Luxi Sans", 1, 12));
    allAspectsButton.setText("query");
    allAspectsButton.setPreferredSize(new java.awt.Dimension(30, 23));
    allAspectsButton.setBorder(new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.RAISED, java.awt.Color.lightGray, java.awt.Color.white, java.awt.Color.darkGray, java.awt.Color.gray));
    allAspectsButton.setMaximumSize(new java.awt.Dimension(128, 32));
    allAspectsButton.setMinimumSize(new java.awt.Dimension(30, 23));
    allAspectsButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        allAspectsButtonActionPerformed(evt);
      }
    });
    buttons.add(new JLabel("query: all aspects"));
    buttons.add(allAspectsButton);



    allJoinpointsButton.setToolTipText("Retrieve all Joinpoints inserted in this AspectManager");
    allJoinpointsButton.setFont(new java.awt.Font("Luxi Sans", 1, 12));
    allJoinpointsButton.setText("query");
    allJoinpointsButton.setPreferredSize(new java.awt.Dimension(50, 23));
    allJoinpointsButton.setBorder(new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.RAISED, java.awt.Color.lightGray, java.awt.Color.white, java.awt.Color.darkGray, java.awt.Color.gray));
    allJoinpointsButton.setMaximumSize(new java.awt.Dimension(128, 32));
    allJoinpointsButton.setMinimumSize(new java.awt.Dimension(30, 23));
    allJoinpointsButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        allJoinpointsButtonActionPerformed(evt);
      }
    });

    buttons.add(new JLabel("query: all joinpoints"));
    buttons.add(allJoinpointsButton);


    boxes.add(buttons);
    boxes.add(Box.createHorizontalGlue());


    jPanel1.add(textAreaScroller);

    jPanel1.add(boxes);

    textAreaScroller.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    textAreaScroller.setPreferredSize(new java.awt.Dimension(500, 39));
    textAreaScroller.setMinimumSize(new java.awt.Dimension(50, 39));
    textAreaScroller.setMaximumSize(new java.awt.Dimension(2000, 100));
    textArea.setWrapStyleWord(true);
    textArea.setLineWrap(true);
    textArea.setEditable(false);
    textArea.setRows(5);
    textArea.setFont(new java.awt.Font("Courier", 0, 11));
    textArea.setPreferredSize(new java.awt.Dimension(0, 70));
    textArea.setMargin(new java.awt.Insets(3, 3, 3, 3));
    textArea.setMinimumSize(new java.awt.Dimension(50, 40));
    textAreaScroller.setViewportView(textArea);


    jPanel3Insertion.setLayout(new FlowLayout(FlowLayout.LEFT));
    //  jPanel3Insertion.setLayout(new BoxLayout(jPanel3Insertion,javax.swing.BoxLayout.X_AXIS));

    JPanel classPathAndAspect = new JPanel();
    classPathAndAspect.setMaximumSize(new Dimension(1000,100));
    classPathAndAspect.setLayout(new BoxLayout(classPathAndAspect, BoxLayout.Y_AXIS));
    classPathAndAspect.add(Box.createVerticalGlue());
    classPathAndAspect.add(jPanel2);
    classPathAndAspect.add(Box.createVerticalGlue());
    classPathAndAspect.add(jPanel4Classpath);
    classPathAndAspect.add(Box.createVerticalGlue());

    jPanel3Insertion.add(Box.createHorizontalStrut(10));
    jPanel3Insertion.add(classPathAndAspect);
    //  jPanel3Insertion.add(Box.createHorizontalStrut(10));
    //  jPanel3Insertion.add(jPanelSelectionInto);
    jPanel3Insertion.add(Box.createHorizontalGlue());

    //  jPanel3Insertion.add(Box.createHorizontalGlue());
    jPanel3Insertion.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(8, 8, 8, 8)));


    jPanel3Insertion.setPreferredSize(new java.awt.Dimension(541, 100));
    jPanel3Insertion.setMinimumSize(new java.awt.Dimension(541, 100));
    jPanel3Insertion.setMaximumSize(new java.awt.Dimension(2000, 100));

    jp5ConsoleArea.setDocument(myModel.getConsole());
    jp5ConsoleArea.setPreferredSize(new java.awt.Dimension(500,100));
    jp5ConsoleArea.setMinimumSize(new java.awt.Dimension(300,100));
    jp5ConsoleArea.setBackground(new Color(0xf9efe8));


    //  jp5ConsoleArea.setLineWrap(true);
    //  jp5ConsoleArea.setColumns(80);
    //  jp5ConsoleArea.setRows(20);
    jp5ConsoleScroll.add(jp5ConsoleArea);
    jp5ConsoleArea.revalidate();
    jp5ConsoleScroll.setViewportView(jp5ConsoleArea);
    jp5ConsolePane.add(jp5ConsoleScroll);

    jp5ConsolePane.setBorder(new javax.swing.border.TitledBorder("Console"));
    jp5ConsolePane.setLayout(new javax.swing.BoxLayout(jp5ConsolePane,javax.swing.BoxLayout.Y_AXIS));
    jp5ConsolePane.setMaximumSize(new java.awt.Dimension(1200,210));
    jp5ConsolePane.setPreferredSize(new java.awt.Dimension(510,210));

    jp5ConsoleArea.setEditable(false);

    jPanel2.setLayout(new BoxLayout(jPanel2,BoxLayout.X_AXIS));
    jLabel1.setText("Aspect class ");
    jLabel1.setPreferredSize(new Dimension(100,23));
    jLabel1.setMaximumSize(new Dimension(100,23));
    jLabel1.setMinimumSize(new Dimension(100,23));
    jPanel2.add(jLabel1);


    classTextField.setDocument(myModel.getAspectClassNameModel());
    classTextField.setMaximumSize(new java.awt.Dimension(330, 23));
    classTextField.setPreferredSize(new java.awt.Dimension(330, 23));
    classTextField.setMinimumSize(new java.awt.Dimension(330, 23));
    classTextField.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        classTextFieldActionPerformed(evt);
      }
    });

    jPanel2.add(classTextField);
    jPanel2.add(insertAspect);
    chooseClass.setText("...");
    chooseClass.setMaximumSize(new Dimension(75,23));
    chooseClass.setPreferredSize(new Dimension(75,23));
    chooseClass.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        chooseClassActionPerformed(evt);
      }
    });


    jPanelSelectionInto.setLayout(new BoxLayout(jPanelSelectionInto,BoxLayout.Y_AXIS));
    jPanelSelectionInto.setBorder(new TitledBorder("aspect insertion target"));
    jPanelSelectionInto.add(useSelectionRadio);
    jPanelSelectionInto.add(useAllRadio);

    //jLabel2.setText("   target VM  ");
    //        jPanel2.add(jLabel2);

    useSelectionRadio.setText("selected VM");
    useSelectionRadio.setModel(myModel.getInsertInSelection());
    selectionVsAllGroup.add(useSelectionRadio);
    useSelectionRadio.setActionCommand("sel");
    useSelectionRadio.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        useSelectionRadioActionPerformed(evt);
      }
    });

    //        jPanel2.add(useSelectionRadio);


    useAllRadio.setText("all VMs");
    useAllRadio.setModel(myModel.getInsertInAllVM());
    selectionVsAllGroup.add(useAllRadio);
    useAllRadio.setActionCommand("all");
    //        jPanel2.add(useAllRadio);


    jPanel4Classpath.setLayout(new javax.swing.BoxLayout(jPanel4Classpath,javax.swing.BoxLayout.X_AXIS));
    jPanel4Classpath.add(jp4CpathLabel);
    jPanel4Classpath.add(jp4CpathField);
    jPanel4Classpath.add(chooseClass);
    jPanel4Classpath.add(javax.swing.Box.createHorizontalGlue());
    jp4CpathField.setDocument(getModel().getClasspathModel());



    jp4CpathField.setMinimumSize(new java.awt.Dimension(330, 23));
    jp4CpathField.setPreferredSize(new java.awt.Dimension(330, 23));
    jp4CpathField.setMaximumSize(new java.awt.Dimension(330, 23));
    jp4CpathLabel.setText("Classpath ");
    jp4CpathLabel.setMaximumSize(new Dimension(100,23));
    jp4CpathLabel.setPreferredSize(new Dimension(100,23));
    jp4CpathLabel.setMinimumSize(new Dimension(100,23));


    //  jp7refreshVMButton.setText("Refresh");
    jp7refreshVMButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Refresh24.gif")));
    //  jp7refreshVMButton.setMargin(new Insets(7,2,6,2));
    jp7refreshVMButton.addActionListener(new ActionListener()    {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        refreshConnectedVMs();
      }});



    jp6StartTx.setText("Start TX");
    jp6StartTx.setMargin(new Insets(7,2,6,2));
    jp6StartTx.addActionListener(new ActionListener()    {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        startTxActionPerformed(evt);
      }});

    jp6CommitTx.setText("Commit TX");
    jp6CommitTx.setMargin(new Insets(7,2,6,2));
    jp6CommitTx.setBackground(new Color(0x39964));
    jp6CommitTx.addActionListener(new ActionListener()    {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        commitTxActionPerformed(evt);
      }});

    jp6AbortTx.setText("Abort TX");
    jp6AbortTx.setMargin(new Insets(7,2,6,2));
    jp6AbortTx.setBackground(new Color(0xf95e5e));
    jp6AbortTx.addActionListener(new ActionListener()    {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        abortTxActionPerformed(evt);
      }});
    jToolBar1.addSeparator();
    jToolBar1.add(jp6StartTx);
    jToolBar1.add(jp6CommitTx);
    jToolBar1.add(jp6AbortTx);
    jToolBar1.addSeparator();
    jToolBar1.add(jp7refreshVMButton);
    jToolBar1.addSeparator();
    jToolBar1.add(jp8QueryToolbar);


    getContentPane().add(jToolBar1,BorderLayout.NORTH);

    //jToolBar1.add(Box.createHorizontalGlue());


    jPanel2.add(jLabel3);
    insertAspect.setText("insert");
    insertAspect.setMaximumSize(new Dimension(75,23));
    insertAspect.setPreferredSize(new Dimension(75,23));

    insertAspect.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        insertAspectActionPerformed(evt);
      }
    });
    jPanel2.add(Box.createHorizontalGlue());


    jPanel1.add(jPanel3Insertion);

    Box resizablePanel1 = new Box(BoxLayout.X_AXIS);
    //resizablePanel1.setMaximumSize(new java.awt.Dimension(2000, 300));
    //resizablePanel1.setPreferredSize(new Dimension(541,300));
    //  resizablePanel1.add(jPanel1);
    resizablePanel1.add(Box.createVerticalStrut(200));
    mainSplitPane.setRightComponent(jPanel1);

    //  jToolBar3.add(jp5ConsolePane);
    getContentPane().add(jp5ConsolePane,BorderLayout.SOUTH);

    menuFile.setMnemonic('F');
    menuFile.setText("File");

    loadItem.setText("Load conf");
    loadItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        loadMenuAction(evt);
      }
    });

    saveItem.setText("Save conf");
    saveItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        saveMenuAction(evt);
      }
    });

    quitItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.ALT_MASK));
    quitItem.setText("Quit");
    quitItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        quitMenuAction(evt);
      }
    });


    menuFile.add(saveItem);
    menuFile.add(loadItem);
    menuFile.add(quitItem);

    jMenuBar1.add(menuFile);

    menuEdit.setMnemonic('E');
    menuEdit.setText("Edit");
    copyItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK));
    copyItem.setText("Copy");
    copyItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        copyButtonActionPerformed(evt);
      }
    });

    menuEdit.add(copyItem);

    pasteItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.CTRL_MASK));
    pasteItem.setText("Paste");
    pasteItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        pasteButtonActionPerformed(evt);
      }
    });

    menuEdit.add(pasteItem);

    cutItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK));
    cutItem.setText("Cut");
    cutItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        cutButtonActionPerformed(evt);
      }
    });

    menuEdit.add(cutItem);

    jMenuBar1.add(menuEdit);

    menuVM.setMnemonic('V');
    menuVM.setText("VM");
    addVMItem.setText("Add VM");
    addVMItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        addVMAction(evt);
      }
    });

    menuVM.add(addVMItem);

    removeVMItem.setText("Remove VM");
    removeVMItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        removeVMAction(evt);
      }
    });

    menuVM.add(removeVMItem);

    jMenuBar1.add(menuVM);

    setJMenuBar(jMenuBar1);

  }//GEN-END:initComponents

  private void useSelectionRadioActionPerformed(java.awt.event.ActionEvent evt) {
    // Add your handling code here:
  }//GEN-LAST:event_useSelectionRadioActionPerformed

  private void insertAspectActionPerformed(java.awt.event.ActionEvent evt) {
    try {
      myModel.insertAspect();
      jp5ConsoleArea.revalidate();
    }
    catch (Exception e) {
      showException(this,e);
    }

  }//GEN-LAST:event_insertAspectActionPerformed

  private void chooseClassActionPerformed(java.awt.event.ActionEvent evt) {
    // Start the file browser
    int returnVal = commonFileChooser.showOpenDialog(this);
    if(returnVal == JFileChooser.APPROVE_OPTION) {
      commonFileChooser.setCurrentDirectory(commonFileChooser.getSelectedFile().getParentFile());
      myModel.appendToClasspath(commonFileChooser.getSelectedFile().getAbsolutePath());
    }


  }//GEN-LAST:event_chooseClassActionPerformed

  private void classTextFieldActionPerformed(java.awt.event.ActionEvent evt) {

  }

  private void cutButtonActionPerformed(java.awt.event.ActionEvent evt) {

    Object[] options = {"Insert", "Cancel"};
    int n = JOptionPane.showConfirmDialog(this,
        "You will delete several elements permanently from PROSE!",
        "Confirmation Message",
        JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);
    if (n == 1)
      return;

    try {  
      myModel.cutSelection();      
    }
    catch (Exception e) {  
      showException(this,e);      
    }
  }

  private void pasteButtonActionPerformed(java.awt.event.ActionEvent evt) {
    Object[] options = {"Insert", "Cancel"};
    int n = JOptionPane.showConfirmDialog(this,
        "You will insert several element permanently into PROSE!",
        "Confirmation Message",
        JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);
    if (n == 1)
      return;

    try {
      myModel.pasteSelection();
    }
    catch (Exception e) {
      showException(this,e);
    }
  }

  private void copyButtonActionPerformed(java.awt.event.ActionEvent evt) {
    try {   
      myModel.copySelection();
    }
    catch (Exception e)  {   
      showException(this,e);
    }
  }

  protected void newTextAreaContent(String content) {
    textArea.setText(content);
  }

  private void jTabbedPane1StateChanged(javax.swing.event.ChangeEvent evt) {
    JTabbedPane tabbedPane = (JTabbedPane)evt.getSource();
    if (tabbedPane.getSelectedComponent() != null)
      ((JWorksheetProseClientPane)tabbedPane.getSelectedComponent()).select();
  }

  private void removeVMAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeVMAction
    /*    if (jTabbedPane1.getTabCount() <= 1)
      {
        JOptionPane.showMessageDialog(this, "You can't remove the last Tab!",
            "Tab warning", JOptionPane.WARNING_MESSAGE);
        return;
      }
     */
    JRemoveVMDialog removeVMDialog = new JRemoveVMDialog(this, false);
    removeVMDialog.setVisible(true);
  }//GEN-LAST:event_removeVMAction

  private void addVMAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addVMAction
    AddVMDialog addVMDialog = new AddVMDialog(this, false);
    addVMDialog.setVisible(true);
  }//GEN-LAST:event_addVMAction


  private void startTxActionPerformed(ActionEvent event){
    try {
      myModel.startTransaction();
      jp6StartTx.setEnabled(false);
      jp6AbortTx.setEnabled(true);
      jp6CommitTx.setEnabled(true);
    }
    catch (Exception e) {   
      showException(this,e)
    }
  }

  private void commitTxActionPerformed(ActionEvent evt) {
    try {
      myModel.commitTransaction(false);
      jp6StartTx.setEnabled(true);
      jp6AbortTx.setEnabled(false);
      jp6CommitTx.setEnabled(false);
    }
    catch (Exception e) {
      int n = JOptionPane.showConfirmDialog(this, "An error occurred during the commit of the current transaction\n"
          + "\nError message: \n---------------------\n" +
          e.getMessage()
          + "\n---------------------\n"
          + "\n Proceed with commit? By answering 'NO', you may later perform"
          + "\n additional operations or abort the transaction. By answering 'YES'"
          + "\n all active nodes will commit, while disonnected nodes are left"
          + "\n out of this transaction",
          "Errors during commit"
          , JOptionPane.YES_NO_OPTION);
      if (n == JOptionPane.NO_OPTION)
        return;
      else if (n == JOptionPane.YES_OPTION) {
        try { myModel.commitTransaction(true); }
        catch (Exception e1) { showException(this,e);}
        jp6StartTx.setEnabled(true);
        jp6AbortTx.setEnabled(false);
        jp6CommitTx.setEnabled(false);

      }
    }

  }

  private void abortTxActionPerformed(ActionEvent evt) {
    try { myModel.abortTransaction(true); }
    catch (Exception e) { showException(this,e); }
    jp6StartTx.setEnabled(true);
    jp6AbortTx.setEnabled(false);
    jp6CommitTx.setEnabled(false);
  }

  private void selectJoinpointButtonActionPerformed(java.awt.event.ActionEvent evt) {
    try { myModel.getActualTableModel().setDisplayJoinpoint(); }
    catch (Exception e) {showException(this,e);}
  }//GEN-LAST:event_selectJoinpointButtonActionPerformed

  private void selectCrosscutButtonActionPerformed(java.awt.event.ActionEvent evt) {
    try {    myModel.getActualTableModel().setDisplayCrosscut();}
    catch (Exception e) {showException(this,e);}
  }//GEN-LAST:event_selectCrosscutButtonActionPerformed

  private void selectAspectButtonActionPerformed(java.awt.event.ActionEvent evt) {
    try {    myModel.getActualTableModel().setDisplayAspect(); }
    catch (Exception e) {showException(this,e);}
  }//GEN-LAST:event_selectAspectButtonActionPerformed

  private void groupByJoinpointButtonActionPerformed(java.awt.event.ActionEvent evt) {

    try { myModel.getActualTableModel().setGroupByJoinpoint();}
    catch (Exception e) {showException(this,e);}

  }//GEN-LAST:event_groupByJoinpointButtonActionPerformed

  private void groupByCrosscutButtonActionPerformed(java.awt.event.ActionEvent evt) {
    try {    myModel.getActualTableModel().setGroupByCrosscut(); }
    catch (Exception e) {showException(this,e);}
  }//GEN-LAST:event_groupByCrosscutButtonActionPerformed

  private void allJoinpointsButtonActionPerformed(java.awt.event.ActionEvent evt) {
    try {
      myModel.getActualTableModel().allJoinpoints();
      this.validate();
    }
    catch (Exception e) {
      showException(this,e);
    }
  }

  private void allAspectsButtonActionPerformed(java.awt.event.ActionEvent evt) {
    try {
      myModel.getActualTableModel().allAspects();
      this.validate();
    }
    catch (Exception e) {
      showException(this,e);
    }
  }

  private void queryButtonActionPerformed(java.awt.event.ActionEvent evt) {
    try {
      if (myModel.getActualTableModel().data == null) {
        JOptionPane.showMessageDialog(this, "Please press button 'AllAspects' or 'AllJoinpoints' first.",
            "query information", JOptionPane.INFORMATION_MESSAGE);
        return;
      }

      if (myModel.getActualTableModel().selectedCells.length == 0) {
        JOptionPane.showMessageDialog(this, "No cells are selected.",
            "query warning", JOptionPane.WARNING_MESSAGE);
        return;
      }
     
      if (myModel.getActualTableModel().select == 0) {
        JOptionPane.showMessageDialog(this, "At least one 'Select'-Checkbox must be enabled.",
            "query warning", JOptionPane.WARNING_MESSAGE);
        return;
      }

      for (int i=0; i < myModel.getActualTableModel().selectedCells.length; i++)
        if ((((Vector)myModel.getActualTableModel().data.get(myModel.getActualTableModel().selectedCells[i]))
            .get(myModel.getActualTableModel().getSelectedColumn()) == null)
            || (((Vector)myModel.getActualTableModel().data.get(myModel.getActualTableModel().selectedCells[i]))
                .get(myModel.getActualTableModel().getSelectedColumn()).toString().equals("#NULL#")))
        {
          JOptionPane.showMessageDialog(this, "It is not allowed to select empty cells!",
              "query warning", JOptionPane.WARNING_MESSAGE);
          return;
        }
     
      if (myModel.getActualTableModel().isMixedSelection()) {
        JOptionPane.showMessageDialog(this, "Don't mix pasted content with normal content for querying",
            "query warning", JOptionPane.WARNING_MESSAGE);
        return;
      }


      myModel.getActualTableModel().query();
      this.validate();
    }
    catch (Exception e) {
      showException(this,e);
    }
  }

  //GEN-LAST:event_queryButtonActionPerformed

  private void groupByAspectButtonActionPerformed(java.awt.event.ActionEvent evt) {
    try  {    myModel.getActualTableModel().setGroupByAspect(); }
    catch (Exception e) { showException(this,e); }
  }//GEN-LAST:event_groupByAspectButtonActionPerformed

  /** Exit the Application */
  private void quitMenuAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_quitMenuAction
    exitGUI();
  }//GEN-LAST:event_quitMenuAction


  private void loadMenuAction(java.awt.event.ActionEvent evt) {
    JFileChooser chooser = new JFileChooser();
    int returnVal = chooser.showOpenDialog(this);
    if(returnVal == JFileChooser.APPROVE_OPTION) {
      try {
        memoFromFile(chooser.getSelectedFile());
      }
      catch (Exception e) { showException(this,e); }
    }
  }


  private void saveMenuAction(java.awt.event.ActionEvent evt) {
    JFileChooser chooser = new JFileChooser();
    int returnVal = chooser.showSaveDialog(this);
    if(returnVal == JFileChooser.APPROVE_OPTION) {
      try {
        memoToFile(chooser.getSelectedFile());
      }
      catch (Exception e) { showException(this,e); }
    }
  }

  private void customizeComponents() throws java.rmi.RemoteException, java.rmi.NotBoundException, java.net.MalformedURLException {
    this.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) { exitGUI(); }
    });
    commonFileChooser= new JFileChooser();
    commonFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  }

  protected JWorksheetProseClientPane getTab(String name) {
    int at = jTabbedPane1.indexOfTab(name);
    if (at != -1)
      return (JWorksheetProseClientPane)jTabbedPane1.getComponentAt(at);
    else
      return null;
  }

  protected void addTab(String n, String host, String port, boolean doRefresh)
  throws MalformedURLException, NotBoundException, RemoteException, IllegalUserInputException, java.net.UnknownHostException {
    if (n == null || n.trim().equals(""))
      throw new IllegalUserInputException("Please specify a name");
    if (getTab(n) != null)
      throw new IllegalUserInputException("The name '" + n + "' is already used!");
    if (host == null || host.trim().equals(""))
      throw new IllegalUserInputException("Please specify a host");
    if (port == null || port.trim().equals(""))
      throw new IllegalUserInputException("Please specify a port");

    JWorksheetProseClientPane newWindow = new JWorksheetProseClientPane(this,n,host,port);
    newWindow.setDividerLocation(0.5);
    newWindow.setDividerSize(5);
    jTabbedPane1.addTab(n, newWindow);


    newWindow.customizeTable(newWindow.getLeftTable());
    newWindow.customizeTable(newWindow.getRightTable());

    jTabbedPane1.setSelectedComponent(newWindow);
    newWindow.select();
    jTabbedPane1.setEnabledAt(jTabbedPane1.indexOfTab(n),false);
    if (doRefresh) {
      ((WorksheetSingleClientModel)newWindow.getLeftTable().getModel()).refresh();
      ((WorksheetSingleClientModel)newWindow.getRightTable().getModel()).refresh();
      jTabbedPane1.setEnabledAt(jTabbedPane1.indexOfTab(n),true);
    }
  }

  public static void showException(java.awt.Component ctx, Exception e) {

    if (e.getClass().equals(java.rmi.NotBoundException.class)) {
      JOptionPane.showMessageDialog(ctx, "The please verify that the remote prose vm is correctly started",
          "connection error", JOptionPane.ERROR_MESSAGE);
    }
   
    else if (e.getClass().equals(NotBoundException.class)) {
      JOptionPane.showMessageDialog(ctx, "Please verify that the remote prose vm is correctly started.\nCause:" + e.getMessage(),
          "connection error", JOptionPane.ERROR_MESSAGE);
    }
   
    else if (e.getClass().equals(java.rmi.RemoteException.class)) {
      JOptionPane.showMessageDialog(ctx, "Connection error. Remote prose (host, port) " +
          "is not responding.\nCause:" + e.getMessage(),"connection errror", JOptionPane.ERROR_MESSAGE);
    }
   
    else if (e.getClass().equals(IllegalUserInputException.class)) {
      JOptionPane.showMessageDialog(ctx,e.getMessage(),"Illegal input",JOptionPane.ERROR_MESSAGE);
    }
   
    else if (e.getClass().equals(java.rmi.ConnectException.class)) {
      JOptionPane.showMessageDialog(ctx,"Cannot connect to the specified address. \n Cause:" + e.getMessage(),"connection error"
          ,JOptionPane.ERROR_MESSAGE);
    }
   
    else if (e.getClass().equals(PasteAspectsException.class)) {
      JOptionPane.showMessageDialog(ctx,"Problems encoutered during aspect insertion:\n"
          + e.getMessage(),"weaving warning",JOptionPane.WARNING_MESSAGE);
    }
   
    else if (e.getClass().equals(WithdrawAspectsException.class)) {
      JOptionPane.showMessageDialog(ctx,"Problems encoutered during aspect deletion:\n"
          + e.getMessage(),"unweaving warning",JOptionPane.WARNING_MESSAGE);
    }
   
    else if (e.getClass().equals(TableSelectionException.class)) {
      JOptionPane.showMessageDialog(ctx,e.getMessage(),"selection warning",JOptionPane.WARNING_MESSAGE);
    }
   
    else if (e.getClass().equals(TransactionFinishException.class)) {
      JOptionPane.showMessageDialog(ctx,e.getMessage(),"transaction warning",JOptionPane.WARNING_MESSAGE);
    }
   
    else if (e.getClass().equals(java.rmi.UnknownHostException.class)) {
      JOptionPane.showMessageDialog(ctx,e.getMessage(),"unknown host",JOptionPane.WARNING_MESSAGE);
    }
   
    else {
      e.printStackTrace();
      JOptionPane.showMessageDialog(ctx,"Unknown exeception:" + e.toString(),"unknown error",JOptionPane.ERROR_MESSAGE);
    }
  }

  protected void removeTab(String name) {
    JWorksheetProseClientPane jpw = getTab(name);
    if (jTabbedPane1.getSelectedIndex() == jTabbedPane1.indexOfTab(name)) {
      jTabbedPane1.remove(jpw);
      if (jTabbedPane1.getTabCount() >0) {
        jTabbedPane1.setSelectedIndex(0);
        ((JWorksheetProseClientPane)jTabbedPane1.getComponentAt(0)).select();
      }
    }
    else
      jTabbedPane1.remove(jpw);
    myModel.removeVM(name);
  }

  public MultipleClientModel getModel() {
    return myModel;
  }

  private void exitGUI() {
    System.exit(0);
  }

  /**
   * @param args the command line arguments
   */
  public static void main(String args[]) {
    JFrame f = new JMultipleProseClient();
    f.pack();
    //f.show();     // deprecated since JDK 1.5
    f.setVisible(true)// replaces show()
  }

  static class TabInfo implements java.io.Serializable {
    String tname;
    String thost;
    String tport;
    public
    boolean equals(Object obj) {
      return
      obj instanceof TabInfo &&
      TabInfo.this.tname.equals(((TabInfo) obj).tname);
    }

    public int hashCode() {
      return tname.hashCode();
    }
  }


  public void memoToFile(java.io.File f) throws java.io.FileNotFoundException, java.io.OptionalDataException, java.io.IOException {
    String classPath = myModel.getClasspath();
    String aspectName = myModel.getAspectClassName();
    Set h = new HashSet();
    Iterator i = myModel.getAllVM().iterator();
    while (i.hasNext()) {
      WorksheetSingleClientModel m = (WorksheetSingleClientModel)i.next();
      TabInfo t = new TabInfo();
      t.tname = m.getName();
      t.thost = m.getHost();
      t.tport = m.getPort();
      h.add(t);
    }
    ObjectOutputStream objOut = new ObjectOutputStream(new FileOutputStream(f));
    objOut.writeObject(classPath);
    objOut.writeObject(aspectName);
    objOut.writeObject(h);
    objOut.close();
  }

  public void memoFromFile(java.io.File f)
  throws java.io.FileNotFoundException, java.io.OptionalDataException, java.net.MalformedURLException,java.io.IOException, java.rmi.NotBoundException, IllegalUserInputException {
    ObjectInputStream oi = new ObjectInputStream(new FileInputStream(f));
    try {
      String classPath = (String)oi.readObject();
      String aspectName = (String)oi.readObject();
      Set h = (Set)oi.readObject();

      jp4CpathField.setText(classPath);
      classTextField.setText(aspectName);

      Iterator i = h.iterator();
      while (i.hasNext()) {
        TabInfo t = (TabInfo)i.next();
        addTab(t.tname,t.thost,t.tport,false);
      }
    }
    catch (ClassNotFoundException e) {
      throw new Error("All classes here are known");
    }
    refreshConnectedVMs();
  }

  // Variables declaration - do not modify//GEN-BEGIN:variables

  private javax.swing.JSplitPane mainSplitPane;

  private javax.swing.JTabbedPane jTabbedPane1;
  private javax.swing.JScrollPane textAreaScroller;
  private javax.swing.JButton pasteButton;
  private javax.swing.JToolBar jToolBar1;
  private javax.swing.JToolBar jToolBar3;
  private javax.swing.JToolBar jToolBar2;
  private javax.swing.JRadioButton groupByAspectButton;
  private javax.swing.JCheckBox selectJoinpointButton;
  private javax.swing.JButton insertAspect;
  private javax.swing.ButtonGroup groupByGroup;
  private javax.swing.JMenu menuEdit;
  private javax.swing.JMenuItem copyItem;
  private javax.swing.JMenuItem quitItem;
  private javax.swing.JRadioButton useSelectionRadio;
  private javax.swing.JPanel checkBoxPanel;
  private javax.swing.JPanel radioBoxPanel;
  private javax.swing.JRadioButton groupByJoinpointButton;
  private javax.swing.JButton allJoinpointsButton;
  private javax.swing.JMenuBar jMenuBar1;
  private javax.swing.JButton chooseClass;
  private javax.swing.JCheckBox selectCrosscutButton;
  private javax.swing.JTextField classTextField;
  private javax.swing.JTextArea textArea;
  private javax.swing.JMenuItem pasteItem;
  private javax.swing.JPanel buttons;
  private javax.swing.JButton copyButton;
  private javax.swing.JPanel jPanel3Insertion;
  private javax.swing.JLabel jp4CpathLabel;
  private javax.swing.JPanel       jPanel4Classpath;
  private javax.swing.JTextField   jp4CpathField;
  private javax.swing.JButton      jp4EditCpathButton;
  private javax.swing.JFileChooser jp4AddCpathDir;

  private javax.swing.JPanel jp5ConsolePane    ;
  private javax.swing.JScrollPane jp5ConsoleScroll;
  private javax.swing.JTextPane jp5ConsoleArea     ;

  private javax.swing.JPanel jPanel2;
  private javax.swing.JPanel jPanel1;
  private javax.swing.JCheckBox selectAspectButton;
  private javax.swing.JButton queryButton;
  private javax.swing.JMenuItem removeVMItem;
  private javax.swing.JButton allAspectsButton;
  private javax.swing.JButton cutButton;
  private javax.swing.JMenu menuVM;
  private javax.swing.JPanel boxes;
  private javax.swing.JLabel jLabel3;
  private javax.swing.JLabel jLabel2;
  private javax.swing.JLabel jLabel1;
  private javax.swing.JMenu menuFile;
  private javax.swing.ButtonGroup selectionVsAllGroup;
  private javax.swing.JMenuItem cutItem;
  private javax.swing.JMenuItem addVMItem;
  private javax.swing.JRadioButton useAllRadio;
  private javax.swing.JRadioButton groupByCrosscutButton;

  private javax.swing.JPanel jPanelSelectionInto = new JPanel();

  private javax.swing.JPanel     jp6transactionPane;
  private javax.swing.JButton    jp6StartTx;
  private javax.swing.JButton    jp6CommitTx;
  private javax.swing.JButton    jp6AbortTx;

  private javax.swing.JButton    jp7refreshVMButton;
  private javax.swing.JButton    jp8QueryToolbar;

  private javax.swing.JMenuItem   saveItem;
  private javax.swing.JMenuItem   loadItem;
  // End of variables declaration//GEN-END:variables

}
TOP

Related Classes of ch.ethz.prose.tools.JMultipleProseClient$TabInfo

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.