org.openide.util.lookup.Lookups Java Examples

The following examples show how to use org.openide.util.lookup.Lookups. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OnSaveTabSelector.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private PreferencesCustomizer getCustomizer(String mimeType) {
    PreferencesCustomizer customizer = allCustomizers.get(mimeType);
    if (customizer == null) {
        Preferences prefs = preferencesFactory.getPreferences(mimeType);
        if (mimeType.length() > 0) {
            Lookup l = Lookups.forPath(ON_SAVE_CUSTOMIZERS_FOLDER + mimeType);
            PreferencesCustomizer.Factory factory = l.lookup(PreferencesCustomizer.Factory.class);
            if (factory != null) {
                customizer = factory.create(prefs);
            }
        } else {
            customizer = null;
        }
        allCustomizers.put(selectedMimeType, customizer);
    }
    return customizer;
}
 
Example #2
Source File: NbMavenProjectImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private Lookup createBasicLookup(ProjectState state, M2AuxilaryConfigImpl auxiliary) {
    return Lookups.fixed(
                this,
                fileObject,
                auxiliary,
                auxiliary.getProblemProvider(),
                auxprops,
                new MavenProjectPropsImpl.Merger(auxprops),
                profileHandler,
                configProvider,
                problemReporter,
                watcher,
                state,
                UILookupMergerSupport.createPrivilegedTemplatesMerger(),
                UILookupMergerSupport.createRecommendedTemplatesMerger(),
                UILookupMergerSupport.createProjectProblemsProviderMerger(),
                LookupProviderSupport.createSourcesMerger(),
                LookupProviderSupport.createSharabilityQueryMerger(),
                ProjectClassPathModifier.extenderForModifier(this),
                LookupMergerSupport.createClassPathModifierMerger(),
                new UnitTestsCompilerOptionsQueryImpl(this),
                new PomCompilerOptionsQueryImpl(this),
                LookupMergerSupport.createCompilerOptionsQueryMerger()
    );
}
 
Example #3
Source File: NbEditorToolBarTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that the action context for the context-aware toolbar actions
 * is the first Lookup.Provider ancestor.
 */
public void testActionContextAncestorsLookupProviderIsPreferred() throws Exception {
    JPanel parent1 = new LookupPanel(Lookups.singleton(new Foo() { }));
    JPanel parent2 = new LookupPanel(Lookups.singleton(new Bar() { }));
    parent1.add(parent2);
    JEditorPane editor = new JEditorPane();
    editor.setEditorKit(new NbEditorKit());
    parent2.add(editor);
    DataObject docDataObject = createDataObject();
    assertNotNull(docDataObject);
    editor.getDocument().putProperty(Document.StreamDescriptionProperty, docDataObject);

    Lookup actionContext = NbEditorToolBar.createActionContext(editor);
    assertNotNull(actionContext.lookup(Bar.class));
    assertNotNull(actionContext.lookup(Node.class));
    assertNull(actionContext.lookup(Foo.class));
}
 
Example #4
Source File: TabbedController.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void readPanels() {
    Lookup lookup = Lookups.forPath(tabFolder);
    options = lookup.lookup(new Lookup.Template<AdvancedOption>( AdvancedOption.class ));
    tabTitle2controller = new HashMap<String, OptionsPanelController>();
    id2tabTitle = new HashMap<String, String>();
    synchronized (tabTitle2Option) {
        for (Lookup.Item<AdvancedOption> item : options.allItems()) {
            AdvancedOption option = item.getInstance();
            String displayName = option.getDisplayName();
            if (displayName != null) {
                tabTitle2Option.put(displayName, option);
                String id = item.getId().substring(item.getId().lastIndexOf('/') + 1);  //NOI18N
                id2tabTitle.put(id, displayName);
            } else {
                LOGGER.log(Level.WARNING, "Display name not defined: {0}", item.toString());  //NOI18N
            }
        }
    }
}
 
