Java Code Examples for org.eclipse.ui.IWorkbenchPage

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project Archimedes, under directory /br.org.archimedes.core/src/br/org/archimedes/gui/handlers/.

Source file: CloseHandler.java

  22 
vote

public Object execute(ExecutionEvent event) throws ExecutionException {
  String all=event.getParameter(CLOSE_ALL_PARAMETER_ID);
  IWorkbenchPage activePage=HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
  if (all != null && Boolean.parseBoolean(all)) {
    activePage.closeAllEditors(true);
  }
 else {
    IEditorPart editor=HandlerUtil.getActiveEditor(event);
    activePage.closeEditor(editor,true);
  }
  return null;
}
 

Example 2

From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.datatools.enablement.simpledb.ui/src/com/amazonaws/eclipse/datatools/enablement/simpledb/ui/editor/.

Source file: OpenQueryEditorAction.java

  22 
vote

@Override public void run(){
  try {
    IWorkbenchPage workbenchPage=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    workbenchPage.openEditor(new DomainEditorInput(this.domainName,AwsToolkitCore.getDefault().getCurrentAccountId()),QueryEditor.ID);
  }
 catch (  PartInitException e) {
    AwsToolkitCore.getDefault().logException(e.getMessage(),e);
  }
}
 

Example 3

From project bioclipse.vscreen, under directory /net.bioclipse.vscreen.ui/src/net/bioclipse/vscreen/ui/wizards/.

Source file: NewVscreenWizard.java

  22 
vote

public boolean performFinish(){
  IEditorInput input=createEditorInput();
  IWorkbenchPage page=activeWindow.getActivePage();
  try {
    page.openEditor(input,"net.bioclipse.jseditor.editor");
  }
 catch (  PartInitException e) {
    e.printStackTrace();
  }
  return true;
}
 

Example 4

From project bndtools, under directory /bndtools.core/src/bndtools/editor/workspace/.

Source file: WorkspaceMainPart.java

  22 
vote

@Override public void linkActivated(HyperlinkEvent e){
  IFile file=ResourcesPlugin.getWorkspace().getRoot().getFile(path);
  FileEditorInput input=new FileEditorInput(file);
  try {
    IWorkbenchPage page=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    page.openEditor(input,"bndtools.bndWorkspaceConfigEditor",true);
  }
 catch (  PartInitException ex) {
    ErrorDialog.openError(getSection().getShell(),"Error","Unable to open editor",ex.getStatus());
  }
}
 

Example 5

From project bundlemaker, under directory /main/org.bundlemaker.core.ui/src/org/bundlemaker/core/ui/utils/.

Source file: BundleMakerFileLinkHelper.java

  22 
vote

@Override public IStructuredSelection findSelection(IEditorInput input){
  if (input instanceof BundleMakerClassFileEditorInput) {
    BundleMakerClassFileEditorInput bmClassFileEditorInput=(BundleMakerClassFileEditorInput)input;
    IWorkbenchPage page=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    if (page != null) {
      IViewPart view=page.findView(IPageLayout.ID_PROJECT_EXPLORER);
      if (view != null && view instanceof CommonNavigator) {
        CommonNavigator cn=(CommonNavigator)view;
        return new StructuredSelection(bmClassFileEditorInput.getResourceArtifact());
      }
    }
  }
  return StructuredSelection.EMPTY;
}
 

Example 6

From project ccw, under directory /ccw.leiningen/src/java/ccw/leiningen/.

Source file: NewLeiningenProjectWizard.java

  22 
vote

private static void replaceCurrentPerspective(IPerspectiveDescriptor persp){
  IWorkbenchWindow window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  if (window == null) {
    return;
  }
  IWorkbenchPage page=window.getActivePage();
  if (page == null) {
    return;
  }
  page.setPerspective(persp);
}
 

Example 7

From project ceylon-ide-eclipse, under directory /plugins/com.redhat.ceylon.eclipse.ui/src/com/redhat/ceylon/eclipse/code/editor/.

Source file: EditorUtility.java

  22 
vote

/** 
 * Tests if a given input element is currently shown in an editor
 * @return the IEditorPart if shown, null if element is not open in an editor
 */
private static IEditorPart isOpenInEditor(Object inputElement){
  IEditorInput input=null;
  input=getEditorInput(inputElement);
  if (input != null) {
    IWorkbenchPage p=getWorkbench().getActiveWorkbenchWindow().getActivePage();
    if (p != null) {
      return p.findEditor(input);
    }
  }
  return null;
}
 

Example 8

From project cilia-workbench, under directory /cilia-workbench-designer/src/fr/liglab/adele/cilia/workbench/designer/view/repositoryview/common/.

Source file: RepositoryView.java

  22 
vote

/** 
 * Opens an editor for editing a file, which name is given into parameter. Registers a listener to update the repo model as soon as the editor saves.
 * @param file the file path
 */
