微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

org.eclipse.core.resources.ResourcesPlugin的实例源码

项目:n4js    文件RunExternalLibrariesPluginTest.java   
/**
 * Loads (and indexes) all the required external libraries. Also imports all the workspace projects.
 */
@Before
public void setupWorkspace() throws Exception {
    final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    assertTrue("Expected empty workspace. Projects were in workspace: " + Arrays.toString(projects),0 == projects.length);
    final URI externalRootLocation = getResourceUri(PROBANDS,EXT_LOC);
    externalLibraryPreferenceStore.add(externalRootLocation);
    final IStatus result = externalLibraryPreferenceStore.save(new NullProgressMonitor());
    assertTrue("Error while saving external library preference changes.",result.isOK());
    waitForAutoBuild();
    for (final String projectName : ALL_PROJECT_IDS) {
        final File projectsRoot = new File(getResourceUri(PROBANDS,WORKSPACE_LOC));
        ProjectUtils.importProject(projectsRoot,projectName);
    }
    waitForAutoBuild();
}
项目:n4js    文件ExternalPackagesPluginTest.java   
/**
 * Check if index is populated only with workspace project content when the external location with single project is
 * registered and workspace contains project with the same name. External library is registered before project is
 * created in the workspace.
 */
public void testWorkspaceProjectHidingExternalProject_after() throws Exception {

    IProject createJSProject = ProjectUtils.createJSProject("LibFoo");
    IFolder src = configureProjectWithXtext(createJSProject);
    IFile manifest = createJSProject.getProject().getFile("manifest.n4mf");
    assertMarkers("manifest of first project should have no errors",manifest,0);

    createTestFile(src,"Foo","console.log('hi')");
    createTestFile(src,"AAAA","BBB","console.log('hi')");
    waitForAutoBuild();

    copyProjectsToLocation(externalLibrariesRoot,"LibFoo");
    setExternalLibrariesPreferenceStoreLocations(externalLibraryPreferenceStore,externalLibrariesRoot);

    Collection<String> expectedWorkspace = collectIndexableFiles(ResourcesPlugin.getWorkspace());

    assertResourceDescriptions(expectedWorkspace,BuilderUtil.getAllResourceDescriptions());

    removeExternalLibrariesPreferenceStoreLocations(externalLibraryPreferenceStore,externalLibrariesRoot);

}
项目:visuflow-plugin    文件UnitLocator.java   
public static UnitLocation locateUnit(VFUnit unit) throws CoreException,IOException {
    VFClass vfClass = unit.getVfMethod().getVfClass();
    String className = vfClass.getSootClass().getName();
    String projectName = GlobalSettings.get("AnalysisProject");
    IPath path = new Path("/sootOutput/" + className + ".jimple");
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
    File file = project.getFile(path).getLocation().toFile();
    List<String> lines = Files.readAllLines(file.toPath());

    // determine method offset
    int[] methodPosition = find(lines,unit.getVfMethod().getSootMethod().getDeclaration(),0);

    String toFind = unit.getUnit().toString() + ";";
    int[] position = find(lines,toFind,methodPosition[1]);

    UnitLocation location = new UnitLocation();
    location.jimpleFile = path;
    location.charStart = position[0];
    location.charEnd = position[1];
    location.line = position[2];
    location.project = project;
    location.vfUnit = unit;
    return location;
}
项目:Hydrograph    文件runconfigDialog.java   
private void loadBuildProperties() {
    String buildPropFilePath = buildPropFilePath();
    IPath bldPropPath = new Path(buildPropFilePath);
    IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(bldPropPath);
    try {
        InputStream reader = iFile.getContents();
        buildProps.load(reader);

    } catch (CoreException | IOException e) {
        MessageDialog.openError(display.getDefault().getActiveShell(),"Error","Exception occurred while loading build properties from file -\n" + e.getMessage());
    }

    Enumeration<?> propertyNames = buildProps.propertyNames();
    populateTextBoxes(propertyNames);

}
项目:Open_Source_ECOA_Toolset_AS5    文件PluginUtil.java   
public LogicalSystemNode getLogicalSystemDeFinition(String name,String containerName) {
    LogicalSystemNode ret = null;
    if (containerName != null) {
        String[] names = StringUtils.split(containerName,"/");
        IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
        IResource resource = wsRoot.findMember(new Path("/" + names[0]));
        IPath loc = resource.getLocation();
        File file = new File(loc.toOsstring() + File.separator + name + ".lsys");
        try {
            ret = ParseUtil.getLogicalSystemNodeFromText(FileUtils.readFiletoString(file));
        } catch (IOException e) {
            EclipseUtil.writeStactTracetoConsole(e);
        }
    }
    return ret;
}
项目:time4sys    文件HrmEditor.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void dispose() {
    updateProblemIndication = false;

    ResourcesPlugin.getWorkspace().removeResourcechangelistener(resourcechangelistener);

    getSite().getPage().removePartListener(partListener);

    adapterFactory.dispose();

    if (getActionBarContributor().getActiveEditor() == this) {
        getActionBarContributor().setActiveEditor(null);
    }

    for (propertysheetPage propertysheetPage : propertysheetPages) {
        propertysheetPage.dispose();
    }

    if (contentOutlinePage != null) {
        contentOutlinePage.dispose();
    }

    super.dispose();
}
项目:n4js    文件ProjectTypeAwareWorkingSetManager.java   
@Override
public IAdaptable[] getElements() {
    final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    final IProject[] elements = new IProject[projects.length];
    int elementCount = 0;
    for (int i = 0,size = projects.length; i < size; i++) {
        final IProject project = projects[i];
        final IN4JSProject n4Project = core.findProject(toUri(project)).orNull();
        if (type == null) { // Other Projects
            if (n4Project == null || !n4Project.exists()) {
                elements[elementCount++] = project;
            }
        } else {
            if (n4Project != null && n4Project.exists() && type.equals(n4Project.getProjectType())) {
                elements[elementCount++] = project;
            }
        }
    }
    return Arrays.copyOfRange(elements,elementCount);
}
项目:convertigo-eclipse    文件ProjectTreeObject.java   
/**
 * Closes a project.
 * 
 * @return <code>false</code> if the close process has been canceled by user.
 */
