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

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

Introduction

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

Prototype

public static Font getBannerFont() 

Source Link

Document

Returns the JFace's banner font.

Usage

From source file:org.gumtree.gumnix.sics.batch.ui.buffer.BatchRunnerPage.java

License:Open Source License

private void createRunMainContent(Composite parent) {
    parent.setLayout(new FillLayout());
    sashForm = new SashForm(parent, SWT.VERTICAL);
    getToolkit().adapt(sashForm);//from   ww  w. java  2  s . c  o m

    // Preview
    Group previewGroup = new Group(sashForm, SWT.NONE);
    previewGroup.setText("Preview");
    getToolkit().adapt(previewGroup);
    previewGroup.setLayout(new FillLayout());
    previewGroup.setFont(JFaceResources.getBannerFont());
    context.previewText = new AutoScrollStyledText(previewGroup,
            SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
    context.previewText.setText("");
    context.previewText.setFont(JFaceResources.getBannerFont());

    // Editor
    Group editorGroup = new Group(sashForm, SWT.NONE);
    editorGroup.setText("Buffer");
    getToolkit().adapt(editorGroup);
    editorGroup.setLayout(new FillLayout());
    editorGroup.setFont(JFaceResources.getBannerFont());
    context.editorText = new AutoScrollStyledText(editorGroup,
            SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
    context.editorText.setText("");
    context.editorText.setFont(JFaceResources.getBannerFont());
    context.editorText.setData(KEY_PREV_DOC_LEN, 0);

    // Log
    Group logGroup = new Group(sashForm, SWT.NONE);
    logGroup.setText("Log");
    getToolkit().adapt(logGroup);
    logGroup.setLayout(new FillLayout());
    logGroup.setFont(JFaceResources.getBannerFont());
    context.logText = new AutoScrollStyledText(logGroup,
            SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
    context.logText.setFont(JFaceResources.getBannerFont());
    context.logText.setData(KEY_PREV_DOC_LEN, 0);

    sashForm.setWeights(new int[] { 0, 1, 1 });
}

From source file:org.gumtree.gumnix.sics.batch.ui.buffer.BatchRunnerPage.java

License:Open Source License

private void createRunControlContent(Composite parent) {
    GridLayoutFactory.swtDefaults().applyTo(parent);

    // Timer/*w  w w .j  a v a 2s.c om*/
    context.timerWidget = new TimerWidget(parent, SWT.NONE);
    getToolkit().adapt(context.timerWidget);
    GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(context.timerWidget);

    // Status
    context.statusLabel = getToolkit().createLabel(parent, "", SWT.CENTER);
    context.statusLabel.setFont(JFaceResources.getBannerFont());
    GridDataFactory.fillDefaults().grab(false, false).hint(SWT.DEFAULT, 50).applyTo(context.statusLabel);

    // Current buffer
    Group currentGroup = new Group(parent, SWT.NONE);
    currentGroup.setText("Executing Buffer");
    getToolkit().adapt(currentGroup);
    GridLayoutFactory.fillDefaults().applyTo(currentGroup);
    GridDataFactory.fillDefaults().grab(false, false).applyTo(currentGroup);
    context.currentBuffer = getToolkit().createText(currentGroup, "", SWT.READ_ONLY);
    context.currentBuffer.setFont(JFaceResources.getBannerFont());
    GridDataFactory.fillDefaults().grab(true, false).applyTo(context.currentBuffer);

    // Buffer queue
    Group queueGroup = new Group(parent, SWT.NONE);
    GridLayoutFactory.swtDefaults().numColumns(2).margins(0, 0).spacing(2, 2).applyTo(queueGroup);
    queueGroup.setText("Buffer Queue");
    getToolkit().adapt(queueGroup);
    GridDataFactory.fillDefaults().grab(false, true).applyTo(queueGroup);
    context.queueViewer = new BatchBufferQueueViewer(queueGroup);
    context.queueViewer.setManager(getBatchBufferManager());
    context.queueViewer.afterParametersSet();
    GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(context.queueViewer);

    context.queueViewer.getViewer().addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            ISelection selection = context.queueViewer.getViewer().getSelection();
            if (selection instanceof IStructuredSelection) {
                Object obj = ((IStructuredSelection) selection).getFirstElement();
                if (obj instanceof IBatchBuffer) {
                    context.previewText.setText(((IBatchBuffer) obj).getContent());
                    sashForm.setWeights(new int[] { 1, 1, 1 });
                }
            }
        }
    });

    final Listener focusListener = new Listener() {
        public void handleEvent(Event event) {
            //            if (!(event.widget instanceof Control))
            //            {
            //               return;
            //            }

            boolean isPreviewChild = false;
            if (context == null || context.queueViewer == null || context.queueViewer.getViewer() == null
                    || context.queueViewer.isDisposed()) {
                return;
            }
            for (Control c = (Control) event.widget; c != null; c = c.getParent()) {
                if (c == context.queueViewer.getViewer().getControl()) {
                    isPreviewChild = true;
                    break;
                }
                if (c == context.previewText) {
                    isPreviewChild = true;
                    break;
                }
            }

            if (!isPreviewChild) {
                sashForm.setWeights(new int[] { 0, 1, 1 });
            }
        }
    };

    getDisplay().addFilter(SWT.FocusIn, focusListener);
    getDisplay().addFilter(SWT.FocusOut, focusListener);

    addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            getDisplay().removeFilter(SWT.FocusIn, focusListener);
            getDisplay().removeFilter(SWT.FocusOut, focusListener);
        }
    });

    Button addWorkspaceButton = getToolkit().createButton(queueGroup, "Workspace", SWT.PUSH);
    addWorkspaceButton.setImage(InternalImage.ADD.getImage());
    addWorkspaceButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            ResourceSelectionDialog dialog = new ResourceSelectionDialog(getShell(),
                    ResourcesPlugin.getWorkspace().getRoot(), "");
            int returnCode = dialog.open();
            if (returnCode == Window.CANCEL) {
                return;
            }
            for (Object result : dialog.getResult()) {
                if (result instanceof IFile) {
                    IFile file = (IFile) result;
                    if (file.getName().endsWith(".tcl")) {
                        IBatchBuffer buffer = new ResourceBasedBatchBuffer(file.getName(),
                                file.getLocationURI());
                        getBatchBufferManager().getBatchBufferQueue().add(buffer);
                    }
                }
            }
        }
    });
    GridDataFactory.fillDefaults().grab(true, false).applyTo(addWorkspaceButton);

    Button addFileSystemButton = getToolkit().createButton(queueGroup, "File System", SWT.PUSH);
    addFileSystemButton.setImage(InternalImage.ADD.getImage());
    addFileSystemButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
            String result = dialog.open();
            if (result == null) {
                return;
            }
            // Only one (or zero) file is selected from the dialog
            File file = new File(result);
            if (file.getName().endsWith(".tcl")) {
                IBatchBuffer buffer = new ResourceBasedBatchBuffer(file.getName(), file.toURI());
                getBatchBufferManager().getBatchBufferQueue().add(buffer);
            }
        }
    });
    GridDataFactory.fillDefaults().grab(true, false).applyTo(addFileSystemButton);

    Button removeButton = getToolkit().createButton(queueGroup, "Remove", SWT.PUSH);
    removeButton.setImage(InternalImage.DELETE.getImage());
    removeButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selections = (IStructuredSelection) context.queueViewer.getViewer()
                    .getSelection();
            getBatchBufferManager().getBatchBufferQueue().removeAll(selections.toList());
        }
    });
    GridDataFactory.fillDefaults().grab(false, false).span(2, 1).applyTo(removeButton);

    //      Button pauseButton = getToolkit().createButton(queueGroup, "Pause", SWT.PUSH);
    //      pauseButton.setImage(InternalImage.PAUSE.getImage());

    context.autoRunButton = getToolkit().createButton(parent, "PLAY", SWT.TOGGLE);
    context.autoRunButton.setImage(InternalImage.PLAY.getImage());
    context.autoRunButton.setFont(JFaceResources.getBannerFont());
    context.autoRunButton.setSelection(getBatchBufferManager().isAutoRun());
    GridDataFactory.fillDefaults().grab(false, false).span(2, 1).applyTo(context.autoRunButton);
    final boolean[] previousSelection = new boolean[] { context.autoRunButton.getSelection() };
    context.autoRunButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            // Check instrument state
            if (checkInstrumentReady && !getBatchBufferManager().isAutoRun()) {
                IInstrumentReadyManager manager = ServiceUtils.getService(IInstrumentReadyManager.class);
                IInstrumentReadyStatus status = manager.isInstrumentReady();
                if (!status.isInstrumentReady()) {
                    // Prepare message
                    StringBuilder builder = new StringBuilder();
                    builder.append("Instrument is not ready due to the following reasons:\n");
                    for (String message : status.getMessages()) {
                        builder.append("  * " + message + "\n");
                    }
                    // Pop up dialog
                    MessageDialog.openWarning(getShell(), "Instrument is not ready", builder.toString());
                    // Disable run
                    getBatchBufferManager().setAutoRun(false);
                    ((Button) e.widget).setSelection(false);
                    return;
                }
            } else {
                boolean confirm = MessageDialog.openConfirm(getShell(), "Confirm pausing the queue",
                        "Please confirm if you want to pause the queue. "
                                + "The current script running in SICS will not be affected. If confirmed, the rest of the scripts in the "
                                + "buffer queue will not be processed.");
                if (!confirm) {
                    getBatchBufferManager().setAutoRun(true);
                    ((Button) e.widget).setSelection(true);
                    return;
                }
            }
            boolean isAutoRun = ((Button) e.widget).getSelection();
            if (previousSelection[0] != isAutoRun) {
                if (isAutoRun) {
                    context.autoRunButton.setText("Pause");
                    context.autoRunButton.setImage(InternalImage.PAUSE.getImage());
                    if (!clearLog) {
                        context.logText.setText("");
                        context.logText.resetScroll();
                    }
                } else {
                    context.autoRunButton.setText("Play");
                    context.autoRunButton.setImage(InternalImage.PLAY.getImage());
                }
                previousSelection[0] = isAutoRun;
            }
            getBatchBufferManager().setAutoRun(isAutoRun);
            if (!isAutoRun) {
                getBatchBufferManager().resetBufferManagerStatus();
            }
        }
    });
    context.autoRunButton.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            if (previousSelection[0] != context.autoRunButton.getSelection()) {
                if (context.autoRunButton.getSelection()) {
                    context.autoRunButton.setText("Pause");
                    context.autoRunButton.setImage(InternalImage.PAUSE.getImage());
                } else {
                    context.autoRunButton.setText("Play");
                    context.autoRunButton.setImage(InternalImage.PLAY.getImage());
                }
                previousSelection[0] = context.autoRunButton.getSelection();
            }
        }
    });

    Button interruptButton = getToolkit().createButton(parent, "Interrupt", SWT.PUSH);
    interruptButton.setImage(InternalImage.INTERRUPT.getImage());
    interruptButton.setFont(JFaceResources.getBannerFont());
    interruptButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            try {
                SicsCore.getSicsController().interrupt();
            } catch (SicsIOException e1) {
                e1.printStackTrace();
            }
        }
    });
    GridDataFactory.fillDefaults().grab(false, false).span(2, 1).applyTo(interruptButton);

    Button checkInstrumentButton = getToolkit().createButton(parent, "Check instrument ready", SWT.CHECK);
    checkInstrumentButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            checkInstrumentReady = ((Button) e.widget).getSelection();
        }
    });
    checkInstrumentReady = true;
    checkInstrumentButton.setSelection(true);

    updateStatus(batchBufferManager.getStatus());

}

