当前位置: 首页>>代码示例>>Java>>正文


Java OpenProjects类代码示例

本文整理汇总了Java中org.netbeans.api.project.ui.OpenProjects的典型用法代码示例。如果您正苦于以下问题:Java OpenProjects类的具体用法?Java OpenProjects怎么用?Java OpenProjects使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OpenProjects类属于org.netbeans.api.project.ui包,在下文中一共展示了OpenProjects类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isOnSourceClasspath

import org.netbeans.api.project.ui.OpenProjects; //导入依赖的package包/类
public static boolean isOnSourceClasspath(FileObject fo) {
    Project p = FileOwnerQuery.getOwner(fo);
    if (p==null) {
        return false;
    }
    if (OpenProjects.getDefault().isProjectOpen(p)) {
        SourceGroup[] gr = ProjectUtils.getSources(p).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
        for (int j = 0; j < gr.length; j++) {
            if (fo==gr[j].getRootFolder()) {
                return true;
            }
            if (FileUtil.isParentOf(gr[j].getRootFolder(), fo)) {
                return true;
            }
        }
        return false;
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:RefactoringUtil.java

示例2: initValues

import org.netbeans.api.project.ui.OpenProjects; //导入依赖的package包/类
public void initValues(String preselectedFolder ) {
    
    Project openProjects[] = OpenProjects.getDefault().getOpenProjects();
    Arrays.sort( openProjects, new ProjectByDisplayNameComparator());
    DefaultComboBoxModel projectsModel = new DefaultComboBoxModel( openProjects );
    projectsComboBox.setModel( projectsModel );                
    projectsComboBox.setSelectedItem( project );
    
    updateRoots();
    updatePackages(); 
    if (preselectedFolder != null) {
        packageComboBox.setSelectedItem(preselectedFolder);
    }
    updateClasses();
    // Determine the extension
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:MoveClassPanel.java

示例3: getSearchInfo

import org.netbeans.api.project.ui.OpenProjects; //导入依赖的package包/类
@Override
public SearchInfo getSearchInfo() {
    Project mainProject = OpenProjects.getDefault().getMainProject();
    if (mainProject == null) {
        /*
         * We cannot prevent this situation. The action may be invoked
         * between moment the main project had been closed and the removal
         * notice was distributed to the main project listener (and this
         * action disabled). This may happen if the the main project
         * is being closed in another thread than this action was
         * invoked from.
         */
        return SearchInfoUtils.createEmptySearchInfo();
    }
    
    return createSingleProjectSearchInfo(mainProject);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:SearchScopeMainProject.java

示例4: closeProject

import org.netbeans.api.project.ui.OpenProjects; //导入依赖的package包/类
/** Closes project with given name.
 * @param name system or display name of project to be closed.
 * @return true if project is closed, false in other cases.
 */
public static boolean closeProject(String name){
    Project[] projectList = OpenProjects.getDefault().getOpenProjects();
    for (int i = 0; i < projectList.length; i++) {
        final Project project = projectList[i];
        if(ProjectUtils.getInformation(project).getDisplayName().equals(name) || ProjectUtils.getInformation(project).getName().equals(name)){
            Mutex.EVENT.writeAccess(new Runnable(){
                public void run(){
                    OpenProjects.getDefault().close(new Project[] {project});
                }
            });
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:Utilities.java

示例5: fire

import org.netbeans.api.project.ui.OpenProjects; //导入依赖的package包/类
private void fire() {
    LOG.log(Level.FINEST, "Request to fire an event");      //NOI18N
    synchronized (this) {
        if (task == null) {
            LOG.log(Level.FINEST, "Scheduled firer task");  //NOI18N
            final Future<Project[]> becomeProjects = OpenProjects.getDefault().openProjects();
            task = RP.create(new Runnable() {
                @Override
                public void run() {
                    try {
                        becomeProjects.get();
                        support.firePropertyChange(PROP_RESOURCES,null,null);
                        LOG.log(Level.FINEST, "Fired an event");    //NOI18N
                    } catch (InterruptedException | ExecutionException ex) {
                        Exceptions.printStackTrace(ex);
                    } finally {
                        task = null;    //Write barrier
                    }
                }
            });
            task.schedule(0);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:DefaultClassPathProvider.java

示例6: createContextAwareInstance

import org.netbeans.api.project.ui.OpenProjects; //导入依赖的package包/类
public @Override Action createContextAwareInstance(final Lookup context) {
    return new AbstractAction(BTN_Open_Project()) {
        public @Override void actionPerformed(ActionEvent e) {
            Set<Project> projects = new HashSet<Project>();
            for (Artifact art : context.lookupAll(Artifact.class)) {
                File f = art.getFile();
                if (f != null) {
                    Project p = FileOwnerQuery.getOwner(org.openide.util.Utilities.toURI(f));
                    if (p != null) {
                        projects.add(p);
                    }
                }
            }
            OpenProjects.getDefault().open(projects.toArray(new NbMavenProjectImpl[projects.size()]), false, true);
        }
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:DependencyNode.java

示例7: removeProjectOpenListener

import org.netbeans.api.project.ui.OpenProjects; //导入依赖的package包/类
@Override
public synchronized void removeProjectOpenListener(IDEProject.OpenListener listener) {
    if (ideProjectOpenListeners != null) {
        Iterator<Reference<IDEProject.OpenListener>> it = ideProjectOpenListeners.iterator();
        while (it.hasNext()) {
            Reference<IDEProject.OpenListener> r = it.next();
            IDEProject.OpenListener l = r.get();
            if (l == null || l == listener) {
                it.remove(); // also doing cleanup of GC'ed references
            }
        }
        if (ideProjectOpenListeners.isEmpty()) {
            ideProjectOpenListeners = null;
            if (projectOpenListener != null) {
                OpenProjects.getDefault().removePropertyChangeListener(projectOpenListener);
                projectOpenListener = null;
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ProjectServicesImpl.java

示例8: getIDEProjectOpenListeners

import org.netbeans.api.project.ui.OpenProjects; //导入依赖的package包/类
private static synchronized IDEProject.OpenListener[] getIDEProjectOpenListeners() {
    if (ideProjectOpenListeners == null) {
        return null;
    }
    List<IDEProject.OpenListener> listenerList = new ArrayList<IDEProject.OpenListener>(ideProjectOpenListeners.size());
    Iterator<Reference<IDEProject.OpenListener>> it = ideProjectOpenListeners.iterator();
    while (it.hasNext()) {
        Reference<IDEProject.OpenListener> r = it.next();
        IDEProject.OpenListener l = r.get();
        if (l == null) {
            it.remove(); // also doing cleanup of GC'ed references
        } else {
            listenerList.add(l);
        }
    }
    if (ideProjectOpenListeners.isEmpty()) {
        ideProjectOpenListeners = null;
        if (projectOpenListener != null) {
            OpenProjects.getDefault().removePropertyChangeListener(projectOpenListener);
            projectOpenListener = null;
        }
        return null;
    }
    return listenerList.toArray(new IDEProject.OpenListener[listenerList.size()]);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:ProjectServicesImpl.java

示例9: getSuitesComboBox

import org.netbeans.api.project.ui.OpenProjects; //导入依赖的package包/类
/**
 * Returns <code>JComboBox</code> containing all suites. Also see
 * {@link #addUserSuite}.
 */
public static JComboBox getSuitesComboBox() {
    MutableComboBoxModel model = new SuiteListModel(userSuites);
    Project[] projects = OpenProjects.getDefault().getOpenProjects();
    for (int i = 0; i < projects.length; i++) {
        String suiteDir = SuiteUtils.getSuiteDirectoryPath(projects[i]);
        if (suiteDir != null) {
            model.addElement(suiteDir);
        }
    }
    JComboBox suiteCombo = new JComboBox(model);
    if (model.getSize() > 0) {
        suiteCombo.setSelectedIndex(0);
    }
    return suiteCombo;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:PlatformComponentFactory.java

示例10: runProjectWizard

import org.netbeans.api.project.ui.OpenProjects; //导入依赖的package包/类
public static @CheckForNull NbModuleProject runProjectWizard(
        final NewNbModuleWizardIterator iterator, final String titleBundleKey) {
    WizardDescriptor wd = new WizardDescriptor(iterator);
    wd.setTitleFormat(new MessageFormat("{0}")); // NOI18N
    wd.setTitle(NbBundle.getMessage(ApisupportAntUIUtils.class, titleBundleKey));
    Dialog dialog = DialogDisplayer.getDefault().createDialog(wd);
    dialog.setVisible(true);
    dialog.toFront();
    NbModuleProject project = null;
    boolean cancelled = wd.getValue() != WizardDescriptor.FINISH_OPTION;
    if (!cancelled) {
        FileObject folder = iterator.getCreateProjectFolder();
        if (folder == null) {
            return null;
        }
        try {
            project = (NbModuleProject) ProjectManager.getDefault().findProject(folder);
            OpenProjects.getDefault().open(new Project[] { project }, false);
        } catch (IOException e) {
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
        }
    }
    return project;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ApisupportAntUIUtils.java

示例11: performAction

import org.netbeans.api.project.ui.OpenProjects; //导入依赖的package包/类
protected void performAction(Node[] activatedNodes) {
    final Project[] projects = new Project[activatedNodes.length];
    for (int i = 0; i < activatedNodes.length; i++) {
        Project project = activatedNodes[i].getLookup().lookup(Project.class);
        projects[i] = project;
    }
    StatusDisplayer.getDefault().setStatusText(getMessage("MSG_OpeningProjects"));
    OpenProjects.getDefault().open(projects, false);
    if(projects.length > 0) {
        RequestProcessor.getDefault().post(new Runnable() {
            public @Override void run() {
                ProjectActionUtils.selectAndExpandProject(projects[0]);
            }
        }, 500);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ModulesNodeFactory.java

示例12: attach

import org.netbeans.api.project.ui.OpenProjects; //导入依赖的package包/类
public void attach( Callback newCallback ) {
    synchronized( this ) {
        if( null != newCallback && null == callback ) {
            OpenProjects.getDefault().addPropertyChangeListener( this );
            TopComponent.getRegistry().addPropertyChangeListener( this );

            Project p = findCurrentProject();
            setCurrentProject(p, false);
        } else if( null == newCallback && null != callback ) {
            OpenProjects.getDefault().removePropertyChangeListener( this );
            TopComponent.getRegistry().removePropertyChangeListener( this );
            setCurrentProject(null, false);
        }
        this.callback = newCallback;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:MainProjectScanningScope.java

示例13: isDelayed

import org.netbeans.api.project.ui.OpenProjects; //导入依赖的package包/类
/**
 * Delays given task if neccessary - e.g. projects are currently openning - and reschedules the task if indexing is running
 * This method waits for projects to open and thus blocks the current thread.
 * @param task task to be delayed
 * @param logger 
 * @param logMessagePrefix
 * @return true if the task was rescheduled
 */
public boolean isDelayed (RequestProcessor.Task task, Logger logger, String logMessagePrefix) {
    boolean rescheduled = false;
    DelayedScan scan = getRegisteredScan(task);
    Future<Project[]> projectOpenTask = OpenProjects.getDefault().openProjects();
    if (!projectOpenTask.isDone()) {
        try {
            projectOpenTask.get();
        } catch (Exception ex) {
            // not interested
        }
    }
    if (IndexingBridge.getInstance().isIndexingInProgress()
            && (BLOCK_INDEFINITELY || scan.waitingLoops * WAITING_PERIOD < MAX_WAITING_TIME)) {
        // do not steal disk from openning projects and indexing tasks
        Level level = ++scan.waitingLoops < 10 ? Level.FINE : Level.INFO;
        logger.log(level, "{0}: Scanning in progress, trying again in {1}ms", new Object[]{logMessagePrefix, WAITING_PERIOD}); //NOI18N
        task.schedule(WAITING_PERIOD); // try again later
        rescheduled = true;
    } else {
        scan.waitingLoops = 0;
    }
    return rescheduled;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:DelayScanRegistry.java

示例14: sourceRootUnregistered

import org.netbeans.api.project.ui.OpenProjects; //导入依赖的package包/类
public static void sourceRootUnregistered(Iterable<? extends URL> roots) {
    for (URL root : roots) {
        knownSourceRootsMap.remove(root);
    }
    //XXX hack make sure we are not holding APTUtils for any unknown roots
    //just in case something goes wrong:
    for (URL unknown : PathRegistry.getDefault().getUnknownRoots()) {
        knownSourceRootsMap.remove(unknown);
    }
    final Project[] projects = OpenProjects.getDefault().getOpenProjects();
    if (projects.length == 0 && !knownSourceRootsMap.isEmpty()) {
        LOG.log(
            Level.WARNING,
            "Non removed known roots: {0}",  //NOI18N
            knownSourceRootsMap.keySet());
        knownSourceRootsMap.clear();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:APTUtils.java

示例15: scanProject

import org.netbeans.api.project.ui.OpenProjects; //导入依赖的package包/类
private void scanProject(String projectName, long thBinaryScan, long thSourceScan, long thBinaryUpdate, long thSourceUpdate) throws Exception {
    File projectsDir = getWorkDir();
    Utilities.projectDownloadAndUnzip(projectName, projectsDir);

    Logger repositoryUpdater = Logger.getLogger(RepositoryUpdater.class.getName());
    repositoryUpdater.setLevel(Level.INFO);
    handler = new ScanningHandler(projectName, thBinaryScan, thSourceScan, thBinaryUpdate, thSourceUpdate);
    repositoryUpdater.addHandler(handler);

    Logger log = Logger.getLogger("org.openide.filesystems.MIMESupport");
    log.setLevel(Level.WARNING);
    Utilities.ReadingHandler readHandler = new Utilities.ReadingHandler();
    log.addHandler(readHandler);

    Utilities.openProjects(projectsDir, projectName);
    Utilities.waitScanningFinished(new File(projectsDir, projectName));
    handler.setType(ScanType.UP_TO_DATE);
    Utilities.refreshIndexes();
    Utilities.waitScanningFinished(new File(projectsDir, projectName));
    OpenProjects.getDefault().close(OpenProjects.getDefault().getOpenProjects());
    repositoryUpdater.removeHandler(handler);
    // wait for scanning of unowned roots after all projects are closed
    synchronized(this) {
        this.wait(10000);
}
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ScanProjectPerfTest.java


注:本文中的org.netbeans.api.project.ui.OpenProjects类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。