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

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

Introduction

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

Prototype

public static Font getFont(String symbolicName) 

Source Link

Document

Returns the font in JFace's font registry with the given symbolic font name.

Usage

From source file:com.axmor.eclipse.typescript.editor.preferences.TypescriptSyntaxColoringPage.java

License:Open Source License

private Control createPreviewer(Composite parent) {
    IPreferenceStore store = new ChainedPreferenceStore(
            new IPreferenceStore[] { getOverlayStore(), Activator.getDefault().getPreferenceStore() });
    fPreviewViewer = new TypeScriptProjectionViewer(null, parent, null, null, false,
            SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);

    fPreviewViewer.setEditable(false);/*from ww  w .  j a  va 2 s .  c om*/
    Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT);
    fPreviewViewer.getTextWidget().setFont(font);

    String content = TypeScriptEditorUtils
            .loadPreviewContentFromFile(getClass().getResourceAsStream("SyntaxPreviewCode.txt")); //$NON-NLS-1$
    IDocument document = new Document(content);
    IDocumentPartitioner partitioner = new FastPartitioner(new TypeScriptPartitionScanner(),
            TypeScriptPartitionScanner.TS_PARTITION_TYPES);
    partitioner.connect(document);
    document.setDocumentPartitioner(partitioner);
    fPreviewViewer.setDocument(document);

    TypeScriptEditorConfiguration configuration = new TypeScriptEditorConfiguration();
    fPreviewViewer.configure(configuration);
    new TypescriptPreviewerUpdater(fPreviewViewer, configuration, store);
    installSemanticHighlighting();

    return fPreviewViewer.getControl();
}

From source file:com.axmor.eclipse.typescript.editor.preferences.TypescriptTemplatePreferencePage.java

License:Open Source License

protected SourceViewer createViewer(Composite parent) {
    SourceViewer viewer = new SourceViewer(parent, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);

    SourceViewerConfiguration configuration = new TypeScriptEditorConfiguration();
    IDocument document = new Document();
    //new AntDocumentSetupParticipant().setup(document);
    IDocumentPartitioner partitioner = new FastPartitioner(new TypeScriptPartitionScanner(),
            TypeScriptPartitionScanner.TS_PARTITION_TYPES);
    partitioner.connect(document);/*ww w  . j  a  v a  2s  .  c  om*/
    document.setDocumentPartitioner(partitioner);
    viewer.configure(configuration);
    viewer.setDocument(document);
    viewer.setEditable(false);
    Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT);
    viewer.getTextWidget().setFont(font);

    return viewer;
}

From source file:com.bdaum.zoom.ui.dialogs.AcousticMessageDialog.java

License:Open Source License

@Override
protected Control createMessageArea(Composite parent) {
    if (Constants.OSX)
        return super.createMessageArea(parent);
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 2, 1));
    composite.setLayout(new GridLayout(2, false));
    Image image = getImage();/*from  w w w . j  a  v  a2s .  c  om*/
    imageLabel = new Label(composite, SWT.NULL);
    if (image != null) {
        image.setBackground(imageLabel.getBackground());
        imageLabel.setImage(image);
    }
    Label titleLabel = new Label(composite, SWT.NONE);
    titleLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    if (dialogTitle != null) {
        titleLabel.setFont(JFaceResources.getFont(UiConstants.MESSAGETITLEFONT));
        titleLabel.setText(dialogTitle);
    }
    if (message != null) {
        composite = new Composite(parent, SWT.NONE);
        composite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 2, 1));
        GridLayout layout = new GridLayout();
        layout.marginWidth = 15;
        composite.setLayout(layout);
        messageLabel = new Label(composite, getMessageLabelStyle());
        messageLabel.setFont(JFaceResources.getFont(UiConstants.MESSAGEFONT));
        messageLabel.setAlignment(message.indexOf('\t') >= 0 ? SWT.LEFT : SWT.CENTER);
        messageLabel.setText(message);
        messageLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
    }
    return parent;
}

