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

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

Introduction

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

Prototype

public static Font getHeaderFont() 

Source Link

Document

Returns the JFace's header font.

Usage

From source file:de.gebit.integrity.eclipse.views.IntegrityTestRunnerView.java

License:Open Source License

/**
 * This is a callback that will allow us to create the viewer and initialize it.
 *//*from   ww w  .j a va  2 s.  co  m*/
// SUPPRESS CHECKSTYLE MethodLength
public void createPartControl(final Composite aParent) {
    aParent.setLayout(new FillLayout());

    final FormToolkit tempToolkit = new FormToolkit(aParent.getDisplay());

    resultSuccessColor = new Color(Display.getCurrent(), 0, 94, 13);
    resultFailureColor = new Color(Display.getCurrent(), 190, 0, 0);
    resultNeutralColor = new Color(Display.getCurrent(), 0, 0, 0);
    resultExceptionColor = new Color(Display.getCurrent(), 204, 163, 0);

    resultTableSuccessColor = new Color(Display.getCurrent(), 205, 255, 222);
    resultTableFailureColor = new Color(Display.getCurrent(), 255, 130, 130);

    searchContainerColor = new Color(Display.getCurrent(), 220, 220, 220);

    resultSuccessIconImage = Activator.getImageDescriptor("icons/suite_success_big.png").createImage();
    resultFailureIconImage = Activator.getImageDescriptor("icons/suite_failure_big.png").createImage();
    resultExceptionIconImage = Activator.getImageDescriptor("icons/suite_exception_big.png").createImage();

    sashForm = new SashForm(aParent, SWT.HORIZONTAL | SWT.SMOOTH);

    treeContainer = new Form(sashForm, SWT.NONE);
    treeContainer.setText("Not connected");
    treeContainer.getBody().setLayout(new FormLayout());
    treeContainer.setBackground(tempToolkit.getColors().getBackground());
    treeContainer.setForeground(tempToolkit.getColors().getColor(IFormColors.TITLE));
    treeContainer.setFont(JFaceResources.getHeaderFont());
    tempToolkit.decorateFormHeading(treeContainer);

    executionProgress = new ProgressBar(treeContainer.getBody(), SWT.NONE);
    FormData tempFormData = new FormData();
    tempFormData.left = new FormAttachment(0, 0);
    tempFormData.right = new FormAttachment(100, 0);
    tempFormData.top = new FormAttachment(0, 0);
    tempFormData.bottom = new FormAttachment(0, 16);
    executionProgress.setLayoutData(tempFormData);

    treeViewer = new TreeViewer(treeContainer.getBody(), SWT.VIRTUAL | SWT.H_SCROLL | SWT.V_SCROLL);
    treeViewer.setUseHashlookup(true);
    treeViewer.setContentProvider(new TestTreeContentProvider(treeViewer));
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(0, 0);
    tempFormData.right = new FormAttachment(100, 0);
    tempFormData.top = new FormAttachment(executionProgress, 0);
    tempFormData.bottom = new FormAttachment(100, -18);
    treeViewer.getTree().setLayoutData(tempFormData);
    treeViewer.getTree().getVerticalBar().addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent anEvent) {
            // nothing to do
        }

        public void widgetSelected(SelectionEvent anEvent) {
            if (anEvent.detail == SWT.NONE) {
                treeViewerIsScrolledManually = false;
            } else if (anEvent.detail == SWT.DRAG) {
                treeViewerIsScrolledManually = true;
            }
        }
    });

    searchContainer = new Composite(treeContainer.getBody(), SWT.NONE);
    searchContainer.setLayout(new FormLayout());
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(0, 0);
    tempFormData.right = new FormAttachment(100, 0);
    tempFormData.top = new FormAttachment(treeViewer.getControl(), 0);
    tempFormData.height = 18;
    searchContainer.setLayoutData(tempFormData);
    searchContainer.setBackground(searchContainerColor);

    searchErrorButtonEnabledImage = Activator.getImageDescriptor("icons/search_failed_enabled.gif")
            .createImage();

    searchErrorButton = new Button(searchContainer, SWT.FLAT);
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(0, 0);
    tempFormData.width = 16;
    tempFormData.top = new FormAttachment(0, 2);
    tempFormData.height = 16;
    searchErrorButton.setImage(searchErrorButtonEnabledImage);
    searchErrorButton.setLayoutData(tempFormData);
    searchErrorButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event anEvent) {
            // repeated clicks shall just jump to the next result
            if (!performTreeSearchForFailures()) {
                jumpToNextSearchResult();
            }
        }
    });

    searchTextField = new Text(searchContainer, SWT.SINGLE);
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(0, 16);
    tempFormData.right = new FormAttachment(100, -100);
    tempFormData.top = new FormAttachment(0, 2);
    tempFormData.height = 16;
    searchTextField.setText("");
    searchTextField.setLayoutData(tempFormData);
    searchTextField.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent anEvent) {
            performTreeSearch();
        }
    });
    searchTextField.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent anEvent) {
            searchTextFieldJustGainedFocus = false;
        }

        @Override
        public void focusGained(FocusEvent anEvent) {
            searchTextFieldJustGainedFocus = true;
        }
    });
    searchTextField.addMouseListener(new MouseListener() {

        @Override
        public void mouseUp(MouseEvent anEvent) {
            // Perform a full selection of all entered text if there is text AND the text field just gained the
            // focus.
            if (searchTextFieldJustGainedFocus && searchTextField.getText().length() > 0) {
                searchTextField.selectAll();
            }
            searchTextFieldJustGainedFocus = false;
        }

        @Override
        public void mouseDown(MouseEvent anEvent) {
            // ignored
        }

        @Override
        public void mouseDoubleClick(MouseEvent anEvent) {
            // ignored
        }
    });

    searchLeftButtonEnabledImage = Activator.getImageDescriptor("icons/search_prev_enabled.gif").createImage();

    searchLeftButton = new Button(searchContainer, SWT.FLAT);
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(searchTextField, 0);
    tempFormData.width = 16;
    tempFormData.top = new FormAttachment(0, 2);
    tempFormData.height = 16;
    searchLeftButton.setImage(searchLeftButtonEnabledImage);
    searchLeftButton.setLayoutData(tempFormData);
    searchLeftButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event anEvent) {
            jumpToPreviousSearchResult();
        }
    });

    searchRightButtonEnabledImage = Activator.getImageDescriptor("icons/search_next_enabled.gif").createImage();

    searchRightButton = new Button(searchContainer, SWT.FLAT);
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(searchLeftButton, 0);
    tempFormData.width = 16;
    tempFormData.top = new FormAttachment(0, 2);
    tempFormData.height = 16;
    searchRightButton.setImage(searchRightButtonEnabledImage);
    searchRightButton.setLayoutData(tempFormData);
    searchRightButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event anEvent) {
            jumpToNextSearchResult();
        }
    });

    searchPositionLabel = new Label(searchContainer, SWT.NONE);
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(searchRightButton, 0);
    tempFormData.right = new FormAttachment(100, 0);
    tempFormData.top = new FormAttachment(0, 2);
    tempFormData.height = 16;
    searchPositionLabel.setBackground(searchContainerColor);
    searchPositionLabel.setLayoutData(tempFormData);
    searchPositionLabel.setText("");
    searchPositionLabel.setAlignment(SWT.CENTER);

    detailsContainer = new Composite(sashForm, SWT.NONE);
    detailsContainer.setLayout(new FillLayout());

    details = new ScrolledForm(detailsContainer, SWT.V_SCROLL | SWT.H_SCROLL);
    details.setExpandHorizontal(true);
    details.setExpandVertical(true);
    details.setBackground(tempToolkit.getColors().getBackground());
    details.setForeground(tempToolkit.getColors().getColor(IFormColors.TITLE));
    details.setFont(JFaceResources.getHeaderFont());
    details.getBody().setLayout(new FormLayout());
    tempToolkit.decorateFormHeading(details.getForm());

    fixtureLinkGroup = new HyperlinkGroup(aParent.getDisplay());
    fixtureLink = new Hyperlink(details.getBody(), SWT.NONE);
    fixtureLink.setBackground(details.getBackground());
    fixtureLink.setText("");
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(0, 5);
    tempFormData.right = new FormAttachment(100, -5);
    tempFormData.top = new FormAttachment(0, 3);
    tempFormData.height = 10;
    fixtureLink.setLayoutData(tempFormData);
    fixtureLink.addHyperlinkListener(new HyperlinkAdapter() {
        public void linkActivated(HyperlinkEvent anEvent) {
            jumpToJavaMethod(anEvent.getLabel());
        }
    });
    fixtureLinkGroup.add(fixtureLink);

    forkLabel = new Label(details.getBody(), SWT.NONE);
    forkLabel.setText("");
    forkLabel.setBackground(tempToolkit.getColors().getBackground());
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(0, 5);
    tempFormData.right = new FormAttachment(100, -5);
    tempFormData.top = new FormAttachment(fixtureLink, 3);
    tempFormData.height = 14;
    forkLabel.setLayoutData(tempFormData);

    detailGroups = new Composite(details.getBody(), SWT.NONE);
    detailGroups.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    GridLayout tempGridLayout = new GridLayout(1, true);
    tempGridLayout.verticalSpacing = 10;
    detailGroups.setLayout(tempGridLayout);
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(0, 5);
    tempFormData.right = new FormAttachment(100, -5);
    tempFormData.top = new FormAttachment(forkLabel, 3);
    tempFormData.bottom = new FormAttachment(100, 0);
    detailGroups.setLayoutData(tempFormData);

    resultSection = tempToolkit.createSection(detailGroups, Section.TITLE_BAR | Section.EXPANDED);
    resultSection.setText("Result");
    GridData tempGridData = new GridData();
    tempGridData.minimumHeight = 10;
    tempGridData.horizontalIndent = 5;
    tempGridData.grabExcessHorizontalSpace = true;
    tempGridData.horizontalAlignment = GridData.FILL;
    resultSection.setLayoutData(tempGridData);
    resultSection.setLayout(new FillLayout());

    resultComposite = tempToolkit.createComposite(resultSection);
    tempToolkit.paintBordersFor(resultComposite);
    resultSection.setClient(resultComposite);
    resultComposite.setLayout(new FormLayout());

    parameterSection = tempToolkit.createSection(detailGroups, Section.TITLE_BAR | Section.EXPANDED);
    parameterSection.setText("Parameters");
    tempGridData = new GridData();
    tempGridData.minimumHeight = SWT.DEFAULT;
    tempGridData.heightHint = 130;
    tempGridData.horizontalIndent = 5;
    tempGridData.grabExcessHorizontalSpace = true;
    tempGridData.horizontalAlignment = GridData.FILL;
    parameterSection.setLayoutData(tempGridData);
    parameterSection.setLayout(new FillLayout());

    parameterComposite = tempToolkit.createComposite(parameterSection);
    tempToolkit.paintBordersFor(parameterComposite);
    parameterSection.setClient(parameterComposite);
    parameterComposite.setLayout(new FillLayout());

    parameterTable = new TableViewer(parameterComposite, SWT.FULL_SELECTION);
    parameterTable.setContentProvider(new ArrayContentProvider());
    configureTable(parameterTable);

    variableSection = tempToolkit.createSection(detailGroups, Section.TITLE_BAR | Section.EXPANDED);
    variableSection.setText("Variable definitions");
    tempGridData = new GridData();
    tempGridData.minimumHeight = SWT.DEFAULT;
    tempGridData.heightHint = 150;
    tempGridData.horizontalIndent = 5;
    tempGridData.grabExcessHorizontalSpace = true;
    tempGridData.horizontalAlignment = GridData.FILL;
    variableSection.setLayoutData(tempGridData);
    variableSection.setLayout(new FillLayout());

    variableComposite = tempToolkit.createComposite(variableSection);
    tempToolkit.paintBordersFor(variableComposite);
    variableSection.setClient(variableComposite);
    variableComposite.setLayout(new FillLayout());

    variableTable = new TableViewer(variableComposite, SWT.FULL_SELECTION);
    variableTable.setContentProvider(new ArrayContentProvider());
    configureTable(variableTable);

    resultComposite = tempToolkit.createComposite(resultSection);
    tempToolkit.paintBordersFor(resultComposite);
    resultSection.setClient(resultComposite);
    resultComposite.setLayout(new FormLayout());

    resultTableComposite = tempToolkit.createComposite(resultComposite);
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(0, 5);
    tempFormData.right = new FormAttachment(100, -5);
    tempFormData.top = new FormAttachment(resultComposite, 10);
    tempFormData.bottom = new FormAttachment(resultTableComposite, RESULT_TABLE_HEIGHT, SWT.TOP);
    resultTableComposite.setLayoutData(tempFormData);
    resultTableComposite.setLayout(new FillLayout());

    resultTable = new TableViewer(resultTableComposite, SWT.FULL_SELECTION);
    resultTable.setContentProvider(new ArrayContentProvider());
    configureResultTable(resultTable);

    varUpdateTableComposite = tempToolkit.createComposite(resultComposite);
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(0, 5);
    tempFormData.right = new FormAttachment(100, -5);
    tempFormData.top = new FormAttachment(resultComposite, 10);
    tempFormData.bottom = new FormAttachment(varUpdateTableComposite, RESULT_TABLE_HEIGHT, SWT.TOP);
    varUpdateTableComposite.setLayoutData(tempFormData);
    varUpdateTableComposite.setLayout(new FillLayout());

    varUpdateTable = new TableViewer(varUpdateTableComposite, SWT.FULL_SELECTION);
    varUpdateTable.setContentProvider(new ArrayContentProvider());
    configureVarUpdateTable(varUpdateTable);

    resultLine1Name = new Label(resultComposite, SWT.WRAP);
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(0, 5);
    tempFormData.right = new FormAttachment(100, -5);
    tempFormData.top = new FormAttachment(0, 4);
    resultLine1Name.setLayoutData(tempFormData);

    resultLine1Border = new Composite(resultComposite, SWT.NONE);
    resultLine1Border.setForeground(resultNeutralColor);
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(0, 5);
    tempFormData.right = new FormAttachment(100, -5);
    tempFormData.top = new FormAttachment(resultLine1Name, 2, SWT.BOTTOM);
    tempFormData.bottom = new FormAttachment(resultLine1Border, RESULT_TEXTFIELD_HEIGHT, SWT.TOP);
    resultLine1Border.setLayoutData(tempFormData);
    FillLayout tempFill = new FillLayout();
    tempFill.marginHeight = 1;
    tempFill.marginWidth = 1;
    resultLine1Border.setLayout(tempFill);
    configureTextFieldBorder(resultLine1Border);

    resultLine1Text = new Text(resultLine1Border, SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL);
    resultLine1Text.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));

    resultLine2Name = new Label(resultComposite, SWT.WRAP);
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(0, 5);
    tempFormData.right = new FormAttachment(100, -5);
    tempFormData.top = new FormAttachment(resultLine1Border, 6);
    resultLine2Name.setLayoutData(tempFormData);

    resultLine2Border = new Composite(resultComposite, SWT.NONE);
    resultLine2Border.setForeground(resultNeutralColor);
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(0, 5);
    tempFormData.right = new FormAttachment(100, -5);
    tempFormData.top = new FormAttachment(resultLine2Name, 2, SWT.BOTTOM);
    tempFormData.bottom = new FormAttachment(resultLine2Border, RESULT_TEXTFIELD_HEIGHT, SWT.TOP);
    resultLine2Border.setLayoutData(tempFormData);
    tempFill = new FillLayout();
    tempFill.marginHeight = 1;
    tempFill.marginWidth = 1;
    resultLine2Border.setLayout(tempFill);
    configureTextFieldBorder(resultLine2Border);

    resultLine2Text = new Text(resultLine2Border, SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL);
    resultLine2Text.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));

    resultLine3Name = new Label(resultComposite, SWT.WRAP);
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(0, 5);
    tempFormData.right = new FormAttachment(100, -5);
    tempFormData.top = new FormAttachment(resultLine2Border, 6);
    resultLine3Name.setLayoutData(tempFormData);
    resultLine3Name.setText("Extended Result Data");

    resultLine3Border = new Composite(resultComposite, SWT.NONE);
    resultLine3Border.setForeground(resultNeutralColor);
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(0, 5);
    tempFormData.right = new FormAttachment(100, -5);
    tempFormData.top = new FormAttachment(resultLine3Name, 2, SWT.BOTTOM);
    tempFormData.bottom = new FormAttachment(resultLine3Border, 0, SWT.TOP);
    resultLine3Border.setLayoutData(tempFormData);
    resultLine3Border.setLayout(new FormLayout());
    configureTextFieldBorder(resultLine3Border);

    resultFailureIcon = new Label(resultComposite, SWT.NONE);
    resultFailureIcon.setImage(resultFailureIconImage);
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(50, -24);
    tempFormData.top = new FormAttachment(0, 10);
    tempFormData.width = 48;
    tempFormData.height = 48;
    resultFailureIcon.setLayoutData(tempFormData);

    resultSuccessIcon = new Label(resultComposite, SWT.NONE);
    resultSuccessIcon.setImage(resultSuccessIconImage);
    tempFormData = new FormData();
    tempFormData.right = new FormAttachment(resultFailureIcon, -16);
    tempFormData.top = new FormAttachment(0, 10);
    tempFormData.width = 48;
    tempFormData.height = 48;
    resultSuccessIcon.setLayoutData(tempFormData);

    resultExceptionIcon = new Label(resultComposite, SWT.NONE);
    resultExceptionIcon.setImage(resultExceptionIconImage);
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(resultFailureIcon, 16);
    tempFormData.top = new FormAttachment(0, 10);
    tempFormData.width = 48;
    tempFormData.height = 48;
    resultExceptionIcon.setLayoutData(tempFormData);

    resultSuccessCountLabel = new Label(resultComposite, SWT.CENTER);
    resultSuccessCountLabel.setText("123");
    resultSuccessCountLabel.setForeground(resultSuccessColor);
    FontData[] tempFontData = resultSuccessCountLabel.getFont().getFontData();
    tempFontData[0].setHeight(16);
    tempFontData[0].setStyle(SWT.BOLD);
    resultSuccessCountLabel.setFont(new Font(Display.getCurrent(), tempFontData[0]));
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(resultSuccessIcon, -32, SWT.CENTER);
    tempFormData.top = new FormAttachment(resultSuccessIcon, 4);
    tempFormData.width = 64;
    tempFormData.height = 24;
    resultSuccessCountLabel.setLayoutData(tempFormData);

    resultFailureCountLabel = new Label(resultComposite, SWT.CENTER);
    resultFailureCountLabel.setText("123");
    resultFailureCountLabel.setForeground(resultFailureColor);
    tempFontData = resultFailureCountLabel.getFont().getFontData();
    tempFontData[0].setHeight(16);
    tempFontData[0].setStyle(SWT.BOLD);
    resultFailureCountLabel.setFont(new Font(Display.getCurrent(), tempFontData[0]));
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(resultFailureIcon, -32, SWT.CENTER);
    tempFormData.top = new FormAttachment(resultFailureIcon, 4);
    tempFormData.width = 64;
    tempFormData.height = 24;
    resultFailureCountLabel.setLayoutData(tempFormData);

    resultExceptionCountLabel = new Label(resultComposite, SWT.CENTER);
    resultExceptionCountLabel.setText("123");
    resultExceptionCountLabel.setForeground(resultExceptionColor);
    tempFontData = resultExceptionCountLabel.getFont().getFontData();
    tempFontData[0].setHeight(16);
    tempFontData[0].setStyle(SWT.BOLD);
    resultExceptionCountLabel.setFont(new Font(Display.getCurrent(), tempFontData[0]));
    tempFormData = new FormData();
    tempFormData.left = new FormAttachment(resultExceptionIcon, -32, SWT.CENTER);
    tempFormData.top = new FormAttachment(resultExceptionIcon, 4);
    tempFormData.width = 64;
    tempFormData.height = 24;
    resultExceptionCountLabel.setLayoutData(tempFormData);

    PlatformUI.getWorkbench().getHelpSystem().setHelp(treeViewer.getControl(),
            "de.gebit.integrity.eclipse.viewer");
    attachTreeInteractionListeners();
    makeActions();
    hookContextMenu();
    contributeToActionBars();
    updateDetailPanel(null, null);
}