protected void openFileEditor(File file){
  IFileStore fileStore;
  try {
    fileStore=EFS.getLocalFileSystem().getStore(new Path(file.getAbsolutePath()));
    IWorkbenchPage page=getViewSite().getPage();
    IEditorPart editor=IDE.openEditorOnFileStore(page,fileStore);
    addEditorSavedListener(editor);
  }
 catch (  PartInitException e) {
    e.printStackTrace();
  }
}
 

Example 9

From project dawn-common, under directory /org.dawb.common.ui/src/org/dawb/common/ui/util/.

Source file: EclipseUtils.java

  22 
vote

/** 
 * Checks of the id passed in == the current perspectives.
 * @param id
 * @return true if is
 */
public static boolean isActivePerspective(final String id){
  final IWorkbenchPage page=getActivePage();
  if (page == null)   return false;
  try {
    return id.equals(page.getPerspective().getId());
  }
 catch (  Exception ignored) {
    return false;
  }
}
 

Example 10

From project dawn-isenciaui, under directory /com.isencia.passerelle.workbench.model.ui/src/main/java/com/isencia/passerelle/workbench/model/ui/utils/.

Source file: EclipseUtils.java

  22 
vote

/** 
 * Checks of the id passed in == the current perspectives.
 * @param id
 * @return true if is
 */
public static boolean isActivePerspective(final String id){
  final IWorkbenchPage page=getActivePage();
  if (page == null)   return false;
  try {
    return id.equals(page.getPerspective().getId());
  }
 catch (  Exception ignored) {
    return false;
  }
}
 

Example 11

From project dawn-tango, under directory /org.dawb.tango.extensions/src/org/dawb/tango/extensions/editors/actions/.

Source file: OpenSpecMonitorHandler.java

  22 
vote

@Override public Object execute(ExecutionEvent event) throws ExecutionException {
  try {
    final File tmp=File.createTempFile("sharedMemoryMonitor","mon");
    tmp.createNewFile();
    final IWorkbenchPage page=EclipseUtils.getActivePage();
    final IFileStore externalFile=EFS.getLocalFileSystem().fromLocalFile(tmp);
    final IEditorInput store=new FileStoreEditorInput(externalFile);
    page.openEditor(store,"org.dawb.tango.extensions.sharedMemEditor",true);
  }
 catch (  Exception ne) {
    throw new ExecutionException("Cannot open shared memory monitor!",ne);
  }
  return Boolean.TRUE;
}
 

Example 12

From project dawn-ui, under directory /org.dawb.workbench.plotting/src/org/dawb/workbench/plotting/printing/.

Source file: PlotExportPrintUtil.java

  22 
vote

private static void copytoClipboard(Image image){
  IWorkbenchPage page=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
  IWorkbenchPart active=page.getActivePart();
  ImageLoader loader=new ImageLoader();
  loader.data=new ImageData[]{image.getImageData()};
  loader.save(tempDirectory + "/" + active.getTitle()+ ".png",SWT.IMAGE_PNG);
  File imageFile=new File(tempDirectory + "/" + active.getTitle()+ ".png");
  Display display=Display.getCurrent();
  Clipboard clipboard=new Clipboard(display);
  String[] data={imageFile.getAbsolutePath()};
  clipboard.setContents(new Object[]{data},new Transfer[]{FileTransfer.getInstance()});
  clipboard.dispose();
  logger.debug("Plot copied to clip-board");
}
 

Example 13

From project dawn-workflow, under directory /org.dawb.passerelle.actors/src/org/dawb/passerelle/editors/.

Source file: EdnaActorActions.java

  22 
vote

private static final XPathEditor getEdnaOutputEditor(){
  final IWorkbenchPage page=EclipseUtils.getActivePage();
  if (page == null)   return null;
  final IEditorPart part=page.getActiveEditor();
  if (part == null || !(part instanceof EdnaActorMultiPageEditor))   return null;
  final EdnaActorMultiPageEditor ed=(EdnaActorMultiPageEditor)part;
  return ed.getEdnaActorOutputEditor();
}
 

Example 14

From project Diver, under directory /ca.uvic.chisel.javasketch/src/ca/uvic/chisel/javasketch/ui/internal/views/.

Source file: ToggleSketchFilteredHandler.java

  22 
vote

private TraceNavigator getNagivator(){
  IWorkbenchPage page;
  try {
    page=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
  }
 catch (  NullPointerException e) {
    return null;
  }
  if (page != null) {
    return (TraceNavigator)page.findView(TraceNavigator.VIEW_ID);
  }
  return null;
}
 

Example 15

From project droolsjbpm-tools, under directory /drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/action/.

Source file: ActionCompletionProcessor.java

  22 
vote

public IEditorPart getEditor(){
  IWorkbench workbench=PlatformUI.getWorkbench();
  if (workbench != null) {
    IWorkbenchWindow workbenchWindow=workbench.getActiveWorkbenchWindow();
    if (workbenchWindow != null) {
      IWorkbenchPage workbenchPage=workbenchWindow.getActivePage();
      if (workbenchPage != null) {
        return workbenchPage.getActiveEditor();
      }
    }
  }
  return null;
}
 

