Example usage for org.eclipse.jface.resource JFaceColors getBannerForeground

List of usage examples for org.eclipse.jface.resource JFaceColors getBannerForeground

Introduction

In this page you can find the example usage for org.eclipse.jface.resource JFaceColors getBannerForeground.

Prototype

public static Color getBannerForeground(Display display) 

Source Link

Usage

From source file:au.gov.ga.earthsci.application.about.AboutDialog.java

License:Apache License

@Override
protected Control createDialogArea(Composite parent) {
    Color background = JFaceColors.getBannerBackground(parent.getDisplay());
    Color foreground = JFaceColors.getBannerForeground(parent.getDisplay());

    final Composite topContainer = new Composite(parent, SWT.NONE);
    topContainer.setBackground(background);
    topContainer.setForeground(foreground);

    topContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;//from  w  w  w.  j  a  v  a  2s .c  o m
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.verticalSpacing = 0;
    layout.horizontalSpacing = 0;
    topContainer.setLayout(layout);

    aboutImage = openAboutImage();

    Label imageLabel = new Label(topContainer, SWT.NONE);
    imageLabel.setBackground(background);
    imageLabel.setForeground(foreground);

    GridData data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.BEGINNING;
    data.grabExcessHorizontalSpace = false;
    imageLabel.setLayoutData(data);
    imageLabel.setImage(aboutImage);

    String aboutText = getAboutText();
    if (aboutText != null) {
        final int minWidth = 400;

        final Composite textComposite = new Composite(topContainer, SWT.NONE);
        data = new GridData(GridData.FILL_BOTH);
        data.widthHint = minWidth;
        textComposite.setLayoutData(data);

        textComposite.setLayout(new FillLayout());

        Browser browser = new Browser(textComposite, SWT.NONE);
        browser.setText(aboutText);
        browser.addLocationListener(new LocationListener() {

            @Override
            public void changing(LocationEvent event) {
                // Intercept links and launch in the platform default
                event.doit = false;
                Program.launch(event.location);
            }

            @Override
            public void changed(LocationEvent event) {
            }
        });
    }

    Label bar = new Label(topContainer, SWT.HORIZONTAL | SWT.SEPARATOR);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    bar.setLayoutData(data);

    return topContainer;
}

From source file:com.architexa.org.eclipse.gef.ui.palette.customize.PaletteCustomizerDialog.java

License:Open Source License

/**
 * A convenient method to create CLabel titles (like the ones used in the
 * Preferences dialog in the Eclipse workbench) throughout the dialog.
 * //from w  ww . j av  a  2s  .  c om
 * @param composite   The composite in which the title is to be created (it must have a
 *                   GridLayout with two columns).
 * @param text         The title to be displayed
 * @return          The newly created CLabel for convenience
 */
protected CLabel createSectionTitle(Composite composite, String text) {
    CLabel cTitle = new CLabel(composite, SWT.LEFT);
    Color background = JFaceColors.getBannerBackground(composite.getDisplay());
    Color foreground = JFaceColors.getBannerForeground(composite.getDisplay());
    JFaceColors.setColors(cTitle, foreground, background);
    cTitle.setFont(JFaceResources.getBannerFont());
    cTitle.setText(text);
    cTitle.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));

    if (titleImage == null) {
        titleImage = new Image(composite.getDisplay(), ImageDescriptor
                .createFromFile(Internal.class, "icons/customizer_dialog_title.gif").getImageData()); //$NON-NLS-1$
        composite.addDisposeListener(new DisposeListener() {
            public void widgetDisposed(DisposeEvent e) {
                titleImage.dispose();
                titleImage = null;
            }
        });
    }

    Label imageLabel = new Label(composite, SWT.LEFT);
    imageLabel.setBackground(background);
    imageLabel.setImage(titleImage);
    imageLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));

    Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data.horizontalSpan = 2;
    separator.setLayoutData(data);

    return cTitle;
}

From source file:com.google.code.t4eclipse.tools.dialog.AboutT4EclipseDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {

    Composite root = new Composite(parent, SWT.None);
    Color background = JFaceColors.getBannerBackground(parent.getDisplay());
    Color foreground = JFaceColors.getBannerForeground(parent.getDisplay());
    root.setBackground(background);/*from ww w .  j  ava2 s  .  c  om*/
    root.setForeground(foreground);

    final int minWidth = 500;
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    data.minimumWidth = minWidth;
    root.setLayoutData(data);

    GridLayout layout = new GridLayout();
    layout.numColumns = 1;

    root.setLayout(layout);
    Label imageLabel = new Label(root, SWT.NONE);

    final Image image = ImageUtility.loadImageResource("/icons/bigT4Eclipse2.GIF");
    imageLabel.setImage(image);
    data = new GridData(SWT.FILL, SWT.FILL, true, true);
    data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_CENTER;

    imageLabel.setLayoutData(data);

    StyledText text = new StyledText(root, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);

    data = new GridData(SWT.FILL, SWT.FILL, true, true);
    data.minimumWidth = minWidth;
    text.setLayoutData(data);

    text.setCaret(null);
    text.setFont(parent.getFont());
    text.setText(getT4EclipseDescriptionText());
    text.setCursor(null);
    text.setLayoutData(new GridData(GridData.FILL_BOTH));

    applyDialogFont(parent);
    return parent;
}

