org.eclipse.ui.IWorkingSet Java Examples

The following examples show how to use org.eclipse.ui.IWorkingSet. 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: JavaProjectWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean performFinish() {
	boolean res= super.performFinish();
	if (res) {
		final IJavaElement newElement= getCreatedElement();

		IWorkingSet[] workingSets= fFirstPage.getWorkingSets();
		if (workingSets.length > 0) {
			PlatformUI.getWorkbench().getWorkingSetManager().addToWorkingSets(newElement, workingSets);
		}

		BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
		selectAndReveal(fSecondPage.getJavaProject().getProject());

		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				IWorkbenchPart activePart= getActivePart();
				if (activePart instanceof IPackagesViewPart) {
					PackageExplorerPart view= PackageExplorerPart.openInActivePerspective();
					view.tryToReveal(newElement);
				}
			}
		});
	}
	return res;
}
 
Example #2
Source File: PythonBaseModelProvider.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @param newWorkingSet
 */
private IWorkspace[] getWorkspaces(IWorkingSet newWorkingSet) {
    IAdaptable[] elements = newWorkingSet.getElements();
    HashSet<IWorkspace> set = new HashSet<IWorkspace>();

    for (IAdaptable adaptable : elements) {
        IResource adapter = adaptable.getAdapter(IResource.class);
        if (adapter != null) {
            IWorkspace workspace = adapter.getWorkspace();
            set.add(workspace);
        } else {
            Log.log("Was not expecting that IWorkingSet adaptable didn't return anything...");
        }
    }
    return set.toArray(new IWorkspace[0]);
}
 
Example #3
Source File: RefreshAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void refreshJavaElements(IStructuredSelection selection, IProgressMonitor monitor) throws JavaModelException {
	Object[] selectedElements= selection.toArray();
	ArrayList<IJavaElement> javaElements= new ArrayList<IJavaElement>();
	for (int i= 0; i < selectedElements.length; i++) {
		Object curr= selectedElements[i];
		if (curr instanceof IPackageFragmentRoot) {
			javaElements.add((IPackageFragmentRoot) curr);
		} else if (curr instanceof PackageFragmentRootContainer) {
			javaElements.addAll(Arrays.asList(((PackageFragmentRootContainer) curr).getPackageFragmentRoots()));
		} else if (curr instanceof IWorkingSet) {
			IAdaptable[] members= ((IWorkingSet) curr).getElements();
			for (int k= 0; k < members.length; k++) {
				IJavaElement adapted= (IJavaElement)members[k].getAdapter(IJavaElement.class);
				if (adapted instanceof IPackageFragmentRoot) {
					javaElements.add(adapted);
				}
			}
		}
		}
	if (!javaElements.isEmpty()) {
		IJavaModel model= JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
		model.refreshExternalArchives(javaElements.toArray(new IJavaElement[javaElements.size()]), monitor);
	}
}
 
Example #4
Source File: WorkingSetManagerModificationStrategyProvider.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns with the strategy for the given property change even argument,
 *
 * @param event
 *            a property change argument.
 * @return a strategy encapsulating an actual working set manager modification.
 */
public WorkingSetManagerModificationStrategy getStrategy(final PropertyChangeEvent event) {

	if (event == null) {
		return NOOP;
	}

	final String property = event.getProperty();
	switch (property) {
	case CHANGE_WORKING_SET_ADD:
		return new AddWorkingSetModificationStrategy((IWorkingSet) event.getNewValue());
	case CHANGE_WORKING_SET_REMOVE:
		return new RemoveWorkingSetModificationStrategy((IWorkingSet) event.getOldValue());
	case CHANGE_WORKING_SET_LABEL_CHANGE: //$FALL-THROUGH$
	case CHANGE_WORKING_SET_NAME_CHANGE: //$FALL-THROUGH$
	case CHANGE_WORKING_SET_CONTENT_CHANGE:
		return new UpdateWorkingSetModificationStraregy(
				(IWorkingSet) event.getOldValue(),
				(IWorkingSet) event.getNewValue());
	default:
		return NOOP;
	}
}
 
