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

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

Introduction

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

Prototype

public static Font getTextFont() 

Source Link

Document

Returns JFace's text font.

Usage

From source file:eu.esdihumboldt.hale.ui.functions.numeric.SequentialIDParameterPage.java

License:Open Source License

/**
 * @see HaleWizardPage#createContent(Composite)
 *///from  w  w  w  .jav  a2 s. c  o  m
@Override
protected void createContent(Composite page) {
    page.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).spacing(10, 8).create());

    Label label;
    GridDataFactory labelLayout = GridDataFactory.swtDefaults().align(SWT.END, SWT.CENTER);
    GridDataFactory controlLayout = GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false);

    // select sequence type
    if (getParametersToHandle().containsKey(PARAM_SEQUENCE)) {
        label = new Label(page, SWT.NONE);
        label.setText("Sequence");
        labelLayout.applyTo(label);

        sequence = new ComboViewer(page);
        sequence.setContentProvider(EnumContentProvider.getInstance());
        sequence.setLabelProvider(new LabelProvider() {

            @Override
            public String getText(Object element) {
                if (element instanceof Sequence) {
                    switch ((Sequence) element) {
                    case overall:
                        return "Over all sequential IDs";
                    case type:
                        return "Per target instance type";
                    }
                }

                return super.getText(element);
            }

        });
        sequence.setInput(Sequence.class);
        controlLayout.applyTo(sequence.getControl());

        Sequence initialValue = Sequence
                .valueOf(getOptionalInitialValue(PARAM_SEQUENCE, new ParameterValue(Sequence.type.name()))
                        .as(String.class));
        sequence.setSelection(new StructuredSelection(initialValue));

        sequence.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                updateStatus();
            }
        });
    }

    // specify prefix
    if (getParametersToHandle().containsKey(PARAM_PREFIX)) {
        label = new Label(page, SWT.NONE);
        label.setText("Prefix");
        labelLayout.applyTo(label);

        prefix = new Text(page, SWT.SINGLE | SWT.BORDER);
        controlLayout.applyTo(prefix);

        prefix.setText(getOptionalInitialValue(PARAM_PREFIX, new ParameterValue("")).as(String.class));

        prefix.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(ModifyEvent e) {
                updateStatus();
            }
        });
    }

    // specify suffix
    if (getParametersToHandle().containsKey(PARAM_SUFFIX)) {
        label = new Label(page, SWT.NONE);
        label.setText("Suffix");
        labelLayout.applyTo(label);

        suffix = new Text(page, SWT.SINGLE | SWT.BORDER);
        controlLayout.applyTo(suffix);

        suffix.setText(getOptionalInitialValue(PARAM_SUFFIX, new ParameterValue("")).as(String.class));

        suffix.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(ModifyEvent e) {
                updateStatus();
            }
        });
    }

    // show example
    if (sequence != null && prefix != null && suffix != null) {
        label = new Label(page, SWT.NONE);
        label.setText("Example");
        labelLayout.applyTo(label);

        example = new Label(page, SWT.NONE);
        example.setFont(JFaceResources.getTextFont());
        controlLayout.applyTo(example);

        // error decoration
        exampleDecoration = new ControlDecoration(example, SWT.LEFT | SWT.TOP, page);
        FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault()
                .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
        exampleDecoration.setImage(fieldDecoration.getImage());
        exampleDecoration.hide();
    }

    updateStatus();
}

From source file:eu.esdihumboldt.hale.ui.scripting.groovy.GroovyEditor.java

License:Open Source License

/**
 * Create the text field.//  w w w  .  j  av  a2  s  . c om
 * 
 * @param parent the parent composite
 * @return the input text field.
 */
private SourceViewer createAndLayoutTextField(Composite parent) {
    IVerticalRuler ruler = createRuler();
    SourceViewer viewer = new SourceViewer(parent, ruler, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).indent(7, 0).create());
    viewer.getTextWidget().setFont(JFaceResources.getTextFont());

    SourceViewerKeyBindings.installDefault(viewer);

    return viewer;
}

From source file:eu.esdihumboldt.hale.ui.scripting.groovy.GroovyEditor.java

License:Open Source License

/**
 * Create the vertical ruler for the source viewer.
 * //from w  w  w  .ja va 2 s  .co m
 * @return the vertical ruler
 */