Example #5
Source File: FileActionTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected @Override void setUp() throws Exception {
    super.setUp();
    System.setProperty("sync.project.execution", "true");
    MockServices.setServices(TestSupport.TestProjectFactory.class);
    clearWorkDir();
    FileObject workDir = FileUtil.toFileObject(getWorkDir());

    
    p1 = TestSupport.createTestProject( workDir, "project1" );
    f1_1 = p1.createData("f1_1.java");
    f1_2 = p1.createData("f1_2.krava");
    d1_1 = DataObject.find(f1_1);
    d1_2 = DataObject.find(f1_2);
           
    project1 = (TestSupport.TestProject)ProjectManager.getDefault().findProject( p1 );
    project1.setLookup( Lookups.fixed( new Object[] { new TestActionProvider() } ) );  
    
    p2 = TestSupport.createTestProject( workDir, "project2" );
    f2_1 = p2.createData("f2_1.java");
    f2_2 = p2.createData("f2_2.krava");
    d2_1 = DataObject.find(f2_1);
    d2_2 = DataObject.find(f2_2);
           
    project2 = (TestSupport.TestProject)ProjectManager.getDefault().findProject( p2 );
    
}
 
Example #6
Source File: LookupUsesRequestProcessorTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testMetaInfLookupDeliversEventsInRPThread() throws InterruptedException {
    ClassLoader l = new MyCL();
    Lookup lkp = Lookups.metaInfServices(l);
    Lookup.Result<Runnable> result = lkp.lookupResult(Runnable.class);
    result.addLookupListener(this);

    assertNull("No runnables found", lkp.lookup(Runnable.class));
    assertNotNull("Thread found", lkp.lookup(Thread.class));
    assertNotNull("Now runnable found", lkp.lookup(Runnable.class));
    synchronized (this) {
        int retry = 5;
        while (cnt == 0 && retry-- > 0) {
            wait(1000);
        }
    }    
    assertEquals("Count is now 1", 1, cnt);
}
 
Example #7
Source File: MoveClassUI.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private Problem setParameters(boolean checkOnly) {
    if (panel == null) {
        return null;
    }
    targetPkgName = panel.getPackageName();

    URL url = URLMapper.findURL(panel.getRootFolder(), URLMapper.EXTERNAL);
    try {
        TreePathHandle targetClass = panel.getTargetClass();
        if(targetClass != null) {
            refactoring.setTarget(Lookups.singleton(targetClass));
        } else {
            refactoring.setTarget(Lookups.singleton(new URL(url.toExternalForm() + panel.getPackageName().replace('.', '/')))); // NOI18N
        }
    } catch (MalformedURLException ex) {
        Exceptions.printStackTrace(ex);
    }
    if (checkOnly) {
        return refactoring.fastCheckParameters();
    } else {
        return refactoring.checkParameters();
    }
}
 
