org.eclipse.core.resources.IResource Java Examples

The following examples show how to use org.eclipse.core.resources.IResource. 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: ResourceDropAdapterAssistant.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the resource selection from the LocalSelectionTransfer.
 * 
 * @return the resource selection from the LocalSelectionTransfer
 */
private IResource[] getSelectedResources(IStructuredSelection selection) {
	ArrayList selectedResources = new ArrayList();

	for (Iterator i = selection.iterator(); i.hasNext();) {
		Object o = i.next();
		if (o instanceof IResource) {
			selectedResources.add(o);
		} else if (o instanceof IAdaptable) {
			IAdaptable a = (IAdaptable) o;
			IResource r = (IResource) a.getAdapter(IResource.class);
			if (r != null) {
				selectedResources.add(r);
			}
		}
	}
	return (IResource[]) selectedResources
			.toArray(new IResource[selectedResources.size()]);
}
 
Example #2
Source File: GroovyFileStore.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void doSave(final Object content) {
    if (content instanceof String) {
        if (getResource().exists() && content != null && content.equals(getContent())) {
            return;
        }
        try {
            final String scriptContent = (String) content;
            final InputStream is = new ByteArrayInputStream(scriptContent.getBytes(UTF_8));
            final IFile sourceFile = getResource();
            if (sourceFile.exists() && FileActionDialog.overwriteQuestion(getName())) {
                sourceFile.setContents(is, IResource.FOLDER, Repository.NULL_PROGRESS_MONITOR);
            } else {
                sourceFile.create(is, true, Repository.NULL_PROGRESS_MONITOR);
            }
            if (!UTF_8.equals(sourceFile.getCharset())) {
                sourceFile.setCharset(UTF_8, Repository.NULL_PROGRESS_MONITOR);
            }
        } catch (final Exception e) {
            BonitaStudioLog.error(e);
        }
    }

}
 
Example #3
Source File: ResolveActionWithChoices.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private SVNTreeConflict getTreeConflict(final IResource resource) {
	BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
		public void run() {
			ISVNClientAdapter client = null;
			try {
				client = SVNWorkspaceRoot.getSVNResourceFor(resource).getRepository().getSVNClient();
				ISVNStatus[] statuses = client.getStatus(resource.getLocation().toFile(), true, true, true);
				for (int i = 0; i < statuses.length; i++) {
					if (statuses[i].hasTreeConflict()) {
						treeConflict = new SVNTreeConflict(statuses[i]);
						break;
					}
				}
			} catch (Exception e) {
				SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
			}
			finally {
				SVNWorkspaceRoot.getSVNResourceFor(resource).getRepository().returnSVNClient(client);
			}
		}			
	});
	return treeConflict;
}
 
Example #4
Source File: RefactoringAvailabilityTester.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
public static boolean isMoveAvailable(final IResource[] resources, final IJavaElement[] elements) throws JavaModelException {
	if (elements != null) {
		for (int index = 0; index < elements.length; index++) {
			IJavaElement element = elements[index];
			if (element == null || !element.exists()) {
				return false;
			}
			if ((element instanceof IType) && ((IType) element).isLocal()) {
				return false;
			}
			if ((element instanceof IPackageDeclaration)) {
				return false;
			}
			if (element instanceof IField && JdtFlags.isEnum((IMember) element)) {
				return false;
			}
		}
	}
	return ReorgPolicyFactory.createMovePolicy(resources, elements).canEnable();
}
 
Example #5
Source File: ModelHelper.java    From tlaplus with MIT License 6 votes vote down vote up
public static void copyModuleFiles(IFile specRootFile, IPath targetFolderPath, IProgressMonitor monitor,
        int STEP, IProject project, Collection<String> extendedModules, final Predicate<String> p) throws CoreException
{

    // iterate and copy modules that are needed for the spec
    IFile moduleFile = null;
    
    final Iterator<String> iterator = extendedModules.iterator();
    while (iterator.hasNext()) {
    	String module = iterator.next();
        // only take care of user modules
        if (p.test(module))
        {
            moduleFile = ResourceHelper.getLinkedFile(project, module, false);
            if (moduleFile != null && moduleFile.exists())
            {
                moduleFile.copy(targetFolderPath.append(moduleFile.getProjectRelativePath()), IResource.DERIVED
                        | IResource.FORCE, new SubProgressMonitor(monitor, STEP / extendedModules.size()));
            }

            // TODO check the existence of copied files
        }
    }
}
 