public boolean close() {
    // close opened editors
    closeAllEditors();

    // save project and copy temporary files to project files
    boolean bRet = save(true);
    if (bRet) {
        ResourcesPlugin.getWorkspace().removeResourcechangelistener(this);

        // clear Source picker view if needed
        clearSourcePickerView();

        Engine.theApp.databaSEObjectsManager.clearCache(getobject());
    }
    return bRet;
}
项目:neoscada    文件RecipeEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (),true ),new FileEditorInput ( file ) );
        }
    }
}
项目:visuflow-plugin    文件WizardPageHandler.java   
/**
 * This method ensures user select Target project and permissions
 */
private void dialogChanged() {
    IResource container = ResourcesPlugin.getWorkspace().getRoot()
            .findMember(new Path(getContainerName().get("TargetPath")));


    if (getContainerName().get("TargetPath").length() == 0) {
        updateStatus("File container must be specified");
        return;
    }
    if (container == null
            || (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) {
        updateStatus("File container must exist");
        return;
    }
    if (!container.isAccessible()) {
        updateStatus("Project must be writable");
        return;
    }
    updateStatus(null);
}
项目:Hydrograph    文件SubjobUiConverterUtil.java   
/**
 * @param subJobXMLPath
 * @param parameterFilePath
 * @param parameterFile
 * @param subJobFile
 * @param importFromPath
 * @param subjobPath
 * @return
 * @throws InstantiationException
 * @throws illegalaccessexception
 * @throws InvocationTargetException
 * @throws NoSuchMethodException
 * @throws JAXBException
 * @throws ParserConfigurationException
 * @throws SAXException
 * @throws IOException
 * @throws CoreException
 * @throws FileNotFoundException
 */
public static Container createSubjobInSpecifiedFolder(IPath subJobXMLPath,IPath parameterFilePath,IFile parameterFile,IFile subJobFile,IPath importFromPath,String subjobPath) throws InstantiationException,illegalaccessexception,InvocationTargetException,NoSuchMethodException,JAXBException,ParserConfigurationException,SAXException,IOException,CoreException,FileNotFoundException {
    UiConverterUtil converterUtil = new UiConverterUtil();
    Object[] subJobContainerArray=null;
        IFile xmlFile = ResourcesPlugin.getWorkspace().getRoot().getFile(subJobXMLPath);
        File file = new File(xmlFile.getFullPath().toString());
    if (file.exists()) {
        subJobContainerArray = converterUtil.convertToUiXml(importFromPath.toFile(),subJobFile,parameterFile,true);
    } else {
        IProject iProject = ResourcesPlugin.getWorkspace().getRoot().getProject(parameterFilePath.segment(1));
        IFolder iFolder = iProject.getFolder(subjobPath.substring(0,subjobPath.lastIndexOf('/')));
        if (!iFolder.exists()) {
            iFolder.create(true,true,new NullProgressMonitor());
        }
        IFile subjobXmlFile = iProject.getFile(subjobPath);
        subJobContainerArray = converterUtil.convertToUiXml(importFromPath.toFile(),true);
        if (!subjobXmlFile.exists() && subJobContainerArray[1] == null) {
            subjobXmlFile.create(new FileInputStream(importFromPath.toString()),new NullProgressMonitor());
        }
    }
    return (Container) subJobContainerArray[0];
}
项目:neoscada    文件HiveTab.java   
protected void chooseWorkspace ()
{
    final ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog ( getShell (),new WorkbenchLabelProvider (),new WorkbenchContentProvider () );
    dialog.setTitle ( "Select driver exporter configuration file" );
    dialog.setMessage ( "Choose a driver exporter file for the configuration" );
    dialog.setInput ( ResourcesPlugin.getWorkspace ().getRoot () );
    dialog.setComparator ( new ResourceComparator ( ResourceComparator.NAME ) );
    dialog.setAllowMultiple ( true );
    dialog.setDialogBoundsSettings ( getDialogBoundsSettings ( HiveTab.WORKSPACE_SELECTION_DIALOG ),Dialog.DIALOG_PERSISTSIZE );
    if ( dialog.open () == IDialogConstants.OK_ID )
    {
        final IResource resource = (IResource)dialog.getFirstResult ();
        if ( resource != null )
        {
            final String arg = resource.getFullPath ().toString ();
            final String fileLoc = VariablesPlugin.getDefault ().getStringVariableManager ().generateVariableExpression ( "workspace_loc",arg ); //$NON-NLS-1$
            this.fileText.setText ( fileLoc );
            makeDirty ();
        }
    }
}
项目:neoscada    文件MemoryEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs ()
{
    SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
    saveAsDialog.open ();
    IPath path = saveAsDialog.getResult ();
    if ( path != null )
    {
        IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
        if ( file != null )
        {
            doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (),new FileEditorInput ( file ) );
        }
    }
}
项目:SimQRI    文件WorkspaceManager.java   
/**
 * 
 * @param modelingProject the name of the selected modeling project
 * @return the list of all the report templates name that are available in the selected modeling project
 */