private IVerticalRuler createRuler() {
    final Display display = Display.getCurrent();
    CompositeRuler ruler = new CompositeRuler(3);
    LineNumberRulerColumn lineNumbers = new LineNumberRulerColumn();
    lineNumbers.setBackground(display.getSystemColor(SWT.COLOR_GRAY)); // SWT.COLOR_INFO_BACKGROUND));
    lineNumbers.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); // SWT.COLOR_INFO_FOREGROUND));
    lineNumbers.setFont(JFaceResources.getTextFont());
    ruler.addDecorator(0, lineNumbers);
    return ruler;
}

From source file:eu.esdihumboldt.hale.ui.style.dialog.XMLStylePage3.java

License:Open Source License

/**
 * @see IDialogPage#createControl(Composite)
 *//*from   w w  w.ja  v a 2s  .c  om*/
@Override
public void createControl(Composite parent) {
    changed = false;

    final Display display = parent.getDisplay();

    FillLayout fillLayout = new FillLayout();
    fillLayout.type = SWT.VERTICAL;
    parent.setLayout(fillLayout);

    CompositeRuler ruler = new CompositeRuler(3);
    LineNumberRulerColumn lineNumbers = new LineNumberRulerColumn();
    lineNumbers.setBackground(display.getSystemColor(SWT.COLOR_GRAY)); // SWT.COLOR_INFO_BACKGROUND));
    lineNumbers.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); // SWT.COLOR_INFO_FOREGROUND));
    lineNumbers.setFont(JFaceResources.getTextFont());
    ruler.addDecorator(0, lineNumbers);

    viewer = new SourceViewer(parent, ruler, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);

    viewer.getTextWidget().setFont(JFaceResources.getTextFont());

    SourceViewerConfiguration conf = new SourceViewerConfiguration();
    viewer.configure(conf);

    SLDTransformer trans = new SLDTransformer();
    trans.setIndentation(2);
    String xml;
    try {
        xml = trans.transform(getParent().getStyle());
    } catch (TransformerException e) {
        xml = "Error: " + e.getMessage(); //$NON-NLS-1$
    }
    IDocument doc = new Document();
    doc.set(xml);
    doc.addDocumentListener(new IDocumentListener() {

        @Override
        public void documentChanged(DocumentEvent event) {
            changed = true;
        }

        @Override
        public void documentAboutToBeChanged(DocumentEvent event) {
            // ignore
        }
    });
    viewer.setInput(doc);

    setControl(viewer.getControl());
}

From source file:fede.workspace.eclipse.java.fields.JavaSourceViewerField.java

License:Apache License

/**
 * Initializes the source viewer. This method is based on code in
 * BreakpointConditionEditor./*from w  w w .ja  v  a  2  s  .  co m*/
 * 
 * @param globalUIController
 *            the global ui controller
 */
private void configureSourceViewer() {

    // if (fConfiguration == null)
    // fConfiguration= new SourceViewerConfiguration();
    // fSourceViewer.configure(fConfiguration);

    JavaTextTools tools = JavaPlugin.getDefault().getJavaTextTools();
    document = new Document();
    IDocumentPartitioner partitioner = tools.createDocumentPartitioner();
    document.setDocumentPartitioner(partitioner);
    partitioner.connect(document);
    fSourceViewer.configure(new DisplayViewerConfiguration(getJavaProject(), getJavaType()) {
        @Override
        public IContentAssistProcessor getContentAssistantProcessor() {
            return getCompletionProcessor();
        }
    });
    fSourceViewer.setEditable(true);
    fSourceViewer.setDocument(document);
    final IUndoManager undoManager = new TextViewerUndoManager(10);
    fSourceViewer.setUndoManager(undoManager);
    undoManager.connect(fSourceViewer);

    fSourceViewer.getTextWidget().setFont(JFaceResources.getTextFont());
    fSourceViewer.getTextWidget().setData(UIField.CADSE_MODEL_KEY, _field);

    Control control = ((SourceViewer) fSourceViewer).getControl();
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 100;
    gd.widthHint = 400;
    control.setLayoutData(gd);

    // gd= (GridData)fSourceViewer.getControl().getLayoutData();
    // gd.heightHint= 100;
    // gd.widthHint= 400;

    fDocumentListener = new IDocumentListener() {
        public void documentAboutToBeChanged(DocumentEvent event) {
        }

        public void documentChanged(DocumentEvent event) {
            _swtuiplatform.broadcastValueChanged(_page, _field, getVisualValue());
        }
    };
    fSourceViewer.getDocument().addDocumentListener(fDocumentListener);

    IHandler handler = new AbstractHandler() {

        public Object execute(ExecutionEvent event) throws ExecutionException {
            ((JavaSourceViewer) fSourceViewer).doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
            return null;
        }
    };
    // fSubmission = new HandlerSubmission(null,
    // fSourceViewer.getControl().getShell(), null,
    // ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, handler,
    // ISources.LEGACY_MEDIUM); //$NON-NLS-1$
    IWorkbench workbench = PlatformUI.getWorkbench();
    IHandlerService commandSupport = (IHandlerService) workbench.getAdapter(IHandlerService.class);
    fSubmission = commandSupport.activateHandler(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS,
            handler);

    // commandSupport.addHandlerSubmission(fSubmission);
}