Example #6
Source File: Storage2UriMapperJdtImplTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testBug463258_03c() throws Exception {
	IJavaProject project = createJavaProject("foo");
	IFile file = project.getProject().getFile("foo.jar");
	file.create(jarInputStream(new TextFile("foo/bar.notindexed", "//empty")), true, monitor());
	addJarToClasspath(project, file);
	
	Storage2UriMapperJavaImpl impl = getStorage2UriMapper();
	
	IPackageFragmentRoot root = JarPackageFragmentRootTestUtil.getJarPackageFragmentRoot(file, (JavaProject) project);
	IPackageFragment foo = root.getPackageFragment("foo");
	JarEntryFile fileInJar = new JarEntryFile("bar.notindexed");
	fileInJar.setParent(foo);
	
	File jarFile = file.getLocation().toFile();
	assertTrue("exists", jarFile.exists());
	assertTrue("delete", jarFile.delete());
	// simulate an automated refresh
	file.refreshLocal(IResource.DEPTH_ONE, null);
	URI uri = impl.getUri(fileInJar);
	assertNull(uri);
}
 
Example #7
Source File: BinaryRefactoringHistoryWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Configures the classpath of the project before refactoring.
 *
 * @param project
 *            the java project
 * @param root
 *            the package fragment root to refactor
 * @param folder
 *            the temporary source folder
 * @param monitor
 *            the progress monitor to use
 * @throws IllegalStateException
 *             if the plugin state location does not exist
 * @throws CoreException
 *             if an error occurs while configuring the class path
 */
