Java Code Examples for org.eclipse.ui.IWorkbenchPart

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 aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.ec2/src/com/amazonaws/eclipse/ec2/ui/.

Source file: OpenAwsViewsAction.java

  22 
vote

/** 
 * Minimizes the welcome/intro view if it's open and maximized.
 */
private void minimizeWelcomeView(){
  IWorkbenchPage workbenchPage=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
  IWorkbenchPart activePart=workbenchPage.getActivePart();
  IIntroPart introPart=(IIntroPart)activePart.getAdapter(IIntroPart.class);
  if (introPart != null) {
    IWorkbenchPartReference reference=workbenchPage.getActivePartReference();
    if (workbenchPage.getPartState(reference) == IWorkbenchPage.STATE_MAXIMIZED) {
      workbenchPage.toggleZoom(reference);
    }
  }
}
 

Example 2

From project ccw, under directory /ccw.core/src/java/ccw/editors/clojure/.

Source file: GotoMatchingBracketHandler.java

  22 
vote

public Object execute(ExecutionEvent event) throws ExecutionException {
  IWorkbenchPart part=HandlerUtil.getActivePart(event);
  IClojureEditor clojureEditor=(IClojureEditor)PlatformUtil.getAdapter(part,IClojureEditor.class);
  if (clojureEditor == null) {
    CCWPlugin.logWarning("Handler " + GotoMatchingBracketHandler.class.getSimpleName() + " executed on a IWorkbenchPart (id:"+ part.getSite().getId()+ ") which is not able to adapt to "+ IClojureEditor.class.getSimpleName());
    return null;
  }
  clojureEditor.gotoMatchingBracket();
  return null;
}
 

Example 3

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

Source file: PlotDataView.java

  22 
vote

@Override protected IWorkbenchPart getBootstrapPart(){
  IWorkbenchPage page=getSite().getPage();
  if (page != null) {
    IWorkbenchPart activePart=page.getActivePart();
    return isImportant(activePart) ? activePart : null;
  }
  return null;
}
 

Example 4

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

Source file: SubModelViewUtils.java

  22 
vote

/** 
 * There are better ways of doing this, for instance telling the workbench that content has changed, using services, etc. However this seems to work for now.
 */
public static void refreshPallette(){
  final IViewPart part=EclipseUtils.getPage().findView(ActorTreeView.ID);
  if (part != null && part instanceof ActorTreeView) {
    ((ActorTreeView)part).refresh();
  }
  final IWorkbenchPart wbPart=EclipseUtils.getPage().getActivePart();
  if (wbPart instanceof PageBookView) {
    final PageBookView pageView=(PageBookView)wbPart;
    if (pageView.getCurrentPage() instanceof ActorTreeViewerPage) {
      ((ActorTreeViewerPage)pageView.getCurrentPage()).refresh();
    }
  }
}
 

Example 5

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 6

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

Source file: TaskDataHandler.java

  22 
vote

/** 
 * Schedule job
 * @param job
 * @param event
 */
protected void schedule(Job job,ExecutionEvent event){
  IWorkbenchSite site=HandlerUtil.getActiveSite(event);
  if (site == null) {
    IWorkbenchPart part=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
    if (part != null)     site=part.getSite();
  }
  IWorkbenchSiteProgressService progress=site != null ? (IWorkbenchSiteProgressService)site.getService(IWorkbenchSiteProgressService.class) : null;
  if (progress != null)   progress.schedule(job);
 else   job.schedule();
}
 

Example 7

From project glimpse-plugin, under directory /src/br/com/tecsinapse/glimpse/views/.

Source file: ReconnectReplHandler.java

  22 
vote

@Override public Object execute(ExecutionEvent event) throws ExecutionException {
  IWorkbenchPart part=HandlerUtil.getActivePart(event);
  if (part instanceof ReplView) {
    ReplView replView=(ReplView)part;
    replView.reconnectRepl();
  }
  return null;
}
 

Example 8

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

Source file: RemoveBrickAction.java

  22 
vote

@Override public void selectionChanged(IAction action,ISelection selection){
  super.selectionChanged(action,selection);
  action.setEnabled(false);
  volume=guiHelper.getSelectedEntity(window,Volume.class);
  if (volume != null) {
    IWorkbenchPart view=guiHelper.getActiveView();
    if (view instanceof VolumeBricksView) {
      bricks=GUIHelper.getInstance().getSelectedEntities(getWindow(),Brick.class);
      action.setEnabled(bricks.size() > 0);
    }
  }
}
 

