Java Code Examples for org.eclipse.core.resources.ResourcesPlugin

The following are top voted examples for showing how to use org.eclipse.core.resources.ResourcesPlugin. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: n4js   File: RunExternalLibrariesPluginTest.java   View source code 6 votes vote down vote up
/**
 * 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();
}
 
Example 2
Project: n4js   File: ExternalPackagesPluginTest.java   View source code 6 votes vote down vote up
/**
 * 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", "console.log('hi')");
	createTestFile(src, "BBB", "console.log('hi')");
	waitForAutoBuild();

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

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

	assertResourceDescriptions(expectedWorkspace, BuilderUtil.getAllResourceDescriptions());

	removeExternalLibrariesPreferenceStoreLocations(externalLibraryPreferenceStore, externalLibrariesRoot);

}
 
Example 3
Project: visuflow-plugin   File: UnitLocator.java   View source code 6 votes vote down vote up
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;
}
 
Example 4
Project: Hydrograph   File: RunConfigDialog.java   View source code 6 votes vote down vote up
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);

}
 
Example 5
Project: Open_Source_ECOA_Toolset_AS5   File: PluginUtil.java   View source code 6 votes vote down vote up
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;
}
 
Example 6
Project: time4sys   File: HrmEditor.java   View source code 6 votes vote down vote up
/**
 * <!-- 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();
}
 
Example 7
Project: n4js   File: ProjectTypeAwareWorkingSetManager.java   View source code 6 votes vote down vote up
@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, 0, elementCount);
}
 
Example 8
Project: convertigo-eclipse   File: ProjectTreeObject.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 9
Project: neoscada   File: RecipeEditor.java   View source code 6 votes vote down vote up
/**
 * 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 ) );
        }
    }
}
 
Example 10
Project: visuflow-plugin   File: WizardPageHandler.java   View source code 6 votes vote down vote up
/**
 * 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);
}
 
Example 11
Project: Hydrograph   File: SubjobUiConverterUtil.java   View source code 6 votes vote down vote up
/**
 * @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(), subJobFile, parameterFile,true);
		if (!subjobXmlFile.exists() && subJobContainerArray[1] == null) {
			subjobXmlFile.create(new FileInputStream(importFromPath.toString()), true, new NullProgressMonitor());
		}
	}
	return (Container) subJobContainerArray[0];
}
 
Example 12
Project: neoscada   File: HiveTab.java   View source code 6 votes vote down vote up
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 ();
        }
    }
}
 
Example 13
Project: neoscada   File: MemoryEditor.java   View source code 6 votes vote down vote up
/**
 * 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 ) );
        }
    }
}
 
Example 14
Project: SimQRI   File: WorkspaceManager.java   View source code 6 votes vote down vote up
/**
 * 
 * @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() + "", "Error", JOptionPane.ERROR_MESSAGE);
	}
	return templatesName;
}
 
Example 15
Project: SimQRI   File: MetamodelEditor.java   View source code 6 votes vote down vote up
/**
 * <!-- 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();
}
 
Example 16
Project: gemoc-studio-modeldebugging   File: SiriusEditorUtils.java   View source code 6 votes vote down vote up
/**
 * 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);
		}
	}
}
 
Example 17
Project: time4sys   File: DesignEditor.java   View source code 6 votes vote down vote up
/**
 * <!-- 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();
}
 
Example 18
Project: gemoc-studio   File: AbstractExampleWizard.java   View source code 6 votes vote down vote up
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;
}
 
Example 19
Project: Open_Source_ECOA_Toolset_AS5   File: PluginUtil.java   View source code 6 votes vote down vote up
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;
}
 
Example 20
Project: time4sys   File: NfpEditor.java   View source code 6 votes vote down vote up
/**
 * <!-- 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();
}
 
Example 21
Project: gw4e.project   File: ResourceManager.java   View source code 5 votes vote down vote up
/**
 * @return
 */
public static boolean isAutoBuilding() {
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	IWorkspaceDescription desc = workspace.getDescription();
	return desc.isAutoBuilding();

}
 
