public void createPeriodActions() { try { JAXBContext jaxbContext = JAXBContext.newInstance(PeriodList.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); StringReader stream = new StringReader( UIActivator.getDefault() .getPreferenceStore() .getString(UIActivator.PREFS_CHART_PERIODS)); PeriodList list = (PeriodList) unmarshaller.unmarshal(stream); Collections.sort( list, new Comparator<Period>() { @Override public int compare(Period o1, Period o2) { if (o1.getPeriod().higherThan(o2.getPeriod())) { return -1; } if (o2.getPeriod().higherThan(o1.getPeriod())) { return 1; } return 0; } }); periodActions = new ContributionItem[list.size()]; for (int i = 0; i < periodActions.length; i++) { periodActions[i] = new ContributionItem(list.get(i)); } } catch (Exception e) { e.printStackTrace(); } }
/* (non-Javadoc) * @see org.eclipse.ui.part.WorkbenchPart#dispose() */ @Override public void dispose() { view.removeViewChangeListener(viewChangeListener); if (subsetHistory != null) { PropertyChangeSupport propertyChangeSupport = (PropertyChangeSupport) subsetHistory.getAdapter(PropertyChangeSupport.class); if (propertyChangeSupport != null) { propertyChangeSupport.removePropertyChangeListener(propertyChangeListener); } } if (UIActivator.getDefault() != null) { IPreferenceStore preferences = UIActivator.getDefault().getPreferenceStore(); preferences.removePropertyChangeListener(preferenceChangeListener); } super.dispose(); }
/* (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(); }
public NavigatorLabelProvider() { if (UIActivator.getDefault() != null) { folderIcon = UIActivator.getDefault().getImageRegistry().get(UIConstants.FOLDER_OBJECT); blankIcon = UIActivator.getDefault().getImageRegistry().get(UIConstants.BLANK_OBJECT); marketIcon = UIActivator.getDefault().getImageRegistry().get(UIConstants.MARKET_FOLDER); securityIcon = UIActivator.getDefault().getImageRegistry().get(UIConstants.REPOSITORY_OBJECT); watchListIcon = UIActivator.getDefault().getImageRegistry().get(UIConstants.REPOSITORY_OBJECT); } }
/* (non-Javadoc) * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) */ @Override protected Control createContents(Composite parent) { Composite content = new Composite(parent, SWT.NONE); GridLayout gridLayout = new GridLayout(1, false); gridLayout.marginWidth = gridLayout.marginHeight = 0; content.setLayout(gridLayout); initializeDialogUnits(content); providers = new SecuritySelectionControl(content); providers.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); providers.setInput(UIActivator.getDefault().getRepositoryService().getSecurities()); performDefaults(); return content; }
protected void doUpdate() { TimeSpan[] aggregation = new TimeSpan[] { TimeSpan.days(1), TimeSpan.minutes(1), }; IDialogSettings dialogSettings = UIActivator.getDefault().getDialogSettings().getSection(ImportDataPage.class.getName()); if (dialogSettings != null) { String[] s = dialogSettings.getArray("AGGREGATION"); if (s != null && s.length != 0) { aggregation = new TimeSpan[s.length]; for (int i = 0; i < aggregation.length; i++) { aggregation[i] = TimeSpan.fromString(s[i]); } } } DataImportJob job = new DataImportJob(security, DataImportJob.INCREMENTAL, null, null, aggregation); job.setUser(true); job.schedule(); }
protected IRepositoryService getRepositoryService() { return UIActivator.getDefault().getRepositoryService(); }
/* (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(); }