From source file:com.bdaum.zoom.ui.internal.dialogs.PurgeEmptyDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite area = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(area, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    composite.setLayout(new GridLayout());
    viewer = new TableViewer(composite, SWT.BORDER | SWT.V_SCROLL);
    viewer.getTable().setLayoutData(new GridData(350, 500));
    viewer.getTable().setLinesVisible(true);
    viewer.setContentProvider(ArrayContentProvider.getInstance());
    TableViewerColumn col1 = new TableViewerColumn(viewer, SWT.NONE);
    col1.getColumn().setWidth(250);//from w w w.j a v a  2 s  .co m
    col1.setLabelProvider(new ZColumnLabelProvider() {
        @Override
        public String getText(Object element) {
            if (element instanceof SmartCollection)
                return ((SmartCollection) element).getName();
            return super.getText(element);
        }
    });
    TableViewerColumn col2 = new TableViewerColumn(viewer, SWT.NONE);
    col2.getColumn().setWidth(250);
    col2.setLabelProvider(new ZColumnLabelProvider() {
        @Override
        public String getText(Object element) {
            if (element instanceof SmartCollection) {
                if (element == pending)
                    return Messages.PurgeEmptyDialog_analyzing;
                if (allDeleted.contains(((SmartCollection) element).getStringId()))
                    return Messages.PurgeEmptyDialog_deleted;
                if (kept.contains(((SmartCollection) element).getStringId()))
                    return Messages.PurgeEmptyDialog_kept;
                return ""; //$NON-NLS-1$
            }
            return super.getText(element);
        }

        @Override
        protected Font getFont(Object element) {
            if (allDeleted.contains(((SmartCollection) element).getStringId()))
                return JFaceResources.getFont(UiConstants.SELECTIONFONT);
            return super.getFont(element);
        }
    });
    viewer.setInput(collections);
    return area;
}

From source file:com.bdaum.zoom.ui.internal.preferences.KeyPreferencePage.java

License:Open Source License

@SuppressWarnings("unused")
private void createBindingTable(Composite composite) {
    bindingViewer = new TableViewer(composite, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.FULL_SELECTION);
    Table table = bindingViewer.getTable();
    table.setLayoutData(new GridData(550, 300));
    table.setHeaderVisible(true);//from w  ww .ja  va  2  s . co  m
    table.setLinesVisible(true);
    commandColumn = createColumn(bindingViewer, Messages.getString("KeyPreferencePage.command"), 200); //$NON-NLS-1$
    commandLabelProvider = new ZColumnLabelProvider() {
        @Override
        public String getText(Object element) {
            if (element instanceof Command) {
                try {
                    return ((Command) element).getName();
                } catch (NotDefinedException e) {
                    return Messages.getString("KeyPreferencePage.undefined"); //$NON-NLS-1$
                }
            }
            return element.toString();
        }

        @Override
        public Font getFont(Object element) {
            if (element instanceof Command) {
                Binding binding = commandMap.get(((Command) element).getId());
                if (binding != null && binding.getType() == Binding.USER)
                    return JFaceResources.getFont(UiConstants.ITALICFONT);
            }
            return super.getFont(element);
        }

    };
    commandColumn.setLabelProvider(commandLabelProvider);
    keyColumn = createColumn(bindingViewer, Messages.getString("KeyPreferencePage.keys"), 150); //$NON-NLS-1$
    keyLabelProvider = new ZColumnLabelProvider() {
        @Override
        public String getText(Object element) {
            if (element instanceof Command) {
                Binding binding = commandMap.get(((Command) element).getId());
                if (binding != null)
                    return binding.getTriggerSequence().format();
                return null;
            }
            return element.toString();
        }
    };
    keyColumn.setLabelProvider(keyLabelProvider);
    catColumn = createColumn(bindingViewer, Messages.getString("KeyPreferencePage.category"), 150); //$NON-NLS-1$
    catLabelProvider = new ZColumnLabelProvider() {
        @Override
        public String getText(Object element) {
            if (element instanceof Command)
                try {
                    return ((Command) element).getCategory().getName();
                } catch (NotDefinedException e) {
                    return Messages.getString("KeyPreferencePage.undefined"); //$NON-NLS-1$
                }
            return element.toString();
        }
    };
    catColumn.setLabelProvider(catLabelProvider);
    bindingViewer.setContentProvider(ArrayContentProvider.getInstance());
    new SortColumnManager(bindingViewer, new int[] { SWT.UP, SWT.UP, SWT.UP }, 0);
    bindingViewer.setComparator(ZViewerComparator.INSTANCE);
    bindingViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            updateDetails();
        }
    });
}

From source file:com.bdaum.zoom.ui.internal.views.ImageViewer.java

