Added
Link Here
|
1 |
/* |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 |
* |
4 |
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. |
5 |
* |
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]" |
23 |
* |
24 |
* Contributor(s): |
25 |
* |
26 |
* The Original Software is NetBeans. The Initial Developer of the Original |
27 |
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun |
28 |
* Microsystems, Inc. All Rights Reserved. |
29 |
* |
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. |
40 |
*/ |
41 |
package org.netbeans.spi.java.project.support.ui; |
42 |
|
43 |
import java.awt.Component; |
44 |
import java.io.File; |
45 |
import java.net.MalformedURLException; |
46 |
import java.net.URL; |
47 |
import java.util.ArrayList; |
48 |
import java.util.List; |
49 |
import java.util.logging.Logger; |
50 |
import javax.swing.Action; |
51 |
import javax.swing.DefaultCellEditor; |
52 |
import javax.swing.DefaultComboBoxModel; |
53 |
import javax.swing.DefaultListCellRenderer; |
54 |
import javax.swing.JComboBox; |
55 |
import javax.swing.JList; |
56 |
import javax.swing.JPanel; |
57 |
import javax.swing.JTable; |
58 |
import javax.swing.ListSelectionModel; |
59 |
import javax.swing.event.ListSelectionEvent; |
60 |
import javax.swing.event.ListSelectionListener; |
61 |
import javax.swing.table.DefaultTableCellRenderer; |
62 |
import javax.swing.table.DefaultTableModel; |
63 |
import javax.swing.table.TableColumn; |
64 |
import org.netbeans.api.project.ant.AntArtifact; |
65 |
import org.netbeans.api.project.libraries.Library; |
66 |
import org.netbeans.api.project.libraries.LibraryManager; |
67 |
import org.netbeans.api.queries.CollocationQuery; |
68 |
import org.netbeans.spi.project.libraries.LibraryTypeProvider; |
69 |
import org.netbeans.spi.project.libraries.support.LibrariesSupport; |
70 |
import org.netbeans.spi.project.support.ant.AntProjectHelper; |
71 |
import org.netbeans.spi.project.support.ant.ReferenceHelper; |
72 |
import org.openide.WizardDescriptor; |
73 |
import org.openide.filesystems.FileObject; |
74 |
import org.openide.filesystems.FileUtil; |
75 |
import org.openide.filesystems.URLMapper; |
76 |
import org.openide.util.Exceptions; |
77 |
import org.openide.util.NbBundle; |
78 |
|
79 |
|
80 |
final class MakeSharableVisualPanel2 extends JPanel { |
81 |
|
82 |
DefaultTableModel model; |
83 |
private String location = null; |
84 |
AntProjectHelper helper; |
85 |
private ReferenceHelper refhelper; |
86 |
String ACTION_COPY = "copy"; //NOI18N |
87 |
String ACTION_RELATIVE = "keep"; //NOI18N |
88 |
String ACTION_ABSOLUTE = "abs"; //NOI18N |
89 |
String ACTION_USE_LOCAL_LIBRARY = "use"; |
90 |
String[] comboValues = new String[]{ |
91 |
ACTION_COPY, ACTION_RELATIVE, ACTION_ABSOLUTE, ACTION_USE_LOCAL_LIBRARY |
92 |
}; |
93 |
String[] comboValuesJar = new String[]{ |
94 |
ACTION_COPY, ACTION_RELATIVE, ACTION_ABSOLUTE |
95 |
}; |
96 |
|
97 |
/** Creates new form MakeSharableVisualPanel2 */ |
98 |
public MakeSharableVisualPanel2() { |
99 |
initComponents(); |
100 |
createTableDefinition(); |
101 |
|
102 |
} |
103 |
|
104 |
@Override |
105 |
public String getName() { |
106 |
return NbBundle.getMessage(MakeSharableVisualPanel2.class, "MakeSharablePanel2.LBL_Actions"); |
107 |
} |
108 |
|
109 |
void readSettings(WizardDescriptor wiz) { |
110 |
String loc = (String) wiz.getProperty(SharableLibrariesUtils.PROP_LOCATION); |
111 |
helper = (AntProjectHelper) wiz.getProperty(SharableLibrariesUtils.PROP_HELPER); |
112 |
refhelper = (ReferenceHelper) wiz.getProperty(SharableLibrariesUtils.PROP_REFERENCE_HELPER); |
113 |
List<String> libraries = (List<String>) wiz.getProperty(SharableLibrariesUtils.PROP_LIBRARIES); |
114 |
List<String> jars = (List<String>) wiz.getProperty(SharableLibrariesUtils.PROP_JAR_REFS); |
115 |
if (!loc.equals(location)) { |
116 |
location = loc; |
117 |
populateTable(helper, libraries, jars); |
118 |
populateDescriptionField(); |
119 |
} |
120 |
} |
121 |
|
122 |
void storeSettings(WizardDescriptor wiz) { |
123 |
refhelper = (ReferenceHelper) wiz.getProperty(SharableLibrariesUtils.PROP_REFERENCE_HELPER); |
124 |
helper = (AntProjectHelper) wiz.getProperty(SharableLibrariesUtils.PROP_HELPER); |
125 |
|
126 |
List<Action> actions = new ArrayList<Action>(); |
127 |
for (int i = 0; i < model.getRowCount(); i++) { |
128 |
Object item = model.getValueAt(i, 0); |
129 |
String action = (String) model.getValueAt(i, 1); |
130 |
if (item instanceof Library) { |
131 |
Library lib = (Library) item; |
132 |
if (ACTION_ABSOLUTE.equals(action)) { |
133 |
actions.add(new SharableLibrariesUtils.KeepLibraryAtLocation(lib, false, helper)); |
134 |
} else if (ACTION_RELATIVE.equals(action)) { |
135 |
actions.add(new SharableLibrariesUtils.KeepLibraryAtLocation(lib, true, helper)); |
136 |
} else if (ACTION_COPY.equals(action)) { |
137 |
actions.add(new SharableLibrariesUtils.CopyLibraryJars(refhelper, lib)); |
138 |
} else if (ACTION_USE_LOCAL_LIBRARY.equals(action)) { |
139 |
//do nothing |
140 |
} else { |
141 |
assert false : "No handling defined for action: " + action; |
142 |
} |
143 |
} else if (item instanceof String) { |
144 |
//file reference |
145 |
String ref = (String) item; |
146 |
if (ACTION_ABSOLUTE.equals(action)) { |
147 |
actions.add(new SharableLibrariesUtils.KeepJarAtLocation(ref, false, helper, refhelper)); |
148 |
} else if (ACTION_RELATIVE.equals(action)) { |
149 |
actions.add(new SharableLibrariesUtils.KeepJarAtLocation(ref, true, helper, refhelper)); |
150 |
} else if (ACTION_COPY.equals(action)) { |
151 |
actions.add(new SharableLibrariesUtils.CopyJars(refhelper, helper, ref)); |
152 |
} else { |
153 |
assert false : "no handling defined for action: " + action; |
154 |
} |
155 |
} else if (item instanceof AntArtifact) { |
156 |
//project dependency.. do we want to handle? proably not.. |
157 |
} |
158 |
} |
159 |
wiz.putProperty(SharableLibrariesUtils.PROP_ACTIONS, actions); |
160 |
|
161 |
} |
162 |
|
163 |
private void createTableDefinition() { |
164 |
model = new DefaultTableModel() { |
165 |
|
166 |
@Override |
167 |
public boolean isCellEditable(int row, int col) { |
168 |
return col == 1; |
169 |
} |
170 |
}; |
171 |
model.addColumn("jar"); |
172 |
model.addColumn("action"); |
173 |
tblJars.setModel(model); |
174 |
TableColumn col1 = tblJars.getColumn("jar"); |
175 |
col1.setHeaderValue(NbBundle.getMessage(MakeSharableVisualPanel2.class, "tblJars.header1")); |
176 |
col1.setResizable(true); |
177 |
col1.setCellRenderer(new DefaultTableCellRenderer() { |
178 |
|
179 |
@Override |
180 |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { |
181 |
String text = ""; |
182 |
if (value instanceof Library) { |
183 |
Library lib = (Library) value; |
184 |
text = lib.getDisplayName(); |
185 |
} else if (value instanceof String) { |
186 |
String v = helper.getStandardPropertyEvaluator().evaluate((String) value); |
187 |
File absFile = helper.resolveFile(v); |
188 |
text = absFile.getAbsolutePath(); |
189 |
} |
190 |
|
191 |
return super.getTableCellRendererComponent(table, text, isSelected, hasFocus, row, column); |
192 |
} |
193 |
}); |
194 |
TableColumn col2 = tblJars.getColumn("action"); |
195 |
col2.setHeaderValue(NbBundle.getMessage(MakeSharableVisualPanel2.class, "tblJars.header2")); |
196 |
col2.sizeWidthToFit(); |
197 |
|
198 |
JComboBox editorBox = new JComboBox(comboValues); |
199 |
editorBox.setEditable(false); |
200 |
DefaultCellEditor ed = new MyCellEditor(editorBox); |
201 |
col2.setCellEditor(ed); |
202 |
col2.setCellRenderer(new DefaultTableCellRenderer() { |
203 |
|
204 |
@Override |
205 |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { |
206 |
String val = (String) value; |
207 |
if (table.getValueAt(row, 0) instanceof Library) { |
208 |
if (ACTION_ABSOLUTE.equals(val)) { |
209 |
val = NbBundle.getMessage(MakeSharableVisualPanel2.class, "TXT_Absolute"); |
210 |
} else if (ACTION_COPY.equals(val)) { |
211 |
val = NbBundle.getMessage(MakeSharableVisualPanel2.class, "TXT_Copy"); |
212 |
} else if (ACTION_RELATIVE.equals(val)) { |
213 |
val = NbBundle.getMessage(MakeSharableVisualPanel2.class, "TXT_Keep"); |
214 |
} else if (ACTION_USE_LOCAL_LIBRARY.equals(val)) { |
215 |
val = NbBundle.getMessage(MakeSharableVisualPanel2.class, "TXT_UseLocal"); |
216 |
} |
217 |
} else { |
218 |
if (ACTION_ABSOLUTE.equals(val)) { |
219 |
val = NbBundle.getMessage(MakeSharableVisualPanel2.class, "TXT_AbsoluteJar"); |
220 |
} else if (ACTION_COPY.equals(val)) { |
221 |
val = NbBundle.getMessage(MakeSharableVisualPanel2.class, "TXT_CopyJar"); |
222 |
} else if (ACTION_RELATIVE.equals(val)) { |
223 |
val = NbBundle.getMessage(MakeSharableVisualPanel2.class, "TXT_KeepJar"); |
224 |
} |
225 |
} |
226 |
return super.getTableCellRendererComponent(table, val, isSelected, hasFocus, row, column); |
227 |
} |
228 |
}); |
229 |
tblJars.getSelectionModel().addListSelectionListener(new ListSelectionListener() { |
230 |
|
231 |
public void valueChanged(ListSelectionEvent e) { |
232 |
populateDescriptionField(); |
233 |
} |
234 |
}); |
235 |
tblJars.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
236 |
} |
237 |
|
238 |
/** This method is called from within the constructor to |
239 |
* initialize the form. |
240 |
* WARNING: Do NOT modify this code. The content of this method is |
241 |
* always regenerated by the Form Editor. |
242 |
*/ |
243 |
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
244 |
private void initComponents() { |
245 |
|
246 |
lblHint = new javax.swing.JLabel(); |
247 |
lblJars = new javax.swing.JLabel(); |
248 |
jScrollPane1 = new javax.swing.JScrollPane(); |
249 |
tblJars = new javax.swing.JTable(); |
250 |
lblDetails = new javax.swing.JLabel(); |
251 |
jScrollPane2 = new javax.swing.JScrollPane(); |
252 |
taDetails = new javax.swing.JTextArea(); |
253 |
|
254 |
org.openide.awt.Mnemonics.setLocalizedText(lblHint, org.openide.util.NbBundle.getMessage(MakeSharableVisualPanel2.class, "MakeSharableVisualPanel2.lblHint.text")); // NOI18N |
255 |
lblHint.setVerticalAlignment(javax.swing.SwingConstants.TOP); |
256 |
|
257 |
lblJars.setLabelFor(tblJars); |
258 |
org.openide.awt.Mnemonics.setLocalizedText(lblJars, org.openide.util.NbBundle.getMessage(MakeSharableVisualPanel2.class, "MakeSharableVisualPanel2.lblJars.text")); // NOI18N |
259 |
|
260 |
jScrollPane1.setViewportView(tblJars); |
261 |
|
262 |
lblDetails.setLabelFor(taDetails); |
263 |
org.openide.awt.Mnemonics.setLocalizedText(lblDetails, org.openide.util.NbBundle.getMessage(MakeSharableVisualPanel2.class, "MakeSharableVisualPanel2.lblDetails.text")); // NOI18N |
264 |
|
265 |
taDetails.setColumns(20); |
266 |
taDetails.setRows(5); |
267 |
jScrollPane2.setViewportView(taDetails); |
268 |
|
269 |
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); |
270 |
this.setLayout(layout); |
271 |
layout.setHorizontalGroup( |
272 |
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
273 |
.add(lblHint, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE) |
274 |
.add(layout.createSequentialGroup() |
275 |
.add(lblJars) |
276 |
.addContainerGap()) |
277 |
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE) |
278 |
.add(layout.createSequentialGroup() |
279 |
.add(lblDetails) |
280 |
.addContainerGap()) |
281 |
.add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE) |
282 |
); |
283 |
layout.setVerticalGroup( |
284 |
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
285 |
.add(layout.createSequentialGroup() |
286 |
.add(lblHint, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
287 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
288 |
.add(lblJars) |
289 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
290 |
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE) |
291 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
292 |
.add(lblDetails) |
293 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
294 |
.add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 104, Short.MAX_VALUE)) |
295 |
); |
296 |
|
297 |
lblJars.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(MakeSharableVisualPanel2.class, "ACSD_lblJars")); // NOI18N |
298 |
lblDetails.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(MakeSharableVisualPanel2.class, "ACSD_lblDetails")); // NOI18N |
299 |
}// </editor-fold>//GEN-END:initComponents |
300 |
// Variables declaration - do not modify//GEN-BEGIN:variables |
301 |
private javax.swing.JScrollPane jScrollPane1; |
302 |
private javax.swing.JScrollPane jScrollPane2; |
303 |
private javax.swing.JLabel lblDetails; |
304 |
private javax.swing.JLabel lblHint; |
305 |
private javax.swing.JLabel lblJars; |
306 |
private javax.swing.JTextArea taDetails; |
307 |
private javax.swing.JTable tblJars; |
308 |
// End of variables declaration//GEN-END:variables |
309 |
private void populateTable(AntProjectHelper helper, List<String> libraries, List<String> jars) { |
310 |
createTableDefinition(); |
311 |
try { |
312 |
File libraryFile = helper.resolveFile(location); |
313 |
File prjDir = FileUtil.toFile(helper.getProjectDirectory()); |
314 |
boolean absoluteLibrary = LibrariesSupport.isAbsoluteURL(LibrariesSupport.convertFilePathToURL(location)); |
315 |
LibraryManager newmanager = LibraryManager.forLocation(libraryFile.toURI().toURL()); |
316 |
LibraryManager oldmanager = LibraryManager.getDefault(); //TODO once we support moving from one place to another, change this |
317 |
for (String lib : libraries) { |
318 |
Library library = oldmanager.getLibrary(lib); |
319 |
Library newLib = newmanager.getLibrary(lib); |
320 |
String action = ACTION_COPY; |
321 |
//TODO when library contents inside the same SCM or relative to new library location, |
322 |
// use the relative path as default.. |
323 |
if (newLib != null) { |
324 |
action = ACTION_USE_LOCAL_LIBRARY; |
325 |
} |
326 |
if (library != null) { |
327 |
model.addRow(new Object[]{library, action}); |
328 |
} |
329 |
} |
330 |
for (String jar : jars) { |
331 |
if (jar != null) { |
332 |
String value = helper.getStandardPropertyEvaluator().evaluate(jar); |
333 |
if (!value.startsWith("${")) { |
334 |
File jarFile = helper.resolveFile(value); |
335 |
String action = ACTION_COPY; |
336 |
if (CollocationQuery.areCollocated(prjDir, jarFile)) { |
337 |
// in the same VCS, without one project structure.. |
338 |
action = ACTION_RELATIVE; |
339 |
} else if (absoluteLibrary && CollocationQuery.areCollocated(libraryFile.getParentFile(), jarFile)) { |
340 |
// jar within the libraries folder or somehow relative to it.. |
341 |
// the path to libraries is absolute though.. absolute path is best guess then as well. |
342 |
action = ACTION_ABSOLUTE; |
343 |
} else if (CollocationQuery.areCollocated(libraryFile.getParentFile(), jarFile)) { |
344 |
action = ACTION_RELATIVE; |
345 |
} |
346 |
model.addRow(new Object[]{jar, action}); |
347 |
} else { |
348 |
Logger.getLogger(MakeSharableVisualPanel2.class.getName()).info("Cannot find jar reference:" + jar); |
349 |
} |
350 |
} else { |
351 |
Logger.getLogger(MakeSharableVisualPanel2.class.getName()).info("Cannot find jar reference:" + jar); |
352 |
} |
353 |
} |
354 |
} catch (MalformedURLException ex) { |
355 |
Exceptions.printStackTrace(ex); |
356 |
} |
357 |
} |
358 |
|
359 |
private void populateDescriptionField() { |
360 |
int row = tblJars.getSelectedRow(); |
361 |
if (row != -1) { |
362 |
Object val = tblJars.getModel().getValueAt(row, 0); |
363 |
if (val instanceof Library) { |
364 |
Library lib = (Library) val; |
365 |
String type = lib.getType(); |
366 |
LibraryTypeProvider provider = LibrariesSupport.getLibraryTypeProvider(type); |
367 |
assert provider != null; |
368 |
String typeString = provider.getDisplayName(); |
369 |
String[] volumes = provider.getSupportedVolumeTypes(); |
370 |
StringBuffer contents = new StringBuffer(); |
371 |
for (String vol : volumes) { |
372 |
List<URL> urls = lib.getContent(vol); |
373 |
for (URL url : urls) { |
374 |
FileObject fo = URLMapper.findFileObject(url); |
375 |
if (fo != null) { |
376 |
if (FileUtil.getArchiveFile(fo) != null) { |
377 |
url = URLMapper.findURL(FileUtil.getArchiveFile(fo), URLMapper.EXTERNAL); |
378 |
} |
379 |
} |
380 |
contents.append(url).append("\n"); |
381 |
} |
382 |
} |
383 |
taDetails.setText("Library (" + typeString + ")\n" + |
384 |
"Contents:\n" + contents); |
385 |
} else if (val instanceof String) { |
386 |
String ref = (String) val; |
387 |
String text = "Jar/Folder\nBinary:"; |
388 |
String value = helper.getStandardPropertyEvaluator().evaluate(ref); |
389 |
File absFile = helper.resolveFile(value); |
390 |
text = text + absFile.getAbsolutePath(); |
391 |
String source = ref.replace("${file.reference", "${source.reference"); //NOI18N |
392 |
value = helper.getStandardPropertyEvaluator().evaluate(source); |
393 |
if (!value.startsWith("${source.")) { //NOI18N |
394 |
absFile = helper.resolveFile(value); |
395 |
text = text + "\nSources:" + absFile.getAbsolutePath(); |
396 |
} |
397 |
String javadoc = ref.replace("${file.reference", "${javadoc.reference"); //NOI18N |
398 |
value = helper.getStandardPropertyEvaluator().evaluate(javadoc); |
399 |
if (!value.startsWith("${javadoc.")) { //NOI18N |
400 |
absFile = helper.resolveFile(value); |
401 |
text = text + "\nJavadoc:" + absFile.getAbsolutePath(); |
402 |
} |
403 |
|
404 |
|
405 |
taDetails.setText(text); |
406 |
} |
407 |
} else { |
408 |
taDetails.setText("<No items selected>"); |
409 |
} |
410 |
} |
411 |
|
412 |
private class MyCellEditor extends DefaultCellEditor { |
413 |
|
414 |
|
415 |
private JComboBox cb; |
416 |
private DefaultListCellRenderer library; |
417 |
private DefaultListCellRenderer jar; |
418 |
|
419 |
MyCellEditor(JComboBox combo) { |
420 |
super(combo); |
421 |
cb = combo; |
422 |
library = new DefaultListCellRenderer() { |
423 |
@Override |
424 |
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
425 |
String val = (String) value; |
426 |
if (ACTION_ABSOLUTE.equals(val)) { |
427 |
val = NbBundle.getMessage(MakeSharableVisualPanel2.class, "TXT_Absolute"); |
428 |
} else if (ACTION_COPY.equals(val)) { |
429 |
val = NbBundle.getMessage(MakeSharableVisualPanel2.class, "TXT_Copy"); |
430 |
} else if (ACTION_RELATIVE.equals(val)) { |
431 |
val = NbBundle.getMessage(MakeSharableVisualPanel2.class, "TXT_Keep"); |
432 |
} else if (ACTION_USE_LOCAL_LIBRARY.equals(val)) { |
433 |
val = NbBundle.getMessage(MakeSharableVisualPanel2.class, "TXT_UseLocal"); |
434 |
} |
435 |
return super.getListCellRendererComponent(list, val, index, isSelected, cellHasFocus); |
436 |
} |
437 |
}; |
438 |
jar = new DefaultListCellRenderer() { |
439 |
@Override |
440 |
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
441 |
String val = (String) value; |
442 |
if (ACTION_ABSOLUTE.equals(val)) { |
443 |
val = NbBundle.getMessage(MakeSharableVisualPanel2.class, "TXT_AbsoluteJar"); |
444 |
} else if (ACTION_COPY.equals(val)) { |
445 |
val = NbBundle.getMessage(MakeSharableVisualPanel2.class, "TXT_CopyJar"); |
446 |
} else if (ACTION_RELATIVE.equals(val)) { |
447 |
val = NbBundle.getMessage(MakeSharableVisualPanel2.class, "TXT_KeepJar"); |
448 |
} else if (ACTION_USE_LOCAL_LIBRARY.equals(val)) { |
449 |
val = NbBundle.getMessage(MakeSharableVisualPanel2.class, "TXT_UseLocalJar"); |
450 |
} |
451 |
return super.getListCellRendererComponent(list, val, index, isSelected, cellHasFocus); |
452 |
} |
453 |
}; |
454 |
|
455 |
} |
456 |
|
457 |
@Override |
458 |
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
459 |
if (table.getValueAt(row, 0) instanceof Library) { |
460 |
cb.setRenderer(library); |
461 |
cb.setModel(new DefaultComboBoxModel(comboValues)); |
462 |
} else { |
463 |
cb.setRenderer(jar); |
464 |
cb.setModel(new DefaultComboBoxModel(comboValuesJar)); |
465 |
} |
466 |
super.getTableCellEditorComponent(table, value, isSelected, row, column); |
467 |
return cb; |
468 |
} |
469 |
} |
470 |
} |
471 |
|