From source file:com.gorillalogic.monkeyconsole.editors.utils.TitleAreaDialogStyledTextMessage.java

License:Open Source License

/**
 * Creates the dialog's title area.//from w  w w .j a v a  2  s. c o  m
 * 
 * @param parent
 *            the SWT parent for the title area widgets
 * @return Control with the highest x axis value.
 */
private Control createTitleArea(Composite parent) {

    // add a dispose listener
    parent.addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent e) {
            if (titleAreaColor != null) {
                titleAreaColor.dispose();
            }
        }
    });
    // Determine the background color of the title bar
    Display display = parent.getDisplay();
    Color background;
    Color foreground;
    if (titleAreaRGB != null) {
        titleAreaColor = new Color(display, titleAreaRGB);
        background = titleAreaColor;
        foreground = null;
    } else {
        background = JFaceColors.getBannerBackground(display);
        foreground = JFaceColors.getBannerForeground(display);
    }

    parent.setBackground(background);
    int verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    int horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    // Dialog image @ right
    titleImageLabel = new Label(parent, SWT.CENTER);
    titleImageLabel.setBackground(background);
    if (titleAreaImage == null)
        titleImageLabel.setImage(JFaceResources.getImage(DLG_IMG_TITLE_BANNER));
    else
        titleImageLabel.setImage(titleAreaImage);

    FormData imageData = new FormData();
    imageData.top = new FormAttachment(0, 0);
    // Note: do not use horizontalSpacing on the right as that would be a
    // regression from
    // the R2.x style where there was no margin on the right and images are
    // flush to the right
    // hand side. see reopened comments in 41172
    imageData.right = new FormAttachment(100, 0); // horizontalSpacing
    titleImageLabel.setLayoutData(imageData);
    // Title label @ top, left
    titleLabel = new Label(parent, SWT.LEFT);
    JFaceColors.setColors(titleLabel, foreground, background);
    titleLabel.setFont(JFaceResources.getBannerFont());
    titleLabel.setText(" ");//$NON-NLS-1$
    FormData titleData = new FormData();
    titleData.top = new FormAttachment(0, verticalSpacing);
    titleData.right = new FormAttachment(titleImageLabel);
    titleData.left = new FormAttachment(0, horizontalSpacing);
    titleLabel.setLayoutData(titleData);
    // Message image @ bottom, left
    messageImageLabel = new Label(parent, SWT.CENTER);
    messageImageLabel.setBackground(background);
    // Message label @ bottom, center
    messageLabel = new Link(parent, SWT.WRAP | SWT.READ_ONLY);
    JFaceColors.setColors(messageLabel, foreground, background);
    messageLabel.setText(" \n "); // two lines//$NON-NLS-1$
    messageLabel.setFont(JFaceResources.getDialogFont());
    messageLabelHeight = messageLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
    // Filler labels
    leftFillerLabel = new Label(parent, SWT.CENTER);
    leftFillerLabel.setBackground(background);
    bottomFillerLabel = new Label(parent, SWT.CENTER);
    bottomFillerLabel.setBackground(background);
    setLayoutsForNormalMessage(verticalSpacing, horizontalSpacing);
    determineTitleImageLargest();
    if (titleImageLargest)
        return titleImageLabel;
    return messageLabel;
}

From source file:com.nokia.s60ct.gui.views.AboutDialog.java

License:Open Source License