Example 9

From project interactive-self-assessment, under directory /editbox/src/pm/eclipse/editbox/actions/.

Source file: EnableEditBox.java

  22 
vote

private void runCommand(boolean isChecked){
  if (win == null)   win=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  if (!isChecked)   releaseDecorators();
 else {
    getRegistry().setPartListener(win.getPartService(),new BoxDecoratorPartListener());
    IWorkbenchPart part=win.getActivePage().getActiveEditor();
    if (part != null)     setVisible(part,true);
  }
  EditBox.getDefault().setEnabled(isChecked);
}
 

Example 10

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

Source file: EditJavascriptCommandHandler.java

  22 
vote

private IEditingDomainProvider getEditingDomainProvider(IWorkbenchWindow wbw){
  if (wbw == null || wbw.getActivePage() == null) {
    return null;
  }
  IWorkbenchPart part=wbw.getActivePage().getActivePart();
  return (part instanceof IEditingDomainProvider ? (IEditingDomainProvider)part : null);
}
 

Example 11

From project makegood, under directory /com.piece_framework.makegood.ui/src/com/piece_framework/makegood/ui/.

Source file: ActivePart.java

  22 
vote

public void update(){
  IWorkbenchPart activePart=getActivePart();
  if (activePart != null) {
    update(activePart);
  }
}
 

Example 12

From project mylyn.context, under directory /org.eclipse.mylyn.java.tests/src/org/eclipse/mylyn/java/tests/.

Source file: ResourceStructureMappingTest.java

  22 
vote

public void testParentResourceMapping() throws CoreException {
  IWorkbenchPart part=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
  IMethod m1=type1.createMethod("public void m1() { }",null,true,null);
  monitor.selectionChanged(part,new StructuredSelection(m1));
  IInteractionElement m1Node=ContextCore.getContextManager().getElement(m1.getHandleIdentifier());
  assertTrue(m1Node.getInterest().isInteresting());
  IResource containingResource=ResourcesUiBridgePlugin.getDefault().getResourceForElement(m1Node,true);
  assertEquals(m1.getCompilationUnit().getAdapter(IResource.class),containingResource);
}
 

Example 13

From project mylyn.docs.intent.main, under directory /tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/util/.

Source file: WorkspaceUtils.java

  22 
vote

/** 
 * Close the welcomePage.
 */
public static void closeWelcomePage(){
  IWorkbenchPart activePart=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
  if (activePart != null && "Welcome".equals(activePart.getTitle()) && activePart instanceof IViewPart) {
    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().hideView((IViewPart)activePart);
  }
}
 

Example 14

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 15

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 16

From project hackergarten-moreunit, under directory /org.moreunit.plugin/src/org/moreunit/annotation/.

Source file: MoreUnitAnnotationModel.java

  21 
vote

public static void attachForAllOpenEditor(){
  IWorkbenchWindow[] windows=PlatformUI.getWorkbench().getWorkbenchWindows();
  for (  IWorkbenchWindow window : windows) {
    IWorkbenchPage[] pages=window.getPages();
    for (    IWorkbenchPage page : pages) {
      IEditorReference[] editors=page.getEditorReferences();
      for (      IEditorReference editorReference : editors) {
        IWorkbenchPart editorPart=editorReference.getPart(false);
        if (editorPart instanceof ITextEditor) {
          attach((ITextEditor)editorPart);
        }
      }
    }
  }
}
 

Example 17

From project mylyn.incubator, under directory /org.eclipse.mylyn.sandbox.tests/src/org/eclipse/mylyn/sandbox/tests/.

Source file: ActiveSearchTest.java

  21 
vote

public void testViewRecursion() throws JavaModelException, PartInitException {
  view=(ActiveSearchView)JavaPlugin.getActivePage().showView(ActiveSearchView.ID);
  ActiveSearchView.getFromActivePerspective().setSyncExecForTesting(false);
  for (  AbstractRelationProvider provider : ContextCorePlugin.getDefault().getRelationProviders()) {
    assertTrue(provider.isEnabled());
  }
  assertEquals(0,view.getViewer().getTree().getItemCount());
  IWorkbenchPart part=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
  IMethod m1=type1.createMethod("void m1() {\n m1(); \n}",null,true,null);
  StructuredSelection sm1=new StructuredSelection(m1);
  monitor.selectionChanged(part,sm1);
  IInteractionElement node=manager.processInteractionEvent(mockInterestContribution(m1.getHandleIdentifier(),scaling.getLandmark()));
  assertEquals(1,ContextCore.getContextManager().getActiveLandmarks().size());
  assertEquals(1,search(2,node).size());
  List<TreeItem> collectedItems=new ArrayList<TreeItem>();
  UiTestUtil.collectTreeItemsInView(view.getViewer().getTree().getItems(),collectedItems);
  assertEquals(1,collectedItems.size());
  monitor.selectionChanged(part,sm1);
  manager.processInteractionEvent(mockInterestContribution(m1.getHandleIdentifier(),-scaling.getLandmark()));
}
 