From source file:eu.esdihumboldt.hale.ui.functions.groovy.internal.PageFunctions.java

License:Open Source License

/**
 * @see org.eclipse.jface.dialogs.DialogTray#createContents(org.eclipse.swt.widgets.Composite)
 *//*from   w  w  w. ja  v  a2  s . c o  m*/
@Override
protected Control createContents(Composite parent) {

    Composite comp = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(comp);
    Label label = new Label(comp, SWT.NONE);
    label.setText("Functions Overview");
    label.setFont(JFaceResources.getHeaderFont());

    // tree viwever
    PatternFilter patternFilter = new TreePathPatternFilter();
    patternFilter.setIncludeLeadingWildcard(true);
    final FilteredTree filteredTree = new TreePathFilteredTree(comp,
            SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, patternFilter, true);

    TreeViewer tree = filteredTree.getViewer();
    tree.setUseHashlookup(true);
    HelperFunctionLabelProvider labelProvider = new HelperFunctionLabelProvider();
    tree.setLabelProvider(labelProvider);
    IContentProvider contentProvider;

    HelperFunctionsService functions = HaleUI.getServiceProvider().getService(HelperFunctionsService.class);

    contentProvider = new TreePathProviderAdapter(new HelperFunctionContentProvider(functions));

    tree.setContentProvider(contentProvider);
    GridDataFactory.fillDefaults().grab(true, true).hint(280, 400).applyTo(filteredTree);

    tree.setComparator(new HelperFunctionComparator());

    tree.setInput(Category.ROOT);

    // Examples
    Label example = new Label(comp, SWT.NONE);
    example.setText("Function documentation");

    try {
        browser = new Browser(comp, SWT.WRAP | SWT.BORDER);
        browser.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(300, 250).create());
    } catch (Throwable e) {

        if (BROWSER_ERROR_REPORTED.compareAndSet(false, true)) {
            log.error("Could not create embedded browser, using text field as fall-back", e);
        }

        textField = new Text(comp, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
        textField.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(300, 250).create());

    }

    tree.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {

            String eg = null;
            HelperFunctionSpecification hfs = null;

            if (!event.getSelection().isEmpty()) {
                TreeSelection treesel = (TreeSelection) event.getSelection();
                TreePath[] paths = treesel.getPaths();
                if (paths != null) {
                    TreePath path = paths[0];
                    for (int i = 0; i < path.getSegmentCount(); i++) {
                        if (path.getSegment(i) instanceof Category) {
                            eg = "Select a function to see its documentation.";
                            if (browser != null) {
                                browser.setText(eg);
                            } else if (textField != null) {
                                textField.setText(eg);
                            }
                        } else if (path.getSegment(i) instanceof HelperFunctionOrCategory) {

                            HelperFunctionOrCategory hfoc = ((HelperFunctionOrCategory) path.getSegment(i));

                            try {
                                hfs = (HelperFunctionSpecification) hfoc.asFunction().getSpec(hfoc.getName());
                            } catch (Exception e) {
                                log.error(
                                        "There is a problem in retrieving the specification for a helper function.",
                                        e);
                            }

                            // displaying the specification
                            if (browser != null) {
                                eg = getFunctionSpecHTML(hfs);
                                browser.setText(eg);
                            } else if (textField != null) {
                                eg = getFunctionSpecText(hfs);
                                textField.setText(eg);
                            }

                        }
                    }
                }
            }

        }

    });
    return comp;

}