From source file:fede.workspace.eclipse.java.fields.JDISourceViewer.java

License:Apache License

/**
* Updates the viewer's font to match the preferences.
*//*from   w  ww. j a v a 2s .  c  o  m*/
private void updateViewerFont() {
    IPreferenceStore store = getPreferenceStore();
    if (store != null) {
        FontData data = null;
        if (store.contains(JFaceResources.TEXT_FONT) && !store.isDefault(JFaceResources.TEXT_FONT)) {
            data = PreferenceConverter.getFontData(store, JFaceResources.TEXT_FONT);
        } else {
            data = PreferenceConverter.getDefaultFontData(store, JFaceResources.TEXT_FONT);
        }
        if (data != null) {
            Font font = new Font(getTextWidget().getDisplay(), data);
            applyFont(font);
            if (getFont() != null) {
                getFont().dispose();
            }
            setFont(font);
            return;
        }
    }
    // if all the preferences failed
    applyFont(JFaceResources.getTextFont());
}

From source file:jasima_gui.editor.ConversionReportView.java

License:Open Source License

public ConversionReportView(Composite parent, final TopLevelEditor editor) {
    FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    message = toolkit.createFormText(parent, true);
    message.setFont("code", JFaceResources.getTextFont());
    message.setColor("light", parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
    message.addHyperlinkListener(new HyperlinkAdapter() {
        @Override/*from   ww  w .j  a v a  2 s .co m*/
        public void linkActivated(HyperlinkEvent e) {
            if (e.getHref().toString().equals(ConversionReport.HREF_CONFIRM)) {
                editor.confirmConversionReport();
            }
        }
    });
}

From source file:jasima_gui.editor.DeserializationFailure.java

License:Open Source License

public DeserializationFailure(Composite parent) {
    FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    Composite comp = toolkit.createComposite(parent);

    GridLayout grid = new GridLayout(2, false);
    grid.marginTop = 10;//  ww  w .  j a  va  2  s .  com
    comp.setLayout(grid);

    Label icon = toolkit.createLabel(comp, null);
    icon.setImage(icon.getDisplay().getSystemImage(SWT.ERROR));

    label = toolkit.createFormText(comp, false);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(label);
    label.setFont(JFaceResources.getTextFont());
    label.setWhitespaceNormalized(false);
}

From source file:name.schedenig.eclipse.grepconsole.view.grepview.GrepView.java

License:Open Source License

/**
 * Creates GUI content.//ww w .j  a va 2s . com
 * 
 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
 */
@Override
public void createPartControl(Composite parent) {
    colorRegistry = new ColorRegistry(Activator.getDefault().getColorRegistry());

    text = new StyledText(parent, SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL);
    text.setFont(JFaceResources.getTextFont());

    ScopedPreferenceStore debugUiPrefs = GrepConsoleUtil.getDebugUiPreferences();

    if (debugUiPrefs != null) {
        debugUiPrefs.addPropertyChangeListener(this);
        refreshColors();
    }

    text.addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(DisposeEvent e) {
            text.getContent().removeTextChangeListener(GrepView.this);
        }
    });

    linkAdapter = new LinkListener(text, lineStyleListener);
    linkAdapter.attach();

    Menu menu = new Menu(text);
    miJumpTo = new MenuItem(menu, SWT.PUSH);
    miJumpTo.setText(Messages.GrepView_jump_to);

    miJumpTo.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            int offset = calculateOriginalOffset(selectedLineIndex);

            if (offset < 0) {
                return;
            }

            getParticipant().getStyledText().setSelection(offset);
        }
    });

    text.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) {
            int y = e.y;
            selectedLineIndex = text.getLineIndex(y);
        }
    });

    menu.addMenuListener(new MenuAdapter() {
        @Override
        public void menuShown(MenuEvent e) {
            int offset = calculateOriginalOffset(selectedLineIndex);
            miJumpTo.setEnabled(offset >= 0);
        }
    });

    text.setMenu(menu);
    participantActivated(Activator.getDefault().getActiveParticipant());

    Activator.getDefault().getPreferenceStore().addPropertyChangeListener(this);
}

