Example usage for org.eclipse.jface.resource JFaceResources getColorRegistry

List of usage examples for org.eclipse.jface.resource JFaceResources getColorRegistry

Introduction

In this page you can find the example usage for org.eclipse.jface.resource JFaceResources getColorRegistry.

Prototype

public static ColorRegistry getColorRegistry() 

Source Link

Document

Returns the color registry for JFace itself.

Usage

From source file:com.bdaum.zoom.rcp.internal.Application.java

License:Open Source License

public Object start(IApplicationContext context) throws Exception {
    Display display = PlatformUI.createDisplay();
    ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
    RGB white = new RGB(255, 255, 255);
    RGB silver = new RGB(144, 144, 144);
    RGB grey = new RGB(128, 128, 128);
    RGB dark = new RGB(64, 64, 64);
    RGB black = new RGB(0, 0, 0);
    // Regions//from w  ww.  ja v a  2 s.  c  o m
    colorRegistry.put(Constants.APPCOLOR_REGION_FACE, new RGB(255, 160, 0));
    // Background
    colorRegistry.put("b", black); //$NON-NLS-1$
    colorRegistry.put("d", dark); //$NON-NLS-1$
    colorRegistry.put("g", new RGB(240, 240, 248)); //$NON-NLS-1$
    colorRegistry.put("w", white); //$NON-NLS-1$
    colorRegistry.put("p", display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND).getRGB()); //$NON-NLS-1$
    // Widget text
    colorRegistry.put("b_", white); //$NON-NLS-1$
    colorRegistry.put("d_", white); //$NON-NLS-1$
    colorRegistry.put("g_", black); //$NON-NLS-1$
    colorRegistry.put("w_", black); //$NON-NLS-1$
    colorRegistry.put("p_", display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND).getRGB()); //$NON-NLS-1$
    // Gallery item text
    colorRegistry.put("b-", grey); //$NON-NLS-1$
    colorRegistry.put("d-", silver); //$NON-NLS-1$
    colorRegistry.put("g-", new RGB(32, 32, 32)); //$NON-NLS-1$
    colorRegistry.put("w-", grey); //$NON-NLS-1$
    colorRegistry.put("p-", display.getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB()); //$NON-NLS-1$
    // Selected gallery item background
    colorRegistry.put("b#", grey); //$NON-NLS-1$
    colorRegistry.put("d#", silver); //$NON-NLS-1$
    colorRegistry.put("g#", dark); //$NON-NLS-1$
    colorRegistry.put("w#", silver); //$NON-NLS-1$
    colorRegistry.put("p#", display.getSystemColor(SWT.COLOR_LIST_SELECTION).getRGB()); //$NON-NLS-1$
    // Selected gallery item text
    colorRegistry.put("b!", black); //$NON-NLS-1$
    colorRegistry.put("d!", dark); //$NON-NLS-1$
    colorRegistry.put("g!", grey); //$NON-NLS-1$
    colorRegistry.put("w!", white); //$NON-NLS-1$
    colorRegistry.put("p!", display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT).getRGB()); //$NON-NLS-1$
    // Fonts are created by the ApplicationWorkbenchAdvisor

    URL iniUrl = FileLocator.find(RcpActivator.getDefault().getBundle(), new Path(ZOOM_INI), null);
    if (iniUrl != null)
        try (InputStream in = iniUrl.openStream()) {
            System.getProperties().load(in);
        }
    try {
        return (PlatformUI.createAndRunWorkbench(display,
                new ApplicationWorkbenchAdvisor()) == PlatformUI.RETURN_RESTART) ? IApplication.EXIT_RESTART
                        : IApplication.EXIT_OK;
    } finally {
        try {
            display.dispose();
        } catch (Exception e) {
            // catched only because of trayitem bug in osx implemention
        }
    }
}

From source file:com.bdaum.zoom.ui.internal.UiUtilities.java

License:Open Source License

