List of usage examples for org.eclipse.jface.resource JFaceColors getBannerBackground
public static Color getBannerBackground(Display display)
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 ww . j a v a2 s. co 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. * // w w w . j a v a 2 s . c o m * @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 w ww. j a va 2 s. c o m*/ 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 ww w . j av a 2 s . co 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.ibm.research.tagging.core.ui.dialogs.OpenWaypointDialog.java
License:Open Source License
private void createWaypointTableViewer(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridData compositeLayout = new GridData(GridData.FILL_BOTH); compositeLayout.heightHint = 240;//from w w w . j a v a 2 s .c o m composite.setLayoutData(compositeLayout); composite.setBackground(JFaceColors.getBannerBackground(Display.getDefault())); GridLayout layout = new GridLayout(); layout.marginWidth = 3; layout.marginHeight = 3; layout.verticalSpacing = 0; layout.marginTop = 0; layout.marginBottom = 0; layout.marginLeft = 0; layout.marginRight = 0; layout.horizontalSpacing = 0; composite.setLayout(layout); ExpressionFilteredTable fFilteredTable = new ExpressionFilteredTable(composite, SWT.MULTI | SWT.V_SCROLL, new ExpressionPatternFilter()); fFilteredTable.setBackground(JFaceColors.getBannerBackground(Display.getDefault())); TableViewer fWaypointViewer = fFilteredTable.getViewer(); fWaypointViewer.setContentProvider(new WaypointTableContentProvider()); fWaypointViewer.setLabelProvider(new WaypointTableLabelProvider()); fWaypointViewer.setSorter(new WaypointTableSorter()); fWaypointViewer.addDragSupport(DND.DROP_MOVE | DND.DROP_COPY, new Transfer[] { WaypointTransfer.getInstance()/*, PluginTransfer.getInstance()*/ }, new WaypointTableDragListener(fWaypointViewer)); fWaypointViewer.addSelectionChangedListener(new WaypointTableSelectionChangedListener()); fWaypointViewer.addSelectionChangedListener(this); fWaypointViewer.addDoubleClickListener(new WaypointTableDoubleClickListener()); Table table = fWaypointViewer.getTable(); table.setHeaderVisible(false); table.setLinesVisible(true); final TableColumn fNameColumn = new TableColumn(table, SWT.LEFT, 0); fNameColumn.setMoveable(false); fNameColumn.setWidth(240); final TableColumn fDescriptionColumn = new TableColumn(table, SWT.LEFT, 1); fDescriptionColumn.setMoveable(false); fDescriptionColumn.setWidth(640); // auto-resize columns on any change to the table table.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { Table table = (Table) e.widget; Rectangle clientSize = table.getClientArea(); int newWidth = clientSize.width - fNameColumn.getWidth(); // this check prevents recursion if (fDescriptionColumn.getWidth() != newWidth) fDescriptionColumn.setWidth(newWidth); } }); fWaypointViewer.setInput(new Object()); }
From source file:com.ibm.research.tagging.core.ui.tags.TagView.java
License:Open Source License
private void createRootComposite(Composite parent) { fRoot = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0;/* w w w . java 2 s.co m*/ layout.marginWidth = 0; layout.marginTop = 0; layout.marginBottom = 0; layout.marginLeft = 0; layout.marginRight = 0; layout.verticalSpacing = 0; layout.horizontalSpacing = 0; fRoot.setLayout(layout); fRoot.setBackground(JFaceColors.getBannerBackground(Display.getDefault())); }
From source file:com.ibm.research.tagging.core.ui.tags.TagView.java
License:Open Source License
private void createTagTableViewer(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); composite.setBackground(JFaceColors.getBannerBackground(Display.getDefault())); GridLayout layout = new GridLayout(); layout.marginHeight = 3;// ww w.ja v a 2s .co m layout.marginWidth = 3; composite.setLayout(layout); FilteredTable filteredTable = new FilteredTable(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, new NQueryTablePatternFilter()); filteredTable.setBackground(JFaceColors.getBannerBackground(Display.getDefault())); fTagViewer = filteredTable.getViewer(); fTagViewer.setContentProvider(new TagTableContentProvider()); fTagViewer.setLabelProvider(new TagTableLabelProvider()); fTagViewer.setSorter(new TagTableSorter()); fHideUnusedTagsFilter = new UnusedTagsViewerFilter(); fTagViewer.addFilter(fHideUnusedTagsFilter); fTagViewer.addDoubleClickListener(new TagTableDoubleClickListener()); fTagViewer.addSelectionChangedListener(new TagTableSelectionChangedListener()); Table table = fTagViewer.getTable(); table.setHeaderVisible(false); table.setLinesVisible(false); fTagViewer.setInput(new Object()); }
From source file:com.ibm.research.tagging.core.ui.waypoints.WaypointView.java
License:Open Source License
private void createRootComposite(Composite parent) { fRoot = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginWidth = 0;/*w ww . jav a 2 s . co m*/ layout.marginHeight = 0; layout.verticalSpacing = 0; layout.marginTop = 0; layout.marginBottom = 0; layout.marginLeft = 0; layout.marginRight = 0; layout.horizontalSpacing = 0; fRoot.setLayout(layout); fRoot.setBackground(JFaceColors.getBannerBackground(Display.getDefault())); }
From source file:com.ibm.research.tagging.core.ui.waypoints.WaypointView.java
License:Open Source License
private void createWaypointTableViewer(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); composite.setBackground(JFaceColors.getBannerBackground(Display.getDefault())); GridLayout layout = new GridLayout(); layout.marginWidth = 3;/*from w w w . ja v a2 s. co m*/ layout.marginHeight = 3; layout.verticalSpacing = 0; layout.marginTop = 0; layout.marginBottom = 0; layout.marginLeft = 0; layout.marginRight = 0; layout.horizontalSpacing = 0; composite.setLayout(layout); fFilteredTable = new ExpressionFilteredTable(composite, SWT.MULTI | SWT.V_SCROLL, new ExpressionPatternFilter()); fFilteredTable.setBackground(JFaceColors.getBannerBackground(Display.getDefault())); fWaypointViewer = fFilteredTable.getViewer(); fWaypointViewer.setContentProvider(new WaypointTableContentProvider()); fWaypointViewer.setLabelProvider(new WaypointTableLabelProvider()); fWaypointViewer.setSorter(new WaypointTableSorter()); fWaypointViewer.addDragSupport(DND.DROP_MOVE | DND.DROP_COPY, new Transfer[] { WaypointTransfer.getInstance()/*, PluginTransfer.getInstance()*/ }, new WaypointTableDragListener(fWaypointViewer)); fWaypointViewer.addSelectionChangedListener(new WaypointTableSelectionChangedListener()); fWaypointViewer.addDoubleClickListener(new WaypointTableDoubleClickListener()); Table table = fWaypointViewer.getTable(); table.setHeaderVisible(false); table.setLinesVisible(true); fNameColumn = new TableColumn(table, SWT.LEFT, 0); fNameColumn.setMoveable(false); fNameColumn.setWidth(240); fDescriptionColumn = new TableColumn(table, SWT.LEFT, 1); fDescriptionColumn.setMoveable(false); fDescriptionColumn.setWidth(640); // auto-resize columns on any change to the table table.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { Table table = (Table) e.widget; Rectangle clientSize = table.getClientArea(); int newWidth = clientSize.width - fNameColumn.getWidth(); // this check prevents recursion if (fDescriptionColumn.getWidth() != newWidth) fDescriptionColumn.setWidth(newWidth); } }); fWaypointViewer.setInput(new Object()); }
From source file:com.ibm.research.tours.controls.HandleToggle.java
License:Open Source License
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); GridLayout layout = new GridLayout(2, false); layout.marginHeight = 0;/*from w w w .ja v a 2s . c o m*/ layout.marginWidth = 0; shell.setLayout(layout); shell.setBackground(JFaceColors.getBannerBackground(display)); Canvas filler = new Canvas(shell, SWT.NONE); filler.setBackground(JFaceColors.getBannerBackground(filler.getDisplay())); filler.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { Canvas canvas = (Canvas) e.widget; Point size = canvas.getSize(); e.gc.setBackground(canvas.getBackground()); e.gc.fillRectangle(0, 0, size.x, size.y); } }); GridData fillerData = new GridData(GridData.FILL_BOTH); filler.setLayoutData(fillerData); HandleToggle toggle = new HandleToggle(shell, SWT.VERTICAL); toggle.setCornerBackground(filler.getBackground()); toggle.setTooltips("toggle on", "toggle off"); toggle.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { HandleToggle toggle = (HandleToggle) e.widget; MessageDialog.openInformation(toggle.getShell(), "test", "you selected the toggle widget. toggle state=" + toggle.getToggleState()); } }); toggle.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); GridData data = new GridData(SWT.RIGHT, SWT.FILL, false, true); data.widthHint = 12; data.minimumWidth = 12; toggle.setLayoutData(data); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }