1 26 27 package ch.ethz.prose.tools; 28 29 import java.rmi.*; 30 import java.net.*; 31 32 import java.awt.Component ; 33 import java.awt.Font ; 34 import java.awt.BorderLayout ; 35 import java.awt.GridLayout ; 36 import java.awt.Insets ; 37 import java.awt.event.WindowAdapter ; 38 import java.awt.event.ActionEvent ; 39 import java.awt.event.ActionListener ; 40 import java.awt.Dimension ; 41 import java.awt.event.WindowEvent ; 42 import java.util.Collections ; 43 import java.util.Iterator ; 44 import java.util.List ; 45 import java.util.StringTokenizer ; 46 import java.util.Vector ; 47 import java.awt.FlowLayout ; 48 49 import java.io.ObjectOutputStream ; 50 import java.io.FileOutputStream ; 51 import java.io.FileInputStream ; 52 import java.io.ObjectInputStream ; 53 54 import javax.swing.border.TitledBorder ; 55 import javax.swing.border.EtchedBorder ; 56 import javax.swing.ButtonModel ; 57 import javax.swing.ComboBoxModel ; 58 import javax.swing.JFileChooser ; 59 import javax.swing.JFrame ; 60 import javax.swing.JPanel ; 61 import javax.swing.JLabel ; 62 import java.awt.Color ; 63 import javax.swing.BoxLayout ; 64 import javax.swing.JOptionPane ; 65 import javax.swing.JTabbedPane ; 66 import javax.swing.event.ListDataEvent ; 67 import javax.swing.event.ListDataListener ; 68 import javax.swing.Box ; 69 import javax.swing.JSplitPane ; 70 71 import ch.ethz.prose.Aspect; 72 import ch.ethz.prose.query.AspectSurrogate; 73 import java.util.*; 74 75 79 public class JMultipleProseClient extends javax.swing.JFrame { 80 81 private MultipleClientModel myModel; 82 private JFileChooser commonFileChooser; 83 84 85 86 public JMultipleProseClient() { 87 88 myModel = new MultipleClientModel(this); 89 initComponents(); 90 try 91 { 92 customizeComponents(); 93 } 94 catch (java.rmi.NotBoundException noProseThere) 95 { 96 throw new Error ("It is not possible for a remote exception to occur upon startup. Please report this bug to PROSE"); 97 } 98 catch (java.net.MalformedURLException wrongUrl) 99 { 100 throw new Error ("It is not possible for a remote exception to occur upon startup. Please report this bug to PROSE"); 101 } 102 catch (java.rmi.RemoteException cannotContact) 103 { 104 throw new Error ("It is not possible for a remote exception to occur upon startup. Please report this bug to PROSE"); 105 } 106 107 } 108 109 private void refreshConnectedVMs() 110 { 111 Iterator i = myModel.getAllVM().iterator(); 112 while (i.hasNext()) 113 { 114 WorksheetSingleClientModel m = (WorksheetSingleClientModel)i.next(); 115 try 116 { 117 m.refresh(); 118 jTabbedPane1.setEnabledAt(jTabbedPane1.indexOfTab(m.getName()),true); 119 } 120 catch (Exception e) 121 { 122 jTabbedPane1.setEnabledAt(jTabbedPane1.indexOfTab(m.getName()),false); 123 } 124 } 125 } 126 127 132 private void initComponents() { 134 135 mainSplitPane = new javax.swing.JSplitPane (); 136 137 jPanelSelectionInto = new JPanel (); 138 groupByGroup = new javax.swing.ButtonGroup (); 139 selectionVsAllGroup = new javax.swing.ButtonGroup (); 140 jPanel1 = new javax.swing.JPanel (); 141 jToolBar1 = new javax.swing.JToolBar (); 142 jToolBar2 = new javax.swing.JToolBar (); 143 jToolBar3 = new javax.swing.JToolBar (); 144 cutButton = new javax.swing.JButton (); 145 copyButton = new javax.swing.JButton (); 146 pasteButton = new javax.swing.JButton (); 147 jTabbedPane1 = new javax.swing.JTabbedPane (); 148 boxes = new javax.swing.JPanel (); 149 checkBoxPanel = new javax.swing.JPanel (); 150 selectAspectButton = new javax.swing.JCheckBox (); 151 selectCrosscutButton = new javax.swing.JCheckBox (); 152 selectJoinpointButton = new javax.swing.JCheckBox (); 153 radioBoxPanel = new javax.swing.JPanel (); 154 groupByAspectButton = new javax.swing.JRadioButton (); 155 groupByCrosscutButton = new javax.swing.JRadioButton (); 156 groupByJoinpointButton = new javax.swing.JRadioButton (); 157 textAreaScroller = new javax.swing.JScrollPane (); 158 textArea = new javax.swing.JTextArea (); 159 buttons = new javax.swing.JPanel (); 160 queryButton = new javax.swing.JButton (); 161 allAspectsButton = new javax.swing.JButton (); 162 allJoinpointsButton = new javax.swing.JButton (); 163 jPanel4Classpath = new javax.swing.JPanel (); 164 165 jPanel4Classpath = new javax.swing.JPanel (); 166 jp4CpathLabel = new javax.swing.JLabel (); 167 jp4CpathField = new javax.swing.JTextField (); 168 jp4EditCpathButton = new javax.swing.JButton (); 169 jp4AddCpathDir = new javax.swing.JFileChooser (); 170 171 172 jp5ConsolePane = new javax.swing.JPanel (); 173 jp5ConsoleArea = new javax.swing.JTextPane (); 174 jp5ConsoleScroll = new javax.swing.JScrollPane (); 175 176 177 jp6transactionPane = new javax.swing.JPanel (); 178 jp6StartTx = new javax.swing.JButton (); 179 jp6CommitTx = new javax.swing.JButton (); 180 jp6AbortTx = new javax.swing.JButton (); 181 182 jp7refreshVMButton = new javax.swing.JButton (); 183 184 185 jp8QueryToolbar = new javax.swing.JButton (); 186 187 jPanel3Insertion= new javax.swing.JPanel (); 188 jPanel2 = new javax.swing.JPanel (); 189 jLabel1 = new javax.swing.JLabel (); 190 classTextField = new javax.swing.JTextField (); 191 chooseClass = new javax.swing.JButton (); 192 jLabel2 = new javax.swing.JLabel (); 193 useSelectionRadio = new javax.swing.JRadioButton (); 194 useAllRadio = new javax.swing.JRadioButton (); 195 jLabel3 = new javax.swing.JLabel (); 196 insertAspect = new javax.swing.JButton (); 197 jMenuBar1 = new javax.swing.JMenuBar (); 198 menuFile = new javax.swing.JMenu (); 199 200 loadItem = new javax.swing.JMenuItem (); 201 saveItem = new javax.swing.JMenuItem (); 202 203 quitItem = new javax.swing.JMenuItem (); 204 menuEdit = new javax.swing.JMenu (); 205 copyItem = new javax.swing.JMenuItem (); 206 pasteItem = new javax.swing.JMenuItem (); 207 cutItem = new javax.swing.JMenuItem (); 208 menuVM = new javax.swing.JMenu (); 209 addVMItem = new javax.swing.JMenuItem (); 210 removeVMItem = new javax.swing.JMenuItem (); 211 212 213 getContentPane().setLayout(new BorderLayout ()); 214 getContentPane().add(mainSplitPane,BorderLayout.CENTER); 216 217 218 219 220 221 222 mainSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); 224 mainSplitPane.setDividerSize(5); 225 mainSplitPane.setPreferredSize(new Dimension (1200,500)); 226 mainSplitPane.setMinimumSize(new Dimension (1200,500)); 227 228 setTitle("Prose Workbench"); 229 jPanel1.setLayout(new BoxLayout (jPanel1,BoxLayout.Y_AXIS)); 230 jPanel1.setMinimumSize(new java.awt.Dimension (400, 250)); 231 jPanel1.setPreferredSize(new java.awt.Dimension (1200, 250)); 232 jPanel1.setMaximumSize(new java.awt.Dimension (2000,300)); 233 cutButton.setIcon(new javax.swing.ImageIcon (getClass().getResource("/toolbarButtonGraphics/general/Cut24.gif"))); 234 cutButton.setToolTipText("Cut Aspect"); 235 cutButton.setFont(new java.awt.Font ("Dialog", 0, 11)); 236 cutButton.addActionListener(new java.awt.event.ActionListener () { 237 public void actionPerformed(java.awt.event.ActionEvent evt) { 238 cutButtonActionPerformed(evt); 239 } 240 }); 241 242 jToolBar1.add(cutButton); 243 244 copyButton.setIcon(new javax.swing.ImageIcon (getClass().getResource("/toolbarButtonGraphics/general/Copy24.gif"))); 245 copyButton.setToolTipText("Copy"); 246 copyButton.addActionListener(new java.awt.event.ActionListener () { 247 public void actionPerformed(java.awt.event.ActionEvent evt) { 248 copyButtonActionPerformed(evt); 249 } 250 }); 251 252 jToolBar1.add(copyButton); 253 254 pasteButton.setIcon(new javax.swing.ImageIcon (getClass().getResource("/toolbarButtonGraphics/general/Paste24.gif"))); 255 pasteButton.setToolTipText("Paste"); 256 pasteButton.addActionListener(new java.awt.event.ActionListener () { 257 public void actionPerformed(java.awt.event.ActionEvent evt) { 258 pasteButtonActionPerformed(evt); 259 } 260 }); 261 262 jToolBar1.add(pasteButton); 263 264 265 jTabbedPane1.setPreferredSize(new java.awt.Dimension (1200, 800)); 266 jTabbedPane1.setMinimumSize(new java.awt.Dimension (400, 200)); 267 jTabbedPane1.setAlignmentX(0.0F); 268 jTabbedPane1.setMaximumSize(new Dimension (2000,2000)); 269 jTabbedPane1.addChangeListener(new javax.swing.event.ChangeListener () { 270 public void stateChanged(javax.swing.event.ChangeEvent evt) { 271 jTabbedPane1StateChanged(evt); 272 } 273 }); 274 275 276 mainSplitPane.setLeftComponent(jTabbedPane1); 277 278 280 boxes.setLayout(new FlowLayout (FlowLayout.LEFT)); 281 282 boxes.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (8, 8, 8, 8))); 283 boxes.setPreferredSize(new java.awt.Dimension (300, 100)); 284 boxes.setMinimumSize(new java.awt.Dimension (572, 100)); 285 boxes.setMaximumSize(new java.awt.Dimension (2000, 100)); 286 checkBoxPanel.setLayout(new java.awt.GridLayout (3, 0, 0, 5)); 287 288 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)))); 289 checkBoxPanel.setMaximumSize(new java.awt.Dimension (160, 82)); 290 checkBoxPanel.setPreferredSize(new java.awt.Dimension (160, 82)); 291 checkBoxPanel.setMinimumSize(new java.awt.Dimension (160, 82)); 292 selectAspectButton.setToolTipText("Select to view 'Aspects' in the result"); 293 selectAspectButton.setModel(myModel.getSelectAspect()); 294 selectAspectButton.setFont(new java.awt.Font ("Luxi Sans", 1, 12)); 295 selectAspectButton.setText("Select Aspects"); 296 selectAspectButton.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (2, 2, 2, 2))); 297 selectAspectButton.addActionListener(new java.awt.event.ActionListener () { 298 public void actionPerformed(java.awt.event.ActionEvent evt) { 299 selectAspectButtonActionPerformed(evt); 300 } 301 }); 302 303 checkBoxPanel.add(selectAspectButton); 304 305 selectCrosscutButton.setToolTipText("Select to view 'Crosscuts' in the result"); 306 selectCrosscutButton.setModel(myModel.getSelectCrosscut()); 307 selectCrosscutButton.setFont(new java.awt.Font ("Luxi Sans", 1, 12)); 308 selectCrosscutButton.setText("Select Crosscuts"); 309 selectCrosscutButton.setPreferredSize(new java.awt.Dimension (130, 20)); 310 selectCrosscutButton.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (2, 2, 2, 2))); 311 selectCrosscutButton.setMaximumSize(new java.awt.Dimension (130, 20)); 312 selectCrosscutButton.setMinimumSize(new java.awt.Dimension (130, 20)); 313 selectCrosscutButton.addActionListener(new java.awt.event.ActionListener () { 314 public void actionPerformed(java.awt.event.ActionEvent evt) { 315 selectCrosscutButtonActionPerformed(evt); 316 } 317 }); 318 319 checkBoxPanel.add(selectCrosscutButton); 320 321 selectJoinpointButton.setToolTipText("Select to view 'Joinpoints' in the result"); 322 selectJoinpointButton.setModel(myModel.getSelectJoinpoint()); 323 selectJoinpointButton.setFont(new java.awt.Font ("Luxi Sans", 1, 12)); 324 selectJoinpointButton.setText("Select Joinpoints"); 325 selectJoinpointButton.setPreferredSize(new java.awt.Dimension (130, 20)); 326 selectJoinpointButton.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (2, 2, 2, 2))); 327 selectJoinpointButton.setMaximumSize(new java.awt.Dimension (130, 20)); 328 selectJoinpointButton.setMinimumSize(new java.awt.Dimension (130, 20)); 329 selectJoinpointButton.addActionListener(new java.awt.event.ActionListener () { 330 public void actionPerformed(java.awt.event.ActionEvent evt) { 331 selectJoinpointButtonActionPerformed(evt); 332 } 333 }); 334 335 checkBoxPanel.add(selectJoinpointButton); 336 337 boxes.add(checkBoxPanel); 338 339 radioBoxPanel.setLayout(new java.awt.GridLayout (3, 0, 0, 5)); 340 341 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)))); 342 radioBoxPanel.setPreferredSize(new java.awt.Dimension (160, 82)); 343 radioBoxPanel.setMinimumSize(new java.awt.Dimension (160, 82)); 344 radioBoxPanel.setMaximumSize(new java.awt.Dimension (160, 82)); 345 groupByAspectButton.setModel(myModel.getGroupByAspect()); 346 groupByAspectButton.setFont(new java.awt.Font ("LuxiSans", 1, 12)); 347 groupByAspectButton.setText("Group by Aspect"); 348 groupByGroup.add(groupByAspectButton); 349 groupByAspectButton.setPreferredSize(new java.awt.Dimension (130, 20)); 350 groupByAspectButton.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (20, 2, 20, 2))); 351 groupByAspectButton.setMaximumSize(new java.awt.Dimension (130, 20)); 352 groupByAspectButton.setMargin(new java.awt.Insets (20, 2, 2, 2)); 353 groupByAspectButton.setMinimumSize(new java.awt.Dimension (130, 20)); 354 groupByAspectButton.setBorderPainted(true); 355 groupByAspectButton.addActionListener(new java.awt.event.ActionListener () { 356 public void actionPerformed(java.awt.event.ActionEvent evt) { 357 groupByAspectButtonActionPerformed(evt); 358 } 359 }); 360 361 radioBoxPanel.add(groupByAspectButton); 362 363 groupByCrosscutButton.setFont(new java.awt.Font ("Luxi Sans", 1, 12)); 364 groupByCrosscutButton.setText("Group by Crosscut"); 365 groupByCrosscutButton.setModel(myModel.getGroupByCrosscut()); 366 groupByGroup.add(groupByCrosscutButton); 367 groupByCrosscutButton.setPreferredSize(new java.awt.Dimension (130, 20)); 368 groupByCrosscutButton.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (2, 2, 2, 2))); 369 groupByCrosscutButton.setMaximumSize(new java.awt.Dimension (130, 20)); 370 groupByCrosscutButton.setMargin(new java.awt.Insets (20, 2, 2, 2)); 371 groupByCrosscutButton.setMinimumSize(new java.awt.Dimension (130, 20)); 372 groupByCrosscutButton.addActionListener(new java.awt.event.ActionListener () { 373 public void actionPerformed(java.awt.event.ActionEvent evt) { 374 groupByCrosscutButtonActionPerformed(evt); 375 } 376 }); 377 378 radioBoxPanel.add(groupByCrosscutButton); 379 380 groupByJoinpointButton.setFont(new java.awt.Font ("Luxi Sans", 1, 12)); 381 382 groupByJoinpointButton.setText("Group by Joinpoint"); 383 384 groupByJoinpointButton.setModel(myModel.getGroupByJoinpoint()); 385 386 groupByGroup.add(groupByJoinpointButton); 387 388 groupByJoinpointButton.setPreferredSize(new java.awt.Dimension (130, 20)); 389 390 groupByJoinpointButton.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (2, 2, 2, 2))); 391 392 groupByJoinpointButton.setMaximumSize(new java.awt.Dimension (130, 20)); 393 394 395 groupByJoinpointButton.setMargin(new java.awt.Insets (20, 2, 2, 2)); 396 397 groupByJoinpointButton.setMinimumSize(new java.awt.Dimension (130, 20)); 398 399 400 groupByJoinpointButton.addActionListener(new java.awt.event.ActionListener () { 401 public void actionPerformed(java.awt.event.ActionEvent evt) { 402 groupByJoinpointButtonActionPerformed(evt); 403 } 404 }); 405 406 radioBoxPanel.add(groupByJoinpointButton); 407 408 boxes.add(radioBoxPanel); 409 410 411 buttons.setLayout(new GridLayout (3,2,5,5)); 412 415 queryButton.setToolTipText("Send the selected Items to the AspectManager and get the Result"); 416 queryButton.setFont(new java.awt.Font ("Luxi Sans", 1, 14)); 417 queryButton.setText("query"); 418 queryButton.setPreferredSize(new java.awt.Dimension (30,23 )); 419 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)); 420 queryButton.setMaximumSize(new java.awt.Dimension (160, 128)); 421 queryButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); 422 queryButton.setMinimumSize(new java.awt.Dimension (30, 23)); 423 queryButton.addActionListener(new java.awt.event.ActionListener () { 424 public void actionPerformed(java.awt.event.ActionEvent evt) { 425 queryButtonActionPerformed(evt); 426 } 427 }); 428 buttons.add(new JLabel ("query: sected cells")); 429 buttons.add(queryButton); 430 431 jp8QueryToolbar.setText("Q"); 432 jp8QueryToolbar.setFont(new java.awt.Font ("Luxi Sans", Font.BOLD, 18)); 433 jp8QueryToolbar.setForeground(new Color (0x765f91)); 434 jp8QueryToolbar.addActionListener(new java.awt.event.ActionListener () { 435 public void actionPerformed(java.awt.event.ActionEvent evt) { 436 queryButtonActionPerformed(evt); 437 } 438 }); 439 440 441 442 Dimension buttonDimension = new Dimension (50,23); 443 Dimension labelDimension = new Dimension (100,23); 444 445 446 447 448 allAspectsButton.setToolTipText("Retrieve all Aspects inserted in this AspectManager"); 449 allAspectsButton.setFont(new java.awt.Font ("Luxi Sans", 1, 12)); 450 allAspectsButton.setText("query"); 451 allAspectsButton.setPreferredSize(new java.awt.Dimension (30, 23)); 452 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)); 453 allAspectsButton.setMaximumSize(new java.awt.Dimension (128, 32)); 454 allAspectsButton.setMinimumSize(new java.awt.Dimension (30, 23)); 455 allAspectsButton.addActionListener(new java.awt.event.ActionListener () { 456 public void actionPerformed(java.awt.event.ActionEvent evt) { 457 allAspectsButtonActionPerformed(evt); 458 } 459 }); 460 buttons.add(new JLabel ("query: all aspects")); 461 buttons.add(allAspectsButton); 462 463 464 465 allJoinpointsButton.setToolTipText("Retrieve all Joinpoints inserted in this AspectManager"); 466 allJoinpointsButton.setFont(new java.awt.Font ("Luxi Sans", 1, 12)); 467 allJoinpointsButton.setText("query"); 468 allJoinpointsButton.setPreferredSize(new java.awt.Dimension (50, 23)); 469 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)); 470 allJoinpointsButton.setMaximumSize(new java.awt.Dimension (128, 32)); 471 allJoinpointsButton.setMinimumSize(new java.awt.Dimension (30, 23)); 472 allJoinpointsButton.addActionListener(new java.awt.event.ActionListener () { 473 public void actionPerformed(java.awt.event.ActionEvent evt) { 474 allJoinpointsButtonActionPerformed(evt); 475 } 476 }); 477 478 buttons.add(new JLabel ("query: all joinpoints")); 479 buttons.add(allJoinpointsButton); 480 481 482 boxes.add(buttons); 483 boxes.add(Box.createHorizontalGlue()); 484 485 486 487 488 jPanel1.add(textAreaScroller); 489 490 jPanel1.add(boxes); 491 492 textAreaScroller.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); 493 textAreaScroller.setPreferredSize(new java.awt.Dimension (500, 39)); 494 textAreaScroller.setMinimumSize(new java.awt.Dimension (50, 39)); 495 textAreaScroller.setMaximumSize(new java.awt.Dimension (2000, 100)); 496 textArea.setWrapStyleWord(true); 497 textArea.setLineWrap(true); 498 textArea.setEditable(false); 499 textArea.setRows(5); 500 textArea.setFont(new java.awt.Font ("Courier", 0, 11)); 501 textArea.setPreferredSize(new java.awt.Dimension (0, 70)); 502 textArea.setMargin(new java.awt.Insets (3, 3, 3, 3)); 503 textArea.setMinimumSize(new java.awt.Dimension (50, 40)); 504 textAreaScroller.setViewportView(textArea); 505 506 507 jPanel3Insertion.setLayout(new FlowLayout (FlowLayout.LEFT)); 508 510 JPanel classPathAndAspect = new JPanel (); 511 classPathAndAspect.setMaximumSize(new Dimension (1000,100)); 512 classPathAndAspect.setLayout(new BoxLayout (classPathAndAspect, BoxLayout.Y_AXIS)); 513 classPathAndAspect.add(Box.createVerticalGlue()); 514 classPathAndAspect.add(jPanel2); 515 classPathAndAspect.add(Box.createVerticalGlue()); 516 classPathAndAspect.add(jPanel4Classpath); 517 classPathAndAspect.add(Box.createVerticalGlue()); 518 519 jPanel3Insertion.add(Box.createHorizontalStrut(10)); 520 jPanel3Insertion.add(classPathAndAspect); 521 jPanel3Insertion.add(Box.createHorizontalGlue()); 524 525 jPanel3Insertion.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (8, 8, 8, 8))); 527 528 529 530 531 jPanel3Insertion.setPreferredSize(new java.awt.Dimension (541, 100)); 532 jPanel3Insertion.setMinimumSize(new java.awt.Dimension (541, 100)); 533 jPanel3Insertion.setMaximumSize(new java.awt.Dimension (2000, 100)); 534 535 jp5ConsoleArea.setDocument(myModel.getConsole()); 536 jp5ConsoleArea.setPreferredSize(new java.awt.Dimension (500,100)); 537 jp5ConsoleArea.setMinimumSize(new java.awt.Dimension (300,100)); 538 jp5ConsoleArea.setBackground(new Color (0xf9efe8)); 539 540 541 jp5ConsoleScroll.add(jp5ConsoleArea); 545 jp5ConsoleArea.revalidate(); 546 jp5ConsoleScroll.setViewportView(jp5ConsoleArea); 547 jp5ConsolePane.add(jp5ConsoleScroll); 548 549 jp5ConsolePane.setBorder(new javax.swing.border.TitledBorder ("Console")); 550 jp5ConsolePane.setLayout(new javax.swing.BoxLayout (jp5ConsolePane,javax.swing.BoxLayout.Y_AXIS)); 551 jp5ConsolePane.setMaximumSize(new java.awt.Dimension (1200,210)); 552 jp5ConsolePane.setPreferredSize(new java.awt.Dimension (510,210)); 553 554 jp5ConsoleArea.setEditable(false); 555 556 jPanel2.setLayout(new BoxLayout (jPanel2,BoxLayout.X_AXIS)); 557 jLabel1.setText("Aspect class "); 558 jLabel1.setPreferredSize(new Dimension (100,23)); 559 jLabel1.setMaximumSize(new Dimension (100,23)); 560 jLabel1.setMinimumSize(new Dimension (100,23)); 561 jPanel2.add(jLabel1); 562 563 564 classTextField.setDocument(myModel.getAspectClassNameModel()); 565 classTextField.setMaximumSize(new java.awt.Dimension (330, 23)); 566 classTextField.setPreferredSize(new java.awt.Dimension (330, 23)); 567 classTextField.setMinimumSize(new java.awt.Dimension (330, 23)); 568 classTextField.addActionListener(new java.awt.event.ActionListener () { 569 public void actionPerformed(java.awt.event.ActionEvent evt) { 570 classTextFieldActionPerformed(evt); 571 } 572 }); 573 574 jPanel2.add(classTextField); 575 jPanel2.add(insertAspect); 576 chooseClass.setText("..."); 577 chooseClass.setMaximumSize(new Dimension (75,23)); 578 chooseClass.setPreferredSize(new Dimension (75,23)); 579 chooseClass.addActionListener(new java.awt.event.ActionListener () { 580 public void actionPerformed(java.awt.event.ActionEvent evt) { 581 chooseClassActionPerformed(evt); 582 } 583 }); 584 585 586 587 588 jPanelSelectionInto.setLayout(new BoxLayout (jPanelSelectionInto,BoxLayout.Y_AXIS)); 589 jPanelSelectionInto.setBorder(new TitledBorder ("aspect insertion target")); 590 jPanelSelectionInto.add(useSelectionRadio); 591 jPanelSelectionInto.add(useAllRadio); 592 593 596 useSelectionRadio.setText("selected VM"); 597 useSelectionRadio.setModel(myModel.getInsertInSelection()); 598 selectionVsAllGroup.add(useSelectionRadio); 599 useSelectionRadio.setActionCommand("sel"); 600 useSelectionRadio.addActionListener(new java.awt.event.ActionListener () { 601 public void actionPerformed(java.awt.event.ActionEvent evt) { 602 useSelectionRadioActionPerformed(evt); 603 } 604 }); 605 606 608 609 useAllRadio.setText("all VMs"); 610 useAllRadio.setModel(myModel.getInsertInAllVM()); 611 selectionVsAllGroup.add(useAllRadio); 612 useAllRadio.setActionCommand("all"); 613 615 616 jPanel4Classpath.setLayout(new javax.swing.BoxLayout (jPanel4Classpath,javax.swing.BoxLayout.X_AXIS)); 617 jPanel4Classpath.add(jp4CpathLabel); 618 jPanel4Classpath.add(jp4CpathField); 619 jPanel4Classpath.add(chooseClass); 620 jPanel4Classpath.add(javax.swing.Box.createHorizontalGlue()); 621 jp4CpathField.setDocument(getModel().getClasspathModel()); 622 623 624 625 jp4CpathField.setMinimumSize(new java.awt.Dimension (330, 23)); 626 jp4CpathField.setPreferredSize(new java.awt.Dimension (330, 23)); 627 jp4CpathField.setMaximumSize(new java.awt.Dimension (330, 23)); 628 jp4CpathLabel.setText("Classpath "); 629 jp4CpathLabel.setMaximumSize(new Dimension (100,23)); 630 jp4CpathLabel.setPreferredSize(new Dimension (100,23)); 631 jp4CpathLabel.setMinimumSize(new Dimension (100,23)); 632 633 634 jp7refreshVMButton.setIcon(new javax.swing.ImageIcon (getClass().getResource("/toolbarButtonGraphics/general/Refresh24.gif"))); 636 jp7refreshVMButton.addActionListener(new ActionListener () { 638 public void actionPerformed(java.awt.event.ActionEvent evt) { 639 refreshConnectedVMs(); 640 }}); 641 642 643 644 jp6StartTx.setText("Start TX"); 645 jp6StartTx.setMargin(new Insets (7,2,6,2)); 646 jp6StartTx.addActionListener(new ActionListener () { 647 public void actionPerformed(java.awt.event.ActionEvent evt) { 648 startTxActionPerformed(evt); 649 }}); 650 651 jp6CommitTx.setText("Commit TX"); 652 jp6CommitTx.setMargin(new Insets (7,2,6,2)); 653 jp6CommitTx.setBackground(new Color (0x39964)); 654 jp6CommitTx.addActionListener(new ActionListener () { 655 public void actionPerformed(java.awt.event.ActionEvent evt) { 656 commitTxActionPerformed(evt); 657 }}); 658 659 jp6AbortTx.setText("Abort TX"); 660 jp6AbortTx.setMargin(new Insets (7,2,6,2)); 661 jp6AbortTx.setBackground(new Color (0xf95e5e)); 662 jp6AbortTx.addActionListener(new ActionListener () { 663 public void actionPerformed(java.awt.event.ActionEvent evt) { 664 abortTxActionPerformed(evt); 665 }}); 666 jToolBar1.addSeparator(); 667 jToolBar1.add(jp6StartTx); 668 jToolBar1.add(jp6CommitTx); 669 jToolBar1.add(jp6AbortTx); 670 jToolBar1.addSeparator(); 671 jToolBar1.add(jp7refreshVMButton); 672 jToolBar1.addSeparator(); 673 jToolBar1.add(jp8QueryToolbar); 674 675 676 getContentPane().add(jToolBar1,BorderLayout.NORTH); 677 678 680 681 jPanel2.add(jLabel3); 682 insertAspect.setText("insert"); 683 insertAspect.setMaximumSize(new Dimension (75,23)); 684 insertAspect.setPreferredSize(new Dimension (75,23)); 685 686 insertAspect.addActionListener(new java.awt.event.ActionListener () { 687 public void actionPerformed(java.awt.event.ActionEvent evt) { 688 insertAspectActionPerformed(evt); 689 } 690 }); 691 jPanel2.add(Box.createHorizontalGlue()); 692 693 694 jPanel1.add(jPanel3Insertion); 695 696 Box resizablePanel1 = new Box (BoxLayout.X_AXIS); 697 resizablePanel1.add(Box.createVerticalStrut(200)); 701 mainSplitPane.setRightComponent(jPanel1); 702 703 getContentPane().add(jp5ConsolePane,BorderLayout.SOUTH); 705 706 menuFile.setMnemonic('F'); 707 menuFile.setText("File"); 708 709 loadItem.setText("Load conf"); 710 loadItem.addActionListener(new java.awt.event.ActionListener () { 711 public void actionPerformed(java.awt.event.ActionEvent evt) { 712 loadMenuAction(evt); 713 } 714 }); 715 716 saveItem.setText("Save conf"); 717 saveItem.addActionListener(new java.awt.event.ActionListener () { 718 public void actionPerformed(java.awt.event.ActionEvent evt) { 719 saveMenuAction(evt); 720 } 721 }); 722 723 quitItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.ALT_MASK)); 724 quitItem.setText("Quit"); 725 quitItem.addActionListener(new java.awt.event.ActionListener () { 726 public void actionPerformed(java.awt.event.ActionEvent evt) { 727 quitMenuAction(evt); 728 } 729 }); 730 731 732 menuFile.add(saveItem); 733 menuFile.add(loadItem); 734 menuFile.add(quitItem); 735 736 jMenuBar1.add(menuFile); 737 738 menuEdit.setMnemonic('E'); 739 menuEdit.setText("Edit"); 740 copyItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK)); 741 copyItem.setText("Copy"); 742 copyItem.addActionListener(new java.awt.event.ActionListener () { 743 public void actionPerformed(java.awt.event.ActionEvent evt) { 744 copyButtonActionPerformed(evt); 745 } 746 }); 747 748 menuEdit.add(copyItem); 749 750 pasteItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.CTRL_MASK)); 751 pasteItem.setText("Paste"); 752 pasteItem.addActionListener(new java.awt.event.ActionListener () { 753 public void actionPerformed(java.awt.event.ActionEvent evt) { 754 pasteButtonActionPerformed(evt); 755 } 756 }); 757 758 menuEdit.add(pasteItem); 759 760 cutItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK)); 761 cutItem.setText("Cut"); 762 cutItem.addActionListener(new java.awt.event.ActionListener () { 763 public void actionPerformed(java.awt.event.ActionEvent evt) { 764 cutButtonActionPerformed(evt); 765 } 766 }); 767 768 menuEdit.add(cutItem); 769 770 jMenuBar1.add(menuEdit); 771 772 menuVM.setMnemonic('V'); 773 menuVM.setText("VM"); 774 addVMItem.setText("Add VM"); 775 addVMItem.addActionListener(new java.awt.event.ActionListener () { 776 public void actionPerformed(java.awt.event.ActionEvent evt) { 777 addVMAction(evt); 778 } 779 }); 780 781 menuVM.add(addVMItem); 782 783 removeVMItem.setText("Remove VM"); 784 removeVMItem.addActionListener(new java.awt.event.ActionListener () { 785 public void actionPerformed(java.awt.event.ActionEvent evt) { 786 removeVMAction(evt); 787 } 788 }); 789 790 menuVM.add(removeVMItem); 791 792 jMenuBar1.add(menuVM); 793 794 setJMenuBar(jMenuBar1); 795 796 } 798 private void useSelectionRadioActionPerformed(java.awt.event.ActionEvent evt) { 799 } 802 private void insertAspectActionPerformed(java.awt.event.ActionEvent evt) 803 { 804 try 805 { 806 myModel.insertAspect(); 807 jp5ConsoleArea.revalidate(); 808 } 809 catch (Exception e) 810 { 811 showException(this,e); 812 } 813 814 } 816 private void chooseClassActionPerformed(java.awt.event.ActionEvent evt) { 817 int returnVal = commonFileChooser.showOpenDialog(this); 819 if(returnVal == JFileChooser.APPROVE_OPTION) { 820 commonFileChooser.setCurrentDirectory(commonFileChooser.getSelectedFile().getParentFile()); 821 myModel.appendToClasspath(commonFileChooser.getSelectedFile().getAbsolutePath()); 822 } 823 824 825 } 827 private void classTextFieldActionPerformed(java.awt.event.ActionEvent evt) { 828 829 } 830 831 private void cutButtonActionPerformed(java.awt.event.ActionEvent evt) { 832 833 Object [] options = {"Insert", "Cancel"}; 834 int n = JOptionPane.showConfirmDialog(this, 835 "You will delete several elements permanently from PROSE!", 836 "Confirmation Message", 837 JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE); 838 if (n == 1) 839 return; 840 841 try 842 { myModel.cutSelection(); } 843 catch (Exception e) 844 { showException(this,e); } 845 } 846 847 private void pasteButtonActionPerformed(java.awt.event.ActionEvent evt) 848 { 849 Object [] options = {"Insert", "Cancel"}; 850 int n = JOptionPane.showConfirmDialog(this, 851 "You will insert several element permanently into PROSE!", 852 "Confirmation Message", 853 JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE); 854 if (n == 1) 855 return; 856 857 try 858 { myModel.pasteSelection(); } 859 catch (Exception e) 860 { showException(this,e);} 861 } 862 863 private void copyButtonActionPerformed(java.awt.event.ActionEvent evt) 864 { 865 try 866 { myModel.copySelection(); } 867 catch (Exception e) 868 { showException(this,e); } 869 } 870 871 872 873 protected void newTextAreaContent(String content) { 874 textArea.setText(content); 875 } 876 877 private void jTabbedPane1StateChanged(javax.swing.event.ChangeEvent evt) { 878 JTabbedPane tabbedPane = (JTabbedPane )evt.getSource(); 879 if (tabbedPane.getSelectedComponent() != null) 880 ((JWorksheetProseClientPane)tabbedPane.getSelectedComponent()).select(); 881 } 882 883 private void removeVMAction(java.awt.event.ActionEvent evt) { 891 JRemoveVMDialog removeVMDialog = new JRemoveVMDialog(this, false); 892 removeVMDialog.setVisible(true); 893 } 895 private void addVMAction(java.awt.event.ActionEvent evt) { AddVMDialog addVMDialog = new AddVMDialog(this, false); 897 addVMDialog.setVisible(true); 898 } 900 901 private void startTxActionPerformed(ActionEvent event){ 902 try 903 { 904 myModel.startTransaction(); 905 jp6StartTx.setEnabled(false); 906 jp6AbortTx.setEnabled(true); 907 jp6CommitTx.setEnabled(true); 908 } 909 catch (Exception e) 910 { showException(this,e); } 911 } 912 913 private void commitTxActionPerformed(ActionEvent evt) 914 { 915 try 916 { 917 myModel.commitTransaction(false); 918 jp6StartTx.setEnabled(true); 919 jp6AbortTx.setEnabled(false); 920 jp6CommitTx.setEnabled(false); 921 } 922 catch (Exception e) 923 { 924 int n = JOptionPane.showConfirmDialog(this, "An error occurred during the commit of the current transaction\n" 925 + "\nError message: \n---------------------\n" + 926 e.getMessage() 927 + "\n---------------------\n" 928 + "\n Proceed with commit? By answering 'NO', you may later perform" 929 + "\n additional operations or abort the transaction. By answering 'YES'" 930 + "\n all active nodes will commit, while disonnected nodes are left" 931 + "\n out of this transaction", 932 "Errors during commit" 933 , JOptionPane.YES_NO_OPTION); 934 if (n == JOptionPane.NO_OPTION) 935 return; 936 else if (n == JOptionPane.YES_OPTION) 937 { 938 try { myModel.commitTransaction(true); } 939 catch (Exception e1) { showException(this,e);} 940 jp6StartTx.setEnabled(true); 941 jp6AbortTx.setEnabled(false); 942 jp6CommitTx.setEnabled(false); 943 944 } 945 } 946 947 } 948 949 private void abortTxActionPerformed(ActionEvent evt) 950 { 951 try { myModel.abortTransaction(true); } 952 catch (Exception e) 953 { showException(this,e); } 954 jp6StartTx.setEnabled(true); 955 jp6AbortTx.setEnabled(false); 956 jp6CommitTx.setEnabled(false); 957 } 958 959 private void selectJoinpointButtonActionPerformed(java.awt.event.ActionEvent evt) { 960 try { myModel.getActualTableModel().setDisplayJoinpoint(); } 961 catch (Exception e) {showException(this,e);} 962 } 964 private void selectCrosscutButtonActionPerformed(java.awt.event.ActionEvent evt) { 965 try { myModel.getActualTableModel().setDisplayCrosscut();} 966 catch (Exception e) {showException(this,e);} 967 } 969 private void selectAspectButtonActionPerformed(java.awt.event.ActionEvent evt) { 970 try { myModel.getActualTableModel().setDisplayAspect(); } 971 catch (Exception e) {showException(this,e);} 972 } 974 private void groupByJoinpointButtonActionPerformed(java.awt.event.ActionEvent evt) { 975 976 try { myModel.getActualTableModel().setGroupByJoinpoint();} 977 catch (Exception e) {showException(this,e);} 978 979 } 981 private void groupByCrosscutButtonActionPerformed(java.awt.event.ActionEvent evt) { 982 try { myModel.getActualTableModel().setGroupByCrosscut(); } 983 catch (Exception e) {showException(this,e);} 984 } 986 private void allJoinpointsButtonActionPerformed(java.awt.event.ActionEvent evt) { 987 try 988 { 989 myModel.getActualTableModel().allJoinpoints(); 990 this.validate(); 991 } 992 catch (Exception e) 993 { 994 showException(this,e); 995 } 996 } 997 998 private void allAspectsButtonActionPerformed(java.awt.event.ActionEvent evt) { 999 try 1000 { 1001 myModel.getActualTableModel().allAspects(); 1002 this.validate(); 1003 } 1004 catch (Exception e) 1005 { 1006 showException(this,e); 1007 } 1008 } 1009 1010 private void queryButtonActionPerformed(java.awt.event.ActionEvent evt) 1011 { 1012 try 1013 { 1014 if (myModel.getActualTableModel().data == null) 1015 { 1016 JOptionPane.showMessageDialog(this, "Please press button 'AllAspects' or 'AllJoinpoints' first.", 1017 "query information", JOptionPane.INFORMATION_MESSAGE); 1018 return; 1019 } 1020 1021 if (myModel.getActualTableModel().selectedCells.length == 0) 1022 { 1023 JOptionPane.showMessageDialog(this, "No cells are selected.", 1024 "query warning", JOptionPane.WARNING_MESSAGE); 1025 return; 1026 } 1027 if (myModel.getActualTableModel().select == 0) 1028 { 1029 JOptionPane.showMessageDialog(this, "At least one 'Select'-Checkbox must be enabled.", 1030 "query warning", JOptionPane.WARNING_MESSAGE); 1031 return; 1032 } 1033 1034 for (int i=0; i < myModel.getActualTableModel().selectedCells.length; i++) 1035 if ((((Vector )myModel.getActualTableModel().data.get(myModel.getActualTableModel().selectedCells[i])) 1036 .get(myModel.getActualTableModel().getSelectedColumn()) == null) 1037 || (((Vector )myModel.getActualTableModel().data.get(myModel.getActualTableModel().selectedCells[i])) 1038 .get(myModel.getActualTableModel().getSelectedColumn()).toString().equals("#NULL#"))) 1039 { 1040 JOptionPane.showMessageDialog(this, "It is not allowed to select empty cells!", 1041 "query warning", JOptionPane.WARNING_MESSAGE); 1042 return; 1043 } 1044 if (myModel.getActualTableModel().isMixedSelection()) 1045 { 1046 JOptionPane.showMessageDialog(this, "Don't mix pasted content with normal content for querying", 1047 "query warning", JOptionPane.WARNING_MESSAGE); 1048 return; 1049 } 1050 1051 1052 myModel.getActualTableModel().query(); 1053 this.validate(); 1054 } 1055 catch (Exception e) 1056 { 1057 showException(this,e); 1058 } 1059 } 1060 1061 1063 private void groupByAspectButtonActionPerformed(java.awt.event.ActionEvent evt) { 1064 try { myModel.getActualTableModel().setGroupByAspect(); } 1065 catch (Exception e) { showException(this,e); } 1066 } 1068 1069 private void quitMenuAction(java.awt.event.ActionEvent evt) { exitGUI(); 1071 } 1073 1074 private void loadMenuAction(java.awt.event.ActionEvent evt) 1075 { 1076 JFileChooser chooser = new JFileChooser (); 1077 int returnVal = chooser.showOpenDialog(this); 1078 if(returnVal == JFileChooser.APPROVE_OPTION) 1079 { 1080 try 1081 { 1082 memoFromFile(chooser.getSelectedFile()); 1083 } 1084 catch (Exception e) 1085 { showException(this,e); } 1086 } 1087 } 1088 1089 1090 private void saveMenuAction(java.awt.event.ActionEvent evt) 1091 { 1092 JFileChooser chooser = new JFileChooser (); 1093 int returnVal = chooser.showSaveDialog(this); 1094 if(returnVal == JFileChooser.APPROVE_OPTION) 1095 { 1096 try 1097 { 1098 memoToFile(chooser.getSelectedFile()); 1099 } 1100 catch (Exception e) 1101 { showException(this,e); } 1102 } 1103 } 1104 1105 1106 private void customizeComponents() throws java.rmi.RemoteException , java.rmi.NotBoundException , java.net.MalformedURLException 1107 { 1108 this.addWindowListener(new WindowAdapter () { 1109 public void windowClosing(WindowEvent e) { exitGUI(); } 1110 }); 1111 commonFileChooser= new JFileChooser (); 1112 commonFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 1113 } 1114 1115 1116 protected JWorksheetProseClientPane getTab(String name) 1117 { 1118 int at = jTabbedPane1.indexOfTab(name); 1119 if (at != -1) 1120 return (JWorksheetProseClientPane)jTabbedPane1.getComponentAt(at); 1121 else 1122 return null; 1123 } 1124 1125 protected void addTab(String n, String host, String port, boolean doRefresh) 1126 throws MalformedURLException, NotBoundException, RemoteException, IllegalUserInputException, java.net.UnknownHostException 1127 { 1128 if (n == null || n.trim().equals("")) 1129 throw new IllegalUserInputException("Please specify a name"); 1130 if (getTab(n) != null) 1131 throw new IllegalUserInputException("The name '" + n + "' is already used!"); 1132 if (host == null || host.trim().equals("")) 1133 throw new IllegalUserInputException("Please specify a host"); 1134 if (port == null || port.trim().equals("")) 1135 throw new IllegalUserInputException("Please specify a port"); 1136 1137 JWorksheetProseClientPane newWindow = new JWorksheetProseClientPane(this,n,host,port); 1138 newWindow.setDividerLocation(0.5); 1139 newWindow.setDividerSize(5); 1140 jTabbedPane1.addTab(n, newWindow); 1141 1142 1143 newWindow.customizeTable(newWindow.getLeftTable()); 1144 newWindow.customizeTable(newWindow.getRightTable()); 1145 1146 jTabbedPane1.setSelectedComponent(newWindow); 1147 newWindow.select(); 1148 jTabbedPane1.setEnabledAt(jTabbedPane1.indexOfTab(n),false); 1149 if (doRefresh) 1150 { 1151 ((WorksheetSingleClientModel)newWindow.getLeftTable().getModel()).refresh(); 1152 ((WorksheetSingleClientModel)newWindow.getRightTable().getModel()).refresh(); 1153 jTabbedPane1.setEnabledAt(jTabbedPane1.indexOfTab(n),true); 1154 } 1155 } 1156 1157 public static void showException(java.awt.Component ctx, Exception e) 1158 { 1159 1160 if (e.getClass().equals(java.rmi.NotBoundException .class)) 1161 { 1162 JOptionPane.showMessageDialog(ctx, "The please verify that the remote prose vm is correctly started", 1163 "connection error", JOptionPane.ERROR_MESSAGE); 1164 } 1165 else if (e.getClass().equals(NotBoundException.class)) 1166 { 1167 JOptionPane.showMessageDialog(ctx, "Please verify that the remote prose vm is correctly started.\nCause:" + e.getMessage(), 1168 "connection error", JOptionPane.ERROR_MESSAGE); 1169 } 1170 else if (e.getClass().equals(java.rmi.RemoteException .class)) 1171 { 1172 JOptionPane.showMessageDialog(ctx, "Connection error. Remote prose (host, port) " + 1173 "is not responding.\nCause:" + e.getMessage(),"connection errror", JOptionPane.ERROR_MESSAGE); 1174 } 1175 else if (e.getClass().equals(IllegalUserInputException.class)) 1176 { 1177 JOptionPane.showMessageDialog(ctx,e.getMessage(),"Illegal input",JOptionPane.ERROR_MESSAGE); 1178 } 1179 else if (e.getClass().equals(java.rmi.ConnectException .class)) 1180 { 1181 JOptionPane.showMessageDialog(ctx,"Cannot connect to the specified address. \n Cause:" + e.getMessage(),"connection error" 1182 ,JOptionPane.ERROR_MESSAGE); 1183 } 1184 else if (e.getClass().equals(PasteAspectsException.class)) 1185 { 1186 JOptionPane.showMessageDialog(ctx,"Problems encoutered during aspect insertion:\n" 1187 + e.getMessage(),"weaving warning",JOptionPane.WARNING_MESSAGE); 1188 } 1189 else if (e.getClass().equals(WithdrawAspectsException.class)) 1190 { 1191 JOptionPane.showMessageDialog(ctx,"Problems encoutered during aspect deletion:\n" 1192 + e.getMessage(),"unweaving warning",JOptionPane.WARNING_MESSAGE); 1193 } 1194 else if (e.getClass().equals(TableSelectionException.class)) 1195 { 1196 JOptionPane.showMessageDialog(ctx,e.getMessage(),"selection warning",JOptionPane.WARNING_MESSAGE); 1197 } 1198 else if (e.getClass().equals(TransactionFinishException.class)) 1199 { 1200 JOptionPane.showMessageDialog(ctx,e.getMessage(),"transaction warning",JOptionPane.WARNING_MESSAGE); 1201 } 1202 else if (e.getClass().equals(java.rmi.UnknownHostException .class)) 1203 { 1204 JOptionPane.showMessageDialog(ctx,e.getMessage(),"unknown host",JOptionPane.WARNING_MESSAGE); 1205 } 1206 else 1207 { 1208 e.printStackTrace(); 1209 JOptionPane.showMessageDialog(ctx,"Unknown exeception:" + e.toString(),"unknown error",JOptionPane.ERROR_MESSAGE); 1210 } 1211 } 1212 1213 protected void removeTab(String name) 1214 { 1215 JWorksheetProseClientPane jpw = getTab(name); 1216 if (jTabbedPane1.getSelectedIndex() == jTabbedPane1.indexOfTab(name)) 1217 { 1218 jTabbedPane1.remove(jpw); 1219 if (jTabbedPane1.getTabCount() >0) 1220 { 1221 jTabbedPane1.setSelectedIndex(0); 1222 ((JWorksheetProseClientPane)jTabbedPane1.getComponentAt(0)).select(); 1223 } 1224 } 1225 else 1226 jTabbedPane1.remove(jpw); 1227 myModel.removeVM(name); 1228 } 1229 1230 public MultipleClientModel getModel() 1231 { 1232 return myModel; 1233 } 1234 1235 private void exitGUI() 1236 { 1237 System.exit(0); 1238 } 1239 1240 1243 public static void main(String args[]) 1244 { 1245 JFrame f = new JMultipleProseClient(); 1246 f.pack(); 1247 f.show(); 1248 } 1249 1250 static class TabInfo implements java.io.Serializable 1251 { 1252 String tname; 1253 String thost; 1254 String tport; 1255 public 1256 boolean equals(Object obj) 1257 { 1258 return 1259 obj instanceof TabInfo && 1260 TabInfo.this.tname.equals(((TabInfo) obj).tname); 1261 } 1262 1263 public int hashCode() 1264 { 1265 return tname.hashCode(); 1266 } 1267 } 1268 1269 1270 1271 1272 public void memoToFile(java.io.File f) throws java.io.FileNotFoundException , java.io.OptionalDataException , java.io.IOException 1273 { 1274 String classPath = myModel.getClasspath(); 1275 String aspectName = myModel.getAspectClassName(); 1276 Set h = new HashSet(); 1277 Iterator i = myModel.getAllVM().iterator(); 1278 while (i.hasNext()) 1279 { 1280 WorksheetSingleClientModel m = (WorksheetSingleClientModel)i.next(); 1281 TabInfo t = new TabInfo(); 1282 t.tname = m.getName(); 1283 t.thost = m.getHost(); 1284 t.tport = m.getPort(); 1285 h.add(t); 1286 } 1287 ObjectOutputStream objOut = new ObjectOutputStream (new FileOutputStream (f)); 1288 objOut.writeObject(classPath); 1289 objOut.writeObject(aspectName); 1290 objOut.writeObject(h); 1291 objOut.close(); 1292 } 1293 1294 public void memoFromFile(java.io.File f) 1295 throws java.io.FileNotFoundException , java.io.OptionalDataException , java.net.MalformedURLException ,java.io.IOException , java.rmi.NotBoundException , IllegalUserInputException 1296 { 1297 ObjectInputStream oi = new ObjectInputStream (new FileInputStream (f)); 1298 try 1299 { 1300 String classPath = (String )oi.readObject(); 1301 String aspectName = (String )oi.readObject(); 1302 Set h = (Set)oi.readObject(); 1303 1304 jp4CpathField.setText(classPath); 1305 classTextField.setText(aspectName); 1306 1307 Iterator i = h.iterator(); 1308 while (i.hasNext()) 1309 { 1310 TabInfo t = (TabInfo)i.next(); 1311 addTab(t.tname,t.thost,t.tport,false); 1312 } 1313 } 1314 catch (ClassNotFoundException e) 1315 { 1316 throw new Error ("All classes here are known"); 1317 } 1318 refreshConnectedVMs(); 1319 } 1320 1321 1323 private javax.swing.JSplitPane mainSplitPane; 1324 1325 private javax.swing.JTabbedPane jTabbedPane1; 1326 private javax.swing.JScrollPane textAreaScroller; 1327 private javax.swing.JButton pasteButton; 1328 private javax.swing.JToolBar jToolBar1; 1329 private javax.swing.JToolBar jToolBar3; 1330 private javax.swing.JToolBar jToolBar2; 1331 private javax.swing.JRadioButton groupByAspectButton; 1332 private javax.swing.JCheckBox selectJoinpointButton; 1333 private javax.swing.JButton insertAspect; 1334 private javax.swing.ButtonGroup groupByGroup; 1335 private javax.swing.JMenu menuEdit; 1336 private javax.swing.JMenuItem copyItem; 1337 private javax.swing.JMenuItem quitItem; 1338 private javax.swing.JRadioButton useSelectionRadio; 1339 private javax.swing.JPanel checkBoxPanel; 1340 private javax.swing.JPanel radioBoxPanel; 1341 private javax.swing.JRadioButton groupByJoinpointButton; 1342 private javax.swing.JButton allJoinpointsButton; 1343 private javax.swing.JMenuBar jMenuBar1; 1344 private javax.swing.JButton chooseClass; 1345 private javax.swing.JCheckBox selectCrosscutButton; 1346 private javax.swing.JTextField classTextField; 1347 private javax.swing.JTextArea textArea; 1348 private javax.swing.JMenuItem pasteItem; 1349 private javax.swing.JPanel buttons; 1350 private javax.swing.JButton copyButton; 1351 private javax.swing.JPanel jPanel3Insertion; 1352 private javax.swing.JLabel jp4CpathLabel; 1353 private javax.swing.JPanel jPanel4Classpath; 1354 private javax.swing.JTextField jp4CpathField; 1355 private javax.swing.JButton jp4EditCpathButton; 1356 private javax.swing.JFileChooser jp4AddCpathDir; 1357 1358 private javax.swing.JPanel jp5ConsolePane ; 1359 private javax.swing.JScrollPane jp5ConsoleScroll; 1360 private javax.swing.JTextPane jp5ConsoleArea ; 1361 1362 private javax.swing.JPanel jPanel2; 1363 private javax.swing.JPanel jPanel1; 1364 private javax.swing.JCheckBox selectAspectButton; 1365 private javax.swing.JButton queryButton; 1366 private javax.swing.JMenuItem removeVMItem; 1367 private javax.swing.JButton allAspectsButton; 1368 private javax.swing.JButton cutButton; 1369 private javax.swing.JMenu menuVM; 1370 private javax.swing.JPanel boxes; 1371 private javax.swing.JLabel jLabel3; 1372 private javax.swing.JLabel jLabel2; 1373 private javax.swing.JLabel jLabel1; 1374 private javax.swing.JMenu menuFile; 1375 private javax.swing.ButtonGroup selectionVsAllGroup; 1376 private javax.swing.JMenuItem cutItem; 1377 private javax.swing.JMenuItem addVMItem; 1378 private javax.swing.JRadioButton useAllRadio; 1379 private javax.swing.JRadioButton groupByCrosscutButton; 1380 1381 private javax.swing.JPanel jPanelSelectionInto = new JPanel (); 1382 1383 private javax.swing.JPanel jp6transactionPane; 1384 private javax.swing.JButton jp6StartTx; 1385 private javax.swing.JButton jp6CommitTx; 1386 private javax.swing.JButton jp6AbortTx; 1387 1388 private javax.swing.JButton jp7refreshVMButton; 1389 private javax.swing.JButton jp8QueryToolbar; 1390 1391 private javax.swing.JMenuItem saveItem; 1392 private javax.swing.JMenuItem loadItem; 1393 1395} 1396 | Popular Tags |