Source code: org/aspectj/tools/ajde/jbuilder/AJBrowserAction.java
1
2 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3 *
4 * This file is part of the IDE support for the AspectJ(tm)
5 * programming language; see http://aspectj.org
6 *
7 * The contents of this file are subject to the Mozilla Public License
8 * Version 1.1 (the "License"); you may not use this file except in
9 * compliance with the License. You may obtain a copy of the License at
10 * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
11 *
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 * for the specific language governing rights and limitations under the
15 * License.
16 *
17 * The Original Code is AspectJ.
18 *
19 * The Initial Developer of the Original Code is Xerox Corporation. Portions
20 * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
21 * All Rights Reserved.
22 *
23 * Contributor(s):
24 */
25
26 package org.aspectj.tools.ajde.jbuilder;
27
28 import javax.swing.*;
29 import java.awt.*;
30 import java.awt.event.*;
31 import java.util.*;
32 import java.io.*;
33 import com.borland.primetime.ide.*;
34 import com.borland.primetime.actions.*;
35 import com.borland.primetime.ui.DefaultDialog;
36 import com.borland.primetime.node.*;
37 import com.borland.jbuilder.node.*;
38 import com.borland.primetime.editor.*;
39 import com.borland.primetime.ide.*;
40 import com.borland.primetime.viewer.*;
41 import com.borland.jbuilder.runtime.*;
42 import com.borland.primetime.runtime.*;
43 import com.borland.primetime.util.VetoException;
44 import com.borland.primetime.vfs.Url;
45 import org.aspectj.ajde.*;
46 import org.aspectj.ajde.ui.*;
47 import org.aspectj.ajde.ui.swing.*;
48
49 /**
50 * @author Mik Kersten
51 */
52 public class AJBrowserAction extends AJAction {
53
54 private boolean isActive = false;
55 private Component projectView = null;
56
57 public AJBrowserAction() {
58 super(
59 "AspectJ Browser",
60 'H',
61 "Start the AspectJ Browser",
62 JBuilderManager.getJBuilderIconRegistry().getAJBrowserDisabledIcon()
63 );
64 }
65
66 public void actionPerformed(Browser browser) {
67 try {
68 if (!isActive) {
69 enable();
70 } else {
71 disable();
72 }
73 } catch (Throwable t) {
74 Ajde.getDefault().getErrorHandler().handleError("Could not start browser.", t);
75 }
76 }
77
78 public void enable() {
79 projectView = Browser.getActiveBrowser().getProjectView().getComponent(1);
80 Browser.getActiveBrowser().getProjectView().remove(projectView);
81 Browser.getActiveBrowser().getProjectView().add(AjdeUIManager.getDefault().getViewManager().getBrowserPanel(), 1);
82 //AjdeUIManager.getDefault().getViewManager().getBrowserPanel().
83 isActive = true;
84 AjdeUIManager.getDefault().getViewManager().getBrowserPanel().repaint();
85 this.setSmallIcon(JBuilderManager.getJBuilderIconRegistry().getAJBrowserEnabledIcon());
86
87 }
88
89 public void disable() {
90 Browser.getActiveBrowser().getProjectView().remove(AjdeUIManager.getDefault().getViewManager().getBrowserPanel());
91 if (projectView != null) {
92 Browser.getActiveBrowser().getProjectView().add(projectView);
93 Browser.getActiveBrowser().getProjectView().refreshTree();
94 isActive = false;
95 this.setSmallIcon(JBuilderManager.getJBuilderIconRegistry().getAJBrowserDisabledIcon());
96 }
97 }
98 }
99
100