Example #5
Source File: GoSearchPage.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
public FileTextSearchScope createTextSearchScope() {
  // Setup search scope
  switch (getContainer().getSelectedScope()) {
    case ISearchPageContainer.WORKSPACE_SCOPE:
      return FileTextSearchScope.newWorkspaceScope(getExtensions(), false);
    case ISearchPageContainer.SELECTION_SCOPE:
      return getSelectedResourcesScope();
    case ISearchPageContainer.SELECTED_PROJECTS_SCOPE:
      return getEnclosingProjectScope();
    case ISearchPageContainer.WORKING_SET_SCOPE:
      IWorkingSet[] workingSets = getContainer().getSelectedWorkingSets();
      return FileTextSearchScope.newSearchScope(workingSets, getExtensions(), false);
    default:
      // unknown scope
      return FileTextSearchScope.newWorkspaceScope(getExtensions(), false);
  }
}
 
Example #6
Source File: DynamicWorkingSetWizardPDETest.java    From eclipse-extras with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testCreateWorkingSet() {
  wizard.init( PlatformUI.getWorkbench(), null );
  wizard.addPages();
  DynamicWorkingSetPage startingPage = ( DynamicWorkingSetPage )wizard.getStartingPage();

  IWorkingSet workingSet = startingPage.getSelection();

  assertThat( workingSet.getName() ).isEmpty();
  assertThat( workingSet.getElements() ).isEmpty();
  assertThat( workingSet.isSelfUpdating() ).isTrue();
  assertThat( workingSet.isAggregateWorkingSet() ).isFalse();
  assertThat( workingSet.isEditable() ).isTrue();
  assertThat( workingSet.getId() ).isEqualTo( DynamicWorkingSet.ID );
  assertThat( workingSet.getLabel() ).isEmpty();
  assertThat( workingSet.getImageDescriptor() ).isNotNull();
}
 
Example #7
Source File: ConfigureWorkingSetAssignementAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void recalculateCheckedState(List<IWorkingSet> addedWorkingSets) {
	Set<IWorkingSet> checkedWorkingSets= new HashSet<IWorkingSet>();
	GrayedCheckedModelElement[] elements= fModel.getChecked();
	for (int i= 0; i < elements.length; i++)
		checkedWorkingSets.add(elements[i].getWorkingSet());

	if (addedWorkingSets != null)
		checkedWorkingSets.addAll(addedWorkingSets);

	fModel= createGrayedCheckedModel(fElements, getAllWorkingSets(), checkedWorkingSets);

	fTableViewer.setInput(fModel);
	fTableViewer.refresh();
	fTableViewer.setCheckedElements(fModel.getChecked());
	fTableViewer.setGrayedElements(fModel.getGrayed());
}
 
Example #8
Source File: NewExtensionWizardPage.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes GUI elements of {@link NewExtensionWizardPage}
 */
private void initialize() {
	ExtensionUtils.getTemplates().stream().forEach(template -> extensionTemplateCombo.add(template));
	extensionTemplateCombo.setText("yempty");
	IWorkingSet[] workingSets = PlatformUI.getWorkbench().getWorkingSetManager().getAllWorkingSets();
	if (workingSets != null)
	{
		for (IWorkingSet workingSet: workingSets)
		{
			if (!workingSet.getName().startsWith("Aggregate"))
			{
				workingSetCombo.add(workingSet.getName());
			}
		}
	}
	extensionDirectoryField.setStringValue(getDefaultExtensionLocation());
}
 
Example #9
Source File: ResourceUtils.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Collects and combines the selection which may contain sources from
 * different projects and / or multiple sources from same project.
 * <p>
 * If selection contains hierarchical data (like file and it's parent
 * directory), the only topmost element is returned (same for directories
 * from projects).
 * <p>
 * The children from selected parents are not resolved, so that the return
 * value contains the 'highest' possible hierarchical elements without
 * children.
 *
 * @param structuredSelection
 * @return a map with the project as a key and selected resources as value.
 *         If project itself was selected, then key is the same as value.
 */
public static Map<IProject, List<WorkItem>> getResourcesPerProject(IStructuredSelection structuredSelection) {
    Map<IProject, List<WorkItem>> projectsMap = new HashMap<>();
    for (Iterator<?> iter = structuredSelection.iterator(); iter.hasNext();) {
        Object element = iter.next();
        WorkItem workItem = getWorkItem(element);
        if (workItem == null) {
            IWorkingSet wset = Util.getAdapter(IWorkingSet.class, element);
            if (wset != null) {
                mapResources(wset, projectsMap);
                continue;
            }

            // Support for active changesets
            ChangeSet set = Util.getAdapter(ChangeSet.class, element);
            for (WorkItem change : getResources(set)) {
                mapResource(change, projectsMap, true);
            }
            continue;
        }
        mapResource(workItem, projectsMap, false);
    }
    return projectsMap;
}
 