Example 16

From project Eclipse, under directory /com.mobilesorcery.sdk.update/src/com/mobilesorcery/sdk/update/internal/.

Source file: RegistrationWebBrowserView.java

  22 
vote

/** 
 * Opens the registration view with a set initial URL; if a view is already open, this method will have no effect.
 * @param whereToGo 
 * @param reopenIntro2 
 */
public static RegistrationWebBrowserView open(URL whereToGo,boolean reopenIntroHint) throws PartInitException {
  IWorkbenchPage page=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
  IViewPart view=page.showView(VIEW_ID);
  if (!(view instanceof RegistrationWebBrowserView)) {
    throw new PartInitException("Excepted view to be mosync registration view");
  }
  RegistrationWebBrowserView registrationView=(RegistrationWebBrowserView)view;
  registrationView.registerListener(reopenIntroHint);
  if (registrationView.initialURL == null && !registrationView.active) {
    setInitialURL(view,whereToGo);
  }
  return registrationView;
}
 

Example 17

From project eclipse-instasearch, under directory /instasearch/src/it/unibz/instasearch/ui/.

Source file: InstaSearchUI.java

  22 
vote

/** 
 * Gets active editor Must be run from UI thread
 * @return IEditorPart
 */
public static IEditorPart getActiveEditor(){
  if (getWorkbenchWindow() == null)   return null;
  IWorkbenchPage activePage=getWorkbenchWindow().getActivePage();
  if (activePage != null) {
    IEditorPart activeEditor=activePage.getActiveEditor();
    return activeEditor;
  }
  return null;
}
 

Example 18

From project eclipse-integration-cloudfoundry, under directory /org.cloudfoundry.ide.eclipse.server.tests/src/org/cloudfoundry/ide/eclipse/server/tests/sts/util/.

Source file: StsTestUtil.java

  22 
vote

public static void cleanUpProjects() throws CoreException {
  IWorkbenchWindow window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  if (window != null) {
    IWorkbenchPage page=window.getActivePage();
    if (page != null) {
      page.closeAllEditors(false);
    }
  }
  deleteAllProjects();
}
 

Example 19

From project eclipse-integration-commons, under directory /org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/.

Source file: StsTestUtil.java

  22 
vote

public static void cleanUpProjects() throws CoreException {
  IWorkbenchWindow window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  if (window != null) {
    IWorkbenchPage page=window.getActivePage();
    if (page != null) {
      page.closeAllEditors(false);
    }
  }
  deleteAllProjects();
}
 

Example 20

From project eclipse-task-editor, under directory /plugins/de.sebastianbenz.task.application/src/de/sebastianbenz/task/app/actions/.

Source file: EditorOpener.java

  22 
vote

public void open(){
  File file=new File(filePath);
  if (file.exists() && (file.getName().endsWith(".todo") || file.getName().endsWith(".taskpaper"))) {
    IWorkbenchPage page=window.getActivePage();
    try {
      IFileStore fileStore=EFS.getStore(file.toURI());
      IDE.openEditor(page,new FileStoreEditorInput(fileStore),"de.sebastianbenz.task.Task");
    }
 catch (    CoreException e) {
      e.printStackTrace();
    }
  }
}
 

Example 21

From project eclipsefp, under directory /net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/actions/.

Source file: OpenHaskellPerspective.java

  22 
vote

@Override public void run(){
  IWorkbenchWindow window=getWorkbench().getActiveWorkbenchWindow();
  IWorkbenchPage page=window.getActivePage();
  IAdaptable input=(page != null) ? page.getInput() : ResourcesPlugin.getWorkspace().getRoot();
  try {
    String perspectiveId=HaskellUIPlugin.ID_PERSPECTIVE;
    getWorkbench().showPerspective(perspectiveId,window,input);
  }
 catch (  WorkbenchException wbex) {
    handleError(wbex,"Could not open perspective.\nSee error log for details.");
  }
}
 

Example 22

From project egit-github, under directory /org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/.

Source file: GistAttachmentPart.java

  22 
vote

protected void openAttachments(OpenEvent event){
  List<ITaskAttachment> attachments=new ArrayList<ITaskAttachment>();
  StructuredSelection selection=(StructuredSelection)event.getSelection();
  List<?> items=selection.toList();
  for (  Object item : items)   if (item instanceof ITaskAttachment)   attachments.add((ITaskAttachment)item);
  if (attachments.isEmpty())   return;
  IWorkbenchPage page=getTaskEditorPage().getSite().getWorkbenchWindow().getActivePage();
  try {
    OpenTaskAttachmentHandler.openAttachments(page,attachments);
  }
 catch (  OperationCanceledException e) {
  }
}
 

Example 23

From project gda-common-rcp, under directory /uk.ac.gda.common.rcp/src/uk/ac/gda/common/rcp/util/.

