本文整理汇总了Java中org.openide.filesystems.FileUtil.getConfigObject方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.getConfigObject方法的具体用法?Java FileUtil.getConfigObject怎么用?Java FileUtil.getConfigObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.filesystems.FileUtil
的用法示例。
在下文中一共展示了FileUtil.getConfigObject方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyRegistered
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@Test public void verifyRegistered() {
final String path = "Actions/Test/html-test.instance";
final FileObject fo = FileUtil.getConfigFile(path);
assertNotNull(fo, "Registration found");
Action a = FileUtil.getConfigObject(path, Action.class);
assertNotNull(a, "Action found");
assertEquals(a.getValue(Action.NAME), "Open me!");
assertEquals(fo.getAttribute("class"), OpenHTMLRegistrationTest.class.getCanonicalName(), "Fully qualified name");
assertEquals(fo.getAttribute("method"), "main");
class FOMap extends HashMap<String,Object> {
@Override
public Object get(Object key) {
return fo.getAttribute(key.toString());
}
}
Pages.R r = new Pages.R(new FOMap());
Object[] arr = r.getTechIds();
assertEquals(arr.length, 3, "Three different ids");
assertEquals(arr[0], "uno");
assertEquals(arr[1], "duo");
assertEquals(arr[2], "tre");
}
示例2: setShowEditorToolbar
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private static boolean setShowEditorToolbar( boolean show ) {
boolean res = true;
Action toggleEditorToolbar = FileUtil.getConfigObject( "Editors/Actions/toggle-toolbar.instance", Action.class ); //NOI18N
if( null != toggleEditorToolbar ) {
if( toggleEditorToolbar instanceof Presenter.Menu ) {
JMenuItem menuItem = ((Presenter.Menu)toggleEditorToolbar).getMenuPresenter();
if( menuItem instanceof JCheckBoxMenuItem ) {
JCheckBoxMenuItem checkBoxMenu = ( JCheckBoxMenuItem ) menuItem;
res = checkBoxMenu.isSelected();
if( checkBoxMenu.isSelected() != show ) {
try {
toggleEditorToolbar.actionPerformed( new ActionEvent( menuItem, 0, "")); //NOII18N
} catch( Exception ex ) {
//don't worry too much if it isn't working, we're just trying to be helpful here
Logger.getLogger( EditorOnlyDisplayer.class.getName()).log( Level.FINE, null, ex );
}
}
}
}
}
return res;
}
示例3: forID
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/**
* Locates a specific action programmatically.
* The action will typically have been registered using {@link ActionRegistration}.
* <p>Normally an {@link ActionReference} will suffice to insert the action
* into various UI elements (typically using {@link Utilities#actionsForPath}),
* but in special circumstances you may need to find a single known action.
* This method is just a shortcut for using {@link FileUtil#getConfigObject}
* with the correct arguments, plus using {@link AcceleratorBinding#setAccelerator}.
* @param category as in {@link ActionID#category}
* @param id as in {@link ActionID#id}
* @return the action registered under that ID, or null
* @throws IllegalArgumentException if a corresponding {@link ActionID} would have been rejected
* @since 7.42
*/
public static Action forID(String category, String id) throws IllegalArgumentException {
// copied from ActionProcessor:
if (category.startsWith("Actions/")) {
throw new IllegalArgumentException("category should not start with Actions/: " + category);
}
if (!FQN.matcher(id).matches()) {
throw new IllegalArgumentException("id must be valid fully qualified name: " + id);
}
String path = "Actions/" + category + "/" + id.replace('.', '-') + ".instance";
Action a = FileUtil.getConfigObject(path, Action.class);
if (a == null) {
return null;
}
FileObject def = FileUtil.getConfigFile(path);
if (def != null) {
AcceleratorBinding.setAccelerator(a, def);
}
return a;
}
示例4: close
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
void close() {
if (isQuery) {
RefactoringPanelContainer.getUsagesComponent().removePanel(this);
} else {
RefactoringPanelContainer.getRefactoringComponent().removePanel(this);
}
if(isVisible) {
Action action = FileUtil.getConfigObject("Actions/Window/org-netbeans-core-windows-actions-SwitchToRecentDocumentAction.instance", Action.class); //NOI18N
if(action != null) {
action.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null));
}
}
closeNotify();
}
示例5: resolve
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@Override
public Future<Result> resolve() {
FutureTask<Result> toRet = new FutureTask<Result>(new Callable<Result>() {
@Override
public Result call() throws Exception {
NotifyDescriptor.Confirmation action = new NotifyDescriptor.Confirmation("You can either define netbeans.installation property in .m2/settings.xml file to point to currently running IDE or open the associated nbm-application project.", "Resolve missing NetBeans platform");
String prop = "Define property";
String open = "Open Application project";
action.setOptions(new Object[] { prop, open, NotifyDescriptor.CANCEL_OPTION});
Object result = DialogDisplayer.getDefault().notify(action);
if (prop.equals(result)) {
RunIDEInstallationChecker.setRunningIDEAsInstallation();
return Result.create(Status.RESOLVED);
}
if (open.equals(result)) {
final Action act = FileUtil.getConfigObject("Actions/Project/org-netbeans-modules-project-ui-OpenProject.instance", Action.class);
if (act != null) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
act.actionPerformed(null);
}
});
}
}
return Result.create(Status.UNRESOLVED);
}
});
toRet.run();
return toRet;
}
示例6: getIntentHandlers
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private static SortedSet<IntentHandler> getIntentHandlers(
Intent intent) {
FileObject f = FileUtil.getConfigFile("Services/Intent/Handlers");
if (f == null) {
return null;
}
SortedSet<IntentHandler> candidates = new TreeSet<>();
for (FileObject fo : f.getChildren()) {
if ("instance".equals(fo.getExt())) {
Object pattern = fo.getAttribute("uriPattern");
Object displayName = fo.getAttribute("displayName");
Object position = fo.getAttribute("position");
Object actions = fo.getAttribute("actions");
if (pattern instanceof String && displayName instanceof String
&& position instanceof Integer
&& actions instanceof String) {
if (canSupport((String) pattern, (String) actions, intent)) {
try {
IntentHandler ih = FileUtil.getConfigObject(
fo.getPath(), IntentHandler.class);
candidates.add(ih);
} catch (Exception e) {
LOG.log(Level.INFO,
"Cannot instantiate handler for " //NOI18N
+ fo.getPath(), e);
}
}
} else {
LOG.log(Level.FINE, "Invalid URI handler {0}", fo.getPath());
}
}
}
return candidates;
}
示例7: getAcceleratedAction
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public static Action getAcceleratedAction(String path) {
// or use Actions.forID
Action a = FileUtil.getConfigObject(path, Action.class);
FileObject fo = FileUtil.getConfigFile(path);
if(fo != null) {
AcceleratorBinding.setAccelerator(a, fo);
}
return a;
}
示例8: missingNavigatorAPIHack
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
static void missingNavigatorAPIHack(
@NonNull final ActionEvent ev,
@NonNull final JavaSource context,
@NullAllowed final JTextComponent target) {
final Action openNavigator = FileUtil.getConfigObject(
"Actions/Window/org-netbeans-modules-navigator-ShowNavigatorAction.instance",
Action.class);
if (openNavigator != null) {
openNavigator.actionPerformed(ev);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
NavigatorHandler.activateNavigator();
final Collection<? extends NavigatorPanel> panels = getPanels(context);
NavigatorPanel cmp = null;
for (NavigatorPanel panel : panels) {
if (panel.getComponent().getClass() == ClassMemberPanelUI.class) {
cmp = panel;
break;
}
}
if (cmp != null) {
NavigatorHandler.activatePanel(cmp);
((ClassMemberPanelUI)cmp.getComponent()).setContext(context, target);
}
}
});
}
}
示例9: testSharedClassObject
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testSharedClassObject() throws Exception {
Shared instance = SharedClassObject.findObject(Shared.class, true);
FileObject data = FileUtil.createData(root, "dir/" + Shared.class.getName().replace('.', '-') + ".instance");
Lookup l = Lookups.forPath("dir");
assertSame(instance, l.lookup(Shared.class));
Shared created = FileUtil.getConfigObject(data.getPath(), Shared.class);
assertSame("Config file found", instance, created);
}
示例10: btnGlobalActionPerformed
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private void btnGlobalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGlobalActionPerformed
// TODO add your handling code here:
Action action = FileUtil.getConfigObject("Actions/System/org-netbeans-modules-templates-actions-TemplatesAction.instance", Action.class);
if (action != null) {
System.setProperty("org.netbeans.modules.templates.actions.TemplatesAction.preselect", "Licenses");
action.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "perform"));
} else {
Exceptions.printStackTrace(new Exception("Actions/System/org-netbeans-modules-templates-actions-TemplatesAction.instance not found"));
}
}
示例11: installKeybindings
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private void installKeybindings(JTextComponent component) {
// Register Escape key
registerKeybinding(ACTION_ESCAPE, ESCAPE,
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
ExtKit.escapeAction, component);
// Register up key
registerKeybinding(ACTION_COMPLETION_UP, COMPLETION_UP,
KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0),
BaseKit.upAction, component);
// Register down key
registerKeybinding(ACTION_COMPLETION_DOWN, COMPLETION_DOWN,
KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0),
BaseKit.downAction, component);
// Register PgDn key
registerKeybinding(ACTION_COMPLETION_PGDN, COMPLETION_PGDN,
KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0),
BaseKit.pageDownAction, component);
// Register PgUp key
registerKeybinding(ACTION_COMPLETION_PGUP, COMPLETION_PGUP,
KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0),
BaseKit.pageUpAction, component);
// Register home key
registerKeybinding(ACTION_COMPLETION_BEGIN, COMPLETION_BEGIN,
KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0),
BaseKit.beginLineAction, component);
// Register end key
registerKeybinding(ACTION_COMPLETION_END, COMPLETION_END,
KeyStroke.getKeyStroke(KeyEvent.VK_END, 0),
BaseKit.endLineAction, component);
Action action = FileUtil.getConfigObject("Actions/Source/org-netbeans-modules-editor-hints-FixAction.instance", Action.class); //NOI18N
KeyStroke ks = action != null ? (KeyStroke) action.getValue(Action.ACCELERATOR_KEY) : null;
registerKeybinding(ACTION_COMPLETION_SUBITEMS_SHOW, COMPLETION_SUBITEMS_SHOW,
ks != null ? ks : KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.ALT_MASK),
null, component);
}
示例12: testNullForFolders
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testNullForFolders() throws Exception {
FileObject data = FileUtil.createFolder(root, "dir/" + Shared.class.getName().replace('.', '-') + ".instance");
Shared nul = FileUtil.getConfigObject(data.getPath(), Shared.class);
assertNull("No object for folders", nul);
}
示例13: getShowLogAction
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
static Action getShowLogAction() {
return FileUtil.getConfigObject("Actions/View/org-netbeans-core-actions-LogAction.instance", Action.class); // NOI18N
}
示例14: getGlobalKitAction
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@Override
protected Action getGlobalKitAction() {
return FileUtil.getConfigObject("Editors/private/GlobalFormatAction.instance", Action.class);
}