From source file:eu.esdihumboldt.hale.ui.functions.groovy.internal.TypeStructureTray.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {
    Composite page = new Composite(parent, SWT.NONE);

    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(page);

    // retrieve the types
    final Collection<? extends TypeDefinition> types = this.types.getTypes();

    // heading//www. j  ava 2  s.  c om
    Label caption = new Label(page, SWT.NONE);
    switch (schemaSpace) {
    case SOURCE:
        caption.setText("Source structure");
        break;
    case TARGET:
        caption.setText("Target structure");
        break;
    }
    caption.setFont(JFaceResources.getHeaderFont());

    // create tree viewer
    PatternFilter patternFilter = new SchemaPatternFilter();
    patternFilter.setIncludeLeadingWildcard(true);
    final FilteredTree filteredTree = new TreePathFilteredTree(page,
            SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, patternFilter, true);

    TreeViewer tree = filteredTree.getViewer();
    tree.setUseHashlookup(true);
    StyledDefinitionLabelProvider labelProvider = new StyledDefinitionLabelProvider();
    tree.setLabelProvider(labelProvider);
    IContentProvider contentProvider;
    if (types.size() == 1) {
        contentProvider = new TreePathProviderAdapter(new TypePropertyContentProvider(tree));
    } else {
        contentProvider = new TreePathProviderAdapter(new TypeDefinitionContentProvider(tree));
    }
    tree.setContentProvider(contentProvider);
    GridDataFactory.fillDefaults().grab(true, true).hint(280, 400).applyTo(filteredTree);

    tree.setComparator(new DefinitionComparator());

    // set input
    if (types.size() == 1) {
        tree.setInput(types.iterator().next());
    } else {
        tree.setInput(types);
    }

    /*
     * Groovy specific part
     */

    // caption
    Label example = new Label(page, SWT.NONE);
    switch (schemaSpace) {
    case SOURCE:
        example.setText("Examples: Access variables");
        break;
    case TARGET:
        example.setText("Example: Build instance");
        break;
    default:
        example.setText("Example");
    }

    // source viewer
    final SourceViewer viewer = new SourceViewer(page, null,
            SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);

    final IColorManager colorManager = new GroovyColorManager();
    SourceViewerConfiguration configuration = new SimpleGroovySourceViewerConfiguration(colorManager,
            ImmutableList.of(BINDING_TARGET, BINDING_BUILDER, BINDING_INDEX, BINDING_SOURCE,
                    BINDING_SOURCE_TYPES, BINDING_TARGET_TYPE, BINDING_CELL, BINDING_LOG, BINDING_CELL_CONTEXT,
                    BINDING_FUNCTION_CONTEXT, BINDING_TRANSFORMATION_CONTEXT),
            null);
    viewer.configure(configuration);

    GridDataFactory.fillDefaults().grab(true, false).hint(200, 130).applyTo(viewer.getControl());

    // make sure the color manager is disposed
    viewer.getControl().addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            colorManager.dispose();
        }
    });

    // react to tree selection changes
    tree.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IDocument doc = new Document();
            GroovySourceViewerUtil.setupDocument(doc);
            String example = null;
            if (!event.getSelection().isEmpty()) {
                switch (schemaSpace) {
                case SOURCE:
                    example = createSourceSample(event.getSelection(), types);
                    break;
                case TARGET:
                    example = createTargetSample(event.getSelection(), types);
                    break;
                }
            }

            if (example == null || example.isEmpty()) {
                switch (schemaSpace) {
                case SOURCE:
                    doc.set("// Please select schema elements to access");
                    break;
                case TARGET:
                    doc.set("// Please select which schema elements\n// to include in the instance to build");
                    break;
                default:
                    doc.set("// Please select one or more schema elements");
                }
            } else {
                doc.set(example);
            }

            viewer.setDocument(doc);
        }
    });

    tree.setSelection(StructuredSelection.EMPTY);

    return page;
}