From source file:org.gumtree.gumnix.sics.batch.ui.buffer.BatchValidationPage.java

License:Open Source License

private void createDisplayArea(Composite parent) {
    SashForm sashForm = new SashForm(parent, SWT.VERTICAL);
    getToolkit().adapt(sashForm);/* w  w w. j  a va 2  s  . c o m*/
    GridDataFactory.fillDefaults().grab(true, true).span(1, 4).applyTo(sashForm);

    // Editor
    Group editorGroup = new Group(sashForm, SWT.NONE);
    editorGroup.setText("Buffer");
    getToolkit().adapt(editorGroup);
    editorGroup.setLayout(new FillLayout());
    editorGroup.setFont(JFaceResources.getBannerFont());
    context.editorText = new AutoScrollStyledText(editorGroup,
            SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
    context.editorText.setFont(JFaceResources.getBannerFont());
    context.editorText.setData(KEY_PREV_DOC_LEN, 0);

    // Log
    Group logGroup = new Group(sashForm, SWT.NONE);
    logGroup.setText("Log");
    getToolkit().adapt(logGroup);
    logGroup.setLayout(new FillLayout());
    logGroup.setFont(JFaceResources.getBannerFont());
    context.logText = new AutoScrollStyledText(logGroup,
            SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
    context.logText.setFont(JFaceResources.getBannerFont());
    context.logText.setData(KEY_PREV_DOC_LEN, 0);

    sashForm.setWeights(new int[] { 1, 1 });
}

From source file:org.jboss.tools.common.model.ui.widgets.DefaultSettings.java

License:Open Source License

protected void initFonts() {
    defaultFont = JFaceResources.getDefaultFont();
    headerFont = JFaceResources.getBannerFont();
    titleFont = JFaceResources.getHeaderFont();
}

From source file:org.kalypso.contribs.eclipse.jface.wizard.view.WizardView.java

License:Open Source License

/**
 * Creates the dialog's title area.//from  ww  w  .  ja v a  2  s. c om
 *
 * @param parent
 *          the SWT parent for the title area widgets
 * @return Control with the highest x axis value.
 */
private Control createTitleArea(final Composite parent) {
    // remeber parent in order to change its colors
    m_parent = parent;

    // Determine the background color of the title bar
    final Display display = parent.getDisplay();
    m_defaultTitleBackground = JFaceColors.getBannerBackground(display).getRGB();
    m_defaultTitleForeground = JFaceColors.getBannerForeground(display).getRGB();

    final int verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    final int horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);

    // Dialog image @ right
    m_titleImage = new Label(parent, SWT.CENTER);
    m_titleImage.setImage(JFaceResources.getImage(TitleAreaDialog.DLG_IMG_TITLE_BANNER));
    final FormData imageData = new FormData();
    imageData.top = new FormAttachment(0, verticalSpacing);
    // 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
    m_titleImage.setLayoutData(imageData);
    // Title label @ top, left
    m_titleLabel = new Label(parent, SWT.LEFT);
    m_titleLabel.setFont(JFaceResources.getBannerFont());
    m_titleLabel.setText(" ");//$NON-NLS-1$
    final FormData titleData = new FormData();
    titleData.top = new FormAttachment(0, verticalSpacing);
    titleData.right = new FormAttachment(m_titleImage);
    titleData.left = new FormAttachment(0, horizontalSpacing);
    m_titleLabel.setLayoutData(titleData);
    // Message image @ bottom, left
    m_messageImageLabel = new Label(parent, SWT.CENTER);
    // Message label @ bottom, center
    m_messageLabel = new Text(parent, SWT.WRAP | SWT.READ_ONLY);
    m_messageLabel.setText(" \n "); // two lines//$NON-NLS-1$
    m_messageLabel.setFont(JFaceResources.getDialogFont());

    // Filler labels
    m_leftFillerLabel = new Label(parent, SWT.CENTER);
    m_bottomFillerLabel = new Label(parent, SWT.CENTER);
    setLayoutsForNormalMessage(verticalSpacing, horizontalSpacing);
    determineTitleImageLargest();
    if (m_titleImageLargest)
        return m_titleImage;
    return m_messageLabel;
}

From source file:org.kalypso.kalypsomodel1d2d.sim.IterationComposite.java

License:Open Source License

public IterationComposite(final Composite composite, final IKalypsoSimulationRunnerComposite calculation,
        final ICalculationUnit subUnit, final int style) {
    super(composite, style);

    m_subUnit = subUnit;//from   w ww.  java2s.c  o m

    final Label unitLable = new Label(this, SWT.CENTER);
    unitLable.setText(m_subUnit.getName() + " - " + calculation.getCalculationTypeName()); //$NON-NLS-1$
    unitLable.setFont(JFaceResources.getBannerFont());

    m_tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);

    final IComponentUiHandlerProvider provider = KalypsoUIExtensions
            .createComponentUiHandlerProvider(DefaultComponentUiHandlerProvider2.ID);
    m_tableViewer.setContentProvider(new TupleResultContentProvider2(provider));

    final Table table = m_tableViewer.getTable();
    table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    table.setHeaderVisible(true);
    table.setVisible(false);

    /* Create control */
    setLayout(new GridLayout(2, false));

    final Label comboLabel = new Label(this, SWT.NONE);
    comboLabel.setText(Messages.getString("org.kalypso.kalypsomodel1d2d.sim.IterationComposite.1")); //$NON-NLS-1$

    m_comboViewer = new ComboViewer(this, SWT.DROP_DOWN | SWT.READ_ONLY);
    m_comboViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, false));
    m_comboViewer.setContentProvider(new ArrayContentProvider());

    m_comboViewer.setInput(m_comboInput);
    m_comboInput.add(STR_NO_RESULTS);
    m_comboViewer.refresh();
    m_comboViewer.setSelection(new StructuredSelection(STR_NO_RESULTS));
    m_comboViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(final Object element) {
            if (element instanceof IterationBean)
                return ((IterationBean) element).name;

            if (element instanceof IObservation)
                return ((IObservation<?>) element).getName();

            return super.getText(element);
        }
    });

    m_comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            handleComboSelectionChanged((IStructuredSelection) event.getSelection());
        }
    });

    m_statusComposite = new StatusComposite(this, StatusComposite.DETAILS);
    m_statusComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    setStatus(null);

    m_comboViewer.getControl().setEnabled(false);

    final Job refreshJob = new UIJob(
            Messages.getString("org.kalypso.kalypsomodel1d2d.sim.IterationComposite.2")) //$NON-NLS-1$
    {
        @Override
        public IStatus runInUIThread(final IProgressMonitor monitor) {
            try {
                updateControl(calculation);

                ProgressUtilities.done(monitor);
            } catch (final CoreException e) {
                return e.getStatus();
            }

            /* Periodically reschedule this task, if it was not canceled */
            if (calculation.getSimulationStatus() == null)
                schedule(500);
            else
                updateControl(calculation); // update one last time, to make sure, current iter is removed from view

            return Status.OK_STATUS;
        }
    };
    refreshJob.setPriority(Job.INTERACTIVE);
    refreshJob.setUser(false);
    refreshJob.setSystem(true);
    refreshJob.schedule();

    addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(final DisposeEvent e) {
            refreshJob.cancel();
        }
    });
}