From source file:name.schedenig.eclipse.grepconsole.view.items.EditableItemsPanel.java

License:Open Source License

/**
 * Creates the GUI content.// w  w  w.  j av  a2s .  c om
 */
private void init() {
    addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(DisposeEvent e) {
            colorRegistry.disposeColors();
        }
    });

    headerFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);// JFaceResources.getHeaderFont();

    colorRegistry = new ColorRegistry(Activator.getDefault().getColorRegistry());
    clipboard = new Clipboard(getDisplay());

    setLayoutData(new GridData(GridData.FILL_BOTH));

    FormLayout layout = new FormLayout();
    setLayout(layout);

    panelTreeAndButtons = new Composite(this, SWT.NONE);
    new GridLayoutBuilder(panelTreeAndButtons, 2, false).setMargins(0).apply();

    treePanel = new ItemsTreePanel(panelTreeAndButtons, SWT.BORDER);
    treePanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 10));
    treePanel.addListener(this);

    hookTreeDragAndDrop();

    Tree tree = treePanel.getTree();

    treeMenu = new Menu(tree);
    treeMenu.addMenuListener(new MenuAdapter() {
        @Override
        public void menuShown(MenuEvent e) {
            refreshMenuItems();
        }
    });

    miCut = new MenuItem(treeMenu, SWT.PUSH);
    miCut.setText(Messages.EditableItemsPanel_cut);

    miCut.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            doCopy(true);
        }
    });

    miCopy = new MenuItem(treeMenu, SWT.PUSH);
    miCopy.setText(Messages.EditableItemsPanel_copy);

    miCopy.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            doCopy(false);
        }
    });

    miPaste = new MenuItem(treeMenu, SWT.PUSH);
    miPaste.setText(Messages.EditableItemsPanel_paste);

    miPaste.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            doPaste();
        }
    });

    tree.setMenu(treeMenu);

    tree.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.character == SWT.DEL) {
                doRemove();
                e.doit = false;
            } else if (e.keyCode == SWT.F2) {
                doEdit();
                e.doit = false;
            } else if (e.keyCode == 'c' && (e.stateMask & SWT.MOD1) != 0) {
                doCopy(false);
                e.doit = false;
            } else if (e.keyCode == 'x' && (e.stateMask & SWT.MOD1) != 0) {
                doCopy(true);
                e.doit = false;
            } else if (e.keyCode == 'v' && (e.stateMask & SWT.MOD1) != 0) {
                doPaste();
            }
        }
    });

    btnAddFolder = new Button(panelTreeAndButtons, SWT.PUSH);
    btnAddFolder.setText(Messages.EditableItemsPanel_add_folder);
    btnAddFolder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

    btnAddFolder.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            doAddFolder();
        }
    });

    btnAddExpression = new Button(panelTreeAndButtons, SWT.PUSH);
    btnAddExpression.setText(Messages.EditableItemsPanel_add_expression);
    btnAddExpression.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

    btnAddExpression.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            doAddExpression(null);
        }
    });

    btnEdit = new Button(panelTreeAndButtons, SWT.PUSH);
    btnEdit.setText(Messages.EditableItemsPanel_edit);
    btnEdit.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

    btnEdit.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            doEdit();
        }
    });

    btnRemove = new Button(panelTreeAndButtons, SWT.PUSH);
    btnRemove.setText(Messages.EditableItemsPanel_remove);
    btnRemove.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

    btnRemove.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            doRemove();
        }
    });

    btnLoad = new Button(panelTreeAndButtons, SWT.PUSH);
    btnLoad.setText(Messages.EditableItemsPanel_load);
    btnLoad.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

    btnLoad.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            doLoad();
        }
    });

    btnSaveSelected = new Button(panelTreeAndButtons, SWT.PUSH);
    btnSaveSelected.setText(Messages.EditableItemsPanel_save_selected);
    btnSaveSelected.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

    btnSaveSelected.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            doSave(false);
        }
    });

    btnSaveAll = new Button(panelTreeAndButtons, SWT.PUSH);
    btnSaveAll.setText(Messages.EditableItemsPanel_save_all);
    btnSaveAll.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

    btnSaveAll.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            doSave(true);
        }
    });

    sash = new Sash(this, SWT.HORIZONTAL | SWT.SMOOTH);

    labelPreview = new Label(this, SWT.NONE);
    labelPreview.setFont(headerFont);
    labelPreview.setText(Messages.EditableItemsPanel_preview);

    grepLineStyleListener = new GrepLineStyleListener(getShell(), null);
    grepLineStyleListener.setColorRegistry(colorRegistry);

    stPreview = new StyledText(this, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    stPreview.addLineStyleListener(grepLineStyleListener);
    stPreview.setFont(JFaceResources.getTextFont());

    menuPreview = new Menu(stPreview);
    miAddExpressionFromPreview = new MenuItem(menuPreview, SWT.PUSH);
    miAddExpressionFromPreview.setText(Messages.EditableItemsPanel_add_expression);
    miAddExpressionFromPreview.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            doAddExpression(stPreview.getSelectionText());
        }
    });

    miLoadDefault = new MenuItem(menuPreview, SWT.PUSH);
    miLoadDefault.setText(Messages.EditableItemsPanel_load_default);
    miLoadDefault.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            doLoadDefaultPreview();
        }
    });

    miSaveDefault = new MenuItem(menuPreview, SWT.PUSH);
    miSaveDefault.setText(Messages.EditableItemsPanel_save_default);
    miSaveDefault.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            doSaveDefaultPreview();
        }
    });

    new MenuItem(menuPreview, SWT.SEPARATOR);
    new PreviewColorHandler(stPreview, menuPreview);

    menuPreview.addMenuListener(new MenuAdapter() {
        @Override
        public void menuShown(MenuEvent e) {
            Set<AbstractGrepModelElement> selection = treePanel.getSelectedElements();
            boolean hasSelection = selection != null && !selection.isEmpty();

            String text = stPreview.getSelectionText();
            miAddExpressionFromPreview.setEnabled(hasSelection && text != null && text.length() > 0);

            super.menuShown(e);
        }
    });

    stPreview.setMenu(menuPreview);

    int preferredPreviewHeight = ((getDisplay().getDPI().y
            * JFaceResources.getTextFont().getFontData()[0].getHeight()) / 72) * 4;

    FormData fd = new FormData();
    fd.top = new FormAttachment(0, 0);
    fd.bottom = new FormAttachment(sash, 0);
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(100, 0);
    panelTreeAndButtons.setLayoutData(fd);

    fd = new FormData();
    fd.bottom = new FormAttachment(100, -sash.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - preferredPreviewHeight);
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(100, 0);
    sash.setLayoutData(fd);

    fd = new FormData();
    fd.top = new FormAttachment(sash, 5);
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(100, 0);
    //fd.bottom = new FormAttachment(100, 0);
    labelPreview.setLayoutData(fd);

    fd = new FormData();
    fd.top = new FormAttachment(labelPreview, 0);
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(100, 0);
    fd.bottom = new FormAttachment(100, 0);
    stPreview.setLayoutData(fd);

    sash.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Rectangle sashBounds = sash.getBounds();
            Rectangle clientArea = getClientArea();

            setSashPosition(-(clientArea.height - sashBounds.height - e.y));
        }
    });

    addControlListener(new ControlAdapter() {
        @Override
        public void controlResized(ControlEvent e) {
            int height = getSize().y;
            FormData fd = (FormData) sash.getLayoutData();

            int min = -height + 50;

            if (min > 0) {
                min = 0;
            }

            if (fd.bottom.offset <= min) {
                setSashPosition(min);
            }
        }
    });

    if (sashPosition != null) {
        setSashPosition(sashPosition);
    }

    refreshButtons();

    if (previewText == null || previewText.trim().length() == 0) {
        stPreview.setText(Activator.getDefault().getPreviewText());
    } else {
        stPreview.setText(previewText);
    }
}