Example #8
Source File: Nodes.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public FixNode(ErrorDescription ed, FixDescription fix) {
    super(Children.LEAF, Lookups.fixed(new OpenCookieImpl(ed), fix));
    this.fix = fix;

    int line = -1;
    try {
        line = ed.getRange().getBegin().getLine();
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
    
    setDisplayName((line != (-1) ? (line + ":") : "") + fix.getText() + "(" + ed.getDescription() + ")");
    setIconBaseWithExtension("org/netbeans/modules/java/hints/analyzer/ui/suggestion.png");
    
    fix.addChangeListener(this);
}
 
Example #9
Source File: FindUsagesTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void test200843() throws IOException, InterruptedException, ExecutionException {
    FileObject testFile = projectDir.getFileObject("/src/simplej2seapp/D.java");
    JavaSource src = JavaSource.forFileObject(testFile);
    final WhereUsedQuery[] wuq = new WhereUsedQuery[1];
    src.runWhenScanFinished(new Task<CompilationController>() {

        @Override
        public void run(CompilationController controller) throws Exception {
            controller.toPhase(JavaSource.Phase.RESOLVED);
            ClassTree klass = (ClassTree) controller.getCompilationUnit().getTypeDecls().get(0);
            MethodTree runTree = (MethodTree) klass.getMembers().get(1);
            TreePath path = controller.getTrees().getPath(controller.getCompilationUnit(), runTree);
            TreePathHandle element = TreePathHandle.create(path, controller);
            Element method = controller.getTrees().getElement(path);
            Collection<ExecutableElement> overridens = JavaRefactoringUtils.getOverriddenMethods((ExecutableElement)method, controller);
            wuq[0] = new WhereUsedQuery(Lookups.singleton(TreePathHandle.create(overridens.iterator().next(), controller)));
            wuq[0].getContext().add(element);
        }
    }, false).get();
    setParameters(wuq, true, false, false, false, false, true);

    doRefactoring("test200843", wuq, 1);
}
 
Example #10
Source File: DOMNode.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Action[] getActions(boolean context) {
    List<Action> actions = new ArrayList<Action>();
    actions.add(SystemAction.get(GoToNodeSourceAction.class));
    if (KnockoutTCController.isKnockoutUsed()) {
        actions.add(SystemAction.get(ShowKnockoutContextAction.class));
    }
    if (node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
        for (Action action : org.openide.util.Utilities.actionsForPath(ACTIONS_PATH)) {
            if (action instanceof ContextAwareAction) {
                Lookup lookup = new ProxyLookup(Lookups.fixed(this), getLookup());
                action = ((ContextAwareAction)action).createContextAwareInstance(lookup);
            }
            actions.add(action);
        }
        actions.add(null);
        actions.add(SystemAction.get(PropertiesAction.class));
    }
    return actions.toArray(new Action[actions.size()]);
}
 
Example #11
Source File: LookupProviderImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static Lookup initLookup(Project project, AntProjectHelper projectHelper, PropertyEvaluator projectEvaluator, AuxiliaryConfiguration aux) {
    final SourceForBinaryQueryImpl sfbq = new SourceForBinaryQueryImpl(projectHelper, projectEvaluator, aux);
    final Classpaths cp = new Classpaths(projectHelper, projectEvaluator, aux, sfbq);
    return Lookups.fixed(
        cp, // ClassPathProvider
        new SourceLevelQueryImpl(projectHelper, projectEvaluator, aux), // SourceLevelQueryImplementation
        sfbq,   // SourceForBinaryQueryImplementation
        new AnnotationProcessingQueryImpl(projectHelper, projectEvaluator, aux),
        new OpenHook(project, cp), // ProjectOpenedHook
        new TestQuery(projectHelper, projectEvaluator, aux), // MultipleRootsUnitTestForSourceQueryImplementation
        new JavadocQuery(projectHelper, projectEvaluator, aux), // JavadocForBinaryQueryImplementation
        new PrivilegedTemplatesImpl(), // PrivilegedTemplates
        new JavaActions(project, projectHelper, projectEvaluator, aux), // ActionProvider
        // XXX could use LookupMergerSupport.createClassPathProviderMerger here, though ClasspathsTest then fails:
        new LookupMergerImpl(), // LookupMerger
        new JavaFreeformFileBuiltQuery(project, projectHelper, projectEvaluator, aux), // FileBuiltQueryImplementation
        new HelpIDFragmentProviderImpl());
}
 
Example #12
Source File: DerbyDatabasesTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testDatabaseSilentlyNotExtractedIfExists() {
    final boolean[] exceptionHappend = new boolean[1];
    
    Lookups.executeWith(sampleDBLookup, new Runnable() {

        @Override
        public void run() {
            try {
                DerbyDatabasesImpl.getDefault().extractSampleDatabase("sample2", false);
                DerbyDatabasesImpl.getDefault().extractSampleDatabase("sample2", false);
            } catch (IOException ex) {
                exceptionHappend[0] = true;
            }
        }
    });
    
    assertFalse("Extracting sample db was not interrupted", exceptionHappend[0]);
}
 
Example #13
Source File: DataNodeTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testDataNodeGetDataFromLookup() throws Exception {

        DataFolder rootFolder = DataFolder.findFolder(FileUtil.getConfigRoot());
        
        class C implements Node.Cookie {
        }
        
        String objectToLookup = "I like my Lookup";
        C cookieToLookup = new C();
        Lookup lookup = Lookups.fixed(new Object[] { objectToLookup, cookieToLookup });
        
        DataNode node = new DataNode(rootFolder, Children.LEAF, lookup);
        Object objectLookedUp = node.getLookup().lookup(String.class);
        assertEquals("object is going to be found", objectToLookup, objectLookedUp);
        assertEquals("cookie found.", cookieToLookup, node.getLookup().lookup(C.class));

        //assertNull("Cannot return string as cookie", node.getCookie(String.class));
        assertEquals("But C is found", cookieToLookup, node.getCookie(C.class));
        
        assertNull("Data object is not found in lookup", node.getLookup().lookup(DataObject.class));
        assertNull("DataObject not found in cookies as they delegate to lookup", node.getCookie(DataObject.class));
    }
 
Example #14
Source File: CompilerOptionsQueryMergerTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testUnmergedResults() {
    final CompilerOptionsQueryImpl impl1 = new CompilerOptionsQueryImpl();
    final CompilerOptionsQueryImpl impl2 = new CompilerOptionsQueryImpl();
    impl1.addRoot(root1).addArgs("a1", "a2");   //NOI18N
    impl2.addRoot(root2).addArgs("b1", "b2");   //NOI18N
    final Lookup baseLkp = Lookups.fixed(
            impl1,
            impl2);
    final CompilerOptionsQueryImplementation merged =
            LookupMergerSupport.createCompilerOptionsQueryMerger()
            .merge(baseLkp);
    final CompilerOptionsQueryImplementation.Result res1 = merged.getOptions(root1);
    assertEquals(
            Arrays.asList("a1","a2"), //NOI18N
            res1.getArguments());
    final CompilerOptionsQueryImplementation.Result res2 = merged.getOptions(root2);
    assertEquals(
            Arrays.asList("b1","b2"), //NOI18N
            res2.getArguments());
}
 
Example #15
Source File: OpenProjectListSetMainTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
    clearWorkDir();
    
    MockServices.setServices(TestSupport.TestProjectFactory.class);
    
    FileObject workDir = FileUtil.toFileObject(getWorkDir());
    assertNotNull(workDir);
    
    down = new CountDownLatch(1);
    
    List<URL> list = new ArrayList<URL>();
    List<ExtIcon> icons = new ArrayList<ExtIcon>();
    List<String> names = new ArrayList<String>();
    for (int i = 0; i < 30; i++) {
        FileObject prj = TestSupport.createTestProject(workDir, "prj" + i);
        URL url = URLMapper.findURL(prj, URLMapper.EXTERNAL);
        list.add(url);
        names.add(url.toExternalForm());
        icons.add(new ExtIcon());
        TestSupport.TestProject tmp = (TestSupport.TestProject)ProjectManager.getDefault ().findProject (prj);
        assertNotNull("Project found", tmp);
        tmp.setLookup(Lookups.singleton(new TestProjectOpenedHookImpl(down)));
    }
    
    OpenProjectListSettings.getInstance().setOpenProjectsURLs(list);
    OpenProjectListSettings.getInstance().setOpenProjectsDisplayNames(names);
    OpenProjectListSettings.getInstance().setOpenProjectsIcons(icons);
    
     //compute project root node children in sync mode
    System.setProperty("test.projectnode.sync", "true");
}
 
