@Override public IWorkbenchPart getWorkbenchPart() { if (fContainer != null) return fContainer.getWorkbenchPart(); return null; }
public IWorkbenchPart getWorkbenchPart() { if (fContainer != null) return fContainer.getWorkbenchPart(); return null; }
@Override public IEditorInput getEditorInput() { if (MergeSourceViewer.this.fContainer.getWorkbenchPart() instanceof IEditorPart) return ((IEditorPart) MergeSourceViewer.this.fContainer.getWorkbenchPart()).getEditorInput(); return null; }
@Override public IWorkbenchPartSite getSite() { return MergeSourceViewer.this.fContainer.getWorkbenchPart().getSite(); }
private IWorkbenchPartSite getSite() { if (fSite == null) { IWorkbenchPart workbenchPart= getCompareConfiguration().getContainer().getWorkbenchPart(); fSite= workbenchPart != null ? workbenchPart.getSite() : null; } return fSite; }
private IWorkbenchPartSite getSite() { if (fSite == null) { IWorkbenchPart workbenchPart= getCompareConfiguration().getContainer().getWorkbenchPart(); fSite= workbenchPart != null ? workbenchPart.getSite() : null; } return fSite; }
protected IWorkbenchPartSite getSite() { IWorkbenchPart workbenchPart = getCompareConfiguration().getContainer().getWorkbenchPart(); return workbenchPart != null ? workbenchPart.getSite() : null; }
private void initialize() { if (fHandlerService == null) { IServiceLocator serviceLocator = fContainer.getServiceLocator(); if (serviceLocator != null) { IHandlerService service = serviceLocator.getService(IHandlerService.class); if (service != null) fHandlerService = service; } if (fHandlerService == null && fContainer.getWorkbenchPart() == null && fExpression != null) { // We're in a dialog so we can use an active shell expression IHandlerService service = PlatformUI.getWorkbench().getService(IHandlerService.class); if (service != null) { fHandlerService = service; } } } }
private void initialize() { if (fHandlerService == null) { IServiceLocator serviceLocator = fContainer.getServiceLocator(); if (serviceLocator != null) { IHandlerService service = (IHandlerService)serviceLocator.getService(IHandlerService.class); if (service != null) fHandlerService = service; } if (fHandlerService == null && fContainer.getWorkbenchPart() == null && fExpression != null) { // We're in a dialog so we can use an active shell expression IHandlerService service = (IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class); if (service != null) { fHandlerService = service; } } } }
@Override protected void setActionsActivated(SourceViewer sourceViewer, boolean state) { if (fEditor != null) { Object editor= fEditor.get(sourceViewer); if (editor instanceof CompilationUnitEditorAdapter) { CompilationUnitEditorAdapter cuea= (CompilationUnitEditorAdapter)editor; cuea.setActionsActivated(state); IAction saveAction= cuea.getAction(ITextEditorActionConstants.SAVE); if (saveAction instanceof IPageListener) { PartEventAction partEventAction= (PartEventAction) saveAction; IWorkbenchPart compareEditorPart= getCompareConfiguration().getContainer().getWorkbenchPart(); if (state) partEventAction.partActivated(compareEditorPart); else partEventAction.partDeactivated(compareEditorPart); } } } }
@Override protected void createControls(Composite composite) { super.createControls(composite); IWorkbenchPart workbenchPart= getCompareConfiguration().getContainer().getWorkbenchPart(); if (workbenchPart != null) { IContextService service= workbenchPart.getSite().getService(IContextService.class); if (service != null) { service.activateContext("org.eclipse.jdt.ui.javaEditorScope"); //$NON-NLS-1$ } } }
@Override protected void createControls(Composite composite) { super.createControls(composite); IWorkbenchPart workbenchPart= getCompareConfiguration().getContainer().getWorkbenchPart(); if (workbenchPart != null) { IContextService service= workbenchPart.getSite().getService(IContextService.class); if (service != null) { service.activateContext("org.eclipse.jdt.ui.javaEditorScope"); //$NON-NLS-1$ } } }
private void registerSaveable(boolean init) { ICompareContainer container = getContainer(); IWorkbenchPart part = container.getWorkbenchPart(); if (part != null) { ISaveablesLifecycleListener lifecycleListener= getSaveablesLifecycleListener(part); // Remove this saveable from the lifecycle listener if (!init) lifecycleListener.handleLifecycleEvent( new SaveablesLifecycleEvent(part, SaveablesLifecycleEvent.POST_CLOSE, new Saveable[] { this }, false)); // Now fix the hashing so it uses the connected document initializeHashing(); // Finally, add this saveable back to the listener lifecycleListener.handleLifecycleEvent( new SaveablesLifecycleEvent(part, SaveablesLifecycleEvent.POST_OPEN, new Saveable[] { this }, false)); } } public void handleDocumentDeleted() {
private void registerSaveable(boolean init) { ICompareContainer container = getContainer(); IWorkbenchPart part = container.getWorkbenchPart(); if (part != null) { ISaveablesLifecycleListener lifecycleListener= getSaveablesLifecycleListener(part); // Remove this saveable from the lifecycle listener. if (!init) { lifecycleListener.handleLifecycleEvent( new SaveablesLifecycleEvent(part, SaveablesLifecycleEvent.POST_CLOSE, new Saveable[] { this }, false)); } // Now fix the hashing so it uses the connected document. initializeHashing(); // Finally, add this saveable back to the listener. lifecycleListener.handleLifecycleEvent( new SaveablesLifecycleEvent(part, SaveablesLifecycleEvent.POST_OPEN, new Saveable[] { this }, false)); } }
private void addSave(IMenuManager menu) { ICommandService commandService = fContainer.getWorkbenchPart().getSite().getService(ICommandService.class); final Command command= commandService.getCommand(IWorkbenchCommandConstants.FILE_SAVE); final IHandler handler = command.getHandler(); if (handler != null) { if (fSaveContributionItem == null) { fSaveContributionItem = new CommandContributionItem( new CommandContributionItemParameter(fContainer .getWorkbenchPart().getSite(), null, command .getId(), CommandContributionItem.STYLE_PUSH)); } // save is an editable dependent action, ie add only when edit // is possible if (handler.isHandled() && getSourceViewer().isEditable()) menu.add(fSaveContributionItem); } }
@Override protected void setActionsActivated(SourceViewer sourceViewer, boolean state) { DefaultMergeEditor mergeEditor = getEditor(sourceViewer); if (mergeEditor != null) { mergeEditor.setActionsActivated(state); IAction saveAction = mergeEditor.getAction(ITextEditorActionConstants.SAVE); if (saveAction instanceof IPageListener) { PartEventAction partEventAction = (PartEventAction) saveAction; IWorkbenchPart compareEditorPart = getCompareConfiguration().getContainer().getWorkbenchPart(); if (state) { partEventAction.partActivated(compareEditorPart); } else { partEventAction.partDeactivated(compareEditorPart); } } } }
public static CompareHandlerService createFor(ICompareContainer container, Shell shell) { IServiceLocator serviceLocator = container.getServiceLocator(); if (serviceLocator != null) { IHandlerService service = serviceLocator.getService(IHandlerService.class); if (service != null) return new CompareHandlerService(container, null); } if (container.getWorkbenchPart() == null && shell != null) { // We're in a dialog so we can use an active shell expression IHandlerService service = PlatformUI.getWorkbench().getService(IHandlerService.class); if (service != null) { Expression e = new ActiveShellExpression(shell); return new CompareHandlerService(container, e); } } return new CompareHandlerService(null, null); }
public static CompareHandlerService createFor(ICompareContainer container, Shell shell) { IServiceLocator serviceLocator = container.getServiceLocator(); if (serviceLocator != null) { IHandlerService service = (IHandlerService)serviceLocator.getService(IHandlerService.class); if (service != null) return new CompareHandlerService(container, null); } if (container.getWorkbenchPart() == null && shell != null) { // We're in a dialog so we can use an active shell expression IHandlerService service = (IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class); if (service != null) { Expression e = new ActiveShellExpression(shell); return new CompareHandlerService(container, e); } } return new CompareHandlerService(null, null); }
private void contributeFindAction(MergeSourceViewer viewer) { IAction action; IWorkbenchPart wp = getCompareConfiguration().getContainer().getWorkbenchPart(); if (wp != null) action = new FindReplaceAction(getResourceBundle(), "Editor.FindReplace.", wp); //$NON-NLS-1$ else action = new FindReplaceAction(getResourceBundle(), "Editor.FindReplace.", viewer.getControl().getShell(), getFindReplaceTarget()); //$NON-NLS-1$ action.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_REPLACE); viewer.addAction(MergeSourceViewer.FIND_ID, action); }
private void contributeFindAction(MergeSourceViewer viewer) { IAction action; IWorkbenchPart wp = getCompareConfiguration().getContainer().getWorkbenchPart(); if (wp != null) action = new FindReplaceAction(getResourceBundle(), "Editor.FindReplace.", wp); //$NON-NLS-1$ else action = new FindReplaceAction(getResourceBundle(), "Editor.FindReplace.", viewer.getSourceViewer().getControl().getShell(), getFindReplaceTarget()); //$NON-NLS-1$ action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_FIND_AND_REPLACE); viewer.addAction(MergeSourceViewer.FIND_ID, action); }