License:Open Source License

public void create() {
    super.create();
    bottomShell = new FadingShell(createKioskShell(Messages.getString("ImageViewer.lowres_viewer")), false, //$NON-NLS-1$
            -1);//w w w . j av a 2s .  c  o  m
    bottomCanvas = new Canvas(bottomShell.getShell(), SWT.DOUBLE_BUFFERED);
    previewShell = new FadingShell(createKioskShell(Messages.getString("ImageViewer.preview_viewer")), true, //$NON-NLS-1$
            Constants.SLIDE_TRANSITION_FADE);
    previewCanvas = new Canvas(previewShell.getShell(), SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND);
    topShell = new FadingShell(createKioskShell(Messages.getString("ImageViewer.highres_viewer")), true, //$NON-NLS-1$
            Constants.SLIDE_TRANSITION_FADE);
    topCanvas = new Canvas(topShell.getShell(), SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND);
    controlShell = new Shell(display, SWT.NO_TRIM);
    controlRegion = new Region(display);
    controlRegion.add(new int[] { 4, 1, 44, 1, 47, 4, 47, 43, 44, 46, 4, 46, 1, 43, 1, 4 });
    controlShell.setRegion(controlRegion);
    controlShell.setText(Constants.APPNAME);
    controlShell.setLayout(new FillLayout());
    controlCanvas = new Canvas(controlShell, SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND);
    controlCanvas.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseUp(MouseEvent e) {
            close();
        }
    });
    bottomCanvas.addKeyListener(this);
    previewCanvas.addKeyListener(this);
    MouseMoveListener mouseMoveListener = new MouseMoveListener() {
        public void mouseMove(MouseEvent e) {
            Canvas canvas = (Canvas) e.widget;
            Rectangle clientArea = canvas.getClientArea();
            if (e.y < clientArea.y + 2 * HOTSPOTSIZE) {
                if (e.x < clientArea.x + 2 * HOTSPOTSIZE && kind != RIGHT)
                    showCloseButton(canvas.toDisplay(clientArea.x, clientArea.y));
                else if (e.x > clientArea.x + clientArea.width - 2 * HOTSPOTSIZE && kind != LEFT)
                    showCloseButton(
                            canvas.toDisplay(clientArea.x + clientArea.width - HOTSPOTSIZE, clientArea.y));
                else
                    controlShell.setVisible(false);
            } else
                controlShell.setVisible(false);
            if (controlShell.getVisible())
                controlShell.forceActive();
        }

        private void showCloseButton(Point pnt) {
            controlShell.setLocation(pnt);
            controlShell.setVisible(true);
        }
    };
    topCanvas.addMouseMoveListener(mouseMoveListener);
    bottomCanvas.addMouseMoveListener(mouseMoveListener);
    previewCanvas.addMouseMoveListener(mouseMoveListener);
    topCanvas.addKeyListener(this);
    topCanvas.addHelpListener(this);
    wheelListener = new InertiaMouseWheelListener();
    wheelListener.setMinScale(1d);
    wheelListener.setMaxScale(MAXZOOM);
    topCanvas.addMouseWheelListener(wheelListener);
    panListener = new InertiaMousePanListener();
    topCanvas.addMouseListener(panListener);
    topCanvas.addMouseMoveListener(panListener);
    PaintListener listener = new PaintListener() {
        public void paintControl(PaintEvent e) {
            Canvas canvas = (Canvas) e.widget;
            Shell shell = canvas.getShell();
            Rectangle sbnds = canvas.getClientArea();
            CssActivator.getDefault().setColors(shell);
            GC gc = e.gc;
            gc.setBackground(shell.getBackground());
            gc.fillRectangle(sbnds);
            if (!highResVisible) {
                Image im = previewImage != null
                        ? previewImage.getSwtImage(display, false, ZImage.UNCROPPED, SWT.DEFAULT, SWT.DEFAULT)
                        : bwmode != null ? getBwImage(asset, bwmode) : getImage(asset);
                if (im != null) {
                    Rectangle ibnds = im.getBounds();
                    double factor = Math.min((double) sbnds.width / ibnds.width,
                            (double) sbnds.height / ibnds.height);
                    if (!enlarge) {
                        double factor2 = Math.min((double) sbnds.width / asset.getWidth(),
                                (double) sbnds.height / asset.getHeight());
                        if (factor2 > 1d)
                            factor /= factor2;
                    }
                    int w = (int) (ibnds.width * factor);
                    int h = (int) (ibnds.height * factor);
                    gc.drawImage(im, 0, 0, ibnds.width, ibnds.height, (sbnds.width - w) / 2,
                            (sbnds.height - h) / 2, w, h);
                }
                String volume = asset.getVolume();
                String text;
                if (file == null)
                    text = volume == null || volume.trim().isEmpty()
                            ? Messages.getString("ImageViewer.highres_not_available") //$NON-NLS-1$
                            : NLS.bind(Messages.getString("ImageViewer.high_res_image_not_available"), //$NON-NLS-1$
                                    volume);
                else if (loadFailed != null)
                    text = loadFailed;
                else
                    text = ((previewImage != null) ? Messages.getString("ImageViewer.loading_highres") : //$NON-NLS-1$
                    Messages.getString("ImageViewer.loading_thumbnail")) //$NON-NLS-1$
                            + "\n\n" + getKeyboardHelp(false) + '\n'; //$NON-NLS-1$
                if (tlayout == null) {
                    tlayout = new TextLayout(display);
                    tlayout.setAlignment(SWT.CENTER);
                    tlayout.setWidth(sbnds.width);
                    tlayout.setFont(JFaceResources.getFont(UiConstants.VIEWERFONT));
                }
                tlayout.setText(text);
                Rectangle tbounds = tlayout.getBounds();
                gc.setForeground(
                        display.getSystemColor((file == null || loadFailed != null) ? SWT.COLOR_DARK_RED
                                : (previewImage != null) ? SWT.COLOR_DARK_CYAN : SWT.COLOR_DARK_GREEN));
                int y = (sbnds.height - tbounds.height) / 2;
                tlayout.draw(gc, 1, y + 1);
                gc.setForeground(display.getSystemColor((file == null || loadFailed != null) ? SWT.COLOR_RED
                        : (previewImage != null) ? SWT.COLOR_CYAN : SWT.COLOR_GREEN));
                tlayout.draw(gc, 0, y);
            }
        }
    };
    bottomCanvas.addPaintListener(listener);
    previewCanvas.addPaintListener(listener);
    topCanvas.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            if (image != null) {
                Rectangle sbounds = topCanvas.getClientArea();
                Shell shell = topShell.getShell();
                CssActivator.getDefault().setColors(shell);
                GC gc = e.gc;
                gc.setBackground(shell.getBackground());
                gc.fillRectangle(sbounds);
                int iwidth = ibounds.width;
                int iheight = ibounds.height;
                if (viewTransform == null) {
                    viewTransform = new PAffineTransform();
                    double zoomfactor = Math.min((double) sbounds.width / iwidth,
                            (double) sbounds.height / iheight);
                    if (!enlarge && zoomfactor > 1d)
                        zoomfactor = 1d;
                    wheelListener.setMinScale(zoomfactor);
                    viewTransform.scale(zoomfactor, zoomfactor);
                }
                rectSrc.setBounds(ibounds.x, ibounds.y, iwidth, iheight);
                viewTransform.transform(rectSrc, rectDst);
                int canvasWidth = Math.min((int) (rectDst.getWidth()), sbounds.width);
                int canvasHeight = Math.min((int) (rectDst.getHeight()), sbounds.height);
                canvasXoffset = Math.max(0, (sbounds.width - canvasWidth) / 2);
                canvasYoffset = Math.max(0, (sbounds.height - canvasHeight) / 2);
                rectSrc.setBounds(0, 0, canvasWidth, canvasHeight);
                viewTransform.inverseTransform(rectSrc, rectDst);
                int cropWidth = Math.min((int) (rectDst.getWidth()), iwidth);
                int cropHeight = Math.min((int) (rectDst.getHeight()), iheight);
                int cropXoffset = Math.max(0, Math.min(iwidth - cropWidth, (int) (rectDst.getX())));
                int cropYoffset = Math.max(0, Math.min(iheight - cropHeight, (int) (rectDst.getY())));
                if (advanced) {
                    gc.setAntialias(SWT.ON);
                    gc.setInterpolation(SWT.HIGH);
                }
                try {
                    image.draw(gc, cropXoffset, cropYoffset, cropWidth, cropHeight, canvasXoffset,
                            canvasYoffset, canvasWidth, canvasHeight, cropmode, sbounds.width, sbounds.height,
                            true);
                    currentFrame.setFrame((double) cropXoffset / iwidth, (double) cropYoffset / iheight,
                            (double) cropWidth / iwidth, (double) cropHeight / iheight);
                } catch (Exception e1) {
                    UiActivator.getDefault().logError(Messages.getString("ImageViewer.error_when_resizing"), //$NON-NLS-1$
                            e1);
                }
                gc.setBackground(topShell.getShell().getBackground());
                if (canvasXoffset > 0)
                    gc.fillRectangle(0, 0, canvasXoffset, sbounds.height);
                if (canvasXoffset + canvasWidth < sbounds.width)
                    gc.fillRectangle(canvasXoffset + canvasWidth, 0,
                            sbounds.width - (canvasXoffset + canvasWidth), sbounds.height);
                if (canvasYoffset > 0)
                    gc.fillRectangle(0, 0, sbounds.width, canvasYoffset);
                if (canvasYoffset + canvasHeight < sbounds.height)
                    gc.fillRectangle(0, canvasYoffset + canvasHeight, sbounds.width,
                            sbounds.height - (canvasYoffset + canvasHeight));
                if (!transformListeners.isEmpty()) {
                    Image img = sync ? Icons.sync32.getImage() : Icons.sync32d.getImage();
                    Rectangle bounds = img.getBounds();
                    int x, y;
                    if (vertical) {
                        hotspot.width = bounds.width;
                        hotspot.height = bounds.height / 2;
                        hotspot.x = x = 0;
                        y = kind == LEFT ? sbounds.height - hotspot.height : -hotspot.height;
                        hotspot.y = kind == LEFT ? y : 0;
                    } else {
                        hotspot.width = bounds.width / 2;
                        hotspot.height = bounds.height;
                        x = kind == LEFT ? sbounds.width - hotspot.width : -hotspot.width;
                        hotspot.x = kind == LEFT ? x : 0;
                        hotspot.y = y = sbounds.height - 2 * bounds.height;
                    }
                    gc.setBackground(
                            display.getSystemColor(sync ? SWT.COLOR_GREEN : SWT.COLOR_WIDGET_NORMAL_SHADOW));
                    gc.fillOval(x - 2, y - 2, bounds.width + 4, bounds.height + 4);
                    gc.drawImage(img, x, y);
                }
            }
        }
    });
    bottomCanvas.redraw();
    controlCanvas.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            e.gc.drawImage(Icons.closeButton.getImage(), 0, 0);
        }
    });
    controlCanvas.redraw();
    controlShell.setBounds(Constants.OSX ? mbounds.x : mbounds.x + mbounds.width - HOTSPOTSIZE, mbounds.y,
            HOTSPOTSIZE, HOTSPOTSIZE);
    controlShell.setVisible(false);
    bottomShell.layout();
    previewShell.layout();
    topShell.layout();
    Ui.getUi().getFrameManager().registerFrameProvider(this);
}