Source file: EclipseUtils.java

  22 
vote

/** 
 * Checks of the id passed in == the current perspectives.
 * @param id
 * @return true if is
 */
public static boolean isActivePerspective(final String id){
  final IWorkbenchPage page=getActivePage();
  if (page == null)   return false;
  try {
    return id.equals(page.getPerspective().getId());
  }
 catch (  Exception ignored) {
    return false;
  }
}
 

Example 24

From project gmc, under directory /src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/toolbar/.

Source file: GlusterToolbarManager.java

  22 
vote

@Override public void updateToolbar(Entity entity){
  ENTITY_TYPE entityType=getEntityType(entity);
  IWorkbenchPage page=window.getActivePage();
  for (  ENTITY_TYPE targetEntityType : actionSetMap.keySet()) {
    String actionSetId=actionSetMap.get(targetEntityType);
    if (entityType == targetEntityType) {
      page.showActionSet(actionSetId);
    }
 else {
      page.hideActionSet(actionSetId);
    }
  }
}
 

Example 25

From project grails-ide, under directory /org.grails.ide.eclipse.editor.groovy/src/org/grails/ide/eclipse/editor/actions/.

Source file: WorkspaceFileHyperlink.java

  22 
vote

public void open(){
  if (fFile != null && fFile.exists()) {
    try {
      IWorkbenchPage page=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
      IEditorPart editor=IDE.openEditor(page,fFile,true);
      if (fHighlightRange != null && editor instanceof ITextEditor) {
        ((ITextEditor)editor).setHighlightRange(fHighlightRange.getOffset(),fHighlightRange.getLength(),true);
      }
    }
 catch (    PartInitException pie) {
      GrailsCoreActivator.log(pie);
    }
  }
}
 

Example 26

From project hackergarten-moreunit, under directory /org.moreunit.core/src/org/moreunit/core/commands/.

Source file: JumpActionHandler.java

  22 
vote

private void openEditor(IFile file,ExecutionEvent event){
  IWorkbenchPage activePage=getActivePage(event);
  if (activePage == null) {
    return;
  }
  try {
    IDE.openEditor(activePage,file,true);
  }
 catch (  PartInitException e) {
    e.printStackTrace();
  }
}
 

Example 27

From project ivyde, under directory /org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/.

Source file: ViewReverseDependenciesHandler.java

  22 
vote

protected void handleProjects(Map projects){
  try {
    ReverseDependencyExplorerView.setSelectedProjects((IProject[])projects.keySet().toArray(new IProject[0]));
    IWorkbenchPage page=IvyPlugin.getActivePage();
    page.showView("org.apache.ivyde.eclipse.ui.views.ReverseDependencyExplorer");
    ReverseDependencyExplorerView.refresh(true);
  }
 catch (  PartInitException e) {
    IvyPlugin.log(IStatus.ERROR,"Error creating Reverse Dependency Explorer",e);
  }
}
 

Example 28

From project js4emf, under directory /org.eclipse.emf.js4emf.ui/src/org/eclipse/emf/js4emf/ui/.

Source file: AbstractSelectionView.java

  22 
vote

protected <T>T getAdapter(IWorkbenchPart part,Class<T> c){
  IWorkbenchPage workbenchPage=getViewSite().getWorkbenchWindow().getActivePage();
  if (workbenchPage == null) {
    return null;
  }
  IEditorPart editorPart=workbenchPage.getActiveEditor();
  return (editorPart != null ? (T)editorPart.getAdapter(c) : null);
}
 

Example 29

From project bel-editor, under directory /org.openbel.editor.ui/src/org/openbel/editor/ui/.

Source file: ResourceLoader.java

  21 
vote

/** 
 * Reloads the available resources in the Resources, Namespaces, and Annotations view. {@inheritDoc}
 */
@Override public void run(){
  try {
    final IWorkbenchPage page=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    final IViewPart rpart=page.showView(ResourceView.ID);
    if ((rpart != null) && (rpart instanceof ResourceView)) {
      final ResourceView rview=(ResourceView)rpart;
      rview.loadContent();
    }
    final IViewPart npart=page.findView(NamespaceView.ID);
    if ((npart != null) && (npart instanceof NamespaceView)) {
      final NamespaceView nview=(NamespaceView)npart;
      nview.loadContent();
    }
    final IViewPart apart=page.findView(AnnotationView.ID);
    if ((apart != null) && (apart instanceof AnnotationView)) {
      final AnnotationView aview=(AnnotationView)apart;
      aview.loadContent();
    }
  }
 catch (  PartInitException e) {
    logError(e);
  }
}
 

Example 30

From project BHT-FPA, under directory /mailer-common/de.bht.fpa.mail.common/src/de/bht/fpa/mail/s000000/common/rcp/statusbar/.

Source file: StatusBarHelper.java

  21 
vote

/** 
 * This method returns the  {@link IStatusLineManager}. It may return <code>null</code>.
 * @return {@link IStatusLineManager} or <code>null</code>
 */
