@Override public void init ( final IViewSite site, final IMemento memento ) throws PartInitException { if ( memento != null ) { this.connectionId = memento.getString ( CONNECTION_ID ); this.connectionUri = memento.getString ( CONNECTION_URI ); } super.init ( site, memento ); try { // it is OK to fail at this stage reInitializeConnection ( this.connectionId, this.connectionUri ); } catch ( final Exception e ) { logger.warn ( "init () - couldn't recreate connection", e ); //$NON-NLS-1$ // just reset all values this.connectionId = null; this.connectionUri = null; this.connectionService = null; this.connectionTracker = null; } }
@Override public void initialize(final ISynchronizePageConfiguration configuration) { super.initialize(configuration); site = configuration.getSite(); final IWorkbenchSite ws = site.getWorkbenchSite(); if (ws instanceof IViewSite) { this.configuration = configuration; final Shell shell = site.getShell(); customCompareAction = new ExternalCompareAction(shell); undoAction = new UndoPendingChangeAction(shell); getLatestAction = new GetLatestAction(shell); getSpecificAction = new GetSpecificAction(shell); checkoutAction = new CheckoutAction(shell); undoAction = new UndoPendingChangeAction(shell); checkinAction = new CheckinAction(shell); historyAction = new ViewHistoryAction(shell); } else { this.configuration = null; } }
private IStatusLineManager getStatusLineManager() { IWorkbench wb = PlatformUI.getWorkbench(); IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); IWorkbenchPage page = win.getActivePage(); IWorkbenchPart part = page.getActivePart(); if (part == null) return null; IWorkbenchPartSite site = part.getSite(); IActionBars actionBars = null; if (site instanceof IEditorSite) actionBars = ((IEditorSite) site).getActionBars(); else if (site instanceof IViewSite) actionBars = ((IViewSite) site).getActionBars(); if (actionBars == null) return null; return actionBars.getStatusLineManager(); }
private IStatusLineManager getStatusLineManager() { IWorkbench wb = PlatformUI.getWorkbench(); IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); IWorkbenchPage page = win.getActivePage(); if (page == null) return null; IWorkbenchPart part = page.getActivePart(); if (part == null) return null; IWorkbenchPartSite site = part.getSite(); IActionBars actionBars = null; if (site instanceof IEditorSite) actionBars = ((IEditorSite) site).getActionBars(); else if (site instanceof IViewSite) actionBars = ((IViewSite) site).getActionBars(); if (actionBars == null) return null; return actionBars.getStatusLineManager(); }
@Override public void init(IPageBookViewPage page, IConsole console) { IPageSite pageSite = page.getSite(); IWorkbenchPage workbenchPage = pageSite.getPage(); IViewPart viewPart = workbenchPage.findView(IConsoleConstants.ID_CONSOLE_VIEW); IViewSite viewSite = viewPart.getViewSite(); IActionBars actionBars = viewSite.getActionBars(); IToolBarManager toolBarManager = actionBars.getToolBarManager(); IContributionItem[] items = toolBarManager.getItems(); for(int i = 0; i < items.length; ++i) { IContributionItem item = items[i]; if(item instanceof ActionContributionItem) { IAction action = ((ActionContributionItem) item).getAction(); String text = action.getText(); if(text.equals("Pi&n Console") || text.equals("Open Console")) toolBarManager.remove(item); } } }
static IStatusLineManager getStatusLineManager() { try { IWorkbenchPartSite site = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getActivePart().getSite(); return ((IViewSite) site).getActionBars().getStatusLineManager(); } catch (Exception e) { // try to get the IStatusLineManager through an active editor try { return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() .getEditorSite().getActionBars().getStatusLineManager(); } catch (Exception e1) { } } return null; }
@Override public void init(IViewSite site) throws PartInitException { super.init(site); ZooKeeperActivator plugin = ZooKeeperActivator.getDefault(); plugin.getZooKeeperConnectionModelManager().getModels(); }
@Override public void init(IViewSite site) throws PartInitException { super.init(site); JmxActivator plugin = JmxActivator.getDefault(); plugin.getJmxConnectionModelManager().getModels(); }
private void hookContextMenu ( final IViewSite viewSite ) { final MenuManager menuMgr = new MenuManager ( "#PopupMenu" ); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown ( true ); menuMgr.addMenuListener ( new IMenuListener () { @Override public void menuAboutToShow ( final IMenuManager manager ) { fillContextMenu ( manager ); } } ); final Menu menu = menuMgr.createContextMenu ( this.viewer.getControl () ); this.viewer.getControl ().setMenu ( menu ); viewSite.registerContextMenu ( menuMgr, this.viewer ); }
@Override public void init ( final IViewSite site, final IMemento memento ) throws PartInitException { super.init ( site, memento ); if ( memento == null ) { return; } final IMemento child = memento.getChild ( CHILD_CONFIGURATION ); if ( child == null ) { return; } final String data = child.getTextData (); if ( data == null || data.isEmpty () ) { return; } try { this.configuration = load ( new ByteArrayInputStream ( Base64.decodeBase64 ( data ) ) ); } catch ( final Exception e ) { StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ), StatusManager.LOG ); } }
@Override public void init ( final IViewSite site, final IMemento memento ) throws PartInitException { super.init ( site, memento ); if ( memento != null ) { final String s = memento.getString ( "columnSettings" ); //$NON-NLS-1$ if ( s != null ) { this.initialColumnSettings = this.gson.fromJson ( s, new TypeToken<List<ColumnProperties>> () {}.getType () ); } } }
public MonitorsViewTable ( final Composite parent, final IViewSite viewSite, final int style, final WritableSet monitors, final List<ColumnProperties> columnSettings ) { super ( parent, style ); this.monitors = monitors; final FillLayout layout = new FillLayout (); setLayout ( layout ); this.tableViewer = new TableViewer ( this, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI ); this.tableRef.set ( this.tableViewer ); createColumns ( this.tableViewer ); applyColumSettings ( columnSettings ); this.tableViewer.getTable ().setHeaderVisible ( true ); this.tableViewer.getTable ().setLinesVisible ( true ); this.tableViewer.setUseHashlookup ( true ); this.tableViewer.setSorter ( new Sorter ( Columns.LAST_FAIL_TIMESTAMP, SWT.DOWN ) ); this.tableViewer.getTable ().setSortDirection ( SWT.DOWN ); hookContextMenu ( this.tableViewer.getControl (), this.tableViewer, viewSite ); viewSite.setSelectionProvider ( this.tableViewer ); final ObservableSetContentProvider contentProvider = new ObservableSetContentProvider (); this.tableViewer.setContentProvider ( contentProvider ); this.tableViewer.setLabelProvider ( new MonitorTableLabelProvider ( Properties.observeEach ( contentProvider.getKnownElements (), BeanProperties.values ( new String[] { "id", "monitor" } ) ), Settings.getTimeZone () ) ); //$NON-NLS-1$ //$NON-NLS-2$ this.tableViewer.setInput ( this.monitors ); contentProvider.getRealizedElements ().addSetChangeListener ( new ISetChangeListener () { @Override public void handleSetChange ( final SetChangeEvent event ) { if ( !MonitorsViewTable.this.scrollLock ) { MonitorsViewTable.this.tableViewer.getTable ().setTopIndex ( 0 ); } } } ); }
protected void hookContextMenu ( final Control control, final ISelectionProvider selectionProvider, final IViewSite viewSite ) { final MenuManager menuMgr = new MenuManager ( "#PopupMenu" ); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown ( true ); menuMgr.addMenuListener ( new IMenuListener () { @Override public void menuAboutToShow ( final IMenuManager manager ) { fillContextMenu ( manager ); } } ); final Menu menu = menuMgr.createContextMenu ( control ); control.setMenu ( menu ); viewSite.registerContextMenu ( menuMgr, selectionProvider ); }
/** * Actions in addition to the standard plotting actions which * should be shown on the plot. * * @param site */ private void createActions(IViewSite site) { IActionBars bars = site.getActionBars(); final List<IContributionManager> mans = Arrays.asList(bars.getToolBarManager(), bars.getMenuManager()); final IAction configureAxes = new Action("Configure...", Activator.getImageDescriptor("icons/home-for-sale-sign-blue.png")) { @Override public void run() { try { IModelDialog<AxisConfiguration> dialog = ServiceHolder.getInterfaceService().createModelDialog(site.getShell()); dialog.setPreamble("Please define the axes and their ranges we will map within."); dialog.create(); dialog.setSize(550,450); // As needed dialog.setText("Scan Area"); dialog.setModel(getAxisConfiguration()); int ok = dialog.open(); if (ok==IModelDialog.OK) { AxisConfiguration conf = dialog.getModel(); setAxisConfiguration(conf); } } catch (Exception ne) { ErrorDialog.openError(site.getShell(), "Error Showing Plot Configuration", "Please contact your support representative.", new Status(IStatus.ERROR, "org.eclipse.scanning.device.ui", ne.getMessage(), ne)); logger.error("Cannot configure plot!", ne); } } }; ViewUtil.addGroups("configure", mans, configureAxes); }
@Override public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site, memento); if (stash.isStashed()) { try { final List<IScanPathModel> models = stash.unstash(List.class); setPath(models); } catch (Exception e) { logger.error("Cannot load generators to memento!", e); } } }
/** * Shows the specified view in the workbench. * * @param viewPart * The view to show. */ public static void showView(final IViewPart viewPart) { Check.notNull(viewPart, "viewPart"); //$NON-NLS-1$ try { final IViewSite viewSite = viewPart.getViewSite(); viewSite.getPage().showView(viewSite.getId()); } catch (final PartInitException e) { final String messageFormat = "Could not create view part {0}"; //$NON-NLS-1$ final String message = MessageFormat.format(messageFormat, viewPart.getViewSite().getId()); log.warn(message, e); } }
@Override public boolean performFinish() { final SynchronizeParticipant syncParticipant = new SynchronizeParticipant(); final ISynchronizeManager syncManager = TeamUI.getSynchronizeManager(); syncManager.addSynchronizeParticipants(new ISynchronizeParticipant[] { syncParticipant }); final ISynchronizeView syncView = syncManager.showSynchronizeViewInActivePage(); syncView.display(syncParticipant); final IResource[] roots = resourceSelectionPage.getRootResources(); syncParticipant.getSubscriberSyncInfoCollector().setRoots(roots); /* Reflection for eclipse 3.0 compat */ final IViewSite viewSite = syncView.getViewSite(); try { final Method getPartMethod = viewSite.getClass().getMethod("getPart", new Class[0]); //$NON-NLS-1$ final Object viewSitePart = getPartMethod.invoke(viewSite, new Object[0]); if (viewSitePart != null && viewSitePart instanceof IWorkbenchPart) { syncParticipant.run((IWorkbenchPart) viewSitePart); } } catch (final Exception e) { /* Suppress */ } return true; }
@Override public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site); if (memento != null) { String u = memento.getString(IBrowserConstants.MEMENTO_URL); if (u != null) { initialUrl = u; } } }
@Override public void init(IViewSite site) throws PartInitException { super.init(site); RuntimeModel.getInstance(); if (textListener == null) { textListener = new SelectionListener(); ISelectionService service = site.getWorkbenchWindow() .getSelectionService(); service.addPostSelectionListener(textListener); } }
@Override public void init(IViewSite site) throws PartInitException { RuntimeModel.getInstance(); super.init(site); if (interfaceListener == null) { interfaceListener = new InterfaceListener(); ISelectionService service = site.getWorkbenchWindow() .getSelectionService(); service.addPostSelectionListener(interfaceListener); } }
public void init(IViewSite site) throws PartInitException { super.init(site); // Register a SLP to refresh the obligation view once it has been // created. This used to be done as part of the // ProverSpecLifecycleParticipant. However, the PSLP is created from an // Extension Point which means it potentially runs *before* the UI is // fully initialized. If this is interleaved with a spec open event, it // means the UIHelper.runUIAsync(..) tries to create a UI and then // nullpointers. // See dipose() where the lifecycle participant is de-registered again. // It should be safe to receive events even if the Obligations View // isn't open, but it's good practice to remove listeners past disposal. // Even if it just saves a few CPU cycles in an hour. Activator.getSpecManager().addSpecLifecycleParticipant(specLifecycleParticipant); }
@Override public void createStatisticUI(final Composite parent, final IViewSite viewSite) { // create chart _chart = new Chart(parent, SWT.FLAT); _chart.setShowZoomActions(true); _chart.setToolBarManager(viewSite.getActionBars().getToolBarManager(), false); }
protected Font getFont() { IViewSite _viewSite = this.getViewSite(); Shell _shell = _viewSite.getShell(); Display _display = _shell.getDisplay(); final Font font = new Font(_display, "Courier", 14, 0); this.swtResources.add(font); return font; }
public void init(IViewSite site) throws PartInitException { super.init(site); String secId = site.getSecondaryId(); String[] ids = secId.split("&"); serverId = Integer.valueOf(ids[0]); objHash = Integer.valueOf(ids[1]); title = ids[2]; for (int i = 3; i < ids.length; i++) { counters.add(ids[i]); } }
public void init(IViewSite site) throws PartInitException { super.init(site); String secId = site.getSecondaryId(); String ids[] = secId.split("&"); this.serverId = CastUtil.cint(ids[0]); this.objHash = CastUtil.cint(ids[1]); }
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]; }
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]; }
public void init(IViewSite site) throws PartInitException { super.init(site); String secondaryId = site.getSecondaryId(); if (secondaryId != null) { String secIds[] = secondaryId.split("_"); serverId = Integer.parseInt(secIds[0]); objHash = Integer.parseInt(secIds[1]); } }
public void init(IViewSite site) throws PartInitException { super.init(site); String secId = site.getSecondaryId(); if (secId != null) { serverId = Integer.parseInt(secId); } }
public void init(IViewSite site) throws PartInitException { super.init(site); String secId = site.getSecondaryId(); String[] ids = secId.split("&"); serverId = Integer.valueOf(ids[0]); objHash = Integer.valueOf(ids[1]); }
public void init(IViewSite site) throws PartInitException { super.init(site); String secondId = site.getSecondaryId(); if (secondId != null) { String[] tokens = StringUtil.tokenizer(secondId, "&"); this.objHash = CastUtil.cint(tokens[0]); } }
@Override public void createStatisticUI(final Composite parent, final IViewSite viewSite) { // create statistic page _statisticPage = new Composite(parent, SWT.FLAT); _statisticPage.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // remove colored border _statisticPage.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); final GridLayout gl = new GridLayout(2, true); gl.marginHeight = 0; gl.marginWidth = 0; gl.verticalSpacing = 0; gl.horizontalSpacing = 0; _statisticPage.setLayout(gl); _chartDistanceCounter = new Chart(_statisticPage, SWT.NONE); _chartDistanceSum = new Chart(_statisticPage, SWT.NONE); _chartAltitudeCounter = new Chart(_statisticPage, SWT.NONE); _chartAltitudeSum = new Chart(_statisticPage, SWT.NONE); _chartDurationCounter = new Chart(_statisticPage, SWT.NONE); _chartDurationSum = new Chart(_statisticPage, SWT.NONE); _chartDistanceCounter.setToolBarManager(viewSite.getActionBars().getToolBarManager(), true); addPrefListener(parent); getPreferences(); }
@Override public void createStatisticUI(final Composite parent, final IViewSite viewSite) { super.createStatisticUI(parent, viewSite); addPrefListener(parent); getPreferences(); }