List of usage examples for org.eclipse.jface.preference IPreferenceStore getInt
int getInt(String name);
From source file:net.sf.sveditor.ui.SVUiPlugin.java
License:Open Source License
public int getTabWidth() { IPreferenceStore chainedPrefs = SVUiPlugin.getDefault().getChainedPrefs(); int tab_width = chainedPrefs.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH); return tab_width; }
From source file:net.sf.sveditor.ui.SVUiPlugin.java
License:Open Source License
public int getIntegerPref(String id) { IPreferenceStore chainedPrefs = SVUiPlugin.getDefault().getChainedPrefs(); int val = chainedPrefs.getInt(id); return val; }
From source file:net.sf.sveditor.ui.text.spelling.SVSpellingProblem.java
License:Open Source License
@Override public ICompletionProposal[] getProposals(IQuickAssistInvocationContext context) { String[] arguments = getArguments(); if (arguments == null) return new ICompletionProposal[0]; if (arguments[0].indexOf('&') != -1 && isIgnoringAmpersand()) return new ICompletionProposal[0]; // no proposals for now IPreferenceStore pstore = SVUiPlugin.getDefault().getPreferenceStore(); final int threshold = pstore.getInt(PreferenceConstants.SPELLING_PROPOSAL_THRESHOLD); int size = 0; List<RankedWordProposal> proposals = null; /** TODO: Sv Implementation RankedWordProposal proposal= null;/* www . j a v a2s. c o m*/ IJavaCompletionProposal[] result= null; int index= 0; boolean fixed= false; boolean match= false; boolean sentence= false; final ISpellCheckEngine engine= SpellCheckEngine.getInstance(); final ISpellChecker checker= engine.getSpellChecker(); if (checker != null) { if (context == null) context= new TextInvocationContext(null, getOffset(), getLength()); else context= new TextInvocationContext(context.getSourceViewer(), getOffset(), getLength()); // FIXME: this is a pretty ugly hack fixed= arguments[0].charAt(0) == IHtmlTagConstants.HTML_TAG_PREFIX || arguments[0].charAt(0) == IJavaDocTagConstants.JAVADOC_TAG_PREFIX; if ((sentence && match) && !fixed) result= new IJavaCompletionProposal[] { new ChangeCaseProposal( arguments, getOffset(), getLength(), context, engine .getLocale()) }; else { proposals= new ArrayList<RankedWordProposal>(checker.getProposals(arguments[0], sentence)); size= proposals.size(); if (threshold > 0 && size > threshold) { Collections.sort(proposals); proposals= proposals .subList(size - threshold - 1, size - 1); size= proposals.size(); } boolean extendable= !fixed ? (checker.acceptsWords() || AddWordProposal.canAskToConfigure()) : false; result= new IJavaCompletionProposal[size + (extendable ? 3 : 2)]; for (index= 0; index < size; index++) { proposal= proposals.get(index); result[index]= new WordCorrectionProposal(proposal .getText(), arguments, getOffset(), getLength(), context, proposal.getRank()); } if (extendable) result[index++]= new AddWordProposal(arguments[0], context); result[index++]= new WordIgnoreProposal(arguments[0], context); result[index++]= new DisableSpellCheckingProposal(context); } } return result; */ return null; }
From source file:net.sf.versiontree.ui.Branch.java
License:Open Source License
/** * Creates a widget representing a branch. * @param arg0 the parent Component/*from ww w. j a v a 2 s.c o m*/ * @param arg1 style */ public Branch(Composite parent, int style) { super(parent, style); initializeImages(); IPreferenceStore prefs = VersionTreePlugin.getDefault().getPreferenceStore(); height = prefs.getInt(VersionTreePlugin.PREF_ELEMENT_HEIGHT); width = prefs.getInt(VersionTreePlugin.PREF_ELEMENT_WIDTH); // Parse background color String color = prefs.getString(VersionTreePlugin.PREF_BRANCH_BACKGROUNDCOLOR); int temp1 = color.indexOf(','); int temp2 = color.indexOf(',', temp1 + 1); background = new Color(null, Integer.valueOf(color.substring(0, temp1)).intValue(), Integer.valueOf(color.substring(temp1 + 1, temp2)).intValue(), Integer.valueOf(color.substring(temp2 + 1, color.length())).intValue()); // add paint listener addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { Branch.this.paintControl(e); } }); // add dispose listner addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { background.dispose(); } }); }
From source file:net.sf.versiontree.ui.Revision.java
License:Open Source License
/** * Creates a new revision widget./*from ww w . j a va2s.com*/ * @param parent * @param style */ public Revision(Composite parent, int style) { super(parent, style); initializeImages(); IPreferenceStore prefs = VersionTreePlugin.getDefault().getPreferenceStore(); height = prefs.getInt(VersionTreePlugin.PREF_ELEMENT_HEIGHT); width = prefs.getInt(VersionTreePlugin.PREF_ELEMENT_WIDTH); // add paint listener addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { Revision.this.paintControl(e); } }); // add dispose listner addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { background.dispose(); versionImage.dispose(); } }); }
From source file:net.sf.versiontree.ui.TreeView.java
License:Open Source License
/** * Reloads some layout relevant preferences from the PreferenceStore * to include any preference changes made in between. *//*from w ww. j a va2 s . com*/ private void reloadPrefrences() { IPreferenceStore prefs = VersionTreePlugin.getDefault().getPreferenceStore(); hspacing = prefs.getInt(VersionTreePlugin.PREF_HSPACING); vspacing = prefs.getInt(VersionTreePlugin.PREF_VSPACING); height = prefs.getInt(VersionTreePlugin.PREF_ELEMENT_HEIGHT); width = prefs.getInt(VersionTreePlugin.PREF_ELEMENT_WIDTH); }
From source file:net.sf.versiontree.ui.TreeViewConfig.java
License:Open Source License
/** * Loads the default configuration from the preference store. *//*from ww w .jav a 2 s .co m*/ public void loadDefaults() { IPreferenceStore prefs = VersionTreePlugin.getDefault().getPreferenceStore(); selectedLayout = prefs.getInt(VersionTreePlugin.PREF_ALGORITHM); drawEmptyBranches = prefs.getBoolean(VersionTreePlugin.PREF_EMPTY_BRANCHES); drawNABranches = prefs.getBoolean(VersionTreePlugin.PREF_NA_BRANCHES); direction = prefs.getInt(VersionTreePlugin.PREF_DIRECTION); }
From source file:net.sf.webcat.eclipse.cxxtest.internal.options.ConfigurationPropertyTester.java
License:Open Source License
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { IConfiguration configuration = (IConfiguration) receiver; if (PROP_CONFIGURATION_NAME.equals(property)) { return configuration.getName().equals(expectedValue); } else if (PROP_PREFERENCE.equals(property)) { IPreferenceStore store = CxxTestPlugin.getDefault().getPreferenceStore(); String key = CxxTestPlugin.PLUGIN_ID + ".preferences." + args[0]; //$NON-NLS-1$ String type = (String) args[1]; Object value = null;//from ww w. j a va 2s . c o m if ("boolean".equals(type)) //$NON-NLS-1$ { value = store.getBoolean(key); } else if ("int".equals(type)) //$NON-NLS-1$ { value = store.getInt(key); } else if ("long".equals(type)) //$NON-NLS-1$ { value = store.getLong(key); } else if ("string".equals(type)) //$NON-NLS-1$ { value = store.getString(type); } else if ("float".equals(type)) //$NON-NLS-1$ { value = store.getFloat(type); } else if ("double".equals(type)) //$NON-NLS-1$ { value = store.getDouble(type); } return expectedValue.equals(value); } else if (PROP_EVALUATE_PREDICATE.equals(property)) { String typename = (String) args[0]; try { @SuppressWarnings("unchecked") Class<? extends IExtraOptionsEnablement> klass = (Class<? extends IExtraOptionsEnablement>) Class .forName(typename); IExtraOptionsEnablement predicate = klass.newInstance(); boolean value = predicate.shouldProcessOptions(configuration.getOwner().getProject(), configuration); return expectedValue.equals(value); } catch (Exception e) { e.printStackTrace(); } return false; } else { assert false; return false; } }
From source file:net.sourceforge.eclipsetrader.charts.preferences.ChartsPrefereces.java
License:Open Source License
protected void performDefaults() { IPreferenceStore pluginPreferences = ChartsPlugin.getDefault().getPreferenceStore(); int autoHideTabs = pluginPreferences.getInt(ChartsPlugin.PREFS_HIDE_TABS); never.setSelection(autoHideTabs == ChartView.HIDE_TABS_NEVER); onlyOne.setSelection(autoHideTabs == ChartView.HIDE_TABS_ONLYONE); extendScale.setSelection(pluginPreferences.getInt(ChartsPlugin.PREFS_EXTEND_SCALE)); extendPeriod.setSelection(pluginPreferences.getInt(ChartsPlugin.PREFS_EXTEND_PERIOD)); updateTree();// ww w .java2s . c om super.performDefaults(); }
From source file:net.sourceforge.eclipsetrader.charts.views.ChartView.java
License:Open Source License
public void createPartControl(Composite parent) { DropTarget target = new DropTarget(parent, DND.DROP_COPY | DND.DROP_MOVE); target.setTransfer(new Transfer[] { SecurityTransfer.getInstance() }); target.addDropListener(dropTargetListener); IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager(); themeManager.addPropertyChangeListener(themeChangeListener); theme = themeManager.getCurrentTheme(); theme.addPropertyChangeListener(themeChangeListener); Composite content = new Composite(parent, SWT.H_SCROLL); GridLayout gridLayout = new GridLayout(); gridLayout.marginWidth = gridLayout.marginHeight = 2; gridLayout.horizontalSpacing = gridLayout.verticalSpacing = 0; content.setLayout(gridLayout);/*w ww .j ava 2 s .c om*/ content.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { if (e.detail == SWT.TRAVERSE_ESCAPE) { newChartObject = null; sashForm.setCursor(null); } } }); sashForm = new SashForm(content, SWT.VERTICAL); sashForm.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 1, 1)); datePlot = new DatePlot(content, SWT.NONE); GridData gridData = new GridData(); gridData.heightHint = 24; gridData.grabExcessHorizontalSpace = true; gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; datePlot.setLayoutData(gridData); datePlot.setForeground(theme.getColorRegistry().get(ChartView.THEME_PERIOD_FOREGROUND)); datePlot.setBackground(theme.getColorRegistry().get(ChartView.THEME_PERIOD_BACKGROUND)); datePlot.getIndicatorPlot().addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { updateScrollbar(); } }); datePlot.getIndicatorPlot().addPlotListener(new PlotListener() { public void plotResized(PlotEvent e) { updateScrollbar(); } }); hBar = content.getHorizontalBar(); hBar.setVisible(false); hBar.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Rectangle plotBounds = datePlot.getIndicatorPlot().getPlotBounds(); int hSelection = hBar.getSelection(); plotBounds.x = -hSelection; datePlot.getIndicatorPlot().setPlotBounds(plotBounds); setPlotBounds(plotBounds); } }); getSite().setSelectionProvider(new ChartSelectionProvider()); getSite().getSelectionProvider().setSelection(new NullSelection()); getSite().getPage().addSelectionListener(this); IActionBars actionBars = getViewSite().getActionBars(); actionBars.setGlobalActionHandler("settings", new Action() { //$NON-NLS-1$ public void run() { ChartSettingsDialog dlg = new ChartSettingsDialog(getChart(), getViewSite().getShell()); dlg.open(); } }); actionBars.setGlobalActionHandler("cut", cutAction = new CutAction(this)); //$NON-NLS-1$ actionBars.setGlobalActionHandler("copy", copyAction = new CopyAction(this)); //$NON-NLS-1$ actionBars.setGlobalActionHandler("paste", pasteAction = new PasteAction(this)); //$NON-NLS-1$ actionBars.setGlobalActionHandler("pasteSpecial", pasteSpecialAction = new PasteSpecialAction(this)); //$NON-NLS-1$ actionBars.setGlobalActionHandler("delete", deleteAction = new DeleteAction(this)); //$NON-NLS-1$ Integer id = new Integer(Integer.parseInt(getViewSite().getSecondaryId())); chart = (Chart) CorePlugin.getRepository().load(Chart.class, id); preferences = new PreferenceStore(getPreferenceStoreLocation(chart).toOSString()); preferences.setDefault(PREFS_FOLLOW_SELECTION, DEFAULT_FOLLOW_SELECTION); preferences.setDefault(PREFS_SHOW_ADJUSTED_VALUES, DEFAULT_SHOW_ADJUSTED_VALUES); preferences.setDefault(PREFS_SHOW_MARKETVALUE, DEFAULT_SHOW_MARKET_VALUE); try { preferences.load(); } catch (Exception e) { } security = chart.getSecurity(); setPartName(chart.getTitle() + ": " + security.getDescription()); updateTitleTooltip(); autoScale = chart.isAutoScale(); followSelection = preferences.getBoolean(PREFS_FOLLOW_SELECTION); showAdjustedValues = preferences.getBoolean(PREFS_SHOW_ADJUSTED_VALUES); showMarketValue = preferences.getBoolean(PREFS_SHOW_MARKETVALUE); updateActionBars(); IPreferenceStore pluginPreferences = ChartsPlugin.getDefault().getPreferenceStore(); datePlot.setExtendPeriod(pluginPreferences.getInt(ChartsPlugin.PREFS_EXTEND_PERIOD)); pluginPreferences.addPropertyChangeListener(pluginPropertiesChangeListener); try { sashForm.getDisplay().asyncExec(new Runnable() { public void run() { datePlot.setInterval(chart.getCompression()); if (datePlot.getInterval() < BarData.INTERVAL_DAILY) datePlot.setBarData(new BarData(security.getIntradayHistory().getList()) .getCompressed(datePlot.getInterval())); else { int period = chart.getPeriod(); int size = security.getHistory().size(); BarData barData = new BarData(showAdjustedValues ? security.getAdjustedHistory().getList() : security.getHistory().getList()); if (period != PERIOD_ALL && size != 0) { Date end = barData.getEnd(); Calendar calendar = Calendar.getInstance(); calendar.setTime(end); switch (period) { case PERIOD_LAST6MONTHS: calendar.add(Calendar.MONTH, -6); break; case PERIOD_LASTYEAR: calendar.add(Calendar.MONTH, -12); break; case PERIOD_LAST2YEARS: calendar.add(Calendar.MONTH, -24); break; case PERIOD_CUSTOM: calendar.setTime(chart.getBeginDate()); end = chart.getEndDate(); break; } barData = barData.getPeriod(calendar.getTime(), end); } if (datePlot.getInterval() != BarData.INTERVAL_DAILY) barData = barData.getCompressed(datePlot.getInterval()); datePlot.setBarData(barData); } /* Calendar day = Calendar.getInstance(); for (Iterator iter = datePlot.getBarData().iterator(); iter.hasNext(); ) { Bar bar = (Bar)iter.next(); day.setTime(bar.getDate()); System.out.println("day.set(" + day.get(Calendar.YEAR) + ", " + day.get(Calendar.MONTH) + ", " + day.get(Calendar.DAY_OF_MONTH) + ", 0, 0, 0);"); System.out.println("barData.append(new Bar(day.getTime(), " + bar.getOpen() + ", " + bar.getHigh() + ", " + bar.getLow() + ", " + bar.getClose() + ", " + bar.getVolume() + "));"); }*/ try { for (int r = 0; r < chart.getRows().size(); r++) itemAdded(chart.getRows().get(r)); chart.getRows().addCollectionObserver(ChartView.this); chart.addObserver(chartUpdateObserver); } catch (Exception e) { e.printStackTrace(); } updateObservers(); String[] values = preferences.getString(PREFS_WEIGHTS).split(";"); //$NON-NLS-1$ int weights[] = new int[values.length]; if (weights.length == tabGroups.size()) { for (int i = 0; i < weights.length; i++) weights[i] = Integer.parseInt(values[i]); sashForm.setWeights(weights); } else if (tabGroups.size() != 0) { weights = new int[tabGroups.size()]; int w = 100 / (weights.length + 2); weights[0] = 100 - w * (weights.length - 1); for (int i = 1; i < weights.length; i++) weights[i] = w; sashForm.setWeights(weights); } Control[] controls = sashForm.getChildren(); for (int i = 0; i < controls.length; i++) { if (controls[i] instanceof ChartTabFolder) controls[i].addControlListener(sashResizeListener); } if (showMarketValue) { security.getQuoteMonitor().addObserver(quoteObserver); quoteObserver.update(security, security.getQuote()); FeedMonitor.monitor(security); } boolean askInitialUpdate = false; if (datePlot.getInterval() < BarData.INTERVAL_DAILY) askInitialUpdate = (security.getIntradayHistory().size() == 0); else askInitialUpdate = (security.getHistory().size() == 0); if (askInitialUpdate) { if (MessageDialog.openQuestion(getViewSite().getShell(), chart.getTitle(), Messages.ChartView_NoDataMessage)) { String id = ""; //$NON-NLS-1$ if (chart.getSecurity().getHistoryFeed() != null) id = chart.getSecurity().getHistoryFeed().getId(); final IHistoryFeed feed = CorePlugin.createHistoryFeedPlugin(id); if (feed != null) { Job job = new Job(Messages.ChartView_UpdateChartMessage) { protected IStatus run(IProgressMonitor monitor) { monitor.beginTask(Messages.ChartView_UpdatingMessage + chart.getSecurity().getDescription(), 1); int interval = IHistoryFeed.INTERVAL_DAILY; if (getInterval() < BarData.INTERVAL_DAILY) interval = IHistoryFeed.INTERVAL_MINUTE; feed.updateHistory(chart.getSecurity(), interval); monitor.worked(1); monitor.done(); return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); } } } } }); } catch (Exception e) { e.printStackTrace(); } try { sashForm.getDisplay().asyncExec(new Runnable() { public void run() { } }); } catch (Exception e) { e.printStackTrace(); } }