Example #16
Source File: AppclientLookupProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Lookup createAdditionalLookup(Lookup baseContext) {
    final Project project = baseContext.lookup(Project.class);
    AppclientWsitProvider wsitProvider = new AppclientWsitProvider(project);

    return Lookups.fixed(new Object[] {
        wsitProvider,
        });
}
 
Example #17
Source File: DirtyStrategiesNode.java    From BART with MIT License 5 votes vote down vote up
public DirtyStrategiesNode(EGTask task,EGTaskDataObjectDataObject dto) {
    super(Children.create(new DirtyStrategiesFactory(dto, task), true), 
            new ProxyLookup(Lookups.fixed(task,dto),dto.getAbstractLookup()));
    setName(NodeResource.NODE_DirtyStrategiesNode);
    setShortDescription(Bundle.HINT_DirtyStrategiesNode());
    setIconBaseWithExtension(R.IMAGE_NODE_DIRTYSTRATEGIES);
    DirtyStrategiesNodeNotifier.addChangeListener(listener = new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            fireDisplayNameChange(null, "");
        }
    });
}
 
Example #18
Source File: RandomErrorTableNode.java    From BART with MIT License 5 votes vote down vote up
public RandomErrorTableNode(EGTask egt,EGTaskDataObjectDataObject dto,String tableName) {
    super(Children.create(new RandomErrorAttributeFactory(egt,dto,tableName), true),
            new ProxyLookup(Lookups.fixed(egt,dto),dto.getAbstractLookup()));
    this.tabName=tableName;
    setName(NodeResource.NODE_RandomErrorTableNode);
    setShortDescription(Bundle.HINT_RandomErrorTableNode());
    setIconBaseWithExtension(R.IMAGE_NODE_ARROW); 
}
 