From source file:com.bdaum.zoom.ui.internal.views.SlideShowPlayer.java

License:Open Source License

public void create() {
    super.create();
    bottomShell = createKioskShell(Messages.getString("SlideShowPlayer.slideshow")); //$NON-NLS-1$
    bottomCanvas = new Canvas(bottomShell, SWT.DOUBLE_BUFFERED);
    bottomCanvas.addKeyListener(this);
    bottomCanvas.addMouseListener(this);
    text = new TextLayout(display);
    text.setAlignment(SWT.CENTER);/*from w w w.  ja va  2  s. c  om*/
    text.setFont(JFaceResources.getFont(UiConstants.VIEWERFONT));
    createTransparentCursor();
    bottomCanvas.setCursor(transparentCursor);
    bottomCanvas.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            Rectangle sbounds = bottomCanvas.getClientArea();
            GC gc = e.gc;
            gc.setBackground(bottomShell.getBackground());
            gc.fillRectangle(sbounds);
            gc.setForeground(bottomShell.getForeground());
            text.setWidth(sbounds.width / 2);
            Rectangle tbounds = text.getBounds();
            text.draw(gc, (sbounds.width - tbounds.width) / 2, (sbounds.height - tbounds.height) / 2);
        }
    });
    bottomShell.setData(CSSProperties.ID, CSSProperties.SLIDESHOW);
    CssActivator.getDefault().setColors(bottomShell);
    text.setText(NLS.bind(slideshow.getAdhoc() ? Messages.getString("SlideShowPlayer.preparing") //$NON-NLS-1$
            : Messages.getString("SlideShowPlayer.preparing_slideshow"), //$NON-NLS-1$
            slideshow.getName()));
    bottomShell.layout();
}

