下面列出了java.awt.event.HierarchyBoundsListener#org.openide.actions.FindAction 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@NonNull
@Override
public Action[] getActions(final boolean context) {
if (context) {
return super.getActions(context);
} else {
if (actions == null) {
actions = new Action[] {
CommonProjectActions.newFileAction(),
null,
SystemAction.get(FindAction.class),
null,
SystemAction.get(PasteAction.class ),
null,
SystemAction.get(FileSystemAction.class ),
null,
SystemAction.get(ToolsAction.class )
};
}
return actions;
}
}
private void loadAndInitActions() {
RP.post(new Runnable() {
@Override
public void run() {
createActions();
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
installKBActions();
getActionMap().put("jumpPrev", //NOI18N
action(PREV_ERROR));
getActionMap().put("jumpNext", //NOI18N
action(NEXT_ERROR));
getActionMap().put(FindAction.class.getName(),
action(FIND));
getActionMap().put(
javax.swing.text.DefaultEditorKit.copyAction,
action(COPY));
actionsLoaded = true;
updateActions();
setInputVisible(isInputVisible()); // update action
}
});
}
});
}
@Override
public Action[] getActions(boolean context) {
List<Action> actions = new ArrayList<Action>();
actions.add(CommonProjectActions.newFileAction());
actions.add(null);
actions.add(SystemAction.get(FindAction.class));
actions.add(null);
actions.add(SystemAction.get(FileSystemAction.class));
actions.add(null);
actions.add(SystemAction.get(PasteAction.class));
actions.add(null);
actions.add(SystemAction.get(ToolsAction.class));
actions.add(null);
actions.add(CommonProjectActions.customizeProjectAction());
return actions.toArray(new Action[actions.size()]);
}
@Override
public Action[] getActions(boolean context) {
if (actions == null) {
actions = new Action[9];
actions[0] = CommonProjectActions.newFileAction();
actions[1] = null;
actions[2] = SystemAction.get(FindAction.class);
actions[3] = null;
actions[4] = SystemAction.get(PasteAction.class);
actions[5] = null;
actions[6] = SystemAction.get(FileSystemAction.class);
actions[7] = null;
actions[8] = ProjectUISupport.createPreselectPropertiesAction(project, "Sources", null); //NOI18N
}
return actions;
}
/**
* Creates actions for package root.
* @return the array of {@link Action}s
*/
@NonNull
static Action[] createRootNodeActions() {
return new Action[] {
CommonProjectActions.newFileAction(),
null,
SystemAction.get( FindAction.class ),
null,
SystemAction.get( PasteAction.class ),
null,
SystemAction.get( FileSystemAction.class ),
null,
SystemAction.get( ToolsAction.class ),
};
}
private Action[] initActions () {
if (actionCache == null) {
List<Action> result = new ArrayList<Action>(2);
if (mode == Mode.FILE) {
for (Action superAction : super.getActions(false)) {
if (isOpenAction(superAction)) {
result.add(superAction);
}
}
result.add (SystemAction.get(ShowJavadocAction.class));
}
else if (mode.isFolder()) {
result.add (SystemAction.get(ShowJavadocAction.class));
Action[] superActions = super.getActions(false);
for (int i=0; i<superActions.length; i++) {
if (superActions[i] instanceof FindAction) {
result.add (superActions[i]);
}
}
if (mode.isRoot()) {
result.add (SystemAction.get(RemoveClassPathRootAction.class));
}
if (mode == Mode.EDITABLE_ROOT) {
result.add (SystemAction.get(EditRootAction.class));
}
}
actionCache = result.toArray(new Action[result.size()]);
}
return actionCache;
}
/**
* Issue #61245: Delegate application/*+xml -> text/xml
*/
public void test61245(){
MimeLookup lookup = MimeLookup.getMimeLookup("application/xml");
checkLookupObject(lookup, FindAction.class, true);
lookup = MimeLookup.getMimeLookup("application/xhtml+xml");
checkLookupObject(lookup, CutAction.class, true);
checkLookupObject(lookup, FindAction.class, false);
checkLookupObject(lookup, ReplaceAction.class, true);
}
public void testAntXmlPopup(){
MimeLookup lookup = MimeLookup.getMimeLookup("text/xml"); //NOI18N
Class layerObjects[] = {CutAction.class, CopyAction.class, PasteAction.class, ReplaceAction.class};
testPopupItems(lookup, layerObjects);
lookup = MimeLookup.getMimeLookup("text/x-ant+xml"); //NOI18N
Class layerObjects2[] = {CutAction.class, CopyAction.class, PasteAction.class, ReplaceAction.class, FindAction.class};
testPopupItems(lookup, layerObjects2);
}
/**
* Issue #61245: Delegate application/*+xml -> text/xml
*/
public void test61245(){
MimeLookup lookup = MimeLookup.getMimeLookup("application/xml");
checkLookupObject(lookup, FindAction.class, true);
lookup = MimeLookup.getMimeLookup("application/xhtml+xml");
checkLookupObject(lookup, CutAction.class, true);
checkLookupObject(lookup, FindAction.class, false);
checkLookupObject(lookup, ReplaceAction.class, true);
}
public void testAntXmlPopup(){
MimeLookup lookup = MimeLookup.getMimeLookup("text/xml"); //NOI18N
Class layerObjects[] = {CutAction.class, CopyAction.class, PasteAction.class, ReplaceAction.class};
testPopupItems(lookup, layerObjects);
lookup = MimeLookup.getMimeLookup("text/x-ant+xml"); //NOI18N
Class layerObjects2[] = {CutAction.class, CopyAction.class, PasteAction.class, ReplaceAction.class, FindAction.class};
testPopupItems(lookup, layerObjects2);
}
public @Override Action[] getActions(boolean context) {
if (actions == null) {
Set<Action> result = new LinkedHashSet<Action>();
result.add(new EditTestDependencyAction(dep, testType, project));
Action[] superActions = super.getActions(false);
for (int i = 0; i < superActions.length; i++) {
if (superActions[i] instanceof FindAction) {
result.add(superActions[i]);
}
}
result.add(LibrariesChildren.REMOVE_DEPENDENCY_ACTION);
actions = result.toArray(new Action[result.size()]);
}
return actions;
}
public Action[] getActions(boolean context) {
return new Action[]{
new EditDependencyAction(dep.getModuleEntry().getCodeNameBase(), project),
SystemAction.get(FindAction.class),
new ShowJavadocAction(dep, project),
SystemAction.get(RemoveAction.class),
};
}
private static boolean isFindAction(final Action action) {
if (action == null) {
return false;
}
if (action instanceof FindAction) {
return true;
}
if ("org.openide.actions.FindAction".equals(action.getValue("key"))) { //NOI18N
return true;
}
return false;
}
@Override
public Action[] getActions(boolean context) {
return new Action[]{
CommonProjectActions.newFileAction(),
null,
SystemAction.get(FindAction.class),
null,
SystemAction.get(PasteAction.class),
null,
SystemAction.get(PropertiesAction.class)
};
}
@Override
public Action[] getActions(boolean context) {
return new Action[]{
CommonProjectActions.newFileAction(),
null,
SystemAction.get(FindAction.class),
null,
SystemAction.get(PasteAction.class),
null,
SystemAction.get(PropertiesAction.class)
};
}
@Override
public Action[] getActions(boolean context) {
return new Action[]{
CommonProjectActions.newFileAction(),
null,
SystemAction.get(FindAction.class),
null,
SystemAction.get(PasteAction.class),
null,
SystemAction.get(PropertiesAction.class)
};
}
@Override
public Action[] getActions(boolean context) {
return new Action[] {
CommonProjectActions.newFileAction(),
SystemAction.get(TestRestServicesAction.class),
null,
SystemAction.get(FindAction.class),
null,
SystemAction.get(PasteAction.class),
null,
SystemAction.get(PropertiesAction.class)
};
}
@Override
public Action[] getActions( boolean context ) {
return new Action[] {
// CommonProjectActions.newFileAction(),
// null,
// SystemAction.get(FileSystemRefreshAction.class),
// null,
SystemAction.get(FindAction.class),
// null,
// SystemAction.get(PasteAction.class),
// null,
// SystemAction.get(ToolsAction.class),
};
}
@Override
public Action[] getActions(boolean context) {
return new Action[]{
CommonProjectActions.newFileAction(),
null,
SystemAction.get(FindAction.class),
null,
SystemAction.get(PasteAction.class),
null,
SystemAction.get(PropertiesAction.class)
};
}
@Override
public Action[] getActions(boolean context) {
return new Action[]{
CommonProjectActions.newFileAction(),
null,
SystemAction.get(FindAction.class),
null,
SystemAction.get(PasteAction.class),
null,
SystemAction.get(PropertiesAction.class)
};
}
public Action[] getActions( boolean context ) {
return new Action[] {
CommonProjectActions.newFileAction(),
null,
SystemAction.get(FileSystemAction.class),
null,
SystemAction.get(FindAction.class),
null,
SystemAction.get(PasteAction.class),
};
}
@Override
public Action[] getActions(boolean context) {
List<Action> actions = new ArrayList<>();
actions.add(CommonProjectActions.newFileAction());
actions.add(null);
if (!isTest) {
actions.add(FileSensitiveActions.fileCommandAction(DownloadCommand.ID, DownloadCommand.DISPLAY_NAME, null));
actions.add(FileSensitiveActions.fileCommandAction(UploadCommand.ID, UploadCommand.DISPLAY_NAME, null));
actions.add(FileSensitiveActions.fileCommandAction(SyncCommand.ID, SyncCommand.DISPLAY_NAME, null));
actions.add(null);
} else {
// #252010
if (project.getTestRoots().getRoots().length > 1) {
actions.add(ProjectSensitiveActions.projectCommandAction(RunTestsCommand.ID, RunTestsCommand.DISPLAY_NAME, null));
actions.add(null);
}
}
actions.add(SystemAction.get(FileSystemAction.class));
actions.add(null);
actions.add(SystemAction.get(FindAction.class));
actions.add(null);
actions.add(SystemAction.get(PasteAction.class));
actions.add(null);
actions.add(SystemAction.get(ToolsAction.class));
actions.add(null);
// customizer - open sources for source node, testing for test node
Action customizeAction = null;
if (isTest) {
customizeAction = new PhpLogicalViewProvider.CustomizeProjectAction(project, CompositePanelProviderImpl.TESTING);
} else {
customizeAction = CommonProjectActions.customizeProjectAction();
}
if (customizeAction != null) {
actions.add(customizeAction);
}
return actions.toArray(new Action[actions.size()]);
}
private Action[] getAdditionalActions() {
List<Action> actions = new ArrayList<Action>();
actions.add(CommonProjectActions.newFileAction());
actions.add(null);
actions.add(getCommandAction(GrailsActionProvider.COMMAND_BUILD, "LBL_BuildAction_Name"));
actions.add(getCommandAction(GrailsActionProvider.COMMAND_COMPILE, "LBL_Compile_Name"));
actions.add(getCommandAction(GrailsActionProvider.COMMAND_CLEAN, "LBL_CleanAction_Name"));
actions.add(getCommandAction(GrailsActionProvider.COMMAND_UPGRADE, "LBL_Upgrade_Name"));
actions.add(null);
actions.add(SystemAction.get(GrailsCommandAction.class));
actions.add(getCommandAction(GrailsActionProvider.COMMAND_GRAILS_SHELL, "LBL_ShellAction_Name"));
actions.add(new ManagePluginsAction(project));
actions.add(null);
actions.add(new ResolvePluginsAction(project));
actions.add(null);
actions.add(getCommandAction(GrailsActionProvider.COMMAND_RUN, "LBL_RunAction_Name"));
actions.add(getCommandAction(GrailsActionProvider.COMMAND_DEBUG, "LBL_DebugAction_Name"));
actions.add(getCommandAction(GrailsActionProvider.COMMAND_TEST, "LBL_TestAction_Name"));
actions.add(null);
actions.add(CommonProjectActions.setAsMainProjectAction());
actions.add(CommonProjectActions.closeProjectAction());
actions.add(null);
actions.add(SystemAction.get(FindAction.class));
actions.add(null);
actions.add(CommonProjectActions.deleteProjectAction());
actions.add(null);
// honor 57874 contact
actions.addAll(Utilities.actionsForPath("Projects/Actions")); //NOI18N
actions.add(null);
actions.add(CommonProjectActions.customizeProjectAction());
return actions.toArray(new Action[actions.size()]);
}
/**
* Sets up action Find that it is activated/deactivated appropriately
* and so that it does what it should do.
*/
private void setupActions() {
JTable bundleTable = ((BundleEditPanel) getComponent(0)).getTable();
FindAction findAction = SystemAction.get(FindAction.class);
Action action = FindPerformer.getFindPerformer(bundleTable);
getActionMap().put(findAction.getActionMapKey(), action);
}
private void registerCustomCCPActions(@Nonnull final JComponent component) {
final ActionMap actionMap = component.getActionMap();
actionMap.put(DefaultEditorKit.cutAction, this.actionCut);
actionMap.put(DefaultEditorKit.copyAction, this.actionCopy);
actionMap.put(DefaultEditorKit.pasteAction, this.actionPaste);
actionMap.put(FindAction.class.getName(), findAction);
}
@Override
@NbBundle.Messages({
"LBL_DownloadCommand=Download...",
"LBL_UploadCommand=Upload...",
"LBL_SyncCommand=Synchronize..."
})
public Action[] getActions(boolean context) {
List<Action> actions = new ArrayList<>();
actions.add(CommonProjectActions.newFileAction());
actions.add(null);
actions.add(FileSensitiveActions.fileCommandAction("dowonload", Bundle.LBL_DownloadCommand(), null));
actions.add(FileSensitiveActions.fileCommandAction("upload", Bundle.LBL_UploadCommand(), null));
actions.add(FileSensitiveActions.fileCommandAction("synchronize", Bundle.LBL_SyncCommand(), null));
actions.add(null);
actions.add(SystemAction.get(FileSystemAction.class));
actions.add(null);
actions.add(SystemAction.get(FindAction.class));
actions.add(null);
actions.add(SystemAction.get(PasteAction.class));
actions.add(null);
actions.add(SystemAction.get(ToolsAction.class));
actions.add(null);
// customizer - open sources for source node, phpunit for test node
Action customizeAction;
customizeAction = CommonProjectActions.customizeProjectAction();
actions.add(customizeAction);
return actions.toArray(new Action[actions.size()]);
}
private FindActionManager() {
super(FindInFilesAction.Selection.class, FindAction.class);
}
/** Testing Base level popup items lookup and sorting */
@RandomlyFails // NB-Core-Build #4599: resultChangedCount is:2 instead of 1
public void testDynamicChangeInPopupFolders() throws Exception {
final int resultChangedCount[] = new int[1];
resultChangedCount[0] = 0;
MimePath mp = MimePath.parse("text/x-java/text/xml/text/html");
Lookup lookup = getLookup(mp);
Lookup.Result result = lookup.lookup(new Template(PopupActions.class));
result.allInstances(); // remove this line if issue #60010 is fixed
LookupListener listener = new LookupListener(){
public void resultChanged(LookupEvent ev){
resultChangedCount[0]++;
}
};
result.addLookupListener(listener);
PopupActions actions = (PopupActions) lookup.lookup(PopupActions.class);
assertTrue("PopupActions should be found", actions != null);
List popupActions = actions.getPopupActions();
int size = popupActions.size();
assertTrue("Number of PopupActions found:"+size+" and should be:"+fsstruct.length, size == fsstruct.length);
//delete RenameAction
TestUtilities.deleteFile(getWorkDir(),
"Editors/text/html/Popup/org-openide-actions-RenameAction.instance");
checkPopupItemPresence(lookup, RenameAction.class, false);
// check firing the change
assertTrue(("resultChangedCount is:"+resultChangedCount[0]+" instead of 1"),resultChangedCount[0] == 1);
resultChangedCount[0] = 0;
//delete base CutAction
TestUtilities.deleteFile(getWorkDir(),
"Editors/Popup/org-openide-actions-CutAction.instance");
checkPopupItemPresence(lookup, CutAction.class, false);
// check firing the change
assertTrue(("resultChangedCount is:"+resultChangedCount[0]+" instead of 1"),resultChangedCount[0] == 1);
resultChangedCount[0] = 0;
//simulate module installation, new action will be added
TestUtilities.createFile(getWorkDir(),
"Editors/Popup/org-openide-actions-FindAction.instance"); //NOI18N
checkPopupItemPresence(lookup, FindAction.class, true);
// check firing the change
assertTrue(("resultChangedCount is:"+resultChangedCount[0]+" instead of 1"),resultChangedCount[0] == 1);
resultChangedCount[0] = 0;
//simulate module installation, new action will be added
TestUtilities.createFile(getWorkDir(),
"Editors/text/x-java/text/xml/text/html/Popup/org-openide-actions-ReplaceAction.instance"); //NOI18N
checkPopupItemPresence(lookup, ReplaceAction.class, true);
//ReplaceAction was created in the uppermost folder
// let's try it is missing in the lower lookup
mp = MimePath.get(MimePath.get("text/x-java"), "text/xml");
lookup = getLookup(mp);
checkPopupItemPresence(lookup, ReplaceAction.class, false);
checkPopupItemPresence(lookup, FindAction.class, true);
// lookup for ReplaceAction in the folder that doesn't exist
lookup = MimeLookup.getLookup("text/html"); //NOI18N
checkPopupItemPresence(lookup, ReplaceAction.class, false);
// create folder with ReplaceAction
TestUtilities.createFile(getWorkDir(),
"Editors/text/html/Popup/org-openide-actions-ReplaceAction.instance"); //NOI18N
checkPopupItemPresence(lookup, ReplaceAction.class, true);
}
/** Testing Base level popup items lookup and sorting */
@RandomlyFails // NB-Core-Build #3718
public void testDynamicChangeInPopupFolders() throws IOException{
final int resultChangedCount[] = new int[1];
resultChangedCount[0] = 0;
MimeLookup lookup = MimeLookup.getMimeLookup("text/x-java").childLookup("text/xml"). //NOI18N
childLookup("text/html"); //NOI18N
Lookup.Result result = lookup.lookup(new Template(PopupActions.class));
result.allInstances(); // remove this line if issue #60010 is fixed
LookupListener listener = new LookupListener(){
public void resultChanged(LookupEvent ev){
resultChangedCount[0]++;
}
};
result.addLookupListener(listener);
PopupActions actions = (PopupActions) lookup.lookup(PopupActions.class);
assertTrue("PopupActions should be found", actions != null);
List popupActions = actions.getPopupActions();
int size = popupActions.size();
assertTrue("Number of PopupActions found:"+size+" and should be:"+fsstruct.length, size == fsstruct.length);
//delete RenameAction
TestUtilities.deleteFile(getWorkDir(),
"Editors/text/html/Popup/org-openide-actions-RenameAction.instance");
checkPopupItemPresence(lookup, RenameAction.class, false);
// check firing the change
assertTrue(("resultChangedCount is:"+resultChangedCount[0]+" instead of 1"),resultChangedCount[0] == 1);
resultChangedCount[0] = 0;
//delete base CutAction
TestUtilities.deleteFile(getWorkDir(),
"Editors/Popup/org-openide-actions-CutAction.instance");
checkPopupItemPresence(lookup, CutAction.class, false);
// check firing the change
assertTrue(("resultChangedCount is:"+resultChangedCount[0]+" instead of 1"),resultChangedCount[0] == 1);
resultChangedCount[0] = 0;
//simulate module installation, new action will be added
TestUtilities.createFile(getWorkDir(),
"Editors/Popup/org-openide-actions-FindAction.instance"); //NOI18N
checkPopupItemPresence(lookup, FindAction.class, true);
// check firing the change
assertTrue(("resultChangedCount is:"+resultChangedCount[0]+" instead of 1"),resultChangedCount[0] == 1);
resultChangedCount[0] = 0;
//simulate module installation, new action will be added
TestUtilities.createFile(getWorkDir(),
"Editors/text/x-java/text/xml/text/html/Popup/org-openide-actions-ReplaceAction.instance"); //NOI18N
checkPopupItemPresence(lookup, ReplaceAction.class, true);
//ReplaceAction was created in the uppermost folder
// let's try it is missing in the lower lookup
lookup = MimeLookup.getMimeLookup("text/x-java").childLookup("text/xml"); //NOI18N
checkPopupItemPresence(lookup, ReplaceAction.class, false);
checkPopupItemPresence(lookup, FindAction.class, true);
// lookup for ReplaceAction in the folder that doesn't exist
lookup = MimeLookup.getMimeLookup("text/html"); //NOI18N
checkPopupItemPresence(lookup, ReplaceAction.class, false);
// create folder with ReplaceAction
TestUtilities.createFile(getWorkDir(),
"Editors/text/html/Popup/org-openide-actions-ReplaceAction.instance"); //NOI18N
checkPopupItemPresence(lookup, ReplaceAction.class, true);
}
@Override
public javax.swing.Action[] getActions(boolean context) {
return new javax.swing.Action[]{SystemAction.get(FindAction.class)};
}