public static synchronized IStatusLineManager getStatusLineManager(){
  if (manager != null) {
    return manager;
  }
  manager=new NullStatusLineManager();
  IWorkbench wb=PlatformUI.getWorkbench();
  if (wb == null) {
    return manager;
  }
  IWorkbenchWindow win=wb.getActiveWorkbenchWindow();
  if (win == null) {
    return manager;
  }
  IWorkbenchPage page=win.getActivePage();
  if (page == null) {
    return manager;
  }
  IWorkbenchPart part=page.getActivePart();
  if (part == null) {
    return manager;
  }
  IWorkbenchPartSite site=part.getSite();
  if (site == null || !(site instanceof IViewSite)) {
    return manager;
  }
  IViewSite vSite=(IViewSite)site;
  IActionBars actionBars=vSite.getActionBars();
  if (actionBars == null) {
    return manager;
  }
  manager=actionBars.getStatusLineManager();
  return manager;
}
 

Example 31

From project bioclipse.speclipse, under directory /plugins/net.bioclipse.spectrum/src/net/bioclipse/spectrum/action/.

Source file: CheatSheetAction.java

  21 
vote

public void run(String[] params,ICheatSheetManager manager){
  if (params[0].equals("opencompare")) {
    IWorkbenchWindow dw=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IWorkbenchPage page=dw.getActivePage();
    try {
      page.showView("net.bioclipse.spectrum.views.SpectrumCompareView");
    }
 catch (    PartInitException e) {
      LogUtils.handleException(e,logger);
    }
  }
 else   if (params[0].equals("newspectrum")) {
    NewSpectrumWizard predwiz=new NewSpectrumWizard();
    WizardDialog wd=new WizardDialog(new Shell(),predwiz);
    wd.open();
  }
 else   if (params[0].equals("saveas")) {
    if (WorkbenchPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() instanceof SpectrumEditor) {
      ((SpectrumEditor)WorkbenchPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()).doSaveAs();
    }
  }
}
 

Example 32

From project bpelunit, under directory /tycho/net.bpelunit.framework.client.eclipse/src/net/bpelunit/framework/client/eclipse/launch/.

Source file: BPELLaunchConfigurationDelegate.java

  21 
vote

private void openConsole(final MessageConsole bpelConsole) throws PartInitException {
  Display.getDefault().syncExec(new Runnable(){
    public void run(){
      IWorkbenchPage page=BPELUnitActivator.getActiveWorkbenchWindow().getActivePage();
      String id=IConsoleConstants.ID_CONSOLE_VIEW;
      IConsoleView view;
      try {
        view=(IConsoleView)page.showView(id);
        view.display(bpelConsole);
      }
 catch (      PartInitException e) {
      }
    }
  }
);
}
 

Example 33

From project BPMN2-Editor-for-Eclipse, under directory /org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/.

Source file: BPMN2Editor.java

  21 
vote

public void showErrorMessage(String msg){
  IWorkbench wb=PlatformUI.getWorkbench();
  IWorkbenchWindow win=wb.getActiveWorkbenchWindow();
  IWorkbenchPage page=win.getActivePage();
  IWorkbenchPart part=page.getActivePart();
  IWorkbenchPartSite site=part.getSite();
  IViewSite vSite=(IViewSite)site;
  IActionBars actionBars=vSite.getActionBars();
  if (actionBars == null)   return;
  IStatusLineManager statusLineManager=actionBars.getStatusLineManager();
  if (statusLineManager == null)   return;
  statusLineManager.setErrorMessage(msg);
  statusLineManager.markDirty();
  statusLineManager.update(true);
}
 

Example 34

From project CBCJVM, under directory /eclipse/CBC/src/cbc/helpers/.

Source file: Helper.java

  21 
vote

public IEditorPart getActiveEditor(){
  IWorkbench iworkbench=PlatformUI.getWorkbench();
  if (iworkbench == null) {
    error("Unable to fetch workbench.");
    return null;
  }
  IWorkbenchWindow iworkbenchwindow=iworkbench.getActiveWorkbenchWindow();
  if (iworkbenchwindow == null) {
    error("Unable to fetch workbench window.");
    return null;
  }
  IWorkbenchPage iworkbenchpage=iworkbenchwindow.getActivePage();
  if (iworkbenchpage == null) {
    error("Unable to fetch workbench page.");
    return null;
  }
  IEditorPart ieditorpart=iworkbenchpage.getActiveEditor();
  if (ieditorpart == null) {
    error("Unable to fetch active editor. You probably have no editors open.");
    return null;
  }
  return ieditorpart;
}
 

Example 35

From project dawn-third, under directory /org.dawb.org.csstudio.swt.xygraph/src/org/csstudio/swt/xygraph/toolbar/.

Source file: TraceConfigPage.java

  21 
vote