From source file:org.mailster.gui.prefs.widgets.DialogMessageArea.java

License:Open Source License

/**
 * Create the contents for the receiver.
 * /*from w  w  w. java2 s  . c  om*/
 * @param parent the Composite that the children will be created in
 */
public void createContents(Composite parent) {
    /* Create the title label */
    this.titleLabel = new CLabel(parent, SWT.LEFT);
    int[] alpha = new int[] { 75, 100 };
    this.titleLabel.setBackground(DEFAULT_GRADIENT_BACKGROUND, alpha);
    this.titleLabel.setFont(JFaceResources.getBannerFont());
    this.titleLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    this.titleLabel.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            e.gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY));
            Rectangle bounds = titleLabel.getClientArea();
            bounds.height -= 2;
            bounds.width -= 1;
            e.gc.drawRectangle(bounds);
        }
    });

    /* Create the message container */
    this.messageComposite = new Composite(parent, SWT.NONE);
    GridLayout messageLayout = new GridLayout(2, false);
    messageLayout.marginWidth = 0;
    messageLayout.marginHeight = 0;
    this.messageComposite.setLayout(messageLayout);

    /* Create the message image holder */
    this.messageImageLabel = new Label(this.messageComposite, SWT.NONE);
    this.messageImageLabel.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO));
    this.messageImageLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER));

    /* Create the message text holder */
    this.messageText = new Text(this.messageComposite, SWT.NONE);
    this.messageText.setEditable(false);

    GridData textData = new GridData(
            GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
    this.messageText.setLayoutData(textData);
}

