Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ ColorTitle_0 = Name
ColorTitle_1 = Type
ColorTitle_2 = RGBA
ColorTitle_3 = Color
ColorTitle_4 = Image
Header_Foreground_Color = Header Foreground Color
Header_Background_Color = Header Background Color
Tab_Height = Tab Height
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ Tab[] createTabs() {
return new Tab [] {
new ButtonTab (this),
new CanvasTab (this),
new ColorTab(this),
new ComboTab (this),
new CoolBarTab (this),
new DateTimeTab (this),
Expand All @@ -121,6 +120,7 @@ Tab[] createTabs() {
shellTab = new ShellTab(this),
new SliderTab (this),
new SpinnerTab (this),
new SystemTab(this),
new TabFolderTab (this),
new TableTab (this),
new TextTab (this),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2016 Red Hat, Inc. and others.
* Copyright (c) 2000, 2025 Red Hat, Inc. and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -14,7 +14,6 @@
*******************************************************************************/
package org.eclipse.swt.examples.controlexample;


import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;

import java.util.HashMap;
Expand All @@ -34,24 +33,27 @@
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Widget;

class ColorTab extends Tab {
Table colors, cursors;
Group colorsGroup, cursorsGroup;
class SystemTab extends Tab {
Table colors, cursors, images;
Group colorsGroup, cursorsGroup, imagesGroup;
HashMap <Integer, String> hmap = new HashMap <> ();
HashMap <Integer, String> cmap = new HashMap <> ();
HashMap <Integer, String> imap = new HashMap <> ();
static final int namedColorEnd = 8;
static String [] columnTitles = {ControlExample.getResourceString("ColorTitle_0"),
ControlExample.getResourceString("ColorTitle_1"),
ControlExample.getResourceString("ColorTitle_2"),
ControlExample.getResourceString("ColorTitle_3")};
static String [] columnTitles2 = {ControlExample.getResourceString("ColorTitle_0"),
ControlExample.getResourceString("ColorTitle_4")};

/* Size widgets added to the "Size" group */
Button packColumnsButton;

/**
* Creates the color tab within a given instance of ControlExample.
*/
ColorTab(ControlExample instance) {
SystemTab(ControlExample instance) {
super(instance);
addTableElements();
}
Expand Down Expand Up @@ -110,6 +112,12 @@ void addTableElements () {
cmap.put(SWT.CURSOR_UPARROW, "CURSOR_UPARROW");
cmap.put(SWT.CURSOR_IBEAM, "CURSOR_IBEAM");
cmap.put(SWT.CURSOR_NO, "CURSOR_NO");

imap.put(SWT.ICON_ERROR, "ICON_ERROR");
imap.put(SWT.ICON_INFORMATION, "ICON_INFORMATION");
imap.put(SWT.ICON_QUESTION, "ICON_QUESTION");
imap.put(SWT.ICON_WARNING, "ICON_WARNING");
imap.put(SWT.ICON_WORKING, "ICON_WORKING");
}

/**
Expand All @@ -118,7 +126,7 @@ void addTableElements () {
@Override
void createExampleGroup () {
super.createExampleGroup ();
exampleGroup.setLayout(new GridLayout(2, false));
exampleGroup.setLayout(new GridLayout(3, false));

colorsGroup = new Group (exampleGroup, SWT.NONE);
colorsGroup.setLayout (new GridLayout ());
Expand All @@ -129,6 +137,11 @@ void createExampleGroup () {
cursorsGroup.setLayout (new GridLayout ());
cursorsGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, false, true));
cursorsGroup.setText ("Cursors");

imagesGroup = new Group (exampleGroup, SWT.NONE);
imagesGroup.setLayout (new GridLayout ());
imagesGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, false, true));
imagesGroup.setText ("Images");
}

/**
Expand Down Expand Up @@ -205,22 +218,44 @@ void createExampleWidgets () {
Cursor cursor = (item != null) ? (Cursor) item.getData() : null;
cursors.setCursor(cursor);
});

/* Create the images table widget */
images = new Table (imagesGroup, style | SWT.V_SCROLL);
images.setLayoutData(new GridData (SWT.FILL, SWT.FILL, false, true));
images.setHeaderVisible(true);
// fill in the table.
for (String columnTitle : columnTitles2) {
TableColumn tableColumn1 = new TableColumn(images, SWT.NONE);
tableColumn1.setText(columnTitle);
tableColumn1.setToolTipText(ControlExample.getResourceString("Tooltip", columnTitle));
}
for (Entry<Integer, String> entry : imap.entrySet()) {
Integer key = entry.getKey();
String value = entry.getValue();
TableItem item = new TableItem(images, SWT.NONE);
item.setText(value);
item.setText(0, value);
item.setImage(1, display.getSystemImage(key));
}
for (int i = 0; i < columnTitles2.length; i++) {
images.getColumn(i).pack();
}
}

/**
* Gets the "Example" widget children.
*/
@Override
Widget [] getExampleWidgets () {
return new Widget [] {colors, cursors};
return new Widget [] {colors, cursors, images};
}

/**
* Gets the Tab name.
*/
@Override
String getTabText () {
return "Color";
return "System";
}

/**
Expand Down
Loading