Example 18

From project neoclipse, under directory /org.neo4j.neoclipse/src/main/java/org/neo4j/neoclipse/.

Source file: Activator.java

  21 
vote

public void setStatusLineMessage(final String message){
  UiHelper.asyncExec(new Runnable(){
    @Override public void run(){
      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.setMessage(message);
    }
  }
);
}
 

Example 19

From project org.openscada.orilla, under directory /org.openscada.ae.ui.views/src/org/openscada/ae/ui/views/handler/.

Source file: AcknowledgeHandler.java

  21 
vote

@Override public Object execute(final ExecutionEvent handlerEvent) throws ExecutionException {
  final IWorkbenchPart part=getActivePage().getActivePart();
  if (!(part instanceof MonitorSubscriptionAlarmsEventsView)) {
    return null;
  }
  final MonitorSubscriptionAlarmsEventsView view=(MonitorSubscriptionAlarmsEventsView)part;
  final Iterator<?> i=getSelection().iterator();
  while (i.hasNext()) {
    final AckInformation ackInformation=AdapterHelper.adapt(i.next(),AckInformation.class);
    if (ackInformation == null) {
      continue;
    }
    final MonitorStatus status=ackInformation.getMonitorStatus();
switch (status) {
case NOT_AKN:
case NOT_OK_NOT_AKN:
      view.acknowledgeMonitor(ackInformation.getMonitorId(),ackInformation.getTimestamp());
    break;
default :
  break;
}
}
return null;
}
 

Example 20

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

Source file: PluginDataSheetView.java

  20 
vote

public void selectionChanged(IWorkbenchPart part,ISelection selection){
  if (selection instanceof IStructuredSelection) {
    Object first=((IStructuredSelection)selection).getFirstElement();
    if (first != null && first instanceof BundleStats) {
      viewer.getDocument().set(printStats((BundleStats)first));
      viewer.refresh();
    }
  }
}
 

Example 21

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

Source file: EditorContainersMonitoringView.java

  20 
vote

protected void linkEditor(IWorkbenchPart part){
  if (fCurrentPadEditor != null) {
    fCurrentPadEditor.removePropertyListener(fCurrentPadEditorPropertyListener);
  }
  fCurrentPadEditor=part;
  fCurrentPadEditor.addPropertyListener(fCurrentPadEditorPropertyListener);
  updateViewerInput();
}
 

Example 22

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

Source file: ReportView.java

  20 
vote

public void selectionChanged(IWorkbenchPart part,ISelection sel){
  if (sel instanceof IStructuredSelection) {
    IvyClasspathContainer ivycp=IvyClasspathUtil.getIvyClasspathContainer((IStructuredSelection)sel);
    if (ivycp != null) {
      browser.setText("<html></html>");
      URL report=ivycp.getReportUrl();
      if (report == null || !browser.setUrl(report.toExternalForm())) {
        browser.setText("<html></html>");
        Message.warn("impossible to set report view url to " + report.toExternalForm());
      }
    }
  }
}
 

Example 23

From project acceleo-modules, under directory /psm-gen-scala/plugins/com.github.sbegaudeau.acceleo.modules.psm.gen.scala.editor/src-gen/com/github/sbegaudeau/acceleo/modules/psm/gen/scala/model/scala/presentation/.

Source file: ScalaEditor.java

  19 
vote

public void partActivated(IWorkbenchPart p){
  if (p instanceof ContentOutline) {
    if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) {
      getActionBarContributor().setActiveEditor(ScalaEditor.this);
      setCurrentViewer(contentOutlineViewer);
    }
  }
 else   if (p instanceof PropertySheet) {
    if (((PropertySheet)p).getCurrentPage() == propertySheetPage) {
      getActionBarContributor().setActiveEditor(ScalaEditor.this);
      handleActivate();
    }
  }
 else   if (p == ScalaEditor.this) {
    handleActivate();
  }
}
 

Example 24