From source file:org.modelio.api.ui.ModelioDialog.java

License:Apache License

@objid("bc2b30d0-120f-11e2-b5c6-002564c97630")
private Control createTitleArea(Composite parent) {
    this.titleArea = new Composite(parent, SWT.NONE);
    initializeDialogUnits(this.titleArea);
    FormData titleAreaData = new FormData();
    titleAreaData.top = new FormAttachment(0, 0);
    titleAreaData.left = new FormAttachment(0, 0);
    titleAreaData.right = new FormAttachment(100, 0);
    this.titleArea.setLayoutData(titleAreaData);
    FormLayout layout = new FormLayout();
    this.titleArea.setLayout(layout);
    this.titleArea.addDisposeListener(new DisposeListener() {
        @Override//from  w  ww.  jav  a2  s .  c  o m
        public void widgetDisposed(DisposeEvent e) {
            if (ModelioDialog.this.titleAreaColor != null)
                ModelioDialog.this.titleAreaColor.dispose();
        }
    });

    org.eclipse.swt.widgets.Display display = this.titleArea.getDisplay();
    Color background;
    Color foreground;
    if (this.titleAreaRGB != null) {
        this.titleAreaColor = new Color(display, this.titleAreaRGB);
        background = this.titleAreaColor;
        foreground = null;
    } else {
        background = JFaceColors.getBannerBackground(display);
        foreground = JFaceColors.getBannerForeground(display);
    }
    int verticalSpacing = convertVerticalDLUsToPixels(1);
    int horizontalSpacing = convertHorizontalDLUsToPixels(4);
    this.titleArea.setBackground(background);

    this.titleRightImageLabel = new Label(this.titleArea, SWT.NONE);
    this.titleRightImageLabel.setBackground(background);
    if (this.titleRightImage != null && !this.titleRightImage.isDisposed())
        this.titleRightImageLabel.setImage(this.titleRightImage);

    this.titleLeftImageLabel = new Label(this.titleArea, SWT.NONE);
    this.titleLeftImageLabel.setBackground(background);
    if (this.titleLeftImage == null || this.titleLeftImage.isDisposed())
        this.titleLeftImageLabel.setImage(JFaceResources.getImage(DLG_IMG_TITLE_BANNER));
    else
        this.titleLeftImageLabel.setImage(this.titleLeftImage);

    FormData rightImageData = new FormData();
    rightImageData.top = new FormAttachment(0, 0);
    rightImageData.right = new FormAttachment(100, 0);
    this.titleRightImageLabel.setLayoutData(rightImageData);

    FormData leftImageData = new FormData();
    leftImageData.top = new FormAttachment(0, 0);
    leftImageData.left = new FormAttachment(0, 0);
    this.titleLeftImageLabel.setLayoutData(leftImageData);

    this.titleLabel = new Label(this.titleArea, SWT.NONE);
    JFaceColors.setColors(this.titleLabel, foreground, background);
    this.titleLabel.setFont(JFaceResources.getBannerFont());
    this.titleLabel.setText(" ");
    FormData titleData = new FormData();
    titleData.left = new FormAttachment(this.titleLeftImageLabel, 5);
    titleData.top = new FormAttachment(0, verticalSpacing);
    titleData.right = new FormAttachment(this.titleRightImageLabel, -5);
    this.titleLabel.setLayoutData(titleData);
    this.messageImageLabel = new Label(this.titleArea, SWT.NONE);
    this.messageImageLabel.setBackground(background);
    this.messageLabel = new Text(this.titleArea, SWT.READ_ONLY | SWT.MULTI | SWT.WRAP);
    //this.messageLabel.setEnabled(false);
    this.messageLabel.setEditable(false);
    JFaceColors.setColors(this.messageLabel, foreground, background);
    this.messageLabel.setFont(JFaceResources.getDialogFont());
    this.messageLabelHeight = this.messageLabel.computeSize(-1, -1).y;
    this.leftFillerLabel = new Label(this.titleArea, SWT.NONE);
    this.leftFillerLabel.setBackground(background);
    setLayoutsForNormalMessage(verticalSpacing, horizontalSpacing);
    determineTitleImageLargest();
    return this.titleArea;
}

