2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
42
package org.netbeans.modules.debugger.ui.actions;
44
import java.awt.Component;
45
import java.awt.event.ActionEvent;
46
import java.awt.event.ActionListener;
47
import java.awt.image.BufferedImage;
48
import java.beans.PropertyChangeListener;
49
import javax.swing.Action;
50
import javax.swing.ImageIcon;
51
import javax.swing.JButton;
52
import javax.swing.JMenuItem;
53
import javax.swing.JPopupMenu;
54
import org.netbeans.spi.project.ActionProvider;
55
import org.netbeans.spi.project.ui.support.MainProjectSensitiveActions;
56
import org.openide.awt.Actions;
57
import org.openide.awt.DropDownButtonFactory;
58
import org.openide.util.Exceptions;
59
import org.openide.util.Lookup;
60
import org.openide.util.NbBundle;
61
import org.openide.util.Utilities;
62
import org.openide.util.actions.Presenter;
63
import org.openide.util.lookup.Lookups;
67
* @author Martin Entlicher
69
public class DebugMainProjectAction implements Action, Presenter.Toolbar {
71
private Action delegate;
73
/** Creates a new instance of DebugMainProjectAction */
74
public DebugMainProjectAction() {
75
delegate = MainProjectSensitiveActions.mainProjectCommandAction(
76
ActionProvider.COMMAND_DEBUG,
77
NbBundle.getMessage(DebugMainProjectAction.class, "LBL_DebugMainProjectAction_Name" ),
78
new ImageIcon(Utilities.loadImage( "org/netbeans/modules/debugger/resources/debugProject.png" ))); // NOI18N
79
delegate.putValue("iconBase","org/netbeans/modules/debugger/resources/debugProject.png"); //NOI18N
82
public Object getValue(String arg0) {
83
return delegate.getValue(arg0);
86
public void putValue(String arg0, Object arg1) {
87
delegate.putValue(arg0, arg1);
90
public void setEnabled(boolean arg0) {
91
delegate.setEnabled(arg0);
94
public boolean isEnabled() {
95
return delegate.isEnabled();
98
public void addPropertyChangeListener(PropertyChangeListener arg0) {
99
delegate.addPropertyChangeListener(arg0);
102
public void removePropertyChangeListener(PropertyChangeListener arg0) {
103
delegate.removePropertyChangeListener(arg0);
106
public void actionPerformed(ActionEvent arg0) {
107
delegate.actionPerformed(arg0);
110
public Component getToolbarPresenter() {
111
JPopupMenu menu = new JPopupMenu();
112
JButton button = DropDownButtonFactory.createDropDownButton(
113
new ImageIcon(new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB)), menu);
114
JMenuItem item = new JMenuItem(Actions.cutAmpersand((String) getValue(NAME)));//"<html><b>"+Actions.cutAmpersand((String) getValue(NAME))+"</b></html>") {
115
item.setEnabled(delegate.isEnabled());
117
item.addActionListener(new ActionListener() {
118
public void actionPerformed(ActionEvent e) {
119
DebugMainProjectAction.this.actionPerformed(e);
123
final ConnectAction ca = (ConnectAction) Lookups.forPath("Actions/Debug").lookup(
124
new Lookup.Template(Action.class, "Actions/Debug/org-netbeans-modules-debugger-ui-actions-ConnectAction", null)) // NOI18N
125
.allInstances().iterator().next();
126
item = new JMenuItem(Actions.cutAmpersand((String) ca.getValue(NAME)));
127
Actions.connect(item, ca);
129
} catch (java.util.NoSuchElementException nsee) {
130
Exceptions.printStackTrace(nsee);
132
Actions.connect(button, this);