protected Control createDialogArea(Composite parent) {

    final Cursor hand = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
    final Cursor busy = new Cursor(parent.getDisplay(), SWT.CURSOR_WAIT);
    setHandCursor(hand);//from w  w w. j a  va 2  s.c  o m
    setBusyCursor(busy);
    getShell().addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent e) {
            setHandCursor(null);
            hand.dispose();
            setBusyCursor(null);
            busy.dispose();
        }
    });

    Image aboutImage = null;

    if (product != null) {
        ImageDescriptor imageDescriptor = ProductProperties.getAboutImage(product);
        if (imageDescriptor != null) {
            aboutImage = imageDescriptor.createImage();
        }
    } else //no product. maybe run from Eclipse
    {
        try {
            URL url = S60CtEditorPlugin.class.getResource("/about.PNG");
            ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(url);
            aboutImage = imageDescriptor.createImage();

        } catch (Exception e) {
        }
    }

    Composite workArea = new Composite(parent, SWT.NONE);
    GridLayout workLayout = new GridLayout(2, false);
    workLayout.marginHeight = 0;
    workLayout.marginWidth = 0;
    workLayout.verticalSpacing = 0;
    workLayout.horizontalSpacing = 0;
    workArea.setLayout(workLayout);
    workArea.setLayoutData(new GridData(GridData.FILL_BOTH));

    // page group
    Color background = JFaceColors.getBannerBackground(parent.getDisplay());
    Color foreground = JFaceColors.getBannerForeground(parent.getDisplay());

    workArea.setBackground(background);
    workArea.setForeground(foreground);

    //image on left side of dialog
    if (aboutImage != null) {
        Label imageLabel = new Label(workArea, SWT.NONE);
        imageLabel.setBackground(background);
        imageLabel.setForeground(foreground);

        GridData data = new GridData();
        data.horizontalAlignment = GridData.FILL;
        data.verticalAlignment = GridData.BEGINNING;
        data.grabExcessHorizontalSpace = false;
        imageLabel.setLayoutData(data);
        imageLabel.setImage(aboutImage);
    }

    // text on the right
    text = new StyledText(workArea, SWT.MULTI | SWT.READ_ONLY);
    text.setCaret(null);
    text.setFont(parent.getFont());
    GridData data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.BEGINNING;
    data.verticalIndent = 12;
    data.grabExcessHorizontalSpace = true;
    data.grabExcessVerticalSpace = true;

    text.setText(getAboutText());
    text.setLayoutData(data);
    text.setCursor(null);
    text.setBackground(background);
    text.setForeground(foreground);

    if (aboutImage != null) {
        // horizontal bar
        Label bar = new Label(workArea, SWT.HORIZONTAL | SWT.SEPARATOR);
        data = new GridData();
        data.horizontalAlignment = GridData.FILL;
        bar.setLayoutData(data);

        Label bar2 = new Label(workArea, SWT.HORIZONTAL | SWT.SEPARATOR);
        bar2.setLayoutData(data);
    }

    return workArea;
}

From source file:com.nokia.tools.carbide.ui.dialogs.CarbideAboutDialog.java

License:Open Source License

/**
 * Creates and returns the contents of the upper part of the dialog (above
 * the button bar). Subclasses should overide.
 * //from   w  w  w.  j av  a 2 s .co m
 * @param parent the parent composite to contain the dialog area
 * @return the dialog area control
 */