Example 22
Project: Equella   File: JPFRepositoryPage.java   View source code 5 votes vote down vote up
@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;
}
 
Example 23
Project: gw4e.project   File: ResourceManager.java   View source code 5 votes vote down vote up
/**
 * @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);
	}
}
 
Example 24
Project: iTrace-Archive   File: XMLGazeExportSolver.java   View source code 5 votes vote down vote up
@Override
public String getFilename() {
    String workspaceLocation =
            ResourcesPlugin.getWorkspace().getRoot().getLocation()
                    .toString();
    return workspaceLocation + "/" + sessionID + "/" + filename;
}
 
Example 25
Project: n4js   File: IDEBUG_856_PluginUITest.java   View source code 5 votes vote down vote up
/**
 * 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());
}
 
Example 26
Project: Open_Source_ECOA_Toolset_AS5   File: ServicesMainPage.java   View source code 5 votes vote down vote up
/**
 * 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());
		}
	}
}
 
Example 27
Project: n4js   File: GHOLD_129_BrokenAstMustNotCauseBuildFailure_PluginUITest.java   View source code 5 votes vote down vote up
/**
 * 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);
}
 
Example 28
Project: Hydrograph   File: PartitionByExpressionUiConverter.java   View source code 5 votes vote down vote up
/**
 * 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, false, uiComponent.getComponentName());
			expressionData.getExternalExpressionData().setExternal(true);
			expressionData.getExternalExpressionData().setFilePath(filePath);
			filterLogicDataStructure.setExpressionEditorData(expressionData);
	 }
	 else {
			OperationClassData operationClassData=FilterLogicExternalOperationExpressionUtil.INSTANCE
		    		 .importOperation(new File(relativePath.toString()), null, false, uiComponent.getComponentName());
		    operationClassData.getExternalOperationClassData().setExternal(true);
		    operationClassData.getExternalOperationClassData().setFilePath(filePath);
		    filterLogicDataStructure.setOperationClassData(operationClassData);
			 
	 }
}
 
Example 29
Project: time4sys   File: DesignEditor.java   View source code 5 votes vote down vote up
/**
 * 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));
		}
	}
}
 
Example 30
Project: vertigo-chroma-kspplugin   File: FilePathHyperLinkDetector.java   View source code 5 votes vote down vote up
@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) };
}
 
Example 31
Project: visuflow-plugin   File: DataModelImpl.java   View source code 5 votes vote down vote up
@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();
}
 
Example 32
Project: time4sys   File: LibraryEditor.java   View source code 5 votes vote down vote up
/**
 * 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);
}
 
Example 33
Project: Hydrograph   File: SubJobUtility.java   View source code 5 votes vote down vote up
public static boolean isFileExistsOnLocalFileSystem(IPath jobFilePath){
	if (ResourcesPlugin.getWorkspace().getRoot().getFile(jobFilePath).exists())
		return true;
	else if (jobFilePath.toFile().exists())
		return true;
	return false;
}
 
Example 34
Project: neoscada   File: SecurityEditor.java   View source code 5 votes vote down vote up
/**
 * 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 );
}
 
Example 35
Project: n4js   File: AbstractExportToSingleFileWizardPage.java   View source code 5 votes vote down vote up
/**
 * 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;
}
 
Example 36
Project: time4sys   File: AnalysisEditor.java   View source code 5 votes vote down vote up
/**
 * 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));
		}
	}
}
 
Example 37
Project: time4sys   File: HrmEditor.java   View source code 5 votes vote down vote up
/**
 * 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));
		}
	}
}
 
Example 38
Project: neoscada   File: OsgiEditor.java   View source code 5 votes vote down vote up
/**
 * 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 );
}
 
Example 39
Project: gw4e.project   File: ResourceManager.java   View source code 5 votes vote down vote up
/**
 * 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;
}
 
Example 40
Project: n4js   File: NpmManager.java   View source code 5 votes vote down vote up
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();
	}
}