KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > ant > freeform > Actions


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.ant.freeform;
21
22 import java.awt.event.ActionEvent JavaDoc;
23 import java.io.File JavaDoc;
24 import java.io.IOException JavaDoc;
25 import java.text.MessageFormat JavaDoc;
26 import java.util.ArrayList JavaDoc;
27 import java.util.Arrays JavaDoc;
28 import java.util.Collection JavaDoc;
29 import java.util.Collections JavaDoc;
30 import java.util.HashMap JavaDoc;
31 import java.util.HashSet JavaDoc;
32 import java.util.Iterator JavaDoc;
33 import java.util.LinkedHashSet JavaDoc;
34 import java.util.List JavaDoc;
35 import java.util.Map JavaDoc;
36 import java.util.Properties JavaDoc;
37 import java.util.Set JavaDoc;
38 import java.util.logging.Level JavaDoc;
39 import java.util.logging.Logger JavaDoc;
40 import java.util.regex.Pattern JavaDoc;
41 import java.util.regex.PatternSyntaxException JavaDoc;
42 import javax.swing.AbstractAction JavaDoc;
43 import javax.swing.Action JavaDoc;
44 import org.apache.tools.ant.module.api.support.ActionUtils;
45 import org.netbeans.modules.ant.freeform.spi.support.Util;
46 import org.netbeans.modules.ant.freeform.ui.ProjectNodeWrapper;
47 import org.netbeans.modules.ant.freeform.ui.UnboundTargetAlert;
48 import org.netbeans.spi.project.ActionProvider;
49 import org.netbeans.spi.project.support.ant.AntProjectHelper;
50 import org.netbeans.spi.project.ui.support.CommonProjectActions;
51 import org.netbeans.spi.project.ui.support.DefaultProjectOperations;
52 import org.netbeans.spi.project.ui.support.ProjectSensitiveActions;
53 import org.openide.DialogDisplayer;
54 import org.openide.ErrorManager;
55 import org.openide.NotifyDescriptor;
56 import org.openide.actions.FindAction;
57 import org.openide.actions.ToolsAction;
58 import org.openide.filesystems.FileObject;
59 import org.openide.filesystems.FileUtil;
60 import org.openide.loaders.DataObject;
61 import org.openide.util.Lookup;
62 import org.openide.util.NbBundle;
63 import org.openide.util.actions.SystemAction;
64 import org.w3c.dom.Element JavaDoc;
65
66 /**
67  * Action bindings for a freeform project.
68  * @author Jesse Glick
69  */