Example #10
Source File: WorkingSetConfigurationDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Removes the selected working sets from the workbench.
 */
private void removeSelectedWorkingSets() {
	ISelection selection= fTableViewer.getSelection();
	if (selection instanceof IStructuredSelection) {
		IWorkingSetManager manager= PlatformUI.getWorkbench().getWorkingSetManager();
		Iterator<?> iter= ((IStructuredSelection)selection).iterator();
		while (iter.hasNext()) {
			IWorkingSet workingSet= (IWorkingSet)iter.next();
			if (fAddedWorkingSets.contains(workingSet)) {
				fAddedWorkingSets.remove(workingSet);
			} else {
				IWorkingSet[] recentWorkingSets= manager.getRecentWorkingSets();
				for (int i= 0; i < recentWorkingSets.length; i++) {
					if (workingSet.equals(recentWorkingSets[i])) {
						fRemovedMRUWorkingSets.add(workingSet);
						break;
					}
				}
				fRemovedWorkingSets.add(workingSet);
			}
			fAllWorkingSets.remove(workingSet);
			manager.removeWorkingSet(workingSet);
		}
		fTableViewer.remove(((IStructuredSelection)selection).toArray());
	}
}
 
Example #11
Source File: RemoveWorkingSetElementAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run(IStructuredSelection selection) {
	IWorkingSet ws= getWorkingSet(selection);
	if (ws == null)
		return;
	HashSet<IAdaptable> elements= new HashSet<IAdaptable>(Arrays.asList(ws.getElements()));
	List<?> selectedElements= selection.toList();
	for (Iterator<?> iter= selectedElements.iterator(); iter.hasNext();) {
		Object object= iter.next();
		if (object instanceof IAdaptable) {
			IAdaptable[] adaptedElements= ws.adaptElements(new IAdaptable[] {(IAdaptable)object});
			if (adaptedElements.length == 1) {
				elements.remove(adaptedElements[0]);
			}
		}
	}
	ws.setElements(elements.toArray(new IAdaptable[elements.size()]));
}
 
Example #12
Source File: ConfigureWorkingSetAssignementAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static GrayedCheckedModel createGrayedCheckedModel(IAdaptable[] elements, IWorkingSet[] workingSets, Set<IWorkingSet> checkedWorkingSets) {
	GrayedCheckedModelElement[] result= new GrayedCheckedModelElement[workingSets.length];

	for (int i= 0; i < workingSets.length; i++) {
		IWorkingSet workingSet= workingSets[i];
		
		int checkCount= 0;
		for (int j= 0; j < elements.length; j++) {
			if (checkedWorkingSets == null) {
				IAdaptable adapted= adapt(workingSet, elements[j]);
				if (adapted != null && contains(workingSet, adapted))
					checkCount++;
			} else {
				if (checkedWorkingSets.contains(workingSet))
					checkCount++;
			}
		}

		result[i]= new GrayedCheckedModelElement(workingSet, checkCount, elements.length);
	}

	return new GrayedCheckedModel(result);
}
 
Example #13
Source File: ResourceUtils.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * @param wset
 *            non null working set
 * @return non null set with work items, which may be empty
 */
public static Set<WorkItem> getResources(IWorkingSet wset) {
    Set<WorkItem> set = new HashSet<>();
    boolean aggregateWorkingSet = wset.isAggregateWorkingSet();
    // IAggregateWorkingSet was introduced in Eclipse 3.5
    if (aggregateWorkingSet && wset instanceof IAggregateWorkingSet) {
        IAggregateWorkingSet aggr = (IAggregateWorkingSet) wset;
        IWorkingSet[] sets = aggr.getComponents();
        for (IWorkingSet iWorkingSet : sets) {
            set.addAll(getResources(iWorkingSet));
        }
    } else {
        IAdaptable[] elements = wset.getElements();
        for (IAdaptable iAdaptable : elements) {
            WorkItem item = getWorkItem(iAdaptable);
            if (item != null) {
                set.add(item);
            }
        }
    }
    return set;
}
 