From project acceleo-webapp-generator, under directory /plugins/org.eclipse.acceleo.tutorial.webapp.editor/src-gen/org/eclipse/acceleo/tutorial/webapp/presentation/.

Source file: WebappEditor.java

  19 
vote

public void partActivated(IWorkbenchPart p){
  if (p instanceof ContentOutline) {
    if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) {
      getActionBarContributor().setActiveEditor(WebappEditor.this);
      setCurrentViewer(contentOutlineViewer);
    }
  }
 else   if (p instanceof PropertySheet) {
    if (((PropertySheet)p).getCurrentPage() == propertySheetPage) {
      getActionBarContributor().setActiveEditor(WebappEditor.this);
      handleActivate();
    }
  }
 else   if (p == WebappEditor.this) {
    handleActivate();
  }
}
 

Example 25

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

Source file: DrawingEditor.java

  19 
vote

@Override public void init(IEditorSite site,IEditorInput input) throws PartInitException {
  if (cursors == null) {
    cursors=DrawingEditor.createCursors(site.getShell().getDisplay());
  }
  setSite(site);
  setInput(input);
  setPartName(input.getName());
  openGL=br.org.archimedes.Utils.getOpenGLWrapper();
  visualHelper=new VisualHelper(openGL,br.org.archimedes.Utils.getWorkspace(),br.org.archimedes.Utils.getInputController());
  getDrawing().addObserver(this);
  getSite().setSelectionProvider(this);
  getEditorSite().getWorkbenchWindow().getPartService().addPartListener(new IPartListener(){
    private IWorkbenchPart lastActivated;
    public void partActivated(    IWorkbenchPart part){
      if (part == DrawingEditor.this) {
        System.out.println("Ativando: " + getDrawing().getTitle());
        lastActivated=part;
        br.org.archimedes.Utils.getInputController().setDrawing(getDrawing());
      }
    }
    public void partBroughtToTop(    IWorkbenchPart part){
    }
    public void partClosed(    IWorkbenchPart part){
      br.org.archimedes.Utils.getInputController().setDrawing(null);
      partActivated(lastActivated);
    }
    public void partDeactivated(    IWorkbenchPart part){
      if (part == DrawingEditor.this) {
        System.out.println("Desativando: " + getDrawing().getTitle());
        lastActivated=null;
      }
    }
    public void partOpened(    IWorkbenchPart part){
    }
  }
);
}
 

Example 26

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

Source file: Activator.java

  19 
vote

/** 
 * {@inheritDoc}
 */
@Override public void selectionChanged(IWorkbenchPart part,ISelection sel){
  if (sel instanceof TreeSelection) {
    selectedProjects=new ArrayList<String>();
    TreeSelection ts=(TreeSelection)sel;
    TreePath[] paths=ts.getPaths();
    if (noItems(paths)) {
      return;
    }
    for (    TreePath path : paths) {
      if (path.getSegmentCount() != 1) {
        continue;
      }
      Object o=path.getFirstSegment();
      if (!(o instanceof Project)) {
        continue;
      }
      Project p=(Project)o;
      selectedProjects.add(p.getName());
    }
  }
}
 

Example 27

From project Bioclipse.clustering, under directory /src/net/bioclipse/chem/clustering/.

Source file: ViewClustering.java

  19 
vote

public void selectionChanged(IWorkbenchPart part,ISelection selection){
  org.eclipse.core.internal.resources.File file;
  final int NUMCLUSTS=2;
  if ((file=getFileFromSelection(selection)) != null) {
    try {
      ClusterList cl=new ClusterList();
      List l=getMolecules(file);
      for (      Object o : l) {
        Cluster clust=new Cluster();
        clust.addElement(o);
        cl.add(clust);
      }
      text.setText("right before display clusterlist");
      clustering=new ClusteringManager();
      ClusterList results=clustering.doClustering(cl,NUMCLUSTS);
      displayClusterList(results);
    }
 catch (    BioclipseException e) {
      text.setText(e.getMessage());
    }
  }
}
 

Example 28

From project bioclipse.speclipse, under directory /plugins/net.bioclipse.nmrshiftdb/src/net/bioclipse/nmrshiftdb/wizards/.

Source file: AssignPredictWizard.java

  19 
vote

/** 
 * @param molecule
 * @param spectrum
 * @param assignmentpage
 * @param view
 * @param mode true=display check, false=do assignment
 */