public static ArrayList<ImageRegion> drawRegions(GC gc, Asset asset, int xs, int ys, int width, int height,
        boolean selected, int showRegions, boolean onlyFaces, Object persId) {
    Device device = gc.getDevice();//  w  w  w .j  a v a  2  s.c  om
    String[] regionIds = asset.getPerson();
    ArrayList<ImageRegion> regions = null;
    Set<Rectangle> rectangleOrOvalList = new HashSet<Rectangle>();
    if (regionIds != null && regionIds.length > 0) {
        int rotation = asset.getRotation();
        regions = new ArrayList<ImageRegion>(regionIds.length);
        gc.setClipping(xs, ys, width, height);
        int i = 0;
        boolean[] done = null;
        if (selected) {
            IDbManager dbManager = Core.getCore().getDbManager();
            for (RegionImpl region : dbManager.obtainObjects(RegionImpl.class, "asset_person_parent", //$NON-NLS-1$
                    asset.getStringId(), QueryField.EQUALS)) {
                if (onlyFaces && region.getType() != null && !region.getType().equals(Region.type_face))
                    continue;
                if (i++ > showRegions)
                    break;
                String id = region.getStringId();
                Rectangle frame = computeFrame(id, xs, ys, width, height, rotation);
                if (frame != null && !isDoubledRegion(rectangleOrOvalList, frame)) {
                    for (int j = 0; j < regionIds.length; j++)
                        if (regionIds[j].equals(id)) {
                            if (done == null)
                                done = new boolean[regionIds.length];
                            done[j] = true;
                        }
                    rectangleOrOvalList.add(frame);
                    gc.setForeground(JFaceResources.getColorRegistry().get(Constants.APPCOLOR_REGION_FACE));
                    if (frame.height < 0) {
                        int d = frame.width;
                        gc.drawOval(frame.x - d / 2, frame.y - d / 2, d, d);
                    } else
                        gc.drawRectangle(frame);
                    String type = region.getType();
                    String name = null;
                    int color = SWT.COLOR_RED;
                    if (type == null || type.isEmpty() || Region.type_face.equals(type)
                            || Region.type_pet.equals(type)) {
                        String albumId = region.getAlbum();
                        SmartCollectionImpl album = albumId == null ? null
                                : dbManager.obtainById(SmartCollectionImpl.class, albumId);
                        name = album != null ? album.getName() : "?"; //$NON-NLS-1$
                        if (persId == null || persId.equals(albumId))
                            color = SWT.COLOR_YELLOW;
                    } else if (Region.type_barCode.equals(type)) {
                        name = region.getAlbum();
                        color = SWT.COLOR_GREEN;
                    }
                    regions.add(
                            new ImageRegion(frame, id, type == null ? Region.type_face : type, name, asset));
                    if (name != null) {
                        gc.setForeground(device.getSystemColor(SWT.COLOR_DARK_GRAY));
                        gc.drawText(name, frame.x + 5, frame.y + 3, true);
                        gc.setForeground(device.getSystemColor(color));
                        gc.drawText(name, frame.x + 4, frame.y + 2, true);
                    }
                }
            }
        }
        gc.setForeground(JFaceResources.getColorRegistry().get(Constants.APPCOLOR_REGION_FACE));
        for (int j = 0; j < regionIds.length; j++) {
            if (done != null && done[j])
                continue;
            if (i++ > showRegions)
                break;
            Rectangle frame = computeFrame(regionIds[j], xs, ys, width, height, rotation);
            if (frame != null && !isDoubledRegion(rectangleOrOvalList, frame)) {
                rectangleOrOvalList.add(frame);
                if (frame.height < 0) {
                    int d = frame.width;
                    gc.drawOval(frame.x - d / 2, frame.y - d / 2, d, d);
                } else
                    gc.drawRectangle(frame);
                regions.add(new ImageRegion(frame, regionIds[j], null, null, asset));
            }
        }
        gc.setClipping((Rectangle) null);
    }
    return regions;
}

From source file:com.bdaum.zoom.ui.internal.widgets.AnimatedGallery.java

License:Open Source License

public AnimatedGallery(final PSWTCanvas canvas, int slideSize, int thumbSize, ImageStore imageSource) {
    this.thumbSize = thumbSize;
    this.imageSource = imageSource;
    setPreferences();// w w w  . j  a va  2  s .c o m
    this.canvas = canvas;
    this.slideSize = slideSize;
    RGB rgb = JFaceResources.getColorRegistry().getRGB(Constants.APPCOLOR_REGION_FACE);
    regionColor = new Color(rgb.red, rgb.green, rgb.blue);
    canvas.setInteractingRenderQuality(PPaintContext.HIGH_QUALITY_RENDERING);
    Rectangle bounds = canvas.getDisplay().getPrimaryMonitor().getBounds();
    surfaceBounds = new java.awt.Rectangle(-bounds.width * 10, -bounds.height * 10, bounds.width * 20,
            bounds.height * 20);
    surface = PSWTPath.createRectangle(surfaceBounds.x, surfaceBounds.y, surfaceBounds.width,
            surfaceBounds.height);
    slideBar = PSWTPath.createRectangle(0, 0, columns * slideSize, slideSize);
    cover = new ZPSWTImage(canvas, Icons.transparentCover.getImage());
    cover.setPickable(false);
    themeChanged();
    canvas.getLayer().addChild(surface);
    surface.addChild(slideBar);
    // TODO is this needed?
    // canvas.addGestureListener(new GestureListener() {
    //
    // public void gesture(GestureEvent e) {
    // if ((e.detail & SWT.GESTURE_BEGIN) != 0) {
    // if (e.magnification == 1d) {
    // previousMagnification = e.magnification;
    // wheelListener.pause();
    // }
    // } else if ((e.detail & SWT.GESTURE_MAGNIFY) != 0) {
    // zoom(canvas,
    // Math.sqrt(e.magnification / previousMagnification));
    // previousMagnification = e.magnification;
    // } else if ((e.detail & SWT.GESTURE_PAN) != 0) {
    // pan(canvas, e.xDirection, e.yDirection);
    // } else if ((e.detail & SWT.GESTURE_END) != 0) {
    // wheelListener.restart();
    // }
    // }
    // });

    PBasicInputEventHandler eventHandler = new GalleryPBasicInputEventHandler(canvas);
    canvas.getRoot().getDefaultInputManager().setKeyboardFocus(eventHandler);
    canvas.addInputEventListener(eventHandler);
    setEventHandlers();
    canvas.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            if (collection != null)
                fillSlidebar(collection);
        }
    });
    titleVerifyListener = new VerifyListener() {
        public void verifyText(VerifyEvent e) {
            fireErrorEvent(e);
        }
    };
}