public static List<String> getTemplates(String modelingProject) { // For the SimulationManagementwindow (names)
    List<String> templatesName = new ArrayList<String>();
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(modelingProject);
    IFolder templatesFolder = project.getFolder("Report Templates");
    try {
        IResource[] folderContent = templatesFolder.members();
        for(IResource resource : folderContent) {
            if(resource.getType() == IFile.FILE && resource.getFileExtension().equals("rptdesign")) {
                templatesName.add(resource.getName());
            }
        }
    } catch (CoreException e) {
        e.printstacktrace();
        JOptionPane.showMessageDialog(null,"Error: " + e.getMessage() + "",JOptionPane.ERROR_MESSAGE);
    }
    return templatesName;
}
项目:SimQRI    文件metamodelEditor.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void dispose() {
    updateProblemIndication = false;

    ResourcesPlugin.getWorkspace().removeResourcechangelistener(resourcechangelistener);

    getSite().getPage().removePartListener(partListener);

    adapterFactory.dispose();

    if (getActionBarContributor().getActiveEditor() == this) {
        getActionBarContributor().setActiveEditor(null);
    }

    for (propertysheetPage propertysheetPage : propertysheetPages) {
        propertysheetPage.dispose();
    }

    if (contentOutlinePage != null) {
        contentOutlinePage.dispose();
    }

    super.dispose();
}
项目:gemoc-studio-modeldebugging    文件SiriusEditorUtils.java   
/**
 * Show the given {@link EObject instruction}.
 * 
 * @param editorPart
 *            the opened {@link DialectEditor}
 * @param instruction
 *            the {@link EObject instruction} to show
 */