From source file:gov.nasa.ensemble.core.activityDictionary.view.preferences.ActivityDictionaryPreferencePage.java

License:Open Source License

private void createActivityInfoComposite(Composite parent) {
    Composite activityInfoComposite = toolkit.createComposite(parent, SWT.BORDER);
    activityInfoComposite.setLayout(new FillLayout());
    GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(activityInfoComposite);
    activityInformation = toolkit.createFormText(activityInfoComposite, false);
    activityInformation.setColor("red", ColorMap.RGB_INSTANCE.getColor(new RGB(200, 0, 0)));
    activityInformation.setFont("header", JFaceResources.getHeaderFont());
    updateFormText(ActivityDictionary.getInstance());
}

From source file:net.bioclipse.browser.editors.BrowserText.java

License:Open Source License

private void fillContent(Composite parent, Color bg) {
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = 10;//from w  w  w.j av  a2  s . co m
    parent.setLayout(layout);
    title = new Label(parent, SWT.WRAP);
    title.setText("Rich Browser");
    title.setFont(JFaceResources.getHeaderFont());
    title.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    title.setBackground(bg);

    link = new Link(parent, SWT.WRAP);
    link.setText("Parent");
    link.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    link.setToolTipText("Parent page");
    link.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            BusyIndicator.showWhile(link.getDisplay(), new Runnable() {
                public void run() {
                    doOpenExternal();
                }
            });
        }
    });
    link.setBackground(bg);
    sep = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
    sep.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    exTitle = new Label(parent, SWT.NULL);
    exTitle.setBackground(bg);
    exTitle.setFont(JFaceResources.getBannerFont());
    exTitle.setText("Rich browser");
    exTitle.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    text = new Label(parent, SWT.WRAP);
    text.setText("Rich browser");
    text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    text.setBackground(bg);
    button = new Button(parent, SWT.PUSH);
    updateButtonText();
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            toggleException();
        }
    });
    exception = new Text(parent, SWT.MULTI);
    loadExceptionText();
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.exclude = true;
    exception.setLayoutData(gd);
}