public AssignPredictWizard(CMLMolecule molecule,CMLSpectrum spectrum,AssignmentPage assignmentpage,IWorkbenchPart view,boolean mode){
  super();
  setWindowTitle("Assign by Prediction");
  setNeedsProgressMonitor(true);
  this.spectrum=spectrum;
  this.molecule=molecule;
  this.assignmentpage=assignmentpage;
  this.mode=mode;
  CMLMetadataList mdl=MetadataUtils.getAllInOneMetadataList(spectrum);
  if (MetadataUtils.getMetadataDescendantsByName(mdl.getMetadataDescendants(),SpecMolEditor.nucleus).size() > 0) {
    nucleus=MetadataUtils.getMetadataDescendantsByName(mdl.getMetadataDescendants(),SpecMolEditor.nucleus).get(0).getAttributeValue("content");
  }
}
 

Example 29

From project bndtools, under directory /bndtools.core/src/bndtools/utils/.

Source file: MessagesPopupDialog.java

  19 
vote

public MessagesPopupDialog(Control controlAttachment,IMessage[] messages,IWorkbenchPart part){
  super(null,PopupDialog.INFOPOPUP_SHELLSTYLE,true,false,false,false,false,null,null);
  this.controlAttachment=controlAttachment;
  this.messages=messages;
  this.part=part;
  this.hyperlinkGroup=new HyperlinkGroup(controlAttachment.getDisplay());
  this.hyperlinkGroup.setHyperlinkUnderlineMode(HyperlinkSettings.UNDERLINE_ALWAYS);
}
 

Example 30

From project bundlemaker, under directory /main/org.bundlemaker.core.ui.event/src/org/bundlemaker/core/ui/event/selection/internal/lifecycle/.

Source file: LifecycleAwarePartListener.java

  19 
vote

@Override public void partOpened(IWorkbenchPart part){
  if (!isOwner(part)) {
    return;
  }
  _owner.onPartOpened();
}
 

Example 31

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

Source file: MarkOccurrencesAction.java

  19 
vote

public void partActivated(IWorkbenchPart part){
  if (part instanceof CeylonEditor) {
    setUpActiveEditor((CeylonEditor)part);
    if (fDocumentProvider != null) {
      retrieveOccurrenceAnnotations();
      if (!fMarkingEnabled) {
        unregisterListeners();
        removeExistingOccurrenceAnnotations();
      }
    }
  }
}
 

Example 32

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

Source file: ChainDesignerView.java

  19 
vote

@Override public void selectionChanged(IWorkbenchPart part,ISelection selection){
  Object element=null;
  if (selection instanceof TreeSelection) {
    TreeSelection treeSelection=(TreeSelection)selection;
    element=treeSelection.getFirstElement();
  }
  if (element == null)   return;
  String id=part.getSite().getId();
  ChainDesignerConfiguration<? extends ChainRepoService<?,?,?>,? extends GraphDrawable> conf=configs.get(id);
  if (conf == null)   return;
  if (conf.isValidElementForSelection(element) == false)   return;
  updateConfigAndModel(id,element);
}
 

Example 33

From project Database-Designer, under directory /plugins/org.obeonetwork.dsl.database.editor/src/org/obeonetwork/dsl/database/presentation/.

Source file: DatabaseEditor.java

  19 
vote

public void partActivated(IWorkbenchPart p){
  if (p instanceof ContentOutline) {
    if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) {
      getActionBarContributor().setActiveEditor(DatabaseEditor.this);
      setCurrentViewer(contentOutlineViewer);
    }
  }
 else   if (p instanceof PropertySheet) {
    if (((PropertySheet)p).getCurrentPage() == propertySheetPage) {
      getActionBarContributor().setActiveEditor(DatabaseEditor.this);
      handleActivate();
    }
  }
 else   if (p == DatabaseEditor.this) {
    handleActivate();
  }
}
 

Example 34

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

Source file: ActorValuePage.java

  19 
vote

@Override public void selectionChanged(IWorkbenchPart part,ISelection selection){
  try {
    updateSelection(selection);
  }
 catch (  Exception e) {
    logger.error("Cannot update value",e);
  }
}
 

Example 35

From project Diver, under directory /ca.uvic.chisel.diver.mylyn.logger/src/ca/uvic/chisel/diver/mylyn/logger/logging/.

Source file: PageSelectionListener.java

  19 
vote

@Override public void selectionChanged(IWorkbenchPart part,ISelection selection){
  String partId=part.getSite().getId();
  Object o=getSelectionObject(part,selection);
  if (o == null) {
    return;
  }
  String elementSelection=translate(o) + "\tpart=" + partId;
  MylynLogger.getDefault().logEvent(elementSelection);
}
 