Example #19
Source File: JAXBBindingSupportFileNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static Lookup createLookup(FileObject xsdFileObject, 
                                    Project prj) {
    return Lookups.fixed( new Object[] {
        xsdFileObject,
        prj
    } );
}
 
Example #20
Source File: WarmUpSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    err.fine("Warmup starting..."); // NOI18N
    StartLog.logStart("Warmup"); // NOI18N
    try {

    Collection<? extends Lookup.Item<Runnable>> warmObjects =
        Lookups.forPath("WarmUp").lookupResult(Runnable.class).allItems(); // NOI18N
    err.log(Level.FINE, "Found {0} warm up task(s)", warmObjects.size()); // NOI18N

    for (Lookup.Item<Runnable> warmer : warmObjects) {
        try {
            Runnable r = warmer.getInstance();
            if (r == null) {
              err.log(Level.WARNING,
                  "Got null warmup task from lookup: id={0}, displayName={1}, class={2}, type={3}",
                  new Object[] {
                  warmer.getId(), warmer.getDisplayName(), warmer.getClass(), warmer.getType() });
            } else {
              r.run();
              StartLog.logProgress("Warmup task executed " + warmer.getId()); // NOI18N
            }
        } catch (Exception ex) {
            Logger.getLogger(WarmUpSupport.class.getName()).log(Level.WARNING, null, ex);
        }
    }
    err.fine("Warmup done."); // NOI18N
    } finally {
    StartLog.logEnd("Warmup"); // NOI18N
    StartLog.impl.flush();
    }
}
 
Example #21
Source File: FeatureProjectFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public FeatureDelegate(FileObject dir, FeatureNonProject feature) {
    this.dir = dir;
    this.hook = feature.new FeatureOpenHook();
    ic.add(UILookupMergerSupport.createProjectOpenHookMerger(hook));
    this.delegate = new ProxyLookup(
        Lookups.fixed(feature, this),
        LookupProviderSupport.createCompositeLookup(
            hooks, "../nonsence" // NOI18N
        )
    );
    this.support = new PropertyChangeSupport(this);
}
 
Example #22
Source File: RenameTestClassRefactoringPlugin.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void addIfMatch(LocationResult location, final TestLocator testLocator, final FileObject fileObject, final List<RenameRefactoring> renameRefactoringsList) {
    if(location.getFileObject() != null && testLocator.getFileType(location.getFileObject()).equals(TestLocator.FileType.TEST)) {
        RenameRefactoring renameRefactoring = new RenameRefactoring(Lookups.singleton(location.getFileObject()));
        renameRefactoring.setNewName(newName(fileObject, location.getFileObject(), refactoring.getNewName()));
        renameRefactoring.setSearchInComments(true);
        renameRefactoringsList.add(renameRefactoring);
    }
}
 
Example #23
Source File: ModuleNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static Lookup createLookup(
        @NonNull final String moduleName,
        @NonNull final URI binUri,
        @NullAllowed final Consumer<Pair<String,String>> preRemoveAction,
        @NullAllowed final Consumer<Pair<String,String>> postRemoveAction) {
    return Lookups.fixed(
            new JavadocProvider(moduleName, binUri),
            new Remove(preRemoveAction, postRemoveAction));
}
 