From source file:net.sf.psstools.lang.ui.views.TextPresentationStringBuilder.java

License:Open Source License

public TextPresentationStringBuilder() {
    fSB = new StringBuilder();
    fPresentation = new TextPresentation();
    fFontStack = new Stack<Font>();
    fColorStack = new Stack<Color>();
    fHeaderFont = JFaceResources.getHeaderFont();
}

From source file:net.sf.smbt.btc.editior.gui.GUIToolkit.java

License:LGPL

/**
 * Creates a scrolled form widget in the provided parent. If you do not
 * require scrolling because there is already a scrolled composite up the
 * parent chain, use 'createForm' instead.
 * //  w w w.  j  a v a 2s  .c  om
 * @param parent
 *            the scrolled form parent
 * @return the form that can scroll itself
 * @see #createForm
 */
public ScrolledForm createScrolledForm(Composite parent) {
    ScrolledForm form = new ScrolledForm(parent, SWT.V_SCROLL | SWT.H_SCROLL | orientation);
    form.setExpandHorizontal(true);
    form.setExpandVertical(true);
    form.setBackground(colors.getBackground());
    form.setForeground(colors.getColor(IFormColors.TITLE));
    form.setFont(JFaceResources.getHeaderFont());
    return form;
}

From source file:net.sf.smbt.btc.editior.gui.GUIToolkit.java