public static void showInstruction(DialectEditor editorPart,EObject instruction) {
    final URI resourceURI = instruction.eResource().getURI();
    if (resourceURI.isPlatformResource()) {
        final String resourcePath = resourceURI.toPlatformString(true);
        final IResource resource = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(
                resourcePath));
        try {
            final IMarker marker = resource.createMarker(EValidator.MARKER);
            marker.setAttribute(EValidator.URI_ATTRIBUTE,EcoreUtil.getURI(instruction).toString());
            final traceabilityMarkerNavigationProvider navigationProvider = new traceabilityMarkerNavigationProvider(
                    (DialectEditor)editorPart);
            navigationProvider.gotoMarker(marker);
            marker.delete();
        } catch (CoreException e) {
            DebugSiriusIdeUiPlugin.INSTANCE.log(e);
        }
    }
}
项目:time4sys    文件DesignEditor.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void dispose() {
    updateProblemIndication = false;

    ResourcesPlugin.getWorkspace().removeResourcechangelistener(resourcechangelistener);

    getSite().getPage().removePartListener(partListener);

    adapterFactory.dispose();

    if (getActionBarContributor().getActiveEditor() == this) {
        getActionBarContributor().setActiveEditor(null);
    }

    for (propertysheetPage propertysheetPage : propertysheetPages) {
        propertysheetPage.dispose();
    }

    if (contentOutlinePage != null) {
        contentOutlinePage.dispose();
    }

    super.dispose();
}
项目:gemoc-studio    文件AbstractExampleWizard.java   
public boolean performFinish() {
    final Collection<ProjectDescriptor> projectDescriptors = getProjectDescriptors();

    WorkspaceJob job = new WorkspaceJob("Unzipping Projects") {
        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            monitor.beginTask("Unzipping Projects",projectDescriptors.size());
            //System.out.println("Unzipping projects...");
            for ( ProjectDescriptor desc : projectDescriptors ) {
                unzipProject(desc,monitor);
                monitor.worked(1);
            }
            //System.out.println("Projects unzipped");
            return Status.OK_STATUS;
        }
    };
    job.setRule(ResourcesPlugin.getWorkspace().getRoot());
    job.schedule();
    return true;
}
项目:Open_Source_ECOA_Toolset_AS5    文件PluginUtil.java   
public ComponentImplementationNode getComponentImplementationDeFinition(String name,String containerName) {
    ComponentImplementationNode ret = null;
    if (containerName != null) {
        String[] names = StringUtils.split(containerName,"/");
        IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
        IResource resource = wsRoot.findMember(new Path("/" + names[0]));
        IPath loc = resource.getLocation();
        File file = new File(loc.toOsstring() + File.separator + name + ".cimpl");
        try {
            ret = ParseUtil.getComponentImplementationNodeFromText(FileUtils.readFiletoString(file));
        } catch (IOException e) {
            EclipseUtil.writeStactTracetoConsole(e);
        }
    }
    return ret;
}
项目:time4sys    文件NfpEditor.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void dispose() {
    updateProblemIndication = false;

    ResourcesPlugin.getWorkspace().removeResourcechangelistener(resourcechangelistener);

    getSite().getPage().removePartListener(partListener);

    adapterFactory.dispose();

    if (getActionBarContributor().getActiveEditor() == this) {
        getActionBarContributor().setActiveEditor(null);
    }

    for (propertysheetPage propertysheetPage : propertysheetPages) {
        propertysheetPage.dispose();
    }

    if (contentOutlinePage != null) {
        contentOutlinePage.dispose();
    }

    super.dispose();
}
项目:gw4e.project    文件ResourceManager.java   
/**
 * @return
 */