protected void exportToCSV(IFile exportTo,IDataProvider dataProvider) throws Exception {
  final IFile csv=getUniqueFile(exportTo,null,"csv");
  final StringBuilder contents=new StringBuilder();
  final IDataProvider prov=trace.getDataProvider();
  final NumberFormat format=new DecimalFormat("##0.#####E0");
  for (int i=0; i < prov.getSize(); i++) {
    final ISample isample=prov.getSample(i);
    contents.append(format.format(isample.getXValue()));
    contents.append(",\t");
    contents.append(format.format(isample.getYValue()));
    contents.append("\n");
  }
  InputStream stream=new ByteArrayInputStream(contents.toString().getBytes());
  csv.create(stream,true,new NullProgressMonitor());
  csv.getParent().refreshLocal(IResource.DEPTH_INFINITE,new NullProgressMonitor());
  final IWorkbenchPage page=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
  IEditorDescriptor desc=PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(csv.getName());
  if (desc == null)   desc=PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(csv.getName() + ".txt");
  page.openEditor(new FileEditorInput(csv),desc.getId());
}
 

Example 36

From project dolphin, under directory /org.adarsh.jutils/src/org/adarsh/jutils/actions/.

Source file: CopyConstructorGeneratorOAD.java

  21 
vote

/** 
 * {@inheritDoc}
 */
public void run(IAction action){
  IWorkbenchPage page=this.packageExplorerPart.getSite().getPage();
  StructuredSelection selection=(StructuredSelection)page.getSelection();
  Object[] compUnits=selection.toArray();
  Shell shell=this.packageExplorerPart.getSite().getShell();
  int failed=0;
  for (int i=0; i < compUnits.length; i++) {
    ICompilationUnit compUnit=(ICompilationUnit)compUnits[i];
    IType type=compUnit.findPrimaryType();
    try {
      if (type != null && type.isClass()) {
        SourceManipulator.createCopyConstructorWithJavaDoc(type);
      }
 else {
        failed++;
      }
    }
 catch (    JavaModelException e) {
      MessageDialog.openError(shell,Messages.getString("exception.title"),Messages.getString("exception.message"));
      Logger.error("Error generating Copy Constructor " + "through OAD",e);
      break;
    }
  }
  if (failed == compUnits.length) {
    MessageDialog.openInformation(shell,Messages.getString("copycon.failure.title"),Messages.getString("copycon.failure.message"));
  }
}
 

Example 37

From project eclipse-integration-gradle, under directory /org.springsource.ide.eclipse.gradle.ui/src/org/springsource/ide/eclipse/gradle/ui/launch/.

Source file: GradleLaunchTasksTab.java

  21 
vote

private GradleProject getContext(){
  IWorkbench wb=PlatformUI.getWorkbench();
  IWorkbenchWindow win=wb.getActiveWorkbenchWindow();
  IWorkbenchPage page=win == null ? null : win.getActivePage();
  if (page != null) {
    ISelection selection=page.getSelection();
    if (selection instanceof IStructuredSelection) {
      IStructuredSelection ss=(IStructuredSelection)selection;
      if (!ss.isEmpty()) {
        Object obj=ss.getFirstElement();
        if (obj instanceof IResource) {
          IResource rsrc=(IResource)obj;
          IProject prj=rsrc.getProject();
          if (prj != null) {
            return GradleCore.create(prj);
          }
        }
      }
    }
    IEditorPart part=page.getActiveEditor();
    if (part != null) {
      IEditorInput input=part.getEditorInput();
      IResource rsrc=(IResource)input.getAdapter(IResource.class);
      if (rsrc != null) {
        IProject prj=rsrc.getProject();
        if (prj != null) {
          return GradleCore.create(prj);
        }
      }
    }
  }
  return null;
}
 

Example 38

From project eclipse.platform.runtime, under directory /bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/.

Source file: DumpContentsView.java

  21 
vote

/** 
 * Rebuilds the view with the dump object provided.
 * @param dump a dump object to be shown on this view 
 */
private void load(IDump dump){
  this.currentFile=dump.getFile();
  if (initialTitle == null)   this.initialTitle=this.getTitle();
  this.setContentDescription(initialTitle + " : " + this.currentFile.getName());
  this.setTitleToolTip("Dump contents for " + this.currentFile.getAbsolutePath());
  viewer.getDocument().set(dump.getContents().toString());
  IWorkbenchPage page=this.getSite().getPage();
  String summaryId=DumpSummaryView.VIEW_ID;
  DumpSummaryView summaryView=(DumpSummaryView)page.findView(summaryId);
  if (summaryView == null && dump.isFailed())   try {
    summaryView=(DumpSummaryView)page.showView(summaryId);
  }
 catch (  PartInitException pie) {
    ErrorUtil.logException(pie,"Error opening view");
  }
  if (summaryView != null)   summaryView.load(dump);
}
 

Example 39

From project edna-rcp, under directory /org.edna.kernel/src/org/edna/kernel/.

Source file: Launcher.java

  21 
vote

