public static StatusLineContributionItem getStatusLineCItem(final String statusLineId) { IWorkbench wb = PlatformUI.getWorkbench(); IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); if (win == null) return null; IWorkbenchPage page = win.getActivePage(); if (page == null) return null; IWorkbenchPart part = page.getActivePart(); if (part == null) return null; IWorkbenchPartSite site = part.getSite(); IViewSite vSite = (IViewSite) site; IActionBars actionBars = vSite.getActionBars(); if (actionBars == null) return null; IStatusLineManager statusLineManager = actionBars.getStatusLineManager(); if (statusLineManager == null) return null; StatusLineContributionItem StatusLineCItem = (StatusLineContributionItem) statusLineManager.find(statusLineId); return StatusLineCItem; }
private IPartService getPartService() { IViewSite site = navigator.getViewSite(); if (site != null) { return site.getService(IPartService.class); } return null; }
@Override public void dispose() { getSite().getPage().removePartListener(fPartListener); Enumeration<IMemoryViewPane> enumeration = fViewPanes.elements(); while (enumeration.hasMoreElements()) { Object element = enumeration.nextElement(); if (element instanceof IMemoryViewPane) { ((IMemoryViewPane) element).dispose(); } } fViewPaneControls.clear(); IViewSite viewSite = getViewSite(); String secondaryId = viewSite.getSecondaryId(); if (secondaryId != null) MemoryViewIdRegistry.deregisterView(secondaryId); fSyncService.shutdown(); if (fAddHandler != null) fAddHandler.dispose(); if (fToggleMonitorsHandler != null) fToggleMonitorsHandler.dispose(); if (fNextMemoryBlockHandler != null) fNextMemoryBlockHandler.dispose(); super.dispose(); }
private String getOrientationPrefId() { IViewSite vs = getViewSite(); String viewId = vs.getSecondaryId(); if (viewId != null) return VIEW_PANE_ORIENTATION_PREF + "." + viewId; // $NON-NLS-1$ return VIEW_PANE_ORIENTATION_PREF; }
private String getVisibilityPrefId() { IViewSite vs = getViewSite(); String viewId = vs.getSecondaryId(); if (viewId != null) return VISIBILITY_PREF + "." + viewId; // $NON-NLS-1$ return VISIBILITY_PREF; }
/** * Displays the given error message in the status line. * * @param message the message to display */ protected void showErrorMessage(String message) { if (fPart instanceof IViewPart) { IViewSite viewSite = ((IViewPart) fPart).getViewSite(); IStatusLineManager manager = viewSite.getActionBars().getStatusLineManager(); manager.setErrorMessage(message); Display.getCurrent().beep(); } }
/** @return secondary id, or null if not available */ private String getViewSiteSecondaryId() { IMemoryRenderingSite renderingSite = fViewPane.getMemoryRenderingSite(); IWorkbenchPartSite ps = renderingSite.getSite(); if (ps instanceof IViewSite) { IViewSite vs = (IViewSite) ps; String secondaryId = vs.getSecondaryId(); return secondaryId; } return null; }
public void init(IViewSite site) throws PartInitException { super.init(site); String secId = site.getSecondaryId(); String ids[] = secId.split("&"); serverId = Integer.valueOf(ids[0]); objType = ids[1]; }
/* (non-Javadoc) * @see org.eclipse.ui.IViewPart#init(org.eclipse.ui.IViewSite, org.eclipse.ui.IMemento) */ public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site); Workbench workbench = (Workbench) site.getWorkbenchWindow().getWorkbench(); try { introPart = workbench.getWorkbenchIntroManager().createNewIntroPart(); // reset the part name of this view to be that of the intro title setPartName(introPart.getTitle()); introPart.addPropertyListener( new IPropertyListener() { public void propertyChanged(Object source, int propId) { firePropertyChange(propId); } }); introSite = new ViewIntroAdapterSite(site, workbench.getIntroDescriptor()); introPart.init(introSite, memento); } catch (CoreException e) { WorkbenchPlugin.log( IntroMessages.Intro_could_not_create_proxy, new Status( IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, IStatus.ERROR, IntroMessages.Intro_could_not_create_proxy, e)); } }
public void init(IViewSite site) throws PartInitException { super.init(site); String secId = site.getSecondaryId(); if (secId != null) { serverId = Integer.parseInt(secId); } }
/** Deactivate the key bindings for an embedded editor. */ public void deactivate() { if (keyBindingService == null) { return; } INestableKeyBindingService service = (INestableKeyBindingService) parent.getKeyBindingService(); service.activateKeyBindingService(null); }
@Override public void init(IViewSite site) throws PartInitException { super.init(site); fViewCnt++; String secondaryId = site.getSecondaryId(); if (secondaryId != null) MemoryViewIdRegistry.registerView(secondaryId); // only do this the first time // not sure if there is a bug in the UI... if the view is // not a primary view and if it's hidden, the view is not // init and created until it becomes visible. if (fViewCnt == 1) { // also try to find other views and register if (DebugUIPlugin.getActiveWorkbenchWindow() != null && DebugUIPlugin.getActiveWorkbenchWindow().getActivePage() != null) { IViewReference references[] = DebugUIPlugin.getActiveWorkbenchWindow().getActivePage().getViewReferences(); for (int i = 0; i < references.length; i++) { if (references[i].getSecondaryId() != null) { MemoryViewIdRegistry.registerView(references[i].getSecondaryId()); } } } } fSyncService = new MemoryViewSynchronizationService(); }
/** Returns a CompositeEditorKeybinding for an embedded editor. */ public IKeyBindingService getKeyBindingService() { if (keyBindingService == null) { INestableKeyBindingService service = (INestableKeyBindingService) parent.getKeyBindingService(); keyBindingService = service.getKeyBindingService(this); } return keyBindingService; }
/** * Handles a selection changed event from the embedded editor. The default implementation gets the * selection provider from the composite editor's site, and calls <code>fireSelectionChanged * </code> on it (only if it is an instance of <code>CompositeEditorSelectionProvider</code>), * passing a new event object. * * <p>Subclasses may extend or reimplement this method. * * @param event the event */ protected void handleSelectionChanged(SelectionChangedEvent event) { ISelectionProvider parentProvider = parent.getSelectionProvider(); if (parentProvider instanceof CompositeEditorSelectionProvider) { SelectionChangedEvent newEvent = new SelectionChangedEvent(parentProvider, event.getSelection()); ((CompositeEditorSelectionProvider) parentProvider).fireSelectionChanged(newEvent); } }
public void init(IViewSite site) throws PartInitException { super.init(site); String secId = site.getSecondaryId(); String[] ids = StringUtil.split(secId, "&"); this.serverId = CastUtil.cint(ids[0]); this.objType = ids[1]; this.counter = ids[2]; this.mode = CounterUtil.getTotalMode(objType, counter); }
@Override public void init(IViewSite site) throws PartInitException { super.init(site); id = site.getId(); sId = site.getSecondaryId(); if (sId == null) { setPartName("Colour Mapping"); } else { try { // You can see it's a histogram by looking but // you really need the file name to know which // view is corresponding to which file. setPartName("Colour Mapping: " + (new File(sId)).getName()); } catch (Exception ne) { setPartName("Colour Mapping"); } } }
private String getPrefId() { // constructs id based on memory view's secondary id + the rendering view pane id // format: secondaryId:viewPaneId StringBuffer id = new StringBuffer(); IMemoryRenderingSite renderingSite = fViewPane.getMemoryRenderingSite(); IWorkbenchPartSite ps = renderingSite.getSite(); if (ps instanceof IViewSite) { IViewSite vs = (IViewSite) ps; String secondaryId = vs.getSecondaryId(); if (secondaryId != null) { id.append(secondaryId); id.append(":"); // $NON-NLS-1$ } } id.append(fViewPane.getId()); String prefId = id.toString(); return prefId; }
public void init(IViewSite site) throws PartInitException { super.init(site); String secId = site.getSecondaryId(); statusMessage = secId; String[] datas = secId.split("&"); grpName = datas[0]; objType = datas[1]; counter = datas[2]; }
/** * Create a toolbar containing the specified actions * * @param actions a collection of actions and null-values (that represent separators) */ public void createToolbar(IAction... actions) { IToolBarManager tmg = site.getActionBars().getToolBarManager(); for (IAction ac : actions) { if (ac == null) { tmg.add(new Separator()); } else { tmg.add(ac); } } }
/** * Create a menu containing the specified actions. * * @param actions a collection of actions and null-values (that represent separators) */ public void createMenu(IAction... actions) { IMenuManager mgr = site.getActionBars().getMenuManager(); for (IAction ac : actions) { if (ac == null) { mgr.add(new Separator()); } else { mgr.add(ac); } } }
/* (non-Javadoc) * @see org.eclipse.ui.part.ViewPart#init(org.eclipse.ui.IViewSite, org.eclipse.ui.IMemento) */ @Override public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site, memento); BundleContext bundleContext = UIActivator.getDefault().getBundle().getBundleContext(); ServiceReference<ITradingSystemService> serviceReference = bundleContext.getServiceReference(ITradingSystemService.class); tradingSystemService = bundleContext.getService(serviceReference); activator = CoreActivator.getDefault(); IDialogSettings rootDialogSettings = UIActivator.getDefault().getDialogSettings(); dialogSettings = rootDialogSettings.getSection(VIEW_ID); if (dialogSettings == null) { dialogSettings = rootDialogSettings.addNewSection(VIEW_ID); dialogSettings.put( COLUMNS, new String[] { "org.eclipsetrader.ui.providers.LastTrade", //$NON-NLS-1$ "org.eclipsetrader.ui.providers.BidPrice", //$NON-NLS-1$ "org.eclipsetrader.ui.providers.AskPrice", //$NON-NLS-1$ "org.eclipsetrader.ui.providers.Position", //$NON-NLS-1$ "org.eclipsetrader.ui.providers.LastTradeDateTime", //$NON-NLS-1$ "org.eclipsetrader.ui.providers.gain", //$NON-NLS-1$ }); IDialogSettings section = dialogSettings.addNewSection(COLUMN_NAMES); section.put("org.eclipsetrader.ui.providers.LastTrade", "Last"); // $NON-NLS-1$ section.put("org.eclipsetrader.ui.providers.BidPrice", "Bid"); // $NON-NLS-1$ section.put("org.eclipsetrader.ui.providers.AskPrice", "Ask"); // $NON-NLS-1$ section.put("org.eclipsetrader.ui.providers.Position", "Position"); // $NON-NLS-1$ section.put("org.eclipsetrader.ui.providers.LastTradeDateTime", "Date / Time"); // $NON-NLS-1$ section.put("org.eclipsetrader.ui.providers.gain", "Gain"); // $NON-NLS-1$ dialogSettings.addNewSection(COLUMN_WIDTHS); } settingsAction = new SettingsAction(site.getShell(), this); IActionBars actionBars = site.getActionBars(); actionBars.setGlobalActionHandler(settingsAction.getId(), settingsAction); actionBars.updateActionBars(); }
/** * Attach a context menu to a org.eclipse.jface.StructuredViewer * * @param viewer the viewer * @param actions the actions to use */ public void createViewerContextMenu(StructuredViewer viewer, final IAction... actions) { MenuManager menuMgr = new MenuManager(); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener( new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { fillContextMenu(manager, actions); } }); Menu menu = menuMgr.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); site.registerContextMenu(menuMgr, viewer); }
public static void executeCommand(IViewSite site, String command) { ICommandService cmdService = (ICommandService) site.getService(ICommandService.class); IHandlerService hdlService = (IHandlerService) site.getService(IHandlerService.class); Command cmd = cmdService.getCommand(command); try { hdlService.executeCommand(cmd.getId(), null); } catch (ExecutionException e) { e.printStackTrace(); } catch (NotDefinedException e) { e.printStackTrace(); } catch (NotEnabledException e) { e.printStackTrace(); } catch (NotHandledException e) { e.printStackTrace(); } }
/** Activate the key bindings for an embedded editor. */ public void activate() { if (keyBindingService == null) { return; } INestableKeyBindingService service = (INestableKeyBindingService) parent.getKeyBindingService(); service.activateKeyBindingService(this); // The workbench only calls updateActiveKeyBindingService() when a workbench part // becomes active. We have to explicitly call it since for the // workbench the active part has not changed. // TODO: find an alternative in Eclipse 3.0 for the following call: // ((Workbench) getWorkbenchWindow().getWorkbench()).updateActiveKeyBindingService(); // TODO: I've tried the following lines but they seem to be unnecessary since the key bindings // are working. // IWorkbench workbench = getWorkbenchWindow().getWorkbench(); // WorkbenchCommandSupport support = (WorkbenchCommandSupport) // workbench.getCommandSupport(); // support.processHandlerSubmissions(true, workbench.getDisplay().getActiveShell()); }
@Override public void init(final IViewSite site, final IMemento memento) throws PartInitException { super.init(site, memento); // For new instances opened while CSS is running, // createNewInstance() tracks the secondary view ID. // But if this view was 'restored' from a saved workspace, // we need to adjust the instance counter to not re-use // IDs of restored views. int this_instance = 1; try { this_instance = Integer.parseInt(site.getSecondaryId()); } catch (NumberFormatException ex) { // Ignore, just assume 1 } synchronized (PVManagerProbe.class) { if (this_instance >= next_instance) next_instance = this_instance + 1; } // Save the memento this.memento = memento; }
/* (non-Javadoc) * @see org.eclipse.ui.part.ViewPart#init(org.eclipse.ui.IViewSite, org.eclipse.ui.IMemento) */ @Override public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site, memento); this.memento = memento; this.preferenceStore = UIActivator.getDefault().getPreferenceStore(); try { dialogSettings = UIActivator.getDefault() .getDialogSettings() .getSection(K_VIEWS) .getSection(site.getSecondaryId()); uri = new URI(dialogSettings.get(K_URI)); IRepositoryService repositoryService = UIActivator.getDefault().getRepositoryService(); security = repositoryService.getSecurityFromURI(uri); String privateTemplate = dialogSettings.get(K_PRIVATE_TEMPLATE); if (privateTemplate != null) { template = unmarshal(privateTemplate); } if (template == null) { IPath templatePath = new Path("data"); // $NON-NLS-1$ if (dialogSettings.get(K_TEMPLATE) != null) { templatePath = templatePath.append(dialogSettings.get(K_TEMPLATE)); } else { templatePath = templatePath.append("basic-template.xml"); } InputStream stream = FileLocator.openStream(UIActivator.getDefault().getBundle(), templatePath, false); template = unmarshal(stream); } } catch (Exception e) { Status status = new Status( IStatus.ERROR, UIActivator.PLUGIN_ID, Messages.ChartViewPart_LoadingErrorMessage + site.getSecondaryId(), e); UIActivator.getDefault().getLog().log(status); } site.setSelectionProvider(new SelectionProvider()); createActions(); createPeriodActions(); IActionBars actionBars = site.getActionBars(); IMenuManager menuManager = actionBars.getMenuManager(); menuManager.add(new Separator("periods.top")); // $NON-NLS-1$ menuManager.add(new Separator("periods")); // $NON-NLS-1$ menuManager.add(new Separator("periods.bottom")); // $NON-NLS-1$ menuManager.add(currentPriceLineAction); menuManager.add(currentBookAction); menuManager.appendToGroup("periods.top", periodAllAction); // $NON-NLS-1$ if (periodActions != null) { for (int i = 0; i < periodActions.length; i++) { menuManager.appendToGroup("periods", periodActions[i]); } } IToolBarManager toolBarManager = actionBars.getToolBarManager(); toolBarManager.add(new Separator("additions")); // $NON-NLS-1$ toolBarManager.add(updateAction); TimeSpan periodTimeSpan = TimeSpan.fromString(dialogSettings.get(K_PERIOD)); TimeSpan resolutionTimeSpan = TimeSpan.fromString(dialogSettings.get(K_RESOLUTION)); setPeriodActionSelection(periodTimeSpan, resolutionTimeSpan); actionBars.setGlobalActionHandler(cutAction.getId(), cutAction); actionBars.setGlobalActionHandler(copyAction.getId(), copyAction); actionBars.setGlobalActionHandler(pasteAction.getId(), pasteAction); actionBars.setGlobalActionHandler(deleteAction.getId(), deleteAction); actionBars.setGlobalActionHandler(ActionFactory.PRINT.getId(), printAction); ToolAction toolAction = new ToolAction( Messages.ChartViewPart_LineAction, this, "org.eclipsetrader.ui.charts.tools.line"); actionBars.setGlobalActionHandler(toolAction.getId(), toolAction); toolAction = new ToolAction( Messages.ChartViewPart_FiboLineAction, this, "org.eclipsetrader.ui.charts.tools.fiboline"); actionBars.setGlobalActionHandler(toolAction.getId(), toolAction); toolAction = new ToolAction( Messages.ChartViewPart_FanLineAction, this, "org.eclipsetrader.ui.charts.tools.fanline"); actionBars.setGlobalActionHandler(toolAction.getId(), toolAction); toolAction = new ToolAction( Messages.ChartViewPart_FiboArcAction, this, "org.eclipsetrader.ui.charts.tools.fiboarc"); actionBars.setGlobalActionHandler(toolAction.getId(), toolAction); actionBars.setGlobalActionHandler(zoomInAction.getActionDefinitionId(), zoomInAction); actionBars.setGlobalActionHandler(zoomOutAction.getActionDefinitionId(), zoomOutAction); actionBars.setGlobalActionHandler(zoomResetAction.getActionDefinitionId(), zoomResetAction); actionBars.setGlobalActionHandler(propertiesAction.getId(), propertiesAction); actionBars.updateActionBars(); }
/** * @param site * @param id * @return tooltip */ public static ToolbarTooltip install(IViewSite site, String id) { ToolBarManager toolBarManager = (ToolBarManager) site.getActionBars().getToolBarManager(); final ToolBar control = toolBarManager.getControl(); return new ToolbarTooltip(control, id); }
@Override public void init(IViewSite site, IMemento memento) throws PartInitException { init(site); String storedExtensions = ""; if (memento != null) { // Open dir path this.dirPath = memento.getString("DIR"); storedExtensions = memento.getString("FILTERS"); if (storedExtensions == null) storedExtensions = ""; } // Filter Extensions imgExtensions = new Action[ImageExplorerDirectoryChooseAction.LISTOFSUFFIX.length]; MenuManager filterMenu = new MenuManager("File Filters"); for (int i = 0; i < ImageExplorerDirectoryChooseAction.LISTOFSUFFIX.length; i++) { final int number = i; imgExtensions[i] = new Action("", IAction.AS_CHECK_BOX) { @Override public void run() { if (this.isChecked()) { filter.remove(ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[number]); } else { filter.add(ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[number]); } // reload the directory updateDirectory.setUser(true); updateDirectory.setPriority(Job.DECORATE); updateDirectory.schedule(1000); } }; imgExtensions[i].setText(ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[i]); imgExtensions[i].setDescription( "Filter " + ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[i] + " on/off"); if (storedExtensions.contains(ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[i])) { imgExtensions[i].setChecked(false); filter.add(ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[i]); } else imgExtensions[i].setChecked(true); filterMenu.add(imgExtensions[i]); } site.getActionBars().getMenuManager().add(filterMenu); // color submenus actions final IPaletteService pservice = PlatformUI.getWorkbench().getService(IPaletteService.class); final Collection<String> names = pservice.getColorSchemes(); String schemeName = getPreferenceColourMapChoice(); colorMenu = new MenuAction("Color"); colorMenu.setId(getClass().getName() + colorMenu.getText()); colorMenu.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/color_wheel.png")); final Map<String, IAction> paletteActions = new HashMap<String, IAction>(11); CheckableActionGroup group = new CheckableActionGroup(); for (final String paletteName : names) { final Action action = new Action(paletteName, IAction.AS_CHECK_BOX) { @Override public void run() { try { setPreferenceColourMapChoice(paletteName); IPlottingSystem<Composite> system = PlottingFactory.getPlottingSystem(getPreferencePlaybackView()); if (system != null) { final Collection<ITrace> traces = system.getTraces(); if (traces != null) for (ITrace trace : traces) { if (trace instanceof IPaletteTrace) { IPaletteTrace paletteTrace = (IPaletteTrace) trace; paletteTrace.setPalette(paletteName); } } } } catch (Exception ne) { logger.error("Cannot create palette data!", ne); } } }; action.setId(paletteName); group.add(action); colorMenu.add(action); action.setChecked(paletteName.equals(schemeName)); paletteActions.put(paletteName, action); } colorMenu.setToolTipText("Histogram"); site.getActionBars().getMenuManager().add(colorMenu); // ImageExplorer preferences final Action openPreferences = new Action("Image Explorer Preferences...") { @Override public void run() { PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), ImageExplorerPreferencePage.ID, null, null); if (pref != null) pref.open(); } }; site.getActionBars().getMenuManager().add(openPreferences); }
/* (non-Javadoc) * Method declared on IViewPart. */ public void init(IViewSite site) throws PartInitException { site.getPage().addPostSelectionListener(this); super.init(site); }
public void init(IViewSite site) throws PartInitException { super.init(site); String secId = site.getSecondaryId(); serverId = CastUtil.cint(secId); }