License:LGPL

/**
 * Creates a form widget in the provided parent. Note that this widget does
 * not scroll its content, so make sure there is a scrolled composite up the
 * parent chain. If you require scrolling, use 'createScrolledForm' instead.
 * //from  ww w. ja  va 2s  .c  o m
 * @param parent
 *            the form parent
 * @return the form that does not scroll
 * @see #createScrolledForm
 */
public Form createForm(Composite parent) {
    Form formContent = new Form(parent, orientation);
    formContent.setBackground(colors.getBackground());
    formContent.setForeground(colors.getColor(IFormColors.TITLE));
    formContent.setFont(JFaceResources.getHeaderFont());
    return formContent;
}

From source file:org.apache.directory.studio.ldapbrowser.ui.editors.schemabrowser.SchemaPage.java

License:Apache License

/**
 * Creates this schema page and details page. 
 *
 * @param parent the parent composite//from   w  w w  . j a  v  a2s .c  o m
 * @return the created composite.
 */
Control createControl(Composite parent) {
    this.toolkit = new FormToolkit(parent.getDisplay());
    this.form = this.toolkit.createForm(parent);
    this.form.getBody().setLayout(new FillLayout());

    this.sashForm = new SashForm(this.form.getBody(), SWT.HORIZONTAL);
    this.sashForm.setLayout(new FillLayout());

    this.masterForm = this.toolkit.createScrolledForm(this.sashForm);
    this.detailForm = new ScrolledForm(this.sashForm, SWT.V_SCROLL | this.toolkit.getOrientation());
    this.detailForm.setExpandHorizontal(true);
    this.detailForm.setExpandVertical(true);
    this.detailForm.setBackground(this.toolkit.getColors().getBackground());
    this.detailForm.setForeground(this.toolkit.getColors().getColor(IFormColors.TITLE));
    this.detailForm.setFont(JFaceResources.getHeaderFont());
    this.sashForm.setWeights(new int[] { 50, 50 });

    this.masterForm.getBody().setLayout(new FillLayout());
    this.createMaster(this.masterForm.getBody());

    this.detailForm.getBody().setLayout(new FillLayout());
    this.createDetail(this.detailForm.getBody());
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection.isEmpty()) {
                detailsPage.setInput(null);
            } else {
                Object obj = ((StructuredSelection) selection).getFirstElement();
                detailsPage.setInput(obj);

                // Do not set the input of the schema browser if 
                // the selection was changed programatically.
                if (!inChange && obj instanceof AbstractSchemaObject) {
                    schemaBrowser.setInput(new SchemaBrowserInput(getConnection(), (AbstractSchemaObject) obj));
                }
            }
        }
    });

    connectionCombo = new BrowserConnectionWidgetContributionItem(this);
    this.form.getToolBarManager().add(connectionCombo);
    this.form.getToolBarManager().add(new Separator());
    showDefaultSchemaAction = new ShowDefaultSchemaAction(schemaBrowser);
    this.form.getToolBarManager().add(showDefaultSchemaAction);
    this.form.getToolBarManager().add(new Separator());
    reloadSchemaAction = new ReloadSchemaAction(this);
    this.form.getToolBarManager().add(reloadSchemaAction);
    this.form.updateToolBar();

    this.refresh();

    return this.form;
}