/** 
 * Gets the print stream for the Console if possible
 * @return a valid printStream
 */
private PrintStream getPrintStream(){
  PrintStream ps;
  try {
    MessageConsole myConsole=findConsole(CONSOLE_NAME);
    MessageConsoleStream out=myConsole.newMessageStream();
    ps=new PrintStream(out);
    IWorkbench workBench=Activator.getDefault().getWorkbench();
    if (workBench != null) {
      IWorkbenchWindow activeWindow=workBench.getActiveWorkbenchWindow();
      if (activeWindow != null) {
        IWorkbenchPage page=activeWindow.getActivePage();
        String id=IConsoleConstants.ID_CONSOLE_VIEW;
        IConsoleView view=(IConsoleView)page.showView(id);
        view.display(myConsole);
      }
    }
  }
 catch (  Exception e) {
    ps=new PrintStream(System.out);
  }
  return ps;
}
 

Example 40

From project eik, under directory /plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/internal/.

Source file: WorkbenchActionProvider.java

  21 
vote

@Override public void init(final ICommonActionExtensionSite aSite){
  super.init(aSite);
  aSite.getStructuredViewer().addDoubleClickListener(new IDoubleClickListener(){
    @Override public void doubleClick(    final DoubleClickEvent event){
      if (!(event.getSelection() instanceof IStructuredSelection)) {
        return;
      }
      final IStructuredSelection structuredSelection=(IStructuredSelection)event.getSelection();
      if (structuredSelection.size() > 1) {
        return;
      }
      final Object element=structuredSelection.getFirstElement();
      if (!(element instanceof IProject)) {
        return;
      }
      final IProject project=(IProject)element;
      final IKarafProject karafProject=(IKarafProject)project.getAdapter(IKarafProject.class);
      final IEditorInput editorInput=new KarafPlatformEditorInput(karafProject);
      try {
        final IWorkbenchPage page=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        page.openEditor(editorInput,KarafPlatformEditorPart.ID);
      }
 catch (      final PartInitException e) {
        KarafWorkbenchActivator.getLogger().error("Unable to open editor for " + karafProject.getName(),e);
      }
    }
  }
);
}
 

Example 41

From project EMF-IncQuery, under directory /plugins/org.eclipse.viatra2.emf.incquery.tooling.gui/src/org/eclipse/viatra2/emf/incquery/gui/wizards/.

Source file: NewGenmodelWizard.java

  21 
vote

@Override public boolean performFinish(){
  IProject project=projectPage.getSelectedProject();
  WorkspaceModifyOperation op=null;
  List<String> genmodelDependencies=new ArrayList<String>();
  for (  GenModel model : genmodelPage.getSelectedGenmodels()) {
    String modelPluginID=model.getModelPluginID();
    if (!genmodelDependencies.contains(modelPluginID)) {
      genmodelDependencies.add(modelPluginID);
    }
  }
  WorkspaceModifyOperation projectOp=new EnsureProjectDependencies(project,genmodelDependencies);
  WorkspaceModifyOperation genmodelOp=new CreateGenmodelOperation(project,genmodelPage.getSelectedGenmodels(),genmodelProvider,resourceSetProvider);
  op=new CompositeWorkspaceModifyOperation(new WorkspaceModifyOperation[]{projectOp,genmodelOp},"Creating generator model");
  try {
    getContainer().run(true,true,op);
  }
 catch (  InterruptedException e) {
    return false;
  }
catch (  InvocationTargetException e) {
    Throwable realException=e.getTargetException();
    logger.error("Cannot initialize EMF-IncQuery generator model " + realException.getMessage(),realException);
    MessageDialog.openError(getShell(),"Error",realException.getMessage());
    return false;
  }
  IFile genmodelFile=(IFile)project.findMember(IncQueryNature.IQGENMODEL);
  BasicNewProjectResourceWizard.selectAndReveal(genmodelFile,workbench.getActiveWorkbenchWindow());
  IWorkbenchPage page=workbench.getActiveWorkbenchWindow().getActivePage();
  try {
    page.openEditor(new FileEditorInput(genmodelFile),workbench.getEditorRegistry().getDefaultEditor(genmodelFile.getName()).getId());
  }
 catch (  PartInitException e) {
    logger.error("Cannot open EMF-IncQuery generator model",e);
  }
  return true;
}
 

Example 42

From project JsTestDriver, under directory /eclipse-plugin/plugins/com.google.eclipse.javascript.jstestdriver.ui/src/com/google/eclipse/javascript/jstestdriver/ui/launch/.

Source file: JsTestDriverLaunchShortcut.java

  21 
vote