Example #14
Source File: WorkingSetModel.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @param memento a memento, or <code>null</code>
 */
public WorkingSetModel(IMemento memento) {
	fLocalWorkingSetManager= PlatformUI.getWorkbench().createLocalWorkingSetManager();
	addListenersToWorkingSetManagers();
	fActiveWorkingSets= new ArrayList<IWorkingSet>();
	fAllWorkingSets= new ArrayList<IWorkingSet>();

	if (memento == null || ! restoreState(memento)) {
		IWorkingSet others= fLocalWorkingSetManager.createWorkingSet(WorkingSetMessages.WorkingSetModel_others_name, new IAdaptable[0]);
		others.setId(IWorkingSetIDs.OTHERS);
		fLocalWorkingSetManager.addWorkingSet(others);
		fActiveWorkingSets.add(others);
		fAllWorkingSets.add(others);
	}
	Assert.isNotNull(fOthersWorkingSetUpdater);

	fElementMapper.rebuild(getActiveWorkingSets());
	fOthersWorkingSetUpdater.updateElements();
}
 
Example #15
Source File: NewWizardsActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private boolean isNewTarget(Object element) {
	if (element == null)
		return true;
	if (element instanceof IResource) {
		return true;
	}
	if (element instanceof IJavaElement) {
		int type= ((IJavaElement)element).getElementType();
		return type == IJavaElement.JAVA_PROJECT ||
			type == IJavaElement.PACKAGE_FRAGMENT_ROOT ||
			type == IJavaElement.PACKAGE_FRAGMENT ||
			type == IJavaElement.COMPILATION_UNIT ||
			type == IJavaElement.TYPE;
	}
	if (element instanceof IWorkingSet) {
		String workingSetId= ((IWorkingSet)element).getId();
		return
			IWorkingSetIDs.JAVA.equals(workingSetId) ||
			IWorkingSetIDs.RESOURCE.equals(workingSetId) ||
			IWorkingSetIDs.OTHERS.equals(workingSetId);
	}
	return false;
}
 
Example #16
Source File: WorkingSetModel.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Tells whether the given working set is supported as top-level element
 * 
 * @param workingSet the working set to test
 * @return <code>true</code> if the given working set is supported as top-level element
 * @since 3.6
 */
public static boolean isSupportedAsTopLevelElement(IWorkingSet workingSet) {
	Object id= workingSet.getId();
	if (IWorkingSetIDs.OTHERS.equals(id) || IWorkingSetIDs.JAVA.equals(id) || IWorkingSetIDs.RESOURCE.equals(id))
		return true;

	if (!workingSet.isSelfUpdating() || workingSet.isAggregateWorkingSet())
		return false;

	IAdaptable[] elements= workingSet.getElements();
	for (int i= 0; i < elements.length; i++) {
		IAdaptable element= elements[i];
		IProject p= (IProject)element.getAdapter(IProject.class);
		if (p != null && p.exists())
			return true;
	}
	return false;
}
 
Example #17
Source File: LRUWorkingSetsList.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private IWorkingSet[] find(ArrayList<IWorkingSet[]> list, IWorkingSet[] workingSets) {
	Set<IWorkingSet> workingSetList= new HashSet<IWorkingSet>(Arrays.asList(workingSets));
	Iterator<IWorkingSet[]> iter= list.iterator();
	while (iter.hasNext()) {
		IWorkingSet[] lruWorkingSets= iter.next();
		Set<IWorkingSet> lruWorkingSetList= new HashSet<IWorkingSet>(Arrays.asList(lruWorkingSets));
		if (lruWorkingSetList.equals(workingSetList))
			return lruWorkingSets;
	}
	return null;
}
 
Example #18
Source File: WorbenchWorkingSetsProviderPDETest.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testGetWorkingSets() {
  workingSetManager.addWorkingSet( workingSet );

  IWorkingSet[] workingSets = new WorbenchWorkingSetsProvider().getWorkingSets();

  assertThat( workingSets ).containsOnly( workingSet );
}
 
