use of org.eclipse.ui.IWorkingSet in project egit by eclipse.
the class GitCreateProjectViaWizardWizard method importProjects.
private void importProjects(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
switch(mySelectionPage.getWizardSelection()) {
case GitSelectWizardPage.EXISTING_PROJECTS_WIZARD:
{
final Set<ProjectRecord> projectsToCreate = new HashSet<>();
final List<IWorkingSet> workingSets = new ArrayList<>();
// get the data from the page in the UI thread
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
projectsToCreate.addAll(myProjectsImportPage.getCheckedProjects());
IWorkingSet[] workingSetArray = myProjectsImportPage.getSelectedWorkingSets();
workingSets.addAll(Arrays.asList(workingSetArray));
myProjectsImportPage.saveWidgetValues();
}
});
ProjectUtils.createProjects(projectsToCreate, workingSets.toArray(new IWorkingSet[workingSets.size()]), monitor);
break;
}
case GitSelectWizardPage.NEW_WIZARD:
{
final List<IProject> previousProjects = Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects());
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
new NewProjectAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow()).run();
}
});
IWorkspaceRunnable wsr = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor actMonitor) throws CoreException {
IProject[] currentProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
SubMonitor progress = SubMonitor.convert(monitor, currentProjects.length);
for (IProject current : currentProjects) {
if (!previousProjects.contains(current)) {
ConnectProviderOperation cpo = new ConnectProviderOperation(current, myRepository.getDirectory());
cpo.execute(progress.newChild(1));
} else {
progress.worked(1);
}
}
}
};
try {
ResourcesPlugin.getWorkspace().run(wsr, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
break;
}
case GitSelectWizardPage.GENERAL_WIZARD:
{
final String[] projectName = new String[1];
final boolean[] defaultLocation = new boolean[1];
// get the data from the page in the UI thread
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
projectName[0] = myCreateGeneralProjectPage.getProjectName();
defaultLocation[0] = myCreateGeneralProjectPage.isDefaultLocation();
}
});
try {
IWorkspaceRunnable wsr = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor actMonitor) throws CoreException {
final IProjectDescription desc = ResourcesPlugin.getWorkspace().newProjectDescription(projectName[0]);
if (!defaultLocation[0]) {
desc.setLocation(new Path(myGitDir));
}
SubMonitor progress = SubMonitor.convert(actMonitor, 4);
IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject(desc.getName());
prj.create(desc, progress.newChild(1));
prj.open(progress.newChild(1));
ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_ONE, progress.newChild(1));
File repoDir = myRepository.getDirectory();
ConnectProviderOperation cpo = new ConnectProviderOperation(prj, repoDir);
cpo.execute(progress.newChild(1));
}
};
ResourcesPlugin.getWorkspace().run(wsr, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
break;
}
}
}
use of org.eclipse.ui.IWorkingSet in project egit by eclipse.
the class GitImportWizard method importProjects.
private void importProjects(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
switch(importWithDirectoriesPage.getWizardSelection()) {
case GitSelectWizardPage.EXISTING_PROJECTS_WIZARD:
{
final Set<ProjectRecord> projectsToCreate = new HashSet<>();
final List<IWorkingSet> workingSets = new ArrayList<>();
// get the data from the pages in the UI thread
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
projectsToCreate.addAll(projectsImportPage.getCheckedProjects());
IWorkingSet[] workingSetArray = projectsImportPage.getSelectedWorkingSets();
workingSets.addAll(Arrays.asList(workingSetArray));
projectsImportPage.saveWidgetValues();
}
});
ProjectUtils.createProjects(projectsToCreate, workingSets.toArray(new IWorkingSet[workingSets.size()]), monitor);
break;
}
case GitSelectWizardPage.NEW_WIZARD:
{
final File[] repoDir = new File[1];
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
repoDir[0] = getTargetRepository().getDirectory();
}
});
final List<IProject> previousProjects = Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects());
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
new NewProjectAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow()).run();
}
});
IWorkspaceRunnable wsr = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor actMonitor) throws CoreException {
IProject[] currentProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
SubMonitor progress = SubMonitor.convert(actMonitor, currentProjects.length);
for (IProject current : currentProjects) if (!previousProjects.contains(current)) {
ConnectProviderOperation cpo = new ConnectProviderOperation(current, repoDir[0]);
cpo.execute(progress.newChild(1));
} else {
progress.worked(1);
}
}
};
try {
ResourcesPlugin.getWorkspace().run(wsr, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
break;
}
case GitSelectWizardPage.GENERAL_WIZARD:
{
final String[] projectName = new String[1];
final boolean[] defaultLocation = new boolean[1];
final String[] path = new String[1];
final File[] repoDir = new File[1];
// get the data from the page in the UI thread
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
projectName[0] = createGeneralProjectPage.getProjectName();
defaultLocation[0] = createGeneralProjectPage.isDefaultLocation();
path[0] = importWithDirectoriesPage.getPath();
repoDir[0] = getTargetRepository().getDirectory();
}
});
try {
IWorkspaceRunnable wsr = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor actMonitor) throws CoreException {
final IProjectDescription desc = ResourcesPlugin.getWorkspace().newProjectDescription(projectName[0]);
desc.setLocation(new Path(path[0]));
SubMonitor progress = SubMonitor.convert(actMonitor, 4);
IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject(desc.getName());
prj.create(desc, progress.newChild(1));
prj.open(progress.newChild(1));
ConnectProviderOperation cpo = new ConnectProviderOperation(prj, repoDir[0]);
cpo.execute(progress.newChild(1));
ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_ONE, progress.newChild(1));
}
};
ResourcesPlugin.getWorkspace().run(wsr, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
break;
}
}
}
use of org.eclipse.ui.IWorkingSet in project titan.EclipsePlug-ins by eclipse.
the class SearchPattern method create.
public static SearchPattern create(final IDialogSettings settings) {
String loadedSearchString = settings.get("searchString");
boolean loadedIsCaseSensitive = settings.getBoolean("isCaseSensitive");
boolean loadedIsRegularExpression = settings.getBoolean("isRegularExpression");
SortedMap<String, Boolean> loadedEvents = new TreeMap<String, Boolean>();
for (String entry : Constants.EVENT_CATEGORIES.keySet()) {
loadedEvents.put(entry, settings.getBoolean(entry));
}
Map<Field, Boolean> loadedLimitTo = new HashMap<Field, Boolean>();
loadedLimitTo.put(Field.SOURCE_INFO, settings.getBoolean(Field.SOURCE_INFO.toString()));
loadedLimitTo.put(Field.MESSAGE, settings.getBoolean(Field.MESSAGE.toString()));
FilterPattern loadedFilterPattern = new FilterPattern(loadedSearchString, loadedLimitTo, loadedIsCaseSensitive, loadedIsRegularExpression);
loadedFilterPattern.setEventsToFilter(loadedEvents, true, false);
// $NON-NLS-1$
String[] wsIds = settings.getArray("workingSets");
IWorkingSet[] workingSets = null;
if (wsIds != null && wsIds.length > 0) {
IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
workingSets = new IWorkingSet[wsIds.length];
for (int i = 0; workingSets != null && i < wsIds.length; i++) {
workingSets[i] = workingSetManager.getWorkingSet(wsIds[i]);
if (workingSets[i] == null) {
workingSets = null;
}
}
}
return new SearchPattern(loadedFilterPattern, settings.getInt("scope"), workingSets);
}
use of org.eclipse.ui.IWorkingSet in project titan.EclipsePlug-ins by eclipse.
the class LogSearchPage method collectFilesForSearch.
private List<IFile> collectFilesForSearch() {
List<IFile> files = new ArrayList<IFile>();
switch(getContainer().getSelectedScope()) {
case ISearchPageContainer.WORKSPACE_SCOPE:
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (IProject project : projects) {
getLogFilesFromResource(project, files);
}
break;
case ISearchPageContainer.SELECTION_SCOPE:
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
ISelection selection = activePage.getSelection();
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
for (Iterator<?> it = structuredSelection.iterator(); it.hasNext(); ) {
Object o = it.next();
if (o instanceof IResource) {
getLogFilesFromResource((IResource) o, files);
}
}
}
break;
case ISearchPageContainer.SELECTED_PROJECTS_SCOPE:
String[] projectNames = getContainer().getSelectedProjectNames();
for (String name : projectNames) {
IProject currentProject = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
getLogFilesFromResource(currentProject, files);
}
break;
case ISearchPageContainer.WORKING_SET_SCOPE:
IWorkingSet[] workingSets = getContainer().getSelectedWorkingSets();
if (workingSets == null || workingSets.length < 1) {
break;
}
for (IWorkingSet workingSet : workingSets) {
for (IAdaptable element : workingSet.getElements()) {
getLogFilesFromResource((IResource) element, files);
}
}
break;
default:
break;
}
return files;
}
use of org.eclipse.ui.IWorkingSet in project bndtools by bndtools.
the class WorkspaceReleaseAction method selectionChanged.
/**
* @see IActionDelegate#selectionChanged(IAction, ISelection)
*/
@Override
public void selectionChanged(IAction action, ISelection selection) {
projects = Collections.emptySet();
if (selection != null && (selection instanceof StructuredSelection)) {
StructuredSelection ss = (StructuredSelection) selection;
projects = new HashSet<IProject>();
for (Iterator<?> itr = ss.iterator(); itr.hasNext(); ) {
Object selected = itr.next();
if (selected instanceof IProject) {
projects.add((IProject) selected);
} else if (selected instanceof IWorkingSet) {
IWorkingSet workingSet = (IWorkingSet) selected;
for (IAdaptable adaptable : workingSet.getElements()) {
IProject project = (IProject) adaptable.getAdapter(IProject.class);
if (project != null && !projects.contains(project)) {
projects.add(project);
}
}
} else if (selected instanceof IFile) {
IFile bndFile = (IFile) selected;
if (bndFile.getName().endsWith(Constants.DEFAULT_BND_EXTENSION)) {
if (!projects.contains(bndFile.getProject()))
projects.add(bndFile.getProject());
}
}
}
}
}
Aggregations