use of org.eclipse.ui.IWorkbench in project Palladio-Editors-Sirius by PalladioSimulator.
the class NewPalladioProjectWizard method openPalladioPerspective.
private void openPalladioPerspective() {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
try {
workbench.showPerspective(PERSPECTIVE_ID, window);
} catch (WorkbenchException e) {
MessageDialog.openError(getShell(), "Error", "Could not open Palladio Perspective");
e.printStackTrace();
}
}
use of org.eclipse.ui.IWorkbench in project linuxtools by eclipse.
the class SpecfileElementHyperlinkDetector method prepareHyperlink.
private IHyperlink[] prepareHyperlink(IRegion lineInfo, String line, String word, SpecfileElement source, int lineIndex) {
IRegion urlRegion = new Region(lineInfo.getOffset() + line.indexOf(word, lineIndex), word.length());
// will only work with 1 active page
// does not work with CompareEditor
IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
IWorkbenchPage page = win.getActivePage();
IEditorPart editor = page.getActiveEditor();
// we can only provide this functionality for resources inside the workbench.
if (editor.getEditorInput() instanceof FileEditorInput) {
IFile original = ((FileEditorInput) editor.getEditorInput()).getFile();
return new IHyperlink[] { new SpecfileElementHyperlink(urlRegion, source, original) };
} else {
return null;
}
}
use of org.eclipse.ui.IWorkbench in project linuxtools by eclipse.
the class CreaterepoCommandHandler method execute.
@Override
public Object execute(ExecutionEvent event) {
// $NON-NLS-1$
final String executionType = event.getParameter("executionType");
try {
IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchPage wbPage = wb.getActiveWorkbenchWindow().getActivePage();
IEditorInput editorInput = wbPage.getActiveEditor().getEditorInput();
IResource resource = ResourceUtil.getResource(editorInput);
final CreaterepoProject project = new CreaterepoProject(resource.getProject());
Job executeCreaterepo = new Job(Messages.Createrepo_jobName) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
monitor.beginTask(Messages.CreaterepoProject_executeCreaterepo, IProgressMonitor.UNKNOWN);
MessageConsoleStream os = CreaterepoUtils.findConsole(Messages.CreaterepoProject_consoleName).newMessageStream();
if (executionType.equals("refresh")) {
// $NON-NLS-1$
return project.update(os);
} else {
return project.createrepo(os);
}
} catch (CoreException e) {
Activator.logError(Messages.Createrepo_errorExecuting, e);
} finally {
monitor.done();
}
return null;
}
};
executeCreaterepo.setUser(true);
executeCreaterepo.schedule();
} catch (CoreException e) {
Activator.logError(Messages.CreaterepoProject_executeCreaterepo, e);
}
return null;
}
use of org.eclipse.ui.IWorkbench in project linuxtools by eclipse.
the class CreaterepoResourceChangeListener method closeEditors.
/**
* Close the editors thats resource has been affected by a change in the
* workspace. E.g. if an editor's project has been closed/deleted, close the
* editor.
*/
private void closeEditors() {
IWorkbench workbench = PlatformUI.getWorkbench();
IResource repomdFile = project.getRepoFile();
// deleted, or the file was deleted. If so, close the editor of the file.
if (!repomdFile.exists()) {
for (IWorkbenchPage page : workbench.getActiveWorkbenchWindow().getPages()) {
for (IEditorReference ref : page.getEditorReferences()) {
try {
// get the resource from the editor part and exit the editor if
// it is within the project(s) being closed/deleted
IResource resource = ResourceUtil.getResource(ref.getEditorInput());
if (ref.getId().equals(RepoFormEditor.EDITOR_ID) && resource.getProject().equals(project.getProject())) {
page.closeEditor(ref.getEditor(false), false);
}
} catch (PartInitException e) {
Activator.logError(Messages.CreaterepoResourceChangeListener_errorGettingResource, e);
}
}
}
}
}
use of org.eclipse.ui.IWorkbench in project linuxtools by eclipse.
the class ChangeLogAction method createChangeLog.
protected IFile createChangeLog(IPath changelog) {
IWorkspaceRoot myWorkspaceRoot = getWorkspaceRoot();
IWorkbench ws = PlatformUI.getWorkbench();
final IFile changelog_File = myWorkspaceRoot.getFile(changelog);
final InputStream initialContents = new ByteArrayInputStream(new byte[0]);
WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
@Override
public void execute(IProgressMonitor monitor) throws CoreException {
try {
// $NON-NLS-1$
monitor.beginTask(Messages.getString("ChangeLog.AddingChangeLog"), 2000);
changelog_File.create(initialContents, false, monitor);
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
} finally {
monitor.done();
}
}
};
try {
new ProgressMonitorDialog(ws.getActiveWorkbenchWindow().getShell()).run(true, true, operation);
} catch (InterruptedException e) {
// $NON-NLS-1$
reportErr(Messages.getString("ChangeLog.ErrInterrupted"), e);
return null;
} catch (InvocationTargetException e) {
// $NON-NLS-1$
reportErr(Messages.getString("ChangeLog.ErrInvocation"), e);
return null;
}
// FIXME: we should put this refreshLocal call into a thread (filed as bug #256180)
try {
IContainer changelogContainer = myWorkspaceRoot.getContainerForLocation(changelog);
if (changelogContainer != null)
changelogContainer.refreshLocal(2, null);
} catch (CoreException e) {
// $NON-NLS-1$
reportErr(Messages.getString("ChangeLog.ErrRefresh"), e);
return null;
}
return changelog_File;
}
Aggregations