Example 36

From project droolsjbpm-tools, under directory /drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/debug/.

Source file: DroolsDebugEventHandlerView.java

  19 
vote

public void contextActivated(ISelection selection,IWorkbenchPart part){
  if (!isAvailable() || !isVisible()) {
    return;
  }
  if (selection instanceof IStructuredSelection) {
    setViewerInput(((IStructuredSelection)selection).getFirstElement());
  }
  showViewer();
}
 

Example 37

From project eclim, under directory /org.eclim.vimplugin/java/org/vimplugin/editors/.

Source file: VimEditorPartListener.java

  19 
vote

/** 
 * {@inheritDoc}
 * @see IPartListener#partActivated(IWorkbenchPart)
 */
public void partActivated(IWorkbenchPart part){
  if (part instanceof VimEditor) {
    VimEditor editor=(VimEditor)part;
    if (editor.isEmbedded()) {
      disableKeys();
    }
  }
 else {
    enableKeys();
  }
}
 

Example 38

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

Source file: MosyncUIPlugin.java

  19 
vote

@Override public void selectionChanged(IWorkbenchPart part,ISelection selection){
  if (part instanceof IEditorPart) {
    updateCurrentlySelectedProject(part.getSite().getWorkbenchWindow(),(IEditorPart)part);
  }
 else {
    updateCurrentlySelectedProject(part.getSite().getWorkbenchWindow());
  }
  callOtherSelectionListeners(part,selection);
}
 

Example 39

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

Source file: MatchHighlightJob.java

  19 
vote

public void partClosed(IWorkbenchPart part){
  if (part == editor) {
    this.cancel();
    deleteMarkers();
  }
}
 

Example 40

From project eclipse-integration-commons, under directory /org.springframework.ide.eclipse.uaa/src/org/springframework/ide/eclipse/internal/uaa/monitor/.

Source file: PartUsageMonitor.java

  19 
vote

private void recordEvent(IWorkbenchPart part){
  if (manager != null && part != null) {
    if (part.getSite() instanceof IViewSite) {
      manager.registerFeatureUse(viewToBundleIdMapper.getBundleId(part.getSite().getId()),Collections.singletonMap("view",part.getSite().getRegisteredName()));
    }
 else     if (part.getSite() instanceof IEditorSite) {
      manager.registerFeatureUse(editorToBundleIdMapper.getBundleId(part.getSite().getId()),Collections.singletonMap("editor",part.getSite().getRegisteredName()));
    }
  }
}
 

Example 41

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

Source file: GradleTasksView.java

  19 
vote

public void selectionChanged(IWorkbenchPart part,ISelection selection){
  if (isLinkingEnabled()) {
    GradleProject p=SelectionUtils.getGradleProject(selection);
    if (p != null) {
      GradleTasksView.this.projectSelected(p);
    }
  }
}
 

Example 42

From project EMF-IncQuery, under directory /plugins/org.eclipse.viatra2.emf.incquery.runtime.gmf/src/org/eclipse/viatra2/emf/incquery/runtime/ui/gmf/util/.

Source file: GMFEditorPartListener.java

  19 
vote

@Override public void partClosed(IWorkbenchPart part){
  if (part != null && part instanceof IEditorPart) {
    IEditorPart closedEditor=(IEditorPart)part;
    if (closedEditor instanceof DiagramDocumentEditor) {
      DiagramDocumentEditor providerEditor=(DiagramDocumentEditor)closedEditor;
      ResourceSet resourceSet=providerEditor.getEditingDomain().getResourceSet();
      if (resourceSet.getResources().size() > 0) {
        if (resourceSet.getResources().size() > 0) {
          MatcherTreeViewerRootKey key=new MatcherTreeViewerRootKey(providerEditor,resourceSet);
          QueryExplorer.getInstance().getModelConnectorMap().get(key).unloadModel();
        }
      }
    }
  }
}
 

Example 43

From project fr.obeo.performance, under directory /fr.obeo.performance.editor/src-gen/fr/obeo/performance/presentation/.

Source file: PerformanceEditor.java

  19 
vote

public void partActivated(IWorkbenchPart p){
  if (p instanceof ContentOutline) {
    if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) {
      getActionBarContributor().setActiveEditor(PerformanceEditor.this);
      setCurrentViewer(contentOutlineViewer);
    }
  }
 else   if (p instanceof PropertySheet) {
    if (((PropertySheet)p).getCurrentPage() == propertySheetPage) {
      getActionBarContributor().setActiveEditor(PerformanceEditor.this);
      handleActivate();
    }
  }
 else   if (p == PerformanceEditor.this) {
    handleActivate();
  }
}
 