From source file:org.modelio.app.preferences.ModelioPreferenceDialog.java

License:Open Source License

@objid("30b98bd5-cab0-4393-b635-b2702b1f80ed")
private void createTitle(Composite parent) {
    // image from plugin
    ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin("org.modelio.app.preferences",
            "icons/headerleft.png");

    Image image = imageDescriptor.createImage();
    setTitleLeftImage(image);//w  w w.  jav a  2 s. c o m

    // _titleArea = new Composite(parent, SWT.NONE);
    this._titleArea = new Composite(parent, SWT.NONE);
    initializeDialogUnits(this._titleArea);
    GridData titleAreaData = new GridData(SWT.FILL, SWT.TOP, true, false);
    /*
     * titleAreaData.top = new FormAttachment(0, 0); titleAreaData.left = new FormAttachment(0, 0); titleAreaData.right = new
     * FormAttachment(100, 0);
     */
    this._titleArea.setLayoutData(titleAreaData);
    FormLayout layout = new FormLayout();
    this._titleArea.setLayout(layout);
    this._titleArea.addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(DisposeEvent e) {
            if (ModelioPreferenceDialog.this._titleAreaColor != null)
                ModelioPreferenceDialog.this._titleAreaColor.dispose();
        }
    });

    org.eclipse.swt.widgets.Display display = this._titleArea.getDisplay();
    Color background;
    Color foreground;
    if (this._titleAreaRGB != null) {
        this._titleAreaColor = new Color(display, this._titleAreaRGB);
        background = this._titleAreaColor;
        foreground = null;
    } else {
        background = JFaceColors.getBannerBackground(display);
        foreground = JFaceColors.getBannerForeground(display);
    }
    int verticalSpacing = convertVerticalDLUsToPixels(1);
    int horizontalSpacing = convertHorizontalDLUsToPixels(4);
    this._titleArea.setBackground(background);

    this._titleRightImageLabel = new Label(this._titleArea, SWT.NONE);
    this._titleRightImageLabel.setBackground(background);
    if (this._titleRightImage != null && !this._titleRightImage.isDisposed())
        this._titleRightImageLabel.setImage(this._titleRightImage);

    this._titleLeftImageLabel = new Label(this._titleArea, SWT.NONE);
    this._titleLeftImageLabel.setBackground(background);
    if (this._titleLeftImage == null || this._titleLeftImage.isDisposed())
        this._titleLeftImageLabel.setImage(JFaceResources.getImage(DLG_IMG_TITLE_BANNER));
    else
        this._titleLeftImageLabel.setImage(this._titleLeftImage);

    FormData rightImageData = new FormData();
    rightImageData.top = new FormAttachment(0, 0);
    rightImageData.right = new FormAttachment(100, 0);
    this._titleRightImageLabel.setLayoutData(rightImageData);

    FormData leftImageData = new FormData();
    leftImageData.top = new FormAttachment(0, 0);
    leftImageData.left = new FormAttachment(0, 0);
    this._titleLeftImageLabel.setLayoutData(leftImageData);

    this._titleLabel = new Label(this._titleArea, SWT.NONE);
    JFaceColors.setColors(this._titleLabel, foreground, background);
    this._titleLabel.setFont(JFaceResources.getBannerFont());
    this._titleLabel.setText(" ");
    FormData titleData = new FormData();
    titleData.left = new FormAttachment(this._titleLeftImageLabel, 5);
    titleData.top = new FormAttachment(0, verticalSpacing);
    titleData.right = new FormAttachment(this._titleRightImageLabel, -5);
    this._titleLabel.setLayoutData(titleData);
    this._messageImageLabel = new Label(this._titleArea, SWT.NONE);
    this._messageImageLabel.setBackground(background);
    this._messageLabel = new Text(this._titleArea, SWT.READ_ONLY | SWT.MULTI);
    this._messageLabel.setEnabled(false);
    this._messageLabel.setEditable(false);
    JFaceColors.setColors(this._messageLabel, foreground, background);
    this._messageLabel.setFont(JFaceResources.getDialogFont());
    this._messageLabelHeight = this._messageLabel.computeSize(-1, -1).y;
    this._leftFillerLabel = new Label(this._titleArea, SWT.NONE);
    this._leftFillerLabel.setBackground(background);
    setLayoutsForNormalMessage(verticalSpacing, horizontalSpacing);
    determineTitleImageLargest();

    Label titleBarSeparator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
    GridData barData = new GridData(768);
    titleBarSeparator.setLayoutData(barData);
}