private static void configureClasspath(final IJavaProject project, final IPackageFragmentRoot root, final IFolder folder, final IProgressMonitor monitor) throws IllegalStateException, CoreException {
	try {
		monitor.beginTask(JarImportMessages.JarImportWizard_prepare_import, 200);
		final IClasspathEntry entry= root.getRawClasspathEntry();
		final IClasspathEntry[] entries= project.getRawClasspath();
		final List<IClasspathEntry> list= new ArrayList<IClasspathEntry>();
		list.addAll(Arrays.asList(entries));
		final IFileStore store= EFS.getLocalFileSystem().getStore(JavaPlugin.getDefault().getStateLocation().append(STUB_FOLDER).append(project.getElementName()));
		if (store.fetchInfo(EFS.NONE, new SubProgressMonitor(monitor, 25, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)).exists())
			store.delete(EFS.NONE, new SubProgressMonitor(monitor, 25, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
		store.mkdir(EFS.NONE, new SubProgressMonitor(monitor, 25, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
		folder.createLink(store.toURI(), IResource.NONE, new SubProgressMonitor(monitor, 25, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
		addExclusionPatterns(list, folder.getFullPath());
		for (int index= 0; index < entries.length; index++) {
			if (entries[index].equals(entry))
				list.add(index, JavaCore.newSourceEntry(folder.getFullPath()));
		}
		project.setRawClasspath(list.toArray(new IClasspathEntry[list.size()]), false, new SubProgressMonitor(monitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
	} finally {
		monitor.done();
	}
}
 
Example #8
Source File: ModuleFile.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * <p>
 * Returns whether a package is on the client source path of this module. The source paths include
 * the paths explicitly declared with <code>&lt;source&gt;</code> tags and all of their descendant
 * packages.
 * </p>
 * <p>
 * For example, if a module is located in <code>com.hello</code> and has the default client source
 * path "client", then <code>com.hello.client</code> and <code>com.hello.client.utils</code> would
 * both return true.
 * </p>
 *
 * @param pckg package to check
 * @return <code>true</code> if this package is on a client source path, and <code>false</code>
 *         otherwise
 */
public boolean isSourcePackage(IPackageFragment pckg) {
  IResource resource = pckg.getResource();
  if (resource.getType() == IResource.FOLDER) {
    IPath pckgFolderPath = resource.getFullPath();

    // Check each source path to see if it's an ancestor of this package
    for (IFolder clientFolder : getFolders(getSourcePaths())) {
      IPath clientFolderPath = clientFolder.getFullPath();
      if (clientFolderPath.isPrefixOf(pckgFolderPath)) {
        return true;
      }
    }
  }

  return false;
}
 
Example #9
Source File: SynchronizerSyncInfoCache.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Flushes statuses from pending cache.
 * The method is not synchronized intentionally.
 */
protected void flushPendingCacheWrites()
{
	if ((pendingCacheWrites.size() > 0) && (!ResourcesPlugin.getWorkspace().isTreeLocked()))
	{
		int count = pendingCacheWrites.size();
		for (int i = 0; i < count; i++) {
			Map.Entry cachedEntry = nextFromPendingCache();
			if (cachedEntry != null)
			{
				IResource resource = (IResource) cachedEntry.getKey();
				byte[] value = (byte []) cachedEntry.getValue();
				if (value == BYTES_REMOVED)
					value = null;
				try {
					ResourcesPlugin.getWorkspace().getSynchronizer().setSyncInfo(StatusCacheManager.SVN_BC_SYNC_KEY, resource, value);
				} catch (CoreException e) {
					SVNProviderPlugin.log(SVNException.wrapException(e));
				}
				removeFromPendingCacheIfEqual((IResource) cachedEntry.getKey(), (byte []) cachedEntry.getValue());
			}
		}
	}
}
 
Example #10
Source File: Bug486584Test.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testNoFullBuildWhenClasspathNotReallyChanged_1() throws CoreException, IOException, InterruptedException {
	IJavaProject project = setupProject();
	IFile libaryFile = copyAndGetXtendExampleJar(project);
	IPath rawLocation = libaryFile.getRawLocation();
	IClasspathEntry libraryEntry = JavaCore.newLibraryEntry(rawLocation, null, null);
	addToClasspath(project, libraryEntry);
	build();
	assertFalse(getEvents().isEmpty());
	getEvents().clear();
	project.setRawClasspath(project.getRawClasspath(), null);
	project.getProject().getFile("src/dummy.txt").create(new StringInputStream(""), false, null);
	project.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
	build();
	assertEquals(0, getEvents().size());
}
 
Example #11
Source File: SVNHistoryPageSource.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public boolean canShowHistoryFor(Object object) {
if (object instanceof IResource) {
	IResource resource = (IResource)object;
	ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
	if (localResource != null) {
		try {
			if (!localResource.isManaged()) {
				return false;
			}
			if (localResource.isAdded() && !localResource.getStatus().isCopied()) {
				return false;
			}
		} catch (Exception e) {
			SVNUIPlugin.log(Status.ERROR, e.getMessage(), e);
		}
	}
}
   return (object instanceof IResource && ((IResource) object).getType() != IResource.ROOT)
       || (object instanceof ISVNRemoteResource);
 }
 
Example #12
Source File: AddAction.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * asks the user if he wants to add the resources if some of them are ignored
    * @return false if he answered no
 */
private boolean promptForAddOfIgnored() {
	IResource[] resources = getSelectedResources();
	boolean prompt = false;
	for (int i = 0; i < resources.length; i++) {
		ISVNLocalResource resource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
		try {
			if (resource.isIgnored()) {
				prompt = true;
				break;
			} 
		} catch (SVNException e) {
			handle(e);
		}
	}
	if (prompt) {
		return MessageDialog.openQuestion(getShell(), Policy.bind("AddAction.addIgnoredTitle"), Policy.bind("AddAction.addIgnoredQuestion")); //$NON-NLS-1$ //$NON-NLS-2$
	}
	return true;
}
 
Example #13
Source File: XbaseBreakpointUtil.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public IResource getBreakpointResource(IEditorInput input) throws CoreException {
	IResource resource = Adapters.adapt(input, IResource.class);
	if (resource != null)
		return resource;
	if (input instanceof IStorageEditorInput) {
		IStorage storage = ((IStorageEditorInput) input).getStorage();
		if (storage instanceof IResource)
			return (IResource) storage;
		if (storage instanceof IJarEntryResource) {
			IResource underlyingResource = ((IJarEntryResource) storage).getPackageFragmentRoot().getUnderlyingResource();
			if (underlyingResource != null)
				return underlyingResource;
		}
	} else {
		IClassFile classFile = Adapters.adapt(input, IClassFile.class);
		if (classFile != null) {
			return getBreakpointResource(classFile.findPrimaryType());
		}
	}
	return ResourcesPlugin.getWorkspace().getRoot();
}
 
Example #14
Source File: PythonRunnerConfigTestWorkbench.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public void testUnittestCommandLine() throws Exception {
    ILaunchConfiguration config = new JythonLaunchShortcut().createDefaultLaunchConfiguration(FileOrResource
            .createArray(new IResource[] { mod1 }));
    PythonRunnerConfig runnerConfig = new PythonRunnerConfig(config, ILaunchManager.RUN_MODE,
            PythonRunnerConfig.RUN_JYTHON);
    String[] argv = runnerConfig.getCommandLine(false);
    assertFalse(arrayContains(argv, PythonRunnerConfig.getRunFilesScript()));
    assertTrue(arrayContains(argv, mod1.getLocation().toOSString()));
}
 
Example #15
Source File: WorkingSetsContentProvider.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
private IAdaptable[] getWorkingSetElements(IWorkingSet workingSet) {
	IAdaptable[] children = workingSet.getElements();
	for (int i = 0; i < children.length; i++) {
		Object resource = children[i].getAdapter(IResource.class);
		if (resource instanceof IProject)
			children[i] = (IProject) resource;
	}
	return children;
}
 
Example #16
Source File: PasteAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void paste(IJavaElement[] javaElements, IResource[] resources, IWorkingSet[] selectedWorkingSets, TransferData[] availableTypes) throws JavaModelException, InterruptedException, InvocationTargetException{
	IResource[] clipboardResources= getClipboardResources(availableTypes);
	if (clipboardResources == null)
		clipboardResources= new IResource[0];
	IJavaElement[] clipboardJavaElements= getClipboardJavaElements(availableTypes);
	if (clipboardJavaElements == null)
		clipboardJavaElements= new IJavaElement[0];

	Object destination= getTarget(javaElements, resources);
	Assert.isNotNull(destination);
	Assert.isLegal(clipboardResources.length + clipboardJavaElements.length > 0);
	ReorgCopyStarter.create(clipboardJavaElements, clipboardResources, ReorgDestinationFactory.createDestination(destination)).run(getShell());
}
 
Example #17
Source File: CopyAction.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
   * The <code>CopyAction</code> implementation of this method defined 
   * on <code>IAction</code> copies the selected resources to the 
   * clipboard.
   */
  public void run() {
      List selectedResources = getSelectedResources();
      IResource[] resources = (IResource[]) selectedResources
              .toArray(new IResource[selectedResources.size()]);

      // Get the file names and a string representation
      final int length = resources.length;
      int actualLength = 0;
      String[] fileNames = new String[length];
      StringBuffer buf = new StringBuffer();
      for (int i = 0; i < length; i++) {
          IPath location = resources[i].getLocation();
          // location may be null. See bug 29491.
          if (location != null) {
		fileNames[actualLength++] = location.toOSString();
	}
          if (i > 0) {
		buf.append("\n"); //$NON-NLS-1$
	}
          buf.append(resources[i].getName());
      }
      // was one or more of the locations null?
      if (actualLength < length) {
          String[] tempFileNames = fileNames;
          fileNames = new String[actualLength];
          for (int i = 0; i < actualLength; i++) {
		fileNames[i] = tempFileNames[i];
	}
      }
      setClipboard(resources, fileNames, buf.toString());

      // update the enablement of the paste action
      // workaround since the clipboard does not suppot callbacks
      if (pasteAction != null && pasteAction.getStructuredSelection() != null) {
	pasteAction.selectionChanged(pasteAction.getStructuredSelection());
}
  }
 
Example #18
Source File: RemoteImportTracesOperation.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private IResource downloadFileTrace(IFileStore trace, IFolder traceFolder, IProgressMonitor monitor) throws CoreException, IOException, InterruptedException {

        IFolder folder = traceFolder;
        String traceName = trace.getName();

        traceName = TmfTraceCoreUtils.validateName(traceName);

        IResource resource = folder.findMember(traceName);
        if ((resource != null) && resource.exists()) {
            String newName = fConflictHandler.checkAndHandleNameClash(resource.getFullPath(), monitor);
            if (newName == null) {
                return null;
            }
            traceName = newName;
        }
        SubMonitor subMonitor = SubMonitor.convert(monitor, 1);
        subMonitor.beginTask(RemoteMessages.RemoteImportTracesOperation_DownloadTask, 1);

        IPath destination = folder.getLocation().addTrailingSeparator().append(traceName);
        IFileInfo info = trace.fetchInfo();
        subMonitor.setTaskName(RemoteMessages.RemoteImportTracesOperation_DownloadTask + ' ' + trace.getName() + '/' + trace.getName());
        try (InputStream in = trace.openInputStream(EFS.NONE, new NullProgressMonitor())) {
            copy(in, folder, destination, subMonitor, info.getLength());
        }
        folder.refreshLocal(IResource.DEPTH_INFINITE, null);
        return folder.findMember(traceName);
    }
 
Example #19
Source File: XdsElementAdapterFactory.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
private IPropertySource getProperties(IResource resource) {
	if (resource == null) {
		return null;
	}
    if (resource instanceof IFile) {
        return new FilePropertySource((IFile) resource);
    }
    else {
        return new ResourcePropertySource(resource);
    }
}
 
Example #20
Source File: AbstractBaseAction.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
protected void refreshProject() {
    final IEditorInput input = getEditorPart().getEditorInput();

    if (input instanceof IFileEditorInput) {
        final IFile iFile = ((IFileEditorInput) getEditorPart().getEditorInput()).getFile();
        final IProject project = iFile.getProject();

        try {
            project.refreshLocal(IResource.DEPTH_INFINITE, null);

        } catch (final CoreException e) {
            ERDiagramActivator.showExceptionDialog(e);
        }
    }
}
 
Example #21
Source File: BaseParser.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This function will remove the markers related to errors.
 * @param resource the file that should have the markers removed
 * @throws CoreException
 */
public static void deleteErrorMarkers(IResource resource) throws CoreException {
    IMarker[] markers = resource.findMarkers(IMarker.PROBLEM, false, IResource.DEPTH_ZERO);
    if (markers.length > 0) {
        resource.deleteMarkers(IMarker.PROBLEM, false, IResource.DEPTH_ZERO);
    }
}
 
Example #22
Source File: AnalysisEngineMainTab.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
private IContainer getContainer(String path) {
Path containerPath = new Path(path);
IResource resource =  getWorkspaceRoot().findMember(containerPath);
if (resource instanceof IContainer)
  return (IContainer) resource;
   
   return null;
 }
 
Example #23
Source File: DefaultResourceBlacklist.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected String getBlacklistValue(List<IResource> items) {
	String blacklist = SCT_BLACKLIST_DEFAULT;
	for (IResource item : items) {
		blacklist += item.getFullPath().toPortableString() + SCT_BLACKLIST_SEPERATOR;
	}
	return blacklist;
}
 
Example #24
Source File: ReorgPolicyFactory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isChildOfOrEqualToAnyFolder(IResource resource) {
	for (int i= 0; i < fFolders.length; i++) {
		IFolder folder= fFolders[i];
		if (folder.equals(resource) || ParentChecker.isDescendantOf(resource, folder))
			return true;
	}
	return false;
}
 
Example #25
Source File: SVNWorkspaceSubscriber.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * SessionResourceVariantByteStore of remoteSyncStateStore used to store (and flush) sync changes
 * register only direct parents of the changed resources.
 * If we want to be able to flush arbitrary subtree from the remoteSyncStateStore (event subtree which root
 * is unchanged resource), we have to cache all parent of the changed resources up to the top.
 * These sync DUMMY_SYNC_BYTES are stored as synch info, so upon this dummy bytes we then filter out
 * the actually unchanged sync data from the cache 
 * @param changedResource
 */
private void registerChangedResourceParent(IResource changedResource) throws TeamException
{
	IContainer parent = changedResource.getParent();
	if (parent == null) return;
	if (remoteSyncStateStore.getBytes(parent) == null)
	{
		remoteSyncStateStore.setBytes(parent, DUMMY_SYNC_BYTES);
		registerChangedResourceParent(parent);
	}    	
}
 
Example #26
Source File: RouteTreeContentProvider.java    From eip-designer with Apache License 2.0 5 votes vote down vote up
@Override
public boolean hasChildren(Object element) {
   if (element instanceof IProject) {
      IProject project = (IProject) element;
      List<IResource> models = new ArrayList<IResource>();
      findEIPModels(models, project.getLocation(), ResourcesPlugin.getWorkspace().getRoot());
      return !models.isEmpty();
   }
   if (element instanceof IResource) {
      return true;
   }
   return false;
}
 
Example #27
Source File: CopyToClipboardAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public CopyToClipboardEnablementPolicy(IResource[] resources, IJavaElement[] javaElements, IJarEntryResource[] jarEntryResources) {
	Assert.isNotNull(resources);
	Assert.isNotNull(javaElements);
	Assert.isNotNull(jarEntryResources);
	fResources= resources;
	fJavaElements= javaElements;
	fJarEntryResources= jarEntryResources;
}
 
Example #28
Source File: LaunchShortcut.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
protected Collection<ILaunchConfiguration> findConfigurations ( final IResource resource ) throws CoreException, IOException
{
    if ( resource == null )
    {
        return Collections.emptyList ();
    }

    final Collection<ILaunchConfiguration> result = new LinkedList<> ();

    final File sourceFile = resource.getLocation ().toFile ().getCanonicalFile ();

    final ILaunchConfiguration[] cfgs = DebugPlugin.getDefault ().getLaunchManager ().getLaunchConfigurations ( getConfigurationType () );
    for ( final ILaunchConfiguration cfg : cfgs )
    {
        final Map<?, ?> envs = cfg.getAttribute ( ATTR_ENV_VARS, Collections.<String, String> emptyMap () );
        if ( envs != null )
        {
            final Object profile = envs.get ( "SCADA_PROFILE" ); //$NON-NLS-1$
            if ( profile instanceof String )
            {
                String profileString = (String)profile;
                profileString = VariablesPlugin.getDefault ().getStringVariableManager ().performStringSubstitution ( profileString );
                final File other = new File ( profileString );
                try
                {
                    if ( sourceFile.equals ( other.getCanonicalFile () ) )
                    {
                        result.add ( cfg );
                    }
                }
                catch ( final IOException e )
                {
                    // ignore this one
                }
            }
        }
    }

    return result;
}
 
Example #29
Source File: BuildPathsBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private IContainer chooseContainer() {
	Class<?>[] acceptedClasses= new Class[] { IProject.class, IFolder.class };
	ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false);
	IProject[] allProjects= fWorkspaceRoot.getProjects();
	ArrayList<IProject> rejectedElements= new ArrayList<IProject>(allProjects.length);
	IProject currProject= fCurrJProject.getProject();
	for (int i= 0; i < allProjects.length; i++) {
		if (!allProjects[i].equals(currProject)) {
			rejectedElements.add(allProjects[i]);
		}
	}
	ViewerFilter filter= new TypedViewerFilter(acceptedClasses, rejectedElements.toArray());

	ILabelProvider lp= new WorkbenchLabelProvider();
	ITreeContentProvider cp= new WorkbenchContentProvider();

	IResource initSelection= null;
	if (fOutputLocationPath != null) {
		initSelection= fWorkspaceRoot.findMember(fOutputLocationPath);
	}

	FolderSelectionDialog dialog= new FolderSelectionDialog(getShell(), lp, cp);
	dialog.setTitle(NewWizardMessages.BuildPathsBlock_ChooseOutputFolderDialog_title);
	dialog.setValidator(validator);
	dialog.setMessage(NewWizardMessages.BuildPathsBlock_ChooseOutputFolderDialog_description);
	dialog.addFilter(filter);
	dialog.setInput(fWorkspaceRoot);
	dialog.setInitialSelection(initSelection);
	dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));

	if (dialog.open() == Window.OK) {
		return (IContainer)dialog.getFirstResult();
	}
	return null;
}
 
Example #30
Source File: ForceRebuildAction.java    From texlipse with Eclipse Public License 1.0 5 votes vote down vote up
public void run(IAction action) {
    IResource res = (IResource) editor.getEditorInput().getAdapter(IResource.class);
    if (res == null) return;
    
    IProject project = res.getProject();
    TexlipseProperties.setSessionProperty(project, TexlipseProperties.FORCED_REBUILD, true);
    try {
        project.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);
    } catch (CoreException e) {
        TexlipsePlugin.log("Force rebuild CoreException", e);
    }        
    TexlipseProperties.setSessionProperty(project, TexlipseProperties.FORCED_REBUILD, null);
}