Example 44

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

Source file: MenuDisplayPartListener.java

  19 
vote

public void updateViews(IWorkbenchPart part){
  if (part instanceof IViewPart) {
    IViewPart view=(IViewPart)part;
    IContributionItem[] items=view.getViewSite().getActionBars().getToolBarManager().getItems();
    for (    IContributionItem iContributionItem : items) {
      if (iContributionItem instanceof CommandContributionItem) {
        CommandContributionItem commandContributionItem=(CommandContributionItem)iContributionItem;
        commandContributionItem.getData().mode=CommandContributionItem.MODE_FORCE_TEXT;
        commandContributionItem.getId();
        Class<? extends CommandContributionItem> class1=commandContributionItem.getClass();
        try {
          Field field=class1.getDeclaredField("mode");
          field.setAccessible(true);
          field.set(commandContributionItem,new Integer(1));
        }
 catch (        SecurityException e) {
          logger.error("SecurityException - Problem setting mode",e);
        }
catch (        IllegalArgumentException e) {
          logger.error("IllegalArgumentException - Problem setting mode",e);
        }
catch (        IllegalAccessException e) {
          logger.error("IllegalAccessException - Problem setting mode",e);
        }
catch (        NoSuchFieldException e) {
          logger.error("NoSuchFieldException - Problem setting mode",e);
        }
        commandContributionItem.update();
      }
      if (iContributionItem instanceof ActionContributionItem) {
        ActionContributionItem commandContributionItem=(ActionContributionItem)iContributionItem;
        commandContributionItem.setMode(ActionContributionItem.MODE_FORCE_TEXT);
      }
    }
  }
}
 

Example 45

From project grails-ide, under directory /org.grails.ide.eclipse.ui/src/org/grails/ide/eclipse/ui/internal/wizard/.

Source file: NewGrailsProjectWizardPageOne.java

  19 
vote

private IWorkingSet[] getSelectedWorkingSet(IStructuredSelection selection,IWorkbenchPart activePart){
  IWorkingSet[] selected=getSelectedWorkingSet(selection);
  if (selected != null && selected.length > 0) {
    for (int i=0; i < selected.length; i++) {
      if (!isValidWorkingSet(selected[i]))       return EMPTY_WORKING_SET_ARRAY;
    }
    return selected;
  }
  if (!(activePart instanceof PackageExplorerPart))   return EMPTY_WORKING_SET_ARRAY;
  PackageExplorerPart explorerPart=(PackageExplorerPart)activePart;
  if (explorerPart.getRootMode() == PackageExplorerPart.PROJECTS_AS_ROOTS) {
    IWorkingSet filterWorkingSet=explorerPart.getFilterWorkingSet();
    if (filterWorkingSet == null)     return EMPTY_WORKING_SET_ARRAY;
    if (!isValidWorkingSet(filterWorkingSet))     return EMPTY_WORKING_SET_ARRAY;
    return new IWorkingSet[]{filterWorkingSet};
  }
 else {
    Object input=explorerPart.getViewPartInput();
    if (!(input instanceof IWorkingSet))     return EMPTY_WORKING_SET_ARRAY;
    IWorkingSet workingSet=(IWorkingSet)input;
    if (!isValidWorkingSet(workingSet))     return EMPTY_WORKING_SET_ARRAY;
    return new IWorkingSet[]{workingSet};
  }
}
 

Example 46

From project JGit, under directory /org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/.

Source file: AbstractOperationAction.java

  19 
vote

public void setActivePart(final IAction act,final IWorkbenchPart part){
  wp=part;
  ISelection sel=part.getSite().getPage().getSelection();
  final List selection;
  if (sel instanceof IStructuredSelection && !sel.isEmpty()) {
    selection=((IStructuredSelection)sel).toList();
  }
 else {
    selection=Collections.EMPTY_LIST;
  }
  op=createOperation(act,selection);
  act.setEnabled(op != null && wp != null);
}
 

Example 47

From project logsaw-app, under directory /net.sf.logsaw.ui/src/net/sf/logsaw/ui/views/.

Source file: ALogEntryFieldView.java

  19 
vote