protected Control createDialogArea(Composite parent) {
    // brand the about box if there is product info
    Image aboutImage = null;
    AboutItem item = null;
    if (product != null) {
        ImageDescriptor imageDescriptor = ProductProperties.getAboutImage(product);
        if (imageDescriptor != null) {
            aboutImage = imageDescriptor.createImage();
        }

        // if the about image is small enough, then show the text
        if (aboutImage == null || aboutImage.getBounds().width <= MAX_IMAGE_WIDTH_FOR_TEXT) {
            String aboutText = ProductProperties.getAboutText(product);
            if (aboutText != null) {
                item = AboutTextManager.scan(aboutText);
            }
        }

        if (aboutImage != null) {
            images.add(aboutImage);
        }
    }

    // create a composite which is the parent of the top area and the bottom
    // button bar, this allows there to be a second child of this composite
    // with
    // a banner background on top but not have on the bottom
    Composite workArea = new Composite(parent, SWT.NONE);
    GridLayout workLayout = new GridLayout();
    workLayout.marginHeight = 0;
    workLayout.marginWidth = 0;
    workLayout.verticalSpacing = 0;
    workLayout.horizontalSpacing = 0;
    workArea.setLayout(workLayout);
    workArea.setLayoutData(new GridData(GridData.FILL_BOTH));

    // page group
    Color background = JFaceColors.getBannerBackground(parent.getDisplay());
    Color foreground = JFaceColors.getBannerForeground(parent.getDisplay());
    Composite top = (Composite) super.createDialogArea(workArea);

    // override any layout inherited from createDialogArea
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    layout.horizontalSpacing = 0;
    top.setLayout(layout);
    top.setLayoutData(new GridData(GridData.FILL_BOTH));
    top.setBackground(background);
    top.setForeground(foreground);

    // the image & text
    final Composite topContainer = new Composite(top, SWT.NONE);
    topContainer.setBackground(background);
    topContainer.setForeground(foreground);

    layout = new GridLayout();
    layout.numColumns = (aboutImage == null || item == null ? 1 : 2);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.verticalSpacing = 0;
    layout.horizontalSpacing = 0;
    topContainer.setLayout(layout);

    GridData data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.grabExcessHorizontalSpace = true;
    topContainer.setLayoutData(data);

    GC gc = new GC(parent);
    // arbitrary default
    int topContainerHeightHint = 100;
    try {
        // default height enough for 6 lines of text
        topContainerHeightHint = Math.max(topContainerHeightHint, gc.getFontMetrics().getHeight() * 6);
    } finally {
        gc.dispose();
    }

    // image on left side of dialog
    if (aboutImage != null) {
        Label imageLabel = new Label(topContainer, SWT.NONE);
        imageLabel.setBackground(background);
        imageLabel.setForeground(foreground);

        data = new GridData();
        data.horizontalAlignment = GridData.FILL;
        data.verticalAlignment = GridData.BEGINNING;
        data.grabExcessHorizontalSpace = false;
        imageLabel.setLayoutData(data);
        imageLabel.setImage(aboutImage);
        // topContainerHeightHint = Math.max(topContainerHeightHint,
        // aboutImage.getBounds().height);
    }

    // data = new GridData();
    // data.horizontalAlignment = GridData.FILL;
    // data.verticalAlignment = GridData.FILL;
    // data.grabExcessHorizontalSpace = true;
    // data.grabExcessVerticalSpace = true;
    // data.heightHint = topContainerHeightHint;
    // topContainer.setLayoutData(data);

    if (item != null) {
        final int minWidth = 400; // This value should really be calculated
        // from the computeSize(SWT.DEFAULT,
        // SWT.DEFAULT) of all the
        // children in infoArea excluding the
        // wrapped styled text
        // There is no easy way to do this.
        final ScrolledComposite scroller = new ScrolledComposite(topContainer, SWT.V_SCROLL | SWT.H_SCROLL);
        data = new GridData(GridData.FILL_BOTH);
        data.widthHint = minWidth;
        scroller.setLayoutData(data);

        final Composite textComposite = new Composite(scroller, SWT.NONE);
        textComposite.setBackground(background);

        layout = new GridLayout();
        layout.numColumns = 1;
        layout.marginRight = 17;
        layout.marginTop = 0;
        textComposite.setLayout(layout);
        data = new GridData();
        data.horizontalAlignment = GridData.FILL;
        data.verticalAlignment = GridData.BEGINNING;
        data.grabExcessHorizontalSpace = true;
        textComposite.setLayoutData(data);

        // Image on the right
        Label textImageLabel = new Label(textComposite, SWT.NONE);
        URL url = BrandingProperties.getUrl(product.getProperty("aboutTextImage"), product.getDefiningBundle());
        Image textImage = ImageDescriptor.createFromURL(url).createImage();
        images.add(textImage);
        textImageLabel.setImage(textImage);
        textImageLabel.setBackground(background);
        textImageLabel.setForeground(foreground);
        data = new GridData();
        data.horizontalAlignment = SWT.RIGHT;
        data.verticalIndent = 7;
        textImageLabel.setLayoutData(data);

        // Version information on the right
        Label versionLabel = new Label(textComposite, SWT.NONE);
        data = new GridData();
        data.horizontalAlignment = SWT.RIGHT;
        data.verticalIndent = 8;
        versionLabel.setText(product.getProperty("versionText"));
        versionLabel.setBackground(background);
        versionLabel.setForeground(foreground);
        versionLabel.setLayoutData(data);

        String buildId = product.getProperty("buildId");
        if (buildId != null && !buildId.startsWith("@")) {
            // don't show build id if it's not resolved, @buildId@
            Label buildIdLabel = new Label(textComposite, SWT.NONE);
            data = new GridData();
            data.horizontalAlignment = SWT.RIGHT;
            data.verticalIndent = 8;
            buildIdLabel.setText(Messages.BuildId_Label + " " + buildId);
            buildIdLabel.setBackground(background);
            buildIdLabel.setForeground(foreground);
            buildIdLabel.setLayoutData(data);
        }

        text = new StyledText(textComposite, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
        text.setCaret(null);
        text.setFont(parent.getFont());
        text.setText(item.getText());
        text.setCursor(null);
        text.setBackground(background);
        text.setForeground(foreground);

        aboutTextManager = new AboutTextManager(text);
        aboutTextManager.setItem(item);

        createTextMenu();

        GridData gd = new GridData();
        gd.verticalAlignment = GridData.BEGINNING;
        gd.horizontalAlignment = GridData.FILL;
        gd.grabExcessHorizontalSpace = true;
        text.setLayoutData(gd);

        // Adjust the scrollbar increments
        scroller.getHorizontalBar().setIncrement(20);
        scroller.getVerticalBar().setIncrement(20);

        final boolean[] inresize = new boolean[1]; // flag to stop
        // unneccesary
        // recursion
        textComposite.addControlListener(new ControlAdapter() {
            public void controlResized(ControlEvent e) {
                if (inresize[0])
                    return;
                inresize[0] = true;
                // required because of bugzilla report 4579
                textComposite.layout(true);
                // required because you want to change the height that the
                // scrollbar will scroll over when the width changes.
                int width = textComposite.getClientArea().width;
                Point p = textComposite.computeSize(width, SWT.DEFAULT);
                scroller.setMinSize(minWidth, p.y);
                inresize[0] = false;
            }
        });

        scroller.setExpandHorizontal(true);
        scroller.setExpandVertical(true);
        Point p = textComposite.computeSize(minWidth, SWT.DEFAULT);
        textComposite.setSize(p.x, p.y);
        scroller.setMinWidth(minWidth);
        scroller.setMinHeight(p.y);

        scroller.setContent(textComposite);
    }

    // horizontal bar
    Label bar = new Label(workArea, SWT.HORIZONTAL | SWT.SEPARATOR);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    bar.setLayoutData(data);
    String[] s = new String[1];
    URL url = Platform.getBundle(Activator.PLUGIN_ID).getEntry("doc/data.html");
    try {
        s[0] = FileLocator.toFileURL(url).toString();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    int[][] index = { { Messages.Oss_Liense_Info.indexOf("Click"),
            Messages.Oss_Liense_Info.length() - Messages.Oss_Liense_Info.indexOf("Click") - 1 } };
    AboutItem licenceItem = new AboutItem(Messages.Oss_Liense_Info, index, s);

    final Composite licenceTextComposite = new Composite(workArea, SWT.NONE);
    licenceTextComposite.setBackground(background);

    layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginRight = 17;
    layout.marginTop = 0;
    licenceTextComposite.setLayout(layout);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.BEGINNING;
    data.grabExcessHorizontalSpace = true;
    licenceTextComposite.setLayoutData(data);

    StyledText licenceText = new StyledText(licenceTextComposite, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
    licenceText.setCaret(null);
    licenceText.setText(licenceItem.getText());
    licenceText.setCursor(null);
    aboutTextManager = new AboutTextManager(licenceText);
    aboutTextManager.setItem(licenceItem);

    bar = new Label(workArea, SWT.HORIZONTAL | SWT.SEPARATOR);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    bar.setLayoutData(data);
    AboutItem ossItem = AboutTextManager.scan(Messages.Oss_Download_Info);

    final Composite ossTextComposite = new Composite(workArea, SWT.NONE);
    ossTextComposite.setBackground(background);

    layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginRight = 17;
    layout.marginTop = 0;
    ossTextComposite.setLayout(layout);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.BEGINNING;
    data.grabExcessHorizontalSpace = true;
    ossTextComposite.setLayoutData(data);

    StyledText ossText = new StyledText(ossTextComposite, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
    ossText.setCaret(null);
    ossText.setText(licenceItem.getText());
    ossText.setCursor(null);
    aboutTextManager = new AboutTextManager(ossText);
    aboutTextManager.setItem(ossItem);

    bar = new Label(workArea, SWT.HORIZONTAL | SWT.SEPARATOR);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    bar.setLayoutData(data);

    // add image buttons for bundle groups that have them
    Composite bottom = (Composite) super.createDialogArea(workArea);
    // override any layout inherited from createDialogArea
    layout = new GridLayout();
    bottom.setLayout(layout);
    data = new GridData();
    data.horizontalAlignment = SWT.FILL;
    data.verticalAlignment = SWT.FILL;
    data.grabExcessHorizontalSpace = true;

    bottom.setLayoutData(data);

    createFeatureImageButtonRow(bottom);

    // spacer
    bar = new Label(bottom, SWT.NONE);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    bar.setLayoutData(data);

    return workArea;
}

From source file:hydrograph.ui.help.aboutDialog.CustomAboutDialog.java

License:Apache License

/**
 * Creates and returns the contents of the upper part of the dialog (above
 * the button bar).//from w  w  w. j a  v a  2  s . c om
 *
 * Subclasses should overide.
 *
 * @param parent
 *            the parent composite to contain the dialog area
 * @return the dialog area control
 */
protected Control createDialogArea(Composite parent) {
    // brand the about box if there is product info
    Image aboutImage = null;
    item = null;
    if (product != null) {
        Bundle bundle = Platform.getBundle(Constants.ABOUT_DIALOG_IMAGE_BUNDLE_NAME);
        URL fullPathString = BundleUtility.find(bundle, Constants.ABOUT_DIALOG_IMAGE_PATH);
        aboutImage = ImageDescriptor.createFromURL(fullPathString).createImage();

        parent.getShell().setMinimumSize(450, 267);

        // if the about image is small enough, then show the text
        if (aboutImage == null || aboutImage.getBounds().width <= MAX_IMAGE_WIDTH_FOR_TEXT) {
            String aboutText = Messages.ABOUT_HEADER_TEXT + Messages.ABOUT_TEXT;

            if (aboutText != null) {
                String buildNumber = System.getProperty(ECLIPSE_BUILD_ID);
                if (StringUtils.isBlank(buildNumber)) {
                    buildNumber = Platform.getBundle(Activator.PLUGIN_ID).getVersion().toString();
                }
                item = AboutTextManager.scan(Messages.ABOUT_VERSION_INFO + "\n" + "Build Number : "
                        + buildNumber + "\n \n" + "License Information : " + Messages.ABOUT_LICENSE_INFO
                        + "\n \n " + Messages.ABOUT_COPYRIGHT_INFO + "\n \n");
            }
        }

        if (aboutImage != null) {
            images.add(aboutImage);
        }
    }

    // create a composite which is the parent of the top area and the bottom
    // button bar, this allows there to be a second child of this composite
    // with
    // a banner background on top but not have on the bottom
    Composite workArea = new Composite(parent, SWT.NONE);
    GridLayout workLayout = new GridLayout();
    workLayout.marginHeight = 0;
    workLayout.marginWidth = 0;
    workLayout.verticalSpacing = 0;
    workLayout.horizontalSpacing = 0;
    workArea.setLayout(workLayout);
    workArea.setLayoutData(new GridData(GridData.FILL_BOTH));

    // page group
    Color background = JFaceColors.getBannerBackground(parent.getDisplay());
    Color foreground = JFaceColors.getBannerForeground(parent.getDisplay());
    Composite top = (Composite) super.createDialogArea(workArea);

    // override any layout inherited from createDialogArea
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    layout.horizontalSpacing = 0;
    top.setLayout(layout);
    top.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    top.setBackground(background);
    top.setForeground(foreground);

    // the image & text
    final Composite topContainer = new Composite(top, SWT.NONE);
    topContainer.setBackground(background);
    topContainer.setForeground(foreground);

    layout = new GridLayout();
    layout.numColumns = (aboutImage == null || item == null ? 1 : 2);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.verticalSpacing = 0;
    layout.horizontalSpacing = 0;
    topContainer.setLayout(layout);
    topContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    // Calculate a good height for the text
    GC gc = new GC(parent);
    int lineHeight = gc.getFontMetrics().getHeight();
    gc.dispose();

    // image on left side of dialog
    if (aboutImage != null) {
        Label imageLabel = new Label(topContainer, SWT.NONE);
        imageLabel.setBackground(background);
        imageLabel.setForeground(foreground);

        GridData data = new GridData(SWT.FILL, SWT.FILL, true, true, 0, 0);
        data.horizontalAlignment = GridData.FILL;
        data.verticalAlignment = GridData.FILL;
        data.grabExcessHorizontalSpace = true;
        data.grabExcessVerticalSpace = true;
        imageLabel.setLayoutData(data);
        imageLabel.setImage(aboutImage);
    }

    Composite newComposite = new Composite(topContainer, SWT.NONE);
    newComposite.setLayout(new GridLayout(1, true));
    newComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    newComposite.setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry(255, 255, 255));
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    topContainer.setLayoutData(data);
    // used only to drive initial size so that there are no hints in the
    // layout data
    final Link link = new Link(newComposite, SWT.NONE);
    GridData data1 = new GridData(SWT.FILL, SWT.FILL, true, false, 0, 0);
    link.setLayoutData(data1);
    link.setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry(255, 255, 255));
    link.setText("<a>" + Messages.ABOUT_HEADER_TEXT + "</a>" + Messages.ABOUT_TEXT);

    link.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseUp(MouseEvent e) {
            try {
                PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser()
                        .openURL(new URL(Messages.HYDROGRAPH_URL));
            } catch (IllegalArgumentException | PartInitException | MalformedURLException e1) {
                logger.error(e1.getMessage());
                WidgetUtility.errorMessage(Messages.ERROR_MESSAGE_FOR_GITHUB_URL);
            }

        }
    });
    if (item != null) {

        text = new StyledText(newComposite, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
        configureText(newComposite);

    }

    // horizontal bar
    Label bar = new Label(workArea, SWT.HORIZONTAL | SWT.SEPARATOR);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    bar.setLayoutData(data);

    // add image buttons for bundle groups that have them
    Composite bottom = (Composite) super.createDialogArea(workArea);
    // override any layout inherited from createDialogArea
    layout = new GridLayout();
    bottom.setLayout(layout);
    data_1 = new GridData();
    data_1.heightHint = 0;
    data_1.horizontalAlignment = SWT.FILL;
    data_1.verticalAlignment = SWT.FILL;
    data_1.grabExcessHorizontalSpace = true;

    bottom.setLayoutData(data_1);

    // spacer
    bar = new Label(bottom, SWT.NONE);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    bar.setLayoutData(data);

    return workArea;
}

From source file:hydrograph.ui.help.aboutDialog.CustomAboutDialog.java

License:Apache License

void configureText(final Composite parent) {
    // Don't set caret to 'null' as this causes
    // https://bugs.eclipse.org/293263.
    // text.setCaret(null);
    Color background = JFaceColors.getBannerBackground(parent.getDisplay());
    Color foreground = JFaceColors.getBannerForeground(parent.getDisplay());

    text.setFont(parent.getFont());//from w ww.  jav a  2  s.co  m
    text.setText(item.getText());

    text.setBackground(background);
    text.setForeground(foreground);
    text.setMargins(TEXT_MARGIN, TEXT_MARGIN, TEXT_MARGIN, 0);

    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    text.setLayoutData(gd);

    aboutTextManager = new AboutTextManager(text);
    aboutTextManager.setItem(item);

    createTextMenu();

}

From source file:io.usethesource.impulse.preferences.fields.details.DetailsDialogForBooleanFields.java

License:Open Source License

private Composite fillInWorkArea(Composite workArea) {
    if (workArea.isDisposed())
        System.err.println("fillInWorkArea:  workArea is disposed!");
    GridLayout workLayout = new GridLayout();
    workLayout.marginHeight = 0;//from  w w  w  . j a va 2s . c o  m
    workLayout.marginWidth = 0;
    workLayout.verticalSpacing = 0;
    workLayout.horizontalSpacing = 0;
    workArea.setLayout(workLayout);
    workArea.setLayoutData(new GridData(GridData.FILL_BOTH));

    // page group
    Color background = JFaceColors.getBannerBackground(parent.getDisplay());
    Color foreground = JFaceColors.getBannerForeground(parent.getDisplay());
    Composite top = (Composite) super.createDialogArea(workArea);

    // override any layout inherited from createDialogArea 
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    layout.horizontalSpacing = 0;
    top.setLayout(layout);
    top.setLayoutData(new GridData(GridData.FILL_BOTH));
    top.setBackground(background);
    top.setForeground(foreground);

    // the image & text   
    Composite topContainer = new Composite(top, SWT.NONE);
    topContainer.setBackground(background);
    topContainer.setForeground(foreground);

    layout = new GridLayout();
    layout.numColumns = (1);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.verticalSpacing = 0;
    layout.horizontalSpacing = 0;
    topContainer.setLayout(layout);
    GridData data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.grabExcessHorizontalSpace = true;
    topContainer.setLayoutData(data);

    String levelString = null;
    if (field.getPreferencesLevel() == null) {
        levelString = "Details as currently applicable";
        if (preferencesService.getProject() != null) {
            levelString += " (including project preferences):  ";
        } else {
            levelString += " (not including any project preferences):  ";
        }
    } else if (field.getPreferencesLevel().equals(IPreferencesService.INSTANCE_LEVEL))
        levelString = PreferenceDialogConstants.INSTANCE_LEVEL_STRING;
    else if (field.getPreferencesLevel().equals(IPreferencesService.CONFIGURATION_LEVEL))
        levelString = PreferenceDialogConstants.CONFIGURATION_LEVEL_STRING;
    else if (field.getPreferencesLevel().equals(IPreferencesService.DEFAULT_LEVEL))
        levelString = PreferenceDialogConstants.DEFAULT_LEVEL_STRING;
    else if (field.getPreferencesLevel().equals(IPreferencesService.PROJECT_LEVEL))
        levelString = PreferenceDialogConstants.PROJECT_LEVEL_STRING;
    else
        levelString = PreferenceDialogConstants.UNKNOWN_LEVEL_STRING + field.getPreferencesLevel();

    Label label = null;

    label = new Label(topContainer, SWT.LEAD);
    label.setText(levelString);
    label.setBackground(PreferencesUtilities.colorWhite);

    label = new Label(topContainer, SWT.LEAD);
    label.setText("\tCurrent value:  '" + field.getChangeControl().getSelection() + "'");
    label.setBackground(PreferencesUtilities.colorWhite);

    label = new Label(topContainer, SWT.LEAD);
    String level = PreferenceDialogConstants.getLevelName(field.getLevelFromWhichLoaded());
    label.setText("\tLevel at which set:  " + level);
    label.setBackground(PreferencesUtilities.colorWhite);

    if ((field.getPreferencesLevel() != null)
            && field.getPreferencesLevel().equals(field.getLevelFromWhichLoaded())) {
        label = new Label(topContainer, SWT.LEAD);
        if (field.isRemovable()) {
            label.setText(PreferenceDialogConstants.IS_REMOVABLE);
        } else {
            label.setText(PreferenceDialogConstants.NOT_REMOVABLE);
        }
    }
    label.setBackground(PreferencesUtilities.colorWhite);

    label = new Label(top, SWT.LEAD);
    label.setText("~~~");
    label.setVisible(false);

    this.workArea = workArea;
    return workArea;
}

From source file:io.usethesource.impulse.preferences.fields.details.DetailsDialogForColorFields.java

License:Open Source License

private Composite fillInWorkArea(Composite workArea) {
    if (workArea.isDisposed())
        System.err.println("fillInWorkArea:  workArea is disposed!!!");
    GridLayout workLayout = new GridLayout();
    workLayout.marginHeight = 0;/*from   www  .ja v a 2s . c o  m*/
    workLayout.marginWidth = 0;
    workLayout.verticalSpacing = 0;
    workLayout.horizontalSpacing = 0;
    workArea.setLayout(workLayout);
    workArea.setLayoutData(new GridData(GridData.FILL_BOTH));

    // page group
    Color background = JFaceColors.getBannerBackground(parent.getDisplay());
    Color foreground = JFaceColors.getBannerForeground(parent.getDisplay());
    Composite top = (Composite) super.createDialogArea(workArea);

    // override any layout inherited from createDialogArea 
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    layout.horizontalSpacing = 0;
    top.setLayout(layout);
    top.setLayoutData(new GridData(GridData.FILL_BOTH));
    top.setBackground(background);
    top.setForeground(foreground);

    // the image & text   
    Composite topContainer = new Composite(top, SWT.NONE);
    topContainer.setBackground(background);
    topContainer.setForeground(foreground);

    layout = new GridLayout();
    layout.numColumns = (1);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.verticalSpacing = 0;
    layout.horizontalSpacing = 0;
    topContainer.setLayout(layout);
    GridData data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.grabExcessHorizontalSpace = true;
    topContainer.setLayoutData(data);

    String levelString = null;
    if (field.getPreferencesLevel() == null) {
        levelString = "Details as currently applicable";
        if (preferencesService.getProject() != null) {
            levelString += " (including project preferences):  ";
        } else {
            levelString += " (not including any project preferences):  ";
        }
    } else if (field.getPreferencesLevel().equals(IPreferencesService.INSTANCE_LEVEL))
        levelString = PreferenceDialogConstants.INSTANCE_LEVEL_STRING;
    else if (field.getPreferencesLevel().equals(IPreferencesService.CONFIGURATION_LEVEL))
        levelString = PreferenceDialogConstants.CONFIGURATION_LEVEL_STRING;
    else if (field.getPreferencesLevel().equals(IPreferencesService.DEFAULT_LEVEL))
        levelString = PreferenceDialogConstants.DEFAULT_LEVEL_STRING;
    else if (field.getPreferencesLevel().equals(IPreferencesService.PROJECT_LEVEL))
        levelString = PreferenceDialogConstants.PROJECT_LEVEL_STRING;
    else
        levelString = PreferenceDialogConstants.UNKNOWN_LEVEL_STRING + field.getPreferencesLevel();

    Label label = null;

    label = new Label(topContainer, SWT.LEAD);
    label.setText(levelString);
    label.setBackground(PreferencesUtilities.colorWhite);

    label = new Label(topContainer, SWT.LEAD);
    label.setText("\tCurrent value:  '" + field.getFieldEditorFontName() + "'");
    label.setBackground(PreferencesUtilities.colorWhite);

    label = new Label(topContainer, SWT.LEAD);
    String level = PreferenceDialogConstants.getLevelName(field.getLevelFromWhichLoaded());
    label.setText("\tLevel at which set:  " + level);
    label.setBackground(PreferencesUtilities.colorWhite);

    label = new Label(topContainer, SWT.LEAD);
    //           if (field.isEmptyStringAllowed()) {
    //              label.setText(PreferenceDialogConstants.EMPTY_OK   );
    //           } else {
    //              label.setText(PreferenceDialogConstants.EMPTY_NOT_OK);
    //           }
    label.setBackground(PreferencesUtilities.colorWhite);

    if ((field.getPreferencesLevel() != null)
            && field.getPreferencesLevel().equals(field.getLevelFromWhichLoaded())) {
        label = new Label(topContainer, SWT.LEAD);
        if (field.isRemovable()) {
            label.setText(PreferenceDialogConstants.IS_REMOVABLE);
        } else {
            label.setText(PreferenceDialogConstants.NOT_REMOVABLE);
        }
    }
    label.setBackground(PreferencesUtilities.colorWhite);

    label = new Label(top, SWT.LEAD);
    label.setText("~~~");
    label.setVisible(false);

    this.workArea = workArea;
    return workArea;
}