gorrus@17297
|
1 |
/*
|
gorrus@17297
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
gorrus@17297
|
3 |
*
|
gorrus@17297
|
4 |
* Copyright 2010 Oracle and/or its affiliates. All rights reserved.
|
gorrus@17297
|
5 |
*
|
gorrus@17297
|
6 |
* Oracle and Java are registered trademarks of Oracle and/or its affiliates.
|
gorrus@17297
|
7 |
* Other names may be trademarks of their respective owners.
|
gorrus@17297
|
8 |
*
|
gorrus@17297
|
9 |
* The contents of this file are subject to the terms of either the GNU
|
gorrus@17297
|
10 |
* General Public License Version 2 only ("GPL") or the Common
|
gorrus@17297
|
11 |
* Development and Distribution License("CDDL") (collectively, the
|
gorrus@17297
|
12 |
* "License"). You may not use this file except in compliance with the
|
gorrus@17297
|
13 |
* License. You can obtain a copy of the License at
|
gorrus@17297
|
14 |
* http://www.netbeans.org/cddl-gplv2.html
|
gorrus@17297
|
15 |
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
|
gorrus@17297
|
16 |
* specific language governing permissions and limitations under the
|
gorrus@17297
|
17 |
* License. When distributing the software, include this License Header
|
gorrus@17297
|
18 |
* Notice in each file and include the License file at
|
gorrus@17297
|
19 |
* nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
|
gorrus@17297
|
20 |
* particular file as subject to the "Classpath" exception as provided
|
gorrus@17297
|
21 |
* by Oracle in the GPL Version 2 section of the License file that
|
gorrus@17297
|
22 |
* accompanied this code. If applicable, add the following below the
|
gorrus@17297
|
23 |
* License Header, with the fields enclosed by brackets [] replaced by
|
gorrus@17297
|
24 |
* your own identifying information:
|
gorrus@17297
|
25 |
* "Portions Copyrighted [year] [name of copyright owner]"
|
gorrus@17297
|
26 |
*
|
gorrus@17297
|
27 |
* If you wish your version of this file to be governed by only the CDDL
|
gorrus@17297
|
28 |
* or only the GPL Version 2, indicate your decision by adding
|
gorrus@17297
|
29 |
* "[Contributor] elects to include this software in this distribution
|
gorrus@17297
|
30 |
* under the [CDDL or GPL Version 2] license." If you do not indicate a
|
gorrus@17297
|
31 |
* single choice of license, a recipient has the option to distribute
|
gorrus@17297
|
32 |
* your version of this file under either the CDDL, the GPL Version 2 or
|
gorrus@17297
|
33 |
* to extend the choice of license to its licensees as provided above.
|
gorrus@17297
|
34 |
* However, if you add GPL Version 2 code and therefore, elected the GPL
|
gorrus@17297
|
35 |
* Version 2 license, then the option applies only if the new code is
|
gorrus@17297
|
36 |
* made subject to such option by the copyright holder.
|
gorrus@17297
|
37 |
*
|
gorrus@17297
|
38 |
* Contributor(s):
|
gorrus@17297
|
39 |
*
|
gorrus@17297
|
40 |
* Portions Copyrighted 2009 Sun Microsystems, Inc.
|
gorrus@17297
|
41 |
*/
|
gorrus@17297
|
42 |
|
gorrus@17297
|
43 |
/*
|
gorrus@17297
|
44 |
* GdbServerAttachPanel.java
|
gorrus@17297
|
45 |
*
|
gorrus@17297
|
46 |
* Created on Aug 14, 2009, 7:39:50 PM
|
gorrus@17297
|
47 |
*/
|
gorrus@17297
|
48 |
|
gorrus@17297
|
49 |
package org.netbeans.modules.cnd.debugger.gdbserver;
|
gorrus@17297
|
50 |
|
gorrus@17297
|
51 |
import java.beans.PropertyChangeListener;
|
alexvsimon@18201
|
52 |
import java.lang.invoke.MethodHandles;
|
gorrus@17769
|
53 |
import javax.swing.JPanel;
|
gorrus@17452
|
54 |
import org.netbeans.modules.cnd.api.remote.RemoteSyncSupport;
|
mromashova@18198
|
55 |
import org.netbeans.modules.cnd.debugger.common2.debugger.NativeDebuggerInfo;
|
gorrus@17811
|
56 |
import org.netbeans.modules.cnd.debugger.common2.debugger.NativeDebuggerManager;
|
gorrus@17297
|
57 |
import org.netbeans.modules.cnd.debugger.common2.debugger.actions.ExecutableProjectPanel;
|
gorrus@17297
|
58 |
import org.netbeans.modules.cnd.debugger.common2.debugger.actions.ExecutableProjectPanel.ProjectCBItem;
|
gorrus@17302
|
59 |
import org.netbeans.modules.cnd.debugger.common2.debugger.debugtarget.DebugTarget;
|
gorrus@17452
|
60 |
import org.netbeans.modules.cnd.debugger.common2.debugger.remote.CndRemote;
|
mromashova@18198
|
61 |
import org.netbeans.modules.cnd.debugger.gdb2.options.GdbDebuggerInfoFactory;
|
gorrus@17302
|
62 |
import org.netbeans.modules.cnd.makeproject.api.configurations.ConfigurationSupport;
|
gorrus@17302
|
63 |
import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfiguration;
|
gorrus@17452
|
64 |
import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
|
gorrus@17297
|
65 |
import org.netbeans.spi.debugger.ui.Controller;
|
gorrus@17769
|
66 |
import org.openide.util.HelpCtx;
|
alexvsimon@18201
|
67 |
import org.openide.util.Lookup;
|
gorrus@17297
|
68 |
import org.openide.util.NbPreferences;
|
gorrus@17297
|
69 |
|
gorrus@17297
|
70 |
/**
|
gorrus@17297
|
71 |
*
|
gorrus@17297
|
72 |
* @author Egor Ushakov
|
gorrus@17297
|
73 |
*/
|
gorrus@17769
|
74 |
public class GdbServerAttachPanel extends JPanel implements HelpCtx.Provider {
|
gorrus@17297
|
75 |
private final Controller controller;
|
gorrus@17297
|
76 |
|
gorrus@17769
|
77 |
private static final String TARGET_KEY = "last-gdbserver-target"; //NOI18N
|
gorrus@17297
|
78 |
|
gorrus@17297
|
79 |
/** Creates new form GdbServerAttachPanel */
|
gorrus@17297
|
80 |
public GdbServerAttachPanel() {
|
gorrus@17297
|
81 |
controller = new GdbServerAttachController();
|
gorrus@17297
|
82 |
initComponents();
|
gorrus@17297
|
83 |
// Fill the Projects combo box
|
gorrus@17297
|
84 |
ExecutableProjectPanel.fillProjectsCombo(projectCB, null);
|
gorrus@17769
|
85 |
targetTF.setText(NbPreferences.forModule(GdbServerAttachPanel.class).get(TARGET_KEY, "remote host:port")); //NOI18N
|
gorrus@17297
|
86 |
}
|
gorrus@17297
|
87 |
|
gorrus@17297
|
88 |
Controller getController() {
|
gorrus@17297
|
89 |
return controller;
|
gorrus@17297
|
90 |
}
|
gorrus@17297
|
91 |
|
gorrus@17297
|
92 |
/** This method is called from within the constructor to
|
gorrus@17297
|
93 |
* initialize the form.
|
gorrus@17297
|
94 |
* WARNING: Do NOT modify this code. The content of this method is
|
gorrus@17297
|
95 |
* always regenerated by the Form Editor.
|
gorrus@17297
|
96 |
*/
|
gorrus@17297
|
97 |
@SuppressWarnings("unchecked")
|
gorrus@17297
|
98 |
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
gorrus@17297
|
99 |
private void initComponents() {
|
gorrus@17297
|
100 |
|
gorrus@17297
|
101 |
projectLabel = new javax.swing.JLabel();
|
gorrus@17297
|
102 |
projectCB = new javax.swing.JComboBox();
|
gorrus@17297
|
103 |
jLabel1 = new javax.swing.JLabel();
|
gorrus@17769
|
104 |
targetTF = new javax.swing.JTextField();
|
gorrus@17297
|
105 |
|
gorrus@17297
|
106 |
projectLabel.setText(org.openide.util.NbBundle.getMessage(GdbServerAttachPanel.class, "GdbServerAttachPanel.projectLabel.text")); // NOI18N
|
gorrus@17297
|
107 |
|
gorrus@17297
|
108 |
jLabel1.setText(org.openide.util.NbBundle.getMessage(GdbServerAttachPanel.class, "GdbServerAttachPanel.jLabel1.text")); // NOI18N
|
gorrus@17297
|
109 |
|
gorrus@17297
|
110 |
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
gorrus@17297
|
111 |
this.setLayout(layout);
|
gorrus@17297
|
112 |
layout.setHorizontalGroup(
|
gorrus@17297
|
113 |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
gorrus@17297
|
114 |
.addGroup(layout.createSequentialGroup()
|
gorrus@17297
|
115 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
gorrus@17297
|
116 |
.addComponent(projectLabel)
|
gorrus@17769
|
117 |
.addComponent(jLabel1))
|
gorrus@17297
|
118 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
gorrus@17297
|
119 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
gorrus@17769
|
120 |
.addComponent(targetTF, javax.swing.GroupLayout.DEFAULT_SIZE, 395, Short.MAX_VALUE)
|
gorrus@17769
|
121 |
.addComponent(projectCB, 0, 395, Short.MAX_VALUE)))
|
gorrus@17297
|
122 |
);
|
gorrus@17297
|
123 |
layout.setVerticalGroup(
|
gorrus@17297
|
124 |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
gorrus@17297
|
125 |
.addGroup(layout.createSequentialGroup()
|
gorrus@17297
|
126 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
gorrus@17297
|
127 |
.addComponent(jLabel1)
|
gorrus@17769
|
128 |
.addComponent(targetTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
gorrus@17297
|
129 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
gorrus@17297
|
130 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
gorrus@17297
|
131 |
.addComponent(projectLabel)
|
gorrus@17769
|
132 |
.addComponent(projectCB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
gorrus@17769
|
133 |
.addContainerGap())
|
gorrus@17297
|
134 |
);
|
gorrus@17297
|
135 |
}// </editor-fold>//GEN-END:initComponents
|
gorrus@17297
|
136 |
|
gorrus@17297
|
137 |
|
gorrus@17297
|
138 |
// Variables declaration - do not modify//GEN-BEGIN:variables
|
gorrus@17297
|
139 |
private javax.swing.JLabel jLabel1;
|
gorrus@17297
|
140 |
private javax.swing.JComboBox projectCB;
|
gorrus@17297
|
141 |
private javax.swing.JLabel projectLabel;
|
gorrus@17769
|
142 |
private javax.swing.JTextField targetTF;
|
gorrus@17297
|
143 |
// End of variables declaration//GEN-END:variables
|
gorrus@17297
|
144 |
|
gorrus@17297
|
145 |
private class GdbServerAttachController implements Controller {
|
gorrus@17297
|
146 |
|
gorrus@17297
|
147 |
@Override
|
gorrus@17297
|
148 |
public boolean cancel() {
|
gorrus@17297
|
149 |
return true;
|
gorrus@17297
|
150 |
}
|
gorrus@17297
|
151 |
|
gorrus@17297
|
152 |
@Override
|
gorrus@17297
|
153 |
public boolean ok() {
|
gorrus@17769
|
154 |
String targetValue = targetTF.getText();
|
gorrus@17769
|
155 |
if (targetValue.length() == 0) {
|
gorrus@17297
|
156 |
return false;
|
gorrus@17297
|
157 |
}
|
gorrus@17297
|
158 |
|
gorrus@17297
|
159 |
//store last values
|
gorrus@17769
|
160 |
NbPreferences.forModule(GdbServerAttachPanel.class).put(TARGET_KEY, targetValue);
|
gorrus@17297
|
161 |
|
gorrus@17297
|
162 |
ProjectCBItem pi = (ProjectCBItem) projectCB.getSelectedItem();
|
gorrus@17297
|
163 |
if (pi != null) {
|
gorrus@17302
|
164 |
MakeConfiguration conf = ConfigurationSupport.getProjectActiveConfiguration(pi.getProject()).clone();
|
gorrus@17302
|
165 |
DebugTarget dt = new DebugTarget(conf);
|
gorrus@17452
|
166 |
|
gorrus@17452
|
167 |
// set executable
|
gorrus@17302
|
168 |
String path = conf.getAbsoluteOutputValue().replace("\\", "/"); // NOI18N
|
gorrus@17452
|
169 |
ExecutionEnvironment exEnv = conf.getDevelopmentHost().getExecutionEnvironment();
|
gorrus@17452
|
170 |
path = RemoteSyncSupport.getPathMap(exEnv, pi.getProject()).getRemotePath(path, true);
|
gorrus@17302
|
171 |
dt.setExecutable(path);
|
gorrus@17302
|
172 |
|
gorrus@17302
|
173 |
// always use gdb
|
mromashova@18198
|
174 |
NativeDebuggerInfo gdi = GdbDebuggerInfoFactory.create(dt,
|
mromashova@18198
|
175 |
CndRemote.userhostFromConfiguration(conf), conf, NativeDebuggerManager.ATTACH, targetValue);
|
gorrus@17811
|
176 |
NativeDebuggerManager.get().debugNoAsk(gdi);
|
gorrus@17297
|
177 |
// try {
|
gorrus@17297
|
178 |
// GdbDebugger.attachGdbServer(target, pi.getProjectInformation());
|
gorrus@17297
|
179 |
// } catch (DebuggerStartException dse) {
|
gorrus@17297
|
180 |
// DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
|
gorrus@17297
|
181 |
// NbBundle.getMessage(GdbServerAttachPanel.class,
|
gorrus@17297
|
182 |
// "ERR_UnexpecedAttachGdbServerFailure", target))); // NOI18N
|
gorrus@17297
|
183 |
// }
|
gorrus@17297
|
184 |
}
|
gorrus@17297
|
185 |
return true;
|
gorrus@17297
|
186 |
}
|
gorrus@17297
|
187 |
|
gorrus@17297
|
188 |
@Override
|
gorrus@17297
|
189 |
public boolean isValid() {
|
gorrus@17297
|
190 |
return projectCB.getItemCount() > 0;
|
gorrus@17297
|
191 |
}
|
gorrus@17297
|
192 |
|
gorrus@17297
|
193 |
@Override
|
gorrus@17297
|
194 |
public void addPropertyChangeListener(PropertyChangeListener l) {
|
gorrus@17297
|
195 |
}
|
gorrus@17297
|
196 |
|
gorrus@17297
|
197 |
@Override
|
gorrus@17297
|
198 |
public void removePropertyChangeListener(PropertyChangeListener l) {
|
gorrus@17297
|
199 |
}
|
gorrus@17297
|
200 |
|
gorrus@17297
|
201 |
}
|
gorrus@17769
|
202 |
|
gorrus@17769
|
203 |
@Override
|
gorrus@17769
|
204 |
public HelpCtx getHelpCtx() {
|
gorrus@17769
|
205 |
return new HelpCtx("gdbserver"); // NOI18N
|
gorrus@17769
|
206 |
}
|
gorrus@17297
|
207 |
}
|