Example #24
Source File: MainImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Checks for new JARs in netbeans.user */
@Override
public void run () {
    // do not call this method twice
    if (onlyRunRunOnce) return;
    onlyRunRunOnce = true;

    ArrayList<File> toAdd = new ArrayList<File> ();
    String user = System.getProperty ("netbeans.user"); // NOI18N
    try {
        if (user != null) {
            JarClassLoader.initializeCache();
            
            build_cp (new File (user), toAdd, new HashSet<File> (), new HashSet<String> ());

        }

        if (!toAdd.isEmpty ()) {
            // source were already added in MainImpl.execute() method while processing userdir
            metaInf = Lookups.metaInfServices(this);
            if (handlers != null) {
                handlers.clear();
                handlers.addAll(metaInf.lookupAll(CLIHandler.class));
            }
        }
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}
 
Example #25
Source File: RunCustomMavenAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override public void actionPerformed(ActionEvent e) {
    if (prj != null) {
        prj.getLookup().lookup(ActionProvider.class).invokeAction(action, Lookups.fixed((Object) fos));
    } else {
        //in editor press shortcut and you end up here.. why?
        //guess prj based on global looukup?
        Action act = createContextAwareInstance(Utilities.actionsGlobalContext());
        if (act != this) {
            act.actionPerformed(e);
        }
    }
}
 
Example #26
Source File: ReusableEditor2Test.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private CES createSupport(String txt) {
    Env env = new Env();
    env.content = txt;
    CES c = new CES(env, Lookups.singleton(txt));
    env.support = c;
    return c;
}
 
Example #27
Source File: TestUtilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Set the global default lookup with some fixed instances including META-INF/services/*.
 */
public static void setLookup(Object... instances) {
    ClassLoader l = TestUtilities.class.getClassLoader();
    DEFAULT.setLookups(new Lookup[] {
        Lookups.fixed(instances),
        Lookups.metaInfServices(l),
        Lookups.singleton(l),
        projects
    });
}
 
Example #28
Source File: ChromeBrowserImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Lookup createLookup() {
    List<Lookup> lookups = new ArrayList<Lookup>();
    if (hasEnhancedMode()) {
        lookups.add(Lookups.fixed(
                    new MessageDispatcherImpl(),
                    new RemoteScriptExecutor(this),
                    new PageInspectionHandleImpl(this)
                ));
        WebKitDebuggingTransport transport = new WebKitDebuggingTransport(
                this);
        lookups.add(Lookups.fixed(transport,
                Factory.createWebKitDebugging(transport)));
    }
    return new ProxyLookup(lookups.toArray(new Lookup[lookups.size()]));
}
 
Example #29
Source File: RenameRefactoringUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public RenameRefactoringUI(RefactoringElement element) {
    name = element.getName();
    Collection<Object> lookupContent = new ArrayList<Object>();
    lookupContent.add(element);
    refactoring = new RenameRefactoring(Lookups.fixed(lookupContent.toArray()));
    refactoring.getContext().add(UI.Constants.REQUEST_PREVIEW);
}
 
Example #30
Source File: DefaultReplaceTokenProviderTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testNgSingle() throws Exception {
    TestFileUtils.writeFile(d, "pom.xml", "<project><modelVersion>4.0.0</modelVersion>"
            + "<groupId>g</groupId><artifactId>a</artifactId><version>0</version></project>");
    TestFileUtils.writeFile(d, "src/test/java/p1/FirstNGTest.java", "package p1; class FirstNGTest {}");
    TestFileUtils.writeFile(d, "src/main/java/p1/First.java", "package p1; class First {}");
    
    Project p = ProjectManager.getDefault().findProject(d);
    assertEquals("p1.FirstNGTest", ActionProviderImpl.replacements(p, ActionProvider.COMMAND_TEST_SINGLE, Lookups.singleton(d.getFileObject("src/main/java/p1/First.java"))).get(DefaultReplaceTokenProvider.PACK_CLASSNAME));

}