Example #19
Source File: PythonBaseModelProvider.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
private TreeNode<LabelAndImage> createErrorWorkingSetWithoutChildren(IWorkingSet parentElement) {
    IImageHandle img = SharedUiPlugin.getImageCache().get(UIConstants.WARNING);
    TreeNode<LabelAndImage> root = new TreeNode<LabelAndImage>(parentElement,
            new LabelAndImage("Warning: working set: " + parentElement.getName() + " does not have any contents.",
                    img));
    new TreeNode<>(root, new LabelAndImage(
            "Access the menu (Ctrl+F10) to edit the working set.", null));
    new TreeNode<>(root, new LabelAndImage(
            "Or select the working set in the tree and use Alt+Enter.", null));
    return root;
}
 
Example #20
Source File: FindImplementorsInWorkingSetAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
QuerySpecification createQuery(IJavaElement element) throws JavaModelException, InterruptedException {
	JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance();

	IWorkingSet[] workingSets= fWorkingSets;
	if (fWorkingSets == null) {
		workingSets= factory.queryWorkingSets();
		if (workingSets == null)
			return super.createQuery(element); // workspace
	}
	SearchUtil.updateLRUWorkingSets(workingSets);
	IJavaSearchScope scope= factory.createJavaSearchScope(workingSets, JavaSearchScopeFactory.NO_PROJ);
	String description= factory.getWorkingSetScopeDescription(workingSets, JavaSearchScopeFactory.NO_PROJ);
	return new ElementQuerySpecification(element, getLimitTo(), scope, description);
}
 
Example #21
Source File: BugContentProvider.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void inputChanged(Viewer newViewer, Object oldInput, Object newInput) {
    viewer = (CommonViewer) newViewer;
    if (newInput == null || newInput instanceof IWorkingSet || newInput instanceof IWorkspaceRoot) {
        rootElement.dispose();
    }
    input = newInput;
    if (newInput == null) {
        refreshJob.setViewer(null);
    } else {
        refreshJob.setViewer((CommonViewer) newViewer);
        bugFilterActive = isBugFilterActive();
    }
    clearFilters();
}
 
Example #22
Source File: MainProjectWizardPage.java    From sarl with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new {@link MainProjectWizardPage}.
 */
@SuppressWarnings("synthetic-access")
public MainProjectWizardPage() {
	super(Messages.SARLProjectNewWizard_3);
	setPageComplete(false);

	this.nameGroup = new NameGroup();
	this.locationGroup = new LocationGroup();
	this.sreGroup = new SREConfigurationBlock(Messages.MainProjectPage_0, true, null, null);
	this.jreGroup = new JREGroup();
	this.workingSetGroup = new WorkingSetGroup();
	this.detectGroup = new DetectGroup();

	// establish connections
	this.nameGroup.addObserver(this.locationGroup);
	this.detectGroup.addObserver(this.jreGroup);
	this.locationGroup.addObserver(this.detectGroup);

	// initialize all elements
	this.nameGroup.notifyObservers();

	// create and connect validator
	this.validator = new Validator();
	this.nameGroup.addObserver(this.validator);
	this.locationGroup.addObserver(this.validator);

	// initialize defaults
	setProjectName(""); //$NON-NLS-1$
	setProjectLocationURI(null);
	setWorkingSets(new IWorkingSet[0]);

	initializeDefaultVM();

	setTitle(Messages.SARLProjectNewWizard_3);
	setDescription(Messages.SARLProjectNewWizard_1);
	setImageDescriptor(SARLEclipsePlugin.getDefault().getImageDescriptor(
			SARLEclipseConfig.NEW_PROJECT_WIZARD_DIALOG_IMAGE));
}
 
Example #23
Source File: GitCloneHandler.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This private method is used to import existing projects into the project
 * explorer.
 * 
 * @param repository
 * @param sets
 */
protected void importProjects(final Repository repository, final IWorkingSet[] sets) {
	String repoName = Activator.getDefault().getRepositoryUtil().getRepositoryName(repository);
	Job importJob = new WorkspaceJob(MessageFormat.format(UIText.GitCloneWizard_jobImportProjects, repoName)) {

		@Override
		public IStatus runInWorkspace(IProgressMonitor monitor) {
			List<File> files = new ArrayList<File>();
			ProjectUtil.findProjectFiles(files, repository.getWorkTree(), true, monitor);
			if (files.isEmpty()) {
				return Status.OK_STATUS;
			}

			Set<ProjectRecord> projectRecords = new LinkedHashSet<ProjectRecord>();
			for (File file : files) {
				projectRecords.add(new ProjectRecord(file));
			}
			try {
				ProjectUtils.createProjects(projectRecords, sets, monitor);
			} catch (InvocationTargetException | InterruptedException e) {
				Activator.logError(e.getLocalizedMessage(), e);
			}

			return Status.OK_STATUS;
		}
	};
	importJob.schedule();
}
 