70 public final class Actions implements ActionProvider {
71
72     private static final Logger JavaDoc LOG = Logger.getLogger(Actions.class.getName());
73
74     /**
75      * Some routine global actions for which we can supply a display name.
76      * These are IDE-specific.
77      */

78     private static final Set JavaDoc<String JavaDoc> COMMON_IDE_GLOBAL_ACTIONS = new HashSet JavaDoc<String JavaDoc>(Arrays.asList(
79         ActionProvider.COMMAND_DEBUG,
80         ActionProvider.COMMAND_DELETE,
81         ActionProvider.COMMAND_COPY,
82         ActionProvider.COMMAND_MOVE,
83         ActionProvider.COMMAND_RENAME));
84     /**
85      * Similar to {@link #COMMON_IDE_GLOBAL_ACTIONS}, but these are not IDE-specific.
86      * We also mark all of these as bound in the project; if the user
87      * does not really have a binding, they are prompted for one when
88      * the action is "run".
89      */

90     private static final Set JavaDoc<String JavaDoc> COMMON_NON_IDE_GLOBAL_ACTIONS = new HashSet JavaDoc<String JavaDoc>(Arrays.asList(
91         ActionProvider.COMMAND_BUILD,
92         ActionProvider.COMMAND_CLEAN,
93         ActionProvider.COMMAND_REBUILD,
94         ActionProvider.COMMAND_RUN,
95         ActionProvider.COMMAND_TEST,
96         // XXX JavaProjectConstants.COMMAND_JAVADOC
97
"javadoc", // NOI18N
98
// XXX WebProjectConstants.COMMAND_REDEPLOY
99
// XXX should this really be here? perhaps not, once web part of #46886 is implemented...
100
"redeploy")); // NOI18N
101

102     private final FreeformProject project;
103     
104     /**
105      * Create a new action provider.
106      * @param project the associated project
107      */

108     public Actions(FreeformProject project) {
109         this.project = project;
110     }
111     
112     public String JavaDoc[] getSupportedActions() {
113         Element JavaDoc genldata = project.getPrimaryConfigurationData();
114         Element JavaDoc actionsEl = Util.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
115
if (actionsEl == null) {
116             return new String JavaDoc[0];
117         }
118         // Use a set, not a list, since when using context you can define one action several times:
119
Set JavaDoc<String JavaDoc> names = new LinkedHashSet JavaDoc<String JavaDoc>();
120         for (Element JavaDoc actionEl : Util.findSubElements(actionsEl)) {
121             names.add(actionEl.getAttribute("name")); // NOI18N
122
}
123         // #46886: also always enable all common global actions, in case they should be selected:
124
names.addAll(COMMON_NON_IDE_GLOBAL_ACTIONS);
125         names.add(COMMAND_RENAME);
126         names.add(COMMAND_MOVE);
127         names.add(COMMAND_COPY);
128         names.add(COMMAND_DELETE);
129         return names.toArray(new String JavaDoc[names.size()]);
130     }
131     
132     public boolean isActionEnabled(String JavaDoc command, Lookup context) throws IllegalArgumentException JavaDoc {
133         if (COMMAND_DELETE.equals(command)) {
134             return true;
135         }
136         if (COMMAND_COPY.equals(command)) {
137             return true;
138         }
139         if (COMMAND_RENAME.equals(command)) {
140             return true;
141         }
142         if (COMMAND_MOVE.equals(command)) {
143             return true;
144         }
145         
146         Element JavaDoc genldata = project.getPrimaryConfigurationData();
147         Element JavaDoc actionsEl = Util.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
148
if (actionsEl == null) {
149             throw new IllegalArgumentException JavaDoc("No commands supported"); // NOI18N
150
}
151         boolean foundAction = false;
152         for (Element JavaDoc actionEl : Util.findSubElements(actionsEl)) {
153             if (actionEl.getAttribute("name").equals(command)) { // NOI18N
154
foundAction = true;
155                 // XXX perhaps check also existence of script
156
Element JavaDoc contextEl = Util.findElement(actionEl, "context", FreeformProjectType.NS_GENERAL); // NOI18N
157
if (contextEl != null) {
158                     // Check whether the context contains files all in this folder,
159
// matching the pattern if any, and matching the arity (single/multiple).
160
Map JavaDoc<String JavaDoc,FileObject> selection = findSelection(contextEl, context, project);
161                     LOG.log(Level.FINE, "detected selection {0} for command {1} in {2}", new Object JavaDoc[] {selection, command, project});
162                     if (selection.size() == 1) {
163                         // Definitely enabled.
164
return true;
165                     } else if (!selection.isEmpty()) {
166                         // Multiple selection; check arity.
167
Element JavaDoc arityEl = Util.findElement(contextEl, "arity", FreeformProjectType.NS_GENERAL); // NOI18N
168
assert arityEl != null : "No <arity> in <context> for " + command;
169                         if (Util.findElement(arityEl, "separated-files", FreeformProjectType.NS_GENERAL) != null) { // NOI18N
170
// Supports multiple selection, take it.
171
return true;
172                         }
173                     }
174                 } else {
175                     // Not context-sensitive.
176
return true;
177                 }
178             }
179         }
180         if (COMMON_NON_IDE_GLOBAL_ACTIONS.contains(command)) {
181             // #46886: these are always enabled if they are not specifically bound.
182
return true;
183         }
184         if (foundAction) {
185             // Was at least one context-aware variant but did not match.
186
return false;
187         } else {
188             throw new IllegalArgumentException JavaDoc("Unrecognized command: " + command); // NOI18N
189
}
190     }
191     
192     public void invokeAction(String JavaDoc command, Lookup context) throws IllegalArgumentException JavaDoc {
193         if (COMMAND_DELETE.equals(command)) {
194             DefaultProjectOperations.performDefaultDeleteOperation(project);
195             return ;
196         }
197         if (COMMAND_COPY.equals(command)) {
198             DefaultProjectOperations.performDefaultCopyOperation(project);
199             return ;
200         }
201         if (COMMAND_RENAME.equals(command)) {
202             DefaultProjectOperations.performDefaultRenameOperation(project, null);
203             return ;
204         }
205         if (COMMAND_MOVE.equals(command)) {
206             DefaultProjectOperations.performDefaultMoveOperation(project);
207             return ;
208         }
209         
210         Element JavaDoc genldata = project.getPrimaryConfigurationData();
211         Element JavaDoc actionsEl = Util.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
212
if (actionsEl == null) {
213             throw new IllegalArgumentException JavaDoc("No commands supported"); // NOI18N
214
}
215         boolean foundAction = false;
216         for (Element JavaDoc actionEl : Util.findSubElements(actionsEl)) {
217             if (actionEl.getAttribute("name").equals(command)) { // NOI18N
218
foundAction = true;
219                 runConfiguredAction(project, actionEl, context);
220             }
221         }
222         if (!foundAction) {
223             if (COMMON_NON_IDE_GLOBAL_ACTIONS.contains(command)) {
224                 // #46886: try to bind it.
225
if (addGlobalBinding(command)) {
226                     // If bound, run it immediately.
227
invokeAction(command, context);
228                 }
229             } else {
230                 throw new IllegalArgumentException JavaDoc("Unrecognized command: " + command); // NOI18N
231
}
232         }
233     }
234     
235     /**
236      * Find a file selection in a lookup context based on a project.xml <context> declaration.
237      * If all DataObject's (or FileObject's) in the lookup match the folder named in the declaration,
238      * and match any optional pattern declaration, then they are returned as a map from relative
239      * path to actual file object. Otherwise an empty map is returned.
240      */

241     private static Map JavaDoc<String JavaDoc,FileObject> findSelection(Element JavaDoc contextEl, Lookup context, FreeformProject project) {
242         Collection JavaDoc<? extends FileObject> files = context.lookupAll(FileObject.class);
243         if (files.isEmpty()) {
244             // Try again with DataObject's.
245
Collection JavaDoc<? extends DataObject> filesDO = context.lookupAll(DataObject.class);
246             if (filesDO.isEmpty()) {
247                  return Collections.emptyMap();
248             }
249             Collection JavaDoc<FileObject> _files = new ArrayList JavaDoc<FileObject>(filesDO.size());
250             for (DataObject d : filesDO) {
251                 _files.add(d.getPrimaryFile());
252             }
253             files = _files;
254         }
255         Element JavaDoc folderEl = Util.findElement(contextEl, "folder", FreeformProjectType.NS_GENERAL); // NOI18N
256
assert folderEl != null : "Must have <folder> in <context>";
257         String JavaDoc rawtext = Util.findText(folderEl);
258         assert rawtext != null : "Must have text contents in <folder>";
259         String JavaDoc evaltext = project.evaluator().evaluate(rawtext);
260         if (evaltext == null) {
261             return Collections.emptyMap();
262         }
263         FileObject folder = project.helper().resolveFileObject(evaltext);
264         if (folder == null) {
265             return Collections.emptyMap();
266         }
267         Pattern JavaDoc pattern = null;
268         Element JavaDoc patternEl = Util.findElement(contextEl, "pattern", FreeformProjectType.NS_GENERAL); // NOI18N
269
if (patternEl != null) {
270             String JavaDoc text = Util.findText(patternEl);
271             assert text != null : "Must have text contents in <pattern>";
272             try {
273                 pattern = Pattern.compile(text);
274             } catch (PatternSyntaxException JavaDoc e) {
275                 org.netbeans.modules.ant.freeform.Util.err.annotate(e, ErrorManager.UNKNOWN, "From <pattern> in " + FileUtil.getFileDisplayName(project.getProjectDirectory().getFileObject(AntProjectHelper.PROJECT_XML_PATH)), null, null, null); // NOI18N
276
org.netbeans.modules.ant.freeform.Util.err.notify(e);
277                 return Collections.emptyMap();
278             }
279         }
280         Map JavaDoc<String JavaDoc,FileObject> result = new HashMap JavaDoc<String JavaDoc,FileObject>();
281         for (FileObject file : files) {
282             String JavaDoc path = FileUtil.getRelativePath(folder, file);
283             if (path == null) {
284                 return Collections.emptyMap();
285             }
286             if (pattern != null && !pattern.matcher(path).find()) {
287                 return Collections.emptyMap();
288             }
289             result.put(path, file);
290         }
291         return result;
292     }
293     
294     /**
295      * Run a project action as described by subelements <script> and <target>.
296      */

297     private static void runConfiguredAction(FreeformProject project, Element JavaDoc actionEl, Lookup context) {
298         String JavaDoc script;
299         Element JavaDoc scriptEl = Util.findElement(actionEl, "script", FreeformProjectType.NS_GENERAL); // NOI18N
300
if (scriptEl != null) {
301             script = Util.findText(scriptEl);
302         } else {
303             script = "build.xml"; // NOI18N
304
}
305         String JavaDoc scriptLocation = project.evaluator().evaluate(script);
306         FileObject scriptFile = project.helper().resolveFileObject(scriptLocation);
307         if (scriptFile == null) {
308             //#57011: if the script does not exist, show a warning:
309
NotifyDescriptor nd = new NotifyDescriptor.Message(MessageFormat.format(NbBundle.getMessage(Actions.class, "LBL_ScriptFileNotFoundError"), new Object JavaDoc[] {scriptLocation}), NotifyDescriptor.ERROR_MESSAGE);
310             
311             DialogDisplayer.getDefault().notify(nd);
312             return;
313         }
314         List JavaDoc<Element JavaDoc> targets = Util.findSubElements(actionEl);
315         List JavaDoc<String JavaDoc> targetNames = new ArrayList JavaDoc<String JavaDoc>(targets.size());
316         for (Element JavaDoc targetEl : targets) {
317             if (!targetEl.getLocalName().equals("target")) { // NOI18N
318
continue;
319             }
320             targetNames.add(Util.findText(targetEl));
321         }
322         String JavaDoc[] targetNameArray;
323         if (!targetNames.isEmpty()) {
324             targetNameArray = targetNames.toArray(new String JavaDoc[targetNames.size()]);
325         } else {
326             // Run default target.
327
targetNameArray = null;
328         }
329         Properties JavaDoc props = new Properties JavaDoc();
330         Element JavaDoc contextEl = Util.findElement(actionEl, "context", FreeformProjectType.NS_GENERAL); // NOI18N
331
if (contextEl != null) {
332             Map JavaDoc<String JavaDoc,FileObject> selection = findSelection(contextEl, context, project);
333             if (selection.isEmpty()) {
334                 return;
335             }
336             String JavaDoc separator = null;
337             if (selection.size() > 1) {
338                 // Find the right separator.
339
Element JavaDoc arityEl = Util.findElement(contextEl, "arity", FreeformProjectType.NS_GENERAL); // NOI18N
340
assert arityEl != null : "No <arity> in <context> for " + actionEl.getAttribute("name");
341                 Element JavaDoc sepFilesEl = Util.findElement(arityEl, "separated-files", FreeformProjectType.NS_GENERAL); // NOI18N
342
if (sepFilesEl == null) {
343                     // Only handles single files -> skip it.
344
return;
345                 }
346                 separator = Util.findText(sepFilesEl);
347             }
348             Element JavaDoc formatEl = Util.findElement(contextEl, "format", FreeformProjectType.NS_GENERAL); // NOI18N
349
assert formatEl != null : "No <format> in <context> for " + actionEl.getAttribute("name");
350             String JavaDoc format = Util.findText(formatEl);
351             StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
352             Iterator JavaDoc<Map.Entry JavaDoc<String JavaDoc,FileObject>> it = selection.entrySet().iterator();
353             while (it.hasNext()) {
354                 Map.Entry JavaDoc<String JavaDoc,FileObject> entry = it.next();
355                 if (format.equals("absolute-path")) { // NOI18N
356
File JavaDoc f = FileUtil.toFile(entry.getValue());
357                     if (f == null) {
358                         // Not a disk file??
359
return;
360                     }
361                     buf.append(f.getAbsolutePath());
362                 } else if (format.equals("relative-path")) { // NOI18N
363
buf.append(entry.getKey());
364                 } else if (format.equals("absolute-path-noext")) { // NOI18N
365
File JavaDoc f = FileUtil.toFile(entry.getValue());
366                     if (f == null) {
367                         // Not a disk file??
368
return;
369                     }
370                     String JavaDoc path = f.getAbsolutePath();
371                     int dot = path.lastIndexOf('.');
372                     if (dot > path.lastIndexOf('/')) {
373                         path = path.substring(0, dot);
374                     }
375                     buf.append(path);
376                 } else if (format.equals("relative-path-noext")) { // NOI18N
377
String JavaDoc path = entry.getKey();
378                     int dot = path.lastIndexOf('.');
379                     if (dot > path.lastIndexOf('/')) {
380                         path = path.substring(0, dot);
381                     }
382                     buf.append(path);
383                 } else {
384                     assert format.equals("java-name") : format;
385                     String JavaDoc path = entry.getKey();
386                     int dot = path.lastIndexOf('.');
387                     String JavaDoc dotless;
388                     if (dot == -1 || dot < path.lastIndexOf('/')) {
389                         dotless = path;
390                     } else {
391                         dotless = path.substring(0, dot);
392                     }
393                     String JavaDoc javaname = dotless.replace('/', '.');
394                     buf.append(javaname);
395                 }
396                 if (it.hasNext()) {
397                     assert separator != null;
398                     buf.append(separator);
399                 }
400             }
401             Element JavaDoc propEl = Util.findElement(contextEl, "property", FreeformProjectType.NS_GENERAL); // NOI18N
402
assert propEl != null : "No <property> in <context> for " + actionEl.getAttribute("name");
403             String JavaDoc prop = Util.findText(propEl);
404             assert prop != null : "Must have text contents in <property>";
405             props.setProperty(prop, buf.toString());
406         }
407         for (Element JavaDoc propEl : targets) {
408             if (!propEl.getLocalName().equals("property")) { // NOI18N
409
continue;
410             }
411             String JavaDoc rawtext = Util.findText(propEl);
412             if (rawtext == null) {
413                 // Legal to have e.g. <property name="intentionally-left-blank"/>
414
rawtext = ""; // NOI18N
415
}
416             String JavaDoc evaltext = project.evaluator().evaluate(rawtext); // might be null
417
if (evaltext != null) {
418                 props.setProperty(propEl.getAttribute("name"), evaltext); // NOI18N
419
}
420         }
421         TARGET_RUNNER.runTarget(scriptFile, targetNameArray, props);
422     }
423     
424     /**
425      * Build the context menu for a project.
426      * @param p a freeform project
427      * @return a list of actions (or null for separators)
428      */

429     public static Action JavaDoc[] createContextMenu(FreeformProject p) {
430         List JavaDoc<Action JavaDoc> actions = new ArrayList JavaDoc<Action JavaDoc>();
431         actions.add(CommonProjectActions.newFileAction());
432         // Requested actions.
433
Element JavaDoc genldata = p.getPrimaryConfigurationData();
434         Element JavaDoc viewEl = Util.findElement(genldata, "view", FreeformProjectType.NS_GENERAL); // NOI18N
435
if (viewEl != null) {
436             Element JavaDoc contextMenuEl = Util.findElement(viewEl, "context-menu", FreeformProjectType.NS_GENERAL); // NOI18N
437
if (contextMenuEl != null) {
438                 actions.add(null);
439                 for (Element JavaDoc actionEl : Util.findSubElements(contextMenuEl)) {
440                     if (actionEl.getLocalName().equals("ide-action")) { // NOI18N
441
String JavaDoc cmd = actionEl.getAttribute("name");
442                         String JavaDoc displayName;
443                         if (COMMON_IDE_GLOBAL_ACTIONS.contains(cmd) || COMMON_NON_IDE_GLOBAL_ACTIONS.contains(cmd)) {
444                             displayName = NbBundle.getMessage(Actions.class, "CMD_" + cmd);
445                         } else {
446                             // OK, fall back to raw name.
447
displayName = cmd;
448                         }
449                         actions.add(ProjectSensitiveActions.projectCommandAction(cmd, displayName, null));
450                     } else if (actionEl.getLocalName().equals("separator")) { // NOI18N
451
actions.add(null);
452                     } else {
453                         assert actionEl.getLocalName().equals("action") : actionEl;
454                         actions.add(new CustomAction(p, actionEl));
455                     }
456                 }
457             }
458         }
459         // Back to generic actions.
460
actions.add(null);
461         actions.add(CommonProjectActions.setAsMainProjectAction());
462         actions.add(CommonProjectActions.openSubprojectsAction());
463         actions.add(CommonProjectActions.closeProjectAction());
464         actions.add(null);
465         actions.add(CommonProjectActions.renameProjectAction());
466         actions.add(CommonProjectActions.moveProjectAction());
467         actions.add(CommonProjectActions.copyProjectAction());
468         actions.add(CommonProjectActions.deleteProjectAction());
469         actions.add(null);
470         actions.add(SystemAction.get(FindAction.class));
471         
472         // honor #57874 contract, see #58624:
473
actions.add(ProjectNodeWrapper.GENERIC_PROJECTS_ACTIONS_MARKER);
474         
475         actions.add(null);
476         actions.add(SystemAction.get(ToolsAction.class));
477         actions.add(null);
478         actions.add(CommonProjectActions.customizeProjectAction());
479         return actions.toArray(new Action JavaDoc[actions.size()]);
480     }
481     
482     private static final class CustomAction extends AbstractAction JavaDoc {
483
484         private final FreeformProject p;
485         private final Element JavaDoc actionEl;
486         
487         public CustomAction(FreeformProject p, Element JavaDoc actionEl) {
488             this.p = p;
489             this.actionEl = actionEl;
490         }
491         
492         public void actionPerformed(ActionEvent JavaDoc e) {
493             runConfiguredAction(p, actionEl, Lookup.EMPTY);
494         }
495         
496         public boolean isEnabled() {
497             String JavaDoc script;
498             Element JavaDoc scriptEl = Util.findElement(actionEl, "script", FreeformProjectType.NS_GENERAL); // NOI18N
499
if (scriptEl != null) {
500                 script = Util.findText(scriptEl);
501             } else {
502                 script = "build.xml"; // NOI18N
503
}
504             String JavaDoc scriptLocation = p.evaluator().evaluate(script);
505             return p.helper().resolveFileObject(scriptLocation) != null;
506         }
507         
508         public Object JavaDoc getValue(String JavaDoc key) {
509             if (key.equals(Action.NAME)) {
510                 Element JavaDoc labelEl = Util.findElement(actionEl, "label", FreeformProjectType.NS_GENERAL); // NOI18N
511
return Util.findText(labelEl);
512             } else {
513                 return super.getValue(key);
514             }
515         }
516         
517     }
518     
519     // Overridable for unit tests only:
520
static TargetRunner TARGET_RUNNER = new TargetRunner();
521     
522     static class TargetRunner {
523         public TargetRunner() {}
524         public void runTarget(FileObject scriptFile, String JavaDoc[] targetNameArray, Properties JavaDoc props) {
525             try {
526                 ActionUtils.runTarget(scriptFile, targetNameArray, props);
527             } catch (IOException JavaDoc e) {
528                 ErrorManager.getDefault().notify(e);
529             }
530         }
531     }
532     
533     /**
534      * Prompt the user to make a binding for a common global command.
535      * Available targets are shown. If one is selected, it is bound
536      * (and also added to the context menu of the project), as if the user
537      * had picked it in {@link TargetMappingPanel}.
538      * @param command the command name as in {@link ActionProvider}
539      * @return true if a binding was successfully created, false if it was cancelled
540      * @see "#46886"
541      */

542     private boolean addGlobalBinding(String JavaDoc command) {
543         try {
544             return new UnboundTargetAlert(project, command).accepted();
545         } catch (IOException JavaDoc e) {
546             // Problem generating bindings - so skip it.
547
ErrorManager.getDefault().notify(e);
548             return false;
549         }
550     }
551     
552 }
553
Popular Tags