From source file:org.bonitasoft.studio.common.editor.CustomFormToolkit.java

License:Open Source License

@Override
public ScrolledForm createScrolledForm(Composite parent) {
    ScrolledForm form = new ScrolledForm(parent, SWT.V_SCROLL | SWT.H_SCROLL | getOrientation()) {

        public org.eclipse.jface.action.IToolBarManager getToolBarManager() {
            if (toolBarManager == null) {
                toolBarManager = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
                ToolBar toolbar = toolBarManager.createControl(getForm().getHead());
                toolbar.setBackground(getBackground());
                toolbar.setForeground(getForeground());
                toolbar.setCursor(FormsResources.getHandCursor());
                getForm().getHead().addDisposeListener(new DisposeListener() {
                    public void widgetDisposed(DisposeEvent e) {
                        if (toolBarManager != null) {
                            toolBarManager.dispose();
                            toolBarManager = null;
                        }/*  www.j  a  v  a  2 s . c o  m*/
                    }
                });
                try {
                    Field f = FormHeading.class.getDeclaredField("toolBarManager");
                    f.setAccessible(true);
                    f.set(getForm().getHead(), toolBarManager);
                } catch (Exception e1) {
                    BonitaStudioLog.error(e1);
                }
            }
            return toolBarManager;

        }
    };
    form.setExpandHorizontal(true);
    form.setExpandVertical(true);
    form.setBackground(getColors().getBackground());
    form.setForeground(getColors().getColor(IFormColors.TITLE));
    form.setFont(JFaceResources.getHeaderFont());
    return form;
}