From source file:com.bdaum.zoom.ui.internal.views.SlideShowPlayer.java

License:Open Source License

private void showInfo(int position, String name) {
    StringBuilder sb = new StringBuilder(512);
    sb.append(name);//from   w  w  w.jav a2  s.c om
    String description = slideshow.getDescription();
    if (description != null && !description.isEmpty())
        sb.append("\n\n").append(description); //$NON-NLS-1$
    sb.append("\n\n").append(NLS.bind(Messages.getString("SlideShowPlayer.n_slides"), total)); //$NON-NLS-1$ //$NON-NLS-2$
    if (firstSlide < 0)
        sb.append('\n').append(Messages.getString("SlideShowPlayer.all_images_are_offline")); //$NON-NLS-1$
    else {
        if (offline > 0) {
            sb.append('\n');
            if (offline == 1)
                sb.append(Messages.getString("SlideShowPlayer.one_image_is_offline")); //$NON-NLS-1$
            else
                sb.append(NLS.bind(Messages.getString("SlideShowPlayer.n_images_are_offline"), //$NON-NLS-1$
                        offline));
        }
        sb.append('\n').append(NLS.bind(Messages.getString("SlideShowPlayer.total_duration"), //$NON-NLS-1$
                formatPeriod(duration)));
        if (position > 0)
            sb.append('\n')
                    .append(NLS.bind(Messages.getString("SlideShowPlayer.duration_from_current_position"), //$NON-NLS-1$
                            formatPeriod(duration - position)));
    }
    sb.append('\n').append(Messages.getString("SlideShowPlayer.press_esc_to_cancel")); //$NON-NLS-1$
    if (firstSlide >= 0)
        sb.append('\n').append(Messages.getString("SlideShowPlayer.move_mouse_to_obtain_control_panel")); //$NON-NLS-1$
    text.setText(sb.toString());
    text.setStyle(new TextStyle(JFaceResources.getFont(UiConstants.VIEWERTITLEFONT), null, null), 0,
            name.length());
    bottomCanvas.redraw();
}