public static boolean isAutoBuilding() {
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceDescription desc = workspace.getDescription();
    return desc.isAutoBuilding();

}
项目:Equella    文件JPFRepositoryPage.java   
@Override
protected Control createContents(Composite parent)
{
    Composite composite = new Composite(parent,SWT.NONE);

    initialize();

    createDescriptionLabel(composite);

    listViewer = new TableViewer(composite,SWT.TOP | SWT.BORDER);

    if( !project.isopen() )
        listViewer.getControl().setEnabled(false);

    listViewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
    listViewer.setContentProvider(new JarProjectContentProvider(project));
    listViewer.setComparator(new ViewerComparator());
    listViewer.setInput(project.getWorkspace());

    String regName = getPreferenceStore().getString(JPFClasspathPlugin.PREF_REGISTRY_NAME);
    if( !regName.isEmpty() )
    {
        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
        listViewer.setSelection(new StructuredSelection(root.getProject(regName)));
    }
    listViewer.addSelectionChangedListener(new ISelectionChangedListener()
    {
        @Override
        public void selectionChanged(SelectionChangedEvent event)
        {
            modified = true;
        }
    });
    applyDialogFont(composite);

    GridLayoutFactory.fillDefaults().generateLayout(composite);

    return composite;
}
项目:gw4e.project    文件ResourceManager.java   
/**
 * @param value
 */
public static void setAutoBuilding(boolean value) {
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    if (workspace.isAutoBuilding() == value)
        return;
    IWorkspaceDescription desc = workspace.getDescription();
    desc.setAutoBuilding(value);
    try {
        workspace.setDescription(desc);
    } catch (CoreException e) {
        ResourceManager.logException(e);
    }
}
项目:iTrace-Archive    文件XMLGazeExportSolver.java   
@Override
public String getFilename() {
    String workspaceLocation =
            ResourcesPlugin.getWorkspace().getRoot().getLocation()
                    .toString();
    return workspaceLocation + "/" + sessionID + "/" + filename;
}
项目:n4js    文件IDEBUG_856_PluginUITest.java   
/**
 * Updates the kNown external library locations with the {@code node_modules} folder.
 */
public void setupWorkspace() throws Exception {
    super.setUp();
    shippedCodeInitializeTestHelper.setupBuiltIns();
    final File projectsRoot = new File(getResourceUri(PROBANDS,WORKSPACE_LOC));
    ProjectUtils.importProject(projectsRoot,PROJECT);
    final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT);
    assertTrue("Cannot access project: " + project,project.isAccessible());
}
项目:Open_Source_ECOA_Toolset_AS5    文件ServicesMainPage.java   
/**
 * Uses the standard container selection dialog to choose the new value for
 * the container field.
 */

private void handlebrowse() {
    ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(),ResourcesPlugin.getWorkspace().getRoot(),false,"Select new file container");
    if (dialog.open() == ContainerSelectionDialog.OK) {
        Object[] result = dialog.getResult();
        if (result.length == 1) {
            containerText.setText(((Path) result[0]).toString());
        }
    }
}
项目:n4js    文件GHOLD_129_brokenAstMustNotCauseBuildFailure_PluginUITest.java   
/**
 * We expect validation errors which means the build was not broken and interrupted due to broken AST when inferring
 * the types.
 */