private void runTests(ILaunchConfiguration launchConfiguration,final List<String> testCases) throws CoreException {
  final ILaunchConfigurationWorkingCopy workingCopy=launchConfiguration.copy("new run").getWorkingCopy();
  workingCopy.setAttribute(TESTS_TO_RUN,testCases);
  final ILaunchConfiguration configuration=workingCopy.doSave();
  Display.getDefault().asyncExec(new Runnable(){
    public void run(){
      IWorkbenchPage page=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
      try {
        JsTestDriverView view=(JsTestDriverView)page.showView(JsTestDriverView.ID);
        TestResultsPanel panel=view.getTestResultsPanel();
        panel.setupForNextTestRun(configuration);
        actionRunnerFactory.getDryActionRunner(configuration,testCases).runActions();
        actionRunnerFactory.getSpecificTestsActionRunner(workingCopy,testCases).runActions();
      }
 catch (      PartInitException e) {
        logger.log(Level.SEVERE,"",e);
      }
catch (      FileNotFoundException e) {
        logger.log(Level.SEVERE,"",e);
      }
    }
  }
);
}
 

Example 43

From project Bio-PEPA, under directory /uk.ac.ed.inf.biopepa.ui/src/uk/ac/ed/inf/biopepa/ui/editors/.

Source file: BioPEPAEditor.java

  19 
vote

static void checkPerspective(IWorkbenchPage page){
  IPerspectiveDescriptor descriptor=page.getPerspective();
  if (descriptor == null)   return;
  String currentPerspective=descriptor.getId();
  if (!currentPerspective.equals(PerspectiveFactory.PERSPECTIVE_ID)) {
    boolean result=MessageDialog.openQuestion(page.getWorkbenchWindow().getShell(),"Switch to Bio-PEPA Perspective","This resource is associated with the Bio-PEPA perspective. Would you like to switch to the Bio-PEPA Perspective now?");
    if (result == true) {
      IWorkbench workbench=BioPEPAPlugin.getDefault().getWorkbench();
      page.setPerspective(workbench.getPerspectiveRegistry().findPerspectiveWithId(PerspectiveFactory.PERSPECTIVE_ID));
    }
  }
}
 

Example 44

From project eclim, under directory /org.eclim/java/org/eclim/eclipse/ui/internal/.

Source file: EclimWorkbenchWindow.java

  19 
vote

/** 
 * {@inheritDoc}
 * @see org.eclipse.ui.IWorkbenchWindow#getActivePage()
 */
public IWorkbenchPage getActivePage(){
  try {
    if (page == null) {
      page=new EclimWorkbenchPage(this,ResourcesPlugin.getWorkspace().getRoot());
    }
    return page;
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}
 

Example 45

From project gted, under directory /net.sf.gted.editor/src/net/sf/gted/editor/.

Source file: POFormEditor.java

  19 
vote

public void resourceChanged(final IResourceChangeEvent event){
  if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
  }
 else   if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
    Display.getDefault().asyncExec(new Runnable(){
      public void run(){
        final IWorkbenchPage[] pages=POFormEditor.this.getSite().getWorkbenchWindow().getPages();
        for (        final IWorkbenchPage element : pages) {
          if (((FileEditorInput)POFormEditor.this.poEditor.getEditorInput()).getFile().getProject().equals(event.getResource())) {
            final IEditorPart editorPart=element.findEditor(POFormEditor.this.poEditor.getEditorInput());
            element.closeEditor(editorPart,true);
          }
        }
      }
    }
);
  }
}
 

Example 46

From project iee, under directory /org.eclipse.iee.editor.monitoring/src/org/eclipse/iee/editor/monitoring/perspectives/.

Source file: EarlyStartup.java

  19 
vote

public void earlyStartup(){
  Display.getDefault().asyncExec(new Runnable(){
    public void run(){
      final IWorkbenchWindow workbenchWindow=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
      if (workbenchWindow != null) {
        workbenchWindow.addPerspectiveListener(new PerspectiveAdapter(){
          @Override public void perspectiveActivated(          IWorkbenchPage page,          IPerspectiveDescriptor perspectiveDescriptor){
            super.perspectiveActivated(page,perspectiveDescriptor);
            System.err.println("--> " + perspectiveDescriptor.getId());
            if (perspectiveDescriptor.getId().indexOf("org.eclipse.iee.editor.monitoring.perspectives.PadsMonitoringPerspective") > -1) {
              if (workbenchWindow.getActivePage() instanceof WorkbenchPage) {
                WorkbenchPage worbenchPage=(WorkbenchPage)workbenchWindow.getActivePage();
                Perspective perspective=worbenchPage.findPerspective(perspectiveDescriptor);
                ArrayList<IActionSetDescriptor> toRemove=new ArrayList<IActionSetDescriptor>();
                if (perspective != null) {
                  for (                  IActionSetDescriptor actionSetDescriptor : perspective.getAlwaysOnActionSets()) {
                    if (actionSetDescriptor.getId().indexOf("org.eclipse.search.searchActionSet") > -1) {
                      toRemove.add(actionSetDescriptor);
                    }
                  }
                  perspective.turnOffActionSets((IActionSetDescriptor[])toRemove.toArray(new IActionSetDescriptor[toRemove.size()]));
                }
              }
            }
          }
        }
);
      }
    }
  }
);
}