From source file:com.cisco.yangide.editor.compare.YangFileMergeViewer.java

License:Open Source License

@Override
protected void configureTextViewer(TextViewer textViewer) {
    SourceViewer yangSourceViewer = (SourceViewer) textViewer;
    YangColorManager colorManager = new YangColorManager(false);

    IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] {
            YangEditorPlugin.getDefault().getCombinedPreferenceStore(), EditorsUI.getPreferenceStore() });

    YangSourceViewerConfiguration configuration = new YangSourceViewerConfiguration(store, colorManager, null);

    yangSourceViewer.configure(configuration);
    yangSourceViewer.setEditable(false);
    Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT);
    yangSourceViewer.getTextWidget().setFont(font);
}

From source file:com.cisco.yangide.editor.compare.YangFileViewerCreator.java

License:Open Source License

@Override
public Viewer createViewer(Composite parent, CompareConfiguration config) {
    YangSourceViewer yangSourceViewer = new YangSourceViewer(parent, null, null, false,
            SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL) {
        @Override/*from   w  ww  . java  2s . co m*/
        public void setInput(Object input) {
            if (input instanceof IStreamContentAccessor) {
                IDocument document = new Document(getContentFromStream((IStreamContentAccessor) input));
                new YangDocumentSetupParticipant().setup(document);
                setDocument(document);
            } else {
                super.setInput(input);
            }
        }
    };
    YangColorManager colorManager = new YangColorManager(false);

    IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] {
            YangEditorPlugin.getDefault().getCombinedPreferenceStore(), EditorsUI.getPreferenceStore() });

    YangSourceViewerConfiguration configuration = new YangSourceViewerConfiguration(store, colorManager, null);

    yangSourceViewer.configure(configuration);
    yangSourceViewer.setEditable(false);
    Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT);
    yangSourceViewer.getTextWidget().setFont(font);

    return yangSourceViewer;
}