From source file:org.modelio.core.ui.dialog.ModelioDialog.java

License:Open Source License

@objid("004a0aba-4a05-1fe0-bf4c-001ec947cd2a")
private Control createTitleArea(Composite parent) {
    this.titleArea = new Composite(parent, SWT.NONE);
    initializeDialogUnits(this.titleArea);
    FormData titleAreaData = new FormData();
    titleAreaData.top = new FormAttachment(0, 0);
    titleAreaData.left = new FormAttachment(0, 0);
    titleAreaData.right = new FormAttachment(100, 0);
    this.titleArea.setLayoutData(titleAreaData);
    FormLayout layout = new FormLayout();
    this.titleArea.setLayout(layout);
    this.titleArea.addDisposeListener(new DisposeListener() {
        @Override//from  w ww.j  av a2  s  .c  o m
        public void widgetDisposed(DisposeEvent e) {
            if (ModelioDialog.this.titleAreaColor != null)
                ModelioDialog.this.titleAreaColor.dispose();
        }
    });

    org.eclipse.swt.widgets.Display display = this.titleArea.getDisplay();
    Color background;
    Color foreground;
    if (this.titleAreaRGB != null) {
        this.titleAreaColor = new Color(display, this.titleAreaRGB);
        background = this.titleAreaColor;
        foreground = null;
    } else {
        background = JFaceColors.getBannerBackground(display);
        foreground = JFaceColors.getBannerForeground(display);
    }
    int verticalSpacing = convertVerticalDLUsToPixels(1);
    int horizontalSpacing = convertHorizontalDLUsToPixels(4);
    this.titleArea.setBackground(background);

    this.titleRightImageLabel = new Label(this.titleArea, SWT.NONE);
    this.titleRightImageLabel.setBackground(background);
    if (this.titleRightImage != null && !this.titleRightImage.isDisposed())
        this.titleRightImageLabel.setImage(this.titleRightImage);

    this.titleLeftImageLabel = new Label(this.titleArea, SWT.NONE);
    this.titleLeftImageLabel.setBackground(background);
    if (this.titleLeftImage == null || this.titleLeftImage.isDisposed())
        this.titleLeftImageLabel.setImage(JFaceResources.getImage(DLG_IMG_TITLE_BANNER));
    else
        this.titleLeftImageLabel.setImage(this.titleLeftImage);

    FormData rightImageData = new FormData();
    rightImageData.top = new FormAttachment(0, 0);
    rightImageData.right = new FormAttachment(100, 0);
    this.titleRightImageLabel.setLayoutData(rightImageData);

    FormData leftImageData = new FormData();
    leftImageData.top = new FormAttachment(0, 0);
    leftImageData.left = new FormAttachment(0, 0);
    this.titleLeftImageLabel.setLayoutData(leftImageData);

    this.titleLabel = new Label(this.titleArea, SWT.NONE);
    JFaceColors.setColors(this.titleLabel, foreground, background);
    this.titleLabel.setFont(JFaceResources.getBannerFont());
    this.titleLabel.setText(" ");
    FormData titleData = new FormData();
    titleData.left = new FormAttachment(this.titleLeftImageLabel, 5);
    titleData.top = new FormAttachment(0, verticalSpacing);
    titleData.right = new FormAttachment(this.titleRightImageLabel, -5);
    this.titleLabel.setLayoutData(titleData);
    this.messageImageLabel = new Label(this.titleArea, SWT.NONE);
    this.messageImageLabel.setBackground(background);
    this.messageLabel = new Text(this.titleArea, SWT.READ_ONLY | SWT.MULTI | SWT.WRAP);
    //this.messageLabel.setEnabled(false);
    this.messageLabel.setEditable(false);
    JFaceColors.setColors(this.messageLabel, foreground, background);
    this.messageLabel.setFont(JFaceResources.getDialogFont());
    this.messageLabelHeight = this.messageLabel.computeSize(-1, -1).y;
    this.leftFillerLabel = new Label(this.titleArea, SWT.NONE);
    this.leftFillerLabel.setBackground(background);
    setLayoutsForNormalMessage(verticalSpacing, horizontalSpacing);
    determineTitleImageLargest();
    return this.titleArea;
}