@Override public void selectionChanged(IWorkbenchPart part,ISelection selection){
  ILogViewEditor editor=(ILogViewEditor)part.getAdapter(ILogViewEditor.class);
  if (editor == null) {
    return;
  }
  ILogResource log=editor.getLogResource();
  LogEntry entry=null;
  if (!selection.isEmpty()) {
    IStructuredSelection sel=(IStructuredSelection)selection;
    entry=(LogEntry)sel.getFirstElement();
  }
  updateContents(log,entry);
}
 

Example 48

From project mwe, under directory /plugins/org.eclipse.emf.mwe.ewm.editor/src/org/eclipse/emf/mwe/ewm/orchestration/presentation/.

Source file: OrchestrationEditor.java

  19 
vote

public void partActivated(IWorkbenchPart p){
  if (p instanceof ContentOutline) {
    if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) {
      getActionBarContributor().setActiveEditor(OrchestrationEditor.this);
      setCurrentViewer(contentOutlineViewer);
    }
  }
 else   if (p instanceof PropertySheet) {
    if (((PropertySheet)p).getCurrentPage() == propertySheetPage) {
      getActionBarContributor().setActiveEditor(OrchestrationEditor.this);
      handleActivate();
    }
  }
 else   if (p == OrchestrationEditor.this) {
    handleActivate();
  }
}
 

Example 49

From project mylyn.docs, under directory /org.eclipse.mylyn.wikitext.tasks.ui/src/org/eclipse/mylyn/internal/wikitext/tasks/ui/.

Source file: WikiTextUserInteractionMonitor.java

  19 
vote

@Override protected void handleWorkbenchPartSelection(IWorkbenchPart part,ISelection selection,boolean contributeToContext){
  if (selection instanceof ITextSelection) {
    OutlineItem item=(OutlineItem)part.getAdapter(OutlineItem.class);
    if (item != null) {
      OutlineItem relevantItem=item.findNearestMatchingOffset(((ITextSelection)selection).getOffset());
      if (relevantItem == null) {
        relevantItem=item;
      }
      handleElementSelection(part,relevantItem,contributeToContext);
    }
  }
 else   if (selection instanceof IStructuredSelection) {
    for (    Object element : ((IStructuredSelection)selection).toArray()) {
      if (element instanceof OutlineItem) {
        handleElementSelection(part,element,contributeToContext);
      }
    }
  }
}
 

Example 50

From project netifera, under directory /platform/com.netifera.platform.ui/com.netifera.platform.ui/src/com/netifera/platform/ui/workbench/.

Source file: WorkbenchChangeManager.java

  19 
vote

private IPartListener createPartListener(){
  return new IPartListener(){
    public void partActivated(    IWorkbenchPart part){
      changeListener.partChange();
    }
    public void partClosed(    IWorkbenchPart part){
      changeListener.partChange();
    }
    public void partBroughtToTop(    IWorkbenchPart part){
    }
    public void partDeactivated(    IWorkbenchPart part){
    }
    public void partOpened(    IWorkbenchPart part){
      changeListener.partChange();
    }
  }
;
}
 

Example 51

From project Newsreader, under directory /bundles/org.eclipse.ecf.salvo.ui/src/org/eclipse/ecf/salvo/ui/internal/editor/.

Source file: ArticlePanel.java

  19 
vote

public void selectionChanged(IWorkbenchPart part,ISelection selection){
  if (part == this) {
    return;
  }
  if (selection instanceof IStructuredSelection) {
    if (((IStructuredSelection)selection).getFirstElement() instanceof ISalvoResource) {
      if (((ISalvoResource)((IStructuredSelection)selection).getFirstElement()).getObject() instanceof INewsgroup) {
        setInput((INewsgroup)((ISalvoResource)((IStructuredSelection)selection).getFirstElement()).getObject());
      }
    }
  }
}
 

Example 52

From project org.openscada.dakara, under directory /org.openscada.vi.model.editor/src/org/openscada/vi/model/VisualInterface/presentation/.

Source file: VisualInterfaceEditor.java

  19 
vote

public void partActivated(IWorkbenchPart p){
  if (p instanceof ContentOutline) {
    if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) {
      getActionBarContributor().setActiveEditor(VisualInterfaceEditor.this);
      setCurrentViewer(contentOutlineViewer);
    }
  }
 else   if (p instanceof PropertySheet) {
    if (((PropertySheet)p).getCurrentPage() == propertySheetPage) {
      getActionBarContributor().setActiveEditor(VisualInterfaceEditor.this);
      handleActivate();
    }
  }
 else   if (p == VisualInterfaceEditor.this) {
    handleActivate();
  }
}