Example #24
Source File: SearchUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Updates the LRU list of working sets.
 *
 * @param workingSets	the workings sets to be added to the LRU list
 */
public static void updateLRUWorkingSets(IWorkingSet[] workingSets) {
	if (workingSets == null || workingSets.length < 1)
		return;

	getLRUWorkingSets().add(workingSets);
	saveState(getDialogStoreSection());
}
 
Example #25
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 {
	String[] fileData= getClipboardFiles(availableTypes);
	if (fileData == null)
		return;

	IContainer container= getAsContainer(getTarget(javaElements, resources));
	if (container == null)
		return;

	new CopyFilesAndFoldersOperation(getShell()).copyFiles(fileData, container);
}
 
Example #26
Source File: LRUWorkingSetsList.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void add(IWorkingSet[] workingSets) {
	removeDeletedWorkingSets();
	IWorkingSet[] existingWorkingSets= find(fLRUList, workingSets);
	if (existingWorkingSets != null)
		fLRUList.remove(existingWorkingSets);
	else if (fLRUList.size() == fSize)
		fLRUList.remove(fSize - 1);
	fLRUList.add(0, workingSets);

}
 
Example #27
Source File: PydevPackageExplorer.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public IWorkingSet[] getSelectedWorkingSets() {
    Object input = getInput();
    if (input instanceof AggregateWorkingSet) {
        return ((AggregateWorkingSet) input).getComponents();
    }
    return null;
}
 
Example #28
Source File: JavaWorkingSetUpdater.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void checkElementExistence(IWorkingSet workingSet) {
	List<IAdaptable> elements= new ArrayList<IAdaptable>(Arrays.asList(workingSet.getElements()));
	boolean changed= false;
	for (Iterator<IAdaptable> iter= elements.iterator(); iter.hasNext();) {
		IAdaptable element= iter.next();
		boolean remove= false;
		if (element instanceof IJavaElement) {
			IJavaElement jElement= (IJavaElement)element;
			// If we have directly a project then remove it when it
			// doesn't exist anymore. However if we have a sub element
			// under a project only remove the element if the parent
			// project is open. Otherwise we would remove all elements
			// in closed projects.
			if (jElement instanceof IJavaProject) {
				remove= !jElement.exists();
			} else {
				final IJavaProject javaProject= jElement.getJavaProject();
				final boolean isProjectOpen= javaProject != null ? javaProject.getProject().isOpen() : true;
				remove= isProjectOpen && !jElement.exists();
			}
		} else if (element instanceof IResource) {
			IResource resource= (IResource)element;
			// See comments above
			if (resource instanceof IProject) {
				remove= !resource.exists();
			} else {
				IProject project= resource.getProject();
				remove= (project != null ? project.isOpen() : true) && !resource.exists();
			}
		}
		if (remove) {
			iter.remove();
			changed= true;
		}
	}
	if (changed) {
		workingSet.setElements(elements.toArray(new IAdaptable[elements.size()]));
	}
}
 
Example #29
Source File: WorkingSetModel.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void addToMap(Map<IAdaptable, Object> map, IAdaptable key, IWorkingSet value) {
	Object obj= map.get(key);
	if (obj == null) {
		map.put(key, value);
	} else if (obj instanceof IWorkingSet) {
		List<IWorkingSet> l= new ArrayList<IWorkingSet>(2);
		l.add((IWorkingSet) obj);
		l.add(value);
		map.put(key, l);
	} else if (obj instanceof List) {
		@SuppressWarnings("unchecked")
		List<IWorkingSet> sets= (List<IWorkingSet>)obj;
		sets.add(value);
	}
}
 
Example #30
Source File: WorkingSetAwareContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean hasChildren(Object element) {
	if (element instanceof IWorkingSet)
		return true;
	return super.hasChildren(element);
}