List of usage examples for org.eclipse.jface.resource StringConverter asRGB
public static RGB asRGB(String value, RGB dflt)
From source file:com.bdaum.zoom.ui.internal.actions.ViewImageAction.java
License:Open Source License
protected void launchViewer(Asset asset1, Asset asset2, boolean shift, boolean alt, boolean ctrl, final IWorkbenchWindow window) { IMediaViewer imageViewer = UiActivator.getDefault().getMediaViewer(asset1); URI uri = Core.getCore().getVolumeManager().findExistingFile(asset1, false); boolean isFile = uri == null || Constants.FILESCHEME.equals(uri.getScheme()); boolean isFtp = uri == null || IFTPService.FTPSCHEME.equals(uri.getScheme()); try {//ww w .jav a 2s. c o m if (uri != null && !isFile && !isFtp && (imageViewer == null || !imageViewer.canHandleRemote())) { PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(uri.toURL()); return; } } catch (Exception e) { Core.getCore().logError(NLS.bind(Messages.ViewImageAction_error_viewing_remote_image, uri), e); } IPreferencesService preferencesService = Platform.getPreferencesService(); RGB filter = StringConverter.asRGB( preferencesService.getString(UiActivator.PLUGIN_ID, PreferenceConstants.BWFILTER, null, null), new RGB(64, 128, 64)); boolean extrnRqrd = asset2 == null && !shift && !alt && !ctrl && (isFile || imageViewer == null || !imageViewer.canHandleRemote()); boolean isDummy = imageViewer != null && imageViewer.isDummy(); if (extrnRqrd || isDummy) { String viewerPath = preferencesService.getString(UiActivator.PLUGIN_ID, imageViewer == null ? PreferenceConstants.EXTERNALVIEWER : PreferenceConstants.EXTERNALMEDIAVIEWER + imageViewer.getId(), "", null); //$NON-NLS-1$ if (viewerPath != null && !viewerPath.isEmpty()) { File viewer = new File(viewerPath); if (viewer.exists()) { try { if (uri == null) { UiUtilities.showFileIsOffline(window.getShell(), asset1); return; } File tempFile = null; File file; if (isFile) file = new File(uri); else file = tempFile = Core.download(uri, null); boolean autoExport = preferencesService.getBoolean(UiActivator.PLUGIN_ID, PreferenceConstants.AUTOEXPORT, true, null); if (autoExport && tempFile == null) { ExportMetadataOperation op = new ExportMetadataOperation( Collections.singletonList(asset1), UiActivator.getDefault().getExportFilter(), UiActivator.getDefault().getPreferenceStore() .getBoolean(PreferenceConstants.JPEGMETADATA), true, false); try { op.execute(new NullProgressMonitor(), new IAdaptable() { @SuppressWarnings({ "unchecked", "rawtypes" }) public Object getAdapter(Class adapter) { if (Shell.class.equals(adapter)) return window.getShell(); return null; } }); } catch (ExecutionException e) { // should not happen } } BatchUtilities.executeCommand(new String[] { viewerPath, file.getAbsolutePath() }, null, Messages.ViewImageAction_run_viewer, IStatus.OK, IStatus.ERROR, -1, 2500L, "UTF-8"); //$NON-NLS-1$ if (tempFile != null) tempFile.delete(); return; } catch (Exception e) { Core.getCore().logError(NLS.bind(Messages.ViewImageAction_error_launching, viewerPath), e); } return; } if (isDummy) { AcousticMessageDialog.openError(window.getShell(), Messages.ViewImageAction_viewer_missing, NLS.bind(Messages.ViewImageAction_reconfigure, viewerPath)); return; } AcousticMessageDialog.openError(window.getShell(), Messages.ViewImageAction_viewer_missing, NLS.bind(Messages.ViewImageAction_configured_external_viewer, viewerPath)); } else if (isDummy) { AcousticMessageDialog.openError(window.getShell(), Messages.ViewImageAction_viewer_missing, Messages.ViewImageAction_configure); return; } } if (imageViewer == null) imageViewer = new ImageViewer(); if (asset2 != null) { IMediaViewer rightViewer = UiActivator.getDefault().getMediaViewer(asset2); if (rightViewer == null) rightViewer = new ImageViewer(); imageViewer = new MultiViewer(imageViewer, rightViewer); } imageViewer.init(window, IKiosk.PRIMARY, alt ? filter : null, ctrl ? (shift ? ZImage.ORIGINAL : ZImage.CROPPED) : ZImage.CROPMASK); try { imageViewer.open(new Asset[] { asset1, asset2 }); } catch (IOException e) { Core.getCore().logError(Messages.ViewImageAction_error_launching_internal_viewer, e); } }
From source file:com.bdaum.zoom.ui.internal.views.PreviewView.java
License:Open Source License
@Override public void createPartControl(Composite parent) { filter = StringConverter.asRGB(Platform.getPreferencesService().getString(UiActivator.PLUGIN_ID, PreferenceConstants.BWFILTER, null, null), new RGB(64, 128, 64)); composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = layout.marginWidth = 0; composite.setLayout(layout);/*ww w.jav a 2 s . com*/ canvas = new Canvas(composite, SWT.DOUBLE_BUFFERED); canvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); PlatformUI.getWorkbench().getHelpSystem().setHelp(canvas, HelpContextIds.PREVIEW_VIEW); canvas.addPaintListener(this); canvas.redraw(); addKeyListener(); addExplanationListener(true); makeActions(getViewSite().getActionBars()); installListeners(); hookContextMenu(); hookDoubleClickAction(); contributeToActionBars(); addDragDropSupport(false, false, true); installHoveringController(); Ui.getUi().getFrameManager().addFrameListener(this); updateActions(true); }
From source file:com.matlab.eclipse.meditor.editors.MatlabConfiguration.java
License:Open Source License
private TextAttribute generateTextAttribute(Preferences prefs, String color) { String colorname = prefs.getString(color); RGB rgb = StringConverter.asRGB(colorname, new RGB(0, 0, 0)); TextAttribute attribute = new TextAttribute(colorManager.getColor(rgb)); return attribute; }
From source file:com.windowtester.internal.runtime.preferences.PlaybackSettings.java
License:Open Source License
/** * Get the current highlight color /* ww w .j a v a 2 s .c o m*/ */ public RGB getHighlightColor() { String c = getProperty(HIGHLIGHT_COLOR); RGB rgb = StringConverter.asRGB(c, null /*DEFAULT_RGB*/); return rgb; }
From source file:com.windowtester.internal.runtime.preferences.PlaybackSettings.java
License:Open Source License
/** * Set the current highlight color.//from w w w.ja v a2 s .c o m */ public void setHighlightColor(String rgbString) { /* * In case RGB is not on the class path, we skip setting this * value -- */ try { // first make sure the string is properly formatted... RGB rgb = StringConverter.asRGB(rgbString, null); // if the value is bad, return early if (rgb == null) return; } catch (NoClassDefFoundError e) { return; //just bail } // if the value is ok, proceed to set it setProperty(HIGHLIGHT_COLOR, rgbString); }
From source file:com.windowtester.runtime.swt.internal.preferences.PlaybackSettings.java
License:Open Source License
/** * Set the current highlight color.//from w w w.ja v a 2 s.c om */ public void setHighlightColor(String rgbString) { //first make sure the string is properly formatted... RGB rgb = StringConverter.asRGB(rgbString, null); //if the value is bad, return early if (rgb == null) return; //if the value is ok, proceed to set it setProperty(HIGHLIGHT_COLOR, rgbString); }
From source file:eu.esdihumboldt.hale.ui.util.ColorManager.java
License:Open Source License
/** * Get the color for the given key. Uses black as a default color if no * color for the key can be found.//from w ww. ja v a 2 s . c om * * @see eu.esdihumboldt.hale.ui.util.IColorManager#getColor(java.lang.String) */ @Override public Color getColor(String key) { RGB color = keyColors.get(key); if (color == null) { // try preferences String rgbStr = prefStore.getString(key); color = StringConverter.asRGB(rgbStr, new RGB(0, 0, 0)); } return getColor(color); }
From source file:melnorme.lang.ide.ui.text.coloring.TextStylingPreference.java
License:Open Source License
public static RGB getRgb(IPreferencesAccess prefsHelper, String key) { return StringConverter.asRGB(prefsHelper.getString(key), PreferenceConverter.COLOR_DEFAULT_DEFAULT); }
From source file:org.eclipse.b3.beelang.ui.internal.BuckminsterIOConsole.java
/** * Returns a color instance based on RGB color string (e.g. "0,0,256" - blue) *//*from ww w . j a va2 s . co m*/ private Color createColor(String colorString) { RGB rgb = StringConverter.asRGB(colorString, null); if (rgb == null) rgb = DEFAULT_COLOR; return new Color(Display.getCurrent(), rgb); }
From source file:org.eclipse.e4.tools.emf.ui.internal.common.ModelEditor.java
License:Open Source License
@Inject public void setNotVisibleColor(@Preference("notVisibleColor") String color) { RGB current = JFaceResources.getColorRegistry().getRGB(ComponentLabelProvider.NOT_VISIBLE_KEY); if (current == null || !current.equals(color)) { JFaceResources.getColorRegistry().put(ComponentLabelProvider.NOT_VISIBLE_KEY, StringConverter.asRGB(color, new RGB(200, 200, 200))); }//from ww w .j a v a2 s . c o m if (viewer != null) { viewer.refresh(); viewer.getControl().redraw(); } }