List of usage examples for org.eclipse.jface.preference IPreferenceStore getInt
int getInt(String name);
From source file:com.nokia.tools.ui.dialog.ResourceSelectionDialog.java
License:Open Source License
/** * Initializes the all control sizes./*w w w . j a v a2 s . c o m*/ */ private void initialSizes() { IPreferenceStore store = UIPreferences.getStore(); previewSize = store.getInt(UIPreferences.PREF_PREVIEW_SIZE_RESOURCE_PAGE); if (previewSize <= 0) { previewSize = PREVIEW_SMALL_SIZE; } GridData gd = (GridData) previewCanvas.getLayoutData(); gd.widthHint = previewSize; previewCanvas.setLayoutData(gd); gd = (GridData) previewArea.getLayoutData(); Point p = previewArea.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); gd.widthHint = p.x; gd.heightHint = p.y; previewArea.setLayoutData(gd); gd = (GridData) previewArea.getParent().getLayoutData(); gd.widthHint = store.getInt(UIPreferences.PREF_LAST_WIDTH_RESOURCE_PAGE); gd.heightHint = store.getInt(UIPreferences.PREF_LAST_HEIGHT_RESOURCE_PAGE); previewArea.getParent().setLayoutData(gd); previewArea.layout(); previewArea.getParent().layout(); }
From source file:com.nokia.tools.ui.dialog.ResourceSelectionDialog.java
License:Open Source License
@Override public int open() { IPreferenceStore store = UIPreferences.getStore(); int x = store.getInt(UIPreferences.PREF_LAST_XPOS_IMAGESELECTION_DIALOG); int y = store.getInt(UIPreferences.PREF_LAST_YPOS_IMAGESELECTION_DIALOG); Shell shell = this.getShell(); if (shell == null || shell.isDisposed()) { shell = null;//from w w w. ja va 2 s.c o m create(); shell = this.getShell(); } if (x == y && y == -9999) getInitialLocation(shell.getSize()); else shell.setLocation(x, y); return super.open(); }
From source file:com.nokia.trace.eventview.TraceEventView.java
License:Open Source License
/** * Configures the widgets/*w w w .j av a 2s . c o m*/ */ void configureWidgets() { // Get preference store from the plugin IPreferenceStore preferences = Activator.getDefault().getPreferenceStore(); // Set description column width int value = preferences.getInt(DESCRIPTION_WIDTH_CONFIGURATION); if (value > 0) { descriptionColumn.setWidth(value); } else { descriptionColumn.setWidth(DEFAULT_DESCRIPTION_WIDTH); } // Set category column width value = preferences.getInt(CATEGORY_WIDTH_CONFIGURATION); if (value > 0) { categoryColumn.setWidth(value); } else { categoryColumn.setWidth(DEFAULT_CATEGORY_WIDTH); } // Set source column width value = preferences.getInt(SOURCE_WIDTH_CONFIGURATION); if (value > 0) { sourceColumn.setWidth(value); } else { sourceColumn.setWidth(DEFAULT_SOURCE_WIDTH); } // Set type column width value = preferences.getInt(TYPE_WIDTH_CONFIGURATION); if (value > 0) { typeColumn.setWidth(value); } else { typeColumn.setWidth(DEFAULT_TYPE_WIDTH); } }
From source file:com.nokia.traceviewer.view.TracePropertyView.java
License:Open Source License
/** * Configures the table column sizes/*from ww w. jav a 2s .co m*/ */ private void configureWidgets() { // Get preference store from the plugin IPreferenceStore preferences = TraceViewerPlugin.getDefault().getPreferenceStore(); // Set line count rule name column width int value = preferences.getInt(LINECOUNTNAME_WIDTH_CONFIGURATION); if (value > 0) { lineCountRuleNameColumn.setWidth(value); } else { lineCountRuleNameColumn.setWidth(LINECOUNTTABLE_RULE_COLUMN_SIZE); } // Set line count occurrences column width value = preferences.getInt(LINECOUNTOCCURRENCES_WIDTH_CONFIGURATION); if (value > 0) { lineCountOccurrencesColumn.setWidth(value); } else { lineCountOccurrencesColumn.setWidth(LINECOUNTTABLE_OCCURRENCES_COLUMN_SIZE); } // Set variable tracing rule name column width value = preferences.getInt(VARIABLENAME_WIDTH_CONFIGURATION); if (value > 0) { variableTracingRuleNameColumn.setWidth(value); } else { variableTracingRuleNameColumn.setWidth(VARIABLETABLE_RULE_COLUMN_SIZE); } // Set variable tracing value column width value = preferences.getInt(VARIABLEVALUE_WIDTH_CONFIGURATION); if (value > 0) { variableTracingValueColumn.setWidth(value); } else { variableTracingValueColumn.setWidth(VARIABLETABLE_VALUE_COLUMN_SIZE); } }
From source file:com.opcoach.training.rental.diagram.providers.RentalViewProvider.java
/** * @generated/*w ww . j ava 2 s. c o m*/ */ public Edge createRentalCustomer_4001(View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Connector edge = NotationFactory.eINSTANCE.createConnector(); edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); ArrayList<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2); points.add(new RelativeBendpoint()); points.add(new RelativeBendpoint()); bendpoints.setPoints(points); edge.setBendpoints(bendpoints); ViewUtil.insertChildView(containerView, edge, index, persisted); edge.setType(RentalVisualIDRegistry.getType(RentalCustomerEditPart.VISUAL_ID)); edge.setElement(null); // initializePreferences final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_LINE_COLOR); ViewUtil.setStructuralFeatureValue(edge, NotationPackage.eINSTANCE.getLineStyle_LineColor(), FigureUtilities.RGBToInteger(lineRGB)); FontStyle edgeFontStyle = (FontStyle) edge.getStyle(NotationPackage.Literals.FONT_STYLE); if (edgeFontStyle != null) { FontData fontData = PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT); edgeFontStyle.setFontName(fontData.getName()); edgeFontStyle.setFontHeight(fontData.getHeight()); edgeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0); edgeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0); org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR); edgeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue()); } Routing routing = Routing.get(prefStore.getInt(IPreferenceConstants.PREF_LINE_STYLE)); if (routing != null) { ViewUtil.setStructuralFeatureValue(edge, NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing); } Node label6001 = createLabel(edge, RentalVisualIDRegistry.getType(WrappingLabelEditPart.VISUAL_ID)); label6001.getStyles().add(NotationFactory.eINSTANCE.createDescriptionStyle()); label6001.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); Location location6001 = (Location) label6001.getLayoutConstraint(); location6001.setX(0); location6001.setY(40); return edge; }
From source file:com.opcoach.training.rental.diagram.providers.RentalViewProvider.java
/** * @generated/*from w w w. j a va2s . co m*/ */ public Edge createRentalRentedObject_4002(View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Connector edge = NotationFactory.eINSTANCE.createConnector(); edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); ArrayList<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2); points.add(new RelativeBendpoint()); points.add(new RelativeBendpoint()); bendpoints.setPoints(points); edge.setBendpoints(bendpoints); ViewUtil.insertChildView(containerView, edge, index, persisted); edge.setType(RentalVisualIDRegistry.getType(RentalRentedObjectEditPart.VISUAL_ID)); edge.setElement(null); // initializePreferences final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_LINE_COLOR); ViewUtil.setStructuralFeatureValue(edge, NotationPackage.eINSTANCE.getLineStyle_LineColor(), FigureUtilities.RGBToInteger(lineRGB)); FontStyle edgeFontStyle = (FontStyle) edge.getStyle(NotationPackage.Literals.FONT_STYLE); if (edgeFontStyle != null) { FontData fontData = PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT); edgeFontStyle.setFontName(fontData.getName()); edgeFontStyle.setFontHeight(fontData.getHeight()); edgeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0); edgeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0); org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR); edgeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue()); } Routing routing = Routing.get(prefStore.getInt(IPreferenceConstants.PREF_LINE_STYLE)); if (routing != null) { ViewUtil.setStructuralFeatureValue(edge, NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing); } Node label6002 = createLabel(edge, RentalVisualIDRegistry.getType(WrappingLabel2EditPart.VISUAL_ID)); label6002.getStyles().add(NotationFactory.eINSTANCE.createDescriptionStyle()); label6002.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); Location location6002 = (Location) label6002.getLayoutConstraint(); location6002.setX(0); location6002.setY(40); return edge; }
From source file:com.puppetlabs.geppetto.pp.dsl.ui.linked.ExtLinkedXtextEditor.java
License:Open Source License
@Override protected void handlePreferenceStoreChanged(PropertyChangeEvent event) { // deal with indent property changing // deal with events that should NOT reach the parent ISourceViewer sourceViewer = getSourceViewer(); if (sourceViewer == null) return;/*from w w w. jav a 2 s . c o m*/ String property = event.getProperty(); // System.out.println("Property Event: " + property); if (FormatterGeneralPreferences.FORMATTER_INDENTSIZE.equals(property) || FormatterGeneralPreferences.FORMATTER_SPACES_FOR_TABS.equals(property)) { IPreferenceStore store = getPreferenceStore(); if (store != null) sourceViewer.getTextWidget() .setTabs(store.getInt(FormatterGeneralPreferences.FORMATTER_INDENTSIZE)); uninstallTabsToSpacesConverter(); if (store.getBoolean(FormatterGeneralPreferences.FORMATTER_SPACES_FOR_TABS)) installTabsToSpacesConverter(); return; } if (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH.equals(property)) { // INHIBIT THIS - Puppet editor is always "spaces for tabs" and does NOT follow the // Editor tab width setting, it is always the same as the indent size for formatting. return; } if (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS.equals(property)) { // INHIBIT THIS CHANGE - Puppet editor is always "spaces for tabs" return; } super.handlePreferenceStoreChanged(event); }
From source file:com.puppetlabs.geppetto.pp.dsl.ui.preferences.data.AbstractPreferenceData.java
License:Open Source License
protected int getContextualInt(IResource r, String property) { Preconditions.checkNotNull(access, getInitializationErrorMessage()); IPreferenceStore store = access.getContextPreferenceStore(r.getProject()); return store.getInt(property); }
From source file:com.python.pydev.analysis.CtxInsensitiveImportComplProposal.java
License:Open Source License
public void apply(IDocument document, char trigger, int stateMask, int offset, IAdaptable projectAdaptable) { if (this.indentString == null) { throw new RuntimeException("Indent string not set (not called with a PyEdit as viewer?)"); }//from w ww .ja v a 2s . co m if (!triggerCharAppliesCurrentCompletion(trigger, document, offset)) { newForcedOffset = offset + 1; //+1 because that's the len of the trigger return; } try { PySelection selection = new PySelection(document); int lineToAddImport = -1; ImportHandleInfo groupInto = null; ImportHandleInfo realImportHandleInfo = null; boolean groupImports = ImportsPreferencesPage.getGroupImports(projectAdaptable); LineStartingScope previousLineThatStartsScope = null; PySelection ps = null; if (this.addLocalImport) { ps = new PySelection(document, offset); int startLineIndex = ps.getStartLineIndex(); if (startLineIndex == 0) { this.addLocalImport = false; } else { previousLineThatStartsScope = ps.getPreviousLineThatStartsScope(PySelection.INDENT_TOKENS, startLineIndex - 1, PySelection.getFirstCharPosition(ps.getCursorLineContents())); if (previousLineThatStartsScope == null) { //note that if we have no previous scope, it means we're actually on the global scope, so, //proceed as usual... this.addLocalImport = false; } } } if (realImportRep.length() > 0 && !this.addLocalImport) { //Workaround for: https://sourceforge.net/tracker/?func=detail&aid=2697165&group_id=85796&atid=577329 //when importing from __future__ import with_statement, we actually want to add a 'with' token, not //with_statement token. boolean isWithStatement = realImportRep.equals("from __future__ import with_statement"); if (isWithStatement) { this.fReplacementString = "with"; } if (groupImports) { try { realImportHandleInfo = new ImportHandleInfo(realImportRep); PyImportsHandling importsHandling = new PyImportsHandling(document); for (ImportHandle handle : importsHandling) { if (handle.contains(realImportHandleInfo)) { lineToAddImport = -2; //signal that there's no need to find a line available to add the import break; } else if (groupInto == null && realImportHandleInfo.getFromImportStr() != null) { List<ImportHandleInfo> handleImportInfo = handle.getImportInfo(); for (ImportHandleInfo importHandleInfo : handleImportInfo) { if (realImportHandleInfo.getFromImportStr() .equals(importHandleInfo.getFromImportStr())) { List<String> commentsForImports = importHandleInfo.getCommentsForImports(); if (commentsForImports.size() > 0 && commentsForImports .get(commentsForImports.size() - 1).length() == 0) { groupInto = importHandleInfo; break; } } } } } } catch (ImportNotRecognizedException e1) { Log.log(e1);//that should not happen at this point } } if (lineToAddImport == -1) { boolean isFutureImport = PySelection.isFutureImportLine(this.realImportRep); lineToAddImport = selection.getLineAvailableForImport(isFutureImport); } } else { lineToAddImport = -1; } String delimiter = PyAction.getDelimiter(document); appliedWithTrigger = trigger == '.' || trigger == '('; String appendForTrigger = ""; if (appliedWithTrigger) { if (trigger == '(') { appendForTrigger = "()"; } else if (trigger == '.') { appendForTrigger = "."; } } //if the trigger is ')', just let it apply regularly -- so, ')' will only be added if it's already in the completion. //first do the completion if (fReplacementString.length() > 0) { int dif = offset - fReplacementOffset; document.replace(offset - dif, dif + this.fLen, fReplacementString + appendForTrigger); } if (this.addLocalImport) { //All the code below is because we don't want to work with a generated AST (as it may not be there), //so, we go to the previous scope, find out the valid indent inside it and then got backwards //from the position we're in now to find the closer location to where we're now where we're //actually able to add the import. try { int iLineStartingScope; if (previousLineThatStartsScope != null) { iLineStartingScope = previousLineThatStartsScope.iLineStartingScope; //Go to a non-empty line from the line we have and the line we're currently in. int iLine = iLineStartingScope + 1; String line = ps.getLine(iLine); int startLineIndex = ps.getStartLineIndex(); while (iLine < startLineIndex && (line.startsWith("#") || line.trim().length() == 0)) { iLine++; line = ps.getLine(iLine); } if (iLine >= startLineIndex) { //Sanity check! iLine = startLineIndex; line = ps.getLine(iLine); } int firstCharPos = PySelection.getFirstCharPosition(line); //Ok, all good so far, now, this would add the line to the beginning of //the element (after the if statement, def, etc.), let's try to put //it closer to where we're now (but still in a valid position). int j = startLineIndex; while (j >= 0) { String line2 = ps.getLine(j); if (PySelection.getFirstCharPosition(line2) == firstCharPos) { iLine = j; break; } if (j == iLineStartingScope) { break; } j--; } String indent = line.substring(0, firstCharPos); String strToAdd = indent + realImportRep + delimiter; ps.addLine(strToAdd, iLine - 1); //Will add it just after the line passed as a parameter. importLen = strToAdd.length(); return; } } catch (Exception e) { Log.log(e); //Something went wrong, add it as global (i.e.: BUG) } } if (groupInto != null && realImportHandleInfo != null) { //let's try to group it final int maxCols; if (SharedCorePlugin.inTestMode()) { maxCols = 80; } else { IPreferenceStore chainedPrefStore = PydevPrefs.getChainedPrefStore(); maxCols = chainedPrefStore .getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN); } int endLine = groupInto.getEndLine(); IRegion lineInformation = document.getLineInformation(endLine); String strToAdd = ", " + realImportHandleInfo.getImportedStr().get(0); String line = PySelection.getLine(document, endLine); if (line.length() + strToAdd.length() > maxCols) { if (line.indexOf('#') == -1) { //no comments: just add it in the next line int len = line.length(); if (line.trim().endsWith(")")) { len = line.indexOf(")"); strToAdd = "," + delimiter + indentString + realImportHandleInfo.getImportedStr().get(0); } else { strToAdd = ",\\" + delimiter + indentString + realImportHandleInfo.getImportedStr().get(0); } int end = lineInformation.getOffset() + len; importLen = strToAdd.length(); document.replace(end, 0, strToAdd); return; } } else { //regular addition (it won't pass the number of columns expected). line = PySelection.getLineWithoutCommentsOrLiterals(line); int len = line.length(); if (line.trim().endsWith(")")) { len = line.indexOf(")"); } int end = lineInformation.getOffset() + len; importLen = strToAdd.length(); document.replace(end, 0, strToAdd); return; } } //if we got here, it hasn't been added in a grouped way, so, let's add it in a new import if (lineToAddImport >= 0 && lineToAddImport <= document.getNumberOfLines()) { IRegion lineInformation = document.getLineInformation(lineToAddImport); String strToAdd = realImportRep + delimiter; importLen = strToAdd.length(); document.replace(lineInformation.getOffset(), 0, strToAdd); return; } } catch (BadLocationException x) { Log.log(x); } }
From source file:com.qcenzo.tools.localize.popup.actions.Localize.java
License:Open Source License
public void run(IAction action) { try {/*from w ww .j a va2 s . c o m*/ if (_selected == null) { MessageDialog.openInformation(_shell, "Error", "Fail to localize."); return; } IPreferenceStore store = Activator.getDefault().getPreferenceStore(); _extensionsPattern = Pattern.compile(store.getString(LocalizationPreferenceConstants.EXTENSIONS) .replaceAll("[\\s" + "|]+", "").replaceAll(";+", "|").toLowerCase()); _node = _nodePicker = new Node(); findFile(Paths.get(_selected.getLocation().toOSString())); _translatorPattern = Pattern .compile(refine(store.getString(LocalizationPreferenceConstants.REGEX).getBytes())); TranslatorManager.getInstance().init(store.getString(LocalizationPreferenceConstants.TRANSLATOR), store.getInt(LocalizationPreferenceConstants.FROMTO)); new ProgressMonitorDialog(_shell).run(true, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { int current = 1; monitor.beginTask("Localizing...(" + current + "/" + Node.number + ")", IProgressMonitor.UNKNOWN); while (_node.path != null) { if (monitor.isCanceled()) monitor.done(); monitor.setTaskName("Localizing...(" + (current++) + "/" + Node.number + ")"); monitor.subTask(_node.path.toString()); translate(_node.path); _node = _node.next; } monitor.done(); } catch (Throwable e) { monitor.done(); } } }); Node.number = 0; IHandlerService s = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class); s.executeCommand("org.eclipse.ui.file.refresh", null); } catch (Throwable e) { } }