From source file:com.cisco.yangide.editor.editors.YangSourceViewerConfiguration.java

License:Open Source License

@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {

    ContentAssistant assistant = new ContentAssistant();
    IContentAssistProcessor processor = new YangSimpleCompletionProcessor();
    assistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);

    assistant.setDocumentPartitioning(YangDocumentSetupParticipant.YANG_PARTITIONING);

    assistant.enableAutoActivation(false);
    assistant.setAutoActivationDelay(200);
    assistant.setProposalPopupOrientation(ContentAssistant.PROPOSAL_REMOVE);
    assistant.setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_ABOVE);
    assistant.setInformationControlCreator(getInformationControlCreator());

    Color background = JFaceResources.getColorRegistry().get(JFacePreferences.CONTENT_ASSIST_BACKGROUND_COLOR);
    assistant.setContextInformationPopupBackground(background);
    assistant.setContextSelectorBackground(background);

    Color foreground = JFaceResources.getColorRegistry().get(JFacePreferences.CONTENT_ASSIST_FOREGROUND_COLOR);
    assistant.setContextInformationPopupForeground(foreground);
    assistant.setContextSelectorForeground(foreground);

    assistant.setStatusLineVisible(true);

    assistant.enableAutoInsert(true);//from  w w  w.  j av  a 2s  .  com

    return assistant;
}

From source file:com.contrastsecurity.ide.eclipse.ui.internal.model.VulnerabilityDetailsPage.java

License:Open Source License

private CTabFolder createTabFolder(Composite parent) {
    CTabFolder folder = new CTabFolder(parent, SWT.NO_REDRAW_RESIZE | SWT.FLAT);
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    folder.setLayoutData(gd);/*from w ww  .j  a v  a 2 s .co m*/
    ColorRegistry reg = JFaceResources.getColorRegistry();
    Color c1 = reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_BG_START"),
            c2 = reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_BG_END");
    folder.setSelectionBackground(new Color[] { c1, c2 }, new int[] { 100 }, true);
    folder.setSelectionForeground(reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR"));
    folder.setSimple(PlatformUI.getPreferenceStore()
            .getBoolean(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS));
    folder.setBorderVisible(true);
    folder.setFont(parent.getFont());
    return folder;
}

From source file:com.google.dart.tools.search.internal.ui.text.DecoratingFileSearchLabelProvider.java

License:Open Source License

public void initialize(ColumnViewer viewer, ViewerColumn column) {
    PlatformUI.getPreferenceStore().addPropertyChangeListener(this);
    JFaceResources.getColorRegistry().addListener(this);

    setOwnerDrawEnabled(showColoredLabels());

    super.initialize(viewer, column);
}

From source file:com.google.dart.tools.search.internal.ui.text.DecoratingFileSearchLabelProvider.java

License:Open Source License

public void dispose() {
    super.dispose();
    PlatformUI.getPreferenceStore().removePropertyChangeListener(this);
    JFaceResources.getColorRegistry().removeListener(this);
}

From source file:com.google.dart.tools.ui.internal.viewsupport.ColoredViewersManager.java

License:Open Source License

public ColoredViewersManager() {
    fManagedViewers = new HashMap<StructuredViewer, ManagedViewer>();
    fManagedLabelProviders = new HashSet<ColoringLabelProvider>();
    fColorRegisty = JFaceResources.getColorRegistry();
}

From source file:com.google.dart.tools.ui.internal.viewsupport.ColoredViewersManager.java

License:Open Source License

public void installColoredLabels(ColoringLabelProvider labelProvider) {
    if (fManagedLabelProviders.contains(labelProvider)) {
        return;//from   w  w w .j  a  va  2s . c  om
    }

    if (fManagedLabelProviders.isEmpty()) {
        // first lp installed
        PlatformUI.getPreferenceStore().addPropertyChangeListener(this);
        JFaceResources.getColorRegistry().addListener(this);
    }
    fManagedLabelProviders.add(labelProvider);
}

From source file:com.google.dart.tools.ui.internal.viewsupport.ColoredViewersManager.java

License:Open Source License

public void uninstallColoredLabels(ColoringLabelProvider labelProvider) {
    if (!fManagedLabelProviders.remove(labelProvider)) {
        return; // not installed
    }/*from  w w  w.jav  a  2s  .  c  o m*/

    if (fManagedLabelProviders.isEmpty()) {
        PlatformUI.getPreferenceStore().removePropertyChangeListener(this);
        JFaceResources.getColorRegistry().removeListener(this);
        // last viewer uninstalled
    }
}