@Test
public void checkbrokenAstDoesNotCauseBuildFailure_ExpectValidationErrors() throws CoreException {
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
    assertTrue("Project '" + PROJECT_NAME + "' does not exist in workspace.",project.isAccessible());

    IResourcesSetupUtil.fullBuild();
    ProjectUtils.waitForAutoBuild();

    // Couldn't resolve reference to IdentifiableElement 'A'.
    // Name missing in type declaration.
    ProjectUtils.assertMarkers("Expected exactly two validation errors.",project,2);
}
项目:Hydrograph    文件PartitionByExpressionUiConverter.java   
/**
 * initialize ui object from external file data.
 * 
 * @param filterLogicDataStructure
 * @param typeTransformOpertaionList
 */
public void populateUIDataFromExternalData(FilterLogicDataStructure filterLogicDataStructure,List<JAXBElement<?>> typeTransformOpertaionList) {
    TypeExternalSchema typeExternalSchema=(TypeExternalSchema) partitionByExpression
            .getoperationorExpressionorIncludeExternalOperation().get(0).getValue();
    String filePath = typeExternalSchema.getUri();
    filePath = StringUtils.replace(filePath,"../","");
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
     IPath relativePath=null;
         relativePath=workspace.getRoot().getFile(new Path(filePath)).getLocation();
     if(StringUtils.equals("includeExternalExpression",((JAXBElement<?>) typeTransformOpertaionList.get(0)).getName().getLocalPart()))
     {
            ExpressionData expressionData=FilterLogicExternalOperationExpressionUtil.INSTANCE
             .importExpression(new File(relativePath.toString()),null,uiComponent.getComponentName());
            expressionData.getExternalExpressionData().setExternal(true);
            expressionData.getExternalExpressionData().setFilePath(filePath);
            filterLogicDataStructure.setExpressionEditorData(expressionData);
     }
     else {
            OperationClassData operationClassData=FilterLogicExternalOperationExpressionUtil.INSTANCE
                     .importOperation(new File(relativePath.toString()),uiComponent.getComponentName());
            operationClassData.getExternalOperationClassData().setExternal(true);
            operationClassData.getExternalOperationClassData().setFilePath(filePath);
            filterLogicDataStructure.setoperationClassData(operationClassData);

     }
}
项目:time4sys    文件DesignEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs() {
    SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell());
    saveAsDialog.open();
    IPath path = saveAsDialog.getResult();
    if (path != null) {
        IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
        if (file != null) {
            doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(),true),new FileEditorInput(file));
        }
    }
}
项目:vertigo-chroma-kspplugin    文件FilePathHyperLinkDetector.java   
@Override
public IHyperlink[] detectHyperlinks(ITextViewer textViewer,IRegion region,boolean canShowMultipleHyperlinks) {

    IDocument document = textViewer.getDocument();

    /* Extrait le mot courant. */
    ITextSelection selection = new TextSelection(document,region.getoffset(),region.getLength());
    ITextSelection currentWordSelection = DocumentUtils.findCurrentWord(document,selection,WordSelectionType.NOT_SPACE);
    if (currentWordSelection == null) {
        return null; // NOSONAR
    }
    String currentWord = currentWordSelection.getText();
    if (currentWord == null) {
        return null; // NOSONAR
    }

    /* Vérifie que c'est un chemin relatif valide. */
    String absolutePath = getAbsolutePath(currentWord);
    if (absolutePath == null) {
        return null; // NOSONAR
    }

    /* Vérifie que le fichier existe. */
    IFile file = (IFile) ResourcesPlugin.getWorkspace().getRoot().findMember(absolutePath);
    if (file == null) {
        return null; // NOSONAR
    }

    /* Renvoin un lien vers le fichier dont on a trouvé le chemin. */
    IRegion targetRegion = new Region(currentWordSelection.getoffset(),currentWordSelection.getLength());
    return new IHyperlink[] { new FileHyperLink(targetRegion,file) };
}
项目:visuflow-plugin    文件DataModelImpl.java   
@Override
public void triggerProjectRebuild() {
    WorkspaceJob build = new WorkspaceJob("rebuild") {

        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD,monitor);
            return Status.OK_STATUS;
        }
    };
    build.schedule();
}
项目:time4sys    文件LibraryEditor.java   
/**
 * This is called during startup.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void init(IEditorSite site,IEditorInput editorInput) {
    setSite(site);
    setInputWithNotify(editorInput);
    setPartName(editorInput.getName());
    site.setSelectionProvider(this);
    site.getPage().addPartListener(partListener);
    ResourcesPlugin.getWorkspace().addResourcechangelistener(resourcechangelistener,IResourceChangeEvent.POST_CHANGE);
}
项目:Hydrograph    文件SubJobUtility.java   
public static boolean isFileExistsOnLocalFileSystem(IPath jobFilePath){
    if (ResourcesPlugin.getWorkspace().getRoot().getFile(jobFilePath).exists())
        return true;
    else if (jobFilePath.toFile().exists())
        return true;
    return false;
}
项目:neoscada    文件SecurityEditor.java   
/**
 * This is called during startup.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void init ( IEditorSite site,IEditorInput editorInput )
{
    setSite ( site );
    setInputWithNotify ( editorInput );
    setPartName ( editorInput.getName () );
    site.setSelectionProvider ( this );
    site.getPage ().addPartListener ( partListener );
    ResourcesPlugin.getWorkspace ().addResourcechangelistener ( resourcechangelistener,IResourceChangeEvent.POST_CHANGE );
}
项目:n4js    文件AbstractExportToSingleFileWizardPage.java   
/**
 * Returns the name of a {@link IProject} with a location that includes targetDirectory. Returns null if there is no
 * such {@link IProject}.
 *
 * @param targetDirectory
 *            the path of the directory to check.
 * @return the overlapping project name or <code>null</code>
 */
