use of org.eclipse.ui.IWorkingSet in project mdw-designer by CenturyLinkCloud.
the class SearchPage method determineScope.
protected void determineScope() {
if (searchPattern == null)
searchPattern = "";
if (scopedProjects == null) {
// determine scoped projects from selection
scopedProjects = new ArrayList<WorkflowProject>();
if (searchPageContainer.getSelectedScope() == ISearchPageContainer.SELECTED_PROJECTS_SCOPE) {
for (String projectName : searchPageContainer.getSelectedProjectNames()) {
IProject project = MdwPlugin.getWorkspaceRoot().getProject(projectName);
WorkflowProject workflowProject = WorkflowProjectManager.getInstance().getWorkflowProject(project);
if (workflowProject != null && !scopedProjects.contains(workflowProject))
scopedProjects.add(workflowProject);
}
} else if (searchPageContainer.getSelectedScope() == ISearchPageContainer.SELECTION_SCOPE) {
if (searchPageContainer.getSelection() instanceof WorkflowProject)
scopedProjects.add((WorkflowProject) searchPageContainer.getSelection());
if (searchPageContainer.getSelection() instanceof WorkflowPackage)
selectedPackage = (WorkflowPackage) searchPageContainer.getSelection();
} else if (searchPageContainer.getSelectedScope() == ISearchPageContainer.WORKING_SET_SCOPE) {
for (IWorkingSet workingSet : searchPageContainer.getSelectedWorkingSets()) {
for (IAdaptable element : workingSet.getElements()) {
if (element instanceof IProject || element instanceof IJavaProject) {
IProject project = element instanceof IJavaProject ? ((IJavaProject) element).getProject() : (IProject) element;
WorkflowProject workflowProject = WorkflowProjectManager.getInstance().getWorkflowProject(project);
if (workflowProject != null && !scopedProjects.contains(workflowProject))
scopedProjects.add(workflowProject);
}
}
}
} else {
scopedProjects.addAll(WorkflowProjectManager.getInstance().getWorkflowProjects());
}
}
}
use of org.eclipse.ui.IWorkingSet in project egit by eclipse.
the class LabelEventJob method decorateResourceMapping.
/**
* Decorates a resource mapping (i.e. a Working Set).
*
* @param element the element for which the decoration was initially called
* @param decoration the decoration
* @throws CoreException
*/
private void decorateResourceMapping(Object element, IDecoration decoration) throws CoreException {
@SuppressWarnings("restriction") ResourceMapping mapping = Utils.getResourceMapping(element);
if (mapping == null) {
return;
}
boolean isWorkingSet = mapping.getModelObject() instanceof IWorkingSet;
IDecoratableResource decoRes;
try {
if (isWorkingSet) {
decoRes = new DecoratableWorkingSet(mapping);
} else {
decoRes = new DecoratableResourceMapping(mapping);
}
} catch (IOException e) {
throw new CoreException(Activator.createErrorStatus(NLS.bind(UIText.Decorator_exceptionMessage, element), e));
}
/*
* don't render question marks on working sets. !isTracked() can have two reasons:
* 1) nothing is tracked.
* 2) no indexDiff for the contained projects ready yet.
* in both cases, don't do anything to not pollute the display of the sets.
*/
if (!decoRes.isTracked() && isWorkingSet) {
return;
}
helper.decorate(decoration, decoRes);
}
use of org.eclipse.ui.IWorkingSet in project egit by eclipse.
the class AbstractGitCloneWizard method performClone.
/**
* Do the clone using data which were collected on the pages
* {@code validSource} and {@code cloneDestination}
*
* @param gitRepositoryInfo
* @return if clone was successful
* @throws URISyntaxException
*/
protected boolean performClone(GitRepositoryInfo gitRepositoryInfo) throws URISyntaxException {
URIish uri = new URIish(gitRepositoryInfo.getCloneUri());
UserPasswordCredentials credentials = gitRepositoryInfo.getCredentials();
setWindowTitle(NLS.bind(UIText.GitCloneWizard_jobName, uri.toString()));
final boolean allSelected;
final Collection<Ref> selectedBranches;
if (validSource.isSourceRepoEmpty()) {
// fetch all branches of empty repo
allSelected = true;
selectedBranches = Collections.emptyList();
} else {
allSelected = validSource.isAllSelected();
selectedBranches = validSource.getSelectedBranches();
}
final File workdir = cloneDestination.getDestinationFile();
final Ref ref = cloneDestination.getInitialBranch();
final String remoteName = cloneDestination.getRemote();
boolean created = workdir.exists();
if (!created)
created = workdir.mkdirs();
if (!created || !workdir.isDirectory()) {
final String errorMessage = NLS.bind(UIText.GitCloneWizard_errorCannotCreate, workdir.getPath());
ErrorDialog.openError(getShell(), getWindowTitle(), UIText.GitCloneWizard_failed, new Status(IStatus.ERROR, Activator.getPluginId(), 0, errorMessage, null));
// let's give user a chance to fix this minor problem
return false;
}
int timeout = Activator.getDefault().getPreferenceStore().getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT);
final CloneOperation op = new CloneOperation(uri, allSelected, selectedBranches, workdir, ref != null ? ref.getName() : null, remoteName, timeout);
CredentialsProvider credentialsProvider = null;
if (credentials != null) {
credentialsProvider = new EGitCredentialsProvider(credentials.getUser(), credentials.getPassword());
} else {
credentialsProvider = new EGitCredentialsProvider();
}
op.setCredentialsProvider(credentialsProvider);
op.setCloneSubmodules(cloneDestination.isCloneSubmodules());
rememberHttpHost(op, uri);
configureFetchSpec(op, gitRepositoryInfo, remoteName);
configurePush(op, gitRepositoryInfo, remoteName);
configureRepositoryConfig(op, gitRepositoryInfo);
configureGerrit(op, gitRepositoryInfo, credentialsProvider, remoteName, timeout);
if (cloneDestination.isImportProjects()) {
final IWorkingSet[] sets = cloneDestination.getWorkingSets();
op.addPostCloneTask(new PostCloneTask() {
@Override
public void execute(Repository repository, IProgressMonitor monitor) throws CoreException {
importProjects(repository, sets);
}
});
}
alreadyClonedInto = workdir.getPath();
if (!callerRunsCloneOperation)
runAsJob(uri, op, gitRepositoryInfo);
else
cloneOperation = op;
return true;
}
use of org.eclipse.ui.IWorkingSet in project egit by eclipse.
the class SelectionPropertyTester method getRepositoryOfProjects.
/**
* @param collection
* the selected elements
* @param single
* <code>true</code> if only a single repository is allowed
* @return the repository if any was found, <code>null</code> otherwise
*/
private static Repository getRepositoryOfProjects(Collection<?> collection, boolean single) {
Repository repo = null;
for (Object element : collection) {
IContainer container = AdapterUtils.adapt(element, IProject.class);
RepositoryMapping mapping = null;
if (container != null) {
mapping = RepositoryMapping.getMapping(container);
} else {
container = AdapterUtils.adapt(element, IContainer.class);
if (container != null) {
mapping = RepositoryMapping.getMapping(container);
}
}
if (container != null && mapping != null && container.equals(mapping.getContainer())) {
Repository r = mapping.getRepository();
if (single && r != null && repo != null && r != repo) {
return null;
} else if (r != null) {
repo = r;
}
} else {
IWorkingSet workingSet = AdapterUtils.adapt(element, IWorkingSet.class);
if (workingSet != null) {
for (IAdaptable adaptable : workingSet.getElements()) {
Repository r = getRepositoryOfProject(adaptable);
if (single && r != null && repo != null && r != repo) {
return null;
} else if (r != null) {
repo = r;
}
}
}
}
}
return repo;
}
use of org.eclipse.ui.IWorkingSet in project bndtools by bndtools.
the class WorkingSetTracker method doWorkingSets.
static void doWorkingSets(final Project model, final IProject targetProject) {
IWorkbench workbench = PlatformUI.getWorkbench();
final IWorkingSetManager workingSetManager = workbench.getWorkingSetManager();
String mergeProperties = model.mergeProperties("-workingset");
if (mergeProperties == null)
return;
Parameters memberShips = new Parameters(mergeProperties);
IWorkingSet[] allWorkingSets = workingSetManager.getAllWorkingSets();
for (IWorkingSet currentWorkingSet : allWorkingSets) {
Attrs attrs = memberShips.remove(currentWorkingSet.getName());
boolean shouldBeMember = attrs != null && Processor.isTrue(attrs.get("member", "true"));
IAdaptable[] elements = currentWorkingSet.getElements();
List<IAdaptable> members = new ExtList<>(elements);
boolean foundProjectInCurrentWorkingSet = false;
for (Iterator<IAdaptable> it = members.iterator(); it.hasNext(); ) {
IAdaptable member = it.next();
if (member.getAdapter(IProject.class) == targetProject) {
foundProjectInCurrentWorkingSet = true;
if (!shouldBeMember) {
it.remove();
}
}
}
if (!foundProjectInCurrentWorkingSet && shouldBeMember) {
members.add(targetProject);
}
if (elements.length != members.size()) {
updateWorkingSet(currentWorkingSet, members);
}
}
for (final Entry<String, Attrs> e : memberShips.entrySet()) {
String name = e.getKey();
boolean isMember = Processor.isTrue(e.getValue().get("member", "true"));
if (!isMember)
continue;
if (!JAVAID_P.matcher(name).matches()) {
SetLocation error = model.warning("Invalid working set name '%s'. Must use pattern of Java identifier", name);
error.file(model.getPropertiesFile().getAbsolutePath());
error.header("-workingset");
continue;
}
IAdaptable[] members = new IAdaptable[1];
members[0] = targetProject;
IWorkingSet newWorkingSet = workingSetManager.createWorkingSet(name, members);
newWorkingSet.setId("org.eclipse.jdt.ui.JavaWorkingSetPage");
newWorkingSet.setLabel(null);
workingSetManager.addWorkingSet(newWorkingSet);
}
}
Aggregations