private String getoverlappingProjectName(String targetDirectory) {
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IPath testPath = new Path(targetDirectory);
    IContainer[] containers = root.findContainersForLocationURI(testPath.makeAbsolute().toFile().toURI());
    if (containers.length > 0) {
        return containers[0].getProject().getName();
    }
    return null;
}
项目:time4sys    文件AnalysisEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs() {
    SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell());
    saveAsDialog.open();
    IPath path = saveAsDialog.getResult();
    if (path != null) {
        IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
        if (file != null) {
            doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(),new FileEditorInput(file));
        }
    }
}
项目:time4sys    文件HrmEditor.java   
/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs() {
    SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell());
    saveAsDialog.open();
    IPath path = saveAsDialog.getResult();
    if (path != null) {
        IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
        if (file != null) {
            doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(),new FileEditorInput(file));
        }
    }
}
项目:neoscada    文件OsgiEditor.java   
/**
 * This is called during startup.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void init ( IEditorSite site,IResourceChangeEvent.POST_CHANGE );
}
项目:gw4e.project    文件ResourceManager.java   
/**
 * Return the passed parameters (a file) as an IFile
 * 
 * @param file
 * @return
 */
public static IFile toIFile(File file) {
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IPath location = Path.fromOsstring(file.getAbsolutePath());
    IFile ifile = workspace.getRoot().getFileForLocation(location);
    return ifile;
}
项目:n4js    文件NpmManager.java   
private static <T> T runWithWorkspaceLock(supplier<T> operation) {
    if (Platform.isRunning()) {
        final ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRoot();
        try {
            Job.getJobManager().beginRule(rule,null);
            return operation.get();
        } finally {
            Job.getJobManager().endRule(rule);
        }
    } else {
        // locking not available/required in headless case
        return operation.get();
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。