diff --git a/examples/org.eclipse.nebula.examples/.classpath b/examples/org.eclipse.nebula.examples/.classpath
index ca3785c41..e801ebfb4 100644
--- a/examples/org.eclipse.nebula.examples/.classpath
+++ b/examples/org.eclipse.nebula.examples/.classpath
@@ -1,7 +1,7 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/examples/org.eclipse.nebula.examples/.settings/org.eclipse.jdt.core.prefs b/examples/org.eclipse.nebula.examples/.settings/org.eclipse.jdt.core.prefs
index e2e9c66d8..f2525a8b9 100644
--- a/examples/org.eclipse.nebula.examples/.settings/org.eclipse.jdt.core.prefs
+++ b/examples/org.eclipse.nebula.examples/.settings/org.eclipse.jdt.core.prefs
@@ -1,14 +1,14 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=11
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
-org.eclipse.jdt.core.compiler.release=enabled
-org.eclipse.jdt.core.compiler.source=11
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=11
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=11
diff --git a/examples/org.eclipse.nebula.examples/build.properties b/examples/org.eclipse.nebula.examples/build.properties
index 58b5d42dc..2398cbab9 100644
--- a/examples/org.eclipse.nebula.examples/build.properties
+++ b/examples/org.eclipse.nebula.examples/build.properties
@@ -1,8 +1,8 @@
-source.. = src/
-output.. = bin/
-bin.includes = icons/,\
- plugin.xml,\
- META-INF/,\
- plugin.properties,\
- .
-src.includes = about.html
+source.. = src/
+output.. = bin/
+bin.includes = icons/,\
+ plugin.xml,\
+ META-INF/,\
+ plugin.properties,\
+ .
+src.includes = about.html
diff --git a/examples/org.eclipse.nebula.examples/schema/examples.exsd b/examples/org.eclipse.nebula.examples/schema/examples.exsd
index b414edeaf..df1c2a40f 100644
--- a/examples/org.eclipse.nebula.examples/schema/examples.exsd
+++ b/examples/org.eclipse.nebula.examples/schema/examples.exsd
@@ -1,154 +1,154 @@
-
-
-
-
-
-
-
-
- Provides an extension point to hook in the Nebula Examples View.
-
-
-
-
-
-
-
-
-
- This extension point enables extenders to hook into the Nebula Examples view. Each contribution will be displayed in a separate tab in the view.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- The tab element is used to point to an implementation of AbstractExampleTab
-
-
-
-
-
-
- The name attribute will be used as the title of the tab. Provide a short name like "ChartTable" which describes the widget that is exposed on the tab.
-
-
-
-
-
-
-
-
-
- Provide a class that extends org.eclipse.nebula.examples.AbstractExampleTab.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- The value of the class attribute in the describer element must represent an implementor of org.eclipse.nebula.examples.AbstractExampleTab
-
-
-
-
-
-
-
-
- 1.0
-
-
-
-
-
-
-
-
- <pre>
-<extension
- point="org.eclipse.nebula.examples.examples">
- <tab
- class="org.eclipse.nebula.widgets.oscilloscope.example.OscilloscopeExampleTab"
- name="Oscilloscope">
- </tab>
-</extension>
-
-
-<extension
- point="org.eclipse.nebula.examples.examples">
- <tab
- class="org.eclipse.nebula.widgets.ganttchart.example.GanttExampleTab"
- name="Ganttchart">
- </tab>
-</extension>
-</pre>
-
-
-
-
-
-
-
-
- No information is supplied by the provider of this extension point but all Nebula widgets must use this extension point. Please look at any of the Nebula widgets for a variety of implementation examples.
-
-
-
-
-
-
-
-
- Copyright (c) 2007,2012 IBM, Remain Software and Others
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Eclipse Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/epl-v10.html
-
-Contributors:
- Chris Gross - IBM - Creation
- Wim jongman <wim.jongman@remainsoftware.com> Documentation
-
-
-
-
-
+
+
+
+
+
+
+
+
+ Provides an extension point to hook in the Nebula Examples View.
+
+
+
+
+
+
+
+
+
+ This extension point enables extenders to hook into the Nebula Examples view. Each contribution will be displayed in a separate tab in the view.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The tab element is used to point to an implementation of AbstractExampleTab
+
+
+
+
+
+
+ The name attribute will be used as the title of the tab. Provide a short name like "ChartTable" which describes the widget that is exposed on the tab.
+
+
+
+
+
+
+
+
+
+ Provide a class that extends org.eclipse.nebula.examples.AbstractExampleTab.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The value of the class attribute in the describer element must represent an implementor of org.eclipse.nebula.examples.AbstractExampleTab
+
+
+
+
+
+
+
+
+ 1.0
+
+
+
+
+
+
+
+
+ <pre>
+<extension
+ point="org.eclipse.nebula.examples.examples">
+ <tab
+ class="org.eclipse.nebula.widgets.oscilloscope.example.OscilloscopeExampleTab"
+ name="Oscilloscope">
+ </tab>
+</extension>
+
+
+<extension
+ point="org.eclipse.nebula.examples.examples">
+ <tab
+ class="org.eclipse.nebula.widgets.ganttchart.example.GanttExampleTab"
+ name="Ganttchart">
+ </tab>
+</extension>
+</pre>
+
+
+
+
+
+
+
+
+ No information is supplied by the provider of this extension point but all Nebula widgets must use this extension point. Please look at any of the Nebula widgets for a variety of implementation examples.
+
+
+
+
+
+
+
+
+ Copyright (c) 2007,2012 IBM, Remain Software and Others
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
+ Chris Gross - IBM - Creation
+ Wim jongman <wim.jongman@remainsoftware.com> Documentation
+
+
+
+
+
diff --git a/examples/org.eclipse.nebula.snippets/.classpath b/examples/org.eclipse.nebula.snippets/.classpath
index ca3785c41..e801ebfb4 100644
--- a/examples/org.eclipse.nebula.snippets/.classpath
+++ b/examples/org.eclipse.nebula.snippets/.classpath
@@ -1,7 +1,7 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/examples/org.eclipse.nebula.snippets/.settings/org.eclipse.jdt.core.prefs b/examples/org.eclipse.nebula.snippets/.settings/org.eclipse.jdt.core.prefs
index 27656b34c..9d6b57d79 100644
--- a/examples/org.eclipse.nebula.snippets/.settings/org.eclipse.jdt.core.prefs
+++ b/examples/org.eclipse.nebula.snippets/.settings/org.eclipse.jdt.core.prefs
@@ -1,7 +1,7 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
-org.eclipse.jdt.core.compiler.compliance=11
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.8
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
+org.eclipse.jdt.core.compiler.compliance=11
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/compositetable/SnippetCompositeTableDataBinding.java b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/compositetable/SnippetCompositeTableDataBinding.java
index a2fa188ff..e4c1d23ad 100644
--- a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/compositetable/SnippetCompositeTableDataBinding.java
+++ b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/compositetable/SnippetCompositeTableDataBinding.java
@@ -1,558 +1,558 @@
-package org.eclipse.nebula.snippets.compositetable;
-
-/*
- * Text example snippet: verify input (only allow digits)
- *
- * For a list of all SWT example snippets see
- * http://www.eclipse.org/swt/snippets/
- */
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.databinding.Binding;
-import org.eclipse.core.databinding.DataBindingContext;
-import org.eclipse.core.databinding.UpdateValueStrategy;
-import org.eclipse.core.databinding.beans.BeansObservables;
-import org.eclipse.core.databinding.beans.PojoObservables;
-import org.eclipse.core.databinding.observable.Realm;
-import org.eclipse.jface.databinding.swt.SWTObservables;
-import org.eclipse.jface.dialogs.TitleAreaDialog;
-import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.window.Window;
-import org.eclipse.nebula.widgets.compositetable.CompositeTable;
-import org.eclipse.nebula.widgets.compositetable.IRowContentProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-@SuppressWarnings("deprecation")
-public class SnippetCompositeTableDataBinding {
-
- /**
- * A Model class representing a hero
- *
- * @author sylvere.richard@sogeti.lu
- *
- */
- private static class Hero {
- private String name;
-
- private String firstname;
-
- public Hero() {
- }
-
- /**
- * copy constructor
- *
- * @param hero
- */
- public Hero(Hero hero) {
- this.firstname = hero.firstname;
- this.name = hero.name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setFirstname(String firstname) {
- this.firstname = firstname;
- }
-
- }
-
- /**
- * A model class containing a list of persons.
- *
- * @author sylvere.richard@sogeti.lu
- *
- */
- private static class MyModel {
- private final PropertyChangeSupport support = new PropertyChangeSupport(this);
-
- /**
- * @param listener
- */
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- support.addPropertyChangeListener(listener);
- }
-
- /**
- * @param propertyName
- * @param listener
- */
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- support.addPropertyChangeListener(propertyName, listener);
- }
-
- /**
- * @param listener
- */
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- support.removePropertyChangeListener(listener);
- }
-
- /**
- * @param propertyName
- * @param listener
- */
- public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- support.removePropertyChangeListener(propertyName, listener);
- }
-
- /**
- *
- * @param propertyName
- * @param oldValue
- * @param newValue
- */
- protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
- support.firePropertyChange(propertyName, oldValue, newValue);
- }
-
- private final List heroes = new LinkedList();
-
- public List getHeroes() {
- return heroes;
- }
-
- /**
- * Returns how many heroes the model contains.
- *
- * @return
- */
- public int getHeroesListSize() {
- return getHeroes().size();
- }
-
- /**
- * Adds a new hero to the list of people
- *
- * @param p
- */
- public void addHero(Hero p) {
- getHeroes().add(p);
- // notify whenever the hero list size changes
- support.firePropertyChange("heroesListSize", getHeroesListSize() - 1, getHeroesListSize());
- }
-
- public void removePerson(Hero person) {
- getHeroes().remove(person);
- // notify whenever the hero list size changes
- support.firePropertyChange("heroesListSize", getHeroesListSize() + 1, getHeroesListSize());
- }
- }
-
- /**
- * contains size of table columns
- */
- private static int[] cols = new int[] { 0, 30, 60, 75 };
-
- /**
- * Header of my table
- *
- * @author sylvere.richard@sogeti.lu
- *
- */
- private static class Header extends Composite {
- public Header(Composite parent, int style) {
- super(parent, style);
-
- doLayout();
- }
-
- private void doLayout() {
- setLayout(new FormLayout());
- Label lblName = new Label(this, SWT.CENTER);
- lblName.setText("Name");
-
- int index = 0;
- FormData data = new FormData();
- data.left = new FormAttachment(cols[index], 100, 5);
- data.right = new FormAttachment(cols[index + 1], 100, 0);
- data.top = new FormAttachment(0, 100, 5);
-
- lblName.setLayoutData(data);
- index++;
-
- Label lblFirstname = new Label(this, SWT.CENTER);
- lblFirstname.setText("Firstname");
-
- data = new FormData();
- data.left = new FormAttachment(cols[index], 100, 5);
- data.right = new FormAttachment(cols[index + 1], 100, 0);
- data.top = new FormAttachment(0, 100, 5);
-
- lblFirstname.setLayoutData(data);
- index++;
-
- Label lblAction = new Label(this, SWT.CENTER);
- lblAction.setText("Action");
-
- data = new FormData();
- data.left = new FormAttachment(cols[index], 100, 5);
- data.right = new FormAttachment(cols[index + 1], 100, 0);
- data.top = new FormAttachment(0, 100, 5);
-
- lblAction.setLayoutData(data);
-
- }
- }
-
- /**
- * A row of my table
- *
- * @author sylvere.richard@sogeti.lu
- *
- */
- private static class Row extends Composite {
-
- private DataBindingContext dbcRow;
-
- private Text lastname;
-
- private Text firstname;
-
- private Button action;
-
- public Row(Composite parent, int style) {
- super(parent, style);
- doLayout();
-
- addListener(SWT.Dispose, e -> {
- // in case the row is bound, we unbind it
- unbind();
- });
- }
-
- private void doLayout() {
- lastname = new Text(this, SWT.BORDER);
- firstname = new Text(this, SWT.BORDER);
- action = new Button(this, SWT.NONE);
- action.setText("Delete");
-
- setLayout(new FormLayout());
-
- // column index
- int index = 0;
- FormData data = new FormData();
- data.top = new FormAttachment(0, 100, 5);
- data.left = new FormAttachment(cols[index], 100, 5);
- data.right = new FormAttachment(cols[index + 1], 100, 0);
- lastname.setLayoutData(data);
- index++;
-
- data = new FormData();
- data.top = new FormAttachment(0, 100, 5);
- data.left = new FormAttachment(cols[index], 100, 5);
- data.right = new FormAttachment(cols[index + 1], 100, 0);
- firstname.setLayoutData(data);
- index++;
-
- data = new FormData();
- data.top = new FormAttachment(0, 100, 5);
- data.left = new FormAttachment(cols[index], 100, 5);
- data.right = new FormAttachment(cols[index + 1], 100, 0);
- action.setLayoutData(data);
- index++;
- }
-
- /**
- * Unbind the current row. Be sure to call this method before any call
- * to bind.
- */
- public void unbind() {
- if (dbcRow != null) {
- dbcRow.dispose();
- dbcRow = null;
- }
- }
-
- /**
- * Binds the current ro with the given Person
- *
- * @param p
- * The Person bean to bind.
- */
- public void bind(Hero p) {
- dbcRow = new DataBindingContext();
- Binding b = dbcRow.bindValue(SWTObservables.observeText(lastname, SWT.Modify), PojoObservables.observeValue(p, "name"), null, null);
- b = dbcRow.bindValue(SWTObservables.observeText(firstname, SWT.Modify), PojoObservables.observeValue(p, "firstname"), null, null);
- }
-
- }
-
- /**
- * A simple dialog to create a new person.
- *
- * @author sylvere.richard@sogeti.lu
- *
- */
- private static final class PersonTitleAreaDialog extends TitleAreaDialog {
- private Text txName;
- private Text txFirstname;
- private final Hero hero = new Hero();
-
- private DataBindingContext dbc = new DataBindingContext();
-
- private PersonTitleAreaDialog(Shell parentShell) {
- super(parentShell);
-
- }
-
- @Override
- protected Control createContents(Composite parent) {
- Control ret = super.createContents(parent);
- setTitle("Add new Hero");
- setMessage("Enter here your favorite hero :");
- return ret;
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
-
- Label lbName = new Label(composite, SWT.NONE);
- lbName.setText("Name :");
-
- txName = new Text(composite, SWT.BORDER);
-
- Label lbFirstname = new Label(composite, SWT.NONE);
- lbFirstname.setText("Firstname :");
-
- txFirstname = new Text(composite, SWT.BORDER);
-
- GridLayoutFactory.fillDefaults().generateLayout(composite);
-
- // binding
- Binding b = dbc.bindValue(SWTObservables.observeText(txFirstname, SWT.FocusOut), PojoObservables.observeValue(hero, "firstname"), null, null);
- b = dbc.bindValue(SWTObservables.observeText(txName, SWT.FocusOut), PojoObservables.observeValue(hero, "name"), null, null);
- return composite;
- }
-
- @Override
- public int open() {
- return super.open();
- }
-
- @Override
- public boolean close() {
- dbc.dispose();
- return super.close();
- }
-
- public Hero getHero() {
- // returns a copy
- return new Hero(hero);
- }
- }
-
- /**
- * This composite contains the CompositeTable and a button to add new rows
- *
- * @author sylvere.richard@sogeti.lu
- *
- */
- private static class MainCompo extends Composite {
-
- private CompositeTable table;
- private Button addNew;
- private final MyModel model = new MyModel();
-
- private final DataBindingContext dbc = new DataBindingContext();
-
- public MainCompo(Composite parent, int style) {
- super(parent, style);
-
- doLayout();
- }
-
- private void doLayout() {
- setLayout(new FormLayout());
-
- table = new CompositeTable(this, SWT.NULL);
- table.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
- new Header(table, SWT.NULL);
- new Row(table, SWT.NULL);
-
- addNew = new Button(this, SWT.NONE);
- addNew.setText("Add new Hero");
- addNew.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- PersonTitleAreaDialog d = new PersonTitleAreaDialog(getShell());
- d.open();
- final int result = d.getReturnCode();
- if (result == Window.OK) {
- Hero p = d.getHero();
- getModel().addHero(p);
- }
- }
- });
-
- FormData data = new FormData();
- data.left = new FormAttachment(0, 100, 5);
- data.right = new FormAttachment(100, 100, -5);
- data.top = new FormAttachment(0, 100, 5);
- data.bottom = new FormAttachment(addNew, -5, SWT.TOP);
- table.setLayoutData(data);
- table.setRunTime(true);
-
- data = new FormData();
- data.right = new FormAttachment(100, 100, -5);
- data.bottom = new FormAttachment(100, 100, -5);
- addNew.setLayoutData(data);
- }
-
- /**
- * In this method, we bind the heroes list size with the
- * compositetable's property 'numRowsInCollection'.
- *
- */
- public void binding() {
-
- // table.setNumRowsInCollection(model.getPeople().size());
- Binding b = dbc.bindValue(PojoObservables.observeValue(table, "numRowsInCollection"), BeansObservables.observeValue(model, "heroesListSize"), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), new UpdateValueStrategy());
-
- table.addRowContentProvider(new IRowContentProvider() {
-
- /**
- * Keeps a reference of each delete listener for each row, so we can
- * remove a listener when compositetable associate the row to another hero.
- */
- private Map map = new HashMap();
-
- /**
- * * Since the compositetable has its own pool of Row elements,
- * we must first ensure to unbind if necessary the row before
- * rebinding it with the Hero given as parameter.
- *
- * In the same way, we remove and add selectionlistener.
- */
- public void refresh(CompositeTable sender, int currentObjectOffset, Control rowControl) {
- Row row = (Row) rowControl;
- final Hero p = model.getHeroes().get(currentObjectOffset);
-
- // unbind previous hero
- row.unbind();
-
- // remove previous listener if nay
- if (map.get(row) != null) {
- row.action.removeSelectionListener(map.get(row));
- }
-
- // bind the new hero
- row.bind(p);
-
- // add selectionlistener
- SelectionListener listen = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- getModel().removePerson(p);
- }
- };
- row.action.addSelectionListener(listen);
- // keep a reference to this listener to be able to remove it
- // during the next refresh
- map.put(row, listen);
- }
- });
- }
-
- public MyModel getModel() {
- return model;
- }
- }
-
- /**
- * Main entry point.
- *
- * @param args
- */
- public static void main(String[] args) {
- final Display display = new Display();
-
- Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() {
- public void run() {
- Shell shell = new Shell(display);
- shell.setText("Jules Verne's Heroes");
- shell.setBounds(0, 0, 400, 200);
- shell.setLayout(new FormLayout());
-
- // creation of the composite containing the table
- MainCompo compo = new MainCompo(shell, SWT.NONE);
-
- // position it on the shell
- FormData data = new FormData();
- data.left = new FormAttachment(0, 100, 5);
- data.right = new FormAttachment(100, 100, -5);
- data.top = new FormAttachment(0, 100, 5);
- data.bottom = new FormAttachment(100, 100, -5);
- compo.setLayoutData(data);
-
- // add some data to the model
- populateModel(compo.getModel());
-
- // binding the UI with the model
- compo.binding();
-
- // start the UI
- shell.open();
-
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- }
- });
- display.dispose();
- }
-
- /**
- * populates the given model with some data
- *
- * @param md
- */
- private static void populateModel(MyModel md) {
- Hero p = new Hero();
- p.setName("Fogg");
- p.setFirstname("Phileas");
- md.getHeroes().add(p);
-
- p = new Hero();
- p.setName("Aronnax");
- p.setFirstname("Pierre");
- md.getHeroes().add(p);
-
- p = new Hero();
- p.setName("Strogoff");
- p.setFirstname("Michel");
- md.getHeroes().add(p);
-
- p = new Hero();
- p.setName("Nemo");
- p.setFirstname("Captain");
- md.getHeroes().add(p);
-
- p = new Hero();
- p.setName("Barbicane");
- p.setFirstname("Impey");
- md.getHeroes().add(p);
- }
-}
+package org.eclipse.nebula.snippets.compositetable;
+
+/*
+ * Text example snippet: verify input (only allow digits)
+ *
+ * For a list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ */
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.databinding.Binding;
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.UpdateValueStrategy;
+import org.eclipse.core.databinding.beans.BeansObservables;
+import org.eclipse.core.databinding.beans.PojoObservables;
+import org.eclipse.core.databinding.observable.Realm;
+import org.eclipse.jface.databinding.swt.SWTObservables;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.window.Window;
+import org.eclipse.nebula.widgets.compositetable.CompositeTable;
+import org.eclipse.nebula.widgets.compositetable.IRowContentProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+@SuppressWarnings("deprecation")
+public class SnippetCompositeTableDataBinding {
+
+ /**
+ * A Model class representing a hero
+ *
+ * @author sylvere.richard@sogeti.lu
+ *
+ */
+ private static class Hero {
+ private String name;
+
+ private String firstname;
+
+ public Hero() {
+ }
+
+ /**
+ * copy constructor
+ *
+ * @param hero
+ */
+ public Hero(Hero hero) {
+ this.firstname = hero.firstname;
+ this.name = hero.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setFirstname(String firstname) {
+ this.firstname = firstname;
+ }
+
+ }
+
+ /**
+ * A model class containing a list of persons.
+ *
+ * @author sylvere.richard@sogeti.lu
+ *
+ */
+ private static class MyModel {
+ private final PropertyChangeSupport support = new PropertyChangeSupport(this);
+
+ /**
+ * @param listener
+ */
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ support.addPropertyChangeListener(listener);
+ }
+
+ /**
+ * @param propertyName
+ * @param listener
+ */
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ support.addPropertyChangeListener(propertyName, listener);
+ }
+
+ /**
+ * @param listener
+ */
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ support.removePropertyChangeListener(listener);
+ }
+
+ /**
+ * @param propertyName
+ * @param listener
+ */
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ support.removePropertyChangeListener(propertyName, listener);
+ }
+
+ /**
+ *
+ * @param propertyName
+ * @param oldValue
+ * @param newValue
+ */
+ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ support.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+ private final List heroes = new LinkedList();
+
+ public List getHeroes() {
+ return heroes;
+ }
+
+ /**
+ * Returns how many heroes the model contains.
+ *
+ * @return
+ */
+ public int getHeroesListSize() {
+ return getHeroes().size();
+ }
+
+ /**
+ * Adds a new hero to the list of people
+ *
+ * @param p
+ */
+ public void addHero(Hero p) {
+ getHeroes().add(p);
+ // notify whenever the hero list size changes
+ support.firePropertyChange("heroesListSize", getHeroesListSize() - 1, getHeroesListSize());
+ }
+
+ public void removePerson(Hero person) {
+ getHeroes().remove(person);
+ // notify whenever the hero list size changes
+ support.firePropertyChange("heroesListSize", getHeroesListSize() + 1, getHeroesListSize());
+ }
+ }
+
+ /**
+ * contains size of table columns
+ */
+ private static int[] cols = new int[] { 0, 30, 60, 75 };
+
+ /**
+ * Header of my table
+ *
+ * @author sylvere.richard@sogeti.lu
+ *
+ */
+ private static class Header extends Composite {
+ public Header(Composite parent, int style) {
+ super(parent, style);
+
+ doLayout();
+ }
+
+ private void doLayout() {
+ setLayout(new FormLayout());
+ Label lblName = new Label(this, SWT.CENTER);
+ lblName.setText("Name");
+
+ int index = 0;
+ FormData data = new FormData();
+ data.left = new FormAttachment(cols[index], 100, 5);
+ data.right = new FormAttachment(cols[index + 1], 100, 0);
+ data.top = new FormAttachment(0, 100, 5);
+
+ lblName.setLayoutData(data);
+ index++;
+
+ Label lblFirstname = new Label(this, SWT.CENTER);
+ lblFirstname.setText("Firstname");
+
+ data = new FormData();
+ data.left = new FormAttachment(cols[index], 100, 5);
+ data.right = new FormAttachment(cols[index + 1], 100, 0);
+ data.top = new FormAttachment(0, 100, 5);
+
+ lblFirstname.setLayoutData(data);
+ index++;
+
+ Label lblAction = new Label(this, SWT.CENTER);
+ lblAction.setText("Action");
+
+ data = new FormData();
+ data.left = new FormAttachment(cols[index], 100, 5);
+ data.right = new FormAttachment(cols[index + 1], 100, 0);
+ data.top = new FormAttachment(0, 100, 5);
+
+ lblAction.setLayoutData(data);
+
+ }
+ }
+
+ /**
+ * A row of my table
+ *
+ * @author sylvere.richard@sogeti.lu
+ *
+ */
+ private static class Row extends Composite {
+
+ private DataBindingContext dbcRow;
+
+ private Text lastname;
+
+ private Text firstname;
+
+ private Button action;
+
+ public Row(Composite parent, int style) {
+ super(parent, style);
+ doLayout();
+
+ addListener(SWT.Dispose, e -> {
+ // in case the row is bound, we unbind it
+ unbind();
+ });
+ }
+
+ private void doLayout() {
+ lastname = new Text(this, SWT.BORDER);
+ firstname = new Text(this, SWT.BORDER);
+ action = new Button(this, SWT.NONE);
+ action.setText("Delete");
+
+ setLayout(new FormLayout());
+
+ // column index
+ int index = 0;
+ FormData data = new FormData();
+ data.top = new FormAttachment(0, 100, 5);
+ data.left = new FormAttachment(cols[index], 100, 5);
+ data.right = new FormAttachment(cols[index + 1], 100, 0);
+ lastname.setLayoutData(data);
+ index++;
+
+ data = new FormData();
+ data.top = new FormAttachment(0, 100, 5);
+ data.left = new FormAttachment(cols[index], 100, 5);
+ data.right = new FormAttachment(cols[index + 1], 100, 0);
+ firstname.setLayoutData(data);
+ index++;
+
+ data = new FormData();
+ data.top = new FormAttachment(0, 100, 5);
+ data.left = new FormAttachment(cols[index], 100, 5);
+ data.right = new FormAttachment(cols[index + 1], 100, 0);
+ action.setLayoutData(data);
+ index++;
+ }
+
+ /**
+ * Unbind the current row. Be sure to call this method before any call
+ * to bind.
+ */
+ public void unbind() {
+ if (dbcRow != null) {
+ dbcRow.dispose();
+ dbcRow = null;
+ }
+ }
+
+ /**
+ * Binds the current ro with the given Person
+ *
+ * @param p
+ * The Person bean to bind.
+ */
+ public void bind(Hero p) {
+ dbcRow = new DataBindingContext();
+ Binding b = dbcRow.bindValue(SWTObservables.observeText(lastname, SWT.Modify), PojoObservables.observeValue(p, "name"), null, null);
+ b = dbcRow.bindValue(SWTObservables.observeText(firstname, SWT.Modify), PojoObservables.observeValue(p, "firstname"), null, null);
+ }
+
+ }
+
+ /**
+ * A simple dialog to create a new person.
+ *
+ * @author sylvere.richard@sogeti.lu
+ *
+ */
+ private static final class PersonTitleAreaDialog extends TitleAreaDialog {
+ private Text txName;
+ private Text txFirstname;
+ private final Hero hero = new Hero();
+
+ private DataBindingContext dbc = new DataBindingContext();
+
+ private PersonTitleAreaDialog(Shell parentShell) {
+ super(parentShell);
+
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ Control ret = super.createContents(parent);
+ setTitle("Add new Hero");
+ setMessage("Enter here your favorite hero :");
+ return ret;
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+
+ Label lbName = new Label(composite, SWT.NONE);
+ lbName.setText("Name :");
+
+ txName = new Text(composite, SWT.BORDER);
+
+ Label lbFirstname = new Label(composite, SWT.NONE);
+ lbFirstname.setText("Firstname :");
+
+ txFirstname = new Text(composite, SWT.BORDER);
+
+ GridLayoutFactory.fillDefaults().generateLayout(composite);
+
+ // binding
+ Binding b = dbc.bindValue(SWTObservables.observeText(txFirstname, SWT.FocusOut), PojoObservables.observeValue(hero, "firstname"), null, null);
+ b = dbc.bindValue(SWTObservables.observeText(txName, SWT.FocusOut), PojoObservables.observeValue(hero, "name"), null, null);
+ return composite;
+ }
+
+ @Override
+ public int open() {
+ return super.open();
+ }
+
+ @Override
+ public boolean close() {
+ dbc.dispose();
+ return super.close();
+ }
+
+ public Hero getHero() {
+ // returns a copy
+ return new Hero(hero);
+ }
+ }
+
+ /**
+ * This composite contains the CompositeTable and a button to add new rows
+ *
+ * @author sylvere.richard@sogeti.lu
+ *
+ */
+ private static class MainCompo extends Composite {
+
+ private CompositeTable table;
+ private Button addNew;
+ private final MyModel model = new MyModel();
+
+ private final DataBindingContext dbc = new DataBindingContext();
+
+ public MainCompo(Composite parent, int style) {
+ super(parent, style);
+
+ doLayout();
+ }
+
+ private void doLayout() {
+ setLayout(new FormLayout());
+
+ table = new CompositeTable(this, SWT.NULL);
+ table.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
+ new Header(table, SWT.NULL);
+ new Row(table, SWT.NULL);
+
+ addNew = new Button(this, SWT.NONE);
+ addNew.setText("Add new Hero");
+ addNew.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ PersonTitleAreaDialog d = new PersonTitleAreaDialog(getShell());
+ d.open();
+ final int result = d.getReturnCode();
+ if (result == Window.OK) {
+ Hero p = d.getHero();
+ getModel().addHero(p);
+ }
+ }
+ });
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 100, 5);
+ data.right = new FormAttachment(100, 100, -5);
+ data.top = new FormAttachment(0, 100, 5);
+ data.bottom = new FormAttachment(addNew, -5, SWT.TOP);
+ table.setLayoutData(data);
+ table.setRunTime(true);
+
+ data = new FormData();
+ data.right = new FormAttachment(100, 100, -5);
+ data.bottom = new FormAttachment(100, 100, -5);
+ addNew.setLayoutData(data);
+ }
+
+ /**
+ * In this method, we bind the heroes list size with the
+ * compositetable's property 'numRowsInCollection'.
+ *
+ */
+ public void binding() {
+
+ // table.setNumRowsInCollection(model.getPeople().size());
+ Binding b = dbc.bindValue(PojoObservables.observeValue(table, "numRowsInCollection"), BeansObservables.observeValue(model, "heroesListSize"), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), new UpdateValueStrategy());
+
+ table.addRowContentProvider(new IRowContentProvider() {
+
+ /**
+ * Keeps a reference of each delete listener for each row, so we can
+ * remove a listener when compositetable associate the row to another hero.
+ */
+ private Map map = new HashMap();
+
+ /**
+ * * Since the compositetable has its own pool of Row elements,
+ * we must first ensure to unbind if necessary the row before
+ * rebinding it with the Hero given as parameter.
+ *
+ * In the same way, we remove and add selectionlistener.
+ */
+ public void refresh(CompositeTable sender, int currentObjectOffset, Control rowControl) {
+ Row row = (Row) rowControl;
+ final Hero p = model.getHeroes().get(currentObjectOffset);
+
+ // unbind previous hero
+ row.unbind();
+
+ // remove previous listener if nay
+ if (map.get(row) != null) {
+ row.action.removeSelectionListener(map.get(row));
+ }
+
+ // bind the new hero
+ row.bind(p);
+
+ // add selectionlistener
+ SelectionListener listen = new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ getModel().removePerson(p);
+ }
+ };
+ row.action.addSelectionListener(listen);
+ // keep a reference to this listener to be able to remove it
+ // during the next refresh
+ map.put(row, listen);
+ }
+ });
+ }
+
+ public MyModel getModel() {
+ return model;
+ }
+ }
+
+ /**
+ * Main entry point.
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ final Display display = new Display();
+
+ Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() {
+ public void run() {
+ Shell shell = new Shell(display);
+ shell.setText("Jules Verne's Heroes");
+ shell.setBounds(0, 0, 400, 200);
+ shell.setLayout(new FormLayout());
+
+ // creation of the composite containing the table
+ MainCompo compo = new MainCompo(shell, SWT.NONE);
+
+ // position it on the shell
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 100, 5);
+ data.right = new FormAttachment(100, 100, -5);
+ data.top = new FormAttachment(0, 100, 5);
+ data.bottom = new FormAttachment(100, 100, -5);
+ compo.setLayoutData(data);
+
+ // add some data to the model
+ populateModel(compo.getModel());
+
+ // binding the UI with the model
+ compo.binding();
+
+ // start the UI
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ }
+ });
+ display.dispose();
+ }
+
+ /**
+ * populates the given model with some data
+ *
+ * @param md
+ */
+ private static void populateModel(MyModel md) {
+ Hero p = new Hero();
+ p.setName("Fogg");
+ p.setFirstname("Phileas");
+ md.getHeroes().add(p);
+
+ p = new Hero();
+ p.setName("Aronnax");
+ p.setFirstname("Pierre");
+ md.getHeroes().add(p);
+
+ p = new Hero();
+ p.setName("Strogoff");
+ p.setFirstname("Michel");
+ md.getHeroes().add(p);
+
+ p = new Hero();
+ p.setName("Nemo");
+ p.setFirstname("Captain");
+ md.getHeroes().add(p);
+
+ p = new Hero();
+ p.setName("Barbicane");
+ p.setFirstname("Impey");
+ md.getHeroes().add(p);
+ }
+}
diff --git a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/gallery/SnippetHScroll.java b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/gallery/SnippetHScroll.java
index 6367200d2..a3892b802 100644
--- a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/gallery/SnippetHScroll.java
+++ b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/gallery/SnippetHScroll.java
@@ -1,89 +1,89 @@
-package org.eclipse.nebula.snippets.gallery;
-
-/*******************************************************************************
- * Copyright (c) 2006-2007 Nicolas Richeton.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors :
- * Nicolas Richeton (nicolas.richeton@gmail.com) - initial implementation
- *******************************************************************************/
-
-import org.eclipse.nebula.widgets.gallery.DefaultGalleryGroupRenderer;
-import org.eclipse.nebula.widgets.gallery.DefaultGalleryItemRenderer;
-import org.eclipse.nebula.widgets.gallery.Gallery;
-import org.eclipse.nebula.widgets.gallery.GalleryItem;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.program.Program;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * This widget displays a simple gallery with some content.
- * Scrolling is vertical.
- *
- *
- *
- * NOTE: THIS WIDGET AND ITS API ARE STILL UNDER DEVELOPMENT. THIS IS A
- * PRE-RELEASE ALPHA VERSION. USERS SHOULD EXPECT API CHANGES IN FUTURE
- * VERSIONS.
- *
- *
- * @author Nicolas Richeton (nicolas.richeton@gmail.com)
- */
-
-public class SnippetHScroll {
-
- public static void main(String[] args) {
- Display display = new Display();
- Image itemImage = new Image(display, Program
- .findProgram("jpg").getImageData()); //$NON-NLS-1$
-
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- Gallery gallery = new Gallery(shell, SWT.H_SCROLL | SWT.MULTI);
-
- // Renderers
- DefaultGalleryGroupRenderer gr = new DefaultGalleryGroupRenderer();
- gr.setMinMargin(10);
- gr.setItemHeight(56);
- gr.setItemWidth(72);
- gr.setAutoMargin(true);
- gallery.setGroupRenderer(gr);
-
- DefaultGalleryItemRenderer ir = new DefaultGalleryItemRenderer();
- gallery.setItemRenderer(ir);
-
- for (int g = 0; g < 2; g++) {
- GalleryItem group = new GalleryItem(gallery, SWT.NONE);
- group.setText("Really Long Group Name " + g); //$NON-NLS-1$
- group.setExpanded(true);
-
- for (int i = 0; i < 10; i++) {
- GalleryItem item = new GalleryItem(group, SWT.NONE);
- if (itemImage != null) {
- item.setImage(itemImage);
- }
- item.setText("Item " + i); //$NON-NLS-1$
- }
- }
-
- shell.pack();
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- if (itemImage != null)
- itemImage.dispose();
- display.dispose();
- }
-}
+package org.eclipse.nebula.snippets.gallery;
+
+/*******************************************************************************
+ * Copyright (c) 2006-2007 Nicolas Richeton.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors :
+ * Nicolas Richeton (nicolas.richeton@gmail.com) - initial implementation
+ *******************************************************************************/
+
+import org.eclipse.nebula.widgets.gallery.DefaultGalleryGroupRenderer;
+import org.eclipse.nebula.widgets.gallery.DefaultGalleryItemRenderer;
+import org.eclipse.nebula.widgets.gallery.Gallery;
+import org.eclipse.nebula.widgets.gallery.GalleryItem;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.program.Program;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * This widget displays a simple gallery with some content.
+ * Scrolling is vertical.
+ *
+ *
+ *
+ * NOTE: THIS WIDGET AND ITS API ARE STILL UNDER DEVELOPMENT. THIS IS A
+ * PRE-RELEASE ALPHA VERSION. USERS SHOULD EXPECT API CHANGES IN FUTURE
+ * VERSIONS.
+ *
+ *
+ * @author Nicolas Richeton (nicolas.richeton@gmail.com)
+ */
+
+public class SnippetHScroll {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Image itemImage = new Image(display, Program
+ .findProgram("jpg").getImageData()); //$NON-NLS-1$
+
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ Gallery gallery = new Gallery(shell, SWT.H_SCROLL | SWT.MULTI);
+
+ // Renderers
+ DefaultGalleryGroupRenderer gr = new DefaultGalleryGroupRenderer();
+ gr.setMinMargin(10);
+ gr.setItemHeight(56);
+ gr.setItemWidth(72);
+ gr.setAutoMargin(true);
+ gallery.setGroupRenderer(gr);
+
+ DefaultGalleryItemRenderer ir = new DefaultGalleryItemRenderer();
+ gallery.setItemRenderer(ir);
+
+ for (int g = 0; g < 2; g++) {
+ GalleryItem group = new GalleryItem(gallery, SWT.NONE);
+ group.setText("Really Long Group Name " + g); //$NON-NLS-1$
+ group.setExpanded(true);
+
+ for (int i = 0; i < 10; i++) {
+ GalleryItem item = new GalleryItem(group, SWT.NONE);
+ if (itemImage != null) {
+ item.setImage(itemImage);
+ }
+ item.setText("Item " + i); //$NON-NLS-1$
+ }
+ }
+
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+
+ if (itemImage != null)
+ itemImage.dispose();
+ display.dispose();
+ }
+}
diff --git a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/gallery/SnippetVScroll.java b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/gallery/SnippetVScroll.java
index 7bdc21a3f..71be56a5a 100644
--- a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/gallery/SnippetVScroll.java
+++ b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/gallery/SnippetVScroll.java
@@ -1,88 +1,88 @@
-package org.eclipse.nebula.snippets.gallery;
-
-/*******************************************************************************
- * Copyright (c) 2006-2007 Nicolas Richeton.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors :
- * Nicolas Richeton (nicolas.richeton@gmail.com) - initial implementation
- *******************************************************************************/
-
-
-import org.eclipse.nebula.widgets.gallery.DefaultGalleryGroupRenderer;
-import org.eclipse.nebula.widgets.gallery.DefaultGalleryItemRenderer;
-import org.eclipse.nebula.widgets.gallery.Gallery;
-import org.eclipse.nebula.widgets.gallery.GalleryItem;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.program.Program;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * This widget displays a simple gallery with some content. Scrolling is
- * vertical.
- *
- *
- * NOTE: THIS WIDGET AND ITS API ARE STILL UNDER DEVELOPMENT. THIS IS A
- * PRE-RELEASE ALPHA VERSION. USERS SHOULD EXPECT API CHANGES IN FUTURE
- * VERSIONS.
- *
- *
- * @author Nicolas Richeton (nicolas.richeton@gmail.com)
- */
-
-public class SnippetVScroll {
-
- public static void main(String[] args) {
- Display display = new Display();
- Image itemImage = new Image(display, Program.findProgram("jpg").getImageData()); //$NON-NLS-1$
-
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- Gallery gallery = new Gallery(shell, SWT.V_SCROLL | SWT.MULTI);
-
- // Renderers
- DefaultGalleryGroupRenderer gr = new DefaultGalleryGroupRenderer();
- gr.setMinMargin(10);
- gr.setItemHeight(56);
- gr.setItemWidth(72);
- gr.setAutoMargin(true);
- gallery.setGroupRenderer(gr);
-
- DefaultGalleryItemRenderer ir = new DefaultGalleryItemRenderer();
- gallery.setItemRenderer(ir);
-
- for (int g = 0; g < 2; g++) {
- GalleryItem group = new GalleryItem(gallery, SWT.NONE);
- group.setText("Really Long Group Name " + g); //$NON-NLS-1$
- group.setExpanded(true);
-
- for (int i = 0; i < 10; i++) {
- GalleryItem item = new GalleryItem(group, SWT.NONE);
- if (itemImage != null) {
- item.setImage(itemImage);
- }
- item.setText("Item " + i); //$NON-NLS-1$
- }
- }
-
- shell.pack();
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- if (itemImage != null)
- itemImage.dispose();
- display.dispose();
- }
-}
+package org.eclipse.nebula.snippets.gallery;
+
+/*******************************************************************************
+ * Copyright (c) 2006-2007 Nicolas Richeton.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors :
+ * Nicolas Richeton (nicolas.richeton@gmail.com) - initial implementation
+ *******************************************************************************/
+
+
+import org.eclipse.nebula.widgets.gallery.DefaultGalleryGroupRenderer;
+import org.eclipse.nebula.widgets.gallery.DefaultGalleryItemRenderer;
+import org.eclipse.nebula.widgets.gallery.Gallery;
+import org.eclipse.nebula.widgets.gallery.GalleryItem;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.program.Program;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * This widget displays a simple gallery with some content. Scrolling is
+ * vertical.
+ *
+ *
+ * NOTE: THIS WIDGET AND ITS API ARE STILL UNDER DEVELOPMENT. THIS IS A
+ * PRE-RELEASE ALPHA VERSION. USERS SHOULD EXPECT API CHANGES IN FUTURE
+ * VERSIONS.
+ *
+ *
+ * @author Nicolas Richeton (nicolas.richeton@gmail.com)
+ */
+
+public class SnippetVScroll {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Image itemImage = new Image(display, Program.findProgram("jpg").getImageData()); //$NON-NLS-1$
+
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ Gallery gallery = new Gallery(shell, SWT.V_SCROLL | SWT.MULTI);
+
+ // Renderers
+ DefaultGalleryGroupRenderer gr = new DefaultGalleryGroupRenderer();
+ gr.setMinMargin(10);
+ gr.setItemHeight(56);
+ gr.setItemWidth(72);
+ gr.setAutoMargin(true);
+ gallery.setGroupRenderer(gr);
+
+ DefaultGalleryItemRenderer ir = new DefaultGalleryItemRenderer();
+ gallery.setItemRenderer(ir);
+
+ for (int g = 0; g < 2; g++) {
+ GalleryItem group = new GalleryItem(gallery, SWT.NONE);
+ group.setText("Really Long Group Name " + g); //$NON-NLS-1$
+ group.setExpanded(true);
+
+ for (int i = 0; i < 10; i++) {
+ GalleryItem item = new GalleryItem(group, SWT.NONE);
+ if (itemImage != null) {
+ item.setImage(itemImage);
+ }
+ item.setText("Item " + i); //$NON-NLS-1$
+ }
+ }
+
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+
+ if (itemImage != null)
+ itemImage.dispose();
+ display.dispose();
+ }
+}
diff --git a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/GridSnippet10.java b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/GridSnippet10.java
index 13c2f7957..a8396213d 100644
--- a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/GridSnippet10.java
+++ b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/GridSnippet10.java
@@ -1,79 +1,79 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.nebula.snippets.grid;
-
-
-import org.eclipse.nebula.widgets.grid.Grid;
-import org.eclipse.nebula.widgets.grid.GridColumn;
-import org.eclipse.nebula.widgets.grid.GridItem;
-import org.eclipse.nebula.widgets.grid.Win7RendererSupport;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/*
- * Create a simple grid with Win7 column header rendering
- *
- * For a list of all Nebula Grid example snippets see
- * http://www.eclipse.org/nebula/widgets/grid/snippets.php
- */
-public class GridSnippet10 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- shell.setLayout(new FillLayout());
-
- Grid grid = new Grid(shell,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- grid.setHeaderVisible(true);
- GridColumn column = new GridColumn(grid,SWT.NONE);
- column.setTree(true);
- column.setText("Column 1");
- column.setWidth(100);
- GridColumn column2 = new GridColumn(grid,SWT.NONE);
- column2.setTree(true);
- column2.setText("Column 1");
- column2.setWidth(100);
- GridColumn column3 = new GridColumn(grid,SWT.NONE);
- column3.setTree(true);
- column3.setText("Column 3");
- column3.setWidth(100);
-
- GridItem item1 = new GridItem(grid,SWT.NONE);
- item1.setText(0,"Root Item1");
- item1.setText(1,"Root Item2");
- item1.setText(2,"Root Item3");
- GridItem item2 = new GridItem(item1,SWT.NONE);
- item2.setText(0,"Second item1");
- item2.setText(1,"Second item2");
- item2.setText(2,"Second item3");
- GridItem item3 = new GridItem(item2,SWT.NONE);
- item3.setText(0,"Third Item1");
- item3.setText(1,"Third Item2");
- item3.setText(2,"Third Item3");
-
- grid.setCellSelectionEnabled(true);
-
- //add the "win7" column header rendering
- Win7RendererSupport.create(grid).decorate();
-
- shell.setSize(200,200);
- shell.open ();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.nebula.snippets.grid;
+
+
+import org.eclipse.nebula.widgets.grid.Grid;
+import org.eclipse.nebula.widgets.grid.GridColumn;
+import org.eclipse.nebula.widgets.grid.GridItem;
+import org.eclipse.nebula.widgets.grid.Win7RendererSupport;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/*
+ * Create a simple grid with Win7 column header rendering
+ *
+ * For a list of all Nebula Grid example snippets see
+ * http://www.eclipse.org/nebula/widgets/grid/snippets.php
+ */
+public class GridSnippet10 {
+
+public static void main (String [] args) {
+ Display display = new Display ();
+ Shell shell = new Shell (display);
+ shell.setLayout(new FillLayout());
+
+ Grid grid = new Grid(shell,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ grid.setHeaderVisible(true);
+ GridColumn column = new GridColumn(grid,SWT.NONE);
+ column.setTree(true);
+ column.setText("Column 1");
+ column.setWidth(100);
+ GridColumn column2 = new GridColumn(grid,SWT.NONE);
+ column2.setTree(true);
+ column2.setText("Column 1");
+ column2.setWidth(100);
+ GridColumn column3 = new GridColumn(grid,SWT.NONE);
+ column3.setTree(true);
+ column3.setText("Column 3");
+ column3.setWidth(100);
+
+ GridItem item1 = new GridItem(grid,SWT.NONE);
+ item1.setText(0,"Root Item1");
+ item1.setText(1,"Root Item2");
+ item1.setText(2,"Root Item3");
+ GridItem item2 = new GridItem(item1,SWT.NONE);
+ item2.setText(0,"Second item1");
+ item2.setText(1,"Second item2");
+ item2.setText(2,"Second item3");
+ GridItem item3 = new GridItem(item2,SWT.NONE);
+ item3.setText(0,"Third Item1");
+ item3.setText(1,"Third Item2");
+ item3.setText(2,"Third Item3");
+
+ grid.setCellSelectionEnabled(true);
+
+ //add the "win7" column header rendering
+ Win7RendererSupport.create(grid).decorate();
+
+ shell.setSize(200,200);
+ shell.open ();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+}
}
\ No newline at end of file
diff --git a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/GridSnippet11.java b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/GridSnippet11.java
index fdab6912a..f8f12a4bc 100644
--- a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/GridSnippet11.java
+++ b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/GridSnippet11.java
@@ -1,81 +1,81 @@
-/*******************************************************************************
- * Copyright (c) 2019 Laurent CARON.
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors: Laurent CARON (laurent.caron@gmail.com) - initial API and
- * implementation
- *******************************************************************************/
-
-package org.eclipse.nebula.snippets.grid;
-
-import org.eclipse.nebula.widgets.grid.Grid;
-import org.eclipse.nebula.widgets.grid.GridColumn;
-import org.eclipse.nebula.widgets.grid.GridItem;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * This snippet show custom header font
- */
-public class GridSnippet11 {
-
- public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
-
- Grid grid = new Grid(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- grid.setHeaderVisible(true);
- grid.setCellSelectionEnabled(true);
- grid.setRowHeaderVisible(true);
-
- Font[] fonts = new Font[4];
- fonts[0] = new Font(display, "Consolas", 11, SWT.NONE);
- fonts[1] = new Font(display, "Arial", 12, SWT.ITALIC);
- fonts[2] = new Font(display, "Calibri", 10, SWT.BOLD);
- fonts[3] = new Font(display, "Courier New", 13, SWT.BOLD | SWT.ITALIC);
-
- int fontIndex = 0;
- for (int colCount = 0; colCount < 4; colCount++) {
- GridColumn column = new GridColumn(grid, SWT.NONE);
- column.setText("Column " + (colCount + 1));
- column.setWidth(100);
- for (int rowCount = 0; rowCount < 50; rowCount++) {
- final GridItem item;
- if (colCount == 0) {
- item = new GridItem(grid, SWT.NONE);
- item.setHeaderFont(fonts[fontIndex % 4]);
- fontIndex++;
- } else {
- item = grid.getItem(rowCount);
- }
- item.setText(colCount, (rowCount + 1) + "." + (colCount + 1));
- }
- }
-
- // Need to call it after items has been created, because the size has to be recomputed.
- grid.setRowHeaderVisible(true);
-
-
- shell.setSize(500, 500);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- for (Font f : fonts) {
- f.dispose();
- }
-
- display.dispose();
- }
+/*******************************************************************************
+ * Copyright (c) 2019 Laurent CARON.
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors: Laurent CARON (laurent.caron@gmail.com) - initial API and
+ * implementation
+ *******************************************************************************/
+
+package org.eclipse.nebula.snippets.grid;
+
+import org.eclipse.nebula.widgets.grid.Grid;
+import org.eclipse.nebula.widgets.grid.GridColumn;
+import org.eclipse.nebula.widgets.grid.GridItem;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * This snippet show custom header font
+ */
+public class GridSnippet11 {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+
+ Grid grid = new Grid(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ grid.setHeaderVisible(true);
+ grid.setCellSelectionEnabled(true);
+ grid.setRowHeaderVisible(true);
+
+ Font[] fonts = new Font[4];
+ fonts[0] = new Font(display, "Consolas", 11, SWT.NONE);
+ fonts[1] = new Font(display, "Arial", 12, SWT.ITALIC);
+ fonts[2] = new Font(display, "Calibri", 10, SWT.BOLD);
+ fonts[3] = new Font(display, "Courier New", 13, SWT.BOLD | SWT.ITALIC);
+
+ int fontIndex = 0;
+ for (int colCount = 0; colCount < 4; colCount++) {
+ GridColumn column = new GridColumn(grid, SWT.NONE);
+ column.setText("Column " + (colCount + 1));
+ column.setWidth(100);
+ for (int rowCount = 0; rowCount < 50; rowCount++) {
+ final GridItem item;
+ if (colCount == 0) {
+ item = new GridItem(grid, SWT.NONE);
+ item.setHeaderFont(fonts[fontIndex % 4]);
+ fontIndex++;
+ } else {
+ item = grid.getItem(rowCount);
+ }
+ item.setText(colCount, (rowCount + 1) + "." + (colCount + 1));
+ }
+ }
+
+ // Need to call it after items has been created, because the size has to be recomputed.
+ grid.setRowHeaderVisible(true);
+
+
+ shell.setSize(500, 500);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+
+ for (Font f : fonts) {
+ f.dispose();
+ }
+
+ display.dispose();
+ }
}
\ No newline at end of file
diff --git a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/TestBug351227.java b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/TestBug351227.java
index b047454dc..82e646ac2 100644
--- a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/TestBug351227.java
+++ b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/TestBug351227.java
@@ -1,46 +1,46 @@
-package org.eclipse.nebula.snippets.grid;
-
-import org.eclipse.nebula.widgets.grid.Grid;
-import org.eclipse.nebula.widgets.grid.GridColumn;
-import org.eclipse.nebula.widgets.grid.GridItem;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-public class TestBug351227 {
-
- public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
-
- Grid grid = new Grid(shell, SWT.BORDER | SWT.V_SCROLL);
- grid.setHeaderVisible(true);
- grid.setCellSelectionEnabled(true);
-
- for (int colCount = 0; colCount < 4; colCount++) {
- GridColumn column = new GridColumn(grid, SWT.NONE);
- column.setText("Column " + (colCount + 1));
- column.setWidth(100);
- for (int rowCount = 0; rowCount < 50; rowCount++) {
- final GridItem item;
- if (colCount == 0) {
- item = new GridItem(grid, SWT.NONE);
- } else {
- item = grid.getItem(rowCount);
- }
- item.setText(colCount, (rowCount + 1) + "." + (colCount + 1));
- }
- }
-
-
- shell.setSize(500, 500);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
+package org.eclipse.nebula.snippets.grid;
+
+import org.eclipse.nebula.widgets.grid.Grid;
+import org.eclipse.nebula.widgets.grid.GridColumn;
+import org.eclipse.nebula.widgets.grid.GridItem;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class TestBug351227 {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+
+ Grid grid = new Grid(shell, SWT.BORDER | SWT.V_SCROLL);
+ grid.setHeaderVisible(true);
+ grid.setCellSelectionEnabled(true);
+
+ for (int colCount = 0; colCount < 4; colCount++) {
+ GridColumn column = new GridColumn(grid, SWT.NONE);
+ column.setText("Column " + (colCount + 1));
+ column.setWidth(100);
+ for (int rowCount = 0; rowCount < 50; rowCount++) {
+ final GridItem item;
+ if (colCount == 0) {
+ item = new GridItem(grid, SWT.NONE);
+ } else {
+ item = grid.getItem(rowCount);
+ }
+ item.setText(colCount, (rowCount + 1) + "." + (colCount + 1));
+ }
+ }
+
+
+ shell.setSize(500, 500);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
}
\ No newline at end of file
diff --git a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/TestBug387468.java b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/TestBug387468.java
index e68675c91..97641298d 100644
--- a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/TestBug387468.java
+++ b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/TestBug387468.java
@@ -1,84 +1,84 @@
-package org.eclipse.nebula.snippets.grid;
-
-import org.eclipse.nebula.widgets.grid.Grid;
-import org.eclipse.nebula.widgets.grid.GridColumn;
-import org.eclipse.nebula.widgets.grid.GridItem;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Create a grid with an item that spans rows.
- *
- * For a list of all Nebula Grid example snippets see
- * http://www.eclipse.org/nebula/widgets/grid/snippets.php
- */
-public class TestBug387468 {
-
- /**
- *
- * @param args
- */
- public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
-
- Grid grid = new Grid(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
-
- grid.setHeaderVisible(true);
- GridColumn column = new GridColumn(grid, SWT.NONE);
- column.setText("Employee");
- column.setWidth(100);
-
- GridColumn column2 = new GridColumn(grid, SWT.NONE);
- column2.setText("Company");
- column2.setWidth(100);
-
- GridItem item1 = new GridItem(grid, SWT.NONE);
- item1.setText("Anne");
- item1.setText(1, "Company A");
- item1.setRowSpan(1, 2);
-
- GridItem item2 = new GridItem(grid, SWT.NONE);
- item2.setText("Jim");
- item1.setText(1, "Company A");
- item2.setRowSpan(1, 2);
-
- GridItem item3 = new GridItem(grid, SWT.NONE);
- item3.setText("Sara");
- item3.setText(1, "Company A");
- item3.setRowSpan(1, 2);
-
- GridItem item4 = new GridItem(grid, SWT.NONE);
- item4.setText("Tom");
- item4.setText(1, "Company B");
- item4.setRowSpan(1, 1);
-
- GridItem item5 = new GridItem(grid, SWT.NONE);
- item5.setText("Nathalie");
- item5.setText(1, "Company B");
- item5.setRowSpan(1, 1);
-
- GridItem item6 = new GridItem(grid, SWT.NONE);
- item6.setText("Wim");
- item6.setText(1, "Company C");
- item6.setRowSpan(1, 1);
-
- GridItem item7 = new GridItem(grid, SWT.NONE);
- item7.setText("Pauline");
- item7.setText(1, "Company C");
- item7.setRowSpan(1, 1);
-
- shell.setSize(300, 300);
- shell.open();
-
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- display.dispose();
- }
+package org.eclipse.nebula.snippets.grid;
+
+import org.eclipse.nebula.widgets.grid.Grid;
+import org.eclipse.nebula.widgets.grid.GridColumn;
+import org.eclipse.nebula.widgets.grid.GridItem;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Create a grid with an item that spans rows.
+ *
+ * For a list of all Nebula Grid example snippets see
+ * http://www.eclipse.org/nebula/widgets/grid/snippets.php
+ */
+public class TestBug387468 {
+
+ /**
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+
+ Grid grid = new Grid(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+
+ grid.setHeaderVisible(true);
+ GridColumn column = new GridColumn(grid, SWT.NONE);
+ column.setText("Employee");
+ column.setWidth(100);
+
+ GridColumn column2 = new GridColumn(grid, SWT.NONE);
+ column2.setText("Company");
+ column2.setWidth(100);
+
+ GridItem item1 = new GridItem(grid, SWT.NONE);
+ item1.setText("Anne");
+ item1.setText(1, "Company A");
+ item1.setRowSpan(1, 2);
+
+ GridItem item2 = new GridItem(grid, SWT.NONE);
+ item2.setText("Jim");
+ item1.setText(1, "Company A");
+ item2.setRowSpan(1, 2);
+
+ GridItem item3 = new GridItem(grid, SWT.NONE);
+ item3.setText("Sara");
+ item3.setText(1, "Company A");
+ item3.setRowSpan(1, 2);
+
+ GridItem item4 = new GridItem(grid, SWT.NONE);
+ item4.setText("Tom");
+ item4.setText(1, "Company B");
+ item4.setRowSpan(1, 1);
+
+ GridItem item5 = new GridItem(grid, SWT.NONE);
+ item5.setText("Nathalie");
+ item5.setText(1, "Company B");
+ item5.setRowSpan(1, 1);
+
+ GridItem item6 = new GridItem(grid, SWT.NONE);
+ item6.setText("Wim");
+ item6.setText(1, "Company C");
+ item6.setRowSpan(1, 1);
+
+ GridItem item7 = new GridItem(grid, SWT.NONE);
+ item7.setText("Pauline");
+ item7.setText(1, "Company C");
+ item7.setRowSpan(1, 1);
+
+ shell.setSize(300, 300);
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+
+ display.dispose();
+ }
}
\ No newline at end of file
diff --git a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/viewer/GridViewerShortTextPerformance.java b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/viewer/GridViewerShortTextPerformance.java
index ad7335890..724f5cb17 100644
--- a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/viewer/GridViewerShortTextPerformance.java
+++ b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/viewer/GridViewerShortTextPerformance.java
@@ -1,250 +1,250 @@
-package org.eclipse.nebula.snippets.grid.viewer;
-
-import java.io.StringWriter;
-
-/*******************************************************************************
- * Copyright (c) 2016 Mirko Paturzo (Exeura srl).
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Mirko Paturzo - improve Grid Export, dispose, fonts and background
- * functional changes
- *******************************************************************************/
-
-import org.eclipse.jface.resource.FontRegistry;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ColumnViewerEditor;
-import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
-import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableColorProvider;
-import org.eclipse.jface.viewers.ITableFontProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.nebula.jface.gridviewer.GridTableViewer;
-import org.eclipse.nebula.jface.gridviewer.GridViewerEditor;
-import org.eclipse.nebula.widgets.grid.GridColumn;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- *
- * Test of the grid with long text.
- *
- * @author Mirko Paturzo
- */
-public class GridViewerShortTextPerformance
-{
-
- private static final int NUM_COLUMNS = 2;
- private static final int NUM_MODELS = 10;
- private static final int HOW_MANY_TEXT_LINE = 100000;
-
- private static final String LINE = "Ground Control to Major Tom..";
-
- private class MyContentProvider implements IStructuredContentProvider
- {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- public Object[] getElements(Object inputElement)
- {
- return (MyModel[]) inputElement;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- public void dispose()
- {
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
- * java.lang.Object, java.lang.Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
- {
-
- }
-
- }
-
- public static boolean flag = true;
-
- public class MyModel
- {
- public int counter;
-
- public MyModel(int counter)
- {
- this.counter = counter;
- }
-
- @Override
- public String toString()
- {
- return "Item " + this.counter;
- }
- }
-
- private static String doBigText()
- {
- StringWriter writer = new StringWriter();
- for (int i = 0; i < HOW_MANY_TEXT_LINE; i++)
- {
- writer.append(LINE);
- }
-// writer.append("\n");
- return writer.toString();
- }
-
- public class MyLabelProvider extends LabelProvider
- implements ITableLabelProvider, ITableFontProvider, ITableColorProvider
- {
- FontRegistry registry = new FontRegistry();
-
- public Image getColumnImage(Object element, int columnIndex)
- {
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex)
- {
- if (columnIndex == 0)
- return "Row " + element.toString();
-
- return doBigText();
- }
-
- public Font getFont(Object element, int columnIndex)
- {
- if (((MyModel) element).counter % 2 == 0)
- {
- return registry.getBold(Display.getCurrent().getSystemFont().getFontData()[0].getName());
- }
- return null;
- }
-
- public Color getBackground(Object element, int columnIndex)
- {
- if (((MyModel) element).counter % 2 == 0)
- {
- return Display.getCurrent().getSystemColor(SWT.COLOR_RED);
- }
- return null;
- }
-
- public Color getForeground(Object element, int columnIndex)
- {
- if (((MyModel) element).counter % 2 == 1)
- {
- return Display.getCurrent().getSystemColor(SWT.COLOR_RED);
- }
- return null;
- }
-
- }
-
- public GridViewerShortTextPerformance(Shell shell)
- {
- final GridTableViewer v = new GridTableViewer(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- v.setLabelProvider(new MyLabelProvider());
- v.setContentProvider(new MyContentProvider());
- v.getGrid().setCellSelectionEnabled(true);
-
- v.setCellEditors(new CellEditor[] { new TextCellEditor(v.getGrid()), new TextCellEditor(v.getGrid()) });
-
- v.setColumnProperties(new String[] { "1", "2" });
-
- ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(v)
- {
-
- @Override
- protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
- {
- return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
- || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
- || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED
- && event.keyCode == SWT.CR);
- }
- };
-
- GridViewerEditor.create(v, actSupport,
- ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
- | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION);
-
- for (int i = 0; i < NUM_COLUMNS; i++)
- {
- createColumn(v, "Column " + i);
- }
-
- MyModel[] model = createModel();
- v.setInput(model);
- v.getGrid().setLinesVisible(true);
- v.getGrid().setHeaderVisible(true);
- }
-
- private void createColumn(final GridTableViewer v, String name)
- {
- GridColumn column = new GridColumn(v.getGrid(), SWT.NONE);
- column.setWidth(200);
- column.setText(name);
- }
-
- private MyModel[] createModel()
- {
- MyModel[] elements = new MyModel[NUM_MODELS];
-
- for (int i = 0; i < NUM_MODELS; i++)
- {
- elements[i] = new MyModel(i);
- }
-
- return elements;
- }
-
- /**
- * @param args
- */
- public static void main(String[] args)
- {
- Display display = new Display();
-
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- new GridViewerShortTextPerformance(shell);
- shell.open();
-
- while (!shell.isDisposed())
- {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- display.dispose();
-
- }
-
-}
+package org.eclipse.nebula.snippets.grid.viewer;
+
+import java.io.StringWriter;
+
+/*******************************************************************************
+ * Copyright (c) 2016 Mirko Paturzo (Exeura srl).
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Mirko Paturzo - improve Grid Export, dispose, fonts and background
+ * functional changes
+ *******************************************************************************/
+
+import org.eclipse.jface.resource.FontRegistry;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnViewerEditor;
+import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
+import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableColorProvider;
+import org.eclipse.jface.viewers.ITableFontProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.nebula.jface.gridviewer.GridTableViewer;
+import org.eclipse.nebula.jface.gridviewer.GridViewerEditor;
+import org.eclipse.nebula.widgets.grid.GridColumn;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ *
+ * Test of the grid with long text.
+ *
+ * @author Mirko Paturzo
+ */
+public class GridViewerShortTextPerformance
+{
+
+ private static final int NUM_COLUMNS = 2;
+ private static final int NUM_MODELS = 10;
+ private static final int HOW_MANY_TEXT_LINE = 100000;
+
+ private static final String LINE = "Ground Control to Major Tom..";
+
+ private class MyContentProvider implements IStructuredContentProvider
+ {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements(Object inputElement)
+ {
+ return (MyModel[]) inputElement;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose()
+ {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
+ * java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
+ {
+
+ }
+
+ }
+
+ public static boolean flag = true;
+
+ public class MyModel
+ {
+ public int counter;
+
+ public MyModel(int counter)
+ {
+ this.counter = counter;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Item " + this.counter;
+ }
+ }
+
+ private static String doBigText()
+ {
+ StringWriter writer = new StringWriter();
+ for (int i = 0; i < HOW_MANY_TEXT_LINE; i++)
+ {
+ writer.append(LINE);
+ }
+// writer.append("\n");
+ return writer.toString();
+ }
+
+ public class MyLabelProvider extends LabelProvider
+ implements ITableLabelProvider, ITableFontProvider, ITableColorProvider
+ {
+ FontRegistry registry = new FontRegistry();
+
+ public Image getColumnImage(Object element, int columnIndex)
+ {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex)
+ {
+ if (columnIndex == 0)
+ return "Row " + element.toString();
+
+ return doBigText();
+ }
+
+ public Font getFont(Object element, int columnIndex)
+ {
+ if (((MyModel) element).counter % 2 == 0)
+ {
+ return registry.getBold(Display.getCurrent().getSystemFont().getFontData()[0].getName());
+ }
+ return null;
+ }
+
+ public Color getBackground(Object element, int columnIndex)
+ {
+ if (((MyModel) element).counter % 2 == 0)
+ {
+ return Display.getCurrent().getSystemColor(SWT.COLOR_RED);
+ }
+ return null;
+ }
+
+ public Color getForeground(Object element, int columnIndex)
+ {
+ if (((MyModel) element).counter % 2 == 1)
+ {
+ return Display.getCurrent().getSystemColor(SWT.COLOR_RED);
+ }
+ return null;
+ }
+
+ }
+
+ public GridViewerShortTextPerformance(Shell shell)
+ {
+ final GridTableViewer v = new GridTableViewer(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ v.setLabelProvider(new MyLabelProvider());
+ v.setContentProvider(new MyContentProvider());
+ v.getGrid().setCellSelectionEnabled(true);
+
+ v.setCellEditors(new CellEditor[] { new TextCellEditor(v.getGrid()), new TextCellEditor(v.getGrid()) });
+
+ v.setColumnProperties(new String[] { "1", "2" });
+
+ ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(v)
+ {
+
+ @Override
+ protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event)
+ {
+ return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
+ || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
+ || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED
+ && event.keyCode == SWT.CR);
+ }
+ };
+
+ GridViewerEditor.create(v, actSupport,
+ ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
+ | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION);
+
+ for (int i = 0; i < NUM_COLUMNS; i++)
+ {
+ createColumn(v, "Column " + i);
+ }
+
+ MyModel[] model = createModel();
+ v.setInput(model);
+ v.getGrid().setLinesVisible(true);
+ v.getGrid().setHeaderVisible(true);
+ }
+
+ private void createColumn(final GridTableViewer v, String name)
+ {
+ GridColumn column = new GridColumn(v.getGrid(), SWT.NONE);
+ column.setWidth(200);
+ column.setText(name);
+ }
+
+ private MyModel[] createModel()
+ {
+ MyModel[] elements = new MyModel[NUM_MODELS];
+
+ for (int i = 0; i < NUM_MODELS; i++)
+ {
+ elements[i] = new MyModel(i);
+ }
+
+ return elements;
+ }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args)
+ {
+ Display display = new Display();
+
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ new GridViewerShortTextPerformance(shell);
+ shell.open();
+
+ while (!shell.isDisposed())
+ {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+
+ display.dispose();
+
+ }
+
+}
diff --git a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/viewer/GridViewerSnippetWithAdaptedDataVisualizer.java b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/viewer/GridViewerSnippetWithAdaptedDataVisualizer.java
index b3892e432..73a7dfdff 100644
--- a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/viewer/GridViewerSnippetWithAdaptedDataVisualizer.java
+++ b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/viewer/GridViewerSnippetWithAdaptedDataVisualizer.java
@@ -1,274 +1,274 @@
-package org.eclipse.nebula.snippets.grid.viewer;
-
-/*******************************************************************************
- * Copyright (c) 2006 Tom Schindl and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Tom Schindl - initial API and implementation
- * Mirko Paturzo - adapt the example for AdaptedDataVisualizer
- *******************************************************************************/
-
-import org.eclipse.jface.resource.FontRegistry;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ColumnViewerEditor;
-import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
-import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
-import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableColorProvider;
-import org.eclipse.jface.viewers.ITableFontProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.nebula.jface.gridviewer.GridTableViewer;
-import org.eclipse.nebula.jface.gridviewer.GridViewerEditor;
-import org.eclipse.nebula.widgets.grid.AdaptedDataVisualizer;
-import org.eclipse.nebula.widgets.grid.GridColumn;
-import org.eclipse.nebula.widgets.grid.GridItem;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Example usage of none mandatory interfaces of ITableFontProvider and
- * ITableColorProvider
- *
- * @author Tom Schindl
- * @author Mirko Paturzo
- *
- * Example with {@link AdaptedDataVisualizer}
- */
-public class GridViewerSnippetWithAdaptedDataVisualizer {
-
- private static final int NUM_COLUMNS = 1000;
- private static final int NUM_MODELS = 1000;
-
- private class MyContentProvider implements IStructuredContentProvider {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- public Object[] getElements(Object inputElement) {
- return (MyModel[]) inputElement;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- public void dispose() {
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
- * java.lang.Object, java.lang.Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-
- }
-
- }
-
- public static boolean flag = true;
-
- public class MyModel {
- public int counter;
-
- public MyModel(int counter) {
- this.counter = counter;
- }
-
- @Override
- public String toString() {
- return "Item " + this.counter;
- }
- }
-
- public class MyLabelProvider extends LabelProvider implements ITableLabelProvider, ITableFontProvider,
- ITableColorProvider {
- FontRegistry registry = new FontRegistry();
-
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- return "Column " + columnIndex + " => " + element.toString();
- }
-
- public Font getFont(Object element, int columnIndex) {
- if (((MyModel) element).counter % 2 == 0) {
- return registry.getBold(Display.getCurrent().getSystemFont().getFontData()[0].getName());
- }
- return null;
- }
-
- public Color getBackground(Object element, int columnIndex) {
- if (((MyModel) element).counter % 2 == 0) {
- return Display.getCurrent().getSystemColor(SWT.COLOR_RED);
- }
- return null;
- }
-
- public Color getForeground(Object element, int columnIndex) {
- if (((MyModel) element).counter % 2 == 1) {
- return Display.getCurrent().getSystemColor(SWT.COLOR_RED);
- }
- return null;
- }
-
- }
-
- /**
- * Below myown AdaptedDataVisualizer
- * @author Mirko Paturzo
- *
- */
- private static class MyOwnDataVisualizer extends AdaptedDataVisualizer {
- FontRegistry registry = new FontRegistry();
-
- private final MyModel models[];
-
- public MyOwnDataVisualizer(MyModel models[]) {
- this.models = models;
- }
-
- @Override
- public Image getImage(GridItem gridItem, int columnIndex) {
- return null;
- }
-
- @Override
- public String getText(GridItem gridItem, int columnIndex) {
- return "Column " + columnIndex + " => " + models[gridItem.getRowIndex()].toString();
- }
-
- @Override
- public Font getFont(GridItem gridItem, int columnIndex) {
- if ((models[gridItem.getRowIndex()]).counter % 2 == 0) {
- return registry.getBold(Display.getCurrent().getSystemFont().getFontData()[0].getName());
- }
- return null;
- }
-
- @Override
- public Color getBackground(GridItem gridItem, int columnIndex) {
- if ((models[gridItem.getRowIndex()]).counter % 2 == 0) {
- return Display.getCurrent().getSystemColor(SWT.COLOR_RED);
- }
- return Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);
- }
-
- @Override
- public Color getForeground(GridItem gridItem, int columnIndex) {
- if ((models[gridItem.getRowIndex()]).counter % 2 == 1) {
- return Display.getCurrent().getSystemColor(SWT.COLOR_RED);
- }
- return Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
- }
- }
-
- public GridViewerSnippetWithAdaptedDataVisualizer(Shell shell) {
- MyModel[] models = createModel();
- final GridTableViewer v = new GridTableViewer(new MyOwnDataVisualizer(models), shell, SWT.BORDER | SWT.V_SCROLL
- | SWT.H_SCROLL);
- v.setLabelProvider(new MyLabelProvider());
- v.setContentProvider(new MyContentProvider());
- v.getGrid().setCellSelectionEnabled(true);
-
- v.setCellEditors(new CellEditor[] { new TextCellEditor(v.getGrid()), new TextCellEditor(v.getGrid()) });
- v.setCellModifier(new ICellModifier() {
-
- public boolean canModify(Object element, String property) {
- return true;
- }
-
- public Object getValue(Object element, String property) {
- return "Column " + property + " => " + element.toString();
- }
-
- public void modify(Object element, String property, Object value) {
-
- }
-
- });
-
- v.setColumnProperties(new String[] { "1", "2" });
-
- ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(v) {
- @Override
- protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
- return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
- || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
- || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR);
- }
- };
-
- GridViewerEditor.create(v, actSupport, ColumnViewerEditor.TABBING_HORIZONTAL
- | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL
- | ColumnViewerEditor.KEYBOARD_ACTIVATION);
-
- for (int i = 0; i < NUM_COLUMNS; i++) {
- createColumn(v, "Column " + i);
- }
-
- v.setInput(models);
- v.getGrid().setLinesVisible(true);
- v.getGrid().setHeaderVisible(true);
- }
-
- private void createColumn(final GridTableViewer v, String name) {
- GridColumn column = new GridColumn(v.getGrid(), SWT.NONE);
- column.setWidth(200);
- column.setText(name);
- }
-
- private MyModel[] createModel() {
- MyModel[] elements = new MyModel[NUM_MODELS];
-
- for (int i = 0; i < NUM_MODELS; i++) {
- elements[i] = new MyModel(i);
- }
-
- return elements;
- }
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Display display = new Display();
-
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- new GridViewerSnippetWithAdaptedDataVisualizer(shell);
- shell.open();
-
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- display.dispose();
-
- }
-
-}
+package org.eclipse.nebula.snippets.grid.viewer;
+
+/*******************************************************************************
+ * Copyright (c) 2006 Tom Schindl and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Tom Schindl - initial API and implementation
+ * Mirko Paturzo - adapt the example for AdaptedDataVisualizer
+ *******************************************************************************/
+
+import org.eclipse.jface.resource.FontRegistry;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnViewerEditor;
+import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
+import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableColorProvider;
+import org.eclipse.jface.viewers.ITableFontProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.nebula.jface.gridviewer.GridTableViewer;
+import org.eclipse.nebula.jface.gridviewer.GridViewerEditor;
+import org.eclipse.nebula.widgets.grid.AdaptedDataVisualizer;
+import org.eclipse.nebula.widgets.grid.GridColumn;
+import org.eclipse.nebula.widgets.grid.GridItem;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Example usage of none mandatory interfaces of ITableFontProvider and
+ * ITableColorProvider
+ *
+ * @author Tom Schindl
+ * @author Mirko Paturzo
+ *
+ * Example with {@link AdaptedDataVisualizer}
+ */
+public class GridViewerSnippetWithAdaptedDataVisualizer {
+
+ private static final int NUM_COLUMNS = 1000;
+ private static final int NUM_MODELS = 1000;
+
+ private class MyContentProvider implements IStructuredContentProvider {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements(Object inputElement) {
+ return (MyModel[]) inputElement;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose() {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
+ * java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+ }
+
+ }
+
+ public static boolean flag = true;
+
+ public class MyModel {
+ public int counter;
+
+ public MyModel(int counter) {
+ this.counter = counter;
+ }
+
+ @Override
+ public String toString() {
+ return "Item " + this.counter;
+ }
+ }
+
+ public class MyLabelProvider extends LabelProvider implements ITableLabelProvider, ITableFontProvider,
+ ITableColorProvider {
+ FontRegistry registry = new FontRegistry();
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ return "Column " + columnIndex + " => " + element.toString();
+ }
+
+ public Font getFont(Object element, int columnIndex) {
+ if (((MyModel) element).counter % 2 == 0) {
+ return registry.getBold(Display.getCurrent().getSystemFont().getFontData()[0].getName());
+ }
+ return null;
+ }
+
+ public Color getBackground(Object element, int columnIndex) {
+ if (((MyModel) element).counter % 2 == 0) {
+ return Display.getCurrent().getSystemColor(SWT.COLOR_RED);
+ }
+ return null;
+ }
+
+ public Color getForeground(Object element, int columnIndex) {
+ if (((MyModel) element).counter % 2 == 1) {
+ return Display.getCurrent().getSystemColor(SWT.COLOR_RED);
+ }
+ return null;
+ }
+
+ }
+
+ /**
+ * Below myown AdaptedDataVisualizer
+ * @author Mirko Paturzo
+ *
+ */
+ private static class MyOwnDataVisualizer extends AdaptedDataVisualizer {
+ FontRegistry registry = new FontRegistry();
+
+ private final MyModel models[];
+
+ public MyOwnDataVisualizer(MyModel models[]) {
+ this.models = models;
+ }
+
+ @Override
+ public Image getImage(GridItem gridItem, int columnIndex) {
+ return null;
+ }
+
+ @Override
+ public String getText(GridItem gridItem, int columnIndex) {
+ return "Column " + columnIndex + " => " + models[gridItem.getRowIndex()].toString();
+ }
+
+ @Override
+ public Font getFont(GridItem gridItem, int columnIndex) {
+ if ((models[gridItem.getRowIndex()]).counter % 2 == 0) {
+ return registry.getBold(Display.getCurrent().getSystemFont().getFontData()[0].getName());
+ }
+ return null;
+ }
+
+ @Override
+ public Color getBackground(GridItem gridItem, int columnIndex) {
+ if ((models[gridItem.getRowIndex()]).counter % 2 == 0) {
+ return Display.getCurrent().getSystemColor(SWT.COLOR_RED);
+ }
+ return Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);
+ }
+
+ @Override
+ public Color getForeground(GridItem gridItem, int columnIndex) {
+ if ((models[gridItem.getRowIndex()]).counter % 2 == 1) {
+ return Display.getCurrent().getSystemColor(SWT.COLOR_RED);
+ }
+ return Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
+ }
+ }
+
+ public GridViewerSnippetWithAdaptedDataVisualizer(Shell shell) {
+ MyModel[] models = createModel();
+ final GridTableViewer v = new GridTableViewer(new MyOwnDataVisualizer(models), shell, SWT.BORDER | SWT.V_SCROLL
+ | SWT.H_SCROLL);
+ v.setLabelProvider(new MyLabelProvider());
+ v.setContentProvider(new MyContentProvider());
+ v.getGrid().setCellSelectionEnabled(true);
+
+ v.setCellEditors(new CellEditor[] { new TextCellEditor(v.getGrid()), new TextCellEditor(v.getGrid()) });
+ v.setCellModifier(new ICellModifier() {
+
+ public boolean canModify(Object element, String property) {
+ return true;
+ }
+
+ public Object getValue(Object element, String property) {
+ return "Column " + property + " => " + element.toString();
+ }
+
+ public void modify(Object element, String property, Object value) {
+
+ }
+
+ });
+
+ v.setColumnProperties(new String[] { "1", "2" });
+
+ ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(v) {
+ @Override
+ protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
+ return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
+ || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
+ || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR);
+ }
+ };
+
+ GridViewerEditor.create(v, actSupport, ColumnViewerEditor.TABBING_HORIZONTAL
+ | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL
+ | ColumnViewerEditor.KEYBOARD_ACTIVATION);
+
+ for (int i = 0; i < NUM_COLUMNS; i++) {
+ createColumn(v, "Column " + i);
+ }
+
+ v.setInput(models);
+ v.getGrid().setLinesVisible(true);
+ v.getGrid().setHeaderVisible(true);
+ }
+
+ private void createColumn(final GridTableViewer v, String name) {
+ GridColumn column = new GridColumn(v.getGrid(), SWT.NONE);
+ column.setWidth(200);
+ column.setText(name);
+ }
+
+ private MyModel[] createModel() {
+ MyModel[] elements = new MyModel[NUM_MODELS];
+
+ for (int i = 0; i < NUM_MODELS; i++) {
+ elements[i] = new MyModel(i);
+ }
+
+ return elements;
+ }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ Display display = new Display();
+
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ new GridViewerSnippetWithAdaptedDataVisualizer(shell);
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+
+ display.dispose();
+
+ }
+
+}
diff --git a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/viewer/GridViewerSnippetWithGridItemDataVisualizer.java b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/viewer/GridViewerSnippetWithGridItemDataVisualizer.java
index 8c2717cca..5472bbb6c 100644
--- a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/viewer/GridViewerSnippetWithGridItemDataVisualizer.java
+++ b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/viewer/GridViewerSnippetWithGridItemDataVisualizer.java
@@ -1,238 +1,238 @@
-package org.eclipse.nebula.snippets.grid.viewer;
-
-/*******************************************************************************
- * Copyright (c) 2006 Tom Schindl and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Tom Schindl - initial API and implementation
- * Mirko Paturzo - improve Grid Export, dispose, fonts and background
- * functional changes
- *******************************************************************************/
-
-
-import org.eclipse.jface.resource.FontRegistry;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ColumnViewerEditor;
-import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
-import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
-import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableColorProvider;
-import org.eclipse.jface.viewers.ITableFontProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.nebula.jface.gridviewer.GridTableViewer;
-import org.eclipse.nebula.jface.gridviewer.GridViewerEditor;
-import org.eclipse.nebula.widgets.grid.GridColumn;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Example usage of none mandatory interfaces of ITableFontProvider and
- * ITableColorProvider
- *
- * @author Tom Schindl
- * @author Mirko Paturzo
- *
- * Original example, with something else (NUM_COLUMNS, NUM_MODELS)
- * Using {@link ColumnRowBigDataVisualizer}
- *
- */
-public class GridViewerSnippetWithGridItemDataVisualizer {
-
- private static final int NUM_COLUMNS = 1000;
- private static final int NUM_MODELS = 1000;
-
- private class MyContentProvider implements IStructuredContentProvider {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- public Object[] getElements(Object inputElement) {
- return (MyModel[]) inputElement;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- public void dispose() {
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
- * java.lang.Object, java.lang.Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-
- }
-
- }
-
- public static boolean flag = true;
-
- public class MyModel {
- public int counter;
-
- public MyModel(int counter) {
- this.counter = counter;
- }
-
-
- @Override
- public String toString() {
- return "Item " + this.counter;
- }
- }
-
- public class MyLabelProvider extends LabelProvider implements
- ITableLabelProvider, ITableFontProvider, ITableColorProvider {
- FontRegistry registry = new FontRegistry();
-
-
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
-
- public String getColumnText(Object element, int columnIndex) {
- return "Column " + columnIndex + " => " + element.toString();
- }
-
-
- public Font getFont(Object element, int columnIndex) {
- if (((MyModel) element).counter % 2 == 0) {
- return registry.getBold(Display.getCurrent().getSystemFont()
- .getFontData()[0].getName());
- }
- return null;
- }
-
-
- public Color getBackground(Object element, int columnIndex) {
- if (((MyModel) element).counter % 2 == 0) {
- return Display.getCurrent().getSystemColor(SWT.COLOR_RED);
- }
- return null;
- }
-
-
- public Color getForeground(Object element, int columnIndex) {
- if (((MyModel) element).counter % 2 == 1) {
- return Display.getCurrent().getSystemColor(SWT.COLOR_RED);
- }
- return null;
- }
-
- }
-
- public GridViewerSnippetWithGridItemDataVisualizer(Shell shell) {
- final GridTableViewer v = new GridTableViewer(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- v.setLabelProvider(new MyLabelProvider());
- v.setContentProvider(new MyContentProvider());
- v.getGrid().setCellSelectionEnabled(true);
-
- v.setCellEditors(new CellEditor[] { new TextCellEditor(v.getGrid()), new TextCellEditor(v.getGrid()) });
- v.setCellModifier(new ICellModifier() {
-
-
- public boolean canModify(Object element, String property) {
- return true;
- }
-
-
- public Object getValue(Object element, String property) {
- return "Column " + property + " => " + element.toString();
- }
-
-
- public void modify(Object element, String property, Object value) {
-
- }
-
- });
-
- v.setColumnProperties(new String[] {"1","2"});
-
- ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(v) {
-
- @Override
- protected boolean isEditorActivationEvent(
- ColumnViewerEditorActivationEvent event) {
- return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
- || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
- || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR);
- }
- };
-
- GridViewerEditor.create(v, actSupport, ColumnViewerEditor.TABBING_HORIZONTAL
- | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
- | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION);
-
- for(int i = 0; i < NUM_COLUMNS; i++) {
- createColumn(v, "Column " + i);
- }
-
- MyModel[] model = createModel();
- v.setInput(model);
- v.getGrid().setLinesVisible(true);
- v.getGrid().setHeaderVisible(true);
- }
-
- private void createColumn(final GridTableViewer v, String name) {
- GridColumn column = new GridColumn(v.getGrid(), SWT.NONE);
- column.setWidth(200);
- column.setText(name);
- }
-
- private MyModel[] createModel() {
- MyModel[] elements = new MyModel[NUM_MODELS];
-
- for (int i = 0; i < NUM_MODELS; i++) {
- elements[i] = new MyModel(i);
- }
-
- return elements;
- }
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Display display = new Display();
-
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- new GridViewerSnippetWithGridItemDataVisualizer(shell);
- shell.open();
-
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- display.dispose();
-
- }
-
-}
+package org.eclipse.nebula.snippets.grid.viewer;
+
+/*******************************************************************************
+ * Copyright (c) 2006 Tom Schindl and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Tom Schindl - initial API and implementation
+ * Mirko Paturzo - improve Grid Export, dispose, fonts and background
+ * functional changes
+ *******************************************************************************/
+
+
+import org.eclipse.jface.resource.FontRegistry;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnViewerEditor;
+import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
+import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableColorProvider;
+import org.eclipse.jface.viewers.ITableFontProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.nebula.jface.gridviewer.GridTableViewer;
+import org.eclipse.nebula.jface.gridviewer.GridViewerEditor;
+import org.eclipse.nebula.widgets.grid.GridColumn;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Example usage of none mandatory interfaces of ITableFontProvider and
+ * ITableColorProvider
+ *
+ * @author Tom Schindl
+ * @author Mirko Paturzo
+ *
+ * Original example, with something else (NUM_COLUMNS, NUM_MODELS)
+ * Using {@link ColumnRowBigDataVisualizer}
+ *
+ */
+public class GridViewerSnippetWithGridItemDataVisualizer {
+
+ private static final int NUM_COLUMNS = 1000;
+ private static final int NUM_MODELS = 1000;
+
+ private class MyContentProvider implements IStructuredContentProvider {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements(Object inputElement) {
+ return (MyModel[]) inputElement;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose() {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
+ * java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+ }
+
+ }
+
+ public static boolean flag = true;
+
+ public class MyModel {
+ public int counter;
+
+ public MyModel(int counter) {
+ this.counter = counter;
+ }
+
+
+ @Override
+ public String toString() {
+ return "Item " + this.counter;
+ }
+ }
+
+ public class MyLabelProvider extends LabelProvider implements
+ ITableLabelProvider, ITableFontProvider, ITableColorProvider {
+ FontRegistry registry = new FontRegistry();
+
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+
+ public String getColumnText(Object element, int columnIndex) {
+ return "Column " + columnIndex + " => " + element.toString();
+ }
+
+
+ public Font getFont(Object element, int columnIndex) {
+ if (((MyModel) element).counter % 2 == 0) {
+ return registry.getBold(Display.getCurrent().getSystemFont()
+ .getFontData()[0].getName());
+ }
+ return null;
+ }
+
+
+ public Color getBackground(Object element, int columnIndex) {
+ if (((MyModel) element).counter % 2 == 0) {
+ return Display.getCurrent().getSystemColor(SWT.COLOR_RED);
+ }
+ return null;
+ }
+
+
+ public Color getForeground(Object element, int columnIndex) {
+ if (((MyModel) element).counter % 2 == 1) {
+ return Display.getCurrent().getSystemColor(SWT.COLOR_RED);
+ }
+ return null;
+ }
+
+ }
+
+ public GridViewerSnippetWithGridItemDataVisualizer(Shell shell) {
+ final GridTableViewer v = new GridTableViewer(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ v.setLabelProvider(new MyLabelProvider());
+ v.setContentProvider(new MyContentProvider());
+ v.getGrid().setCellSelectionEnabled(true);
+
+ v.setCellEditors(new CellEditor[] { new TextCellEditor(v.getGrid()), new TextCellEditor(v.getGrid()) });
+ v.setCellModifier(new ICellModifier() {
+
+
+ public boolean canModify(Object element, String property) {
+ return true;
+ }
+
+
+ public Object getValue(Object element, String property) {
+ return "Column " + property + " => " + element.toString();
+ }
+
+
+ public void modify(Object element, String property, Object value) {
+
+ }
+
+ });
+
+ v.setColumnProperties(new String[] {"1","2"});
+
+ ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(v) {
+
+ @Override
+ protected boolean isEditorActivationEvent(
+ ColumnViewerEditorActivationEvent event) {
+ return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
+ || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
+ || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR);
+ }
+ };
+
+ GridViewerEditor.create(v, actSupport, ColumnViewerEditor.TABBING_HORIZONTAL
+ | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
+ | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION);
+
+ for(int i = 0; i < NUM_COLUMNS; i++) {
+ createColumn(v, "Column " + i);
+ }
+
+ MyModel[] model = createModel();
+ v.setInput(model);
+ v.getGrid().setLinesVisible(true);
+ v.getGrid().setHeaderVisible(true);
+ }
+
+ private void createColumn(final GridTableViewer v, String name) {
+ GridColumn column = new GridColumn(v.getGrid(), SWT.NONE);
+ column.setWidth(200);
+ column.setText(name);
+ }
+
+ private MyModel[] createModel() {
+ MyModel[] elements = new MyModel[NUM_MODELS];
+
+ for (int i = 0; i < NUM_MODELS; i++) {
+ elements[i] = new MyModel(i);
+ }
+
+ return elements;
+ }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ Display display = new Display();
+
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ new GridViewerSnippetWithGridItemDataVisualizer(shell);
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+
+ display.dispose();
+
+ }
+
+}
diff --git a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/viewer/GridVirtualTableViewer.java b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/viewer/GridVirtualTableViewer.java
index eec8bec52..2b9b36243 100644
--- a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/viewer/GridVirtualTableViewer.java
+++ b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/grid/viewer/GridVirtualTableViewer.java
@@ -1,153 +1,153 @@
-package org.eclipse.nebula.snippets.grid.viewer;
-
-/*******************************************************************************
- * Copyright (c) 2014 Mirko Paturzo (Exeura srl).
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Mirko Paturzo - realize example
- *******************************************************************************/
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.nebula.jface.gridviewer.GridTableViewer;
-import org.eclipse.nebula.widgets.grid.GridColumn;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * A simple TableViewer to demonstrate the usage of a lazy content provider
- * with a virtual table
- */
-public class GridVirtualTableViewer {
-
- private static final int ROWS = 1000000;
- private static final int COLUMNS = 10;
-
- private class MyContentProvider implements IStructuredContentProvider {
- public MyContentProvider(GridTableViewer viewer) {
-
- }
- public void dispose() {
- // TODO Auto-generated method stub
-
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // TODO Auto-generated method stub
-
- }
-
- public Object[] getElements(Object inputElement) {
- return (Object[]) inputElement;
- }
-
- }
-
- public class MyModel {
- public int counter;
-
- public MyModel(int counter) {
- this.counter = counter;
- }
-
- @Override
- public String toString() {
- return "Item " + this.counter;
- }
- }
-
- public GridVirtualTableViewer(Shell shell) {
- LabelProvider labelProvider = new LabelProvider();
- final GridTableViewer v = new GridTableViewer(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.VIRTUAL);
-
- v.setLabelProvider(labelProvider);
- v.setContentProvider(new MyContentProvider(v));
- v.setUseHashlookup(true);
- v.getGrid().setLinesVisible(true);
- v.getGrid().setHeaderVisible(true);
- v.getGrid().setVisibleLinesColumnPack(true);
-// v.getGrid().setRowHeaderVisible(true);
-// v.setRowHeaderLabelProvider(new ColumnLabelProvider() {
-// @Override
-// public String getText(Object element) {
-// return "xyz";
-// }
-// });
- v.getGrid().setLayoutData(new GridData(GridData.FILL_BOTH));
-
- for (int i = 0; i < COLUMNS; i++)
- {
- createColumn(v, "Column");
- }
-
- MyModel[] model = createModel();
- v.setInput(model);
-
- Button b = new Button(shell, SWT.PUSH);
- b.setText("Filter items without 0");
- b.addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(SelectionEvent arg0) {
- v.addFilter(new ViewerFilter() {
-
- @Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- return element.toString().contains("0");
- }
- });
- }
-
- public void widgetDefaultSelected(SelectionEvent arg0) {
- }
- });
- }
- private void createColumn(final GridTableViewer v, String name) {
- GridColumn column = new GridColumn(v.getGrid(), SWT.NONE);
- column.setWidth(200);
- column.setText(name);
- }
- private MyModel[] createModel() {
- MyModel[] elements = new MyModel[ROWS];
-
- for (int i = 0; i < ROWS; i++) {
- elements[i] = new MyModel(i);
- }
-
- return elements;
- }
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new GridLayout());
- new GridVirtualTableViewer(shell);
- shell.open();
-
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- display.dispose();
-
- }
-
+package org.eclipse.nebula.snippets.grid.viewer;
+
+/*******************************************************************************
+ * Copyright (c) 2014 Mirko Paturzo (Exeura srl).
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Mirko Paturzo - realize example
+ *******************************************************************************/
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.nebula.jface.gridviewer.GridTableViewer;
+import org.eclipse.nebula.widgets.grid.GridColumn;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * A simple TableViewer to demonstrate the usage of a lazy content provider
+ * with a virtual table
+ */
+public class GridVirtualTableViewer {
+
+ private static final int ROWS = 1000000;
+ private static final int COLUMNS = 10;
+
+ private class MyContentProvider implements IStructuredContentProvider {
+ public MyContentProvider(GridTableViewer viewer) {
+
+ }
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return (Object[]) inputElement;
+ }
+
+ }
+
+ public class MyModel {
+ public int counter;
+
+ public MyModel(int counter) {
+ this.counter = counter;
+ }
+
+ @Override
+ public String toString() {
+ return "Item " + this.counter;
+ }
+ }
+
+ public GridVirtualTableViewer(Shell shell) {
+ LabelProvider labelProvider = new LabelProvider();
+ final GridTableViewer v = new GridTableViewer(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.VIRTUAL);
+
+ v.setLabelProvider(labelProvider);
+ v.setContentProvider(new MyContentProvider(v));
+ v.setUseHashlookup(true);
+ v.getGrid().setLinesVisible(true);
+ v.getGrid().setHeaderVisible(true);
+ v.getGrid().setVisibleLinesColumnPack(true);
+// v.getGrid().setRowHeaderVisible(true);
+// v.setRowHeaderLabelProvider(new ColumnLabelProvider() {
+// @Override
+// public String getText(Object element) {
+// return "xyz";
+// }
+// });
+ v.getGrid().setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ for (int i = 0; i < COLUMNS; i++)
+ {
+ createColumn(v, "Column");
+ }
+
+ MyModel[] model = createModel();
+ v.setInput(model);
+
+ Button b = new Button(shell, SWT.PUSH);
+ b.setText("Filter items without 0");
+ b.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent arg0) {
+ v.addFilter(new ViewerFilter() {
+
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ return element.toString().contains("0");
+ }
+ });
+ }
+
+ public void widgetDefaultSelected(SelectionEvent arg0) {
+ }
+ });
+ }
+ private void createColumn(final GridTableViewer v, String name) {
+ GridColumn column = new GridColumn(v.getGrid(), SWT.NONE);
+ column.setWidth(200);
+ column.setText(name);
+ }
+ private MyModel[] createModel() {
+ MyModel[] elements = new MyModel[ROWS];
+
+ for (int i = 0; i < ROWS; i++) {
+ elements[i] = new MyModel(i);
+ }
+
+ return elements;
+ }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout());
+ new GridVirtualTableViewer(shell);
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+
+ display.dispose();
+
+ }
+
}
\ No newline at end of file
diff --git a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/pshelf/PShelfViewerSnippet1.java b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/pshelf/PShelfViewerSnippet1.java
index e41123f46..e74599090 100644
--- a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/pshelf/PShelfViewerSnippet1.java
+++ b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/pshelf/PShelfViewerSnippet1.java
@@ -1,150 +1,150 @@
-package org.eclipse.nebula.snippets.pshelf;
-
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.ListViewer;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TreeNode;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.nebula.jface.pshelfviewer.IShelfViewerFactory;
-import org.eclipse.nebula.jface.pshelfviewer.PShelfViewer;
-import org.eclipse.nebula.widgets.pshelf.RedmondShelfRenderer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-public class PShelfViewerSnippet1 {
-
- private MyTreeNode myModel;
- private MyContentProvider myContentProvider;
- private MyLabelProvider myLabelProvider;
-
- private class MyViewerFactory implements IShelfViewerFactory {
-
- public Viewer createViewerForContent(Composite parent, Object content) {
- TreeNode node = (TreeNode) content;
- StructuredViewer viewer;
- if (node.getValue().equals("List")) {
- viewer = new ListViewer(parent);
- } else {
- viewer = new TreeViewer(parent);
- }
-
- viewer.setContentProvider(myContentProvider);
- viewer.setLabelProvider(myLabelProvider);
- return viewer;
- }
-
- }
-
- private class MyContentProvider implements ITreeContentProvider {
-
- public Object[] getChildren(Object parentElement) {
- return ((TreeNode) parentElement).getChildren();
- }
-
- public Object getParent(Object element) {
- return ((TreeNode) element).getParent();
- }
-
- public boolean hasChildren(Object element) {
- return ((TreeNode) element).hasChildren();
- }
-
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof Object[]) {
- // elements for ListViewer
- return (Object[]) inputElement;
- } else {
- // elements for PShelf
- Object[] children = getChildren(inputElement);
- // prepend "All" node to children
- Object[] elements = new Object[children.length + 1];
- elements[0] = myModel;
- System.arraycopy(children, 0, elements, 1, children.length);
- return elements;
- }
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- }
-
- private class MyLabelProvider extends LabelProvider {
-
- public String getText(Object element) {
- return ((TreeNode) element).getValue().toString();
- }
- }
-
- private class MyTreeNode extends TreeNode {
-
- public MyTreeNode(Object value) {
- super(value);
- }
-
- public void setChildren(TreeNode[] children) {
- super.setChildren(children);
- for (int i = 0; i < children.length; i++) {
- children[i].setParent(this);
- }
- }
-
- }
-
- public PShelfViewerSnippet1(Shell shell) {
- PShelfViewer viewer = new PShelfViewer(shell, SWT.NONE,
- new MyViewerFactory());
-
- // Optionally, change the renderer
- viewer.getPShelf().setRenderer(new RedmondShelfRenderer());
-
- // Optionally, transfer selection between viewers
- viewer.setTransferSelection(true);
-
- myContentProvider = new MyContentProvider();
- viewer.setContentProvider(myContentProvider);
- myLabelProvider = new MyLabelProvider();
- viewer.setLabelProvider(myLabelProvider);
- createModel();
- viewer.setInput(myModel);
- }
-
- private void createModel() {
- myModel = new MyTreeNode("All");
- TreeNode list = new MyTreeNode("List");
- TreeNode tree = new MyTreeNode("Tree");
- myModel.setChildren(new TreeNode[] { list, tree });
-
- list.setChildren(new TreeNode[] {
- new MyTreeNode("List item 1"), new MyTreeNode("List item 2")
- });
-
- MyTreeNode treeNode1 = new MyTreeNode("Tree item 1");
- tree.setChildren(new TreeNode[] { treeNode1, new MyTreeNode("Tree item 2") });
- treeNode1.setChildren(new TreeNode[] { new MyTreeNode("Sub item 1.1") });
- }
-
- public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
-
- new PShelfViewerSnippet1(shell);
-
- shell.setSize(200, 400);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
-}
+package org.eclipse.nebula.snippets.pshelf;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TreeNode;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.nebula.jface.pshelfviewer.IShelfViewerFactory;
+import org.eclipse.nebula.jface.pshelfviewer.PShelfViewer;
+import org.eclipse.nebula.widgets.pshelf.RedmondShelfRenderer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class PShelfViewerSnippet1 {
+
+ private MyTreeNode myModel;
+ private MyContentProvider myContentProvider;
+ private MyLabelProvider myLabelProvider;
+
+ private class MyViewerFactory implements IShelfViewerFactory {
+
+ public Viewer createViewerForContent(Composite parent, Object content) {
+ TreeNode node = (TreeNode) content;
+ StructuredViewer viewer;
+ if (node.getValue().equals("List")) {
+ viewer = new ListViewer(parent);
+ } else {
+ viewer = new TreeViewer(parent);
+ }
+
+ viewer.setContentProvider(myContentProvider);
+ viewer.setLabelProvider(myLabelProvider);
+ return viewer;
+ }
+
+ }
+
+ private class MyContentProvider implements ITreeContentProvider {
+
+ public Object[] getChildren(Object parentElement) {
+ return ((TreeNode) parentElement).getChildren();
+ }
+
+ public Object getParent(Object element) {
+ return ((TreeNode) element).getParent();
+ }
+
+ public boolean hasChildren(Object element) {
+ return ((TreeNode) element).hasChildren();
+ }
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof Object[]) {
+ // elements for ListViewer
+ return (Object[]) inputElement;
+ } else {
+ // elements for PShelf
+ Object[] children = getChildren(inputElement);
+ // prepend "All" node to children
+ Object[] elements = new Object[children.length + 1];
+ elements[0] = myModel;
+ System.arraycopy(children, 0, elements, 1, children.length);
+ return elements;
+ }
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ }
+
+ private class MyLabelProvider extends LabelProvider {
+
+ public String getText(Object element) {
+ return ((TreeNode) element).getValue().toString();
+ }
+ }
+
+ private class MyTreeNode extends TreeNode {
+
+ public MyTreeNode(Object value) {
+ super(value);
+ }
+
+ public void setChildren(TreeNode[] children) {
+ super.setChildren(children);
+ for (int i = 0; i < children.length; i++) {
+ children[i].setParent(this);
+ }
+ }
+
+ }
+
+ public PShelfViewerSnippet1(Shell shell) {
+ PShelfViewer viewer = new PShelfViewer(shell, SWT.NONE,
+ new MyViewerFactory());
+
+ // Optionally, change the renderer
+ viewer.getPShelf().setRenderer(new RedmondShelfRenderer());
+
+ // Optionally, transfer selection between viewers
+ viewer.setTransferSelection(true);
+
+ myContentProvider = new MyContentProvider();
+ viewer.setContentProvider(myContentProvider);
+ myLabelProvider = new MyLabelProvider();
+ viewer.setLabelProvider(myLabelProvider);
+ createModel();
+ viewer.setInput(myModel);
+ }
+
+ private void createModel() {
+ myModel = new MyTreeNode("All");
+ TreeNode list = new MyTreeNode("List");
+ TreeNode tree = new MyTreeNode("Tree");
+ myModel.setChildren(new TreeNode[] { list, tree });
+
+ list.setChildren(new TreeNode[] {
+ new MyTreeNode("List item 1"), new MyTreeNode("List item 2")
+ });
+
+ MyTreeNode treeNode1 = new MyTreeNode("Tree item 1");
+ tree.setChildren(new TreeNode[] { treeNode1, new MyTreeNode("Tree item 2") });
+ treeNode1.setChildren(new TreeNode[] { new MyTreeNode("Sub item 1.1") });
+ }
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+
+ new PShelfViewerSnippet1(shell);
+
+ shell.setSize(200, 400);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/tablecombo/TableComboSnippet1.java b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/tablecombo/TableComboSnippet1.java
index 09439e1af..786df1da9 100644
--- a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/tablecombo/TableComboSnippet1.java
+++ b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/tablecombo/TableComboSnippet1.java
@@ -1,510 +1,510 @@
-/*******************************************************************************
- * Copyright (c) 2009 Marty Jones
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Marty Jones - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.nebula.snippets.tablecombo;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.nebula.widgets.tablecombo.TableCombo;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Show basic features of TableCombo
- *
- */
-public class TableComboSnippet1 {
-
- private static Font boldFont;
- private static Image testImage;
- private static Image test2Image;
- private static Image test3Image;
- private static Color darkRed;
- private static Color darkBlue;
- private static Color darkGreen;
- private static List modelList;
- private static Text listenerResults;
- private static Group listenerGroup;
-
- /**
- * @param args
- */
- public static void main(String[] args) {
-
- // get display.
- Display display = new Display ();
-
- // create bold and italic font.
- boldFont = new Font(display,"Arial",8, SWT.BOLD | SWT.ITALIC);
-
- // create images
- testImage = ImageDescriptor.createFromFile(TableComboSnippet1.class,
- "in_ec_ov_success_16x16.gif").createImage();
- test2Image = ImageDescriptor.createFromFile(TableComboSnippet1.class,
- "in_ec_ov_warning_16x16.gif").createImage();
- test3Image = ImageDescriptor.createFromFile(TableComboSnippet1.class,
- "invalid_build_tool_16x16.gif").createImage();
-
- // create colors
- darkRed = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED);
- darkBlue = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE);
- darkGreen = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN);
-
- // load the model list.
- modelList = loadModel();
-
- // create a new shell.
- Shell shell = new Shell (display);
- shell.setText("TableCombo Snippet 1");
- shell.setSize(600, 400);
- shell.setLayout(new GridLayout());
-
- // create group
- Group group = new Group(shell, SWT.NONE);
- group.setLayout(new GridLayout(2, false));
- group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
- group.setText("Sample Group");
-
- // create group
- listenerGroup = new Group(shell, SWT.NONE);
- listenerGroup.setLayout(new GridLayout(1, false));
- listenerGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
- listenerGroup.setText("Listener Results");
-
- listenerResults = new Text(listenerGroup, SWT.BORDER | SWT.MULTI);
- GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
- gd.heightHint = 30;
- listenerResults.setLayoutData(gd);
-
- ////////////////////////////////////////////////////////////////////////
- // Sample #1
- ////////////////////////////////////////////////////////////////////////
- Label label = new Label(group, SWT.NONE);
- label.setText("Single Column (Mimics Normal Combo Field):");
-
- // create TableCombo
- TableCombo tc = new TableCombo(group, SWT.BORDER | SWT.READ_ONLY);
- tc.setLayoutData(new GridData(125, SWT.DEFAULT));
-
- // load the dataset.
- loadSingleDataset(tc.getTable());
-
- // add listener
- tc.addSelectionListener(new ItemSelected(tc, "Sample1"));
-
- ////////////////////////////////////////////////////////////////////////
- // Sample #2
- ////////////////////////////////////////////////////////////////////////
-
- label = new Label(group, SWT.NONE);
- label.setText("Single Column (With Images)");
-
- // create TableCombo
- tc = new TableCombo(group, SWT.BORDER | SWT.READ_ONLY);
- tc.setLayoutData(new GridData(125, SWT.DEFAULT));
-
- // load the dataset.
- loadSingleDatasetWithImages(tc.getTable());
-
- // add listener
- tc.addSelectionListener(new ItemSelected(tc, "Sample2"));
- ////////////////////////////////////////////////////////////////////////
- // Sample #3
- ////////////////////////////////////////////////////////////////////////
- // create label
- label = new Label(group, SWT.NONE);
- label.setText("Two Columns:");
-
- // create TableCombo
- tc = new TableCombo(group, SWT.BORDER | SWT.READ_ONLY);
- tc.setLayoutData(new GridData(125, SWT.DEFAULT));
-
- // tell the TableCombo that I want 2 blank columns auto sized.
- tc.defineColumns(2);
-
- // set which column will be used for the selected item.
- tc.setDisplayColumnIndex(1);
-
- tc.setToolTipText("This is a tool tip.");
-
- // load the dataset.
- loadTwoColumnDataset(tc.getTable());
-
- // add listener
- tc.addSelectionListener(new ItemSelected(tc, "Sample3"));
-
- ////////////////////////////////////////////////////////////////////////
- // Sample #4
- ////////////////////////////////////////////////////////////////////////
- // create label
- label = new Label(group, SWT.NONE);
- label.setText("Two Columns (With Colors && Fonts):");
-
- // create TableCombo
- tc = new TableCombo(group, SWT.BORDER | SWT.READ_ONLY);
- tc.setLayoutData(new GridData(125, SWT.DEFAULT));
-
- // tell the TableCombo that I want 2 blank columns auto sized.
- tc.defineColumns(2);
-
- // set which column will be used for the selected item.
- tc.setDisplayColumnIndex(1);
-
- // load the dataset.
- loadTwoColumnDatasetWithColorsAndFonts(tc.getTable());
-
- // add listener
- tc.addSelectionListener(new ItemSelected(tc, "Sample4"));
-
- ////////////////////////////////////////////////////////////////////////
- // Sample #5
- ////////////////////////////////////////////////////////////////////////
- // create label
- label = new Label(group, SWT.NONE);
- label.setText("Three Columns (With Colors && Fonts && Header):");
-
- // create TableCombo
- tc = new TableCombo(group, SWT.BORDER | SWT.READ_ONLY);
- tc.setLayoutData(new GridData(125, SWT.DEFAULT));
-
- // tell the TableCombo that I want 3 columns autosized with the following column headers.
- tc.defineColumns(new String[] { "Id", "Description", "Computed"});
-
- // set which column will be used for the selected item.
- tc.setDisplayColumnIndex(2);
-
- // turn on the table header.
- tc.setShowTableHeader(true);
-
- // load the dataset.
- loadThreeColumnDatasetWithColorsAndFonts(tc.getTable());
-
- // add listener
- tc.addSelectionListener(new ItemSelected(tc, "Sample5"));
-
- ////////////////////////////////////////////////////////////////////////
- // Sample #6
- ////////////////////////////////////////////////////////////////////////
- // create label
- label = new Label(group, SWT.NONE);
- label.setText("Three Columns (First Column, Fixed Width):");
-
- // create TableCombo
- tc = new TableCombo(group, SWT.BORDER | SWT.READ_ONLY);
- tc.setLayoutData(new GridData(125, SWT.DEFAULT));
-
- // tell the TableCombo that I want 3 columns autosized with the following column headers.
- tc.defineColumns(new String[] { "Id", "Description", "Computed"},
- new int[] { 50 , SWT.DEFAULT, SWT.DEFAULT});
-
- // set which column will be used for the selected item.
- tc.setDisplayColumnIndex(2);
-
- // turn on the table header.
- tc.setShowTableHeader(true);
-
- // load the dataset.
- loadThreeColumnDatasetWithColorsAndFonts(tc.getTable());
-
- // add listener
- tc.addSelectionListener(new ItemSelected(tc, "Sample6"));
-
- ////////////////////////////////////////////////////////////////////////
- // Sample #7
- ////////////////////////////////////////////////////////////////////////
- // create label
- label = new Label(group, SWT.NONE);
- label.setText("Three Columns (With Table Width 75%):");
-
- // create TableCombo
- tc = new TableCombo(group, SWT.BORDER | SWT.READ_ONLY);
- tc.setLayoutData(new GridData(125, SWT.DEFAULT));
-
- // tell the TableCombo that I want 3 columns autosized with the following column headers.
- tc.defineColumns(new String[] { "Id", "Description", "Computed"});
-
- // set which column will be used for the selected item.
- tc.setDisplayColumnIndex(2);
-
- // turn on the table header.
- tc.setShowTableHeader(true);
-
- // load the dataset.
- loadThreeColumnDatasetWithColorsAndFonts(tc.getTable());
-
- // set the table width % to 75%
- tc.setTableWidthPercentage(75);
-
- // add listener
- tc.addSelectionListener(new ItemSelected(tc, "Sample7"));
-
- ////////////////////////////////////////////////////////////////////////
- // Sample #8
- ////////////////////////////////////////////////////////////////////////
- // create label
- label = new Label(group, SWT.NONE);
- label.setText("Keep popup open");
-
- // create TableCombo
- tc = new TableCombo(group, SWT.BORDER | SWT.READ_ONLY);
- tc.setLayoutData(new GridData(125, SWT.DEFAULT));
-
- // tell the TableCombo that I want 3 columns autosized with the following column headers.
- tc.defineColumns(new String[] { "Id", "Description", "Computed"});
-
- // set which column will be used for the selected item.
- tc.setDisplayColumnIndex(2);
-
- // turn on the table header.
- tc.setShowTableHeader(true);
-
- // load the dataset.
- loadThreeColumnDatasetWithColorsAndFonts(tc.getTable());
-
- // add listener
- tc.addSelectionListener(new ItemSelected(tc, "Sample8"));
-
- // keep popup open after selecting an element
- tc.setClosePopupAfterSelection(false);
-
- // open the shell.
- shell.open();
-
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
-
- // dispose of the font
- boldFont.dispose();
-
- // dispose images
- testImage.dispose();
- test2Image.dispose();
- test3Image.dispose();
-
- // dispose colors
- darkRed.dispose();
- darkBlue.dispose();
- darkGreen.dispose();
-
- // dispose display
- display.dispose ();
- }
-
- /**
- * load a list of rows with a single column
- * @return
- */
- private static List loadSingleDataset(Table table) {
- List rowList = new ArrayList();
-
- int total = (modelList == null ? 0 : modelList.size());
-
- for (int index=0; index < total; index++) {
- TableItem ti = new TableItem(table, SWT.NONE);
- Model model = (Model)modelList.get(index);
- ti.setText(model.getDescription());
- rowList.add(ti);
- }
-
- return rowList;
- }
-
- /**
- * load a list of rows with a single column that includes images
- * @return
- */
- private static List loadSingleDatasetWithImages(Table table) {
- List list = loadSingleDataset(table);
-
- int total = (list == null ? 0 : list.size());
-
- for (int index=0; index < total; index++) {
- TableItem ti = ((TableItem)(list.get(index)));
-
- if (index == 1 || index == 7 || index == 13 || index == 19) {
- ti.setImage(0, testImage);
- }
- else if (index == 3 || index == 9 || index == 15) {
- ti.setImage(0, test2Image);
- }
- else if (index == 5 || index == 11 || index == 17) {
- ti.setImage(0, test3Image);
- }
- }
-
- return list;
- }
-
- /**
- * load a list of rows with 2 columns in each row.
- * @return
- */
- private static List loadTwoColumnDataset(Table table) {
- List rowList = new ArrayList();
-
- int total = (modelList == null ? 0 : modelList.size());
-
- for (int index=0; index < total; index++) {
- TableItem ti = new TableItem(table, SWT.NONE);
- Model model = (Model)modelList.get(index);
- ti.setText(new String[] { String.valueOf(model.getId()), model.getDescription() });
- rowList.add(ti);
- }
-
- return rowList;
- }
-
- /**
- * load a list of rows with 2 columns that includes colors and fonts.
- * @return
- */
- private static List loadTwoColumnDatasetWithColorsAndFonts(Table table) {
- List list = loadTwoColumnDataset(table);
-
- int total = (list == null ? 0 : list.size());
-
- for (int index=0; index < total; index++) {
- TableItem ti = ((TableItem)(list.get(index)));
-
- if (index == 0 || index == 14) {
- ti.setForeground(darkRed);
- ti.setFont(boldFont);
- }
- else if (index == 4 || index == 19) {
- ti.setForeground(darkBlue);
- ti.setFont(boldFont);
- }
- else if (index == 9) {
- ti.setForeground(darkGreen);
- ti.setFont(boldFont);
- }
- }
-
- return list;
- }
-
- /**
- * load a list of rows with 3 columns
- * @return
- */
- private static List loadThreeColumnDataset(Table table) {
- List rowList = new ArrayList();
-
- int total = (modelList == null ? 0 : modelList.size());
-
- for (int index=0; index < total; index++) {
- TableItem ti = new TableItem(table, SWT.NONE);
- Model model = (Model)modelList.get(index);
- ti.setText(new String[] { String.valueOf(model.getId()), model.getDescription(),
- String.valueOf(model.getId()) + " - " + model.getDescription() });
- rowList.add(ti);
- }
-
- return rowList;
- }
-
- /**
- * load a list of rows with 3 columns that includes colors and fonts.
- * @return
- */
- private static List loadThreeColumnDatasetWithColorsAndFonts(Table table) {
- List list = loadThreeColumnDataset(table);
-
- int total = (list == null ? 0 : list.size());
-
- for (int index=0; index < total; index++) {
- TableItem ti = ((TableItem)(list.get(index)));
-
- if (index == 0 || index == 14) {
- ti.setForeground(darkRed);
- ti.setFont(boldFont);
- }
- else if (index == 4 || index == 19) {
- ti.setForeground(darkBlue);
- ti.setFont(boldFont);
- } else if (index==6) {
- ti.setForeground(table.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- ti.setBackground(table.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- } else if (index == 9) {
- ti.setForeground(darkGreen);
- ti.setFont(boldFont);
- }
- }
-
- return list;
- }
-
- /**
- * load the Model data.
- * @return
- */
- private static List loadModel() {
- List items = new ArrayList();
- items.add(new Model(1, "One"));
- items.add(new Model(2, "Two"));
- items.add(new Model(3, "Three"));
- items.add(new Model(4, "Four"));
- items.add(new Model(5, "Five"));
- items.add(new Model(6, "Six"));
- items.add(new Model(7, "Seven"));
- items.add(new Model(8, "Eight"));
- items.add(new Model(9, "Nine"));
- items.add(new Model(10, "Ten"));
- items.add(new Model(11, "Eleven"));
- items.add(new Model(12, "Twelve"));
- items.add(new Model(13, "Thirteen"));
- items.add(new Model(14, "Fourteen"));
- items.add(new Model(15, "Fiveteen"));
- items.add(new Model(16, "Sixteen"));
- items.add(new Model(17, "Seventeen"));
- items.add(new Model(18, "Eighteen"));
- items.add(new Model(19, "Nineteen"));
- items.add(new Model(20, "Twenty"));
-
- return items;
- }
-
- private static class ItemSelected extends SelectionAdapter {
-
- private TableCombo tc;
- private String text;
-
- public ItemSelected(TableCombo tc, String text) {
- this.tc = tc;
- this.text = text;
- }
-
- public void widgetSelected(SelectionEvent e) {
- listenerGroup.setText("Listener Results - (" + text + ")");
- listenerResults.setText(tc.getText() == null ? "null" : tc.getText());
- }
- }
-}
-
+/*******************************************************************************
+ * Copyright (c) 2009 Marty Jones
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Marty Jones - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.nebula.snippets.tablecombo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.nebula.widgets.tablecombo.TableCombo;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Show basic features of TableCombo
+ *
+ */
+public class TableComboSnippet1 {
+
+ private static Font boldFont;
+ private static Image testImage;
+ private static Image test2Image;
+ private static Image test3Image;
+ private static Color darkRed;
+ private static Color darkBlue;
+ private static Color darkGreen;
+ private static List modelList;
+ private static Text listenerResults;
+ private static Group listenerGroup;
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+
+ // get display.
+ Display display = new Display ();
+
+ // create bold and italic font.
+ boldFont = new Font(display,"Arial",8, SWT.BOLD | SWT.ITALIC);
+
+ // create images
+ testImage = ImageDescriptor.createFromFile(TableComboSnippet1.class,
+ "in_ec_ov_success_16x16.gif").createImage();
+ test2Image = ImageDescriptor.createFromFile(TableComboSnippet1.class,
+ "in_ec_ov_warning_16x16.gif").createImage();
+ test3Image = ImageDescriptor.createFromFile(TableComboSnippet1.class,
+ "invalid_build_tool_16x16.gif").createImage();
+
+ // create colors
+ darkRed = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED);
+ darkBlue = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE);
+ darkGreen = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN);
+
+ // load the model list.
+ modelList = loadModel();
+
+ // create a new shell.
+ Shell shell = new Shell (display);
+ shell.setText("TableCombo Snippet 1");
+ shell.setSize(600, 400);
+ shell.setLayout(new GridLayout());
+
+ // create group
+ Group group = new Group(shell, SWT.NONE);
+ group.setLayout(new GridLayout(2, false));
+ group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+ group.setText("Sample Group");
+
+ // create group
+ listenerGroup = new Group(shell, SWT.NONE);
+ listenerGroup.setLayout(new GridLayout(1, false));
+ listenerGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+ listenerGroup.setText("Listener Results");
+
+ listenerResults = new Text(listenerGroup, SWT.BORDER | SWT.MULTI);
+ GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
+ gd.heightHint = 30;
+ listenerResults.setLayoutData(gd);
+
+ ////////////////////////////////////////////////////////////////////////
+ // Sample #1
+ ////////////////////////////////////////////////////////////////////////
+ Label label = new Label(group, SWT.NONE);
+ label.setText("Single Column (Mimics Normal Combo Field):");
+
+ // create TableCombo
+ TableCombo tc = new TableCombo(group, SWT.BORDER | SWT.READ_ONLY);
+ tc.setLayoutData(new GridData(125, SWT.DEFAULT));
+
+ // load the dataset.
+ loadSingleDataset(tc.getTable());
+
+ // add listener
+ tc.addSelectionListener(new ItemSelected(tc, "Sample1"));
+
+ ////////////////////////////////////////////////////////////////////////
+ // Sample #2
+ ////////////////////////////////////////////////////////////////////////
+
+ label = new Label(group, SWT.NONE);
+ label.setText("Single Column (With Images)");
+
+ // create TableCombo
+ tc = new TableCombo(group, SWT.BORDER | SWT.READ_ONLY);
+ tc.setLayoutData(new GridData(125, SWT.DEFAULT));
+
+ // load the dataset.
+ loadSingleDatasetWithImages(tc.getTable());
+
+ // add listener
+ tc.addSelectionListener(new ItemSelected(tc, "Sample2"));
+ ////////////////////////////////////////////////////////////////////////
+ // Sample #3
+ ////////////////////////////////////////////////////////////////////////
+ // create label
+ label = new Label(group, SWT.NONE);
+ label.setText("Two Columns:");
+
+ // create TableCombo
+ tc = new TableCombo(group, SWT.BORDER | SWT.READ_ONLY);
+ tc.setLayoutData(new GridData(125, SWT.DEFAULT));
+
+ // tell the TableCombo that I want 2 blank columns auto sized.
+ tc.defineColumns(2);
+
+ // set which column will be used for the selected item.
+ tc.setDisplayColumnIndex(1);
+
+ tc.setToolTipText("This is a tool tip.");
+
+ // load the dataset.
+ loadTwoColumnDataset(tc.getTable());
+
+ // add listener
+ tc.addSelectionListener(new ItemSelected(tc, "Sample3"));
+
+ ////////////////////////////////////////////////////////////////////////
+ // Sample #4
+ ////////////////////////////////////////////////////////////////////////
+ // create label
+ label = new Label(group, SWT.NONE);
+ label.setText("Two Columns (With Colors && Fonts):");
+
+ // create TableCombo
+ tc = new TableCombo(group, SWT.BORDER | SWT.READ_ONLY);
+ tc.setLayoutData(new GridData(125, SWT.DEFAULT));
+
+ // tell the TableCombo that I want 2 blank columns auto sized.
+ tc.defineColumns(2);
+
+ // set which column will be used for the selected item.
+ tc.setDisplayColumnIndex(1);
+
+ // load the dataset.
+ loadTwoColumnDatasetWithColorsAndFonts(tc.getTable());
+
+ // add listener
+ tc.addSelectionListener(new ItemSelected(tc, "Sample4"));
+
+ ////////////////////////////////////////////////////////////////////////
+ // Sample #5
+ ////////////////////////////////////////////////////////////////////////
+ // create label
+ label = new Label(group, SWT.NONE);
+ label.setText("Three Columns (With Colors && Fonts && Header):");
+
+ // create TableCombo
+ tc = new TableCombo(group, SWT.BORDER | SWT.READ_ONLY);
+ tc.setLayoutData(new GridData(125, SWT.DEFAULT));
+
+ // tell the TableCombo that I want 3 columns autosized with the following column headers.
+ tc.defineColumns(new String[] { "Id", "Description", "Computed"});
+
+ // set which column will be used for the selected item.
+ tc.setDisplayColumnIndex(2);
+
+ // turn on the table header.
+ tc.setShowTableHeader(true);
+
+ // load the dataset.
+ loadThreeColumnDatasetWithColorsAndFonts(tc.getTable());
+
+ // add listener
+ tc.addSelectionListener(new ItemSelected(tc, "Sample5"));
+
+ ////////////////////////////////////////////////////////////////////////
+ // Sample #6
+ ////////////////////////////////////////////////////////////////////////
+ // create label
+ label = new Label(group, SWT.NONE);
+ label.setText("Three Columns (First Column, Fixed Width):");
+
+ // create TableCombo
+ tc = new TableCombo(group, SWT.BORDER | SWT.READ_ONLY);
+ tc.setLayoutData(new GridData(125, SWT.DEFAULT));
+
+ // tell the TableCombo that I want 3 columns autosized with the following column headers.
+ tc.defineColumns(new String[] { "Id", "Description", "Computed"},
+ new int[] { 50 , SWT.DEFAULT, SWT.DEFAULT});
+
+ // set which column will be used for the selected item.
+ tc.setDisplayColumnIndex(2);
+
+ // turn on the table header.
+ tc.setShowTableHeader(true);
+
+ // load the dataset.
+ loadThreeColumnDatasetWithColorsAndFonts(tc.getTable());
+
+ // add listener
+ tc.addSelectionListener(new ItemSelected(tc, "Sample6"));
+
+ ////////////////////////////////////////////////////////////////////////
+ // Sample #7
+ ////////////////////////////////////////////////////////////////////////
+ // create label
+ label = new Label(group, SWT.NONE);
+ label.setText("Three Columns (With Table Width 75%):");
+
+ // create TableCombo
+ tc = new TableCombo(group, SWT.BORDER | SWT.READ_ONLY);
+ tc.setLayoutData(new GridData(125, SWT.DEFAULT));
+
+ // tell the TableCombo that I want 3 columns autosized with the following column headers.
+ tc.defineColumns(new String[] { "Id", "Description", "Computed"});
+
+ // set which column will be used for the selected item.
+ tc.setDisplayColumnIndex(2);
+
+ // turn on the table header.
+ tc.setShowTableHeader(true);
+
+ // load the dataset.
+ loadThreeColumnDatasetWithColorsAndFonts(tc.getTable());
+
+ // set the table width % to 75%
+ tc.setTableWidthPercentage(75);
+
+ // add listener
+ tc.addSelectionListener(new ItemSelected(tc, "Sample7"));
+
+ ////////////////////////////////////////////////////////////////////////
+ // Sample #8
+ ////////////////////////////////////////////////////////////////////////
+ // create label
+ label = new Label(group, SWT.NONE);
+ label.setText("Keep popup open");
+
+ // create TableCombo
+ tc = new TableCombo(group, SWT.BORDER | SWT.READ_ONLY);
+ tc.setLayoutData(new GridData(125, SWT.DEFAULT));
+
+ // tell the TableCombo that I want 3 columns autosized with the following column headers.
+ tc.defineColumns(new String[] { "Id", "Description", "Computed"});
+
+ // set which column will be used for the selected item.
+ tc.setDisplayColumnIndex(2);
+
+ // turn on the table header.
+ tc.setShowTableHeader(true);
+
+ // load the dataset.
+ loadThreeColumnDatasetWithColorsAndFonts(tc.getTable());
+
+ // add listener
+ tc.addSelectionListener(new ItemSelected(tc, "Sample8"));
+
+ // keep popup open after selecting an element
+ tc.setClosePopupAfterSelection(false);
+
+ // open the shell.
+ shell.open();
+
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+
+ // dispose of the font
+ boldFont.dispose();
+
+ // dispose images
+ testImage.dispose();
+ test2Image.dispose();
+ test3Image.dispose();
+
+ // dispose colors
+ darkRed.dispose();
+ darkBlue.dispose();
+ darkGreen.dispose();
+
+ // dispose display
+ display.dispose ();
+ }
+
+ /**
+ * load a list of rows with a single column
+ * @return
+ */
+ private static List loadSingleDataset(Table table) {
+ List rowList = new ArrayList();
+
+ int total = (modelList == null ? 0 : modelList.size());
+
+ for (int index=0; index < total; index++) {
+ TableItem ti = new TableItem(table, SWT.NONE);
+ Model model = (Model)modelList.get(index);
+ ti.setText(model.getDescription());
+ rowList.add(ti);
+ }
+
+ return rowList;
+ }
+
+ /**
+ * load a list of rows with a single column that includes images
+ * @return
+ */
+ private static List loadSingleDatasetWithImages(Table table) {
+ List list = loadSingleDataset(table);
+
+ int total = (list == null ? 0 : list.size());
+
+ for (int index=0; index < total; index++) {
+ TableItem ti = ((TableItem)(list.get(index)));
+
+ if (index == 1 || index == 7 || index == 13 || index == 19) {
+ ti.setImage(0, testImage);
+ }
+ else if (index == 3 || index == 9 || index == 15) {
+ ti.setImage(0, test2Image);
+ }
+ else if (index == 5 || index == 11 || index == 17) {
+ ti.setImage(0, test3Image);
+ }
+ }
+
+ return list;
+ }
+
+ /**
+ * load a list of rows with 2 columns in each row.
+ * @return
+ */
+ private static List loadTwoColumnDataset(Table table) {
+ List rowList = new ArrayList();
+
+ int total = (modelList == null ? 0 : modelList.size());
+
+ for (int index=0; index < total; index++) {
+ TableItem ti = new TableItem(table, SWT.NONE);
+ Model model = (Model)modelList.get(index);
+ ti.setText(new String[] { String.valueOf(model.getId()), model.getDescription() });
+ rowList.add(ti);
+ }
+
+ return rowList;
+ }
+
+ /**
+ * load a list of rows with 2 columns that includes colors and fonts.
+ * @return
+ */
+ private static List loadTwoColumnDatasetWithColorsAndFonts(Table table) {
+ List list = loadTwoColumnDataset(table);
+
+ int total = (list == null ? 0 : list.size());
+
+ for (int index=0; index < total; index++) {
+ TableItem ti = ((TableItem)(list.get(index)));
+
+ if (index == 0 || index == 14) {
+ ti.setForeground(darkRed);
+ ti.setFont(boldFont);
+ }
+ else if (index == 4 || index == 19) {
+ ti.setForeground(darkBlue);
+ ti.setFont(boldFont);
+ }
+ else if (index == 9) {
+ ti.setForeground(darkGreen);
+ ti.setFont(boldFont);
+ }
+ }
+
+ return list;
+ }
+
+ /**
+ * load a list of rows with 3 columns
+ * @return
+ */
+ private static List loadThreeColumnDataset(Table table) {
+ List rowList = new ArrayList();
+
+ int total = (modelList == null ? 0 : modelList.size());
+
+ for (int index=0; index < total; index++) {
+ TableItem ti = new TableItem(table, SWT.NONE);
+ Model model = (Model)modelList.get(index);
+ ti.setText(new String[] { String.valueOf(model.getId()), model.getDescription(),
+ String.valueOf(model.getId()) + " - " + model.getDescription() });
+ rowList.add(ti);
+ }
+
+ return rowList;
+ }
+
+ /**
+ * load a list of rows with 3 columns that includes colors and fonts.
+ * @return
+ */
+ private static List loadThreeColumnDatasetWithColorsAndFonts(Table table) {
+ List list = loadThreeColumnDataset(table);
+
+ int total = (list == null ? 0 : list.size());
+
+ for (int index=0; index < total; index++) {
+ TableItem ti = ((TableItem)(list.get(index)));
+
+ if (index == 0 || index == 14) {
+ ti.setForeground(darkRed);
+ ti.setFont(boldFont);
+ }
+ else if (index == 4 || index == 19) {
+ ti.setForeground(darkBlue);
+ ti.setFont(boldFont);
+ } else if (index==6) {
+ ti.setForeground(table.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ ti.setBackground(table.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ } else if (index == 9) {
+ ti.setForeground(darkGreen);
+ ti.setFont(boldFont);
+ }
+ }
+
+ return list;
+ }
+
+ /**
+ * load the Model data.
+ * @return
+ */
+ private static List loadModel() {
+ List items = new ArrayList();
+ items.add(new Model(1, "One"));
+ items.add(new Model(2, "Two"));
+ items.add(new Model(3, "Three"));
+ items.add(new Model(4, "Four"));
+ items.add(new Model(5, "Five"));
+ items.add(new Model(6, "Six"));
+ items.add(new Model(7, "Seven"));
+ items.add(new Model(8, "Eight"));
+ items.add(new Model(9, "Nine"));
+ items.add(new Model(10, "Ten"));
+ items.add(new Model(11, "Eleven"));
+ items.add(new Model(12, "Twelve"));
+ items.add(new Model(13, "Thirteen"));
+ items.add(new Model(14, "Fourteen"));
+ items.add(new Model(15, "Fiveteen"));
+ items.add(new Model(16, "Sixteen"));
+ items.add(new Model(17, "Seventeen"));
+ items.add(new Model(18, "Eighteen"));
+ items.add(new Model(19, "Nineteen"));
+ items.add(new Model(20, "Twenty"));
+
+ return items;
+ }
+
+ private static class ItemSelected extends SelectionAdapter {
+
+ private TableCombo tc;
+ private String text;
+
+ public ItemSelected(TableCombo tc, String text) {
+ this.tc = tc;
+ this.text = text;
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ listenerGroup.setText("Listener Results - (" + text + ")");
+ listenerResults.setText(tc.getText() == null ? "null" : tc.getText());
+ }
+ }
+}
+
diff --git a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/visualization/Readme b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/visualization/Readme
index 8dec9311b..dae76bf52 100644
--- a/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/visualization/Readme
+++ b/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/visualization/Readme
@@ -1,3 +1,3 @@
-Please don't modify code here!
-The snippets here are copied from visualization plugins, which will overwritten regularly by coping them from visualization plugins.
+Please don't modify code here!
+The snippets here are copied from visualization plugins, which will overwritten regularly by coping them from visualization plugins.
\ No newline at end of file
diff --git a/releng/org.eclipse.nebula.examples.release.feature/feature.xml b/releng/org.eclipse.nebula.examples.release.feature/feature.xml
index 0f5f191e3..8c083e497 100644
--- a/releng/org.eclipse.nebula.examples.release.feature/feature.xml
+++ b/releng/org.eclipse.nebula.examples.release.feature/feature.xml
@@ -1,496 +1,496 @@
-
-
-
-
- This feature contains the examples for the examples view.
-
-
-
- Copyright 2015, Weltevree beheer B.V. and others
-
-
-
- %license
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ This feature contains the examples for the examples view.
+
+
+
+ Copyright 2015, Weltevree beheer B.V. and others
+
+
+
+ %license
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/releng/org.eclipse.nebula.examples.webstart/rootfiles/nebula.jnlp b/releng/org.eclipse.nebula.examples.webstart/rootfiles/nebula.jnlp
index 1427f91ac..46f34aacb 100644
--- a/releng/org.eclipse.nebula.examples.webstart/rootfiles/nebula.jnlp
+++ b/releng/org.eclipse.nebula.examples.webstart/rootfiles/nebula.jnlp
@@ -1,49 +1,49 @@
-
-
-
- Nebula Examples
- Eclipse Nebula Project
-
-
-
-
-
-
-
- -nosplash
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ Nebula Examples
+ Eclipse Nebula Project
+
+
+
+
+
+
+
+ -nosplash
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/releng/org.eclipse.nebula.feature/feature.xml b/releng/org.eclipse.nebula.feature/feature.xml
index 2373b7598..77271623e 100644
--- a/releng/org.eclipse.nebula.feature/feature.xml
+++ b/releng/org.eclipse.nebula.feature/feature.xml
@@ -1,264 +1,264 @@
-
-
-
-
- This feature contains the Eclipse Nebula widgets.
-
-
-
- %license
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ This feature contains the Eclipse Nebula widgets.
+
+
+
+ %license
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/releng/org.eclipse.nebula.feature/javadoc.xml b/releng/org.eclipse.nebula.feature/javadoc.xml
index 8be72946e..fa16b7fbc 100644
--- a/releng/org.eclipse.nebula.feature/javadoc.xml
+++ b/releng/org.eclipse.nebula.feature/javadoc.xml
@@ -1,6 +1,6 @@
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/releng/org.eclipse.nebula.nebula-parent/pom.xml b/releng/org.eclipse.nebula.nebula-parent/pom.xml
index ad3f5bd8c..09f50993f 100644
--- a/releng/org.eclipse.nebula.nebula-parent/pom.xml
+++ b/releng/org.eclipse.nebula.nebula-parent/pom.xml
@@ -1,464 +1,464 @@
-
-
-
- 4.0.0
- org.eclipse.nebula
- nebula-parent
- 1.0.0-SNAPSHOT
- pom
-
-
- 4.0.4
- ${tycho-version}
- 5.10.0
- 3.0.5
- 3.6.0
- 3.6.3
- 3.3.1
- 1.3.3
- 3.9.0
- 4.13.2
- 0.8.9
- 5.2.0
-
- https://download.eclipse.org/releases/latest
-
- 11
- 11
-
-
- jacoco
- reuseReports
-
- ../target/jacoco.exec
-
- scm:git:https://github.com/eclipse/nebula/
-
-
- https://download.eclipse.org/releases/latest
- https://download.eclipse.org/justj/tools/updates/nightly/latest
- genie.nebula
-
-
- updates
- yyyyMMddHHmm
- http://www.example.com/
- nightly
-
-
-
-
-
-
- org.eclipse.tycho
- tycho-packaging-plugin
- ${tycho-version}
-
-
- true
-
-
-
-
- org.eclipse.tycho.extras
- tycho-sourceref-jgit
- ${tycho-extras-version}
-
-
-
-
-
- org.eclipse.tycho
- tycho-maven-plugin
- ${tycho-version}
- true
-
-
-
- org.eclipse.tycho
- target-platform-configuration
- ${tycho-version}
-
- JavaSE-17
- consider
-
-
- linux
- gtk
- x86_64
-
-
- win32
- win32
- x86_64
-
-
- macosx
- cocoa
- x86_64
-
-
-
-
-
-
- org.jacoco
- jacoco-maven-plugin
- ${jacoco-version}
-
-
-
- prepare-agent
-
-
-
- ${sonar.jacoco.reportPath}
-
- *.nebula.*
-
-
- true
-
-
-
-
-
-
-
- org.eclipse.tycho
- tycho-surefire-plugin
- ${tycho-version}
-
- true
- ${tycho.testArgLine} -Xmx512m -Djava.awt.headless=true ${tests.vmargs}
-
-
-
-
- org.eclipse.tycho
- tycho-source-plugin
-
-
- plugin-source
-
- plugin-source
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- ${mjd-version}
-
-
-
-
-
-
- org.eclipse.tycho
- tycho-compiler-plugin
- ${tycho-version}
-
- UTF-8
-
-
-
- org.eclipse.tycho
- tycho-source-plugin
- ${tycho-version}
-
-
- org.apache.maven.plugins
- maven-resources-plugin
- ${mrp-version}
-
- ISO-8859-1
-
-
-
- org.codehaus.mojo
- findbugs-maven-plugin
- ${findbugs-version}
-
- true
- false
-
-
-
-
- check
-
-
-
-
-
- org.apache.maven.plugins
- maven-pmd-plugin
- ${pmd-version}
-
- utf-8
- 100
- 1.5
- xml
- false
-
-
-
-
- cpd-check
-
-
-
-
-
- org.apache.maven.plugins
- maven-assembly-plugin
- ${map-version}
-
-
-
-
-
-
-
-
- org.mockito
- mockito-core
- ${mockito-version}
-
-
-
-
-
-
- junit
- junit
- ${junit-version}
- test
-
-
-
-
-
-
- tycho-snapshots
- https://oss.sonatype.org/content/groups/public/
-
- false
-
-
- true
-
-
-
-
-
-
- projects
- p2
- ${target-platform}
-
-
-
-
-
-
- nebula-dev Mailing List
- nebula-dev@eclipse.org
- https://dev.eclipse.org/mailman/listinfo/nebula-dev
- https://dev.eclipse.org/mailman/listinfo/nebula-dev
- https://dev.eclipse.org/mhonarc/lists/nebula-dev
-
-
-
-
- https://github.com/eclipse/nebula/issues
- Github
-
-
-
- https://github.com/eclipse/nebula
-
-
-
-
- Eclipse Public License 2.0
-
- All rights reserved.
-
- This program and the accompanying materials
- are made available under the terms of the Eclipse Public License
- 2.0
- which accompanies this distribution, and is available at
- https://www.eclipse.org/legal/epl-2.0/
-
- SPDX-License-Identifier: EPL-2.0
-
- https://www.eclipse.org/legal/epl-2.0/
-
-
-
-
-
-
-
- ../../widgets/badgedlabel
- ../../widgets/carousel
- ../../widgets/cdatetime
- ../../widgets/chips
- ../../widgets/compositetable
- ../../widgets/ctreecombo
- ../../widgets/cwt
- ../../widgets/effects
- ../../widgets/floatingtext
- ../../widgets/fontawesome
- ../../widgets/formattedtext
- ../../widgets/gallery
- ../../widgets/ganttchart
- ../../widgets/geomap
- ../../widgets/grid
- ../../widgets/led
- ../../widgets/nebulaslider
- ../../widgets/opal/breadcrumb
- ../../widgets/opal/calculator
- ../../widgets/opal/checkboxgroup
- ../../widgets/opal/columnbrowser
- ../../widgets/opal/commons
- ../../widgets/opal/dialog
- ../../widgets/opal/duallist
- ../../widgets/opal/header
- ../../widgets/opal/heapmanager
- ../../widgets/opal/horizontalspinner
- ../../widgets/opal/launcher
- ../../widgets/opal/logindialog
- ../../widgets/opal/multichoice
- ../../widgets/opal/notifier
- ../../widgets/opal/panels
- ../../widgets/opal/preferencewindow
- ../../widgets/opal/promptsupport
- ../../widgets/opal/propertytable
- ../../widgets/opal/rangeslider
- ../../widgets/opal/roundedtoolbar
- ../../widgets/opal/starrating
- ../../widgets/opal/switchbutton
- ../../widgets/opal/textassist
- ../../widgets/opal/tipoftheday
- ../../widgets/opal/titledseparator
- ../../widgets/oscilloscope
- ../../widgets/paperclips
- ../../widgets/passwordrevealer
- ../../widgets/pgroup
- ../../widgets/progresscircle
- ../../widgets/pshelf
- ../../widgets/richtext
- ../../widgets/roundedcheckbox
- ../../widgets/roundedswitch
- ../../widgets/segmentedbar
- ../../widgets/splitbutton
- ../../widgets/stepbar
- ../../widgets/tablecombo
- ../../widgets/tiles
- ../../widgets/treemapper
- ../../widgets/visualization
- ../../widgets/xviewer
-
-
-
- ../../widgets/calendarcombo
- ../../widgets/collapsiblebuttons
- ../../widgets/datechooser
- ../../widgets/pagination
- ../../widgets/picture
- ../../widgets/radiogroup
- ../../widgets/timeline
-
- ../../examples/org.eclipse.nebula.examples
- ../../examples/org.eclipse.nebula.examples.feature
-
-
-
- ../org.eclipse.nebula.feature
- ../org.eclipse.nebula.examples.release.feature
-
- ../org.eclipse.nebula.incubation.feature
- ../org.eclipse.nebula.examples.incubation.feature
-
- ../org.eclipse.nebula.site
-
-
-
-
- promote
-
- ../org.eclipse.nebula.site/promotion
-
-
-
-
- static-checks
-
-
-
- org.codehaus.mojo
- findbugs-maven-plugin
-
-
- org.apache.maven.plugins
- maven-pmd-plugin
-
-
-
-
-
-
- build-server
-
-
-
- org.eclipse.cbi.maven.plugins
- eclipse-jarsigner-plugin
- ${ejp-version}
-
-
- sign
- verify
-
- sign
-
-
-
-
-
-
-
-
-
- cbi
- https://repo.eclipse.org/content/repositories/cbi-releases/
-
- true
-
-
- false
-
-
-
-
-
-
-
-
+
+
+
+ 4.0.0
+ org.eclipse.nebula
+ nebula-parent
+ 1.0.0-SNAPSHOT
+ pom
+
+
+ 4.0.4
+ ${tycho-version}
+ 5.10.0
+ 3.0.5
+ 3.6.0
+ 3.6.3
+ 3.3.1
+ 1.3.3
+ 3.9.0
+ 4.13.2
+ 0.8.9
+ 5.2.0
+
+ https://download.eclipse.org/releases/latest
+
+ 11
+ 11
+
+
+ jacoco
+ reuseReports
+
+ ../target/jacoco.exec
+
+ scm:git:https://github.com/eclipse/nebula/
+
+
+ https://download.eclipse.org/releases/latest
+ https://download.eclipse.org/justj/tools/updates/nightly/latest
+ genie.nebula
+
+
+ updates
+ yyyyMMddHHmm
+ http://www.example.com/
+ nightly
+
+
+
+
+
+
+ org.eclipse.tycho
+ tycho-packaging-plugin
+ ${tycho-version}
+
+
+ true
+
+
+
+
+ org.eclipse.tycho.extras
+ tycho-sourceref-jgit
+ ${tycho-extras-version}
+
+
+
+
+
+ org.eclipse.tycho
+ tycho-maven-plugin
+ ${tycho-version}
+ true
+
+
+
+ org.eclipse.tycho
+ target-platform-configuration
+ ${tycho-version}
+
+ JavaSE-17
+ consider
+
+
+ linux
+ gtk
+ x86_64
+
+
+ win32
+ win32
+ x86_64
+
+
+ macosx
+ cocoa
+ x86_64
+
+
+
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+ ${jacoco-version}
+
+
+
+ prepare-agent
+
+
+
+ ${sonar.jacoco.reportPath}
+
+ *.nebula.*
+
+
+ true
+
+
+
+
+
+
+
+ org.eclipse.tycho
+ tycho-surefire-plugin
+ ${tycho-version}
+
+ true
+ ${tycho.testArgLine} -Xmx512m -Djava.awt.headless=true ${tests.vmargs}
+
+
+
+
+ org.eclipse.tycho
+ tycho-source-plugin
+
+
+ plugin-source
+
+ plugin-source
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ ${mjd-version}
+
+
+
+
+
+
+ org.eclipse.tycho
+ tycho-compiler-plugin
+ ${tycho-version}
+
+ UTF-8
+
+
+
+ org.eclipse.tycho
+ tycho-source-plugin
+ ${tycho-version}
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ ${mrp-version}
+
+ ISO-8859-1
+
+
+
+ org.codehaus.mojo
+ findbugs-maven-plugin
+ ${findbugs-version}
+
+ true
+ false
+
+
+
+
+ check
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-pmd-plugin
+ ${pmd-version}
+
+ utf-8
+ 100
+ 1.5
+ xml
+ false
+
+
+
+
+ cpd-check
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+ ${map-version}
+
+
+
+
+
+
+
+
+ org.mockito
+ mockito-core
+ ${mockito-version}
+
+
+
+
+
+
+ junit
+ junit
+ ${junit-version}
+ test
+
+
+
+
+
+
+ tycho-snapshots
+ https://oss.sonatype.org/content/groups/public/
+
+ false
+
+
+ true
+
+
+
+
+
+
+ projects
+ p2
+ ${target-platform}
+
+
+
+
+
+
+ nebula-dev Mailing List
+ nebula-dev@eclipse.org
+ https://dev.eclipse.org/mailman/listinfo/nebula-dev
+ https://dev.eclipse.org/mailman/listinfo/nebula-dev
+ https://dev.eclipse.org/mhonarc/lists/nebula-dev
+
+
+
+
+ https://github.com/eclipse/nebula/issues
+ Github
+
+
+
+ https://github.com/eclipse/nebula
+
+
+
+
+ Eclipse Public License 2.0
+
+ All rights reserved.
+
+ This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License
+ 2.0
+ which accompanies this distribution, and is available at
+ https://www.eclipse.org/legal/epl-2.0/
+
+ SPDX-License-Identifier: EPL-2.0
+
+ https://www.eclipse.org/legal/epl-2.0/
+
+
+
+
+
+
+
+ ../../widgets/badgedlabel
+ ../../widgets/carousel
+ ../../widgets/cdatetime
+ ../../widgets/chips
+ ../../widgets/compositetable
+ ../../widgets/ctreecombo
+ ../../widgets/cwt
+ ../../widgets/effects
+ ../../widgets/floatingtext
+ ../../widgets/fontawesome
+ ../../widgets/formattedtext
+ ../../widgets/gallery
+ ../../widgets/ganttchart
+ ../../widgets/geomap
+ ../../widgets/grid
+ ../../widgets/led
+ ../../widgets/nebulaslider
+ ../../widgets/opal/breadcrumb
+ ../../widgets/opal/calculator
+ ../../widgets/opal/checkboxgroup
+ ../../widgets/opal/columnbrowser
+ ../../widgets/opal/commons
+ ../../widgets/opal/dialog
+ ../../widgets/opal/duallist
+ ../../widgets/opal/header
+ ../../widgets/opal/heapmanager
+ ../../widgets/opal/horizontalspinner
+ ../../widgets/opal/launcher
+ ../../widgets/opal/logindialog
+ ../../widgets/opal/multichoice
+ ../../widgets/opal/notifier
+ ../../widgets/opal/panels
+ ../../widgets/opal/preferencewindow
+ ../../widgets/opal/promptsupport
+ ../../widgets/opal/propertytable
+ ../../widgets/opal/rangeslider
+ ../../widgets/opal/roundedtoolbar
+ ../../widgets/opal/starrating
+ ../../widgets/opal/switchbutton
+ ../../widgets/opal/textassist
+ ../../widgets/opal/tipoftheday
+ ../../widgets/opal/titledseparator
+ ../../widgets/oscilloscope
+ ../../widgets/paperclips
+ ../../widgets/passwordrevealer
+ ../../widgets/pgroup
+ ../../widgets/progresscircle
+ ../../widgets/pshelf
+ ../../widgets/richtext
+ ../../widgets/roundedcheckbox
+ ../../widgets/roundedswitch
+ ../../widgets/segmentedbar
+ ../../widgets/splitbutton
+ ../../widgets/stepbar
+ ../../widgets/tablecombo
+ ../../widgets/tiles
+ ../../widgets/treemapper
+ ../../widgets/visualization
+ ../../widgets/xviewer
+
+
+
+ ../../widgets/calendarcombo
+ ../../widgets/collapsiblebuttons
+ ../../widgets/datechooser
+ ../../widgets/pagination
+ ../../widgets/picture
+ ../../widgets/radiogroup
+ ../../widgets/timeline
+
+ ../../examples/org.eclipse.nebula.examples
+ ../../examples/org.eclipse.nebula.examples.feature
+
+
+
+ ../org.eclipse.nebula.feature
+ ../org.eclipse.nebula.examples.release.feature
+
+ ../org.eclipse.nebula.incubation.feature
+ ../org.eclipse.nebula.examples.incubation.feature
+
+ ../org.eclipse.nebula.site
+
+
+
+
+ promote
+
+ ../org.eclipse.nebula.site/promotion
+
+
+
+
+ static-checks
+
+
+
+ org.codehaus.mojo
+ findbugs-maven-plugin
+
+
+ org.apache.maven.plugins
+ maven-pmd-plugin
+
+
+
+
+
+
+ build-server
+
+
+
+ org.eclipse.cbi.maven.plugins
+ eclipse-jarsigner-plugin
+ ${ejp-version}
+
+
+ sign
+ verify
+
+ sign
+
+
+
+
+
+
+
+
+
+ cbi
+ https://repo.eclipse.org/content/repositories/cbi-releases/
+
+ true
+
+
+ false
+
+
+
+
+
+
+
+
diff --git a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.feature/.project b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.feature/.project
index e26ed04f5..cb225ebc7 100644
--- a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.feature/.project
+++ b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.feature/.project
@@ -1,17 +1,17 @@
-
-
- org.eclipse.nebula.widgets.badgedlabel.feature
-
-
-
-
-
- org.eclipse.pde.FeatureBuilder
-
-
-
-
-
- org.eclipse.pde.FeatureNature
-
-
+
+
+ org.eclipse.nebula.widgets.badgedlabel.feature
+
+
+
+
+
+ org.eclipse.pde.FeatureBuilder
+
+
+
+
+
+ org.eclipse.pde.FeatureNature
+
+
diff --git a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.feature/build.properties b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.feature/build.properties
index f9fa03db0..b40f03f72 100644
--- a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.feature/build.properties
+++ b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.feature/build.properties
@@ -1,4 +1,4 @@
-bin.includes = feature.xml,\
- epl-2.0.html,\
- feature.properties,\
- license.html
+bin.includes = feature.xml,\
+ epl-2.0.html,\
+ feature.properties,\
+ license.html
diff --git a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.feature/feature.properties b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.feature/feature.properties
index ce26a1b1f..9dd2dd546 100644
--- a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.feature/feature.properties
+++ b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.feature/feature.properties
@@ -1,148 +1,148 @@
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-licenseURL=license.html
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-license=\
-Eclipse Foundation Software User Agreement\n\
-\n\
-November 22, 2017\n\
-\n\
-Usage Of Content\n\
-\n\
-THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION\n\
-AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF\n\
-THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE\n\
-TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
-BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED\n\
-BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE\n\
-AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY\n\
-APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU\n\
-MAY NOT USE THE CONTENT.\n\
-\n\
-Applicable Licenses\n\
-\n\
-Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\
-is provided to you under the terms and conditions of the Eclipse Public License\n\
-Version 2.0 ("EPL"). A copy of the EPL is provided with this Content and is also\n\
-available at http://www.eclipse.org/legal/epl-2.0. For purposes of the EPL,\n\
-"Program" will mean the Content.\n\
-\n\
-Content includes, but is not limited to, source code, object code, documentation\n\
-and other files maintained in the Eclipse Foundation source code repository\n\
-("Repository") in software modules ("Modules") and made available as\n\
-downloadable archives ("Downloads").\n\
-\n\
-- Content may be structured and packaged into modules to facilitate\n\
- delivering, extending, and upgrading the Content. Typical modules may\n\
- include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and\n\
- features ("Features").\n\
-- Each Plug-in or Fragment may be packaged as a sub-directory or JAR\n\
- (Java\u2122 ARchive) in a directory named "plugins".\n\
-- A Feature is a bundle of one or more Plug-ins and/or Fragments and\n\
- associated material. Each Feature may be packaged as a sub-directory in a\n\
- directory named "features". Within a Feature, files named "feature.xml" may\n\
- contain a list of the names and version numbers of the Plug-ins and/or\n\
- Fragments associated with that Feature.\n\
-- Features may also include other Features ("Included Features"). Within a\n\
- Feature, files named "feature.xml" may contain a list of the names and\n\
- version numbers of Included Features.\n\
-\n\
-The terms and conditions governing Plug-ins and Fragments should be contained in\n\
-files named "about.html" ("Abouts"). The terms and conditions governing Features\n\
-and Included Features should be contained in files named "license.html"\n\
-("Feature Licenses"). Abouts and Feature Licenses may be located in any\n\
-directory of a Download or Module including, but not limited to the following\n\
-locations:\n\
-\n\
-- The top-level (root) directory\n\
-- Plug-in and Fragment directories\n\
-- Inside Plug-ins and Fragments packaged as JARs\n\
-- Sub-directories of the directory named "src" of certain Plug-ins\n\
-- Feature directories\n\
-\n\
-Note: if a Feature made available by the Eclipse Foundation is installed using\n\
-the Provisioning Technology (as defined below), you must agree to a license\n\
-("Feature Update License") during the installation process. If the Feature\n\
-contains Included Features, the Feature Update License should either provide you\n\
-with the terms and conditions governing the Included Features or inform you\n\
-where you can locate them. Feature Update Licenses may be found in the "license"\n\
-property of files named "feature.properties" found within a Feature. Such\n\
-Abouts, Feature Licenses, and Feature Update Licenses contain the terms and\n\
-conditions (or references to such terms and conditions) that govern your use of\n\
-the associated Content in that directory.\n\
-\n\
-THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL\n\
-OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE\n\
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
-\n\
-- Eclipse Public License Version 1.0 (available at\n\
- http://www.eclipse.org/legal/epl-v10.html)\n\
-- Eclipse Distribution License Version 1.0 (available at\n\
- http://www.eclipse.org/licenses/edl-v1.0.html)\n\
-- Common Public License Version 1.0 (available at\n\
- http://www.eclipse.org/legal/cpl-v10.html)\n\
-- Apache Software License 1.1 (available at\n\
- http://www.apache.org/licenses/LICENSE)\n\
-- Apache Software License 2.0 (available at\n\
- http://www.apache.org/licenses/LICENSE-2.0)\n\
-- Mozilla Public License Version 1.1 (available at\n\
- http://www.mozilla.org/MPL/MPL-1.1.html)\n\
-\n\
-IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO\n\
-USE OF THE CONTENT. If no About, Feature License, or Feature Update License is\n\
-provided, please contact the Eclipse Foundation to determine what terms and\n\
-conditions govern that particular Content.\n\
-\n\
-Use of Provisioning Technology\n\
-\n\
-The Eclipse Foundation makes available provisioning software, examples of which\n\
-include, but are not limited to, p2 and the Eclipse Update Manager\n\
-("Provisioning Technology") for the purpose of allowing users to install\n\
-software, documentation, information and/or other materials (collectively\n\
-"Installable Software"). This capability is provided with the intent of allowing\n\
-such users to install, extend and update Eclipse-based products. Information\n\
-about packaging Installable Software is available at\n\
-http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\
-\n\
-You may use Provisioning Technology to allow other parties to install\n\
-Installable Software. You shall be responsible for enabling the applicable\n\
-license agreements relating to the Installable Software to be presented to, and\n\
-accepted by, the users of the Provisioning Technology in accordance with the\n\
-Specification. By using Provisioning Technology in such a manner and making it\n\
-available in accordance with the Specification, you further acknowledge your\n\
-agreement to, and the acquisition of all necessary rights to permit the\n\
-following:\n\
-\n\
-1. A series of actions may occur ("Provisioning Process") in which a user may\n\
- execute the Provisioning Technology on a machine ("Target Machine") with the\n\
- intent of installing, extending or updating the functionality of an\n\
- Eclipse-based product.\n\
-2. During the Provisioning Process, the Provisioning Technology may cause third\n\
- party Installable Software or a portion thereof to be accessed and copied to\n\
- the Target Machine.\n\
-3. Pursuant to the Specification, you will provide to the user the terms and\n\
- conditions that govern the use of the Installable Software ("Installable\n\
- Software Agreement") and such Installable Software Agreement shall be\n\
- accessed from the Target Machine in accordance with the Specification. Such\n\
- Installable Software Agreement must inform the user of the terms and\n\
- conditions that govern the Installable Software and must solicit acceptance\n\
- by the end user in the manner prescribed in such Installable\n\
- Software Agreement. Upon such indication of agreement by the user, the\n\
- provisioning Technology will complete installation of the\n\
- Installable Software.\n\
-\n\
-Cryptography\n\
-\n\
-Content may contain encryption software. The country in which you are currently\n\
-may have restrictions on the import, possession, and use, and/or re-export to\n\
-another country, of encryption software. BEFORE using any encryption software,\n\
-please check the country's laws, regulations and policies concerning the import,\n\
-possession, or use, and re-export of encryption software, to see if this is\n\
-permitted.\n\
-\n\
-Java and all Java-based trademarks are trademarks of Oracle Corporation in the\n\
-United States, other countries, or both.\n
-########### end of license property ##########################################
+# "licenseURL" property - URL of the "Feature License"
+# do not translate value - just change to point to a locale-specific HTML page
+licenseURL=license.html
+
+# "license" property - text of the "Feature Update License"
+# should be plain text version of license agreement pointed to be "licenseURL"
+license=\
+Eclipse Foundation Software User Agreement\n\
+\n\
+November 22, 2017\n\
+\n\
+Usage Of Content\n\
+\n\
+THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION\n\
+AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF\n\
+THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE\n\
+TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
+BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED\n\
+BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE\n\
+AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
+TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY\n\
+APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU\n\
+MAY NOT USE THE CONTENT.\n\
+\n\
+Applicable Licenses\n\
+\n\
+Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\
+is provided to you under the terms and conditions of the Eclipse Public License\n\
+Version 2.0 ("EPL"). A copy of the EPL is provided with this Content and is also\n\
+available at http://www.eclipse.org/legal/epl-2.0. For purposes of the EPL,\n\
+"Program" will mean the Content.\n\
+\n\
+Content includes, but is not limited to, source code, object code, documentation\n\
+and other files maintained in the Eclipse Foundation source code repository\n\
+("Repository") in software modules ("Modules") and made available as\n\
+downloadable archives ("Downloads").\n\
+\n\
+- Content may be structured and packaged into modules to facilitate\n\
+ delivering, extending, and upgrading the Content. Typical modules may\n\
+ include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and\n\
+ features ("Features").\n\
+- Each Plug-in or Fragment may be packaged as a sub-directory or JAR\n\
+ (Java\u2122 ARchive) in a directory named "plugins".\n\
+- A Feature is a bundle of one or more Plug-ins and/or Fragments and\n\
+ associated material. Each Feature may be packaged as a sub-directory in a\n\
+ directory named "features". Within a Feature, files named "feature.xml" may\n\
+ contain a list of the names and version numbers of the Plug-ins and/or\n\
+ Fragments associated with that Feature.\n\
+- Features may also include other Features ("Included Features"). Within a\n\
+ Feature, files named "feature.xml" may contain a list of the names and\n\
+ version numbers of Included Features.\n\
+\n\
+The terms and conditions governing Plug-ins and Fragments should be contained in\n\
+files named "about.html" ("Abouts"). The terms and conditions governing Features\n\
+and Included Features should be contained in files named "license.html"\n\
+("Feature Licenses"). Abouts and Feature Licenses may be located in any\n\
+directory of a Download or Module including, but not limited to the following\n\
+locations:\n\
+\n\
+- The top-level (root) directory\n\
+- Plug-in and Fragment directories\n\
+- Inside Plug-ins and Fragments packaged as JARs\n\
+- Sub-directories of the directory named "src" of certain Plug-ins\n\
+- Feature directories\n\
+\n\
+Note: if a Feature made available by the Eclipse Foundation is installed using\n\
+the Provisioning Technology (as defined below), you must agree to a license\n\
+("Feature Update License") during the installation process. If the Feature\n\
+contains Included Features, the Feature Update License should either provide you\n\
+with the terms and conditions governing the Included Features or inform you\n\
+where you can locate them. Feature Update Licenses may be found in the "license"\n\
+property of files named "feature.properties" found within a Feature. Such\n\
+Abouts, Feature Licenses, and Feature Update Licenses contain the terms and\n\
+conditions (or references to such terms and conditions) that govern your use of\n\
+the associated Content in that directory.\n\
+\n\
+THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL\n\
+OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE\n\
+OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
+\n\
+- Eclipse Public License Version 1.0 (available at\n\
+ http://www.eclipse.org/legal/epl-v10.html)\n\
+- Eclipse Distribution License Version 1.0 (available at\n\
+ http://www.eclipse.org/licenses/edl-v1.0.html)\n\
+- Common Public License Version 1.0 (available at\n\
+ http://www.eclipse.org/legal/cpl-v10.html)\n\
+- Apache Software License 1.1 (available at\n\
+ http://www.apache.org/licenses/LICENSE)\n\
+- Apache Software License 2.0 (available at\n\
+ http://www.apache.org/licenses/LICENSE-2.0)\n\
+- Mozilla Public License Version 1.1 (available at\n\
+ http://www.mozilla.org/MPL/MPL-1.1.html)\n\
+\n\
+IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO\n\
+USE OF THE CONTENT. If no About, Feature License, or Feature Update License is\n\
+provided, please contact the Eclipse Foundation to determine what terms and\n\
+conditions govern that particular Content.\n\
+\n\
+Use of Provisioning Technology\n\
+\n\
+The Eclipse Foundation makes available provisioning software, examples of which\n\
+include, but are not limited to, p2 and the Eclipse Update Manager\n\
+("Provisioning Technology") for the purpose of allowing users to install\n\
+software, documentation, information and/or other materials (collectively\n\
+"Installable Software"). This capability is provided with the intent of allowing\n\
+such users to install, extend and update Eclipse-based products. Information\n\
+about packaging Installable Software is available at\n\
+http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\
+\n\
+You may use Provisioning Technology to allow other parties to install\n\
+Installable Software. You shall be responsible for enabling the applicable\n\
+license agreements relating to the Installable Software to be presented to, and\n\
+accepted by, the users of the Provisioning Technology in accordance with the\n\
+Specification. By using Provisioning Technology in such a manner and making it\n\
+available in accordance with the Specification, you further acknowledge your\n\
+agreement to, and the acquisition of all necessary rights to permit the\n\
+following:\n\
+\n\
+1. A series of actions may occur ("Provisioning Process") in which a user may\n\
+ execute the Provisioning Technology on a machine ("Target Machine") with the\n\
+ intent of installing, extending or updating the functionality of an\n\
+ Eclipse-based product.\n\
+2. During the Provisioning Process, the Provisioning Technology may cause third\n\
+ party Installable Software or a portion thereof to be accessed and copied to\n\
+ the Target Machine.\n\
+3. Pursuant to the Specification, you will provide to the user the terms and\n\
+ conditions that govern the use of the Installable Software ("Installable\n\
+ Software Agreement") and such Installable Software Agreement shall be\n\
+ accessed from the Target Machine in accordance with the Specification. Such\n\
+ Installable Software Agreement must inform the user of the terms and\n\
+ conditions that govern the Installable Software and must solicit acceptance\n\
+ by the end user in the manner prescribed in such Installable\n\
+ Software Agreement. Upon such indication of agreement by the user, the\n\
+ provisioning Technology will complete installation of the\n\
+ Installable Software.\n\
+\n\
+Cryptography\n\
+\n\
+Content may contain encryption software. The country in which you are currently\n\
+may have restrictions on the import, possession, and use, and/or re-export to\n\
+another country, of encryption software. BEFORE using any encryption software,\n\
+please check the country's laws, regulations and policies concerning the import,\n\
+possession, or use, and re-export of encryption software, to see if this is\n\
+permitted.\n\
+\n\
+Java and all Java-based trademarks are trademarks of Oracle Corporation in the\n\
+United States, other countries, or both.\n
+########### end of license property ##########################################
diff --git a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.feature/feature.xml b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.feature/feature.xml
index 8eca18a81..eb6a16fa7 100644
--- a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.feature/feature.xml
+++ b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.feature/feature.xml
@@ -1,34 +1,34 @@
-
-
-
-
- Badged Label
-
-
-
- %license
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ Badged Label
+
+
+
+ %license
+
+
+
+
+
+
+
+
+
+
+
diff --git a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.feature/pom.xml b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.feature/pom.xml
index 8740227b8..837a9df63 100644
--- a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.feature/pom.xml
+++ b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.feature/pom.xml
@@ -1,31 +1,31 @@
-
-
-
- 4.0.0
-
-
- org.eclipse.nebula
- badgedlabel
- 1.0.0-SNAPSHOT
-
-
- org.eclipse.nebula.widgets.badgedlabel.feature
- eclipse-feature
- 1.0.0-SNAPSHOT
-
- Nebula Badged Label Feature
-
-
+
+
+
+ 4.0.0
+
+
+ org.eclipse.nebula
+ badgedlabel
+ 1.0.0-SNAPSHOT
+
+
+ org.eclipse.nebula.widgets.badgedlabel.feature
+ eclipse-feature
+ 1.0.0-SNAPSHOT
+
+ Nebula Badged Label Feature
+
+
diff --git a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/.classpath b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/.classpath
index ca3785c41..e801ebfb4 100644
--- a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/.classpath
+++ b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/.classpath
@@ -1,7 +1,7 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/.project b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/.project
index f3ba63d25..d3f3631f6 100644
--- a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/.project
+++ b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/.project
@@ -1,28 +1,28 @@
-
-
- org.eclipse.nebula.widgets.badgedlabel.snippets
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
-
- org.eclipse.pde.PluginNature
- org.eclipse.jdt.core.javanature
-
-
+
+
+ org.eclipse.nebula.widgets.badgedlabel.snippets
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/.settings/org.eclipse.jdt.core.prefs b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/.settings/org.eclipse.jdt.core.prefs
index 11265a345..7adc0fb9a 100644
--- a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/.settings/org.eclipse.jdt.core.prefs
+++ b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,10 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
-org.eclipse.jdt.core.compiler.compliance=11
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
-org.eclipse.jdt.core.compiler.release=enabled
-org.eclipse.jdt.core.compiler.source=11
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
+org.eclipse.jdt.core.compiler.compliance=11
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=11
diff --git a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/META-INF/MANIFEST.MF b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/META-INF/MANIFEST.MF
index 97317c446..0cf457036 100644
--- a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/META-INF/MANIFEST.MF
+++ b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/META-INF/MANIFEST.MF
@@ -1,10 +1,10 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Nebula Opal Badge Snippets
-Bundle-SymbolicName: org.eclipse.nebula.widgets.badgedlabel.snippets
-Bundle-Version: 1.0.0.qualifier
-Bundle-Vendor: Eclipse Nebula
-Bundle-RequiredExecutionEnvironment: JavaSE-11
-Require-Bundle: org.eclipse.nebula.widgets.badgedlabel;bundle-version="1.0.0",
- org.eclipse.swt
-Automatic-Module-Name: org.eclipse.nebula.widgets.badgedlabel.snippets
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Nebula Opal Badge Snippets
+Bundle-SymbolicName: org.eclipse.nebula.widgets.badgedlabel.snippets
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: Eclipse Nebula
+Bundle-RequiredExecutionEnvironment: JavaSE-11
+Require-Bundle: org.eclipse.nebula.widgets.badgedlabel;bundle-version="1.0.0",
+ org.eclipse.swt
+Automatic-Module-Name: org.eclipse.nebula.widgets.badgedlabel.snippets
diff --git a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/build.properties b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/build.properties
index 41eb6ade2..34d2e4d2d 100644
--- a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/build.properties
+++ b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/build.properties
@@ -1,4 +1,4 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/pom.xml b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/pom.xml
index a7395eb2a..1f98f8b99 100644
--- a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/pom.xml
+++ b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/pom.xml
@@ -1,24 +1,24 @@
-
-
-
- 4.0.0
-
-
- org.eclipse.nebula
- badgedlabel
- 1.0.0-SNAPSHOT
-
-
- org.eclipse.nebula.widgets.badgedlabel.snippets
- eclipse-plugin
-
-
+
+
+
+ 4.0.0
+
+
+ org.eclipse.nebula
+ badgedlabel
+ 1.0.0-SNAPSHOT
+
+
+ org.eclipse.nebula.widgets.badgedlabel.snippets
+ eclipse-plugin
+
+
diff --git a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/src/org/eclipse/nebula/widgets/badgedlabel/BadgedLabelSnippet.java b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/src/org/eclipse/nebula/widgets/badgedlabel/BadgedLabelSnippet.java
index aeaabf929..4f4aeefaf 100644
--- a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/src/org/eclipse/nebula/widgets/badgedlabel/BadgedLabelSnippet.java
+++ b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel.snippets/src/org/eclipse/nebula/widgets/badgedlabel/BadgedLabelSnippet.java
@@ -1,114 +1,114 @@
-/*******************************************************************************
- * Copyright (c) 2019 Akuiteo (http://www.akuiteo.com).
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors: Laurent CARON (laurent.caron at gmail dot com) - initial API and
- * implementation
- *******************************************************************************/
-package org.eclipse.nebula.widgets.badgedlabel;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Snippet for the BadgedLabel widget
- */
-public class BadgedLabelSnippet {
- private static Shell shell;
- private static Image icon;
-
- /**
- * @param args
- */
- public static void main(final String[] args) {
- final Display display = new Display();
- shell = new Shell(display);
- shell.setText("BadgedLabel Snippet");
- shell.setLayout(new GridLayout(5, false));
- shell.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
-
- icon = new Image(display, BadgedLabelSnippet.class.getClassLoader()
- .getResourceAsStream("org/eclipse/nebula/widgets/badgedlabel/user.png"));
-
- createButtons("Blue :", SWT.COLOR_BLUE, SWT.TOP | SWT.LEFT);
- createButtons("Grey:", SWT.COLOR_GRAY, SWT.TOP | SWT.RIGHT);
- createButtons("Green:", SWT.COLOR_GREEN, SWT.BOTTOM | SWT.LEFT);
- createButtons("Red:", SWT.COLOR_RED, SWT.BOTTOM | SWT.RIGHT);
- createButtons("Yellow:", SWT.COLOR_YELLOW, SWT.TOP | SWT.RIGHT);
- createButtons("Cyan:", SWT.COLOR_CYAN, SWT.TOP | SWT.LEFT);
- createButtons("Black:", SWT.COLOR_BLACK, SWT.BOTTOM | SWT.RIGHT);
-
- shell.pack();
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
-
- icon.dispose();
- display.dispose();
-
- }
-
- private static void createButtons(final String text, int color, int location) {
- final Label label = new Label(shell, SWT.NONE);
- label.setBackground(label.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- String locationText;
- if (location == (SWT.BOTTOM | SWT.LEFT)) {
- locationText = "Bottom left";
- } else if (location == (SWT.BOTTOM | SWT.RIGHT)) {
- locationText = "Bottom right";
- } else if (location == (SWT.TOP | SWT.LEFT)) {
- locationText = "Top left";
- } else {
- locationText = "Top right";
- }
-
- label.setText(text + " " + locationText);
- label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
-
- final BadgedLabel button1 = new BadgedLabel(shell, location);
- button1.setText("Notification");
- final GridData gd = new GridData(GridData.FILL, GridData.CENTER, false, false);
- gd.widthHint = 200;
- gd.heightHint = 100;
- button1.setLayoutData(gd);
- button1.setBadgeValue("1");
- button1.setPredefinedColor(color);
- button1.setBackground(label.getDisplay().getSystemColor(SWT.COLOR_WHITE));
-
- final BadgedLabel button2 = new BadgedLabel(shell, location);
- button2.setText("Text & image");
- button2.setImage(icon);
- button2.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
- button2.setPredefinedColor(color);
- button2.setBadgeValue("2");
- button2.setBackground(label.getDisplay().getSystemColor(SWT.COLOR_WHITE));
-
- final BadgedLabel button3 = new BadgedLabel(shell, location);
- button3.setImage(icon);
- button3.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
- button3.setPredefinedColor(color);
- button3.setBadgeValue("99+");
- button3.setBackground(label.getDisplay().getSystemColor(SWT.COLOR_WHITE));
-
- final BadgedLabel button4 = new BadgedLabel(shell, location);
- button4.setText("Disabled");
- button4.setEnabled(false);
- button4.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
- button4.setPredefinedColor(color);
- button4.setBadgeValue("New");
- button4.setBackground(label.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2019 Akuiteo (http://www.akuiteo.com).
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors: Laurent CARON (laurent.caron at gmail dot com) - initial API and
+ * implementation
+ *******************************************************************************/
+package org.eclipse.nebula.widgets.badgedlabel;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Snippet for the BadgedLabel widget
+ */
+public class BadgedLabelSnippet {
+ private static Shell shell;
+ private static Image icon;
+
+ /**
+ * @param args
+ */
+ public static void main(final String[] args) {
+ final Display display = new Display();
+ shell = new Shell(display);
+ shell.setText("BadgedLabel Snippet");
+ shell.setLayout(new GridLayout(5, false));
+ shell.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+
+ icon = new Image(display, BadgedLabelSnippet.class.getClassLoader()
+ .getResourceAsStream("org/eclipse/nebula/widgets/badgedlabel/user.png"));
+
+ createButtons("Blue :", SWT.COLOR_BLUE, SWT.TOP | SWT.LEFT);
+ createButtons("Grey:", SWT.COLOR_GRAY, SWT.TOP | SWT.RIGHT);
+ createButtons("Green:", SWT.COLOR_GREEN, SWT.BOTTOM | SWT.LEFT);
+ createButtons("Red:", SWT.COLOR_RED, SWT.BOTTOM | SWT.RIGHT);
+ createButtons("Yellow:", SWT.COLOR_YELLOW, SWT.TOP | SWT.RIGHT);
+ createButtons("Cyan:", SWT.COLOR_CYAN, SWT.TOP | SWT.LEFT);
+ createButtons("Black:", SWT.COLOR_BLACK, SWT.BOTTOM | SWT.RIGHT);
+
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+
+ icon.dispose();
+ display.dispose();
+
+ }
+
+ private static void createButtons(final String text, int color, int location) {
+ final Label label = new Label(shell, SWT.NONE);
+ label.setBackground(label.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ String locationText;
+ if (location == (SWT.BOTTOM | SWT.LEFT)) {
+ locationText = "Bottom left";
+ } else if (location == (SWT.BOTTOM | SWT.RIGHT)) {
+ locationText = "Bottom right";
+ } else if (location == (SWT.TOP | SWT.LEFT)) {
+ locationText = "Top left";
+ } else {
+ locationText = "Top right";
+ }
+
+ label.setText(text + " " + locationText);
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
+
+ final BadgedLabel button1 = new BadgedLabel(shell, location);
+ button1.setText("Notification");
+ final GridData gd = new GridData(GridData.FILL, GridData.CENTER, false, false);
+ gd.widthHint = 200;
+ gd.heightHint = 100;
+ button1.setLayoutData(gd);
+ button1.setBadgeValue("1");
+ button1.setPredefinedColor(color);
+ button1.setBackground(label.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+
+ final BadgedLabel button2 = new BadgedLabel(shell, location);
+ button2.setText("Text & image");
+ button2.setImage(icon);
+ button2.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
+ button2.setPredefinedColor(color);
+ button2.setBadgeValue("2");
+ button2.setBackground(label.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+
+ final BadgedLabel button3 = new BadgedLabel(shell, location);
+ button3.setImage(icon);
+ button3.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
+ button3.setPredefinedColor(color);
+ button3.setBadgeValue("99+");
+ button3.setBackground(label.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+
+ final BadgedLabel button4 = new BadgedLabel(shell, location);
+ button4.setText("Disabled");
+ button4.setEnabled(false);
+ button4.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
+ button4.setPredefinedColor(color);
+ button4.setBadgeValue("New");
+ button4.setBackground(label.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ }
+}
diff --git a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/.classpath b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/.classpath
index ca3785c41..e801ebfb4 100644
--- a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/.classpath
+++ b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/.classpath
@@ -1,7 +1,7 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/.project b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/.project
index 8b09a97b3..639f3376e 100644
--- a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/.project
+++ b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/.project
@@ -1,28 +1,28 @@
-
-
- org.eclipse.nebula.widgets.badgedlabel
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
-
- org.eclipse.pde.PluginNature
- org.eclipse.jdt.core.javanature
-
-
+
+
+ org.eclipse.nebula.widgets.badgedlabel
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/.settings/org.eclipse.jdt.core.prefs b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/.settings/org.eclipse.jdt.core.prefs
index 11265a345..7adc0fb9a 100644
--- a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/.settings/org.eclipse.jdt.core.prefs
+++ b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,10 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
-org.eclipse.jdt.core.compiler.compliance=11
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
-org.eclipse.jdt.core.compiler.release=enabled
-org.eclipse.jdt.core.compiler.source=11
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
+org.eclipse.jdt.core.compiler.compliance=11
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=11
diff --git a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/META-INF/MANIFEST.MF b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/META-INF/MANIFEST.MF
index aa6904b5d..b8727b241 100644
--- a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/META-INF/MANIFEST.MF
+++ b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/META-INF/MANIFEST.MF
@@ -1,11 +1,11 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Nebula Badged Label Widget
-Bundle-SymbolicName: org.eclipse.nebula.widgets.badgedlabel
-Bundle-Version: 1.0.0.qualifier
-Bundle-Vendor: Eclipse Nebula
-Bundle-RequiredExecutionEnvironment: JavaSE-11
-Export-Package: org.eclipse.nebula.widgets.badgedlabel
-Require-Bundle: org.eclipse.nebula.widgets.opal.commons,
- org.eclipse.swt
-Automatic-Module-Name: org.eclipse.nebula.widgets.badgedlabel
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Nebula Badged Label Widget
+Bundle-SymbolicName: org.eclipse.nebula.widgets.badgedlabel
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: Eclipse Nebula
+Bundle-RequiredExecutionEnvironment: JavaSE-11
+Export-Package: org.eclipse.nebula.widgets.badgedlabel
+Require-Bundle: org.eclipse.nebula.widgets.opal.commons,
+ org.eclipse.swt
+Automatic-Module-Name: org.eclipse.nebula.widgets.badgedlabel
diff --git a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/build.properties b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/build.properties
index 41eb6ade2..34d2e4d2d 100644
--- a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/build.properties
+++ b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/build.properties
@@ -1,4 +1,4 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/pom.xml b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/pom.xml
index 7e14f017e..337c4fa21 100644
--- a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/pom.xml
+++ b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/pom.xml
@@ -1,24 +1,24 @@
-
-
-
- 4.0.0
-
-
- org.eclipse.nebula
- badgedlabel
- 1.0.0-SNAPSHOT
-
-
- org.eclipse.nebula.widgets.badgedlabel
- eclipse-plugin
-
-
+
+
+
+ 4.0.0
+
+
+ org.eclipse.nebula
+ badgedlabel
+ 1.0.0-SNAPSHOT
+
+
+ org.eclipse.nebula.widgets.badgedlabel
+ eclipse-plugin
+
+
diff --git a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/src/org/eclipse/nebula/widgets/badgedlabel/BadgedLabel.java b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/src/org/eclipse/nebula/widgets/badgedlabel/BadgedLabel.java
index 5e3e78107..4aa3c89b5 100644
--- a/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/src/org/eclipse/nebula/widgets/badgedlabel/BadgedLabel.java
+++ b/widgets/badgedlabel/org.eclipse.nebula.widgets.badgedlabel/src/org/eclipse/nebula/widgets/badgedlabel/BadgedLabel.java
@@ -1,772 +1,772 @@
-/*******************************************************************************
- * Copyright (c) 2019 Akuiteo (http://www.akuiteo.com).
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors: Laurent CARON (laurent.caron at gmail dot com) - initial API and
- * implementation
- *******************************************************************************/
-package org.eclipse.nebula.widgets.badgedlabel;
-
-import org.eclipse.nebula.widgets.opal.commons.SWTGraphicUtil;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-
-/**
- * Instances of this class represent a non-selectable user interface object that
- * displays a string or image. A badge is displayed on this label, so you can
- * add extra information (the most common used is a notification label that
- * shows the number of unread notifications).
- *
- *
- *
Styles:
- *
SWT.BORDER
- *
SWT.LEFT or SWT.RIGHT (horizontal location)
- *
SWT.TOP or SWT.BOTTOM (vertical location)
- *
Events:
- *
(none)
- *
- */
-public class BadgedLabel extends Canvas {
- private static final int PADDING = 8;
- private static final int MARGIN = 7;
- private static final int CIRCLE_DIAMETER = 18;
- private static final int MAX_BADGE_TEXT_SIZE = 11;
- private Image image;
- private String text;
- private String badgeValue;
- private Color textColor, backgroundColor, borderColor, badgeForeground, badgeBackground;
- private final Font badgeFont;
- private Font boldFont;
- private int horizontalLocation, verticalLocation;
- private GC gc;
- private int left;
- private int top;
- private Point buttonSize;
- private Point textSizeCache;
- private Point badgeTextSizeCache;
-
- /**
- * Constructs a new instance of this class given its parent and a style value
- * describing its behavior and appearance.
- *
- * The style value is either one of the style constants defined in class
- * SWT which is applicable to instances of this class, or must be
- * built by bitwise OR'ing together (that is, using the
- * int "|" operator) two or more of those SWT style
- * constants. The class description lists the style constants that are
- * applicable to the class. Style bits are also inherited from superclasses.
- *
- *
- * @param parent
- * a composite control which will be the parent of the new instance
- * (cannot be null)
- * @param style
- * the style of control to construct
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_NULL_ARGUMENT - if the parent is null
- *
- * @exception SWTException
- *
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the parent
- *
ERROR_INVALID_SUBCLASS - if this class is not an allowed
- * subclass
- *
- *
- */
- public BadgedLabel(Composite parent, int style) {
- super(parent, checkStyle(style) | SWT.DOUBLE_BUFFERED);
- badgeFont = SWTGraphicUtil.buildFontFrom(this, SWT.NONE, 8);
- SWTGraphicUtil.addDisposer(this, badgeFont);
- boldFont = SWTGraphicUtil.buildFontFrom(this, SWT.BOLD);
- SWTGraphicUtil.addDisposer(this, boldFont);
- horizontalLocation = (getStyle() & SWT.LEFT) != 0 ? SWT.LEFT : SWT.RIGHT;
- verticalLocation = (getStyle() & SWT.TOP) != 0 ? SWT.TOP : SWT.BOTTOM;
- initDefaultColors();
- addListener(SWT.Paint, e -> onPaint(e));
- }
-
- private static int checkStyle(final int style) {
- final int mask = SWT.BORDER | SWT.LEFT | SWT.RIGHT | SWT.TOP | SWT.BOTTOM;
- int newStyle = style & mask;
- newStyle |= SWT.DOUBLE_BUFFERED;
- return newStyle;
- }
-
- private void initDefaultColors() {
- textColor = getDisplay().getSystemColor(SWT.COLOR_BLACK);
- SWTGraphicUtil.addDisposer(this, textColor);
-
- backgroundColor = new Color(getDisplay(), 247, 247, 247);
- SWTGraphicUtil.addDisposer(this, backgroundColor);
-
- borderColor = new Color(getDisplay(), 204, 204, 204);
- SWTGraphicUtil.addDisposer(this, borderColor);
-
- badgeForeground = getDisplay().getSystemColor(SWT.COLOR_WHITE);
- badgeBackground = new Color(getDisplay(), 0, 123, 255);
- SWTGraphicUtil.addDisposer(this, badgeBackground);
- }
-
- private void onPaint(Event e) {
- gc = e.gc;
- gc.setAntialias(SWT.ON);
- gc.setAdvanced(true);
- final Color previousForeground = getForeground();
- final Color previousBackground = getBackground();
-
- drawButton();
- drawBadge();
-
- gc.setForeground(previousForeground);
- gc.setBackground(previousBackground);
- }
-
- private void drawButton() {
- drawShape();
- drawImageAndText();
- }
-
- private void drawShape() {
- buttonSize = computeButtonSize();
- final Rectangle area = getClientArea();
- left = MARGIN;
- if (horizontalLocation == SWT.LEFT) {
- left += MARGIN;
- }
-
- top = MARGIN;
- if (verticalLocation == SWT.TOP) {
- top += MARGIN;
- }
-
- // Background
- gc.setBackground(backgroundColor);
- gc.fillRoundRectangle(left, top, //
- Math.max(buttonSize.x, area.width - 2 * MARGIN) - left, //
- Math.max(buttonSize.y, area.height - 2 * MARGIN) - top, 3, 3);
-
- // Foreground
- gc.setForeground(borderColor);
- gc.drawRoundRectangle(left, top, //
- Math.max(buttonSize.x, area.width - 2 * MARGIN) - left, //
- Math.max(buttonSize.y, area.height - 2 * MARGIN) - top, 3, 3);
- }
-
- private void drawImageAndText() {
- final int textWidth = getTextSizeInPixels().x;
- int textDelta = 0;
- final Rectangle area = getClientArea();
- final int width = Math.max(buttonSize.x, area.width - 2 * MARGIN) - left;
- final int height = Math.max(buttonSize.y, area.height - 2 * MARGIN) - top;
- if (image != null) {
- final Point imageSize = new Point(image.getBounds().width, image.getBounds().height);
- int wholeLength = imageSize.x;
- if (textWidth != 0) {
- wholeLength += PADDING / 2 + getTextSizeInPixels().x;
- }
-
- final int x = left + (width - wholeLength) / 2;
- gc.drawImage(image, x, top + (height - imageSize.y) / 2);
- textDelta = x + imageSize.x + PADDING / 2;
- }
-
- if (textWidth == 0) {
- return;
- }
-
- final int x = textDelta == 0 ? left + (width - textWidth) / 2 : textDelta;
- gc.setFont(boldFont);
- gc.setForeground(isEnabled() ? textColor : getDisplay().getSystemColor(SWT.COLOR_GRAY));
- gc.drawText(text, x, top + (height - getTextSizeInPixels().y) / 2, false);
- }
-
- private Point getTextSizeInPixels() {
- if (text == null || text.equals("")) {
- return new Point(0, 0);
- }
-
- if (textSizeCache != null) {
- return textSizeCache;
- }
-
- final GC gc = new GC(this);
- gc.setFont(boldFont);
- textSizeCache = gc.stringExtent(text);
- gc.dispose();
- return textSizeCache;
- }
-
- private void drawBadge() {
- if (badgeValue == null || badgeValue.equals("")) {
- return;
- }
-
- gc.setForeground(badgeForeground);
- gc.setBackground(badgeBackground);
-
- final Point textSize = getBadgeTextSizeInPixels();
- final Rectangle area = getClientArea();
- final int width = Math.max(buttonSize.x, area.width - 2 * MARGIN) - left;
- final int height = Math.max(buttonSize.y, area.height - 2 * MARGIN) - top;
- int badgeWith;
- if (textSize.x > MAX_BADGE_TEXT_SIZE) {
- // Draw a round rectangle
- badgeWith = textSize.x + MAX_BADGE_TEXT_SIZE / 2;
- } else {
- // Draw a circle
- badgeWith = CIRCLE_DIAMETER;
- }
-
- int x;
- switch (horizontalLocation) {
- case SWT.RIGHT:
- x = left + width - badgeWith / 2;
- break;
- case SWT.LEFT:
- x = left - badgeWith / 2;
- break;
- default:
- return;
- }
-
- int y;
- switch (verticalLocation) {
- case SWT.TOP:
- y = top - CIRCLE_DIAMETER / 2;
- break;
- case SWT.BOTTOM:
- y = top + height - CIRCLE_DIAMETER / 2;
- break;
- default:
- return;
- }
- if (textSize.x > MAX_BADGE_TEXT_SIZE) {
- // Draw a round rectangle
- gc.fillRoundRectangle(x, y, badgeWith, CIRCLE_DIAMETER, 3, 3);
- } else {
- // Draw a circle
- gc.fillOval(x, y, CIRCLE_DIAMETER, CIRCLE_DIAMETER);
- }
- gc.setFont(badgeFont);
- gc.drawText(badgeValue, x + (badgeWith - textSize.x) / 2, y + (CIRCLE_DIAMETER - textSize.y) / 2, true);
- }
-
- private Point getBadgeTextSizeInPixels() {
- if (badgeTextSizeCache != null) {
- return badgeTextSizeCache;
- }
- final GC gc = new GC(this);
- gc.setFont(badgeFont);
- badgeTextSizeCache = gc.stringExtent(badgeValue);
- gc.dispose();
- return badgeTextSizeCache;
-
- }
-
- /**
- * Sets the badge's color theme to the theme specified by the argument
- *
- * @param color
- * the new color, can pick one of the following value:
- * SWT.COLOR_BLUE, SWT.COLOR_GRAY, SWT.COLOR_GREEN, SWT.COLOR_RED,
- * SWT.COLOR_YELLOW, SWT.COLOR_CYAN, SWT.COLOR_BLACK
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_NULL_ARGUMENT - if the argument is null
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public void setPredefinedColor(int color) {
- checkWidget();
-
- badgeForeground = getDisplay().getSystemColor(SWT.COLOR_WHITE);
- switch (color) {
- case SWT.COLOR_BLUE:
- badgeBackground = new Color(getDisplay(), 0, 123, 255);
- break;
- case SWT.COLOR_GRAY:
- badgeBackground = new Color(getDisplay(), 108, 117, 125);
- break;
- case SWT.COLOR_GREEN:
- badgeBackground = new Color(getDisplay(), 40, 167, 69);
- break;
- case SWT.COLOR_RED:
- badgeBackground = new Color(getDisplay(), 220, 53, 69);
- break;
- case SWT.COLOR_YELLOW:
- badgeForeground = getDisplay().getSystemColor(SWT.COLOR_BLACK);
- badgeBackground = new Color(getDisplay(), 255, 193, 7);
- break;
- case SWT.COLOR_CYAN:
- badgeBackground = new Color(getDisplay(), 23, 162, 184);
- break;
- default: // BLACK
- badgeBackground = new Color(getDisplay(), 52, 58, 64);
- }
-
- SWTGraphicUtil.addDisposer(this, badgeBackground);
- }
-
- /**
- * @see org.eclipse.swt.widgets.Control#computeSize(int, int, boolean)
- */
- @Override
- public Point computeSize(final int wHint, final int hHint, final boolean changed) {
- checkWidget();
-
- if (image == null && text == null) {
- return super.computeSize(wHint, hHint, changed);
- }
-
- // Button
- final Point buttonSize = computeButtonSize();
- int width = buttonSize.x;
- int height = buttonSize.y;
-
- // Margin
- width += 3 * MARGIN;
- height += 3 * MARGIN;
- return new Point(Math.max(width, wHint), Math.max(height, hHint));
- }
-
- private Point computeButtonSize() {
- int width = 2 * PADDING, height = 2 * PADDING;
- if (image != null && text == null) {
- final Rectangle bounds = image.getBounds();
- width += bounds.width;
- height = Math.max(height, bounds.height + 2 * PADDING);
- } else if (text != null && image == null) {
- final Point extent = getTextSizeInPixels();
- width = Math.max(width, extent.x + 2 * PADDING);
- height = height + extent.y;
- } else {
- final Rectangle bounds = image.getBounds();
- final Point extent = getTextSizeInPixels();
- width += bounds.width + PADDING + extent.x + 2 * PADDING;
- final int maxTextAndImageHeight = Math.max(extent.y, bounds.y);
- height = Math.max(height, maxTextAndImageHeight + 2 * PADDING);
- }
- return new Point(width, height);
- }
-
- /**
- * Returns the background color that the receiver will use to draw.
- *
- * @return the receiver's background color
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public Color getBackgroundColor() {
- checkWidget();
- return backgroundColor;
- }
-
- /**
- * Returns the background color that the badge will use to draw.
- *
- * @return the badge's backdground color
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public Color getBadgeBackground() {
- checkWidget();
- return badgeBackground;
- }
-
- /**
- * Returns the foreground color that the badge will use to draw.
- *
- * @return the badge's foreground color
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public Color getBadgeForeground() {
- checkWidget();
- return badgeForeground;
- }
-
- /**
- * Returns the text of the badge
- *
- * @return the badge's text
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public String getBadgeValue() {
- checkWidget();
- return badgeValue;
- }
-
- /**
- * Returns the border color that the receiver will use to draw.
- *
- * @return the receiver's border color
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public Color getBorderColor() {
- checkWidget();
- return borderColor;
- }
-
- /**
- * Returns the receiver's image if it has one, or null if it does not.
- *
- * @return the receiver's image
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public Image getImage() {
- checkWidget();
- return image;
- }
-
- /**
- * Returns the receiver's text, which will be an empty string if it has never
- * been set or if the receiver is a SEPARATOR label.
- *
- * @return the receiver's text
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public String getText() {
- checkWidget();
- return text;
- }
-
- /**
- * Returns the text color that the receiver will use to draw.
- *
- * @return the receiver's text color
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public Color getTextColor() {
- checkWidget();
- return textColor;
- }
-
- /**
- * Sets the receiver's background color to the color specified by the argument
- *
- * @param color
- * the new color
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument has been
- * disposed
- *
ERROR_NULL_ARGUMENT - if the argument is null
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public void setBackgroundColor(Color backgroundColor) {
- checkWidget();
- checkColor(backgroundColor);
- this.backgroundColor = backgroundColor;
- }
-
- private void checkColor(Color color) {
- if (color == null) {
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- }
- if (color.isDisposed()) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- }
-
- /**
- * Sets the badge's background color to the color specified by the argument
- *
- * @param color
- * the new color
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument has been
- * disposed
- *
ERROR_NULL_ARGUMENT - if the argument is null
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public void setBadgeBackground(Color badgeBackground) {
- checkWidget();
- checkColor(badgeBackground);
- this.badgeBackground = badgeBackground;
- }
-
- /**
- * Sets the badge's foreground color to the color specified by the argument
- *
- * @param color
- * the new color
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument has been
- * disposed
- *
ERROR_NULL_ARGUMENT - if the argument is null
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public void setBadgeForeground(Color badgeForeground) {
- checkWidget();
- checkColor(badgeForeground);
- this.badgeForeground = badgeForeground;
- }
-
- /**
- * Sets the badge's value (text) to the text specified by the argument
- *
- * @param value
- * the new text value
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_NULL_ARGUMENT - if the argument is null
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public void setBadgeValue(String value) {
- checkWidget();
- if (value == null) {
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- }
- badgeValue = value;
- badgeTextSizeCache = null;
- }
-
- /**
- * Sets the receiver's border color to the color specified by the argument
- *
- * @param color
- * the new color
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument has been
- * disposed
- *
ERROR_NULL_ARGUMENT - if the argument is null
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public void setBorderColor(Color borderColor) {
- checkWidget();
- checkColor(borderColor);
- this.borderColor = borderColor;
- }
-
- /**
- * @see org.eclipse.swt.widgets.Control#setEnabled(boolean)
- */
- @Override
- public void setEnabled(boolean enabled) {
- super.setEnabled(enabled);
- redraw();
- }
-
- /**
- * @see org.eclipse.swt.widgets.Canvas#setFont(org.eclipse.swt.graphics.Font)
- */
- @Override
- public void setFont(Font font) {
- super.setFont(font);
- textSizeCache = null;
- boldFont.dispose();
- boldFont = SWTGraphicUtil.buildFontFrom(this, SWT.BOLD);
- }
-
- /**
- * Sets the receiver's image to the argument, which may be null indicating that
- * no image should be displayed.
- *
- * @param image
- * the image to display on the receiver (may be null)
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the image has been
- * disposed
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- * This method sets the widget label. The label may include the mnemonic
- * character and line delimiters.
- *
- *
- * Mnemonics are indicated by an '&' that causes the next character to be
- * the mnemonic. When the user presses a key sequence that matches the mnemonic,
- * focus is assigned to the control that follows the label. On most platforms,
- * the mnemonic appears underlined but may be emphasised in a platform specific
- * manner. The mnemonic indicator character '&' can be escaped by doubling
- * it in the string, causing a single '&' to be displayed.
- *
- *
- * Note: If control characters like '\n', '\t' etc. are used in the string, then
- * the behavior is platform dependent.
- *
- *
- * @param string
- * the new text
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_NULL_ARGUMENT - if the text is null
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public void setText(String text) {
- checkWidget();
- textSizeCache = null;
- this.text = text;
- }
-
- /**
- * Sets the receiver's text color to the color specified by the argument
- *
- * @param color
- * the new color
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument has been
- * disposed
- *
ERROR_NULL_ARGUMENT - if the argument is null
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public void setTextColor(Color textColor) {
- checkWidget();
- checkColor(textColor);
- this.textColor = textColor;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2019 Akuiteo (http://www.akuiteo.com).
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors: Laurent CARON (laurent.caron at gmail dot com) - initial API and
+ * implementation
+ *******************************************************************************/
+package org.eclipse.nebula.widgets.badgedlabel;
+
+import org.eclipse.nebula.widgets.opal.commons.SWTGraphicUtil;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class represent a non-selectable user interface object that
+ * displays a string or image. A badge is displayed on this label, so you can
+ * add extra information (the most common used is a notification label that
+ * shows the number of unread notifications).
+ *
+ *
+ *
Styles:
+ *
SWT.BORDER
+ *
SWT.LEFT or SWT.RIGHT (horizontal location)
+ *
SWT.TOP or SWT.BOTTOM (vertical location)
+ *
Events:
+ *
(none)
+ *
+ */
+public class BadgedLabel extends Canvas {
+ private static final int PADDING = 8;
+ private static final int MARGIN = 7;
+ private static final int CIRCLE_DIAMETER = 18;
+ private static final int MAX_BADGE_TEXT_SIZE = 11;
+ private Image image;
+ private String text;
+ private String badgeValue;
+ private Color textColor, backgroundColor, borderColor, badgeForeground, badgeBackground;
+ private final Font badgeFont;
+ private Font boldFont;
+ private int horizontalLocation, verticalLocation;
+ private GC gc;
+ private int left;
+ private int top;
+ private Point buttonSize;
+ private Point textSizeCache;
+ private Point badgeTextSizeCache;
+
+ /**
+ * Constructs a new instance of this class given its parent and a style value
+ * describing its behavior and appearance.
+ *
+ * The style value is either one of the style constants defined in class
+ * SWT which is applicable to instances of this class, or must be
+ * built by bitwise OR'ing together (that is, using the
+ * int "|" operator) two or more of those SWT style
+ * constants. The class description lists the style constants that are
+ * applicable to the class. Style bits are also inherited from superclasses.
+ *
+ *
+ * @param parent
+ * a composite control which will be the parent of the new instance
+ * (cannot be null)
+ * @param style
+ * the style of control to construct
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_NULL_ARGUMENT - if the parent is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the parent
+ *
ERROR_INVALID_SUBCLASS - if this class is not an allowed
+ * subclass
+ *
+ *
+ */
+ public BadgedLabel(Composite parent, int style) {
+ super(parent, checkStyle(style) | SWT.DOUBLE_BUFFERED);
+ badgeFont = SWTGraphicUtil.buildFontFrom(this, SWT.NONE, 8);
+ SWTGraphicUtil.addDisposer(this, badgeFont);
+ boldFont = SWTGraphicUtil.buildFontFrom(this, SWT.BOLD);
+ SWTGraphicUtil.addDisposer(this, boldFont);
+ horizontalLocation = (getStyle() & SWT.LEFT) != 0 ? SWT.LEFT : SWT.RIGHT;
+ verticalLocation = (getStyle() & SWT.TOP) != 0 ? SWT.TOP : SWT.BOTTOM;
+ initDefaultColors();
+ addListener(SWT.Paint, e -> onPaint(e));
+ }
+
+ private static int checkStyle(final int style) {
+ final int mask = SWT.BORDER | SWT.LEFT | SWT.RIGHT | SWT.TOP | SWT.BOTTOM;
+ int newStyle = style & mask;
+ newStyle |= SWT.DOUBLE_BUFFERED;
+ return newStyle;
+ }
+
+ private void initDefaultColors() {
+ textColor = getDisplay().getSystemColor(SWT.COLOR_BLACK);
+ SWTGraphicUtil.addDisposer(this, textColor);
+
+ backgroundColor = new Color(getDisplay(), 247, 247, 247);
+ SWTGraphicUtil.addDisposer(this, backgroundColor);
+
+ borderColor = new Color(getDisplay(), 204, 204, 204);
+ SWTGraphicUtil.addDisposer(this, borderColor);
+
+ badgeForeground = getDisplay().getSystemColor(SWT.COLOR_WHITE);
+ badgeBackground = new Color(getDisplay(), 0, 123, 255);
+ SWTGraphicUtil.addDisposer(this, badgeBackground);
+ }
+
+ private void onPaint(Event e) {
+ gc = e.gc;
+ gc.setAntialias(SWT.ON);
+ gc.setAdvanced(true);
+ final Color previousForeground = getForeground();
+ final Color previousBackground = getBackground();
+
+ drawButton();
+ drawBadge();
+
+ gc.setForeground(previousForeground);
+ gc.setBackground(previousBackground);
+ }
+
+ private void drawButton() {
+ drawShape();
+ drawImageAndText();
+ }
+
+ private void drawShape() {
+ buttonSize = computeButtonSize();
+ final Rectangle area = getClientArea();
+ left = MARGIN;
+ if (horizontalLocation == SWT.LEFT) {
+ left += MARGIN;
+ }
+
+ top = MARGIN;
+ if (verticalLocation == SWT.TOP) {
+ top += MARGIN;
+ }
+
+ // Background
+ gc.setBackground(backgroundColor);
+ gc.fillRoundRectangle(left, top, //
+ Math.max(buttonSize.x, area.width - 2 * MARGIN) - left, //
+ Math.max(buttonSize.y, area.height - 2 * MARGIN) - top, 3, 3);
+
+ // Foreground
+ gc.setForeground(borderColor);
+ gc.drawRoundRectangle(left, top, //
+ Math.max(buttonSize.x, area.width - 2 * MARGIN) - left, //
+ Math.max(buttonSize.y, area.height - 2 * MARGIN) - top, 3, 3);
+ }
+
+ private void drawImageAndText() {
+ final int textWidth = getTextSizeInPixels().x;
+ int textDelta = 0;
+ final Rectangle area = getClientArea();
+ final int width = Math.max(buttonSize.x, area.width - 2 * MARGIN) - left;
+ final int height = Math.max(buttonSize.y, area.height - 2 * MARGIN) - top;
+ if (image != null) {
+ final Point imageSize = new Point(image.getBounds().width, image.getBounds().height);
+ int wholeLength = imageSize.x;
+ if (textWidth != 0) {
+ wholeLength += PADDING / 2 + getTextSizeInPixels().x;
+ }
+
+ final int x = left + (width - wholeLength) / 2;
+ gc.drawImage(image, x, top + (height - imageSize.y) / 2);
+ textDelta = x + imageSize.x + PADDING / 2;
+ }
+
+ if (textWidth == 0) {
+ return;
+ }
+
+ final int x = textDelta == 0 ? left + (width - textWidth) / 2 : textDelta;
+ gc.setFont(boldFont);
+ gc.setForeground(isEnabled() ? textColor : getDisplay().getSystemColor(SWT.COLOR_GRAY));
+ gc.drawText(text, x, top + (height - getTextSizeInPixels().y) / 2, false);
+ }
+
+ private Point getTextSizeInPixels() {
+ if (text == null || text.equals("")) {
+ return new Point(0, 0);
+ }
+
+ if (textSizeCache != null) {
+ return textSizeCache;
+ }
+
+ final GC gc = new GC(this);
+ gc.setFont(boldFont);
+ textSizeCache = gc.stringExtent(text);
+ gc.dispose();
+ return textSizeCache;
+ }
+
+ private void drawBadge() {
+ if (badgeValue == null || badgeValue.equals("")) {
+ return;
+ }
+
+ gc.setForeground(badgeForeground);
+ gc.setBackground(badgeBackground);
+
+ final Point textSize = getBadgeTextSizeInPixels();
+ final Rectangle area = getClientArea();
+ final int width = Math.max(buttonSize.x, area.width - 2 * MARGIN) - left;
+ final int height = Math.max(buttonSize.y, area.height - 2 * MARGIN) - top;
+ int badgeWith;
+ if (textSize.x > MAX_BADGE_TEXT_SIZE) {
+ // Draw a round rectangle
+ badgeWith = textSize.x + MAX_BADGE_TEXT_SIZE / 2;
+ } else {
+ // Draw a circle
+ badgeWith = CIRCLE_DIAMETER;
+ }
+
+ int x;
+ switch (horizontalLocation) {
+ case SWT.RIGHT:
+ x = left + width - badgeWith / 2;
+ break;
+ case SWT.LEFT:
+ x = left - badgeWith / 2;
+ break;
+ default:
+ return;
+ }
+
+ int y;
+ switch (verticalLocation) {
+ case SWT.TOP:
+ y = top - CIRCLE_DIAMETER / 2;
+ break;
+ case SWT.BOTTOM:
+ y = top + height - CIRCLE_DIAMETER / 2;
+ break;
+ default:
+ return;
+ }
+ if (textSize.x > MAX_BADGE_TEXT_SIZE) {
+ // Draw a round rectangle
+ gc.fillRoundRectangle(x, y, badgeWith, CIRCLE_DIAMETER, 3, 3);
+ } else {
+ // Draw a circle
+ gc.fillOval(x, y, CIRCLE_DIAMETER, CIRCLE_DIAMETER);
+ }
+ gc.setFont(badgeFont);
+ gc.drawText(badgeValue, x + (badgeWith - textSize.x) / 2, y + (CIRCLE_DIAMETER - textSize.y) / 2, true);
+ }
+
+ private Point getBadgeTextSizeInPixels() {
+ if (badgeTextSizeCache != null) {
+ return badgeTextSizeCache;
+ }
+ final GC gc = new GC(this);
+ gc.setFont(badgeFont);
+ badgeTextSizeCache = gc.stringExtent(badgeValue);
+ gc.dispose();
+ return badgeTextSizeCache;
+
+ }
+
+ /**
+ * Sets the badge's color theme to the theme specified by the argument
+ *
+ * @param color
+ * the new color, can pick one of the following value:
+ * SWT.COLOR_BLUE, SWT.COLOR_GRAY, SWT.COLOR_GREEN, SWT.COLOR_RED,
+ * SWT.COLOR_YELLOW, SWT.COLOR_CYAN, SWT.COLOR_BLACK
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_NULL_ARGUMENT - if the argument is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ */
+ public void setPredefinedColor(int color) {
+ checkWidget();
+
+ badgeForeground = getDisplay().getSystemColor(SWT.COLOR_WHITE);
+ switch (color) {
+ case SWT.COLOR_BLUE:
+ badgeBackground = new Color(getDisplay(), 0, 123, 255);
+ break;
+ case SWT.COLOR_GRAY:
+ badgeBackground = new Color(getDisplay(), 108, 117, 125);
+ break;
+ case SWT.COLOR_GREEN:
+ badgeBackground = new Color(getDisplay(), 40, 167, 69);
+ break;
+ case SWT.COLOR_RED:
+ badgeBackground = new Color(getDisplay(), 220, 53, 69);
+ break;
+ case SWT.COLOR_YELLOW:
+ badgeForeground = getDisplay().getSystemColor(SWT.COLOR_BLACK);
+ badgeBackground = new Color(getDisplay(), 255, 193, 7);
+ break;
+ case SWT.COLOR_CYAN:
+ badgeBackground = new Color(getDisplay(), 23, 162, 184);
+ break;
+ default: // BLACK
+ badgeBackground = new Color(getDisplay(), 52, 58, 64);
+ }
+
+ SWTGraphicUtil.addDisposer(this, badgeBackground);
+ }
+
+ /**
+ * @see org.eclipse.swt.widgets.Control#computeSize(int, int, boolean)
+ */
+ @Override
+ public Point computeSize(final int wHint, final int hHint, final boolean changed) {
+ checkWidget();
+
+ if (image == null && text == null) {
+ return super.computeSize(wHint, hHint, changed);
+ }
+
+ // Button
+ final Point buttonSize = computeButtonSize();
+ int width = buttonSize.x;
+ int height = buttonSize.y;
+
+ // Margin
+ width += 3 * MARGIN;
+ height += 3 * MARGIN;
+ return new Point(Math.max(width, wHint), Math.max(height, hHint));
+ }
+
+ private Point computeButtonSize() {
+ int width = 2 * PADDING, height = 2 * PADDING;
+ if (image != null && text == null) {
+ final Rectangle bounds = image.getBounds();
+ width += bounds.width;
+ height = Math.max(height, bounds.height + 2 * PADDING);
+ } else if (text != null && image == null) {
+ final Point extent = getTextSizeInPixels();
+ width = Math.max(width, extent.x + 2 * PADDING);
+ height = height + extent.y;
+ } else {
+ final Rectangle bounds = image.getBounds();
+ final Point extent = getTextSizeInPixels();
+ width += bounds.width + PADDING + extent.x + 2 * PADDING;
+ final int maxTextAndImageHeight = Math.max(extent.y, bounds.y);
+ height = Math.max(height, maxTextAndImageHeight + 2 * PADDING);
+ }
+ return new Point(width, height);
+ }
+
+ /**
+ * Returns the background color that the receiver will use to draw.
+ *
+ * @return the receiver's background color
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ */
+ public Color getBackgroundColor() {
+ checkWidget();
+ return backgroundColor;
+ }
+
+ /**
+ * Returns the background color that the badge will use to draw.
+ *
+ * @return the badge's backdground color
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ */
+ public Color getBadgeBackground() {
+ checkWidget();
+ return badgeBackground;
+ }
+
+ /**
+ * Returns the foreground color that the badge will use to draw.
+ *
+ * @return the badge's foreground color
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ */
+ public Color getBadgeForeground() {
+ checkWidget();
+ return badgeForeground;
+ }
+
+ /**
+ * Returns the text of the badge
+ *
+ * @return the badge's text
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ */
+ public String getBadgeValue() {
+ checkWidget();
+ return badgeValue;
+ }
+
+ /**
+ * Returns the border color that the receiver will use to draw.
+ *
+ * @return the receiver's border color
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ */
+ public Color getBorderColor() {
+ checkWidget();
+ return borderColor;
+ }
+
+ /**
+ * Returns the receiver's image if it has one, or null if it does not.
+ *
+ * @return the receiver's image
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ */
+ public Image getImage() {
+ checkWidget();
+ return image;
+ }
+
+ /**
+ * Returns the receiver's text, which will be an empty string if it has never
+ * been set or if the receiver is a SEPARATOR label.
+ *
+ * @return the receiver's text
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ */
+ public String getText() {
+ checkWidget();
+ return text;
+ }
+
+ /**
+ * Returns the text color that the receiver will use to draw.
+ *
+ * @return the receiver's text color
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ */
+ public Color getTextColor() {
+ checkWidget();
+ return textColor;
+ }
+
+ /**
+ * Sets the receiver's background color to the color specified by the argument
+ *
+ * @param color
+ * the new color
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument has been
+ * disposed
+ *
ERROR_NULL_ARGUMENT - if the argument is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ */
+ public void setBackgroundColor(Color backgroundColor) {
+ checkWidget();
+ checkColor(backgroundColor);
+ this.backgroundColor = backgroundColor;
+ }
+
+ private void checkColor(Color color) {
+ if (color == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (color.isDisposed()) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ }
+
+ /**
+ * Sets the badge's background color to the color specified by the argument
+ *
+ * @param color
+ * the new color
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument has been
+ * disposed
+ *
ERROR_NULL_ARGUMENT - if the argument is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ */
+ public void setBadgeBackground(Color badgeBackground) {
+ checkWidget();
+ checkColor(badgeBackground);
+ this.badgeBackground = badgeBackground;
+ }
+
+ /**
+ * Sets the badge's foreground color to the color specified by the argument
+ *
+ * @param color
+ * the new color
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument has been
+ * disposed
+ *
ERROR_NULL_ARGUMENT - if the argument is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ */
+ public void setBadgeForeground(Color badgeForeground) {
+ checkWidget();
+ checkColor(badgeForeground);
+ this.badgeForeground = badgeForeground;
+ }
+
+ /**
+ * Sets the badge's value (text) to the text specified by the argument
+ *
+ * @param value
+ * the new text value
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_NULL_ARGUMENT - if the argument is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ */
+ public void setBadgeValue(String value) {
+ checkWidget();
+ if (value == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ badgeValue = value;
+ badgeTextSizeCache = null;
+ }
+
+ /**
+ * Sets the receiver's border color to the color specified by the argument
+ *
+ * @param color
+ * the new color
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument has been
+ * disposed
+ *
ERROR_NULL_ARGUMENT - if the argument is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ */
+ public void setBorderColor(Color borderColor) {
+ checkWidget();
+ checkColor(borderColor);
+ this.borderColor = borderColor;
+ }
+
+ /**
+ * @see org.eclipse.swt.widgets.Control#setEnabled(boolean)
+ */
+ @Override
+ public void setEnabled(boolean enabled) {
+ super.setEnabled(enabled);
+ redraw();
+ }
+
+ /**
+ * @see org.eclipse.swt.widgets.Canvas#setFont(org.eclipse.swt.graphics.Font)
+ */
+ @Override
+ public void setFont(Font font) {
+ super.setFont(font);
+ textSizeCache = null;
+ boldFont.dispose();
+ boldFont = SWTGraphicUtil.buildFontFrom(this, SWT.BOLD);
+ }
+
+ /**
+ * Sets the receiver's image to the argument, which may be null indicating that
+ * no image should be displayed.
+ *
+ * @param image
+ * the image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the image has been
+ * disposed
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ * This method sets the widget label. The label may include the mnemonic
+ * character and line delimiters.
+ *
+ *
+ * Mnemonics are indicated by an '&' that causes the next character to be
+ * the mnemonic. When the user presses a key sequence that matches the mnemonic,
+ * focus is assigned to the control that follows the label. On most platforms,
+ * the mnemonic appears underlined but may be emphasised in a platform specific
+ * manner. The mnemonic indicator character '&' can be escaped by doubling
+ * it in the string, causing a single '&' to be displayed.
+ *
+ *
+ * Note: If control characters like '\n', '\t' etc. are used in the string, then
+ * the behavior is platform dependent.
+ *
+ *
+ * @param string
+ * the new text
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_NULL_ARGUMENT - if the text is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ */
+ public void setText(String text) {
+ checkWidget();
+ textSizeCache = null;
+ this.text = text;
+ }
+
+ /**
+ * Sets the receiver's text color to the color specified by the argument
+ *
+ * @param color
+ * the new color
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument has been
+ * disposed
+ *
ERROR_NULL_ARGUMENT - if the argument is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ */
+ public void setTextColor(Color textColor) {
+ checkWidget();
+ checkColor(textColor);
+ this.textColor = textColor;
+ }
+
+}
diff --git a/widgets/badgedlabel/pom.xml b/widgets/badgedlabel/pom.xml
index a003247a3..e874ae13f 100644
--- a/widgets/badgedlabel/pom.xml
+++ b/widgets/badgedlabel/pom.xml
@@ -1,23 +1,23 @@
-
-
- 4.0.0
-
-
- org.eclipse.nebula
- 1.0.0-SNAPSHOT
- nebula-parent
- ../../releng/org.eclipse.nebula.nebula-parent
-
-
- badgedlabel
- pom
- 1.0.0-SNAPSHOT
-
-
- org.eclipse.nebula.widgets.badgedlabel
- org.eclipse.nebula.widgets.badgedlabel.feature
- org.eclipse.nebula.widgets.badgedlabel.snippets
-
-
-
+
+
+ 4.0.0
+
+
+ org.eclipse.nebula
+ 1.0.0-SNAPSHOT
+ nebula-parent
+ ../../releng/org.eclipse.nebula.nebula-parent
+
+
+ badgedlabel
+ pom
+ 1.0.0-SNAPSHOT
+
+
+ org.eclipse.nebula.widgets.badgedlabel
+ org.eclipse.nebula.widgets.badgedlabel.feature
+ org.eclipse.nebula.widgets.badgedlabel.snippets
+
+
+
diff --git a/widgets/calendarcombo/org.eclipse.nebula.widgets.calendarcombo.example/.project b/widgets/calendarcombo/org.eclipse.nebula.widgets.calendarcombo.example/.project
index 78c10f40d..3913de68c 100644
--- a/widgets/calendarcombo/org.eclipse.nebula.widgets.calendarcombo.example/.project
+++ b/widgets/calendarcombo/org.eclipse.nebula.widgets.calendarcombo.example/.project
@@ -1,28 +1,28 @@
-
-
- org.eclipse.nebula.widgets.calendarcombo.example
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
-
- org.eclipse.pde.PluginNature
- org.eclipse.jdt.core.javanature
-
-
+
+
+ org.eclipse.nebula.widgets.calendarcombo.example
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/widgets/carousel/org.eclipse.nebula.widgets.carousel.feature/.project b/widgets/carousel/org.eclipse.nebula.widgets.carousel.feature/.project
index 154d3d9c0..47d6830ee 100644
--- a/widgets/carousel/org.eclipse.nebula.widgets.carousel.feature/.project
+++ b/widgets/carousel/org.eclipse.nebula.widgets.carousel.feature/.project
@@ -1,17 +1,17 @@
-
-
- org.eclipse.nebula.widgets.carousel.feature
-
-
-
-
-
- org.eclipse.pde.FeatureBuilder
-
-
-
-
-
- org.eclipse.pde.FeatureNature
-
-
+
+
+ org.eclipse.nebula.widgets.carousel.feature
+
+
+
+
+
+ org.eclipse.pde.FeatureBuilder
+
+
+
+
+
+ org.eclipse.pde.FeatureNature
+
+
diff --git a/widgets/carousel/org.eclipse.nebula.widgets.carousel.feature/build.properties b/widgets/carousel/org.eclipse.nebula.widgets.carousel.feature/build.properties
index f9fa03db0..b40f03f72 100644
--- a/widgets/carousel/org.eclipse.nebula.widgets.carousel.feature/build.properties
+++ b/widgets/carousel/org.eclipse.nebula.widgets.carousel.feature/build.properties
@@ -1,4 +1,4 @@
-bin.includes = feature.xml,\
- epl-2.0.html,\
- feature.properties,\
- license.html
+bin.includes = feature.xml,\
+ epl-2.0.html,\
+ feature.properties,\
+ license.html
diff --git a/widgets/carousel/org.eclipse.nebula.widgets.carousel.feature/feature.properties b/widgets/carousel/org.eclipse.nebula.widgets.carousel.feature/feature.properties
index ce26a1b1f..9dd2dd546 100644
--- a/widgets/carousel/org.eclipse.nebula.widgets.carousel.feature/feature.properties
+++ b/widgets/carousel/org.eclipse.nebula.widgets.carousel.feature/feature.properties
@@ -1,148 +1,148 @@
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-licenseURL=license.html
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-license=\
-Eclipse Foundation Software User Agreement\n\
-\n\
-November 22, 2017\n\
-\n\
-Usage Of Content\n\
-\n\
-THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION\n\
-AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF\n\
-THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE\n\
-TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
-BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED\n\
-BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE\n\
-AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY\n\
-APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU\n\
-MAY NOT USE THE CONTENT.\n\
-\n\
-Applicable Licenses\n\
-\n\
-Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\
-is provided to you under the terms and conditions of the Eclipse Public License\n\
-Version 2.0 ("EPL"). A copy of the EPL is provided with this Content and is also\n\
-available at http://www.eclipse.org/legal/epl-2.0. For purposes of the EPL,\n\
-"Program" will mean the Content.\n\
-\n\
-Content includes, but is not limited to, source code, object code, documentation\n\
-and other files maintained in the Eclipse Foundation source code repository\n\
-("Repository") in software modules ("Modules") and made available as\n\
-downloadable archives ("Downloads").\n\
-\n\
-- Content may be structured and packaged into modules to facilitate\n\
- delivering, extending, and upgrading the Content. Typical modules may\n\
- include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and\n\
- features ("Features").\n\
-- Each Plug-in or Fragment may be packaged as a sub-directory or JAR\n\
- (Java\u2122 ARchive) in a directory named "plugins".\n\
-- A Feature is a bundle of one or more Plug-ins and/or Fragments and\n\
- associated material. Each Feature may be packaged as a sub-directory in a\n\
- directory named "features". Within a Feature, files named "feature.xml" may\n\
- contain a list of the names and version numbers of the Plug-ins and/or\n\
- Fragments associated with that Feature.\n\
-- Features may also include other Features ("Included Features"). Within a\n\
- Feature, files named "feature.xml" may contain a list of the names and\n\
- version numbers of Included Features.\n\
-\n\
-The terms and conditions governing Plug-ins and Fragments should be contained in\n\
-files named "about.html" ("Abouts"). The terms and conditions governing Features\n\
-and Included Features should be contained in files named "license.html"\n\
-("Feature Licenses"). Abouts and Feature Licenses may be located in any\n\
-directory of a Download or Module including, but not limited to the following\n\
-locations:\n\
-\n\
-- The top-level (root) directory\n\
-- Plug-in and Fragment directories\n\
-- Inside Plug-ins and Fragments packaged as JARs\n\
-- Sub-directories of the directory named "src" of certain Plug-ins\n\
-- Feature directories\n\
-\n\
-Note: if a Feature made available by the Eclipse Foundation is installed using\n\
-the Provisioning Technology (as defined below), you must agree to a license\n\
-("Feature Update License") during the installation process. If the Feature\n\
-contains Included Features, the Feature Update License should either provide you\n\
-with the terms and conditions governing the Included Features or inform you\n\
-where you can locate them. Feature Update Licenses may be found in the "license"\n\
-property of files named "feature.properties" found within a Feature. Such\n\
-Abouts, Feature Licenses, and Feature Update Licenses contain the terms and\n\
-conditions (or references to such terms and conditions) that govern your use of\n\
-the associated Content in that directory.\n\
-\n\
-THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL\n\
-OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE\n\
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
-\n\
-- Eclipse Public License Version 1.0 (available at\n\
- http://www.eclipse.org/legal/epl-v10.html)\n\
-- Eclipse Distribution License Version 1.0 (available at\n\
- http://www.eclipse.org/licenses/edl-v1.0.html)\n\
-- Common Public License Version 1.0 (available at\n\
- http://www.eclipse.org/legal/cpl-v10.html)\n\
-- Apache Software License 1.1 (available at\n\
- http://www.apache.org/licenses/LICENSE)\n\
-- Apache Software License 2.0 (available at\n\
- http://www.apache.org/licenses/LICENSE-2.0)\n\
-- Mozilla Public License Version 1.1 (available at\n\
- http://www.mozilla.org/MPL/MPL-1.1.html)\n\
-\n\
-IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO\n\
-USE OF THE CONTENT. If no About, Feature License, or Feature Update License is\n\
-provided, please contact the Eclipse Foundation to determine what terms and\n\
-conditions govern that particular Content.\n\
-\n\
-Use of Provisioning Technology\n\
-\n\
-The Eclipse Foundation makes available provisioning software, examples of which\n\
-include, but are not limited to, p2 and the Eclipse Update Manager\n\
-("Provisioning Technology") for the purpose of allowing users to install\n\
-software, documentation, information and/or other materials (collectively\n\
-"Installable Software"). This capability is provided with the intent of allowing\n\
-such users to install, extend and update Eclipse-based products. Information\n\
-about packaging Installable Software is available at\n\
-http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\
-\n\
-You may use Provisioning Technology to allow other parties to install\n\
-Installable Software. You shall be responsible for enabling the applicable\n\
-license agreements relating to the Installable Software to be presented to, and\n\
-accepted by, the users of the Provisioning Technology in accordance with the\n\
-Specification. By using Provisioning Technology in such a manner and making it\n\
-available in accordance with the Specification, you further acknowledge your\n\
-agreement to, and the acquisition of all necessary rights to permit the\n\
-following:\n\
-\n\
-1. A series of actions may occur ("Provisioning Process") in which a user may\n\
- execute the Provisioning Technology on a machine ("Target Machine") with the\n\
- intent of installing, extending or updating the functionality of an\n\
- Eclipse-based product.\n\
-2. During the Provisioning Process, the Provisioning Technology may cause third\n\
- party Installable Software or a portion thereof to be accessed and copied to\n\
- the Target Machine.\n\
-3. Pursuant to the Specification, you will provide to the user the terms and\n\
- conditions that govern the use of the Installable Software ("Installable\n\
- Software Agreement") and such Installable Software Agreement shall be\n\
- accessed from the Target Machine in accordance with the Specification. Such\n\
- Installable Software Agreement must inform the user of the terms and\n\
- conditions that govern the Installable Software and must solicit acceptance\n\
- by the end user in the manner prescribed in such Installable\n\
- Software Agreement. Upon such indication of agreement by the user, the\n\
- provisioning Technology will complete installation of the\n\
- Installable Software.\n\
-\n\
-Cryptography\n\
-\n\
-Content may contain encryption software. The country in which you are currently\n\
-may have restrictions on the import, possession, and use, and/or re-export to\n\
-another country, of encryption software. BEFORE using any encryption software,\n\
-please check the country's laws, regulations and policies concerning the import,\n\
-possession, or use, and re-export of encryption software, to see if this is\n\
-permitted.\n\
-\n\
-Java and all Java-based trademarks are trademarks of Oracle Corporation in the\n\
-United States, other countries, or both.\n
-########### end of license property ##########################################
+# "licenseURL" property - URL of the "Feature License"
+# do not translate value - just change to point to a locale-specific HTML page
+licenseURL=license.html
+
+# "license" property - text of the "Feature Update License"
+# should be plain text version of license agreement pointed to be "licenseURL"
+license=\
+Eclipse Foundation Software User Agreement\n\
+\n\
+November 22, 2017\n\
+\n\
+Usage Of Content\n\
+\n\
+THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION\n\
+AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF\n\
+THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE\n\
+TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
+BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED\n\
+BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE\n\
+AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
+TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY\n\
+APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU\n\
+MAY NOT USE THE CONTENT.\n\
+\n\
+Applicable Licenses\n\
+\n\
+Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\
+is provided to you under the terms and conditions of the Eclipse Public License\n\
+Version 2.0 ("EPL"). A copy of the EPL is provided with this Content and is also\n\
+available at http://www.eclipse.org/legal/epl-2.0. For purposes of the EPL,\n\
+"Program" will mean the Content.\n\
+\n\
+Content includes, but is not limited to, source code, object code, documentation\n\
+and other files maintained in the Eclipse Foundation source code repository\n\
+("Repository") in software modules ("Modules") and made available as\n\
+downloadable archives ("Downloads").\n\
+\n\
+- Content may be structured and packaged into modules to facilitate\n\
+ delivering, extending, and upgrading the Content. Typical modules may\n\
+ include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and\n\
+ features ("Features").\n\
+- Each Plug-in or Fragment may be packaged as a sub-directory or JAR\n\
+ (Java\u2122 ARchive) in a directory named "plugins".\n\
+- A Feature is a bundle of one or more Plug-ins and/or Fragments and\n\
+ associated material. Each Feature may be packaged as a sub-directory in a\n\
+ directory named "features". Within a Feature, files named "feature.xml" may\n\
+ contain a list of the names and version numbers of the Plug-ins and/or\n\
+ Fragments associated with that Feature.\n\
+- Features may also include other Features ("Included Features"). Within a\n\
+ Feature, files named "feature.xml" may contain a list of the names and\n\
+ version numbers of Included Features.\n\
+\n\
+The terms and conditions governing Plug-ins and Fragments should be contained in\n\
+files named "about.html" ("Abouts"). The terms and conditions governing Features\n\
+and Included Features should be contained in files named "license.html"\n\
+("Feature Licenses"). Abouts and Feature Licenses may be located in any\n\
+directory of a Download or Module including, but not limited to the following\n\
+locations:\n\
+\n\
+- The top-level (root) directory\n\
+- Plug-in and Fragment directories\n\
+- Inside Plug-ins and Fragments packaged as JARs\n\
+- Sub-directories of the directory named "src" of certain Plug-ins\n\
+- Feature directories\n\
+\n\
+Note: if a Feature made available by the Eclipse Foundation is installed using\n\
+the Provisioning Technology (as defined below), you must agree to a license\n\
+("Feature Update License") during the installation process. If the Feature\n\
+contains Included Features, the Feature Update License should either provide you\n\
+with the terms and conditions governing the Included Features or inform you\n\
+where you can locate them. Feature Update Licenses may be found in the "license"\n\
+property of files named "feature.properties" found within a Feature. Such\n\
+Abouts, Feature Licenses, and Feature Update Licenses contain the terms and\n\
+conditions (or references to such terms and conditions) that govern your use of\n\
+the associated Content in that directory.\n\
+\n\
+THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL\n\
+OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE\n\
+OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
+\n\
+- Eclipse Public License Version 1.0 (available at\n\
+ http://www.eclipse.org/legal/epl-v10.html)\n\
+- Eclipse Distribution License Version 1.0 (available at\n\
+ http://www.eclipse.org/licenses/edl-v1.0.html)\n\
+- Common Public License Version 1.0 (available at\n\
+ http://www.eclipse.org/legal/cpl-v10.html)\n\
+- Apache Software License 1.1 (available at\n\
+ http://www.apache.org/licenses/LICENSE)\n\
+- Apache Software License 2.0 (available at\n\
+ http://www.apache.org/licenses/LICENSE-2.0)\n\
+- Mozilla Public License Version 1.1 (available at\n\
+ http://www.mozilla.org/MPL/MPL-1.1.html)\n\
+\n\
+IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO\n\
+USE OF THE CONTENT. If no About, Feature License, or Feature Update License is\n\
+provided, please contact the Eclipse Foundation to determine what terms and\n\
+conditions govern that particular Content.\n\
+\n\
+Use of Provisioning Technology\n\
+\n\
+The Eclipse Foundation makes available provisioning software, examples of which\n\
+include, but are not limited to, p2 and the Eclipse Update Manager\n\
+("Provisioning Technology") for the purpose of allowing users to install\n\
+software, documentation, information and/or other materials (collectively\n\
+"Installable Software"). This capability is provided with the intent of allowing\n\
+such users to install, extend and update Eclipse-based products. Information\n\
+about packaging Installable Software is available at\n\
+http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\
+\n\
+You may use Provisioning Technology to allow other parties to install\n\
+Installable Software. You shall be responsible for enabling the applicable\n\
+license agreements relating to the Installable Software to be presented to, and\n\
+accepted by, the users of the Provisioning Technology in accordance with the\n\
+Specification. By using Provisioning Technology in such a manner and making it\n\
+available in accordance with the Specification, you further acknowledge your\n\
+agreement to, and the acquisition of all necessary rights to permit the\n\
+following:\n\
+\n\
+1. A series of actions may occur ("Provisioning Process") in which a user may\n\
+ execute the Provisioning Technology on a machine ("Target Machine") with the\n\
+ intent of installing, extending or updating the functionality of an\n\
+ Eclipse-based product.\n\
+2. During the Provisioning Process, the Provisioning Technology may cause third\n\
+ party Installable Software or a portion thereof to be accessed and copied to\n\
+ the Target Machine.\n\
+3. Pursuant to the Specification, you will provide to the user the terms and\n\
+ conditions that govern the use of the Installable Software ("Installable\n\
+ Software Agreement") and such Installable Software Agreement shall be\n\
+ accessed from the Target Machine in accordance with the Specification. Such\n\
+ Installable Software Agreement must inform the user of the terms and\n\
+ conditions that govern the Installable Software and must solicit acceptance\n\
+ by the end user in the manner prescribed in such Installable\n\
+ Software Agreement. Upon such indication of agreement by the user, the\n\
+ provisioning Technology will complete installation of the\n\
+ Installable Software.\n\
+\n\
+Cryptography\n\
+\n\
+Content may contain encryption software. The country in which you are currently\n\
+may have restrictions on the import, possession, and use, and/or re-export to\n\
+another country, of encryption software. BEFORE using any encryption software,\n\
+please check the country's laws, regulations and policies concerning the import,\n\
+possession, or use, and re-export of encryption software, to see if this is\n\
+permitted.\n\
+\n\
+Java and all Java-based trademarks are trademarks of Oracle Corporation in the\n\
+United States, other countries, or both.\n
+########### end of license property ##########################################
diff --git a/widgets/carousel/org.eclipse.nebula.widgets.carousel.feature/feature.xml b/widgets/carousel/org.eclipse.nebula.widgets.carousel.feature/feature.xml
index 3d184bd8b..867f8172e 100644
--- a/widgets/carousel/org.eclipse.nebula.widgets.carousel.feature/feature.xml
+++ b/widgets/carousel/org.eclipse.nebula.widgets.carousel.feature/feature.xml
@@ -1,34 +1,34 @@
-
-
-
-
- Chips Widget
-
-
-
- %license
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ Chips Widget
+
+
+
+ %license
+
+
+
+
+
+
+
+
+
+
+
diff --git a/widgets/carousel/org.eclipse.nebula.widgets.carousel.feature/pom.xml b/widgets/carousel/org.eclipse.nebula.widgets.carousel.feature/pom.xml
index 051bde005..1863acf4b 100644
--- a/widgets/carousel/org.eclipse.nebula.widgets.carousel.feature/pom.xml
+++ b/widgets/carousel/org.eclipse.nebula.widgets.carousel.feature/pom.xml
@@ -1,31 +1,31 @@
-
-
-
- 4.0.0
-
-
- org.eclipse.nebula
- carousel
- 1.0.0-SNAPSHOT
-
-
- org.eclipse.nebula.widgets.carousel.feature
- eclipse-feature
- 1.0.0-SNAPSHOT
-
- Nebula Carousel Feature
-
-
+
+
+
+ 4.0.0
+
+
+ org.eclipse.nebula
+ carousel
+ 1.0.0-SNAPSHOT
+
+
+ org.eclipse.nebula.widgets.carousel.feature
+ eclipse-feature
+ 1.0.0-SNAPSHOT
+
+ Nebula Carousel Feature
+
+
diff --git a/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/.classpath b/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/.classpath
index ca3785c41..e801ebfb4 100644
--- a/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/.classpath
+++ b/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/.classpath
@@ -1,7 +1,7 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/.project b/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/.project
index 0cbf56274..392342958 100644
--- a/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/.project
+++ b/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/.project
@@ -1,28 +1,28 @@
-
-
- org.eclipse.nebula.widgets.carousel.snippets
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
-
- org.eclipse.pde.PluginNature
- org.eclipse.jdt.core.javanature
-
-
+
+
+ org.eclipse.nebula.widgets.carousel.snippets
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/.settings/org.eclipse.jdt.core.prefs b/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/.settings/org.eclipse.jdt.core.prefs
index 11265a345..7adc0fb9a 100644
--- a/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/.settings/org.eclipse.jdt.core.prefs
+++ b/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,10 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
-org.eclipse.jdt.core.compiler.compliance=11
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
-org.eclipse.jdt.core.compiler.release=enabled
-org.eclipse.jdt.core.compiler.source=11
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
+org.eclipse.jdt.core.compiler.compliance=11
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=11
diff --git a/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/META-INF/MANIFEST.MF b/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/META-INF/MANIFEST.MF
index 87219ffdd..51a6cacf3 100644
--- a/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/META-INF/MANIFEST.MF
+++ b/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/META-INF/MANIFEST.MF
@@ -1,10 +1,10 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Nebula Carousel Snippets
-Bundle-SymbolicName: org.eclipse.nebula.widgets.carousel.snippets
-Bundle-Version: 1.0.0.qualifier
-Bundle-Vendor: Eclipse Nebula
-Bundle-RequiredExecutionEnvironment: JavaSE-11
-Require-Bundle: org.eclipse.nebula.widgets.carousel;bundle-version="1.0.0",
- org.eclipse.swt
-Automatic-Module-Name: org.eclipse.nebula.widgets.carousel.snippets
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Nebula Carousel Snippets
+Bundle-SymbolicName: org.eclipse.nebula.widgets.carousel.snippets
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: Eclipse Nebula
+Bundle-RequiredExecutionEnvironment: JavaSE-11
+Require-Bundle: org.eclipse.nebula.widgets.carousel;bundle-version="1.0.0",
+ org.eclipse.swt
+Automatic-Module-Name: org.eclipse.nebula.widgets.carousel.snippets
diff --git a/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/build.properties b/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/build.properties
index 41eb6ade2..34d2e4d2d 100644
--- a/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/build.properties
+++ b/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/build.properties
@@ -1,4 +1,4 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/pom.xml b/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/pom.xml
index 981682fa7..f5430b5af 100644
--- a/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/pom.xml
+++ b/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/pom.xml
@@ -1,24 +1,24 @@
-
-
-
- 4.0.0
-
-
- org.eclipse.nebula
- carousel
- 1.0.0-SNAPSHOT
-
-
- org.eclipse.nebula.widgets.carousel.snippets
- eclipse-plugin
-
-
+
+
+
+ 4.0.0
+
+
+ org.eclipse.nebula
+ carousel
+ 1.0.0-SNAPSHOT
+
+
+ org.eclipse.nebula.widgets.carousel.snippets
+ eclipse-plugin
+
+
diff --git a/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/src/org/eclipse/nebula/widgets/chips/CarouselSnippet.java b/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/src/org/eclipse/nebula/widgets/chips/CarouselSnippet.java
index 8ec50de2e..4f3843efe 100644
--- a/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/src/org/eclipse/nebula/widgets/chips/CarouselSnippet.java
+++ b/widgets/carousel/org.eclipse.nebula.widgets.carousel.snippets/src/org/eclipse/nebula/widgets/chips/CarouselSnippet.java
@@ -1,66 +1,66 @@
-/*******************************************************************************
- * Copyright (c) 2020 Laurent CARON.
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors: Laurent CARON (laurent.caron at gmail dot com) - initial API and
- * implementation
- *******************************************************************************/
-package org.eclipse.nebula.widgets.chips;
-
-import org.eclipse.nebula.widgets.carousel.Carousel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Snippet for the Carousel widget
- */
-public class CarouselSnippet {
-
- private static Shell shell;
-
- /**
- * @param args
- */
- public static void main(final String[] args) {
- final Display display = new Display();
- shell = new Shell(display);
- shell.setText("Carousel Snippet");
- shell.setLayout(new FillLayout());
- shell.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
-
- final Carousel carousel = new Carousel(shell, SWT.NONE);
- carousel.addImage(loadImage("images/first.png"));
- carousel.addImage(loadImage("images/second.jpg"));
- carousel.addImage(loadImage("images/third.png"));
-
- final Listener listener = event -> {
- System.out.println("Click on " + carousel.getSelection());
- };
- carousel.addListener(SWT.Selection, listener);
-
- shell.pack();
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
-
- display.dispose();
-
- }
-
- private static Image loadImage(final String img) {
- return new Image(shell.getDisplay(), CarouselSnippet.class.getResourceAsStream(img));
- }
-
+/*******************************************************************************
+ * Copyright (c) 2020 Laurent CARON.
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors: Laurent CARON (laurent.caron at gmail dot com) - initial API and
+ * implementation
+ *******************************************************************************/
+package org.eclipse.nebula.widgets.chips;
+
+import org.eclipse.nebula.widgets.carousel.Carousel;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Snippet for the Carousel widget
+ */
+public class CarouselSnippet {
+
+ private static Shell shell;
+
+ /**
+ * @param args
+ */
+ public static void main(final String[] args) {
+ final Display display = new Display();
+ shell = new Shell(display);
+ shell.setText("Carousel Snippet");
+ shell.setLayout(new FillLayout());
+ shell.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+
+ final Carousel carousel = new Carousel(shell, SWT.NONE);
+ carousel.addImage(loadImage("images/first.png"));
+ carousel.addImage(loadImage("images/second.jpg"));
+ carousel.addImage(loadImage("images/third.png"));
+
+ final Listener listener = event -> {
+ System.out.println("Click on " + carousel.getSelection());
+ };
+ carousel.addListener(SWT.Selection, listener);
+
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+
+ display.dispose();
+
+ }
+
+ private static Image loadImage(final String img) {
+ return new Image(shell.getDisplay(), CarouselSnippet.class.getResourceAsStream(img));
+ }
+
}
\ No newline at end of file
diff --git a/widgets/carousel/org.eclipse.nebula.widgets.carousel/.classpath b/widgets/carousel/org.eclipse.nebula.widgets.carousel/.classpath
index ca3785c41..e801ebfb4 100644
--- a/widgets/carousel/org.eclipse.nebula.widgets.carousel/.classpath
+++ b/widgets/carousel/org.eclipse.nebula.widgets.carousel/.classpath
@@ -1,7 +1,7 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/widgets/carousel/org.eclipse.nebula.widgets.carousel/.project b/widgets/carousel/org.eclipse.nebula.widgets.carousel/.project
index 7761b0ded..36ddd0982 100644
--- a/widgets/carousel/org.eclipse.nebula.widgets.carousel/.project
+++ b/widgets/carousel/org.eclipse.nebula.widgets.carousel/.project
@@ -1,28 +1,28 @@
-
-
- org.eclipse.nebula.widgets.carousel
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
-
- org.eclipse.pde.PluginNature
- org.eclipse.jdt.core.javanature
-
-
+
+
+ org.eclipse.nebula.widgets.carousel
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/widgets/carousel/org.eclipse.nebula.widgets.carousel/.settings/org.eclipse.jdt.core.prefs b/widgets/carousel/org.eclipse.nebula.widgets.carousel/.settings/org.eclipse.jdt.core.prefs
index 11265a345..7adc0fb9a 100644
--- a/widgets/carousel/org.eclipse.nebula.widgets.carousel/.settings/org.eclipse.jdt.core.prefs
+++ b/widgets/carousel/org.eclipse.nebula.widgets.carousel/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,10 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
-org.eclipse.jdt.core.compiler.compliance=11
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
-org.eclipse.jdt.core.compiler.release=enabled
-org.eclipse.jdt.core.compiler.source=11
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
+org.eclipse.jdt.core.compiler.compliance=11
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=11
diff --git a/widgets/carousel/org.eclipse.nebula.widgets.carousel/META-INF/MANIFEST.MF b/widgets/carousel/org.eclipse.nebula.widgets.carousel/META-INF/MANIFEST.MF
index c999e53fe..53c431024 100644
--- a/widgets/carousel/org.eclipse.nebula.widgets.carousel/META-INF/MANIFEST.MF
+++ b/widgets/carousel/org.eclipse.nebula.widgets.carousel/META-INF/MANIFEST.MF
@@ -1,11 +1,11 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Nebula Carousel Widget
-Bundle-SymbolicName: org.eclipse.nebula.widgets.carousel
-Bundle-Version: 1.0.0.qualifier
-Bundle-Vendor: Eclipse Nebula
-Bundle-RequiredExecutionEnvironment: JavaSE-11
-Export-Package: org.eclipse.nebula.widgets.carousel
-Require-Bundle: org.eclipse.nebula.widgets.opal.commons;visibility:=reexport,
- org.eclipse.swt
-Automatic-Module-Name: org.eclipse.nebula.widgets.carousel
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Nebula Carousel Widget
+Bundle-SymbolicName: org.eclipse.nebula.widgets.carousel
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: Eclipse Nebula
+Bundle-RequiredExecutionEnvironment: JavaSE-11
+Export-Package: org.eclipse.nebula.widgets.carousel
+Require-Bundle: org.eclipse.nebula.widgets.opal.commons;visibility:=reexport,
+ org.eclipse.swt
+Automatic-Module-Name: org.eclipse.nebula.widgets.carousel
diff --git a/widgets/carousel/org.eclipse.nebula.widgets.carousel/build.properties b/widgets/carousel/org.eclipse.nebula.widgets.carousel/build.properties
index 41eb6ade2..34d2e4d2d 100644
--- a/widgets/carousel/org.eclipse.nebula.widgets.carousel/build.properties
+++ b/widgets/carousel/org.eclipse.nebula.widgets.carousel/build.properties
@@ -1,4 +1,4 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/widgets/carousel/org.eclipse.nebula.widgets.carousel/pom.xml b/widgets/carousel/org.eclipse.nebula.widgets.carousel/pom.xml
index b4adae8e9..9ae8c8020 100644
--- a/widgets/carousel/org.eclipse.nebula.widgets.carousel/pom.xml
+++ b/widgets/carousel/org.eclipse.nebula.widgets.carousel/pom.xml
@@ -1,24 +1,24 @@
-
-
-
- 4.0.0
-
-
- org.eclipse.nebula
- carousel
- 1.0.0-SNAPSHOT
-
-
- org.eclipse.nebula.widgets.carousel
- eclipse-plugin
-
-
+
+
+
+ 4.0.0
+
+
+ org.eclipse.nebula
+ carousel
+ 1.0.0-SNAPSHOT
+
+
+ org.eclipse.nebula.widgets.carousel
+ eclipse-plugin
+
+
diff --git a/widgets/carousel/org.eclipse.nebula.widgets.carousel/src/org/eclipse/nebula/widgets/carousel/Carousel.java b/widgets/carousel/org.eclipse.nebula.widgets.carousel/src/org/eclipse/nebula/widgets/carousel/Carousel.java
index b735fe698..29e6f1b6e 100644
--- a/widgets/carousel/org.eclipse.nebula.widgets.carousel/src/org/eclipse/nebula/widgets/carousel/Carousel.java
+++ b/widgets/carousel/org.eclipse.nebula.widgets.carousel/src/org/eclipse/nebula/widgets/carousel/Carousel.java
@@ -1,487 +1,487 @@
-/*******************************************************************************
- * Copyright (c) 2020 Laurent CARON.
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors: Laurent CARON (laurent.caron at gmail dot com) - initial API and
- * implementation
- *******************************************************************************/
-package org.eclipse.nebula.widgets.carousel;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.nebula.widgets.opal.commons.SWTGraphicUtil;
-import org.eclipse.nebula.widgets.opal.commons.SelectionListenerUtil;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * Instances of this class represent a "Carousel". This is a component that displays numerous images, and ones can navigate through images.
- *
- *
- *
Styles:
- *
(none)
- *
Events:
- *
SWT.Selection
- *
- */
-public class Carousel extends Composite {
-
- int selection = 0;
- final ImageContainer imageContainer;
- final ImageSelector imageSelector;
- private List images = new ArrayList<>();
-
- /**
- * Constructs a new instance of this class given its parent and a style value
- * describing its behavior and appearance.
- *
- * The style value is either one of the style constants defined in class
- * SWT which is applicable to instances of this class, or must be
- * built by bitwise OR'ing together (that is, using the
- * int "|" operator) two or more of those SWT style
- * constants. The class description lists the style constants that are
- * applicable to the class. Style bits are also inherited from superclasses.
- *
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_NULL_ARGUMENT - if the parent is null
- *
- * @exception SWTException
- *
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the parent
- *
ERROR_INVALID_SUBCLASS - if this class is not an allowed
- * subclass
- *
- *
- */
- public Carousel(final Composite parent, final int style) {
- super(parent, checkStyle(style));
- setLayout(new GridLayout());
- imageContainer = new ImageContainer(this, SWT.NONE);
- imageContainer.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
- imageSelector = new ImageSelector(this, SWT.NONE);
- imageSelector.setLayoutData(new GridData(GridData.END, GridData.FILL, false, false));
-
- initDefaultColors();
- addListener(SWT.KeyUp, e -> {
- if (e.keyCode == SWT.ARROW_LEFT) {
- imageContainer.movePrevious();
- }
- if (e.keyCode == SWT.ARROW_RIGHT) {
- imageContainer.moveNext();
- }
- });
- }
-
- private static int checkStyle(final int style) {
- final int mask = SWT.BORDER;
- final int newStyle = style & mask;
- return newStyle;
- }
-
- private void initDefaultColors() {
- setArrowColor(getDisplay().getSystemColor(SWT.COLOR_BLACK));
- setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
- setCircleBackground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
- setCircleForeground(SWTGraphicUtil.getColorSafely(153, 153, 153));
- setCircleHoverColor(SWTGraphicUtil.getColorSafely(102, 102, 102));
- }
-
- /**
- * Adds the image to the collection of images
- *
- * @param image the image to add
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_NULL_ARGUMENT - if image is null
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- *
- * @see Image
- * @see #removeImage
- */
- public void addImage(final Image image) {
- checkWidget();
- if (image == null) {
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- }
- images.add(image);
- imageContainer.setImage(images.get(selection));
- layout();
- }
-
-
-
- /**
- * Adds the listener to the collection of listeners who will be notified when
- * the control is selected by the user, by sending it one of the messages
- * defined in the SelectionListener interface.
- *
- * widgetDefaultSelected is not called.
- *
- *
- * @param listener the listener which should be notified when the control is
- * selected by the user,
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_NULL_ARGUMENT - if the listener is null
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
- public void addSelectionListener(final SelectionListener listener) {
- checkWidget();
- SelectionListenerUtil.addSelectionListener(this, listener);
- }
-
- /**
- * Remove the image to the collection of images
- *
- * @param image the image to remove
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_NULL_ARGUMENT - if image is null
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- *
- * @see Image
- * @see #removeImage
- */
- public void removeImage(final Image image) {
- checkWidget();
- if (image == null) {
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- }
- images.remove(image);
- }
-
- /**
- * Removes the listener from the collection of listeners who will be notified
- * when the control is selected by the user.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_NULL_ARGUMENT - if the listener is null
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public Color getArrowColor() {
- checkWidget();
- return imageSelector.arrowColor;
- }
-
- /**
- * Returns the receiver's circle background (when selected).
- *
- * @return the circle background color
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public Color getCircleBackground() {
- checkWidget();
- return imageSelector.circleBackground;
- }
-
- /**
- * Returns the receiver's circle foreground color.
- *
- * @return the circle foreground color
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public Color getCircleForeground() {
- checkWidget();
- return imageSelector.circleForeground;
- }
-
- /**
- * Returns the receiver's circle foreground color when mouse is over.
- *
- * @return the circle foreground color when mouse is over
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public Color getCircleHoverColor() {
- checkWidget();
- return imageSelector.circleHoverColor;
- }
-
- /**
- * Returns the receiver's list of images.
- *
- * @return the list of images
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public List getImages() {
- checkWidget();
- return images;
- }
-
- /**
- * Returns true if the receiver is selected,
- * and false otherwise.
- *
- * Note: This operation is only available if the SWT.CHECK or the SWT.PUSH flag is set.
- *
- *
- * @return the selection state
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public int getSelection() {
- checkWidget();
- return selection;
- }
-
- /**
- * Sets the receiver's arrow color to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setArrowColor(final Color arrowColor) {
- checkWidget();
- imageSelector.arrowColor = arrowColor;
- imageSelector.redraw();
- }
-
- /**
- * @see org.eclipse.swt.widgets.Control#setBackground(org.eclipse.swt.graphics.Color)
- */
- @Override
- public void setBackground(final Color color) {
- super.setBackground(color);
- imageContainer.setBackground(color);
- imageSelector.setBackground(color);
- }
-
- /**
- * Sets the receiver's circle selection color to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setCircleBackground(final Color circleBackground) {
- checkWidget();
- imageSelector.circleBackground = circleBackground;
- imageSelector.redraw();
- }
-
- /**
- * Sets the circle's foreground color to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setCircleForeground(final Color circleForeground) {
- checkWidget();
- imageSelector.circleForeground = circleForeground;
- imageSelector.redraw();
- }
-
- /**
- * Sets the circle's foreground color (when mouse hover) to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setCircleHoverColor(final Color circleHoverColor) {
- checkWidget();
- imageSelector.circleHoverColor = circleHoverColor;
- imageSelector.redraw();
- }
-
- /**
- * Sets the receiver's list of images.
- *
- * @param images the new list of images
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_NULL_ARGUMENT - if the argument is null
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setImages(final List images) {
- checkWidget();
- if (images == null) {
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- }
- this.images = images;
- selection = 0;
- imageContainer.setImage(images.get(selection));
- layout();
- }
-
- /**
- * Sets the selection state of the receiver, if it is of type CHECK or
- * PUSH.
- *
- *
- * When the receiver is of type CHECK or RADIO,
- * it is selected when it is checked. When it is of type TOGGLE,
- * it is selected when it is pushed in.
- *
- * @param selected the new selection state
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument is lower than 0 or greater or equals to the number of images
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setSelection(final int selected) {
- checkWidget();
- if (selected < 0 || selected >= images.size()) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- selection = selected;
- imageContainer.setImage(images.get(selection));
- redraw();
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2020 Laurent CARON.
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors: Laurent CARON (laurent.caron at gmail dot com) - initial API and
+ * implementation
+ *******************************************************************************/
+package org.eclipse.nebula.widgets.carousel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.nebula.widgets.opal.commons.SWTGraphicUtil;
+import org.eclipse.nebula.widgets.opal.commons.SelectionListenerUtil;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Instances of this class represent a "Carousel". This is a component that displays numerous images, and ones can navigate through images.
+ *
+ *
+ *
Styles:
+ *
(none)
+ *
Events:
+ *
SWT.Selection
+ *
+ */
+public class Carousel extends Composite {
+
+ int selection = 0;
+ final ImageContainer imageContainer;
+ final ImageSelector imageSelector;
+ private List images = new ArrayList<>();
+
+ /**
+ * Constructs a new instance of this class given its parent and a style value
+ * describing its behavior and appearance.
+ *
+ * The style value is either one of the style constants defined in class
+ * SWT which is applicable to instances of this class, or must be
+ * built by bitwise OR'ing together (that is, using the
+ * int "|" operator) two or more of those SWT style
+ * constants. The class description lists the style constants that are
+ * applicable to the class. Style bits are also inherited from superclasses.
+ *
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_NULL_ARGUMENT - if the parent is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the parent
+ *
ERROR_INVALID_SUBCLASS - if this class is not an allowed
+ * subclass
+ *
+ *
+ */
+ public Carousel(final Composite parent, final int style) {
+ super(parent, checkStyle(style));
+ setLayout(new GridLayout());
+ imageContainer = new ImageContainer(this, SWT.NONE);
+ imageContainer.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
+ imageSelector = new ImageSelector(this, SWT.NONE);
+ imageSelector.setLayoutData(new GridData(GridData.END, GridData.FILL, false, false));
+
+ initDefaultColors();
+ addListener(SWT.KeyUp, e -> {
+ if (e.keyCode == SWT.ARROW_LEFT) {
+ imageContainer.movePrevious();
+ }
+ if (e.keyCode == SWT.ARROW_RIGHT) {
+ imageContainer.moveNext();
+ }
+ });
+ }
+
+ private static int checkStyle(final int style) {
+ final int mask = SWT.BORDER;
+ final int newStyle = style & mask;
+ return newStyle;
+ }
+
+ private void initDefaultColors() {
+ setArrowColor(getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ setCircleBackground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ setCircleForeground(SWTGraphicUtil.getColorSafely(153, 153, 153));
+ setCircleHoverColor(SWTGraphicUtil.getColorSafely(102, 102, 102));
+ }
+
+ /**
+ * Adds the image to the collection of images
+ *
+ * @param image the image to add
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_NULL_ARGUMENT - if image is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ *
+ * @see Image
+ * @see #removeImage
+ */
+ public void addImage(final Image image) {
+ checkWidget();
+ if (image == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ images.add(image);
+ imageContainer.setImage(images.get(selection));
+ layout();
+ }
+
+
+
+ /**
+ * Adds the listener to the collection of listeners who will be notified when
+ * the control is selected by the user, by sending it one of the messages
+ * defined in the SelectionListener interface.
+ *
+ * widgetDefaultSelected is not called.
+ *
+ *
+ * @param listener the listener which should be notified when the control is
+ * selected by the user,
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_NULL_ARGUMENT - if the listener is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+ public void addSelectionListener(final SelectionListener listener) {
+ checkWidget();
+ SelectionListenerUtil.addSelectionListener(this, listener);
+ }
+
+ /**
+ * Remove the image to the collection of images
+ *
+ * @param image the image to remove
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_NULL_ARGUMENT - if image is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ *
+ * @see Image
+ * @see #removeImage
+ */
+ public void removeImage(final Image image) {
+ checkWidget();
+ if (image == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ images.remove(image);
+ }
+
+ /**
+ * Removes the listener from the collection of listeners who will be notified
+ * when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_NULL_ARGUMENT - if the listener is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public Color getArrowColor() {
+ checkWidget();
+ return imageSelector.arrowColor;
+ }
+
+ /**
+ * Returns the receiver's circle background (when selected).
+ *
+ * @return the circle background color
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public Color getCircleBackground() {
+ checkWidget();
+ return imageSelector.circleBackground;
+ }
+
+ /**
+ * Returns the receiver's circle foreground color.
+ *
+ * @return the circle foreground color
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public Color getCircleForeground() {
+ checkWidget();
+ return imageSelector.circleForeground;
+ }
+
+ /**
+ * Returns the receiver's circle foreground color when mouse is over.
+ *
+ * @return the circle foreground color when mouse is over
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public Color getCircleHoverColor() {
+ checkWidget();
+ return imageSelector.circleHoverColor;
+ }
+
+ /**
+ * Returns the receiver's list of images.
+ *
+ * @return the list of images
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public List getImages() {
+ checkWidget();
+ return images;
+ }
+
+ /**
+ * Returns true if the receiver is selected,
+ * and false otherwise.
+ *
+ * Note: This operation is only available if the SWT.CHECK or the SWT.PUSH flag is set.
+ *
+ *
+ * @return the selection state
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public int getSelection() {
+ checkWidget();
+ return selection;
+ }
+
+ /**
+ * Sets the receiver's arrow color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setArrowColor(final Color arrowColor) {
+ checkWidget();
+ imageSelector.arrowColor = arrowColor;
+ imageSelector.redraw();
+ }
+
+ /**
+ * @see org.eclipse.swt.widgets.Control#setBackground(org.eclipse.swt.graphics.Color)
+ */
+ @Override
+ public void setBackground(final Color color) {
+ super.setBackground(color);
+ imageContainer.setBackground(color);
+ imageSelector.setBackground(color);
+ }
+
+ /**
+ * Sets the receiver's circle selection color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setCircleBackground(final Color circleBackground) {
+ checkWidget();
+ imageSelector.circleBackground = circleBackground;
+ imageSelector.redraw();
+ }
+
+ /**
+ * Sets the circle's foreground color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setCircleForeground(final Color circleForeground) {
+ checkWidget();
+ imageSelector.circleForeground = circleForeground;
+ imageSelector.redraw();
+ }
+
+ /**
+ * Sets the circle's foreground color (when mouse hover) to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setCircleHoverColor(final Color circleHoverColor) {
+ checkWidget();
+ imageSelector.circleHoverColor = circleHoverColor;
+ imageSelector.redraw();
+ }
+
+ /**
+ * Sets the receiver's list of images.
+ *
+ * @param images the new list of images
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_NULL_ARGUMENT - if the argument is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setImages(final List images) {
+ checkWidget();
+ if (images == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ this.images = images;
+ selection = 0;
+ imageContainer.setImage(images.get(selection));
+ layout();
+ }
+
+ /**
+ * Sets the selection state of the receiver, if it is of type CHECK or
+ * PUSH.
+ *
+ *
+ * When the receiver is of type CHECK or RADIO,
+ * it is selected when it is checked. When it is of type TOGGLE,
+ * it is selected when it is pushed in.
+ *
+ * @param selected the new selection state
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument is lower than 0 or greater or equals to the number of images
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setSelection(final int selected) {
+ checkWidget();
+ if (selected < 0 || selected >= images.size()) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ selection = selected;
+ imageContainer.setImage(images.get(selection));
+ redraw();
+ }
+
+}
diff --git a/widgets/carousel/org.eclipse.nebula.widgets.carousel/src/org/eclipse/nebula/widgets/carousel/ImageContainer.java b/widgets/carousel/org.eclipse.nebula.widgets.carousel/src/org/eclipse/nebula/widgets/carousel/ImageContainer.java
index 6d8a00207..953fe39a4 100644
--- a/widgets/carousel/org.eclipse.nebula.widgets.carousel/src/org/eclipse/nebula/widgets/carousel/ImageContainer.java
+++ b/widgets/carousel/org.eclipse.nebula.widgets.carousel/src/org/eclipse/nebula/widgets/carousel/ImageContainer.java
@@ -1,208 +1,208 @@
-/*******************************************************************************
- * Copyright (c) 2020 Laurent CARON.
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors: Laurent CARON (laurent.caron at gmail dot com) - initial API and
- * implementation
- *******************************************************************************/
-package org.eclipse.nebula.widgets.carousel;
-
-import java.util.List;
-
-import org.eclipse.nebula.widgets.opal.commons.SelectionListenerUtil;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-
-class ImageContainer extends Canvas {
-
- private Image image, scrollImage;
- private Carousel carousel;
- private int slider;
-
- public ImageContainer(final Carousel parent, final int style) {
- super(parent, SWT.DOUBLE_BUFFERED);
- carousel = parent;
- slider = -1;
- addListener(SWT.Paint, e -> {
- final GC gc = e.gc;
- gc.setAntialias(SWT.ON);
- gc.setInterpolation(SWT.HIGH);
-
- if (image == null) {
- return;
- }
-
- final Rectangle clientArea = getClientArea();
- if (slider == -1) {
- final Rectangle imageBounds = image.getBounds();
- if (imageBounds.width > clientArea.width || imageBounds.height > clientArea.height) {
- // Image is too big
- final Point point = reduceImageSoItFits(image);
- final int newWidth = point.x;
- final int newHeight = point.y;
-
- gc.drawImage(image, 0, 0, imageBounds.width, imageBounds.height, (clientArea.width - newWidth) / 2, (clientArea.height - newHeight) / 2, newWidth, newHeight);
- } else {
- gc.drawImage(image, (clientArea.width - imageBounds.width) / 2, (clientArea.height - imageBounds.height) / 2);
- }
- return;
- }
-
- // Animation
- if (!scrollImage.isDisposed()) {
- gc.drawImage(scrollImage, slider, 0, clientArea.width, clientArea.height, 0, 0, clientArea.width, clientArea.height);
- }
- });
- }
-
- private Point reduceImageSoItFits(final Image img) {
- final Rectangle clientArea = getClientArea();
- final Rectangle imageBounds = img.getBounds();
- final float ratio = imageBounds.width * 1f / imageBounds.height * 1f;
-
- int newWidth = imageBounds.width;
- int newHeight = imageBounds.height;
- while (newWidth > clientArea.width - 5 || newHeight > clientArea.height - 5) {
- newWidth = (int) (newWidth * .9f);
- newHeight = (int) (newWidth / ratio);
- }
- return new Point(newWidth, newHeight);
- }
-
- @Override
- public Point computeSize(final int wHint, final int hHint, final boolean changed) {
- final Point superSize = super.computeSize(wHint, hHint, changed);
-
- int width = 0, height = 0;
- final List images = ((Carousel) getParent()).getImages();
- for (final Image image : images) {
- final Rectangle rect = image.getBounds();
- width = Math.max(width, rect.width);
- height = Math.max(height, rect.height);
- }
- return new Point(Math.max(superSize.x, width), Math.max(superSize.y, height));
- }
-
- void setImage(final Image image) {
- this.image = image;
- }
-
- void moveTo(final int newSelection) {
- final int direction = newSelection > carousel.getSelection() ? SWT.LEFT : SWT.RIGHT;
- slide(newSelection, direction);
- carousel.selection = newSelection;
- SelectionListenerUtil.fireSelectionListeners(carousel,null);
- carousel.imageSelector.redraw();
- }
-
- void moveNext() {
- int newSelection = carousel.selection + 1;
- if (newSelection == carousel.getImages().size()) {
- newSelection = 0;
- }
- slide(newSelection, SWT.LEFT);
- carousel.selection = newSelection;
- SelectionListenerUtil.fireSelectionListeners(carousel,null);
- carousel.imageSelector.redraw();
- }
-
- private void slide(final int target, final int direction) {
- final int width = getClientArea().width;
- slider = direction == SWT.LEFT ? 0 : width;
- if (direction == SWT.LEFT) {
- createScrolledImage(image, carousel.getImages().get(target));
- } else {
- createScrolledImage(carousel.getImages().get(target), image);
- }
-
- getDisplay().timerExec(200, new Runnable() {
-
- @Override
- public void run() {
- ImageContainer.this.redraw();
- final int step = width / 5;
- if (direction == SWT.LEFT) {
- slider += step;
- if (slider >= width) {
- slider = -1;
- scrollImage.dispose();
- return;
- }
- } else {
- slider -= step;
- if (slider <= 0) {
- slider = -1;
- scrollImage.dispose();
- return;
- }
- }
- getDisplay().timerExec(50, this);
- }
- });
-
- image = carousel.getImages().get(target);
- redraw();
- }
-
- private void createScrolledImage(final Image left, final Image right) {
- final Rectangle clientArea = getClientArea();
-
- scrollImage = new Image(getDisplay(), clientArea.width * 2, clientArea.height);
- final GC gc = new GC(scrollImage);
- gc.setInterpolation(SWT.HIGH);
-
- gc.setBackground(carousel.getBackground());
- gc.fillRectangle(0, 0, clientArea.width * 2, clientArea.height);
-
- final Rectangle leftImageBounds = left.getBounds();
- if (leftImageBounds.width > clientArea.width || leftImageBounds.height > clientArea.height) {
- // Image is too big
- final Point point = reduceImageSoItFits(left);
- final int newWidth = point.x;
- final int newHeight = point.y;
-
- gc.drawImage(left, 0, 0, leftImageBounds.width, leftImageBounds.height, //
- (clientArea.width - newWidth) / 2, (clientArea.height - newHeight) / 2, newWidth, newHeight);
- } else {
- gc.drawImage(left, (clientArea.width - leftImageBounds.width) / 2, (clientArea.height - leftImageBounds.height) / 2);
- }
-
- final Rectangle rightImageBounds = right.getBounds();
- if (rightImageBounds.width > clientArea.width || rightImageBounds.height > clientArea.height) {
- // Image is too big
- final Point point = reduceImageSoItFits(right);
- final int newWidth = point.x;
- final int newHeight = point.y;
-
- gc.drawImage(right, 0, 0, rightImageBounds.width, rightImageBounds.height, //
- clientArea.width + (clientArea.width - newWidth) / 2, (clientArea.height - newHeight) / 2, newWidth, newHeight);
- } else {
- gc.drawImage(right, clientArea.width + (clientArea.width - rightImageBounds.width) / 2, (clientArea.height - rightImageBounds.height) / 2);
- }
-
- gc.dispose();
- }
-
-
- void movePrevious() {
- final Carousel carousel = (Carousel) getParent();
- int newSelection = carousel.selection - 1;
- if (newSelection == -1) {
- newSelection = carousel.getImages().size() - 1;
- }
- slide(newSelection, SWT.RIGHT);
- carousel.selection = newSelection;
- SelectionListenerUtil.fireSelectionListeners(carousel,null);
- carousel.imageSelector.redraw();
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2020 Laurent CARON.
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors: Laurent CARON (laurent.caron at gmail dot com) - initial API and
+ * implementation
+ *******************************************************************************/
+package org.eclipse.nebula.widgets.carousel;
+
+import java.util.List;
+
+import org.eclipse.nebula.widgets.opal.commons.SelectionListenerUtil;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+
+class ImageContainer extends Canvas {
+
+ private Image image, scrollImage;
+ private Carousel carousel;
+ private int slider;
+
+ public ImageContainer(final Carousel parent, final int style) {
+ super(parent, SWT.DOUBLE_BUFFERED);
+ carousel = parent;
+ slider = -1;
+ addListener(SWT.Paint, e -> {
+ final GC gc = e.gc;
+ gc.setAntialias(SWT.ON);
+ gc.setInterpolation(SWT.HIGH);
+
+ if (image == null) {
+ return;
+ }
+
+ final Rectangle clientArea = getClientArea();
+ if (slider == -1) {
+ final Rectangle imageBounds = image.getBounds();
+ if (imageBounds.width > clientArea.width || imageBounds.height > clientArea.height) {
+ // Image is too big
+ final Point point = reduceImageSoItFits(image);
+ final int newWidth = point.x;
+ final int newHeight = point.y;
+
+ gc.drawImage(image, 0, 0, imageBounds.width, imageBounds.height, (clientArea.width - newWidth) / 2, (clientArea.height - newHeight) / 2, newWidth, newHeight);
+ } else {
+ gc.drawImage(image, (clientArea.width - imageBounds.width) / 2, (clientArea.height - imageBounds.height) / 2);
+ }
+ return;
+ }
+
+ // Animation
+ if (!scrollImage.isDisposed()) {
+ gc.drawImage(scrollImage, slider, 0, clientArea.width, clientArea.height, 0, 0, clientArea.width, clientArea.height);
+ }
+ });
+ }
+
+ private Point reduceImageSoItFits(final Image img) {
+ final Rectangle clientArea = getClientArea();
+ final Rectangle imageBounds = img.getBounds();
+ final float ratio = imageBounds.width * 1f / imageBounds.height * 1f;
+
+ int newWidth = imageBounds.width;
+ int newHeight = imageBounds.height;
+ while (newWidth > clientArea.width - 5 || newHeight > clientArea.height - 5) {
+ newWidth = (int) (newWidth * .9f);
+ newHeight = (int) (newWidth / ratio);
+ }
+ return new Point(newWidth, newHeight);
+ }
+
+ @Override
+ public Point computeSize(final int wHint, final int hHint, final boolean changed) {
+ final Point superSize = super.computeSize(wHint, hHint, changed);
+
+ int width = 0, height = 0;
+ final List images = ((Carousel) getParent()).getImages();
+ for (final Image image : images) {
+ final Rectangle rect = image.getBounds();
+ width = Math.max(width, rect.width);
+ height = Math.max(height, rect.height);
+ }
+ return new Point(Math.max(superSize.x, width), Math.max(superSize.y, height));
+ }
+
+ void setImage(final Image image) {
+ this.image = image;
+ }
+
+ void moveTo(final int newSelection) {
+ final int direction = newSelection > carousel.getSelection() ? SWT.LEFT : SWT.RIGHT;
+ slide(newSelection, direction);
+ carousel.selection = newSelection;
+ SelectionListenerUtil.fireSelectionListeners(carousel,null);
+ carousel.imageSelector.redraw();
+ }
+
+ void moveNext() {
+ int newSelection = carousel.selection + 1;
+ if (newSelection == carousel.getImages().size()) {
+ newSelection = 0;
+ }
+ slide(newSelection, SWT.LEFT);
+ carousel.selection = newSelection;
+ SelectionListenerUtil.fireSelectionListeners(carousel,null);
+ carousel.imageSelector.redraw();
+ }
+
+ private void slide(final int target, final int direction) {
+ final int width = getClientArea().width;
+ slider = direction == SWT.LEFT ? 0 : width;
+ if (direction == SWT.LEFT) {
+ createScrolledImage(image, carousel.getImages().get(target));
+ } else {
+ createScrolledImage(carousel.getImages().get(target), image);
+ }
+
+ getDisplay().timerExec(200, new Runnable() {
+
+ @Override
+ public void run() {
+ ImageContainer.this.redraw();
+ final int step = width / 5;
+ if (direction == SWT.LEFT) {
+ slider += step;
+ if (slider >= width) {
+ slider = -1;
+ scrollImage.dispose();
+ return;
+ }
+ } else {
+ slider -= step;
+ if (slider <= 0) {
+ slider = -1;
+ scrollImage.dispose();
+ return;
+ }
+ }
+ getDisplay().timerExec(50, this);
+ }
+ });
+
+ image = carousel.getImages().get(target);
+ redraw();
+ }
+
+ private void createScrolledImage(final Image left, final Image right) {
+ final Rectangle clientArea = getClientArea();
+
+ scrollImage = new Image(getDisplay(), clientArea.width * 2, clientArea.height);
+ final GC gc = new GC(scrollImage);
+ gc.setInterpolation(SWT.HIGH);
+
+ gc.setBackground(carousel.getBackground());
+ gc.fillRectangle(0, 0, clientArea.width * 2, clientArea.height);
+
+ final Rectangle leftImageBounds = left.getBounds();
+ if (leftImageBounds.width > clientArea.width || leftImageBounds.height > clientArea.height) {
+ // Image is too big
+ final Point point = reduceImageSoItFits(left);
+ final int newWidth = point.x;
+ final int newHeight = point.y;
+
+ gc.drawImage(left, 0, 0, leftImageBounds.width, leftImageBounds.height, //
+ (clientArea.width - newWidth) / 2, (clientArea.height - newHeight) / 2, newWidth, newHeight);
+ } else {
+ gc.drawImage(left, (clientArea.width - leftImageBounds.width) / 2, (clientArea.height - leftImageBounds.height) / 2);
+ }
+
+ final Rectangle rightImageBounds = right.getBounds();
+ if (rightImageBounds.width > clientArea.width || rightImageBounds.height > clientArea.height) {
+ // Image is too big
+ final Point point = reduceImageSoItFits(right);
+ final int newWidth = point.x;
+ final int newHeight = point.y;
+
+ gc.drawImage(right, 0, 0, rightImageBounds.width, rightImageBounds.height, //
+ clientArea.width + (clientArea.width - newWidth) / 2, (clientArea.height - newHeight) / 2, newWidth, newHeight);
+ } else {
+ gc.drawImage(right, clientArea.width + (clientArea.width - rightImageBounds.width) / 2, (clientArea.height - rightImageBounds.height) / 2);
+ }
+
+ gc.dispose();
+ }
+
+
+ void movePrevious() {
+ final Carousel carousel = (Carousel) getParent();
+ int newSelection = carousel.selection - 1;
+ if (newSelection == -1) {
+ newSelection = carousel.getImages().size() - 1;
+ }
+ slide(newSelection, SWT.RIGHT);
+ carousel.selection = newSelection;
+ SelectionListenerUtil.fireSelectionListeners(carousel,null);
+ carousel.imageSelector.redraw();
+ }
+
+}
diff --git a/widgets/carousel/org.eclipse.nebula.widgets.carousel/src/org/eclipse/nebula/widgets/carousel/ImageSelector.java b/widgets/carousel/org.eclipse.nebula.widgets.carousel/src/org/eclipse/nebula/widgets/carousel/ImageSelector.java
index 023a417fc..8939a1a0b 100644
--- a/widgets/carousel/org.eclipse.nebula.widgets.carousel/src/org/eclipse/nebula/widgets/carousel/ImageSelector.java
+++ b/widgets/carousel/org.eclipse.nebula.widgets.carousel/src/org/eclipse/nebula/widgets/carousel/ImageSelector.java
@@ -1,158 +1,158 @@
-/*******************************************************************************
- * Copyright (c) 2020 Laurent CARON.
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors: Laurent CARON (laurent.caron at gmail dot com) - initial API and
- * implementation
- *******************************************************************************/
-package org.eclipse.nebula.widgets.carousel;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-
-class ImageSelector extends Canvas {
- private static final int CIRCLE_DIAMETER = 20;
- private static final int ARROW_SIZE = 12;
-
- Color arrowColor, circleBackground, circleForeground, circleHoverColor;
- private final List rects = new ArrayList<>();
- private int indexHover = -1;
- private Rectangle arrowLeftArea, arrowRightArea;
- private boolean hoverLeftArrow, hoverRightArrow;
- private final Carousel carousel;
-
- public ImageSelector(final Carousel parent, final int none) {
- super(parent, SWT.DOUBLE_BUFFERED);
- carousel = parent;
-
- addListener(SWT.Paint, e -> {
- final GC gc = e.gc;
- gc.setFont(getFont());
- gc.setAdvanced(true);
- gc.setTextAntialias(SWT.ON);
- gc.setAntialias(SWT.ON);
- final Color previousForeground = gc.getForeground();
- final Color previousBackground = gc.getBackground();
-
- drawContent(gc);
-
- gc.setBackground(previousBackground);
- gc.setForeground(previousForeground);
- });
-
- addListener(SWT.MouseExit, e -> {
- indexHover = -1;
- setCursor(getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
- });
-
- addListener(SWT.MouseMove, e -> {
- Point pt = getDisplay().getCursorLocation();
- pt = getDisplay().map(null, this, pt.x, pt.y);
-
- hoverLeftArrow = arrowLeftArea.contains(pt);
- hoverRightArrow = arrowRightArea.contains(pt);
-
- Cursor expectedCursor = hoverLeftArrow || hoverRightArrow ? getDisplay().getSystemCursor(SWT.CURSOR_HAND) : getDisplay().getSystemCursor(SWT.CURSOR_ARROW);
- indexHover = -1;
- for (int i = 0; i < rects.size(); i++) {
- final Rectangle rect = rects.get(i);
- if (rect.contains(pt)) {
- expectedCursor = getDisplay().getSystemCursor(SWT.CURSOR_HAND);
- indexHover = i;
- break;
- }
- }
-
- if (!expectedCursor.equals(getCursor())) {
- setCursor(expectedCursor);
- }
- redraw();
- });
-
- addListener(SWT.MouseUp, e -> {
- final ImageContainer imageContainer = parent.imageContainer;
- if (hoverLeftArrow) {
- imageContainer.movePrevious();
- } else if (hoverRightArrow) {
- imageContainer.moveNext();
- } else if (indexHover != -1) {
- imageContainer.moveTo(indexHover);
- }
- });
- }
-
- private void drawContent(final GC gc) {
- final int x = drawCircles(gc);
- drawArrows(x, gc);
- }
-
- private int drawCircles(final GC gc) {
- int x = 0;
- final Rectangle clientArea = getClientArea();
- rects.clear();
- for (int i = 0; i < carousel.getImages().size(); i++) {
- final Rectangle rect = new Rectangle(x, (clientArea.height - CIRCLE_DIAMETER) / 2, CIRCLE_DIAMETER, CIRCLE_DIAMETER);
- rects.add(rect);
- if (i == carousel.getSelection()) {
- gc.setBackground(circleBackground);
- gc.fillOval(rect.x, rect.y, CIRCLE_DIAMETER, CIRCLE_DIAMETER);
- } else if (i == indexHover) {
- //
- gc.setForeground(circleHoverColor);
- gc.drawOval(rect.x, rect.y, CIRCLE_DIAMETER, CIRCLE_DIAMETER);
- } else {
- gc.setForeground(circleForeground);
- gc.drawOval(rect.x, rect.y, CIRCLE_DIAMETER, CIRCLE_DIAMETER);
- }
- x += CIRCLE_DIAMETER + 5;
- }
- return x + CIRCLE_DIAMETER;
-
- }
-
- private void drawArrows(int x, final GC gc) {
- gc.setForeground(arrowColor);
-
- final Rectangle clientArea = getClientArea();
- final int topY = (clientArea.height - ARROW_SIZE) / 2;
- final int width = (int) (ARROW_SIZE * .5f);
-
- gc.setLineWidth(hoverLeftArrow ? 3 : 1);
-
- gc.drawPolyline(new int[] { x + width, topY, //
- x, topY + ARROW_SIZE / 2, //
- x + width, topY + ARROW_SIZE });
-
- arrowLeftArea = new Rectangle(x, topY, ARROW_SIZE, ARROW_SIZE);
-
- x += ARROW_SIZE * 3;
-
- gc.setLineWidth(hoverRightArrow ? 3 : 1);
- gc.drawPolyline(new int[] { x, topY, //
- x + width, topY + ARROW_SIZE / 2, //
- x, topY + ARROW_SIZE });
- arrowRightArea = new Rectangle(x, topY, ARROW_SIZE, ARROW_SIZE);
- }
-
- @Override
- public Point computeSize(final int wHint, final int hHint, final boolean changed) {
- final Point superSize = super.computeSize(wHint, hHint, changed);
- final int width = 70 + carousel.getImages().size() * (CIRCLE_DIAMETER + 5);
- final int height = 40;
- return new Point(Math.max(superSize.x, width), Math.max(superSize.y, height));
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2020 Laurent CARON.
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors: Laurent CARON (laurent.caron at gmail dot com) - initial API and
+ * implementation
+ *******************************************************************************/
+package org.eclipse.nebula.widgets.carousel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+
+class ImageSelector extends Canvas {
+ private static final int CIRCLE_DIAMETER = 20;
+ private static final int ARROW_SIZE = 12;
+
+ Color arrowColor, circleBackground, circleForeground, circleHoverColor;
+ private final List rects = new ArrayList<>();
+ private int indexHover = -1;
+ private Rectangle arrowLeftArea, arrowRightArea;
+ private boolean hoverLeftArrow, hoverRightArrow;
+ private final Carousel carousel;
+
+ public ImageSelector(final Carousel parent, final int none) {
+ super(parent, SWT.DOUBLE_BUFFERED);
+ carousel = parent;
+
+ addListener(SWT.Paint, e -> {
+ final GC gc = e.gc;
+ gc.setFont(getFont());
+ gc.setAdvanced(true);
+ gc.setTextAntialias(SWT.ON);
+ gc.setAntialias(SWT.ON);
+ final Color previousForeground = gc.getForeground();
+ final Color previousBackground = gc.getBackground();
+
+ drawContent(gc);
+
+ gc.setBackground(previousBackground);
+ gc.setForeground(previousForeground);
+ });
+
+ addListener(SWT.MouseExit, e -> {
+ indexHover = -1;
+ setCursor(getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
+ });
+
+ addListener(SWT.MouseMove, e -> {
+ Point pt = getDisplay().getCursorLocation();
+ pt = getDisplay().map(null, this, pt.x, pt.y);
+
+ hoverLeftArrow = arrowLeftArea.contains(pt);
+ hoverRightArrow = arrowRightArea.contains(pt);
+
+ Cursor expectedCursor = hoverLeftArrow || hoverRightArrow ? getDisplay().getSystemCursor(SWT.CURSOR_HAND) : getDisplay().getSystemCursor(SWT.CURSOR_ARROW);
+ indexHover = -1;
+ for (int i = 0; i < rects.size(); i++) {
+ final Rectangle rect = rects.get(i);
+ if (rect.contains(pt)) {
+ expectedCursor = getDisplay().getSystemCursor(SWT.CURSOR_HAND);
+ indexHover = i;
+ break;
+ }
+ }
+
+ if (!expectedCursor.equals(getCursor())) {
+ setCursor(expectedCursor);
+ }
+ redraw();
+ });
+
+ addListener(SWT.MouseUp, e -> {
+ final ImageContainer imageContainer = parent.imageContainer;
+ if (hoverLeftArrow) {
+ imageContainer.movePrevious();
+ } else if (hoverRightArrow) {
+ imageContainer.moveNext();
+ } else if (indexHover != -1) {
+ imageContainer.moveTo(indexHover);
+ }
+ });
+ }
+
+ private void drawContent(final GC gc) {
+ final int x = drawCircles(gc);
+ drawArrows(x, gc);
+ }
+
+ private int drawCircles(final GC gc) {
+ int x = 0;
+ final Rectangle clientArea = getClientArea();
+ rects.clear();
+ for (int i = 0; i < carousel.getImages().size(); i++) {
+ final Rectangle rect = new Rectangle(x, (clientArea.height - CIRCLE_DIAMETER) / 2, CIRCLE_DIAMETER, CIRCLE_DIAMETER);
+ rects.add(rect);
+ if (i == carousel.getSelection()) {
+ gc.setBackground(circleBackground);
+ gc.fillOval(rect.x, rect.y, CIRCLE_DIAMETER, CIRCLE_DIAMETER);
+ } else if (i == indexHover) {
+ //
+ gc.setForeground(circleHoverColor);
+ gc.drawOval(rect.x, rect.y, CIRCLE_DIAMETER, CIRCLE_DIAMETER);
+ } else {
+ gc.setForeground(circleForeground);
+ gc.drawOval(rect.x, rect.y, CIRCLE_DIAMETER, CIRCLE_DIAMETER);
+ }
+ x += CIRCLE_DIAMETER + 5;
+ }
+ return x + CIRCLE_DIAMETER;
+
+ }
+
+ private void drawArrows(int x, final GC gc) {
+ gc.setForeground(arrowColor);
+
+ final Rectangle clientArea = getClientArea();
+ final int topY = (clientArea.height - ARROW_SIZE) / 2;
+ final int width = (int) (ARROW_SIZE * .5f);
+
+ gc.setLineWidth(hoverLeftArrow ? 3 : 1);
+
+ gc.drawPolyline(new int[] { x + width, topY, //
+ x, topY + ARROW_SIZE / 2, //
+ x + width, topY + ARROW_SIZE });
+
+ arrowLeftArea = new Rectangle(x, topY, ARROW_SIZE, ARROW_SIZE);
+
+ x += ARROW_SIZE * 3;
+
+ gc.setLineWidth(hoverRightArrow ? 3 : 1);
+ gc.drawPolyline(new int[] { x, topY, //
+ x + width, topY + ARROW_SIZE / 2, //
+ x, topY + ARROW_SIZE });
+ arrowRightArea = new Rectangle(x, topY, ARROW_SIZE, ARROW_SIZE);
+ }
+
+ @Override
+ public Point computeSize(final int wHint, final int hHint, final boolean changed) {
+ final Point superSize = super.computeSize(wHint, hHint, changed);
+ final int width = 70 + carousel.getImages().size() * (CIRCLE_DIAMETER + 5);
+ final int height = 40;
+ return new Point(Math.max(superSize.x, width), Math.max(superSize.y, height));
+ }
+
+}
diff --git a/widgets/carousel/pom.xml b/widgets/carousel/pom.xml
index 6eb6ad727..582d637b1 100644
--- a/widgets/carousel/pom.xml
+++ b/widgets/carousel/pom.xml
@@ -1,23 +1,23 @@
-
-
- 4.0.0
-
-
- org.eclipse.nebula
- 1.0.0-SNAPSHOT
- nebula-parent
- ../../releng/org.eclipse.nebula.nebula-parent
-
-
- carousel
- pom
- 1.0.0-SNAPSHOT
-
-
- org.eclipse.nebula.widgets.carousel
- org.eclipse.nebula.widgets.carousel.feature
- org.eclipse.nebula.widgets.carousel.snippets
-
-
-
+
+
+ 4.0.0
+
+
+ org.eclipse.nebula
+ 1.0.0-SNAPSHOT
+ nebula-parent
+ ../../releng/org.eclipse.nebula.nebula-parent
+
+
+ carousel
+ pom
+ 1.0.0-SNAPSHOT
+
+
+ org.eclipse.nebula.widgets.carousel
+ org.eclipse.nebula.widgets.carousel.feature
+ org.eclipse.nebula.widgets.carousel.snippets
+
+
+
diff --git a/widgets/cdatetime/org.eclipse.nebula.jface.cdatetime/.classpath b/widgets/cdatetime/org.eclipse.nebula.jface.cdatetime/.classpath
index ca3785c41..e801ebfb4 100644
--- a/widgets/cdatetime/org.eclipse.nebula.jface.cdatetime/.classpath
+++ b/widgets/cdatetime/org.eclipse.nebula.jface.cdatetime/.classpath
@@ -1,7 +1,7 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/widgets/cdatetime/org.eclipse.nebula.jface.cdatetime/.settings/org.eclipse.jdt.core.prefs b/widgets/cdatetime/org.eclipse.nebula.jface.cdatetime/.settings/org.eclipse.jdt.core.prefs
index 11265a345..7adc0fb9a 100644
--- a/widgets/cdatetime/org.eclipse.nebula.jface.cdatetime/.settings/org.eclipse.jdt.core.prefs
+++ b/widgets/cdatetime/org.eclipse.nebula.jface.cdatetime/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,10 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
-org.eclipse.jdt.core.compiler.compliance=11
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
-org.eclipse.jdt.core.compiler.release=enabled
-org.eclipse.jdt.core.compiler.source=11
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
+org.eclipse.jdt.core.compiler.compliance=11
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=11
diff --git a/widgets/cdatetime/org.eclipse.nebula.jface.cdatetime/META-INF/MANIFEST.MF b/widgets/cdatetime/org.eclipse.nebula.jface.cdatetime/META-INF/MANIFEST.MF
index e67f384d4..443594dbe 100644
--- a/widgets/cdatetime/org.eclipse.nebula.jface.cdatetime/META-INF/MANIFEST.MF
+++ b/widgets/cdatetime/org.eclipse.nebula.jface.cdatetime/META-INF/MANIFEST.MF
@@ -1,16 +1,16 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.nebula.jface.cdatetime
-Bundle-Version: 1.3.0.qualifier
-Bundle-Name: %pluginName
-Bundle-Vendor: %providerName
-Bundle-Localization: plugin
-Bundle-RequiredExecutionEnvironment: JavaSE-11
-Require-Bundle: org.eclipse.core.runtime;bundle-version="3.4.0",
- org.eclipse.nebula.widgets.cdatetime;bundle-version="0.14.0",
- org.eclipse.jface;bundle-version="3.4.0",
- org.eclipse.core.databinding;bundle-version="1.1.0",
- org.eclipse.jface.databinding,
- org.eclipse.core.databinding.property;bundle-version="1.6.100"
-Export-Package: org.eclipse.nebula.jface.cdatetime
-Automatic-Module-Name: org.eclipse.nebula.jface.cdatetime
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.eclipse.nebula.jface.cdatetime
+Bundle-Version: 1.3.0.qualifier
+Bundle-Name: %pluginName
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Bundle-RequiredExecutionEnvironment: JavaSE-11
+Require-Bundle: org.eclipse.core.runtime;bundle-version="3.4.0",
+ org.eclipse.nebula.widgets.cdatetime;bundle-version="0.14.0",
+ org.eclipse.jface;bundle-version="3.4.0",
+ org.eclipse.core.databinding;bundle-version="1.1.0",
+ org.eclipse.jface.databinding,
+ org.eclipse.core.databinding.property;bundle-version="1.6.100"
+Export-Package: org.eclipse.nebula.jface.cdatetime
+Automatic-Module-Name: org.eclipse.nebula.jface.cdatetime
diff --git a/widgets/cdatetime/org.eclipse.nebula.jface.cdatetime/src/org/eclipse/nebula/jface/cdatetime/CDateTimeValueProperty.java b/widgets/cdatetime/org.eclipse.nebula.jface.cdatetime/src/org/eclipse/nebula/jface/cdatetime/CDateTimeValueProperty.java
index 493a78cc3..1fc012858 100644
--- a/widgets/cdatetime/org.eclipse.nebula.jface.cdatetime/src/org/eclipse/nebula/jface/cdatetime/CDateTimeValueProperty.java
+++ b/widgets/cdatetime/org.eclipse.nebula.jface.cdatetime/src/org/eclipse/nebula/jface/cdatetime/CDateTimeValueProperty.java
@@ -1,82 +1,82 @@
-/*******************************************************************************
- * Copyright (c) 2019 Peter Pfeifer
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Peter Pfeifer - initial API and implementation - bug #279782
- *******************************************************************************/
-package org.eclipse.nebula.jface.cdatetime;
-import java.util.Date;
-
-import org.eclipse.jface.databinding.swt.WidgetValueProperty;
-import org.eclipse.nebula.widgets.cdatetime.CDateTime;
-import org.eclipse.swt.SWT;
-
-
-public class CDateTimeValueProperty extends WidgetValueProperty {
-
- public static final String EDITABLE = "editable";
-
- String property = "date";
-
- /**
- *
- */
- public CDateTimeValueProperty() {
- super(new int[] { SWT.Selection, SWT.Modify });
- }
-
- /**
- * @param property
- */
- public CDateTimeValueProperty(String property) {
- this();
- this.property = property;
- }
-
- /**
- * @see org.eclipse.core.databinding.property.value.SimpleValueProperty#doGetValue(java.lang.Object)
- */
- @Override
- protected Object doGetValue(Object source) {
- CDateTime dateTime = (CDateTime) source;
- // just in case editable property is bound
- if (CDateTimeValueProperty.EDITABLE.equals(this.property)) {
- return dateTime.getEditable();
- } else {
- return dateTime.getSelection();
- }
- }
-
-
- /**
- * @see org.eclipse.core.databinding.property.value.SimpleValueProperty#doSetValue(java.lang.Object, java.lang.Object)
- */
- @Override
- protected void doSetValue(Object source, Object value) {
- CDateTime dateTime = (CDateTime) source;
- // just in case editable property is bound
- if (CDateTimeValueProperty.EDITABLE.equals(this.property)) {
- dateTime.setEditable((Boolean) value);
- } else {
- dateTime.setSelection((Date) value);
- }
- }
-
- /**
- * @see org.eclipse.core.databinding.property.value.IValueProperty#getValueType()
- */
- public Object getValueType() {
- // just in case editable property is bound
- if (CDateTimeValueProperty.EDITABLE.equals(this.property)) {
- return Boolean.class;
- }
- return Date.class;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2019 Peter Pfeifer
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Peter Pfeifer - initial API and implementation - bug #279782
+ *******************************************************************************/
+package org.eclipse.nebula.jface.cdatetime;
+import java.util.Date;
+
+import org.eclipse.jface.databinding.swt.WidgetValueProperty;
+import org.eclipse.nebula.widgets.cdatetime.CDateTime;
+import org.eclipse.swt.SWT;
+
+
+public class CDateTimeValueProperty extends WidgetValueProperty {
+
+ public static final String EDITABLE = "editable";
+
+ String property = "date";
+
+ /**
+ *
+ */
+ public CDateTimeValueProperty() {
+ super(new int[] { SWT.Selection, SWT.Modify });
+ }
+
+ /**
+ * @param property
+ */
+ public CDateTimeValueProperty(String property) {
+ this();
+ this.property = property;
+ }
+
+ /**
+ * @see org.eclipse.core.databinding.property.value.SimpleValueProperty#doGetValue(java.lang.Object)
+ */
+ @Override
+ protected Object doGetValue(Object source) {
+ CDateTime dateTime = (CDateTime) source;
+ // just in case editable property is bound
+ if (CDateTimeValueProperty.EDITABLE.equals(this.property)) {
+ return dateTime.getEditable();
+ } else {
+ return dateTime.getSelection();
+ }
+ }
+
+
+ /**
+ * @see org.eclipse.core.databinding.property.value.SimpleValueProperty#doSetValue(java.lang.Object, java.lang.Object)
+ */
+ @Override
+ protected void doSetValue(Object source, Object value) {
+ CDateTime dateTime = (CDateTime) source;
+ // just in case editable property is bound
+ if (CDateTimeValueProperty.EDITABLE.equals(this.property)) {
+ dateTime.setEditable((Boolean) value);
+ } else {
+ dateTime.setSelection((Date) value);
+ }
+ }
+
+ /**
+ * @see org.eclipse.core.databinding.property.value.IValueProperty#getValueType()
+ */
+ public Object getValueType() {
+ // just in case editable property is bound
+ if (CDateTimeValueProperty.EDITABLE.equals(this.property)) {
+ return Boolean.class;
+ }
+ return Date.class;
+ }
+}
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css.feature/.project b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css.feature/.project
index 0e911020e..16bcb0729 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css.feature/.project
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css.feature/.project
@@ -1,17 +1,17 @@
-
-
- org.eclipse.nebula.widgets.cdatetime.css.feature
-
-
-
-
-
- org.eclipse.pde.FeatureBuilder
-
-
-
-
-
- org.eclipse.pde.FeatureNature
-
-
+
+
+ org.eclipse.nebula.widgets.cdatetime.css.feature
+
+
+
+
+
+ org.eclipse.pde.FeatureBuilder
+
+
+
+
+
+ org.eclipse.pde.FeatureNature
+
+
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css.feature/feature.xml b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css.feature/feature.xml
index 6e596f635..bbcac5a02 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css.feature/feature.xml
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css.feature/feature.xml
@@ -1,34 +1,34 @@
-
-
-
-
- CDateTime CSS
-
-
-
- %license
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ CDateTime CSS
+
+
+
+ %license
+
+
+
+
+
+
+
+
+
+
+
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css.feature/pom.xml b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css.feature/pom.xml
index 84a00dd3e..3e2ced616 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css.feature/pom.xml
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css.feature/pom.xml
@@ -1,32 +1,32 @@
-
-
-
- 4.0.0
-
-
- org.eclipse.nebula
- cdatetime
- 1.5.0-SNAPSHOT
-
-
- org.eclipse.nebula.widgets.cdatetime.css.feature
- eclipse-feature
- 1.4.0-SNAPSHOT
-
- Nebula CDateTime CSS Feature
-
-
+
+
+
+ 4.0.0
+
+
+ org.eclipse.nebula
+ cdatetime
+ 1.5.0-SNAPSHOT
+
+
+ org.eclipse.nebula.widgets.cdatetime.css.feature
+ eclipse-feature
+ 1.4.0-SNAPSHOT
+
+ Nebula CDateTime CSS Feature
+
+
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/.classpath b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/.classpath
index ca3785c41..e801ebfb4 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/.classpath
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/.classpath
@@ -1,7 +1,7 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/.project b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/.project
index 5e031ee29..51d46324b 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/.project
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/.project
@@ -1,28 +1,28 @@
-
-
- org.eclipse.nebula.widgets.cdatetime.css
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
-
- org.eclipse.pde.PluginNature
- org.eclipse.jdt.core.javanature
-
-
+
+
+ org.eclipse.nebula.widgets.cdatetime.css
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/.settings/org.eclipse.jdt.core.prefs b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/.settings/org.eclipse.jdt.core.prefs
index 11265a345..7adc0fb9a 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/.settings/org.eclipse.jdt.core.prefs
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,10 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
-org.eclipse.jdt.core.compiler.compliance=11
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
-org.eclipse.jdt.core.compiler.release=enabled
-org.eclipse.jdt.core.compiler.source=11
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
+org.eclipse.jdt.core.compiler.compliance=11
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=11
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/META-INF/MANIFEST.MF b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/META-INF/MANIFEST.MF
index 8cef4dd1c..45d798244 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/META-INF/MANIFEST.MF
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/META-INF/MANIFEST.MF
@@ -1,14 +1,14 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Nebula CDateTime CSS
-Bundle-SymbolicName: org.eclipse.nebula.widgets.cdatetime.css;singleton:=true
-Bundle-Version: 1.0.0.qualifier
-Bundle-RequiredExecutionEnvironment: JavaSE-11
-Require-Bundle: org.eclipse.swt,
- org.eclipse.e4.ui.services;bundle-version="0.10.0",
- org.eclipse.e4.ui.css.core;bundle-version="0.10.0",
- org.eclipse.e4.ui.css.swt;bundle-version="0.10.0",
- org.eclipse.nebula.widgets.cdatetime
-Export-Package: org.eclipse.nebula.widgets.cdatetime.css
-Bundle-Vendor: Eclipse Nebula
-Automatic-Module-Name: org.eclipse.nebula.widgets.cdatetime.css
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Nebula CDateTime CSS
+Bundle-SymbolicName: org.eclipse.nebula.widgets.cdatetime.css;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-11
+Require-Bundle: org.eclipse.swt,
+ org.eclipse.e4.ui.services;bundle-version="0.10.0",
+ org.eclipse.e4.ui.css.core;bundle-version="0.10.0",
+ org.eclipse.e4.ui.css.swt;bundle-version="0.10.0",
+ org.eclipse.nebula.widgets.cdatetime
+Export-Package: org.eclipse.nebula.widgets.cdatetime.css
+Bundle-Vendor: Eclipse Nebula
+Automatic-Module-Name: org.eclipse.nebula.widgets.cdatetime.css
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/build.properties b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/build.properties
index 6f20375d6..e9863e281 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/build.properties
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/build.properties
@@ -1,5 +1,5 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- plugin.xml
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/plugin.xml b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/plugin.xml
index cb66b3872..0ce481167 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/plugin.xml
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/plugin.xml
@@ -1,54 +1,54 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/pom.xml b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/pom.xml
index 4a40e24ad..9c1af910f 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/pom.xml
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/pom.xml
@@ -1,30 +1,30 @@
-
-
-
- 4.0.0
-
-
- org.eclipse.nebula
- cdatetime
- 1.5.0-SNAPSHOT
-
-
- org.eclipse.nebula.widgets.cdatetime.css
- eclipse-plugin
- 1.0.0-SNAPSHOT
-
-
+
+
+
+ 4.0.0
+
+
+ org.eclipse.nebula
+ cdatetime
+ 1.5.0-SNAPSHOT
+
+
+ org.eclipse.nebula.widgets.cdatetime.css
+ eclipse-plugin
+ 1.0.0-SNAPSHOT
+
+
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/src/org/eclipse/nebula/widgets/cdatetime/css/CDateTimePropertyHandler.java b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/src/org/eclipse/nebula/widgets/cdatetime/css/CDateTimePropertyHandler.java
index 5781de10a..8cc6d55fd 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/src/org/eclipse/nebula/widgets/cdatetime/css/CDateTimePropertyHandler.java
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.css/src/org/eclipse/nebula/widgets/cdatetime/css/CDateTimePropertyHandler.java
@@ -1,296 +1,296 @@
-/*******************************************************************************
- * Copyright (c) 2020 Laurent Caron.
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors: Laurent Caron - initial API and implementation
- ******************************************************************************/
-package org.eclipse.nebula.widgets.cdatetime.css;
-
-import org.eclipse.e4.ui.css.core.css2.CSS2FontHelper;
-import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler;
-import org.eclipse.e4.ui.css.core.engine.CSSEngine;
-import org.eclipse.e4.ui.css.core.impl.dom.Measure;
-import org.eclipse.e4.ui.css.swt.dom.ControlElement;
-import org.eclipse.nebula.widgets.cdatetime.CDateTime;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.widgets.Control;
-import org.w3c.dom.css.CSSPrimitiveValue;
-import org.w3c.dom.css.CSSValue;
-import org.w3c.dom.css.CSSValueList;
-
-@SuppressWarnings("restriction")
-public class CDateTimePropertyHandler implements ICSSPropertyHandler {
- @Override
- public boolean applyCSSProperty(final Object element, final String property, final CSSValue value, final String pseudo, final CSSEngine engine) throws Exception {
- final CDateTime cdt =(CDateTime) ((ControlElement) element).getNativeWidget();
-
- // General properties
- if ("cdt-background-color".equals(property)) {
- final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
- cdt.setBackground(newColor);
- }
- if ("cdt-color".equals(property)) {
- final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
- cdt.setForeground(newColor);
- }
- if ("cdt-font".equals(property)) {
- applyCSSPropertyFont(cdt, value, false);
- }
- if ("cdt-font-style".equals(property)) {
- applyCSSPropertyStyle(cdt, value, false);
- }
- if ("cdt-font-size".equals(property)) {
- applyCSSPropertySize(cdt, value, false);
- }
- if ("cdt-font-weight".equals(property)) {
- applyCSSPropertyWeight(cdt, value, false);
- }
- if ("cdt-font-family".equals(property)) {
- applyCSSPropertyFamily(cdt, value, false);
- }
-
- // Picker
- if ("cdt-picker-background-color".equals(property)) {
- final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
- cdt.setPickerBackgroundColor(newColor);
- }
- if ("cdt-picker-color".equals(property)) {
- final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
- cdt.setPickerForegroundColor(newColor);
- }
- if ("cdt-picker-font".equals(property)) {
- applyCSSPropertyFont(cdt, value, true);
- }
- if ("cdt-picker-font-style".equals(property)) {
- applyCSSPropertyStyle(cdt, value, true);
- }
- if ("cdt-picker-font-size".equals(property)) {
- applyCSSPropertySize(cdt, value, true);
- }
- if ("cdt-picker-font-weight".equals(property)) {
- applyCSSPropertyWeight(cdt, value, true);
- }
- if ("cdt-picker-font-family".equals(property)) {
- applyCSSPropertyFamily(cdt, value, true);
- }
-
- if ("cdt-picker-active-day-color".equals(property)) {
- final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
- cdt.setPickerActiveDayColor(newColor);
- }
- if ("cdt-picker-inactive-day-color".equals(property)) {
- final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
- cdt.setPickerInactiveDayColor(newColor);
- }
- if ("cdt-picker-today-color".equals(property)) {
- final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
- cdt.setPickerTodayColor(newColor);
- }
-
- // Minutes
- if ("cdt-picker-minutes-color".equals(property)) {
- final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
- cdt.setPickerMinutesColor(newColor);
- }
- if ("cdt-picker-minutes-background-color".equals(property)) {
- final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
- cdt.setPickerMinutesBackgroundColor(newColor);
- }
-
- // Picker buttons
- if ("cdt-button-hover-border-color".equals(property)) {
- final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
- cdt.setButtonHoverBorderColor(newColor);
- }
- if ("cdt-button-hover-background-color".equals(property)) {
- final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
- cdt.setButtonHoverBackgroundColor(newColor);
- }
- if ("cdt-button-selected-border-color".equals(property)) {
- final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
- cdt.setButtonSelectedBorderColor(newColor);
- }
- if ("cdt-button-selected-background-color".equals(property)) {
- final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
- cdt.setButtonSelectedBackgroundColor(newColor);
- }
-
- // Ok, Cancel & clear buttons
- if ("cdt-ok-color".equals(property)) {
- final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
- cdt.setOkButtonColor(newColor);
- }
- if ("cdt-cancel-color".equals(property)) {
- final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
- cdt.setCancelButtonColor(newColor);
- }
- if ("cdt-clear-color".equals(property)) {
- final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
- cdt.setClearButtonForegroundColor(newColor);
- }
-
- if ("cdt-clear-font".equals(property)) {
- applyCSSPropertyFont(cdt, value, true);
- }
- if ("cdt-clear-font-style".equals(property)) {
- applyCSSPropertyStyle(cdt, value, true);
- }
- if ("cdt-clear-font-size".equals(property)) {
- applyCSSPropertySize(cdt, value, true);
- }
- if ("cdt-clear-font-weight".equals(property)) {
- applyCSSPropertyWeight(cdt, value, true);
- }
- if ("cdt-clear-font-family".equals(property)) {
- applyCSSPropertyFamily(cdt, value, true);
- }
- return true;
- }
-
- // CSS Font
- private void applyCSSPropertyFont(final Control widget, final CSSValue value, final boolean picker) throws Exception {
- if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) {
- final CSSValueList valueList = (CSSValueList) value;
- final int length = valueList.getLength();
- for (int i = 0; i < length; i++) {
- final CSSValue value2 = valueList.item(i);
- if (value2.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
- final String cssProp = CSS2FontHelper.getCSSFontPropertyName((CSSPrimitiveValue) value2);
- if (cssProp.equals("font-family")) {
- applyCSSPropertyFamily(widget, value2, picker);
- } else if (cssProp.equals("font-size")) {
- applyCSSPropertySize(widget, value2, picker);
- } else if (cssProp.equals("font-weight") && ("bold".equals(value2.getCssText()) || "bolder".equals(value2.getCssText()))) {
- applyCSSPropertyWeight(widget, value2, picker);
- } else if (cssProp.equals("font-style") && ("italic".equals(value2.getCssText()) || "oblique".equals(value2.getCssText()))) {
- applyCSSPropertyStyle(widget, value2, picker);
- }
- }
- }
- }
- }
-
- private void applyCSSPropertyStyle(final Control widget, final CSSValue value, final boolean picker) throws Exception {
- if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
- final FontData fd = CSSEngineHelper.getFontData(widget, picker);
- boolean modified = false;
- if ("italic".equals(value.getCssText()) || "oblique".equals(value.getCssText())) {
- modified = (fd.getStyle() & SWT.ITALIC) != SWT.ITALIC;
- if (modified) {
- fd.setStyle(fd.getStyle() | SWT.ITALIC);
- }
- } else {
- modified = (fd.getStyle() & SWT.ITALIC) == SWT.ITALIC;
- if (modified) {
- fd.setStyle(fd.getStyle() | ~SWT.ITALIC);
- }
- }
- if (modified) {
- if (picker) {
- applyFontForPicker((CDateTime) widget, fd);
- } else {
- applyFont(widget, fd);
- }
- }
-
- }
- }
-
- private void applyFont(final Control widget, final FontData fd) {
- if (widget.getFont() != null && !widget.getFont().equals(widget.getDisplay().getSystemFont())) {
- widget.getFont().dispose();
- }
- final Font newFont = new Font(widget.getDisplay(), fd);
- widget.setFont(newFont);
- widget.addListener(SWT.Dispose, e -> {
- if (newFont != null && !newFont.isDisposed()) {
- newFont.dispose();
- }
- });
- }
-
- private void applyFontForPicker(final CDateTime widget, final FontData fd) {
- if (widget.getPickerFont() != null && !widget.getPickerFont().equals(widget.getDisplay().getSystemFont())) {
- widget.getPickerFont().dispose();
- }
- final Font newFont = new Font(widget.getDisplay(), fd);
- widget.setPickerFont(newFont);
- widget.addListener(SWT.Dispose, e -> {
- if (newFont != null && !newFont.isDisposed()) {
- newFont.dispose();
- }
- });
- }
-
- private void applyCSSPropertySize(final Control widget, final CSSValue value, final boolean picker) throws Exception {
- if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
- final FontData fd = CSSEngineHelper.getFontData(widget, picker);
- final Measure m = (Measure) value;
-
- final int newSize = Math.round(m.getFloatValue((short) 0));
- final boolean modified = fd.getHeight() != newSize;
- if (modified) {
- fd.setHeight(newSize);
- if (picker) {
- applyFontForPicker((CDateTime) widget, fd);
- } else {
- applyFont(widget, fd);
- }
- }
- }
- }
-
- private void applyCSSPropertyWeight(final Control widget, final CSSValue value, final boolean picker) throws Exception {
- if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
- final FontData fd = CSSEngineHelper.getFontData(widget, picker);
- boolean modified = false;
- if ("bold".equals(value.getCssText()) || "bolder".equals(value.getCssText())) {
- modified = (fd.getStyle() & SWT.BOLD) != SWT.BOLD;
- if (modified) {
- fd.setStyle(fd.getStyle() | SWT.BOLD);
- }
- } else {
- modified = (fd.getStyle() & SWT.BOLD) == SWT.BOLD;
- if (modified) {
- fd.setStyle(fd.getStyle() | ~SWT.BOLD);
- }
- }
- if (modified) {
- if (picker) {
- applyFontForPicker((CDateTime) widget, fd);
- } else {
- applyFont(widget, fd);
- }
- }
-
- }
- }
-
- private void applyCSSPropertyFamily(final Control widget, final CSSValue value, final boolean picker) throws Exception {
- if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
- final FontData fd = CSSEngineHelper.getFontData(widget, picker);
- final boolean modified = !fd.getName().equals(value.getCssText());
- if (modified) {
- fd.setName(value.getCssText());
- if (picker) {
- applyFontForPicker((CDateTime) widget, fd);
- } else {
- applyFont(widget, fd);
- }
- }
- }
- }
-
- @Override
- public String retrieveCSSProperty(final Object element, final String property, final String pseudo, final CSSEngine engine) throws Exception {
- return null;
- }
+/*******************************************************************************
+ * Copyright (c) 2020 Laurent Caron.
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors: Laurent Caron - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.nebula.widgets.cdatetime.css;
+
+import org.eclipse.e4.ui.css.core.css2.CSS2FontHelper;
+import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler;
+import org.eclipse.e4.ui.css.core.engine.CSSEngine;
+import org.eclipse.e4.ui.css.core.impl.dom.Measure;
+import org.eclipse.e4.ui.css.swt.dom.ControlElement;
+import org.eclipse.nebula.widgets.cdatetime.CDateTime;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.widgets.Control;
+import org.w3c.dom.css.CSSPrimitiveValue;
+import org.w3c.dom.css.CSSValue;
+import org.w3c.dom.css.CSSValueList;
+
+@SuppressWarnings("restriction")
+public class CDateTimePropertyHandler implements ICSSPropertyHandler {
+ @Override
+ public boolean applyCSSProperty(final Object element, final String property, final CSSValue value, final String pseudo, final CSSEngine engine) throws Exception {
+ final CDateTime cdt =(CDateTime) ((ControlElement) element).getNativeWidget();
+
+ // General properties
+ if ("cdt-background-color".equals(property)) {
+ final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
+ cdt.setBackground(newColor);
+ }
+ if ("cdt-color".equals(property)) {
+ final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
+ cdt.setForeground(newColor);
+ }
+ if ("cdt-font".equals(property)) {
+ applyCSSPropertyFont(cdt, value, false);
+ }
+ if ("cdt-font-style".equals(property)) {
+ applyCSSPropertyStyle(cdt, value, false);
+ }
+ if ("cdt-font-size".equals(property)) {
+ applyCSSPropertySize(cdt, value, false);
+ }
+ if ("cdt-font-weight".equals(property)) {
+ applyCSSPropertyWeight(cdt, value, false);
+ }
+ if ("cdt-font-family".equals(property)) {
+ applyCSSPropertyFamily(cdt, value, false);
+ }
+
+ // Picker
+ if ("cdt-picker-background-color".equals(property)) {
+ final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
+ cdt.setPickerBackgroundColor(newColor);
+ }
+ if ("cdt-picker-color".equals(property)) {
+ final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
+ cdt.setPickerForegroundColor(newColor);
+ }
+ if ("cdt-picker-font".equals(property)) {
+ applyCSSPropertyFont(cdt, value, true);
+ }
+ if ("cdt-picker-font-style".equals(property)) {
+ applyCSSPropertyStyle(cdt, value, true);
+ }
+ if ("cdt-picker-font-size".equals(property)) {
+ applyCSSPropertySize(cdt, value, true);
+ }
+ if ("cdt-picker-font-weight".equals(property)) {
+ applyCSSPropertyWeight(cdt, value, true);
+ }
+ if ("cdt-picker-font-family".equals(property)) {
+ applyCSSPropertyFamily(cdt, value, true);
+ }
+
+ if ("cdt-picker-active-day-color".equals(property)) {
+ final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
+ cdt.setPickerActiveDayColor(newColor);
+ }
+ if ("cdt-picker-inactive-day-color".equals(property)) {
+ final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
+ cdt.setPickerInactiveDayColor(newColor);
+ }
+ if ("cdt-picker-today-color".equals(property)) {
+ final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
+ cdt.setPickerTodayColor(newColor);
+ }
+
+ // Minutes
+ if ("cdt-picker-minutes-color".equals(property)) {
+ final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
+ cdt.setPickerMinutesColor(newColor);
+ }
+ if ("cdt-picker-minutes-background-color".equals(property)) {
+ final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
+ cdt.setPickerMinutesBackgroundColor(newColor);
+ }
+
+ // Picker buttons
+ if ("cdt-button-hover-border-color".equals(property)) {
+ final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
+ cdt.setButtonHoverBorderColor(newColor);
+ }
+ if ("cdt-button-hover-background-color".equals(property)) {
+ final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
+ cdt.setButtonHoverBackgroundColor(newColor);
+ }
+ if ("cdt-button-selected-border-color".equals(property)) {
+ final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
+ cdt.setButtonSelectedBorderColor(newColor);
+ }
+ if ("cdt-button-selected-background-color".equals(property)) {
+ final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
+ cdt.setButtonSelectedBackgroundColor(newColor);
+ }
+
+ // Ok, Cancel & clear buttons
+ if ("cdt-ok-color".equals(property)) {
+ final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
+ cdt.setOkButtonColor(newColor);
+ }
+ if ("cdt-cancel-color".equals(property)) {
+ final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
+ cdt.setCancelButtonColor(newColor);
+ }
+ if ("cdt-clear-color".equals(property)) {
+ final Color newColor = (Color) engine.convert(value, Color.class, cdt.getDisplay());
+ cdt.setClearButtonForegroundColor(newColor);
+ }
+
+ if ("cdt-clear-font".equals(property)) {
+ applyCSSPropertyFont(cdt, value, true);
+ }
+ if ("cdt-clear-font-style".equals(property)) {
+ applyCSSPropertyStyle(cdt, value, true);
+ }
+ if ("cdt-clear-font-size".equals(property)) {
+ applyCSSPropertySize(cdt, value, true);
+ }
+ if ("cdt-clear-font-weight".equals(property)) {
+ applyCSSPropertyWeight(cdt, value, true);
+ }
+ if ("cdt-clear-font-family".equals(property)) {
+ applyCSSPropertyFamily(cdt, value, true);
+ }
+ return true;
+ }
+
+ // CSS Font
+ private void applyCSSPropertyFont(final Control widget, final CSSValue value, final boolean picker) throws Exception {
+ if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) {
+ final CSSValueList valueList = (CSSValueList) value;
+ final int length = valueList.getLength();
+ for (int i = 0; i < length; i++) {
+ final CSSValue value2 = valueList.item(i);
+ if (value2.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
+ final String cssProp = CSS2FontHelper.getCSSFontPropertyName((CSSPrimitiveValue) value2);
+ if (cssProp.equals("font-family")) {
+ applyCSSPropertyFamily(widget, value2, picker);
+ } else if (cssProp.equals("font-size")) {
+ applyCSSPropertySize(widget, value2, picker);
+ } else if (cssProp.equals("font-weight") && ("bold".equals(value2.getCssText()) || "bolder".equals(value2.getCssText()))) {
+ applyCSSPropertyWeight(widget, value2, picker);
+ } else if (cssProp.equals("font-style") && ("italic".equals(value2.getCssText()) || "oblique".equals(value2.getCssText()))) {
+ applyCSSPropertyStyle(widget, value2, picker);
+ }
+ }
+ }
+ }
+ }
+
+ private void applyCSSPropertyStyle(final Control widget, final CSSValue value, final boolean picker) throws Exception {
+ if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
+ final FontData fd = CSSEngineHelper.getFontData(widget, picker);
+ boolean modified = false;
+ if ("italic".equals(value.getCssText()) || "oblique".equals(value.getCssText())) {
+ modified = (fd.getStyle() & SWT.ITALIC) != SWT.ITALIC;
+ if (modified) {
+ fd.setStyle(fd.getStyle() | SWT.ITALIC);
+ }
+ } else {
+ modified = (fd.getStyle() & SWT.ITALIC) == SWT.ITALIC;
+ if (modified) {
+ fd.setStyle(fd.getStyle() | ~SWT.ITALIC);
+ }
+ }
+ if (modified) {
+ if (picker) {
+ applyFontForPicker((CDateTime) widget, fd);
+ } else {
+ applyFont(widget, fd);
+ }
+ }
+
+ }
+ }
+
+ private void applyFont(final Control widget, final FontData fd) {
+ if (widget.getFont() != null && !widget.getFont().equals(widget.getDisplay().getSystemFont())) {
+ widget.getFont().dispose();
+ }
+ final Font newFont = new Font(widget.getDisplay(), fd);
+ widget.setFont(newFont);
+ widget.addListener(SWT.Dispose, e -> {
+ if (newFont != null && !newFont.isDisposed()) {
+ newFont.dispose();
+ }
+ });
+ }
+
+ private void applyFontForPicker(final CDateTime widget, final FontData fd) {
+ if (widget.getPickerFont() != null && !widget.getPickerFont().equals(widget.getDisplay().getSystemFont())) {
+ widget.getPickerFont().dispose();
+ }
+ final Font newFont = new Font(widget.getDisplay(), fd);
+ widget.setPickerFont(newFont);
+ widget.addListener(SWT.Dispose, e -> {
+ if (newFont != null && !newFont.isDisposed()) {
+ newFont.dispose();
+ }
+ });
+ }
+
+ private void applyCSSPropertySize(final Control widget, final CSSValue value, final boolean picker) throws Exception {
+ if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
+ final FontData fd = CSSEngineHelper.getFontData(widget, picker);
+ final Measure m = (Measure) value;
+
+ final int newSize = Math.round(m.getFloatValue((short) 0));
+ final boolean modified = fd.getHeight() != newSize;
+ if (modified) {
+ fd.setHeight(newSize);
+ if (picker) {
+ applyFontForPicker((CDateTime) widget, fd);
+ } else {
+ applyFont(widget, fd);
+ }
+ }
+ }
+ }
+
+ private void applyCSSPropertyWeight(final Control widget, final CSSValue value, final boolean picker) throws Exception {
+ if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
+ final FontData fd = CSSEngineHelper.getFontData(widget, picker);
+ boolean modified = false;
+ if ("bold".equals(value.getCssText()) || "bolder".equals(value.getCssText())) {
+ modified = (fd.getStyle() & SWT.BOLD) != SWT.BOLD;
+ if (modified) {
+ fd.setStyle(fd.getStyle() | SWT.BOLD);
+ }
+ } else {
+ modified = (fd.getStyle() & SWT.BOLD) == SWT.BOLD;
+ if (modified) {
+ fd.setStyle(fd.getStyle() | ~SWT.BOLD);
+ }
+ }
+ if (modified) {
+ if (picker) {
+ applyFontForPicker((CDateTime) widget, fd);
+ } else {
+ applyFont(widget, fd);
+ }
+ }
+
+ }
+ }
+
+ private void applyCSSPropertyFamily(final Control widget, final CSSValue value, final boolean picker) throws Exception {
+ if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
+ final FontData fd = CSSEngineHelper.getFontData(widget, picker);
+ final boolean modified = !fd.getName().equals(value.getCssText());
+ if (modified) {
+ fd.setName(value.getCssText());
+ if (picker) {
+ applyFontForPicker((CDateTime) widget, fd);
+ } else {
+ applyFont(widget, fd);
+ }
+ }
+ }
+ }
+
+ @Override
+ public String retrieveCSSProperty(final Object element, final String property, final String pseudo, final CSSEngine engine) throws Exception {
+ return null;
+ }
}
\ No newline at end of file
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/.classpath b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/.classpath
index ca3785c41..e801ebfb4 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/.classpath
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/.classpath
@@ -1,7 +1,7 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/.project b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/.project
index 8fa1a09a4..b51d60d0f 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/.project
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/.project
@@ -1,28 +1,28 @@
-
-
- org.eclipse.nebula.widgets.cdatetime.example.e4
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
-
- org.eclipse.pde.PluginNature
- org.eclipse.jdt.core.javanature
-
-
+
+
+ org.eclipse.nebula.widgets.cdatetime.example.e4
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/.settings/org.eclipse.jdt.core.prefs b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/.settings/org.eclipse.jdt.core.prefs
index 11265a345..7adc0fb9a 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/.settings/org.eclipse.jdt.core.prefs
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,10 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
-org.eclipse.jdt.core.compiler.compliance=11
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
-org.eclipse.jdt.core.compiler.release=enabled
-org.eclipse.jdt.core.compiler.source=11
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
+org.eclipse.jdt.core.compiler.compliance=11
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=11
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/Application.e4xmi b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/Application.e4xmi
index 8747d5c8c..af84b1247 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/Application.e4xmi
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/Application.e4xmi
@@ -1,41 +1,41 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/build.properties b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/build.properties
index 163f78c0c..04ab1e9b8 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/build.properties
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/build.properties
@@ -1,8 +1,8 @@
-source.. = src/
-output.. = bin/
-bin.includes = plugin.xml,\
- META-INF/,\
- .,\
- icons/,\
- css/default.css,\
- Application.e4xmi
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ icons/,\
+ css/default.css,\
+ Application.e4xmi
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/css/default.css b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/css/default.css
index ff828ea5e..97ce0a70b 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/css/default.css
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/css/default.css
@@ -1,85 +1,85 @@
-/*
-CSS for CDateTime
-*/
-
-CDateTime#one {
- cdt-font: Verdana 11px;
- cdt-color: white;
- cdt-background-color: darkred;
-}
-
-CDateTime#two {
- cdt-picker-font: Verdana 10px;
- cdt-picker-color: magenta;
- cdt-picker-background-color: #ffffcc;
-
- cdt-picker-active-day-color: darkgreen;
- cdt-picker-inactive-day-color: cyan;
- cdt-picker-today-color: darkred;
-}
-
-CDateTime#three {
- cdt-picker-font: Verdana 10px;
- cdt-picker-color: magenta;
- cdt-picker-background-color: #ffffcc;
-
- cdt-picker-active-day-color: darkgreen;
- cdt-picker-inactive-day-color: cyan;
- cdt-picker-today-color: darkred;
- cdt-picker-minutes-color: white;
- cdt-picker-minutes-background-color: darkblue;
-
-
- cdt-button-hover-border-color: cyan;
- cdt-button-hover-background-color: darkblue;
- cdt-button-selected-border-color: darkred;
- cdt-button-selected-background-color: red;
-}
-
-CDateTime#four,CDateTime#five,CDateTime#six {
- cdt-picker-font: Verdana 10px;
- cdt-picker-color: magenta;
- cdt-picker-background-color: #ffffcc;
-
- cdt-picker-active-day-color: darkgreen;
- cdt-picker-inactive-day-color: cyan;
- cdt-picker-today-color: darkred;
- cdt-picker-minutes-color: white;
- cdt-picker-minutes-background-color: darkblue;
-
-
- cdt-button-hover-border-color: cyan;
- cdt-button-hover-background-color: darkblue;
- cdt-button-selected-border-color: darkred;
- cdt-button-selected-background-color: red;
-}
-
-CDateTime#okcancelclear {
- cdt-ok-color: red;
- cdt-cancel-color: green;
- cdt-clear-color: cyan;
- cdt-clear-font: Verdana 11px;
-}
-
-CDateTime#big_one {
- cdt-picker-font: Verdana 10px;
- cdt-picker-color: magenta;
- cdt-picker-background-color: #ffffcc;
-
- cdt-picker-active-day-color: darkgreen;
- cdt-picker-inactive-day-color: cyan;
- cdt-picker-today-color: darkred;
- cdt-picker-minutes-color: white;
- cdt-picker-minutes-background-color: darkblue;
-
-
- cdt-button-hover-border-color: cyan;
- cdt-button-hover-background-color: darkblue;
- cdt-button-selected-border-color: darkred;
- cdt-button-selected-background-color: red;
-}
-
-CDateTime#big_two {
- cdt-background-color: darkred;
-}
-
+/*
+CSS for CDateTime
+*/
+
+CDateTime#one {
+ cdt-font: Verdana 11px;
+ cdt-color: white;
+ cdt-background-color: darkred;
+}
+
+CDateTime#two {
+ cdt-picker-font: Verdana 10px;
+ cdt-picker-color: magenta;
+ cdt-picker-background-color: #ffffcc;
+
+ cdt-picker-active-day-color: darkgreen;
+ cdt-picker-inactive-day-color: cyan;
+ cdt-picker-today-color: darkred;
+}
+
+CDateTime#three {
+ cdt-picker-font: Verdana 10px;
+ cdt-picker-color: magenta;
+ cdt-picker-background-color: #ffffcc;
+
+ cdt-picker-active-day-color: darkgreen;
+ cdt-picker-inactive-day-color: cyan;
+ cdt-picker-today-color: darkred;
+ cdt-picker-minutes-color: white;
+ cdt-picker-minutes-background-color: darkblue;
+
+
+ cdt-button-hover-border-color: cyan;
+ cdt-button-hover-background-color: darkblue;
+ cdt-button-selected-border-color: darkred;
+ cdt-button-selected-background-color: red;
+}
+
+CDateTime#four,CDateTime#five,CDateTime#six {
+ cdt-picker-font: Verdana 10px;
+ cdt-picker-color: magenta;
+ cdt-picker-background-color: #ffffcc;
+
+ cdt-picker-active-day-color: darkgreen;
+ cdt-picker-inactive-day-color: cyan;
+ cdt-picker-today-color: darkred;
+ cdt-picker-minutes-color: white;
+ cdt-picker-minutes-background-color: darkblue;
+
+
+ cdt-button-hover-border-color: cyan;
+ cdt-button-hover-background-color: darkblue;
+ cdt-button-selected-border-color: darkred;
+ cdt-button-selected-background-color: red;
+}
+
+CDateTime#okcancelclear {
+ cdt-ok-color: red;
+ cdt-cancel-color: green;
+ cdt-clear-color: cyan;
+ cdt-clear-font: Verdana 11px;
+}
+
+CDateTime#big_one {
+ cdt-picker-font: Verdana 10px;
+ cdt-picker-color: magenta;
+ cdt-picker-background-color: #ffffcc;
+
+ cdt-picker-active-day-color: darkgreen;
+ cdt-picker-inactive-day-color: cyan;
+ cdt-picker-today-color: darkred;
+ cdt-picker-minutes-color: white;
+ cdt-picker-minutes-background-color: darkblue;
+
+
+ cdt-button-hover-border-color: cyan;
+ cdt-button-hover-background-color: darkblue;
+ cdt-button-selected-border-color: darkred;
+ cdt-button-selected-background-color: red;
+}
+
+CDateTime#big_two {
+ cdt-background-color: darkred;
+}
+
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/org.eclipse.nebula.widgets.cdatetime.example.e4.product b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/org.eclipse.nebula.widgets.cdatetime.example.e4.product
index 2b0163c42..0e2c4d57c 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/org.eclipse.nebula.widgets.cdatetime.example.e4.product
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/org.eclipse.nebula.widgets.cdatetime.example.e4.product
@@ -1,95 +1,95 @@
-
-
-
-
-
-
-
-
-
- -clearPersistedState
-
- -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+ -clearPersistedState
+
+ -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/plugin.xml b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/plugin.xml
index 80be9c9ff..7861c7d13 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/plugin.xml
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/plugin.xml
@@ -1,22 +1,22 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/pom.xml b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/pom.xml
index 1189816bb..04de7e4e3 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/pom.xml
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/pom.xml
@@ -1,32 +1,32 @@
-
-
-
- 4.0.0
-
-
- org.eclipse.nebula
- cdatetime
- 1.5.0-SNAPSHOT
-
-
- org.eclipse.nebula.widgets.cdatetime.example.e4
- 1.4.0-SNAPSHOT
- eclipse-plugin
-
-
+
+
+
+ 4.0.0
+
+
+ org.eclipse.nebula
+ cdatetime
+ 1.5.0-SNAPSHOT
+
+
+ org.eclipse.nebula.widgets.cdatetime.example.e4
+ 1.4.0-SNAPSHOT
+ eclipse-plugin
+
+
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/src/org/eclipse/nebula/widgets/cdatetime/example/e4/Activator.java b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/src/org/eclipse/nebula/widgets/cdatetime/example/e4/Activator.java
index bb8de2141..5da150a06 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/src/org/eclipse/nebula/widgets/cdatetime/example/e4/Activator.java
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example.e4/src/org/eclipse/nebula/widgets/cdatetime/example/e4/Activator.java
@@ -1,43 +1,43 @@
-/*******************************************************************************
- * Copyright (c) 2020 Laurent Caron
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Laurent Caron - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.nebula.widgets.cdatetime.example.e4;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-public class Activator implements BundleActivator {
-
- private static BundleContext context;
-
- static BundleContext getContext() {
- return context;
- }
-
- /**
- * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(final BundleContext bundleContext) throws Exception {
- Activator.context = bundleContext;
- }
-
- /**
- * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(final BundleContext bundleContext) throws Exception {
- Activator.context = null;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2020 Laurent Caron
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Laurent Caron - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.nebula.widgets.cdatetime.example.e4;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ private static BundleContext context;
+
+ static BundleContext getContext() {
+ return context;
+ }
+
+ /**
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(final BundleContext bundleContext) throws Exception {
+ Activator.context = bundleContext;
+ }
+
+ /**
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(final BundleContext bundleContext) throws Exception {
+ Activator.context = null;
+ }
+
+}
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example/.classpath b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example/.classpath
index ca3785c41..e801ebfb4 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example/.classpath
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example/.classpath
@@ -1,7 +1,7 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example/.settings/org.eclipse.jdt.core.prefs b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example/.settings/org.eclipse.jdt.core.prefs
index 11265a345..7adc0fb9a 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example/.settings/org.eclipse.jdt.core.prefs
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,10 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
-org.eclipse.jdt.core.compiler.compliance=11
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
-org.eclipse.jdt.core.compiler.release=enabled
-org.eclipse.jdt.core.compiler.source=11
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
+org.eclipse.jdt.core.compiler.compliance=11
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=11
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example/META-INF/MANIFEST.MF b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example/META-INF/MANIFEST.MF
index 64b3e3f55..0ad1c7287 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example/META-INF/MANIFEST.MF
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.example/META-INF/MANIFEST.MF
@@ -1,13 +1,13 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Nebula CDateTime Example
-Bundle-SymbolicName: org.eclipse.nebula.widgets.cdatetime.example;singleton:=true
-Bundle-Version: 1.0.0.qualifier
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.nebula.examples;bundle-version="1.0.4",
- org.eclipse.nebula.widgets.cdatetime;bundle-version="0.14.0"
-Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: JavaSE-11
-Bundle-Vendor: Eclipse Nebula
-Automatic-Module-Name: org.eclipse.nebula.widgets.cdatetime.example
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Nebula CDateTime Example
+Bundle-SymbolicName: org.eclipse.nebula.widgets.cdatetime.example;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.nebula.examples;bundle-version="1.0.4",
+ org.eclipse.nebula.widgets.cdatetime;bundle-version="0.14.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-11
+Bundle-Vendor: Eclipse Nebula
+Automatic-Module-Name: org.eclipse.nebula.widgets.cdatetime.example
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/.classpath b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/.classpath
index ca3785c41..e801ebfb4 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/.classpath
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/.classpath
@@ -1,7 +1,7 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/.settings/org.eclipse.jdt.core.prefs b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/.settings/org.eclipse.jdt.core.prefs
index 11265a345..7adc0fb9a 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/.settings/org.eclipse.jdt.core.prefs
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,10 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
-org.eclipse.jdt.core.compiler.compliance=11
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
-org.eclipse.jdt.core.compiler.release=enabled
-org.eclipse.jdt.core.compiler.source=11
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
+org.eclipse.jdt.core.compiler.compliance=11
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=11
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/META-INF/MANIFEST.MF b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/META-INF/MANIFEST.MF
index 2a35cdd09..d22809c7a 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/META-INF/MANIFEST.MF
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/META-INF/MANIFEST.MF
@@ -1,14 +1,14 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.nebula.widgets.cdatetime.snippets
-Bundle-Version: 1.0.0.qualifier
-Bundle-Name: %pluginName
-Bundle-Vendor: %providerName
-Bundle-Localization: plugin
-Export-Package: org.eclipse.nebula.widgets.cdatetime.snippets
-Require-Bundle: org.eclipse.jface,
- org.eclipse.ui.forms,
- org.eclipse.nebula.widgets.cdatetime,
- org.eclipse.nebula.jface.cdatetime
-Bundle-RequiredExecutionEnvironment: JavaSE-11
-Automatic-Module-Name: org.eclipse.nebula.widgets.cdatetime.snippets
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.eclipse.nebula.widgets.cdatetime.snippets
+Bundle-Version: 1.0.0.qualifier
+Bundle-Name: %pluginName
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Export-Package: org.eclipse.nebula.widgets.cdatetime.snippets
+Require-Bundle: org.eclipse.jface,
+ org.eclipse.ui.forms,
+ org.eclipse.nebula.widgets.cdatetime,
+ org.eclipse.nebula.jface.cdatetime
+Bundle-RequiredExecutionEnvironment: JavaSE-11
+Automatic-Module-Name: org.eclipse.nebula.widgets.cdatetime.snippets
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/src/org/eclipse/nebula/widgets/cdatetime/snippets/CDTEditorSample.java b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/src/org/eclipse/nebula/widgets/cdatetime/snippets/CDTEditorSample.java
index bba2725bf..f93e886a2 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/src/org/eclipse/nebula/widgets/cdatetime/snippets/CDTEditorSample.java
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/src/org/eclipse/nebula/widgets/cdatetime/snippets/CDTEditorSample.java
@@ -1,220 +1,220 @@
-package org.eclipse.nebula.widgets.cdatetime.snippets;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ColumnViewerEditor;
-import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
-import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.TableViewerEditor;
-import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.nebula.jface.cdatetime.CDateTimeCellEditor;
-import org.eclipse.nebula.widgets.cdatetime.CDT;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TableItem;
-
-/**
- * Edit cell values in a table
- *
- * @author Tom Schindl
- *
- */
-public class CDTEditorSample {
- private class MyContentProvider implements IStructuredContentProvider {
-
- /**
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- public Object[] getElements(Object inputElement) {
- return (MyModel[]) inputElement;
- }
-
- /**
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- public void dispose() {
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.
- * viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-
- }
-
- }
-
- public class MyModel {
- public String firstName, lastName;
- public Date birthDate;
-
- public MyModel(String firstName, String lastName, Date birthDate) {
- super();
- this.firstName = firstName;
- this.lastName = lastName;
- this.birthDate = birthDate;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-
- public Date getBirthDate() {
- return birthDate;
- }
-
- public void setBirthDate(Date birthDate) {
- this.birthDate = birthDate;
- }
-
- }
-
- public CDTEditorSample(Shell shell) {
- final TableViewer v = new TableViewer(shell, SWT.BORDER | SWT.FULL_SELECTION);
- TableViewerColumn tc = new TableViewerColumn(v, SWT.NONE);
- tc.getColumn().setWidth(100);
- tc.getColumn().setText("First Name");
- tc.setLabelProvider(new ColumnLabelProvider() {
-
- @Override
- public String getText(Object element) {
- MyModel e = (MyModel) element;
- return e.getFirstName();
- }
- });
-
- tc = new TableViewerColumn(v, SWT.NONE);
- tc.getColumn().setWidth(200);
- tc.getColumn().setText("Last Name");
- tc.setLabelProvider(new ColumnLabelProvider() {
-
- @Override
- public String getText(Object element) {
- MyModel e = (MyModel) element;
- return e.getLastName();
- }
- });
-
- tc = new TableViewerColumn(v, SWT.NONE);
- tc.getColumn().setWidth(200);
- tc.getColumn().setText("Date of birth");
- tc.setLabelProvider(new ColumnLabelProvider() {
-
- @Override
- public String getText(Object element) {
- MyModel e = (MyModel) element;
- return new SimpleDateFormat("MM/dd/yyyy").format(e.getBirthDate());
- }
- });
-
- v.setContentProvider(new MyContentProvider());
- v.setCellModifier(new ICellModifier() {
-
- /**
- * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object,
- * java.lang.String)
- */
- public boolean canModify(Object element, String property) {
- return true;
- }
-
- /**
- * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object,
- * java.lang.String)
- */
- public Object getValue(Object element, String property) {
- MyModel e = (MyModel) element;
- if (property.equals("firstName")) {
- return e.getFirstName();
- } else if (property.equals("lastName")) {
- return e.getLastName();
- }
- return e.getBirthDate();
- }
-
- /**
- * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object,
- * java.lang.String, java.lang.Object)
- */
- public void modify(Object element, String property, Object value) {
- TableItem item = (TableItem) element;
- MyModel e = (MyModel) item.getData();
- if (property.equals("firstName")) {
- e.firstName = (String) value;
- } else if (property.equals("lastName")) {
- e.lastName = (String) value;
- } else {
- e.birthDate = (Date) value;
- }
- v.update(item.getData(), null);
- }
-
- });
-
- v.setColumnProperties(new String[] { "firstName", "lastName", "birthDate" });
- v.setCellEditors(new CellEditor[] { new TextCellEditor(v.getTable()), new TextCellEditor(v.getTable()),
- new CDateTimeCellEditor(v.getTable(), CDT.BORDER | CDT.SPINNER) });
- TableViewerEditor.create(v, new ColumnViewerEditorActivationStrategy(v), ColumnViewerEditor.TABBING_HORIZONTAL
- | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL);
-
- MyModel[] model = createModel();
- v.setInput(model);
- v.getTable().setLinesVisible(true);
- }
-
- private MyModel[] createModel() {
- MyModel[] elements = new MyModel[10];
-
- for (int i = 0; i < 10; i++) {
- elements[i] = new MyModel("First name #" + i, "Last Name #" + i, new Date());
- }
-
- return elements;
- }
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- new CDTEditorSample(shell);
- shell.open();
-
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- display.dispose();
-
- }
-
-}
+package org.eclipse.nebula.widgets.cdatetime.snippets;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ColumnViewerEditor;
+import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.TableViewerEditor;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.nebula.jface.cdatetime.CDateTimeCellEditor;
+import org.eclipse.nebula.widgets.cdatetime.CDT;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TableItem;
+
+/**
+ * Edit cell values in a table
+ *
+ * @author Tom Schindl
+ *
+ */
+public class CDTEditorSample {
+ private class MyContentProvider implements IStructuredContentProvider {
+
+ /**
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements(Object inputElement) {
+ return (MyModel[]) inputElement;
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose() {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.
+ * viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+ }
+
+ }
+
+ public class MyModel {
+ public String firstName, lastName;
+ public Date birthDate;
+
+ public MyModel(String firstName, String lastName, Date birthDate) {
+ super();
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.birthDate = birthDate;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public Date getBirthDate() {
+ return birthDate;
+ }
+
+ public void setBirthDate(Date birthDate) {
+ this.birthDate = birthDate;
+ }
+
+ }
+
+ public CDTEditorSample(Shell shell) {
+ final TableViewer v = new TableViewer(shell, SWT.BORDER | SWT.FULL_SELECTION);
+ TableViewerColumn tc = new TableViewerColumn(v, SWT.NONE);
+ tc.getColumn().setWidth(100);
+ tc.getColumn().setText("First Name");
+ tc.setLabelProvider(new ColumnLabelProvider() {
+
+ @Override
+ public String getText(Object element) {
+ MyModel e = (MyModel) element;
+ return e.getFirstName();
+ }
+ });
+
+ tc = new TableViewerColumn(v, SWT.NONE);
+ tc.getColumn().setWidth(200);
+ tc.getColumn().setText("Last Name");
+ tc.setLabelProvider(new ColumnLabelProvider() {
+
+ @Override
+ public String getText(Object element) {
+ MyModel e = (MyModel) element;
+ return e.getLastName();
+ }
+ });
+
+ tc = new TableViewerColumn(v, SWT.NONE);
+ tc.getColumn().setWidth(200);
+ tc.getColumn().setText("Date of birth");
+ tc.setLabelProvider(new ColumnLabelProvider() {
+
+ @Override
+ public String getText(Object element) {
+ MyModel e = (MyModel) element;
+ return new SimpleDateFormat("MM/dd/yyyy").format(e.getBirthDate());
+ }
+ });
+
+ v.setContentProvider(new MyContentProvider());
+ v.setCellModifier(new ICellModifier() {
+
+ /**
+ * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object,
+ * java.lang.String)
+ */
+ public boolean canModify(Object element, String property) {
+ return true;
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object,
+ * java.lang.String)
+ */
+ public Object getValue(Object element, String property) {
+ MyModel e = (MyModel) element;
+ if (property.equals("firstName")) {
+ return e.getFirstName();
+ } else if (property.equals("lastName")) {
+ return e.getLastName();
+ }
+ return e.getBirthDate();
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object,
+ * java.lang.String, java.lang.Object)
+ */
+ public void modify(Object element, String property, Object value) {
+ TableItem item = (TableItem) element;
+ MyModel e = (MyModel) item.getData();
+ if (property.equals("firstName")) {
+ e.firstName = (String) value;
+ } else if (property.equals("lastName")) {
+ e.lastName = (String) value;
+ } else {
+ e.birthDate = (Date) value;
+ }
+ v.update(item.getData(), null);
+ }
+
+ });
+
+ v.setColumnProperties(new String[] { "firstName", "lastName", "birthDate" });
+ v.setCellEditors(new CellEditor[] { new TextCellEditor(v.getTable()), new TextCellEditor(v.getTable()),
+ new CDateTimeCellEditor(v.getTable(), CDT.BORDER | CDT.SPINNER) });
+ TableViewerEditor.create(v, new ColumnViewerEditorActivationStrategy(v), ColumnViewerEditor.TABBING_HORIZONTAL
+ | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL);
+
+ MyModel[] model = createModel();
+ v.setInput(model);
+ v.getTable().setLinesVisible(true);
+ }
+
+ private MyModel[] createModel() {
+ MyModel[] elements = new MyModel[10];
+
+ for (int i = 0; i < 10; i++) {
+ elements[i] = new MyModel("First name #" + i, "Last Name #" + i, new Date());
+ }
+
+ return elements;
+ }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ new CDTEditorSample(shell);
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+
+ display.dispose();
+
+ }
+
+}
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/src/org/eclipse/nebula/widgets/cdatetime/snippets/CDTSnippet09.java b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/src/org/eclipse/nebula/widgets/cdatetime/snippets/CDTSnippet09.java
index 6b2c3d493..28e36639a 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/src/org/eclipse/nebula/widgets/cdatetime/snippets/CDTSnippet09.java
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/src/org/eclipse/nebula/widgets/cdatetime/snippets/CDTSnippet09.java
@@ -1,83 +1,83 @@
-/****************************************************************************
- * Copyright (c) 2012 Scott Klein
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Scott Klein - initial API and implementation
- *****************************************************************************/
-
-package org.eclipse.nebula.widgets.cdatetime.snippets;
-
-import java.util.TimeZone;
-
-import org.eclipse.nebula.widgets.cdatetime.CDateTime;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * This snippet shows how to use the timezone features of the CDateTime widget.
- * Please notice that you are able to tab to the timezone field were you can
- * roll through them.
- *
- */
-public class CDTSnippet09 {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- final Display display = new Display();
- final Shell shell = new Shell(display);
- shell.setText("CDateTime");
- shell.setLayout(new FillLayout());
-
- // build list of allowed time zones -- since there are over 600 of them
- // we will add US time zones as an example of the developer
- // selectively allowing particular ones using political boundaries
- TimeZone[] timezones = new TimeZone[] {
- TimeZone.getTimeZone("US/Alaska"),
- TimeZone.getTimeZone("US/Hawaii"),
- TimeZone.getTimeZone("US/Pacific"),
- TimeZone.getTimeZone("US/Arizona"),
- TimeZone.getTimeZone("US/Mountain"),
- TimeZone.getTimeZone("US/Central"),
- TimeZone.getTimeZone("US/Eastern") };
-
- CDateTime dateTime = new CDateTime(shell, SWT.NONE);
-
- // This *requires* us to set a pattern that *must* include the Zone
- // Offset key (z)
- // otherwise the time zones functionality will be off
- dateTime.setPattern("MM/dd/yyyy HH:mm.ss z", timezones);
-
- // It is always a good idea to manually set the controls' initial time
- // zone
- // using one of the time zones from your list of allowed time zones.
- // When using the time zone functionality we do not alter the initial
- // time zone
- // in the setPattern( String, TimeZone[]) call
- dateTime.setTimeZone(timezones[0]);
-
- shell.pack();
- Point size = shell.getSize();
- Rectangle screen = display.getMonitors()[0].getBounds();
- shell.setBounds((screen.width - size.x) / 2,
- (screen.height - size.y) / 2, 180, 54);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
+/****************************************************************************
+ * Copyright (c) 2012 Scott Klein
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Scott Klein - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.nebula.widgets.cdatetime.snippets;
+
+import java.util.TimeZone;
+
+import org.eclipse.nebula.widgets.cdatetime.CDateTime;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * This snippet shows how to use the timezone features of the CDateTime widget.
+ * Please notice that you are able to tab to the timezone field were you can
+ * roll through them.
+ *
+ */
+public class CDTSnippet09 {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setText("CDateTime");
+ shell.setLayout(new FillLayout());
+
+ // build list of allowed time zones -- since there are over 600 of them
+ // we will add US time zones as an example of the developer
+ // selectively allowing particular ones using political boundaries
+ TimeZone[] timezones = new TimeZone[] {
+ TimeZone.getTimeZone("US/Alaska"),
+ TimeZone.getTimeZone("US/Hawaii"),
+ TimeZone.getTimeZone("US/Pacific"),
+ TimeZone.getTimeZone("US/Arizona"),
+ TimeZone.getTimeZone("US/Mountain"),
+ TimeZone.getTimeZone("US/Central"),
+ TimeZone.getTimeZone("US/Eastern") };
+
+ CDateTime dateTime = new CDateTime(shell, SWT.NONE);
+
+ // This *requires* us to set a pattern that *must* include the Zone
+ // Offset key (z)
+ // otherwise the time zones functionality will be off
+ dateTime.setPattern("MM/dd/yyyy HH:mm.ss z", timezones);
+
+ // It is always a good idea to manually set the controls' initial time
+ // zone
+ // using one of the time zones from your list of allowed time zones.
+ // When using the time zone functionality we do not alter the initial
+ // time zone
+ // in the setPattern( String, TimeZone[]) call
+ dateTime.setTimeZone(timezones[0]);
+
+ shell.pack();
+ Point size = shell.getSize();
+ Rectangle screen = display.getMonitors()[0].getBounds();
+ shell.setBounds((screen.width - size.x) / 2,
+ (screen.height - size.y) / 2, 180, 54);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
}
\ No newline at end of file
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/src/org/eclipse/nebula/widgets/cdatetime/snippets/CDTSnippet12.java b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/src/org/eclipse/nebula/widgets/cdatetime/snippets/CDTSnippet12.java
index 608f59eb8..f6cca198c 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/src/org/eclipse/nebula/widgets/cdatetime/snippets/CDTSnippet12.java
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/src/org/eclipse/nebula/widgets/cdatetime/snippets/CDTSnippet12.java
@@ -1,65 +1,65 @@
-package org.eclipse.nebula.widgets.cdatetime.snippets;
-
-import org.eclipse.nebula.widgets.cdatetime.CDT;
-import org.eclipse.nebula.widgets.cdatetime.CDateTime;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-public class CDTSnippet12 {
-
- private static Display display = new Display();
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Shell shell = new Shell(display);
-
- shell.setText("Nebula CDateTime");
- shell.setLayout(new GridLayout());
-
- GridLayout layout = new GridLayout(1, false);
- shell.setLayout(layout);
-
- CDateTime cDateTime1 = new CDateTime(shell, CDT.DROP_DOWN | CDT.DATE_SHORT | CDT.BORDER);
- new CDateTime(shell, CDT.DROP_DOWN | CDT.DATE_SHORT | CDT.BORDER);
-
- cDateTime1.addTraverseListener(new TraverseListener() {
- @Override
- public void keyTraversed(TraverseEvent eParm){
- System.out.println("TraverseListener.keyTraversed() " + eParm);
- }
- });
-
- cDateTime1.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent eParm) {
- System.out.println("ModifyListener.modifyText() " + eParm);
- }
- });
-
- shell.pack();
- Point size = shell.getSize();
- Rectangle screen = display.getMonitors()[0].getBounds();
- shell.setBounds(
- (screen.width-size.x)/2,
- (screen.height-size.y)/2,
- size.x,
- size.y
- );
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
-
+package org.eclipse.nebula.widgets.cdatetime.snippets;
+
+import org.eclipse.nebula.widgets.cdatetime.CDT;
+import org.eclipse.nebula.widgets.cdatetime.CDateTime;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.TraverseEvent;
+import org.eclipse.swt.events.TraverseListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class CDTSnippet12 {
+
+ private static Display display = new Display();
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ Shell shell = new Shell(display);
+
+ shell.setText("Nebula CDateTime");
+ shell.setLayout(new GridLayout());
+
+ GridLayout layout = new GridLayout(1, false);
+ shell.setLayout(layout);
+
+ CDateTime cDateTime1 = new CDateTime(shell, CDT.DROP_DOWN | CDT.DATE_SHORT | CDT.BORDER);
+ new CDateTime(shell, CDT.DROP_DOWN | CDT.DATE_SHORT | CDT.BORDER);
+
+ cDateTime1.addTraverseListener(new TraverseListener() {
+ @Override
+ public void keyTraversed(TraverseEvent eParm){
+ System.out.println("TraverseListener.keyTraversed() " + eParm);
+ }
+ });
+
+ cDateTime1.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent eParm) {
+ System.out.println("ModifyListener.modifyText() " + eParm);
+ }
+ });
+
+ shell.pack();
+ Point size = shell.getSize();
+ Rectangle screen = display.getMonitors()[0].getBounds();
+ shell.setBounds(
+ (screen.width-size.x)/2,
+ (screen.height-size.y)/2,
+ size.x,
+ size.y
+ );
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
}
\ No newline at end of file
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/src/org/eclipse/nebula/widgets/cdatetime/snippets/DropTestSnippet.java b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/src/org/eclipse/nebula/widgets/cdatetime/snippets/DropTestSnippet.java
index dd7c9be04..55a6bc142 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/src/org/eclipse/nebula/widgets/cdatetime/snippets/DropTestSnippet.java
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.snippets/src/org/eclipse/nebula/widgets/cdatetime/snippets/DropTestSnippet.java
@@ -1,106 +1,106 @@
-/****************************************************************************
- * Copyright (c) 2008 Jeremy Dowdall
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Jeremy Dowdall - initial API and implementation
- *****************************************************************************/
-
-package org.eclipse.nebula.widgets.cdatetime.snippets;
-
-import org.eclipse.nebula.cwt.base.BaseCombo;
-import org.eclipse.nebula.widgets.cdatetime.CDT;
-import org.eclipse.nebula.widgets.cdatetime.CDateTime;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Dialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-
-
-public class DropTestSnippet {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- final Display display = new Display();
- final Shell shell = new Shell(display);
- shell.setText("CDC");
- shell.setLayout(new GridLayout());
-
- GridLayout layout = new GridLayout(2, true);
- shell.setLayout(layout);
-
- final BaseCombo cdc1 = new CDateTime(shell, CDT.BORDER);
- cdc1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- final BaseCombo cdc2 = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
- cdc2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
-
- shell.pack();
- Point size = shell.getSize();
- Rectangle screen = display.getMonitors()[0].getBounds();
- shell.setBounds(
- (screen.width-size.x)/2,
- (screen.height-size.y)/2,
- size.x,
- size.y
- );
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
-}
-
-class MyDialog extends Dialog {
- /**
- *
- */
- Shell shell;
-
- public MyDialog (Shell parent, int style) {
- super(parent, style);
- }
- public void close() {
- shell.close();
- }
-
- public void open() {
- Shell parent = getParent();
- final Shell shell = new Shell(parent, getStyle());
- shell.setText("Testing");
- shell.setLayout(new GridLayout());
-
- final BaseCombo cdc2 = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
- cdc2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- Display display = parent.getDisplay();
- shell.layout(true, true);
- shell.pack();
- int x = shell.getSize().x;
- int y = shell.getSize().y;
- shell.setLocation(
- (display.getBounds().width-x)/2,
- (display.getBounds().height-y)/2
- );
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
- }
- }
-}
+/****************************************************************************
+ * Copyright (c) 2008 Jeremy Dowdall
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Jeremy Dowdall - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.nebula.widgets.cdatetime.snippets;
+
+import org.eclipse.nebula.cwt.base.BaseCombo;
+import org.eclipse.nebula.widgets.cdatetime.CDT;
+import org.eclipse.nebula.widgets.cdatetime.CDateTime;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Dialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+
+
+public class DropTestSnippet {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setText("CDC");
+ shell.setLayout(new GridLayout());
+
+ GridLayout layout = new GridLayout(2, true);
+ shell.setLayout(layout);
+
+ final BaseCombo cdc1 = new CDateTime(shell, CDT.BORDER);
+ cdc1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ final BaseCombo cdc2 = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
+ cdc2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+
+ shell.pack();
+ Point size = shell.getSize();
+ Rectangle screen = display.getMonitors()[0].getBounds();
+ shell.setBounds(
+ (screen.width-size.x)/2,
+ (screen.height-size.y)/2,
+ size.x,
+ size.y
+ );
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+}
+
+class MyDialog extends Dialog {
+ /**
+ *
+ */
+ Shell shell;
+
+ public MyDialog (Shell parent, int style) {
+ super(parent, style);
+ }
+ public void close() {
+ shell.close();
+ }
+
+ public void open() {
+ Shell parent = getParent();
+ final Shell shell = new Shell(parent, getStyle());
+ shell.setText("Testing");
+ shell.setLayout(new GridLayout());
+
+ final BaseCombo cdc2 = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
+ cdc2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ Display display = parent.getDisplay();
+ shell.layout(true, true);
+ shell.pack();
+ int x = shell.getSize().x;
+ int y = shell.getSize().y;
+ shell.setLocation(
+ (display.getBounds().width-x)/2,
+ (display.getBounds().height-y)/2
+ );
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ }
+}
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/.classpath b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/.classpath
index 749841635..a42a828e0 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/.classpath
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/.classpath
@@ -1,11 +1,11 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/.settings/org.eclipse.jdt.core.prefs b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/.settings/org.eclipse.jdt.core.prefs
index e2e9c66d8..f2525a8b9 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/.settings/org.eclipse.jdt.core.prefs
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/.settings/org.eclipse.jdt.core.prefs
@@ -1,14 +1,14 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=11
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
-org.eclipse.jdt.core.compiler.release=enabled
-org.eclipse.jdt.core.compiler.source=11
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=11
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=11
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/src/org/eclipse/nebula/widgets/cdatetime/Bug370605.java b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/src/org/eclipse/nebula/widgets/cdatetime/Bug370605.java
index 7e4dca1a0..f899b5dfe 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/src/org/eclipse/nebula/widgets/cdatetime/Bug370605.java
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/src/org/eclipse/nebula/widgets/cdatetime/Bug370605.java
@@ -1,350 +1,350 @@
-/****************************************************************************
- * Copyright (c) 2012 Scott Klein
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Scott Klein - initial API and implementation
- *****************************************************************************/
-
-package org.eclipse.nebula.widgets.cdatetime;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.TimeZone;
-
-import org.eclipse.nebula.cwt.test.AbstractVTestCase;
-import org.eclipse.swt.SWT;
-
-public class Bug370605 extends AbstractVTestCase {
-
- private static final String FALL_EPOCH = "11/04/2012 00:00.00 PDT";
-
- private static Date now = new Date();
-
- private static final String PATTERN_TIMESTAMP = "MM/dd/yyyy HH:mm.ss z";
-
- private static final String SPRING_EPOCH = "03/11/2012 01:00.00 PST";
-
- private static final TimeZone TIMEZONE_DST = TimeZone
- .getTimeZone("US/Pacific");
-
- private static final TimeZone TIMEZONE_INITIAL = TimeZone
- .getTimeZone("Pacific/Kiritimati");
-
- private static Collection timezones = new ArrayList();
-
- private static final String[] TIMEZONES = { "UTC", "MIT", "HST", "AST",
- "PST", "MST", "CST", "EST", "PRT", "AGT", "BET", "CET", "EET",
- "NET", "IST", "VST", "JST", "NST" };
-
- private CdtTester tester;
-
- /**
- * Using traverse arrow keys, move through each field of the control
- *
- * Stop traversing if we have cycled back to the starting field, or we reach
- * the time zone field
- *
- * @return true, if the time zone field has been found. false otherwise.
- */
- private boolean moveToTimeZoneField(int calendarFieldSelection) {
- CDateTime cdt = tester.getCDateTime();
- int initialField = cdt.getCalendarField();
-
- int currentField = -1;
- do {
- keyPress(SWT.ARROW_RIGHT);
- keyPress('\r');
- currentField = cdt.getCalendarField();
- } while (currentField != initialField
- && currentField != calendarFieldSelection);
-
- return currentField != Calendar.ZONE_OFFSET;
- }
-
- public void setUp() throws Exception {
- timezones.clear();
- for (final String timezone : TIMEZONES) {
- timezones.add(TimeZone.getTimeZone(timezone));
- }
- tester = new CdtTester(getShell(), CDT.BORDER | CDT.TAB_FIELDS
- | CDT.CLOCK_24_HOUR | CDT.DATE_LONG | CDT.TIME_MEDIUM);
-
- }
-
- /**
- * This uses a single test with a known DST zone (PST).
- *
- *
- * Test Plans
- *
roll over the epoch time and ensure we roll over both 1 AM times
- * (Daylight and Standard).
- *
roll backwards and ensure we can do that also
- *
manually type in the epoch time and ensure we get the Java default
- * time
- *
- *
- * @throws Exception
- */
- public void testDaylightSavingsFallRoll() throws Exception {
- TimeZone.setDefault(TIMEZONE_DST);
- SimpleDateFormat sdf = new SimpleDateFormat(PATTERN_TIMESTAMP);
- Date fallEpochDate = sdf.parse(FALL_EPOCH);
- Calendar fallEpochCal = Calendar.getInstance();
- fallEpochCal.setTime(fallEpochDate);
-
- tester.setPattern(PATTERN_TIMESTAMP);
- tester.setTimeZone(TIMEZONE_DST);
- tester.setSelection(fallEpochDate);
-
- click(tester.getTextWidget());
-
- moveToTimeZoneField(Calendar.HOUR_OF_DAY);
-
- // VERIFY: Move from 12 AM to 1 AM
- // Ignoring time zone DST during this test
- keyPress(SWT.ARROW_UP);
- keyPress('\r');
-
- Date modifiedDate = tester.getCDateTime().getCalendarTime();
- Calendar modifiedCal = Calendar.getInstance();
- modifiedCal.setTime(modifiedDate);
-
- assertEquals(fallEpochCal.get(Calendar.HOUR_OF_DAY) + 1,
- modifiedCal.get(Calendar.HOUR_OF_DAY));
-
- // VERFIY: Move from 1 AM to 1 AM
- // Ignoring time zone DST during this test
- keyPress(SWT.ARROW_UP);
- keyPress('\r');
-
- modifiedDate = tester.getCDateTime().getCalendarTime();
- modifiedCal = Calendar.getInstance();
- modifiedCal.setTime(modifiedDate);
-
- assertEquals(fallEpochCal.get(Calendar.HOUR_OF_DAY) + 1,
- modifiedCal.get(Calendar.HOUR_OF_DAY));
-
- // VERIFY: Move from 1 AM to 2 AM
- keyPress(SWT.ARROW_UP);
- keyPress('\r');
-
- modifiedDate = tester.getCDateTime().getCalendarTime();
- modifiedCal = Calendar.getInstance();
- modifiedCal.setTime(modifiedDate);
-
- assertEquals(fallEpochCal.get(Calendar.HOUR_OF_DAY) + 2,
- modifiedCal.get(Calendar.HOUR_OF_DAY));
-
- // VERIFY: Move backwards from 2 AM to 1 AM
- keyPress(SWT.ARROW_DOWN);
- keyPress('\r');
-
- modifiedDate = tester.getCDateTime().getCalendarTime();
- modifiedCal = Calendar.getInstance();
- modifiedCal.setTime(modifiedDate);
-
- assertEquals(fallEpochCal.get(Calendar.HOUR_OF_DAY) + 1,
- modifiedCal.get(Calendar.HOUR_OF_DAY));
-
- // VERIFY: Move backwards from 1 AM to 1 AM
- keyPress(SWT.ARROW_DOWN);
- keyPress('\r');
-
- modifiedDate = tester.getCDateTime().getCalendarTime();
- modifiedCal = Calendar.getInstance();
- modifiedCal.setTime(modifiedDate);
-
- assertEquals(fallEpochCal.get(Calendar.HOUR_OF_DAY) + 1,
- modifiedCal.get(Calendar.HOUR_OF_DAY));
-
- // VERIFY: Move backwards from 1 AM to 12 AM
- keyPress(SWT.ARROW_DOWN);
- keyPress('\r');
-
- modifiedDate = tester.getCDateTime().getCalendarTime();
- modifiedCal = Calendar.getInstance();
- modifiedCal.setTime(modifiedDate);
-
- assertEquals(fallEpochCal.get(Calendar.HOUR_OF_DAY),
- modifiedCal.get(Calendar.HOUR_OF_DAY));
-
- // VERIFY: Manually type in 1 AM
- keyPress(SWT.KEYPAD_0);
- keyPress(SWT.KEYPAD_1);
- keyPress('\r');
-
- modifiedDate = tester.getCDateTime().getCalendarTime();
- modifiedCal = Calendar.getInstance();
- modifiedCal.setTime(modifiedDate);
-
- assertEquals(1, modifiedCal.get(Calendar.HOUR_OF_DAY));
-
- }
-
- /**
- * This uses a single test with a known DST zone (PST).
- *
- *
- * Test Plans
- *
roll over the epoch time and ensure we roll over 1 AM directly into 3
- * AM
- *
roll backwards and ensure we can do that also
- *
manually type in the epoch time and ensure we get the Java default
- * time
- *
- *
- * @throws Exception
- */
- public void testDaylightSavingsSpringRoll() throws Exception {
- TimeZone.setDefault(TIMEZONE_DST);
- SimpleDateFormat sdf = new SimpleDateFormat(PATTERN_TIMESTAMP);
- Date springEpochDate = sdf.parse(SPRING_EPOCH);
- Calendar springEpochCal = Calendar.getInstance();
- springEpochCal.setTime(springEpochDate);
-
- tester.setPattern(PATTERN_TIMESTAMP);
- tester.setTimeZone(TIMEZONE_DST);
- tester.setSelection(springEpochDate);
-
- click(tester.getTextWidget());
-
- moveToTimeZoneField(Calendar.HOUR_OF_DAY);
-
- // VERIFY: Spring from 1 AM to 3 AM using arrow keys
- keyPress(SWT.ARROW_UP);
- keyPress('\r');
-
- Date modifiedDate = tester.getCDateTime().getCalendarTime();
- Calendar modifiedCal = Calendar.getInstance();
- modifiedCal.setTime(modifiedDate);
-
- assertEquals(springEpochCal.get(Calendar.HOUR_OF_DAY) + 2,
- modifiedCal.get(Calendar.HOUR_OF_DAY));
-
- // VERIFY: Spring backwards from 3 AM to 1 AM using arrow keys
- keyPress(SWT.ARROW_DOWN);
- keyPress('\r');
-
- modifiedDate = tester.getCDateTime().getCalendarTime();
- modifiedCal = Calendar.getInstance();
- modifiedCal.setTime(modifiedDate);
-
- assertEquals(springEpochCal.get(Calendar.HOUR_OF_DAY),
- modifiedCal.get(Calendar.HOUR_OF_DAY));
-
- // VERIFY: Manully enter 2 AM and verify it reverts to 3 AM
- keyPress(SWT.KEYPAD_0);
- keyPress(SWT.KEYPAD_2);
-
- modifiedDate = tester.getCDateTime().getCalendarTime();
- modifiedCal = Calendar.getInstance();
- modifiedCal.setTime(modifiedDate);
-
- assertEquals(3, modifiedCal.get(Calendar.HOUR_OF_DAY));
-
- }
-
- /**
- * Using a CDateTime that is not configured for altering time zone, verify
- * that the time zone field is simply not able to be traversed into.
- *
- * @throws Exception
- */
- public void testNoTimeZoneSelection() throws Exception {
- tester.setPattern(PATTERN_TIMESTAMP);
- tester.setTimeZone(TIMEZONE_INITIAL);
- tester.setSelection(now);
-
- click(tester.getTextWidget());
-
- // VERIFY: TimeZone is set to the initial time zone
- final TimeZone wtzOriginal = tester.getCDateTime().getTimeZone();
- assertEquals(TIMEZONE_INITIAL.getDisplayName(),
- wtzOriginal.getDisplayName());
-
- // VERIFY: Move over to time zone, but this should not be
- // possible, so the utility method should return false
- assertTrue(moveToTimeZoneField(Calendar.ZONE_OFFSET));
- }
-
- /**
- * Using a CDateTime that is configured for altering the time zone, verify
- * that our original time zone that we set to the control is still in the
- * control on instantiation. Here we use a time zone that is *not* in the
- * list to ensure we do no alter the programatic expectation.
- *
- * We then step over to the time zone field and verify that the controls
- * time zone is altered in accordance with our list of time zones that we
- * set into the control
- *
- * @throws Exception
- */
- public void testTimeZoneSelection() throws Exception {
- tester.setPattern(PATTERN_TIMESTAMP, timezones.toArray(new TimeZone[0]));
- tester.setTimeZone(TIMEZONE_INITIAL);
- tester.setSelection(now);
-
- // VERIFY: TimeZone is set to the initial time zone
- final TimeZone wtzOriginal = tester.getCDateTime().getTimeZone();
- assertEquals(TIMEZONE_INITIAL.getDisplayName(),
- wtzOriginal.getDisplayName());
-
- // Move to the TimeZone field
- click(tester.getTextWidget());
- moveToTimeZoneField(Calendar.ZONE_OFFSET);
-
- SimpleDateFormat sdf = new SimpleDateFormat("z");
-
- // VERIFY: Flip forward through each available timezone and that it
- // changes in the control
- for (String timezone : TIMEZONES) {
- keyPress(SWT.ARROW_UP);
- keyPress('\r');
-
- final TimeZone actualTimeZone = tester.getCDateTime().getTimeZone();
- final TimeZone expectedTimeZone = TimeZone.getTimeZone(timezone);
-
- // get the actual timezone format we expect, and the actual one
- sdf.setTimeZone(actualTimeZone);
- final String actualTimeZoneDisplay = sdf.format(new Date());
- sdf.setTimeZone(expectedTimeZone);
- final String expectedTimeZoneDisplay = sdf.format(new Date());
-
- assertEquals(actualTimeZoneDisplay, expectedTimeZoneDisplay);
- }
-
- // Get back to the "1st" time zone in the list
- keyPress(SWT.ARROW_UP);
- keyPress('\r');
-
- // VERIFY: Flip backward through each available timezone and that it
- // changes in the control
- for (int idx = TIMEZONES.length - 1; idx >= 0; idx--) {
- keyPress(SWT.ARROW_DOWN);
- keyPress('\r');
-
- final TimeZone actualTimeZone = tester.getCDateTime().getTimeZone();
- final TimeZone expectedTimeZone = TimeZone
- .getTimeZone(TIMEZONES[idx]);
-
- // get the actual timezone format we expect, and the actual one
- sdf.setTimeZone(actualTimeZone);
- final String actualTimeZoneDisplay = sdf.format(new Date());
- sdf.setTimeZone(expectedTimeZone);
- final String expectedTimeZoneDisplay = sdf.format(new Date());
-
- assertEquals(actualTimeZoneDisplay, expectedTimeZoneDisplay);
-
- }
- }
+/****************************************************************************
+ * Copyright (c) 2012 Scott Klein
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Scott Klein - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.nebula.widgets.cdatetime;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.TimeZone;
+
+import org.eclipse.nebula.cwt.test.AbstractVTestCase;
+import org.eclipse.swt.SWT;
+
+public class Bug370605 extends AbstractVTestCase {
+
+ private static final String FALL_EPOCH = "11/04/2012 00:00.00 PDT";
+
+ private static Date now = new Date();
+
+ private static final String PATTERN_TIMESTAMP = "MM/dd/yyyy HH:mm.ss z";
+
+ private static final String SPRING_EPOCH = "03/11/2012 01:00.00 PST";
+
+ private static final TimeZone TIMEZONE_DST = TimeZone
+ .getTimeZone("US/Pacific");
+
+ private static final TimeZone TIMEZONE_INITIAL = TimeZone
+ .getTimeZone("Pacific/Kiritimati");
+
+ private static Collection timezones = new ArrayList();
+
+ private static final String[] TIMEZONES = { "UTC", "MIT", "HST", "AST",
+ "PST", "MST", "CST", "EST", "PRT", "AGT", "BET", "CET", "EET",
+ "NET", "IST", "VST", "JST", "NST" };
+
+ private CdtTester tester;
+
+ /**
+ * Using traverse arrow keys, move through each field of the control
+ *
+ * Stop traversing if we have cycled back to the starting field, or we reach
+ * the time zone field
+ *
+ * @return true, if the time zone field has been found. false otherwise.
+ */
+ private boolean moveToTimeZoneField(int calendarFieldSelection) {
+ CDateTime cdt = tester.getCDateTime();
+ int initialField = cdt.getCalendarField();
+
+ int currentField = -1;
+ do {
+ keyPress(SWT.ARROW_RIGHT);
+ keyPress('\r');
+ currentField = cdt.getCalendarField();
+ } while (currentField != initialField
+ && currentField != calendarFieldSelection);
+
+ return currentField != Calendar.ZONE_OFFSET;
+ }
+
+ public void setUp() throws Exception {
+ timezones.clear();
+ for (final String timezone : TIMEZONES) {
+ timezones.add(TimeZone.getTimeZone(timezone));
+ }
+ tester = new CdtTester(getShell(), CDT.BORDER | CDT.TAB_FIELDS
+ | CDT.CLOCK_24_HOUR | CDT.DATE_LONG | CDT.TIME_MEDIUM);
+
+ }
+
+ /**
+ * This uses a single test with a known DST zone (PST).
+ *
+ *
+ * Test Plans
+ *
roll over the epoch time and ensure we roll over both 1 AM times
+ * (Daylight and Standard).
+ *
roll backwards and ensure we can do that also
+ *
manually type in the epoch time and ensure we get the Java default
+ * time
+ *
+ *
+ * @throws Exception
+ */
+ public void testDaylightSavingsFallRoll() throws Exception {
+ TimeZone.setDefault(TIMEZONE_DST);
+ SimpleDateFormat sdf = new SimpleDateFormat(PATTERN_TIMESTAMP);
+ Date fallEpochDate = sdf.parse(FALL_EPOCH);
+ Calendar fallEpochCal = Calendar.getInstance();
+ fallEpochCal.setTime(fallEpochDate);
+
+ tester.setPattern(PATTERN_TIMESTAMP);
+ tester.setTimeZone(TIMEZONE_DST);
+ tester.setSelection(fallEpochDate);
+
+ click(tester.getTextWidget());
+
+ moveToTimeZoneField(Calendar.HOUR_OF_DAY);
+
+ // VERIFY: Move from 12 AM to 1 AM
+ // Ignoring time zone DST during this test
+ keyPress(SWT.ARROW_UP);
+ keyPress('\r');
+
+ Date modifiedDate = tester.getCDateTime().getCalendarTime();
+ Calendar modifiedCal = Calendar.getInstance();
+ modifiedCal.setTime(modifiedDate);
+
+ assertEquals(fallEpochCal.get(Calendar.HOUR_OF_DAY) + 1,
+ modifiedCal.get(Calendar.HOUR_OF_DAY));
+
+ // VERFIY: Move from 1 AM to 1 AM
+ // Ignoring time zone DST during this test
+ keyPress(SWT.ARROW_UP);
+ keyPress('\r');
+
+ modifiedDate = tester.getCDateTime().getCalendarTime();
+ modifiedCal = Calendar.getInstance();
+ modifiedCal.setTime(modifiedDate);
+
+ assertEquals(fallEpochCal.get(Calendar.HOUR_OF_DAY) + 1,
+ modifiedCal.get(Calendar.HOUR_OF_DAY));
+
+ // VERIFY: Move from 1 AM to 2 AM
+ keyPress(SWT.ARROW_UP);
+ keyPress('\r');
+
+ modifiedDate = tester.getCDateTime().getCalendarTime();
+ modifiedCal = Calendar.getInstance();
+ modifiedCal.setTime(modifiedDate);
+
+ assertEquals(fallEpochCal.get(Calendar.HOUR_OF_DAY) + 2,
+ modifiedCal.get(Calendar.HOUR_OF_DAY));
+
+ // VERIFY: Move backwards from 2 AM to 1 AM
+ keyPress(SWT.ARROW_DOWN);
+ keyPress('\r');
+
+ modifiedDate = tester.getCDateTime().getCalendarTime();
+ modifiedCal = Calendar.getInstance();
+ modifiedCal.setTime(modifiedDate);
+
+ assertEquals(fallEpochCal.get(Calendar.HOUR_OF_DAY) + 1,
+ modifiedCal.get(Calendar.HOUR_OF_DAY));
+
+ // VERIFY: Move backwards from 1 AM to 1 AM
+ keyPress(SWT.ARROW_DOWN);
+ keyPress('\r');
+
+ modifiedDate = tester.getCDateTime().getCalendarTime();
+ modifiedCal = Calendar.getInstance();
+ modifiedCal.setTime(modifiedDate);
+
+ assertEquals(fallEpochCal.get(Calendar.HOUR_OF_DAY) + 1,
+ modifiedCal.get(Calendar.HOUR_OF_DAY));
+
+ // VERIFY: Move backwards from 1 AM to 12 AM
+ keyPress(SWT.ARROW_DOWN);
+ keyPress('\r');
+
+ modifiedDate = tester.getCDateTime().getCalendarTime();
+ modifiedCal = Calendar.getInstance();
+ modifiedCal.setTime(modifiedDate);
+
+ assertEquals(fallEpochCal.get(Calendar.HOUR_OF_DAY),
+ modifiedCal.get(Calendar.HOUR_OF_DAY));
+
+ // VERIFY: Manually type in 1 AM
+ keyPress(SWT.KEYPAD_0);
+ keyPress(SWT.KEYPAD_1);
+ keyPress('\r');
+
+ modifiedDate = tester.getCDateTime().getCalendarTime();
+ modifiedCal = Calendar.getInstance();
+ modifiedCal.setTime(modifiedDate);
+
+ assertEquals(1, modifiedCal.get(Calendar.HOUR_OF_DAY));
+
+ }
+
+ /**
+ * This uses a single test with a known DST zone (PST).
+ *
+ *
+ * Test Plans
+ *
roll over the epoch time and ensure we roll over 1 AM directly into 3
+ * AM
+ *
roll backwards and ensure we can do that also
+ *
manually type in the epoch time and ensure we get the Java default
+ * time
+ *
+ *
+ * @throws Exception
+ */
+ public void testDaylightSavingsSpringRoll() throws Exception {
+ TimeZone.setDefault(TIMEZONE_DST);
+ SimpleDateFormat sdf = new SimpleDateFormat(PATTERN_TIMESTAMP);
+ Date springEpochDate = sdf.parse(SPRING_EPOCH);
+ Calendar springEpochCal = Calendar.getInstance();
+ springEpochCal.setTime(springEpochDate);
+
+ tester.setPattern(PATTERN_TIMESTAMP);
+ tester.setTimeZone(TIMEZONE_DST);
+ tester.setSelection(springEpochDate);
+
+ click(tester.getTextWidget());
+
+ moveToTimeZoneField(Calendar.HOUR_OF_DAY);
+
+ // VERIFY: Spring from 1 AM to 3 AM using arrow keys
+ keyPress(SWT.ARROW_UP);
+ keyPress('\r');
+
+ Date modifiedDate = tester.getCDateTime().getCalendarTime();
+ Calendar modifiedCal = Calendar.getInstance();
+ modifiedCal.setTime(modifiedDate);
+
+ assertEquals(springEpochCal.get(Calendar.HOUR_OF_DAY) + 2,
+ modifiedCal.get(Calendar.HOUR_OF_DAY));
+
+ // VERIFY: Spring backwards from 3 AM to 1 AM using arrow keys
+ keyPress(SWT.ARROW_DOWN);
+ keyPress('\r');
+
+ modifiedDate = tester.getCDateTime().getCalendarTime();
+ modifiedCal = Calendar.getInstance();
+ modifiedCal.setTime(modifiedDate);
+
+ assertEquals(springEpochCal.get(Calendar.HOUR_OF_DAY),
+ modifiedCal.get(Calendar.HOUR_OF_DAY));
+
+ // VERIFY: Manully enter 2 AM and verify it reverts to 3 AM
+ keyPress(SWT.KEYPAD_0);
+ keyPress(SWT.KEYPAD_2);
+
+ modifiedDate = tester.getCDateTime().getCalendarTime();
+ modifiedCal = Calendar.getInstance();
+ modifiedCal.setTime(modifiedDate);
+
+ assertEquals(3, modifiedCal.get(Calendar.HOUR_OF_DAY));
+
+ }
+
+ /**
+ * Using a CDateTime that is not configured for altering time zone, verify
+ * that the time zone field is simply not able to be traversed into.
+ *
+ * @throws Exception
+ */
+ public void testNoTimeZoneSelection() throws Exception {
+ tester.setPattern(PATTERN_TIMESTAMP);
+ tester.setTimeZone(TIMEZONE_INITIAL);
+ tester.setSelection(now);
+
+ click(tester.getTextWidget());
+
+ // VERIFY: TimeZone is set to the initial time zone
+ final TimeZone wtzOriginal = tester.getCDateTime().getTimeZone();
+ assertEquals(TIMEZONE_INITIAL.getDisplayName(),
+ wtzOriginal.getDisplayName());
+
+ // VERIFY: Move over to time zone, but this should not be
+ // possible, so the utility method should return false
+ assertTrue(moveToTimeZoneField(Calendar.ZONE_OFFSET));
+ }
+
+ /**
+ * Using a CDateTime that is configured for altering the time zone, verify
+ * that our original time zone that we set to the control is still in the
+ * control on instantiation. Here we use a time zone that is *not* in the
+ * list to ensure we do no alter the programatic expectation.
+ *
+ * We then step over to the time zone field and verify that the controls
+ * time zone is altered in accordance with our list of time zones that we
+ * set into the control
+ *
+ * @throws Exception
+ */
+ public void testTimeZoneSelection() throws Exception {
+ tester.setPattern(PATTERN_TIMESTAMP, timezones.toArray(new TimeZone[0]));
+ tester.setTimeZone(TIMEZONE_INITIAL);
+ tester.setSelection(now);
+
+ // VERIFY: TimeZone is set to the initial time zone
+ final TimeZone wtzOriginal = tester.getCDateTime().getTimeZone();
+ assertEquals(TIMEZONE_INITIAL.getDisplayName(),
+ wtzOriginal.getDisplayName());
+
+ // Move to the TimeZone field
+ click(tester.getTextWidget());
+ moveToTimeZoneField(Calendar.ZONE_OFFSET);
+
+ SimpleDateFormat sdf = new SimpleDateFormat("z");
+
+ // VERIFY: Flip forward through each available timezone and that it
+ // changes in the control
+ for (String timezone : TIMEZONES) {
+ keyPress(SWT.ARROW_UP);
+ keyPress('\r');
+
+ final TimeZone actualTimeZone = tester.getCDateTime().getTimeZone();
+ final TimeZone expectedTimeZone = TimeZone.getTimeZone(timezone);
+
+ // get the actual timezone format we expect, and the actual one
+ sdf.setTimeZone(actualTimeZone);
+ final String actualTimeZoneDisplay = sdf.format(new Date());
+ sdf.setTimeZone(expectedTimeZone);
+ final String expectedTimeZoneDisplay = sdf.format(new Date());
+
+ assertEquals(actualTimeZoneDisplay, expectedTimeZoneDisplay);
+ }
+
+ // Get back to the "1st" time zone in the list
+ keyPress(SWT.ARROW_UP);
+ keyPress('\r');
+
+ // VERIFY: Flip backward through each available timezone and that it
+ // changes in the control
+ for (int idx = TIMEZONES.length - 1; idx >= 0; idx--) {
+ keyPress(SWT.ARROW_DOWN);
+ keyPress('\r');
+
+ final TimeZone actualTimeZone = tester.getCDateTime().getTimeZone();
+ final TimeZone expectedTimeZone = TimeZone
+ .getTimeZone(TIMEZONES[idx]);
+
+ // get the actual timezone format we expect, and the actual one
+ sdf.setTimeZone(actualTimeZone);
+ final String actualTimeZoneDisplay = sdf.format(new Date());
+ sdf.setTimeZone(expectedTimeZone);
+ final String expectedTimeZoneDisplay = sdf.format(new Date());
+
+ assertEquals(actualTimeZoneDisplay, expectedTimeZoneDisplay);
+
+ }
+ }
}
\ No newline at end of file
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/src/org/eclipse/nebula/widgets/cdatetime/css/BaseCSSThemingTest.java b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/src/org/eclipse/nebula/widgets/cdatetime/css/BaseCSSThemingTest.java
index 5d2237383..aa48d34b8 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/src/org/eclipse/nebula/widgets/cdatetime/css/BaseCSSThemingTest.java
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/src/org/eclipse/nebula/widgets/cdatetime/css/BaseCSSThemingTest.java
@@ -1,203 +1,203 @@
-package org.eclipse.nebula.widgets.cdatetime.css;
-
-import java.io.StringReader;
-
-import org.eclipse.e4.ui.css.core.dom.properties.providers.CSSPropertyHandlerSimpleProviderImpl;
-import org.eclipse.e4.ui.css.core.engine.CSSErrorHandler;
-import org.eclipse.e4.ui.css.swt.dom.SWTElementProvider;
-import org.eclipse.e4.ui.css.swt.engine.CSSSWTEngineImpl;
-import org.eclipse.nebula.cwt.test.AbstractVTestCase;
-import org.eclipse.nebula.widgets.cdatetime.CDateTime;
-import org.eclipse.nebula.widgets.cdatetime.CdtTester;
-import org.eclipse.nebula.widgets.cdatetime.css.CDateTimePropertyHandler;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-
-/**
- * Base class for CSS tests
- */
-@SuppressWarnings("restriction")
-public class BaseCSSThemingTest extends AbstractVTestCase {
-
- protected CSSSWTEngineImpl engine;
- protected CdtTester tester;
-
- @FunctionalInterface
- protected interface ColorGetter {
- Color getColor(CDateTime cdt);
- }
-
- @FunctionalInterface
- protected interface FontGetter {
- Font getFont(CDateTime cdt);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
-
- engine = new CSSSWTEngineImpl(getShell().getDisplay()) {
- protected void initializeCSSPropertyHandlers() {
- CSSPropertyHandlerSimpleProviderImpl handlerProvider = new CSSPropertyHandlerSimpleProviderImpl();
- handlerProvider.registerCSSPropertyHandler(CDateTimePropertyHandler.class, new CDateTimePropertyHandler());
-
- String[] props = new String[] { "cdt-background-color", "cdt-color", "cdt-font", "cdt-font-style", "cdt-font-size", "cdt-font-weight", "cdt-font-family", "cdt-picker-background-color", "cdt-picker-color", "cdt-picker-font",
- "cdt-picker-font-style", "cdt-picker-font-size", "cdt-picker-font-weight", "cdt-picker-font-family", "cdt-picker-active-day-color", "cdt-picker-inactive-day-color", "cdt-picker-today-color", "cdt-picker-minutes-color",
- "cdt-picker-minutes-background-color", "cdt-button-hover-border-color", "cdt-button-hover-background-color", "cdt-button-selected-border-color", "cdt-button-selected-background-color" };
-
- for (String prop : props) {
- handlerProvider.registerCSSProperty(prop, CDateTimePropertyHandler.class);
- }
- propertyHandlerProviders.add(handlerProvider);
- }
- };
- engine.setElementProvider(new SWTElementProvider());
- engine.setErrorHandler(new CSSErrorHandler() {
- public void error(Exception e) {
- e.printStackTrace();
- }
- });
- }
-
- protected void checkColor(final String property, final ColorGetter getter) {
- final boolean[] result = new boolean[1];
- result[0] = false;
- getDisplay().syncExec(new Runnable() {
-
- public void run() {
- try {
- int r = (int) (Math.random() * 255);
- int g = (int) (Math.random() * 255);
- int b = (int) (Math.random() * 255);
- applyCSS(String.format("%s: rgb(%d, %d, %d);", property, r, g, b));
- Color bgColor = getter.getColor(tester.getCDateTime());
- result[0] = (bgColor != null && bgColor.getRed() == r && bgColor.getGreen() == g && bgColor.getBlue() == b);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- assertTrue(result[0]);
- }
-
- protected void checkFont(final String property, final FontGetter getter) {
- final boolean[] result = new boolean[1];
- result[0] = false;
- getDisplay().syncExec(new Runnable() {
-
- public void run() {
- try {
- applyCSS(property + ": Verdana 11px italic;");
- Font font = getter.getFont(tester.getCDateTime());
- if (font == null) {
- return;
- }
- FontData fd = font.getFontData()[0];
- boolean assertFontName = "Verdana".equals(fd.getName());
- boolean assertFontSize = fd.getHeight() == 11;
- boolean assertFontStyle = (fd.getStyle() & SWT.ITALIC) == SWT.ITALIC;
-
- result[0] = assertFontName && assertFontSize && assertFontStyle;
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- assertTrue(result[0]);
- }
-
- protected void checkFontStyle(final String property, final FontGetter getter) {
- final boolean[] result = new boolean[1];
- result[0] = false;
- getDisplay().syncExec(new Runnable() {
-
- public void run() {
- try {
- applyCSS(property + ": italic;");
- Font font = getter.getFont(tester.getCDateTime());
- if (font == null) {
- return;
- }
- FontData fd = font.getFontData()[0];
- result[0] = (fd.getStyle() & SWT.ITALIC) == SWT.ITALIC;
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- assertTrue(result[0]);
- }
-
- protected void checkFontSize(final String property, final FontGetter getter) {
- final boolean[] result = new boolean[1];
- result[0] = false;
- getDisplay().syncExec(new Runnable() {
-
- public void run() {
- try {
- applyCSS(property + ": 13px;");
- Font font = getter.getFont(tester.getCDateTime());
- if (font == null) {
- return;
- }
- FontData fd = font.getFontData()[0];
- result[0] = fd.getHeight() == 13;
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- assertTrue(result[0]);
- }
-
- protected void checkFontWeight(final String property, final FontGetter getter) {
- final boolean[] result = new boolean[1];
- result[0] = false;
- getDisplay().syncExec(new Runnable() {
-
- public void run() {
- try {
- applyCSS(property + ": bold;");
- Font font = getter.getFont(tester.getCDateTime());
- if (font == null) {
- return;
- }
- FontData fd = font.getFontData()[0];
- result[0] = (fd.getStyle() & SWT.BOLD) == SWT.BOLD;
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- assertTrue(result[0]);
- }
-
- protected void checkFontFamily(final String property, final FontGetter getter) {
- final boolean[] result = new boolean[1];
- result[0] = false;
- getDisplay().syncExec(new Runnable() {
-
- public void run() {
- try {
- applyCSS(property + ": Helvetica;");
- Font font = getter.getFont(tester.getCDateTime());
- if (font == null) {
- return;
- }
- FontData fd = font.getFontData()[0];
- result[0] = "Helvetica".equals(fd.getName());
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- assertTrue(result[0]);
- }
-
- private void applyCSS(String css) throws Exception {
- engine.parseStyleSheet(new StringReader("CDateTime {" + css + "}"));
- engine.applyStyles(getShell(), true);
- }
-
-}
+package org.eclipse.nebula.widgets.cdatetime.css;
+
+import java.io.StringReader;
+
+import org.eclipse.e4.ui.css.core.dom.properties.providers.CSSPropertyHandlerSimpleProviderImpl;
+import org.eclipse.e4.ui.css.core.engine.CSSErrorHandler;
+import org.eclipse.e4.ui.css.swt.dom.SWTElementProvider;
+import org.eclipse.e4.ui.css.swt.engine.CSSSWTEngineImpl;
+import org.eclipse.nebula.cwt.test.AbstractVTestCase;
+import org.eclipse.nebula.widgets.cdatetime.CDateTime;
+import org.eclipse.nebula.widgets.cdatetime.CdtTester;
+import org.eclipse.nebula.widgets.cdatetime.css.CDateTimePropertyHandler;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+
+/**
+ * Base class for CSS tests
+ */
+@SuppressWarnings("restriction")
+public class BaseCSSThemingTest extends AbstractVTestCase {
+
+ protected CSSSWTEngineImpl engine;
+ protected CdtTester tester;
+
+ @FunctionalInterface
+ protected interface ColorGetter {
+ Color getColor(CDateTime cdt);
+ }
+
+ @FunctionalInterface
+ protected interface FontGetter {
+ Font getFont(CDateTime cdt);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ engine = new CSSSWTEngineImpl(getShell().getDisplay()) {
+ protected void initializeCSSPropertyHandlers() {
+ CSSPropertyHandlerSimpleProviderImpl handlerProvider = new CSSPropertyHandlerSimpleProviderImpl();
+ handlerProvider.registerCSSPropertyHandler(CDateTimePropertyHandler.class, new CDateTimePropertyHandler());
+
+ String[] props = new String[] { "cdt-background-color", "cdt-color", "cdt-font", "cdt-font-style", "cdt-font-size", "cdt-font-weight", "cdt-font-family", "cdt-picker-background-color", "cdt-picker-color", "cdt-picker-font",
+ "cdt-picker-font-style", "cdt-picker-font-size", "cdt-picker-font-weight", "cdt-picker-font-family", "cdt-picker-active-day-color", "cdt-picker-inactive-day-color", "cdt-picker-today-color", "cdt-picker-minutes-color",
+ "cdt-picker-minutes-background-color", "cdt-button-hover-border-color", "cdt-button-hover-background-color", "cdt-button-selected-border-color", "cdt-button-selected-background-color" };
+
+ for (String prop : props) {
+ handlerProvider.registerCSSProperty(prop, CDateTimePropertyHandler.class);
+ }
+ propertyHandlerProviders.add(handlerProvider);
+ }
+ };
+ engine.setElementProvider(new SWTElementProvider());
+ engine.setErrorHandler(new CSSErrorHandler() {
+ public void error(Exception e) {
+ e.printStackTrace();
+ }
+ });
+ }
+
+ protected void checkColor(final String property, final ColorGetter getter) {
+ final boolean[] result = new boolean[1];
+ result[0] = false;
+ getDisplay().syncExec(new Runnable() {
+
+ public void run() {
+ try {
+ int r = (int) (Math.random() * 255);
+ int g = (int) (Math.random() * 255);
+ int b = (int) (Math.random() * 255);
+ applyCSS(String.format("%s: rgb(%d, %d, %d);", property, r, g, b));
+ Color bgColor = getter.getColor(tester.getCDateTime());
+ result[0] = (bgColor != null && bgColor.getRed() == r && bgColor.getGreen() == g && bgColor.getBlue() == b);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ assertTrue(result[0]);
+ }
+
+ protected void checkFont(final String property, final FontGetter getter) {
+ final boolean[] result = new boolean[1];
+ result[0] = false;
+ getDisplay().syncExec(new Runnable() {
+
+ public void run() {
+ try {
+ applyCSS(property + ": Verdana 11px italic;");
+ Font font = getter.getFont(tester.getCDateTime());
+ if (font == null) {
+ return;
+ }
+ FontData fd = font.getFontData()[0];
+ boolean assertFontName = "Verdana".equals(fd.getName());
+ boolean assertFontSize = fd.getHeight() == 11;
+ boolean assertFontStyle = (fd.getStyle() & SWT.ITALIC) == SWT.ITALIC;
+
+ result[0] = assertFontName && assertFontSize && assertFontStyle;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ assertTrue(result[0]);
+ }
+
+ protected void checkFontStyle(final String property, final FontGetter getter) {
+ final boolean[] result = new boolean[1];
+ result[0] = false;
+ getDisplay().syncExec(new Runnable() {
+
+ public void run() {
+ try {
+ applyCSS(property + ": italic;");
+ Font font = getter.getFont(tester.getCDateTime());
+ if (font == null) {
+ return;
+ }
+ FontData fd = font.getFontData()[0];
+ result[0] = (fd.getStyle() & SWT.ITALIC) == SWT.ITALIC;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ assertTrue(result[0]);
+ }
+
+ protected void checkFontSize(final String property, final FontGetter getter) {
+ final boolean[] result = new boolean[1];
+ result[0] = false;
+ getDisplay().syncExec(new Runnable() {
+
+ public void run() {
+ try {
+ applyCSS(property + ": 13px;");
+ Font font = getter.getFont(tester.getCDateTime());
+ if (font == null) {
+ return;
+ }
+ FontData fd = font.getFontData()[0];
+ result[0] = fd.getHeight() == 13;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ assertTrue(result[0]);
+ }
+
+ protected void checkFontWeight(final String property, final FontGetter getter) {
+ final boolean[] result = new boolean[1];
+ result[0] = false;
+ getDisplay().syncExec(new Runnable() {
+
+ public void run() {
+ try {
+ applyCSS(property + ": bold;");
+ Font font = getter.getFont(tester.getCDateTime());
+ if (font == null) {
+ return;
+ }
+ FontData fd = font.getFontData()[0];
+ result[0] = (fd.getStyle() & SWT.BOLD) == SWT.BOLD;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ assertTrue(result[0]);
+ }
+
+ protected void checkFontFamily(final String property, final FontGetter getter) {
+ final boolean[] result = new boolean[1];
+ result[0] = false;
+ getDisplay().syncExec(new Runnable() {
+
+ public void run() {
+ try {
+ applyCSS(property + ": Helvetica;");
+ Font font = getter.getFont(tester.getCDateTime());
+ if (font == null) {
+ return;
+ }
+ FontData fd = font.getFontData()[0];
+ result[0] = "Helvetica".equals(fd.getName());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ assertTrue(result[0]);
+ }
+
+ private void applyCSS(String css) throws Exception {
+ engine.parseStyleSheet(new StringReader("CDateTime {" + css + "}"));
+ engine.applyStyles(getShell(), true);
+ }
+
+}
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/src/org/eclipse/nebula/widgets/cdatetime/css/ThemingButtonPropertiesTests.java b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/src/org/eclipse/nebula/widgets/cdatetime/css/ThemingButtonPropertiesTests.java
index 80f96d163..7c42cef76 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/src/org/eclipse/nebula/widgets/cdatetime/css/ThemingButtonPropertiesTests.java
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/src/org/eclipse/nebula/widgets/cdatetime/css/ThemingButtonPropertiesTests.java
@@ -1,35 +1,35 @@
-package org.eclipse.nebula.widgets.cdatetime.css;
-
-import java.util.Date;
-
-import org.eclipse.nebula.widgets.cdatetime.CDT;
-import org.eclipse.nebula.widgets.cdatetime.CdtTester;
-
-public class ThemingButtonPropertiesTests extends BaseCSSThemingTest {
- /**
- * @throws java.lang.Exception
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- tester = new CdtTester(getShell(), CDT.BORDER | CDT.COMPACT | CDT.DROP_DOWN | CDT.DATE_LONG | CDT.TIME_MEDIUM);
- tester.setSelection(new Date());
- }
-
- public void testCdtButtonHoverBackgroundColor() throws Exception {
- checkColor("cdt-button-hover-background-color", cdt -> cdt.getButtonHoverBackgroundColor());
- }
-
- public void testCdtButtonHoverBorderColor() throws Exception {
- checkColor("cdt-button-hover-border-color", cdt -> cdt.getButtonHoverBorderColor());
- }
-
- public void testCdtButtonSelectedBackgroundColor() throws Exception {
- checkColor("cdt-button-selected-background-color", cdt -> cdt.getButtonSelectedBackgroundColor());
- }
-
- public void testCdtButtonSelectedBorderColor() throws Exception {
- checkColor("cdt-button-selected-border-color", cdt -> cdt.getButtonSelectedBorderColor());
- }
-
-}
+package org.eclipse.nebula.widgets.cdatetime.css;
+
+import java.util.Date;
+
+import org.eclipse.nebula.widgets.cdatetime.CDT;
+import org.eclipse.nebula.widgets.cdatetime.CdtTester;
+
+public class ThemingButtonPropertiesTests extends BaseCSSThemingTest {
+ /**
+ * @throws java.lang.Exception
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ tester = new CdtTester(getShell(), CDT.BORDER | CDT.COMPACT | CDT.DROP_DOWN | CDT.DATE_LONG | CDT.TIME_MEDIUM);
+ tester.setSelection(new Date());
+ }
+
+ public void testCdtButtonHoverBackgroundColor() throws Exception {
+ checkColor("cdt-button-hover-background-color", cdt -> cdt.getButtonHoverBackgroundColor());
+ }
+
+ public void testCdtButtonHoverBorderColor() throws Exception {
+ checkColor("cdt-button-hover-border-color", cdt -> cdt.getButtonHoverBorderColor());
+ }
+
+ public void testCdtButtonSelectedBackgroundColor() throws Exception {
+ checkColor("cdt-button-selected-background-color", cdt -> cdt.getButtonSelectedBackgroundColor());
+ }
+
+ public void testCdtButtonSelectedBorderColor() throws Exception {
+ checkColor("cdt-button-selected-border-color", cdt -> cdt.getButtonSelectedBorderColor());
+ }
+
+}
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/src/org/eclipse/nebula/widgets/cdatetime/css/ThemingGeneralPropertiesTests.java b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/src/org/eclipse/nebula/widgets/cdatetime/css/ThemingGeneralPropertiesTests.java
index 7129d26b6..6173793e2 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/src/org/eclipse/nebula/widgets/cdatetime/css/ThemingGeneralPropertiesTests.java
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/src/org/eclipse/nebula/widgets/cdatetime/css/ThemingGeneralPropertiesTests.java
@@ -1,56 +1,56 @@
-package org.eclipse.nebula.widgets.cdatetime.css;
-
-import java.util.Date;
-
-import org.eclipse.nebula.widgets.cdatetime.CDT;
-import org.eclipse.nebula.widgets.cdatetime.CdtTester;
-
-public class ThemingGeneralPropertiesTests extends BaseCSSThemingTest {
-
- /**
- * @throws java.lang.Exception
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- tester = new CdtTester(getShell(), CDT.DATE_MEDIUM | CDT.TIME_MEDIUM);
- tester.setSelection(new Date());
- }
-
- /**
- * @throws java.lang.Exception
- */
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testCdtBackgroundColor() throws Exception {
- checkColor("cdt-background-color", cdt -> cdt.getBackground());
-
- }
-
- public void testCdtColor() throws Exception {
- checkColor("cdt-color", cdt -> cdt.getForeground());
- }
-
- public void testCdtFont() throws Exception {
- checkFont("cdt-font", cdt -> cdt.getFont());
- }
-
- public void testCdtFontStyle() throws Exception {
- checkFontStyle("cdt-font-style", cdt -> cdt.getFont());
- }
-
- public void testCdtFontSize() throws Exception {
- checkFontSize("cdt-font-size", cdt -> cdt.getFont());
- }
-
- public void testCdtFontWeight() throws Exception {
- checkFontWeight("cdt-font-weight", cdt -> cdt.getFont());
- }
-
- public void testCdtFontFamily() throws Exception {
- checkFontFamily("cdt-font-family", cdt -> cdt.getFont());
- }
-}
+package org.eclipse.nebula.widgets.cdatetime.css;
+
+import java.util.Date;
+
+import org.eclipse.nebula.widgets.cdatetime.CDT;
+import org.eclipse.nebula.widgets.cdatetime.CdtTester;
+
+public class ThemingGeneralPropertiesTests extends BaseCSSThemingTest {
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ tester = new CdtTester(getShell(), CDT.DATE_MEDIUM | CDT.TIME_MEDIUM);
+ tester.setSelection(new Date());
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testCdtBackgroundColor() throws Exception {
+ checkColor("cdt-background-color", cdt -> cdt.getBackground());
+
+ }
+
+ public void testCdtColor() throws Exception {
+ checkColor("cdt-color", cdt -> cdt.getForeground());
+ }
+
+ public void testCdtFont() throws Exception {
+ checkFont("cdt-font", cdt -> cdt.getFont());
+ }
+
+ public void testCdtFontStyle() throws Exception {
+ checkFontStyle("cdt-font-style", cdt -> cdt.getFont());
+ }
+
+ public void testCdtFontSize() throws Exception {
+ checkFontSize("cdt-font-size", cdt -> cdt.getFont());
+ }
+
+ public void testCdtFontWeight() throws Exception {
+ checkFontWeight("cdt-font-weight", cdt -> cdt.getFont());
+ }
+
+ public void testCdtFontFamily() throws Exception {
+ checkFontFamily("cdt-font-family", cdt -> cdt.getFont());
+ }
+}
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/src/org/eclipse/nebula/widgets/cdatetime/css/ThemingPickerPartPropertiesTests.java b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/src/org/eclipse/nebula/widgets/cdatetime/css/ThemingPickerPartPropertiesTests.java
index ed4736773..f4bb0eed7 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/src/org/eclipse/nebula/widgets/cdatetime/css/ThemingPickerPartPropertiesTests.java
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime.tests/src/org/eclipse/nebula/widgets/cdatetime/css/ThemingPickerPartPropertiesTests.java
@@ -1,71 +1,71 @@
-package org.eclipse.nebula.widgets.cdatetime.css;
-
-import java.util.Date;
-
-import org.eclipse.nebula.widgets.cdatetime.CDT;
-import org.eclipse.nebula.widgets.cdatetime.CDateTime;
-import org.eclipse.nebula.widgets.cdatetime.CdtTester;
-import org.eclipse.swt.graphics.Color;
-
-public class ThemingPickerPartPropertiesTests extends BaseCSSThemingTest {
-
- /**
- * @throws java.lang.Exception
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- tester = new CdtTester(getShell(), CDT.BORDER | CDT.COMPACT | CDT.DROP_DOWN | CDT.DATE_LONG | CDT.TIME_MEDIUM);
- tester.setSelection(new Date());
- }
-
- public void testCdtPickerBackgroundColor() throws Exception {
- checkColor("cdt-picker-background-color", cdt -> cdt.getPickerBackgroundColor());
- }
-
- public void testCdtPickerColor() throws Exception {
- checkColor("cdt-picker-color", cdt -> cdt.getPickerForegroundColor());
- }
-
- public void testCdtPickerFont() throws Exception {
- checkFont("cdt-picker-font", cdt -> cdt.getPickerFont());
- }
-
- public void testCdtPickerFontStyle() throws Exception {
- checkFontStyle("cdt-picker-font-style", cdt -> cdt.getPickerFont());
- }
-
- public void testCdtPickerFontSize() throws Exception {
- checkFontSize("cdt-picker-font-size", cdt -> cdt.getPickerFont());
- }
-
- public void testCdtPickerFontWeight() throws Exception {
- checkFontWeight("cdt-picker-font-weight", cdt -> cdt.getPickerFont());
- }
-
- public void testCdtPickerFontFamily() throws Exception {
- checkFontFamily("cdt-picker-font-family", cdt -> cdt.getPickerFont());
- }
-
- public void testCdtPickerActiveDayColor() throws Exception {
- checkColor("cdt-picker-active-day-color", new ColorGetter() {
- public Color getColor(CDateTime cdt) {
- return cdt.getPickerActiveDayColor();
- }
- });
- }
- public void testCdtPickerInactiveDayColor() throws Exception {
- checkColor("cdt-picker-inactive-day-color", cdt -> cdt.getPickerInactiveDayColor());
- }
-
- public void testCdtPickerTodayColor() throws Exception {
- checkColor("cdt-picker-today-color", cdt -> cdt.getPickerTodayColor());
- }
-
- public void testCdtPickerMinutesColor() throws Exception {
- checkColor("cdt-picker-minutes-color", cdt -> cdt.getPickerMinutesColor());
- }
- public void testCdtPickerMinutesBackgroundColor() throws Exception {
- checkColor("cdt-picker-minutes-background-color", cdt -> cdt.getPickerMinutesBackgroundColor());
- }
-}
+package org.eclipse.nebula.widgets.cdatetime.css;
+
+import java.util.Date;
+
+import org.eclipse.nebula.widgets.cdatetime.CDT;
+import org.eclipse.nebula.widgets.cdatetime.CDateTime;
+import org.eclipse.nebula.widgets.cdatetime.CdtTester;
+import org.eclipse.swt.graphics.Color;
+
+public class ThemingPickerPartPropertiesTests extends BaseCSSThemingTest {
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ tester = new CdtTester(getShell(), CDT.BORDER | CDT.COMPACT | CDT.DROP_DOWN | CDT.DATE_LONG | CDT.TIME_MEDIUM);
+ tester.setSelection(new Date());
+ }
+
+ public void testCdtPickerBackgroundColor() throws Exception {
+ checkColor("cdt-picker-background-color", cdt -> cdt.getPickerBackgroundColor());
+ }
+
+ public void testCdtPickerColor() throws Exception {
+ checkColor("cdt-picker-color", cdt -> cdt.getPickerForegroundColor());
+ }
+
+ public void testCdtPickerFont() throws Exception {
+ checkFont("cdt-picker-font", cdt -> cdt.getPickerFont());
+ }
+
+ public void testCdtPickerFontStyle() throws Exception {
+ checkFontStyle("cdt-picker-font-style", cdt -> cdt.getPickerFont());
+ }
+
+ public void testCdtPickerFontSize() throws Exception {
+ checkFontSize("cdt-picker-font-size", cdt -> cdt.getPickerFont());
+ }
+
+ public void testCdtPickerFontWeight() throws Exception {
+ checkFontWeight("cdt-picker-font-weight", cdt -> cdt.getPickerFont());
+ }
+
+ public void testCdtPickerFontFamily() throws Exception {
+ checkFontFamily("cdt-picker-font-family", cdt -> cdt.getPickerFont());
+ }
+
+ public void testCdtPickerActiveDayColor() throws Exception {
+ checkColor("cdt-picker-active-day-color", new ColorGetter() {
+ public Color getColor(CDateTime cdt) {
+ return cdt.getPickerActiveDayColor();
+ }
+ });
+ }
+ public void testCdtPickerInactiveDayColor() throws Exception {
+ checkColor("cdt-picker-inactive-day-color", cdt -> cdt.getPickerInactiveDayColor());
+ }
+
+ public void testCdtPickerTodayColor() throws Exception {
+ checkColor("cdt-picker-today-color", cdt -> cdt.getPickerTodayColor());
+ }
+
+ public void testCdtPickerMinutesColor() throws Exception {
+ checkColor("cdt-picker-minutes-color", cdt -> cdt.getPickerMinutesColor());
+ }
+ public void testCdtPickerMinutesBackgroundColor() throws Exception {
+ checkColor("cdt-picker-minutes-background-color", cdt -> cdt.getPickerMinutesBackgroundColor());
+ }
+}
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/projectSet.psf b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/projectSet.psf
index a3586557c..aec255ed4 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/projectSet.psf
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/projectSet.psf
@@ -1,19 +1,19 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/CDateTime.java b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/CDateTime.java
index e7a33993e..966df1b65 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/CDateTime.java
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/CDateTime.java
@@ -1,2602 +1,2602 @@
-/****************************************************************************
- * Copyright (c) 2006-2019 Jeremy Dowdall
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Jeremy Dowdall - initial API and implementation
- * Wim Jongman - https://bugs.eclipse.org/bugs/show_bug.cgi?id=362181
- * Scott Klein - https://bugs.eclipse.org/bugs/show_bug.cgi?id=370605
- * Baruch Youssin - https://bugs.eclipse.org/bugs/show_bug.cgi?id=261414
- * Doug Showell - https://bugs.eclipse.org/bugs/show_bug.cgi?id=383589
- * Bel Razom - https://bugs.eclipse.org/bugs/show_bug.cgi?id=527399
- * Stefan Nöbauer - https://bugs.eclipse.org/bugs/show_bug.cgi?id=548149
- *****************************************************************************/
-
-package org.eclipse.nebula.widgets.cdatetime;
-
-import java.text.AttributedCharacterIterator;
-import java.text.CharacterIterator;
-import java.text.DateFormat;
-import java.text.DateFormat.Field;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Locale;
-import java.util.TimeZone;
-
-import org.eclipse.nebula.cwt.base.BaseCombo;
-import org.eclipse.nebula.cwt.v.VButton;
-import org.eclipse.nebula.cwt.v.VCanvas;
-import org.eclipse.nebula.cwt.v.VGridLayout;
-import org.eclipse.nebula.cwt.v.VLabel;
-import org.eclipse.nebula.cwt.v.VLayout;
-import org.eclipse.nebula.cwt.v.VNative;
-import org.eclipse.nebula.cwt.v.VPanel;
-import org.eclipse.nebula.cwt.v.VTracker;
-import org.eclipse.nebula.widgets.cdatetime.CDT.PickerPart;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.events.FocusAdapter;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Spinner;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.TypedListener;
-
-/**
- * The CDateTime provides both textual and graphical means selecting a
- * date.
- * As with other combo type widgets, there are three basic styles:
- *
- *
Text only (default)
- *
Graphical only (CDT.SIMPLE)
- *
Combo - a text selector with a drop-down graphical selector
- * (CDT.DROP_DOWN)
- *
- *
- * Styles are set using the constants provided in the CDT class.
- *
- *
- * @see CDT
- * @since 1.5
- */
-public class CDateTime extends BaseCombo {
-
- /**
- * A simple class used for editing a field numerically.
- */
- private class EditField {
-
- private String buffer;
- private int digits;
- private int count = 0;
-
- EditField(int digits, int initialValue) {
- this.digits = digits;
- buffer = Integer.toString(initialValue);
- }
-
- /**
- * Adds a character if it is a digit; in case the field exceeds its
- * capacity, the oldest character is dropped from the buffer. Non-digits
- * are dropped.
- *
- * @param c
- * @return true if the new character is a digit and with its addition
- * the active field reaches or exceeds its capacity, false
- * otherwise
- */
- boolean addChar(char c) {
- if (Character.isDigit(c)) {
- buffer = count > 0 ? buffer : ""; //$NON-NLS-1$
- buffer += String.valueOf(c);
- if (buffer.length() > digits) {
- buffer = buffer.substring(buffer.length() - digits,
- buffer.length());
- }
- }
- return ++count > digits - 1;
- }
-
- int getValue() {
- return Integer.parseInt(buffer);
- }
-
- void removeLastCharacter() {
- if (buffer.length() > 0) {
- buffer = buffer.substring(0, buffer.length() - 1);
- count--;
- }
- }
-
- void reset() {
- count = 0;
- }
-
- @Override
- public String toString() {
- if (buffer.length() < digits) {
- char[] ca = new char[digits - buffer.length()];
- Arrays.fill(ca, '0');
- buffer = String.valueOf(ca).concat(buffer);
- }
- return buffer;
- }
- }
-
- /**
- * The layout used for a "basic" CDateTime - when it is neither of style
- * SIMPLE or DROP_DOWN - with style of SPINNER.
- * Note that there is a spinner, but no button for this style.
- */
- class SpinnerLayout extends VLayout {
-
- @Override
- protected Point computeSize(VPanel panel, int wHint, int hHint,
- boolean flushCache) {
- Point size = text.computeSize(SWT.DEFAULT, SWT.DEFAULT);
-
- Rectangle sRect = spinner.getControl().computeTrim(0, 0, 0, 0);
- int sWidth = sRect.x + sRect.width
- - 2 * spinner.getControl().getBorderWidth() + 1;
-
- if (gtk && sWidth == 0) {
- sWidth = 67;
- }
-
- size.x += sWidth;
- size.x++;
- size.y += textMarginHeight;
-
- if (wHint != SWT.DEFAULT) {
- size.x = Math.min(size.x, wHint);
- }
- if (hHint != SWT.DEFAULT) {
- size.y = Math.min(size.y, hHint);
- }
- return size;
- }
-
- @Override
- protected void layout(VPanel panel, boolean flushCache) {
- Rectangle cRect = panel.getClientArea();
- if (cRect.isEmpty()) {
- return;
- }
-
- Point tSize = text.getControl().computeSize(SWT.DEFAULT,
- SWT.DEFAULT);
- tSize.y += textMarginHeight;
-
- spinner.setBounds(cRect.x, cRect.y, cRect.width, tSize.y);
-
- Rectangle sRect = spinner.getControl().computeTrim(0, 0, 0, 0);
- int sWidth = sRect.x + sRect.width
- - 2 * spinner.getControl().getBorderWidth() + 1;
-
- if (gtk && sWidth == 0) {
- sWidth = 67;
- }
-
- tSize.x = cRect.width - sWidth;
-
- text.setBounds(cRect.x, cRect.y + getBorderWidth(), tSize.x,
- tSize.y);
- }
- }
-
- private static final int FIELD_NONE = -1;
-
- private static final int DISCARD = 0;
- private static final int WRAP = 1;
- private static final int BLOCK = 2;
-
- private static int convertStyle(int style) {
- int rstyle = SWT.NONE;
- if ((style & CDT.DROP_DOWN) != 0) {
- rstyle |= SWT.DROP_DOWN;
- }
- if ((style & CDT.SIMPLE) != 0) {
- rstyle |= SWT.SIMPLE;
- }
- if ((style & CDT.READ_ONLY) != 0) {
- rstyle |= SWT.READ_ONLY;
- }
- if ((style & CDT.BUTTON_LEFT) != 0) {
- rstyle |= SWT.LEFT;
- }
- if ((style & CDT.TEXT_LEAD) != 0) {
- rstyle |= SWT.LEAD;
- }
- if ((style & CDT.BORDER) != 0) {
- rstyle |= SWT.BORDER;
- }
- if (win32) {
- rstyle |= SWT.DOUBLE_BUFFERED;
- }
- return rstyle;
- }
-
- VPanel picker;
-
- VNative spinner;
- boolean internalFocusShift = false;
- boolean rightClick = false;
-
- private Date cancelDate;
- private Calendar calendar;
- private Calendar minDate;
- private Calendar maxDate;
-
- private DateFormat df;
- Locale locale;
-
- TimeZone timezone;
- Field[] field;
- int activeField;
-
- private boolean tabStops = false;
- // Store these values so that the style can be reset automatically
- // to update everything if/when the locale is changed
- int style;
- String pattern = null;
-
- int format = -1;
-
- private CDateTimePainter painter;
-
- /**
- * Delegates events to their appropriate handler
- */
- Listener textListener = event -> {
- switch (event.type) {
- case SWT.FocusIn:
- rightClick = false;
- if (internalFocusShift) {
- if (activeField < 0) {
- fieldFirst();
- updateText();
- }
- } else {
- if (VTracker.getLastTraverse() == SWT.TRAVERSE_TAB_PREVIOUS) {
- fieldLast();
- } else {
- fieldFirst();
- }
- updateText();
- }
- break;
- case SWT.FocusOut:
- if (!rightClick && !internalFocusShift) {
- if (commitEditField()) {
- updateText();
- } else {
- editField = null;
- }
- }
- break;
- case SWT.KeyDown:
- handleKey(event);
- break;
- case SWT.MouseDown:
- if (event.button == 1) {
- fieldFromTextSelection();
- } else if (event.button == 2) {
- fieldNext();
- } else if (event.button == 3) {
- rightClick = true;
- }
- break;
- case SWT.MouseWheel:
- Control focusedControl = getDisplay().getFocusControl();
- if (getTextWidget() != null
- && getTextWidget().getControl() != focusedControl) {
- // Do not handle mousewheel events if the widget does not have
- // focus
- break;
- }
- if (event.count > 0) {
- fieldAdjust(1);
- } else {
- fieldAdjust(-1);
- }
- event.doit = false;
- break;
- case SWT.MouseUp:
- if (event.button == 1) {
- fieldFromTextSelection();
- }
- break;
- case SWT.Traverse:
- handleTraverse(event);
- break;
- case SWT.Verify:
- verify(event);
- break;
- }
- };
- private Point textSelectionOffset = new Point(0, 0); // x = selOffset start,
- // y = selOffset
- // amount
- private EditField editField;
-
- private String[] separator;
- private int[] calendarFields;
- private boolean isTime;
- private boolean isDate;
- // private boolean isNull = true;
- private String nullText = null;
-
- private boolean defaultNullText = true;
- private boolean singleSelection;
-
- // private boolean dragSelection;
- private Date[] selection = new Date[0];
-
- private boolean scrollable = true;
-
- CDateTimeBuilder builder;
-
- VPanel pickerPanel;
-
- private TimeZone[] allowedTimezones;
-
- Color buttonHoverBackgroundColor, buttonHoverBorderColor;
- Color buttonSelectedBackgroundColor, buttonSelectedBorderColor;
-
- Color pickerForegroundColor, pickerBackgroundColor;
- Font pickerFont;
-
- Color pickerActiveDayColor, pickerInactiveDayColor, pickerTodayColor;
- Color pickerMinutesColor, pickerMinutesBackgroundColor;
-
- Color okButtonColor, cancelButtonColor, clearButtonForegroundColor;
- Font clearButtonFont;
- private VButton okButton, clearButton, cancelButton;
-
- /**
- * Constructs a new instance of this class given its parent and a style
- * value describing its behavior and appearance. The current date and the
- * system's default locale are used.
- *
- * @param parent
- * a widget which will be the parent of the new instance (cannot
- * be null)
- * @param style
- * the style of widget to construct
- */
- public CDateTime(Composite parent, int style) {
- super(parent, convertStyle(style));
- init(style);
- }
-
- /**
- * Adds the listener to the collection of listeners who will be notified
- * when the receiver's selection changes, by sending it one of the messages
- * defined in the SelectionListener interface.
- *
- * widgetSelected is called when the selection (date/time)
- * changes. widgetDefaultSelected is when ENTER is pressed the
- * text box.
- *
- * The event's data field will contain the newly selected Date object.
- * The event's detail field will contain which Calendar Field was changed
- *
- * @param listener
- * the listener which should be notified
- * @exception IllegalArgumentException
- *
- *
ERROR_NULL_ARGUMENT - if the listener is null
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
- public void addSelectionListener(SelectionListener listener) {
- if (listener != null) {
- TypedListener typedListener = new TypedListener(listener);
- addListener(SWT.Selection, typedListener);
- addListener(SWT.DefaultSelection, typedListener);
- }
- }
-
- /**
- * Adds the textListener for the appropriate SWT events to handle
- * incrementing fields.
- */
- protected void addTextListener() {
- removeTextListener();
-
- Text control = text.getControl();
- control.addListener(SWT.FocusIn, textListener);
- control.addListener(SWT.FocusOut, textListener);
- control.addListener(SWT.KeyDown, textListener);
- control.addListener(SWT.MouseDown, textListener);
- control.addListener(SWT.MouseWheel, textListener);
- control.addListener(SWT.MouseUp, textListener);
- control.addListener(SWT.Verify, textListener);
-
- text.addListener(SWT.Traverse, textListener);
- }
-
- /**
- * If a field is being edited (via keyboard), set the edit value to the
- * active field of the calendar. Reset the count of the EditField so that a
- * subsequent key press will overwrite its contents;
- *
- * @return true if the commit was successfull (the value was valid for the
- * field) or there was no commit to be made (editField is null),
- * false otherwise
- */
- private boolean commitEditField() {
- if (editField != null) {
- int cf = getCalendarField();
- int val = editField.getValue();
- editField.reset();
- if (cf == Calendar.MONTH) {
- val--;
- }
- return fieldSet(cf, val, DISCARD);
- }
- return true;
- }
-
- /**
- * If style is neither SIMPLE or DROP_DOWN, then this method simply returns,
- * otherwise it creates the picker.
- */
- private void createPicker() {
- if (isSimple()) {
- pickerPanel = panel;
- setContent(panel.getComposite());
- } else if (isDropDown()) {
- disposePicker();
-
- Shell shell = getContentShell();
- int style = (isSimple() ? SWT.NONE : SWT.BORDER)
- | SWT.DOUBLE_BUFFERED;
- VCanvas canvas = new VCanvas(shell, style);
- pickerPanel = canvas.getPanel();
- pickerPanel.setWidget(canvas);
- VGridLayout layout = new VGridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.verticalSpacing = 1;
- pickerPanel.setLayout(layout);
- setContent(pickerPanel.getComposite());
-
- canvas.addListener(SWT.KeyDown, event -> {
- if (SWT.ESC == event.keyCode) {
- event.doit = false;
- if (selection.length > 0 && selection[0] != cancelDate) {
- setSelection(cancelDate);
- fireSelectionChanged();
- }
- setOpen(false);
- }
- });
-
- if (field.length > 1 || isTime) {
- createPickerToolbar(pickerPanel);
- }
- }
-
- if (pickerBackgroundColor != null) {
- pickerPanel.setBackground(pickerBackgroundColor);
- }
- if (pickerForegroundColor != null) {
- pickerPanel.setForeground(pickerForegroundColor);
- }
- if (pickerFont != null) {
- pickerPanel.setFont(pickerFont);
- }
-
- if (isDate) {
- DatePicker dp = new DatePicker(this);
- dp.setScrollable(scrollable);
- dp.setFields(calendarFields);
- dp.updateView();
- picker = dp;
- } else if (isTime) {
- if ((style & CDT.CLOCK_DISCRETE) != 0) {
- DiscreteTimePicker dtp = new DiscreteTimePicker(this);
- dtp.setFields(calendarFields);
- dtp.updateView();
- picker = dtp;
- } else {
- AnalogTimePicker atp = new AnalogTimePicker(this);
- atp.setFields(calendarFields);
- atp.updateView();
- picker = atp;
- }
- }
-
- if (isDropDown()) {
- picker.setLayoutData(
- new GridData(SWT.FILL, SWT.FILL, false, false));
- }
- }
-
- private void createPickerToolbar(VPanel parent) {
- VPanel tb = new VPanel(parent, SWT.NONE);
- VGridLayout layout = new VGridLayout(3, false);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.horizontalSpacing = 2;
- tb.setLayout(layout);
- tb.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
- tb.setData(CDT.PickerPart, PickerPart.Toolbar);
-
- okButton = new VButton(tb, SWT.OK | SWT.NO_FOCUS);
- okButton.setData(CDT.PickerPart, PickerPart.OkButton);
- okButton.setToolTipText(Resources.getString("accept.text", locale)); //$NON-NLS-1$
- okButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
- okButton.addListener(SWT.Selection, event -> setOpen(false));
- okButton.setHoverBackgroundColor(buttonHoverBackgroundColor);
- okButton.setHoverBorderColor(buttonHoverBorderColor);
- okButton.setSelectedBackgroundColor(buttonSelectedBackgroundColor);
- okButton.setSelectedBorderColor(buttonSelectedBorderColor);
- okButton.setForeground(okButtonColor);
-
- cancelButton = new VButton(tb, SWT.CANCEL | SWT.NO_FOCUS);
- cancelButton.setData(CDT.PickerPart, PickerPart.CancelButton);
- cancelButton.setToolTipText(Resources.getString("cancel.text", locale)); //$NON-NLS-1$
- cancelButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
- cancelButton.addListener(SWT.Selection, event -> {
- setSelection(cancelDate);
- fireSelectionChanged();
- setOpen(false);
- });
- cancelButton.setHoverBackgroundColor(buttonHoverBackgroundColor);
- cancelButton.setHoverBorderColor(buttonHoverBorderColor);
- cancelButton.setSelectedBackgroundColor(buttonSelectedBackgroundColor);
- cancelButton.setSelectedBorderColor(buttonSelectedBorderColor);
- cancelButton.setForeground(cancelButtonColor);
-
- clearButton = new VButton(tb, SWT.NO_FOCUS);
- clearButton.setData(CDT.PickerPart, PickerPart.ClearButton);
- clearButton.setText(Resources.getString("clear.text", locale)); //$NON-NLS-1$
- clearButton.setToolTipText(Resources.getString("clear.text", locale)); //$NON-NLS-1$
- clearButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
- clearButton.addListener(SWT.Selection, event -> {
- setOpen(false);
- setSelection(null);
- fireSelectionChanged();
- });
- clearButton.setForeground(clearButtonForegroundColor!=null?clearButtonForegroundColor:parent.getForeground());
- clearButton.setFont(clearButtonFont!=null?clearButtonFont:parent.getFont());
- clearButton.setHoverBackgroundColor(buttonHoverBackgroundColor);
- clearButton.setHoverBorderColor(buttonHoverBorderColor);
- clearButton.setSelectedBackgroundColor(buttonSelectedBackgroundColor);
- clearButton.setSelectedBorderColor(buttonSelectedBorderColor);
-
-
- VLabel sep = new VLabel(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
- sep.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
- }
-
- private void disposePicker() {
- if (content != null) {
- if (picker != null) {
- picker.dispose();
- picker = null;
- }
- if (isDropDown()) {
- Control c = content;
- setContent(null);
- c.dispose();
- if (contentShell != null) {
- Display.getDefault().asyncExec(() -> {
- if (contentShell != null
- && !contentShell.isDisposed()) {
- contentShell.dispose();
- contentShell = null;
- }
- });
- }
- }
- }
- }
-
- /**
- * Adds the given amount to the x² field, if there is one
- */
- void fieldAdjust(int amount) {
- if (!hasSelection()) {
- if (DatePicker.isValidDate(calendar, minDate, maxDate)) {
- setSelection(calendar.getTime());
- fireSelectionChanged();
- } else {
- setOpen(true);
- }
- } else {
- int cf = getCalendarField();
- if (cf >= 0) {
- fieldRoll(cf, amount, WRAP);
- }
- }
- }
-
- void fieldFirst() {
- // If the user has opted to have the user be able to
- // change time zones then allow the next field to be the
- // time zone field
- if (this.allowedTimezones == null) {
- if (Calendar.ZONE_OFFSET == getCalendarField(field[0])) {
- setActiveField(1);
- } else {
- setActiveField(0);
- }
- } else {
- // allowed time zones have been set, so let the user edit it
- setActiveField(0);
- }
- }
-
- /**
- * Sets the active field from the select of the text box
- */
- void fieldFromTextSelection() {
- if (!hasSelection()) {
- // setActiveField(FIELD_ALL);
- fieldNext();
- } else {
- Point sel = text.getControl().getSelection();
- AttributedCharacterIterator aci = df
- .formatToCharacterIterator(calendar.getTime());
- if (sel.x > textSelectionOffset.x) {
- sel.x += textSelectionOffset.y;
- }
- aci.setIndex(sel.x);
- Object[] oa = aci.getAttributes().keySet().toArray();
- if (oa.length == 0 && sel.x > 0) {
- sel.x -= 1;
- aci.setIndex(sel.x);
- oa = aci.getAttributes().keySet().toArray();
- }
- if (oa.length > 0) {
- for (int i = 0; i < field.length; i++) {
- if (oa[0].equals(field[i])) {
- // If the user has opted to have the user be able to
- // change time zones then allow the next field to be the
- // time zone field
- if (this.allowedTimezones == null) {
- if (Calendar.ZONE_OFFSET != getCalendarField(
- field[i])) {
- setActiveField(i);
- }
- } else {
- // allowed time zones have been set, so let the user
- // edit it
- setActiveField(i);
- }
- break;
- }
- }
- updateText();
- }
- }
- }
-
- void fieldLast() {
- // If the user has opted to have the user be able to change
- // time zones then allow the next field to be the time zone field
- if (this.allowedTimezones == null) {
- if (Calendar.ZONE_OFFSET == getCalendarField(
- field[field.length - 1])) {
- setActiveField(field.length - 2);
- } else {
- setActiveField(field.length - 1);
- }
- } else {
- // allowed time zones have been set, so let the user edit it
- setActiveField(field.length - 1);
- }
- }
-
- /**
- * Sets the active field to the next field; wraps if necessary and sets to
- * last field if there is no current active field
- */
- void fieldNext() {
- fieldNext(false);
- }
-
- /**
- * Sets the active field to the next field; wraps if necessary and sets to
- * last field if there is no current active field
- *
- * @param If
- * true, the text update will be asynchronous (for changes to
- * text selection)
- */
- void fieldNext(boolean async) {
- if (activeField >= 0 && activeField < field.length - 1) {
- // If the user has opted to have the user be able to change
- // time zones then allow the next field to be the time zone field
- if (this.allowedTimezones == null) {
- if (Calendar.ZONE_OFFSET == getCalendarField(
- field[activeField + 1])) {
- if (activeField < field.length - 2) {
- setActiveField(activeField + 2);
- } else {
- setActiveField(0);
- }
- } else {
- setActiveField(activeField + 1);
- }
- } else {
- // allowed time zones have been set, so let the user edit it
- setActiveField(activeField + 1);
- }
- } else {
- // If the user has opted to have the user be able to change
- // time zones then allow the next field to be the time zone field
- if (this.allowedTimezones == null) {
- if (Calendar.ZONE_OFFSET == getCalendarField(field[0])) {
- setActiveField(1);
- } else {
- setActiveField(0);
- }
- } else {
- // allowed time zones have been set, so let the user edit it
- setActiveField(0);
- }
- }
- updateText(async);
- }
-
- /**
- * Sets the active field to the previous field; wraps if necessary and sets
- * to first field if there is no current active field
- */
- private void fieldPrev() {
- fieldPrev(false);
- }
-
- /**
- * Sets the active field to the previous field; wraps if necessary and sets
- * to first field if there is no current active field
- *
- * @param If
- * true, the text update will be asynchronous (for changes to
- * text selection)
- */
- void fieldPrev(boolean async) {
- if (activeField > 0 && activeField < field.length) {
- // If the user has opted to have the user be able to change
- // time zones then allow the next field to be the time zone field
- if (this.allowedTimezones == null) {
- if (Calendar.ZONE_OFFSET == getCalendarField(
- field[activeField - 1])) {
- if (activeField > 1) {
- setActiveField(activeField - 2);
- } else {
- setActiveField(field.length - 1);
- }
- } else {
- setActiveField(activeField - 1);
- }
- } else {
- // allowed time zones have been set, so let the user edit it
- setActiveField(activeField - 1);
- }
- } else {
- // If the user has opted to have the user be able to change
- // time zones then allow the next field to be the time zone field
- if (this.allowedTimezones == null) {
-
- if (Calendar.ZONE_OFFSET == getCalendarField(
- field[field.length - 1])) {
- setActiveField(field.length - 2);
- } else {
- setActiveField(field.length - 1);
- }
- } else {
- // allowed time zones have been set, so let the user edit it
- setActiveField(field.length - 1);
- }
- }
- updateText(async);
- }
-
- private boolean fieldRoll(final int calendarField, final int rollAmount,
- final int style) {
- if (!getEditable()) {
- return false;
- }
-
- long backup = calendar.getTimeInMillis();
-
- if (calendarField == Calendar.ZONE_OFFSET
- && this.allowedTimezones != null) {
- boolean timeZoneSet = false;
- for (int idx = 0; idx < this.allowedTimezones.length; idx++) {
- TimeZone activeTimeZone = this.getTimeZone();
- if (activeTimeZone.getID() == this.allowedTimezones[idx]
- .getID()) {
- if (rollAmount < 0) {
- if (idx == 0) {
- this.setTimeZone(
- this.allowedTimezones[this.allowedTimezones.length
- - 1]);
- } else {
- this.setTimeZone(this.allowedTimezones[idx - 1]);
- }
- } else if (rollAmount > 0) {
- if (idx == this.allowedTimezones.length - 1) {
- this.setTimeZone(this.allowedTimezones[0]);
- } else {
- this.setTimeZone(this.allowedTimezones[idx + 1]);
- }
- }
- timeZoneSet = true;
- break;
- }
- }
- if (!timeZoneSet) {
- this.setTimeZone(this.allowedTimezones[0]);
- }
- } else {
- if ((this.style & CDT.ADD_ON_ROLL) != 0) {
- calendar.add(calendarField, rollAmount);
- } else {
- if (calendarField == Calendar.YEAR
- && calendar.get(Calendar.YEAR) == 1 && rollAmount < 0) {
- return false;
- }
- calendar.roll(calendarField, rollAmount);
- }
- }
-
- if (!DatePicker.isValidDate(calendar, minDate, maxDate)) {
- calendar.setTimeInMillis(backup);
- return false;
- }
- if (selection.length > 0) {
- selection[0] = calendar.getTime();
- }
- updateText();
- updatePicker();
- fireSelectionChanged(calendarField);
-
- return true;
- }
-
- /**
- * Sets the given calendar field to the given value.
- * NOTE: This is NOT the active field but a field in the "calendar"
- * variable.
- *
- * @param calendarField
- * the field of calendar to set
- * @param value
- * the value to set it to
- * @param style
- * the of set to perform; if the value is valid for the given
- * calendarField then this has no affect, otherwise it will take
- * an action according to this style int:
- *
- *
DISCARD: the value will be discarded and the method
- * returns without performing and action
- *
WRAP: if value is higher than its maximum it will be set
- * to its minimum, and visa versa
- *
BLOCK: if value is higher than its maximum it will be set
- * to its maximum, and visa versa
- *
- * @return true if the field was set, false otherwise (as is possible with a
- * DISCARD style)
- */
- private boolean fieldSet(int calendarField, int value, int style) {
- if (!getEditable()) {
- return false;
- }
- if (calendarField >= 0) {
- if (value > calendar.getActualMaximum(calendarField)) {
- if (style == DISCARD) {
- return false;
- } else if (style == WRAP) {
- value = calendar.getActualMinimum(calendarField);
- } else if (style == BLOCK) {
- value = calendar.getActualMaximum(calendarField);
- }
- } else if (value < calendar.getActualMinimum(calendarField)) {
- if (style == DISCARD) {
- return false;
- } else if (style == WRAP) {
- value = calendar.getActualMaximum(calendarField);
- } else if (style == BLOCK) {
- value = calendar.getActualMinimum(calendarField);
- }
- }
-
- Calendar tmp = (Calendar) calendar.clone();
- tmp.set(calendarField, value);
- tmp.getTime(); // call to set the Fields in the Calendar
-
- if (!DatePicker.isValidDate(tmp, getMinDate(), getMaxDate())) {
- return false;
- }
-
- calendar.set(calendarField, value);
- if (selection.length > 0) {
- selection[0] = calendar.getTime();
- }
- updateText();
- updatePicker();
- fireSelectionChanged(calendarField);
- }
- return true;
- }
-
- /**
- *
- * Notifies listeners that the selection for this CDateTime has changed
- *
- *
- * This will fire both a regular selection event, and a default selection
- * event.
- *
- *
- * The data field is populated by {@link #getSelectedDates()}.
- *
- * Notifies listeners that a field of the selected date for this CDateTime
- * has changed
- *
- *
- * Note that this is only valid when {@link #singleSelection} is true, and
- * will only fire a regular selection event (not a default selection event)
- *
- *
- * The data field is populated by {@link #getSelection()} and the detail
- * field holds the field which was changed.
- *
- *
- * @param field
- * the Calendar Field which caused the change, or -1 if
- * setTime was called (thus setting all Calendar
- * Fields)
- */
- void fireSelectionChanged(int field) {
- Event event = new Event();
- event.data = getSelection();
- event.detail = field;
- if (this.field.length == 1) {
- if (isOpen()) {
- setOpen(false);
- }
- notifyListeners(SWT.Selection, event);
- notifyListeners(SWT.DefaultSelection, event);
- } else {
- notifyListeners(SWT.Selection, event);
- }
- }
-
- VButton getButtonWidget() {
- return button;
- }
-
- /**
- * Gets the calendar field corresponding to the active field, if there is
- * one.
- *
- * @return an int representing the calendar field, -1 if there isn't one.
- */
- int getCalendarField() {
- return hasField(activeField) ? getCalendarField(field[activeField])
- : -1;
- }
-
- int getCalendarField(Field field) {
- int cf = field.getCalendarField();
- if (cf < 0) {
- if (field.toString().indexOf("hour 1") > -1) { //$NON-NLS-1$
- cf = Calendar.HOUR;
- } else if (field.toString().contains("zone")) { //$NON-NLS-1$
- cf = Calendar.ZONE_OFFSET;
- } else if (field.toString().contains("hour of day 1")) { //$NON-NLS-1$
- cf = Calendar.HOUR_OF_DAY;
- }
- }
- return cf;
- }
-
- Calendar getCalendarInstance() {
- return getCalendarInstance(calendar.getTimeInMillis());
- }
-
- /**
- *
- * WARNING: Experimental API - this method may be removed in future
- * versions
- *
- * Get a new instance of Calendar that is initialized with the timezone and
- * locale of this CDateTime, and set to the given date.
- *
- * @param date
- * the date that the Calendar will be set to, or null for the
- * current system time
- * @return a new instance of Calendar
- */
- public Calendar getCalendarInstance(Date date) {
- if (date == null) {
- return getCalendarInstance(System.currentTimeMillis());
- } else {
- return getCalendarInstance(date.getTime());
- }
- }
-
- /**
- *
- * WARNING: Experimental API - this method may be removed in future
- * versions
- *
- * Get a new instance of Calendar that is initialized with the timezone and
- * locale of this CDateTime, and set to the given date.
- *
- * @param date
- * the date, in millis, that the Calendar will be set to
- * @return a new instance of Calendar
- */
- public Calendar getCalendarInstance(long date) {
- Calendar cal = Calendar.getInstance(timezone, locale);
- cal.setTimeInMillis(date);
- return cal;
- }
-
- Date getCalendarTime() {
- return calendar.getTime();
- }
-
- long getCalendarTimeInMillis() {
- return calendar.getTimeInMillis();
- }
-
- @Override
- public boolean getEditable() {
- return !panel.hasStyle(SWT.READ_ONLY);
- }
-
- /**
- * The locale currently in use by this CDateTime.
- *
- * @return the locale
- * @see #setLocale(Locale)
- */
- public Locale getLocale() {
- return locale;
- }
-
- /**
- * Get the text which will be shown when the selection is set to null. Note
- * that this will be equal to the default null text for the given locale
- * unless the null text has been explicitly set using
- * {@link #setNullText(String)}
- *
- * @return the text shown when the selection is null
- * @see #setNullText(String)
- */
- public String getNullText() {
- if (nullText == null) {
- if (isDate) {
- return Resources.getString("null_text.date", locale); //$NON-NLS-1$
- } else {
- return Resources.getString("null_text.time", locale); //$NON-NLS-1$
- }
- }
- return nullText;
- }
-
- CDateTimePainter getPainter() {
- if (painter == null) {
- setPainter(new CDateTimePainter());
- }
- return painter;
- }
-
- /**
- * Get the pattern of this CDateTime as used to set its format. If the
- * format was NOT set using setFormat(String) this will return
- * null.
- *
- * @return the pattern, null if there isn't one
- * @see SimpleDateFormat
- * @see #setFormat(int)
- * @see #setPattern(String)
- */
- public String getPattern() {
- return pattern;
- }
-
- /**
- * Get the current selection of this CDateTime widget, or null if there is
- * no selection.
- *
- * @return the current selection
- */
- public Date getSelection() {
- return hasSelection() ? selection[0] : null;
- }
-
- @Override
- public int getStyle() {
- return style;
- }
-
- @Override
- public String getText() {
- return checkText() ? text.getText() : null;
- }
-
- VNative getTextWidget() {
- return text;
- }
-
- /**
- * The timezone currently in use by this CDateTime.
- *
- * @return the timezone
- * @see #setTimeZone(String)
- * @see #setTimeZone(TimeZone)
- */
- public TimeZone getTimeZone() {
- return timezone;
- }
-
- /**
- * The Key event handler
- *
- * @param event
- * the event
- */
- void handleKey(Event event) {
- if (event.stateMask != 0 && event.stateMask != SWT.SHIFT) {
- return;
- }
- if ('\r' == event.keyCode || SWT.KEYPAD_CR == event.keyCode) {
- fieldNext();
- fireSelectionChanged(true);
- } else if (SWT.BS == event.keyCode || SWT.DEL == event.keyCode) {
- event.doit = false;
- setSelection((Date) null);
- fireSelectionChanged();
- } else if (!hasField(activeField) && !hasSelection()) {
- event.doit = false;
- } else {
- switch (event.keyCode) {
- case '-':
- case SWT.KEYPAD_SUBTRACT:
- fieldAdjust(-1);
- break;
- case '=':
- case '+':
- case SWT.KEYPAD_ADD:
- fieldAdjust(1);
- break;
- case SWT.BS:
- if (editField != null) {
- editField.removeLastCharacter();
- }
- break;
- case SWT.CR:
- fieldNext();
- fireSelectionChanged();
- break;
- case SWT.ARROW_DOWN:
- fieldAdjust(-1);
- updateText(true);
- break;
- case SWT.ARROW_UP:
- fieldAdjust(1);
- updateText(true);
- break;
- case SWT.ARROW_LEFT:
- fieldPrev(true);
- break;
- case SWT.ARROW_RIGHT:
- fieldNext(true);
- break;
- case SWT.ESC:
- if (contentShell != null) {
- event.doit = false;
- if (selection.length > 0 && selection[0] != cancelDate) {
- setSelection(cancelDate);
- fireSelectionChanged();
- }
- setOpen(false);
- }
- break;
- default:
- if (hasField(activeField) && activeField + 1 < separator.length
- && String.valueOf(event.character)
- .equals(separator[activeField + 1])) {
- fieldNext();
- } else if (!hasSelection()
- && String.valueOf(event.character).matches("[0-9]")) { //$NON-NLS-1$
- fieldAdjust(0);
- fieldFirst();
- }
- }
- }
- }
-
- /**
- * The Travers event handler. Note that ARROW_UP and ARROW_DOWN are handled
- * in the handleKey method.
- *
- * @param event
- * the event
- */
- void handleTraverse(Event event) {
- boolean allowTimeZoneEdit = this.allowedTimezones != null;
-
- switch (event.detail) {
- case SWT.TRAVERSE_ARROW_NEXT:
- if (event.keyCode == SWT.ARROW_RIGHT) {
- fieldNext();
- } else if (event.keyCode == SWT.ARROW_DOWN) {
- fieldAdjust(-1);
- }
- break;
- case SWT.TRAVERSE_ARROW_PREVIOUS:
- if (event.keyCode == SWT.ARROW_LEFT) {
- fieldPrev();
- } else if (event.keyCode == SWT.ARROW_UP) {
- fieldAdjust(1);
- }
- break;
- case SWT.CR:
- fieldNext();
- fireSelectionChanged();
- break;
- case SWT.TRAVERSE_TAB_NEXT:
- if (tabStops && hasSelection()) {
- // if we are at the last field, allow the tab out of the control
- // the last field is also considered to be the 2nd to last if
- // the last is a time zone
- // we now check if the control allows time zone editing
- if (activeField == field.length - 1
- || activeField == field.length - 2
- && Calendar.ZONE_OFFSET == getCalendarField(
- field[field.length - 1])
- && !allowTimeZoneEdit) {
- event.doit = true;
- } else {
- event.doit = false;
- if (activeField < 0) {
- fieldPrev();
- } else {
- fieldNext();
- }
- }
- }
- break;
- case SWT.TRAVERSE_TAB_PREVIOUS:
- if (tabStops && hasSelection()) {
- // if we are at the 1st field, allow the tab out of the control
- // the 1st field is also considered to the the 2nd if the 1st
- // is a time zone
- if (activeField == 0 || activeField == 1
- && Calendar.ZONE_OFFSET == getCalendarField(field[0])
- && !allowTimeZoneEdit) {
- event.doit = true;
- } else {
- event.doit = false;
- if (activeField < 0) {
- fieldNext();
- } else {
- fieldPrev();
- }
- }
- }
- break;
- default:
- }
- }
-
- /**
- * Determines if the given field number is backed by a real field.
- *
- * @param field
- * the field number to check
- * @return true if the given field number corresponds to a field in the
- * field array
- */
- private boolean hasField(int field) {
- return field >= 0 && field <= this.field.length;
- }
-
- /**
- * Return true if this CDateTime has one or more dates selected;
- *
- * @return true if a date is selected, false otherwise
- */
- public boolean hasSelection() {
- return selection.length > 0;
- }
-
- private void init(int style) {
- this.style = style;
- locale = Locale.getDefault();
- try {
- timezone = TimeZone.getDefault();
- } catch (Exception e) {
- timezone = TimeZone.getTimeZone("GMT"); //$NON-NLS-1$
- }
- calendar = Calendar.getInstance(this.timezone, this.locale);
- calendar.setTime(new Date());
- tabStops = (style & CDT.TAB_FIELDS) != 0;
- singleSelection = (style & CDT.SIMPLE) == 0 || (style & CDT.MULTI) == 0;
-
- setFormat(style);
-
- if (isSimple()) {
- return;
- }
- if (isDropDown()) {
- if ((style & CDT.BUTTON_AUTO) != 0) {
- setButtonVisibility(BaseCombo.BUTTON_AUTO);
- } else {
- setButtonVisibility(BaseCombo.BUTTON_ALWAYS);
- }
- } else {
- setButtonVisibility(BaseCombo.BUTTON_NEVER);
- if ((style & CDT.SPINNER) != 0) {
- int sStyle = SWT.VERTICAL;
- if (gtk && (style & CDT.BORDER) != 0) {
- sStyle |= SWT.BORDER;
- }
- spinner = VNative.create(Spinner.class, panel, sStyle);
- if (win32) {
- spinner.setBackground(text.getControl().getBackground());
- }
- spinner.getControl().setMinimum(0);
- spinner.getControl().setMaximum(50);
- spinner.getControl().setDigits(1);
- spinner.getControl().setIncrement(1);
- spinner.getControl().setPageIncrement(1);
- spinner.getControl().setSelection(25);
- spinner.getControl().addFocusListener(new FocusAdapter() {
- @Override
- public void focusGained(FocusEvent e) {
- internalFocusShift = true;
- setFocus();
- internalFocusShift = false;
- }
- });
- spinner.getControl().addMouseListener(new MouseAdapter() {
- @Override
- public void mouseDown(MouseEvent e) {
- if (e.button == 2) {
- fieldNext();
- }
- }
- });
- spinner.getControl()
- .addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (VTracker.getMouseDownButton() != 2) {
- if (spinner.getControl()
- .getSelection() > 25) {
- fieldAdjust(1);
- } else {
- fieldAdjust(-1);
- }
- spinner.getControl().setSelection(25);
- }
- }
- });
- panel.setLayout(new SpinnerLayout());
- }
- }
-
- updateText();
- activeField = -5;
- setActiveField(FIELD_NONE);
-
- if (checkText()) {
- addTextListener();
- }
- }
-
- boolean isSelected(Date date) {
- for (Date d : selection) {
- if (d.equals(date)) {
- return true;
- }
- }
- return false;
- }
-
- boolean isSingleSelection() {
- return singleSelection;
- }
-
- /**
- * Determine whether the provided field is the most precise field.
- * According to the used pattern, e.g.
- *
- *
dd.mm.yyyy
- *
MMMM yyyy
- *
yyyy
- *
- * the date picker provides the panels for selecting a day, month or year
- * respectively. The panel should close itself and set the selection in the
- * CDateTime field when the user selects the most precise field. The
- * constants from the {@link Calendar} class may be used to determine the
- * most precise field:
- *
- *
{@link Calendar#YEAR} -> 1
- *
{@link Calendar#MONTH} -> 2
- *
{@link Calendar#DATE} -> 5
- *
- * e.g. the highest constant is the closing field.
- *
- * @param calendarField
- * The calendar field identifying a pattern field
- * @return true if the highest pattern field
- */
- boolean isClosingField(int calendarField) {
- // find the "highest" constant in the pattern fields
- int i = Integer.MIN_VALUE;
- for (Field f : field) {
- i = Math.max(i, f.getCalendarField());
- }
- // compare the highest constant with the field
- if (i == calendarField) {
- return true;
- }
- return false;
- }
-
- @Override
- protected void postClose(Shell popup) {
- disposePicker();
- }
-
- /**
- * Removes the listener from the collection of listeners who will be
- * notified when the receiver's selection changes.
- *
- * @param listener
- * the listener which should no longer be notified
- * @exception IllegalArgumentException
- *
- *
ERROR_NULL_ARGUMENT - if the listener is null
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- * @see SelectionListener
- * @see #addSelectionListener
- */
- public void removeSelectionListener(SelectionListener listener) {
- if (listener != null) {
- TypedListener l = new TypedListener(listener);
- removeListener(SWT.Selection, l);
- removeListener(SWT.DefaultSelection, l);
- }
- }
-
- /**
- * Removes the textListener for the appropriate SWT events to handle
- * incrementing fields.
- */
- protected void removeTextListener() {
- Text control = text.getControl();
- control.removeListener(SWT.KeyDown, textListener);
- control.removeListener(SWT.MouseDown, textListener);
- control.removeListener(SWT.MouseWheel, textListener);
- control.removeListener(SWT.MouseUp, textListener);
- control.removeListener(SWT.Verify, textListener);
- text.removeListener(SWT.Traverse, textListener);
- }
-
- /**
- * Sets the active field, which may or may not be a real field (it may also
- * be FIELD_NONE)
- *
- * @param field
- * the field to be set active
- * @see CDateTime#hasField(int)
- */
- private void setActiveField(int field) {
- if (activeField != field) {
- commitEditField();
- editField = null;
- activeField = field;
- }
- }
-
- /**
- *
- * WARNING: Experimental API - this method may be removed in future
- * versions
- *
- * Sets the builder that this CDateTime widget will use to build its
- * graphical selector to the given builder, or to a default builder if the
- * given builder is null.
- *
- * @param builder
- * the builder to use, or null to use a default builder
- */
- public void setBuilder(CDateTimeBuilder builder) {
- this.builder = builder;
- this.minDate = builder.getMinDate();
- this.maxDate = builder.getMaxDate();
-
- if (picker != null) {
- disposePicker();
- createPicker();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.nebula.cwt.base.BaseCombo#setButtonImage(org.eclipse.swt.
- * graphics.Image)
- */
- @Override
- public void setButtonImage(Image image) {
- super.setButtonImage(image);
- }
-
- @Override
- protected boolean setContentFocus() {
- if (checkPicker()) {
- internalFocusShift = true;
- boolean result = picker.setFocus();
- internalFocusShift = false;
- return result;
- }
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.nebula.cwt.base.BaseCombo#setEditable(boolean)
- */
- @Override
- public void setEditable(boolean editable) {
- super.setEditable(editable);
- if (checkPicker()) {
- if (picker instanceof DatePicker) {
- ((DatePicker) picker).setEditable(editable);
- } else {
- picker.setActivatable(editable);
- }
- }
- }
-
- private boolean checkPicker() {
- return picker != null && !picker.isDisposed();
- }
-
- /**
- * Set the date and time format of this CDateTime uses style constants which
- * correspond to the various forms of DateFormat.getXxxInstance(int).
- *
- * Styles are bitwise OR'ed together, but only one "DATE" and one "TIME" may
- * be set at a time.
- *
- * Examples:
- * setFormat(CDT.DATE_LONG);
- * setFormat(CDT.DATE_SHORT | CDT.TIME_MEDIUM);
- *
- * @param format
- * the bitwise OR'ed Date and Time format to be set
- * @throws IllegalArgumentException
- * @see #getPattern()
- * @see #setPattern(String)
- */
- public void setFormat(int format) throws IllegalArgumentException {
- int dateStyle = (format & CDT.DATE_SHORT) != 0 ? DateFormat.SHORT
- : (format & CDT.DATE_MEDIUM) != 0 ? DateFormat.MEDIUM
- : (format & CDT.DATE_LONG) != 0 ? DateFormat.LONG : -1;
- int timeStyle = (format & CDT.TIME_SHORT) != 0 ? DateFormat.SHORT
- : (format & CDT.TIME_MEDIUM) != 0 ? DateFormat.MEDIUM : -1;
- String str = null;
- if (dateStyle != -1 && timeStyle != -1) {
- str = ((SimpleDateFormat) DateFormat.getDateTimeInstance(dateStyle,
- timeStyle, locale)).toPattern();
- } else if (dateStyle != -1) {
- str = ((SimpleDateFormat) DateFormat.getDateInstance(dateStyle,
- locale)).toPattern();
- } else if (timeStyle != -1) {
- str = ((SimpleDateFormat) DateFormat.getTimeInstance(timeStyle,
- locale)).toPattern();
- } else if (pattern == null) { // first call, so set to default
- format = CDT.DATE_SHORT;
- str = ((SimpleDateFormat) DateFormat
- .getDateInstance(DateFormat.SHORT, locale)).toPattern();
- }
- if (str != null) {
- this.format = format;
- setPattern(str);
- }
- }
-
- /**
- * Sets the Locale to be used by this CDateTime and causes all affected
- * attributes to be updated
- * If the provided locale is the same as the current locale then this method
- * simply returns. If the provided Locale is null then this CDateTime will
- * use the system's default locale.
- * If this CDateTime is of style DROP_DOWN then
- * the associated CDateTime will be set to the same locale.
- *
- * @param locale
- * the Locale, or null to use the system's default
- * @see #getLocale()
- */
- public void setLocale(Locale locale) {
- if (locale == null) {
- locale = Locale.getDefault();
- }
- if (!this.locale.equals(locale)) {
- this.locale = locale;
- if (format > 0) {
- setFormat(format);
- } else {
- setPattern(pattern);
- }
- updateNullText();
- }
- }
-
- @Override
- protected void setModifyEventProperties(Event e) {
- e.data = calendar.getTime();
- }
-
- /**
- * Set the text to be shown when the selection is null. Passing null into
- * this method will cause the CDateTime widget to use a default null text
- * for the given locale.
- *
- * @param text
- */
- public void setNullText(String text) {
- defaultNullText = false;
- nullText = text;
- updateText();
- }
-
- @Override
- public void setOpen(boolean open) {
- setOpen(open, null);
- }
-
- @Override
- public void setOpen(boolean open, Runnable callback) {
- if (open) {
- cancelDate = getSelection();
- createPicker();
- } else {
- cancelDate = null;
- }
- super.setOpen(open, callback);
- if (hasSelection()) {
- show(getSelection());
- }
- }
-
- /**
- *
- * WARNING: Experimental API - this method may be removed in future
- * versions
- *
- * Sets the painter that this CDateTime widget will use to paint its
- * graphical selector to the given painter, or to a default painter if the
- * given painter is null.
- *
- * @param painter
- * the painter to use, or null to use a default painter
- */
- public void setPainter(CDateTimePainter painter) {
- if (painter != null) {
- painter.setCDateTime(this);
- }
- this.painter = painter;
- }
-
- /**
- * Set the style of this CDateTime to work with dates and / or times as
- * determined by the given pattern. This will set the fields shown in the
- * text box and, if DROP_DOWN style is set, the fields of the
- * drop down component.
- * This method is backed by an implementation of SimpleDateFormat, and as
- * such, any string pattern which is valid for SimpleDateFormat may be used.
- * Examples (US Locale):
- * setPattern("MM/dd/yyyy h:mm a");
- * setPattern("'Meeting @' h:mm a 'on' EEEE, MMM dd,
- * yyyy");
- *
- * @param pattern
- * the pattern to use, if it is invalid, the original is restored
- * @throws IllegalArgumentException
- * @see SimpleDateFormat
- * @see #getPattern()
- * @see #setFormat(int)
- */
- public void setPattern(String pattern) throws IllegalArgumentException {
- this.allowedTimezones = null;
- if (isOpen()) {
- setOpen(false);
- }
- df = new SimpleDateFormat(pattern, locale);
- df.setTimeZone(timezone);
- if (updateFields()) {
- this.pattern = pattern;
- this.format = -1;
- boolean wasDate = isDate;
- boolean wasTime = isTime;
- isDate = isTime = false;
- calendarFields = new int[field.length];
- for (int i = 0; i < calendarFields.length; i++) {
- calendarFields[i] = getCalendarField(field[i]);
- switch (calendarFields[i]) {
- case Calendar.AM_PM:
- case Calendar.HOUR:
- case Calendar.HOUR_OF_DAY:
- case Calendar.MILLISECOND:
- case Calendar.MINUTE:
- case Calendar.SECOND:
- case Calendar.ZONE_OFFSET:
- isTime = true;
- break;
- case Calendar.DAY_OF_MONTH:
- case Calendar.DAY_OF_WEEK:
- case Calendar.DAY_OF_WEEK_IN_MONTH:
- case Calendar.DAY_OF_YEAR:
- case Calendar.ERA:
- case Calendar.MONTH:
- case Calendar.WEEK_OF_MONTH:
- case Calendar.WEEK_OF_YEAR:
- case Calendar.YEAR:
- isDate = true;
- break;
- default:
- break;
- }
- }
- if (checkButton() && (isDate != wasDate || isTime != wasTime)) {
- if (defaultButtonImage) {
- if (isDate && isTime) {
- doSetButtonImage(Resources.getIconCalendarClock());
- } else if (isDate) {
- doSetButtonImage(Resources.getIconCalendar());
- } else {
- doSetButtonImage(Resources.getIconClock());
- }
- }
- updateNullText();
- }
- if (checkText()) {
- updateText();
- }
- if (isSimple()) {
- disposePicker();
- createPicker();
- }
- } else {
- throw new IllegalArgumentException(
- "Problem setting pattern: \"" + pattern + "\""); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- void setScrollable(boolean scrollable) {
- this.scrollable = scrollable;
- if (isSimple() && !scrollable) {
- if (picker != null && picker instanceof DatePicker) {
- updatePicker();
- }
- }
- }
-
- /**
- * Set the selection for this CDateTime to that of the provided
- * Date object.
- *
- * @param selection
- * the new selection, or null to clear the selection
- */
- public void setSelection(Date selection) {
- if (getEditable()) {
- if (selection == null) {
- this.selection = new Date[0];
- } else if (DatePicker.isValidDate(getCalendarInstance(selection),
- minDate, maxDate)) {
- this.selection = new Date[] { selection };
- }
- }
- if (singleSelection && this.selection.length > 0) {
- show(selection);
- } else {
- updateText();
- updatePicker();
- }
- }
-
- /**
- * Sets the timezone to the timezone specified by the given zoneID, or to
- * the system default if the given zoneID is null. If the give zoneID cannot
- * be understood, then the timezone will be set to GMT.
- *
- * @param zoneID
- * the id of the timezone to use, or null to use the system
- * default
- * @see #setTimeZone(TimeZone)
- */
- public void setTimeZone(String zoneID) {
- if (zoneID == null) {
- setTimeZone((TimeZone) null);
- } else {
- setTimeZone(TimeZone.getTimeZone(zoneID));
- }
- }
-
- /**
- * Sets the timezone to the given timezone, or to the system's default
- * timezone if the given timezone is null.
- *
- * @param zone
- * the timezone to use, or null to use the system default
- * @see #setTimeZone(String)
- */
- public void setTimeZone(TimeZone zone) {
- if (zone == null) {
- timezone = TimeZone.getDefault();
- }
- if (!this.timezone.equals(zone)) {
- this.timezone = zone;
- calendar.setTimeZone(this.timezone);
- df.setTimeZone(this.timezone);
- updateText();
- }
- }
-
- /**
- * Shows the given date if it can be shown by the selector. In other words,
- * for graphical selectors such as a calendar, the visible range of time is
- * moved so that the given date is visible.
- *
- * @param date
- * the date to show
- */
- public void show(Date date) {
- if (date == null) {
- calendar.setTime(new Date());
- } else {
- calendar.setTime(date);
- }
- updateText();
- updatePicker();
- }
-
- /**
- * Show the selection if it can be shown by the selector. Has no affect if
- * there is no selection.
- *
- * @see #show(Date)
- */
- public void showSelection() {
- if (selection.length > 0) {
- show(selection[0]);
- }
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName() + " {" + getCalendarTime() + "}"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * inspects all of the calendar fields in the field array to
- * determine what style is appropriate and then sets that style to the
- * picker using the setPickerStyle method.
- */
- private boolean updateFields() {
- Field[] bak = new Field[field == null ? 0 : field.length];
- if (bak.length > 0) {
- System.arraycopy(field, 0, bak, 0, field.length);
- }
-
- AttributedCharacterIterator aci = df
- .formatToCharacterIterator(calendar.getTime());
- field = new Field[aci.getAllAttributeKeys().size()];
- separator = new String[field.length + 1]; // there can be a separator
- // before and after
- int i = 0;
- Object last = null;
- for (char c = aci.first(); c != CharacterIterator.DONE; c = aci
- .next()) {
- Object[] oa = aci.getAttributes().keySet().toArray();
- if (oa.length > 0) {
- if (oa[0] != last && i < field.length) {
- if (getCalendarField((Field) oa[0]) < 0) {
- if (bak.length > 0) {
- field = new Field[bak.length];
- System.arraycopy(bak, 0, field, 0, bak.length);
- }
- return false;
- } else {
- field[i] = (Field) oa[0];
- last = oa[0];
- }
- i++;
- }
- } else {
- if (separator[i] == null) {
- separator[i] = String.valueOf(c);
- }
- }
- }
-
- df.setLenient(false);
- setActiveField(FIELD_NONE);
- return true;
- }
-
- private void updateNullText() {
- if (defaultNullText) {
- if (isDate) {
- nullText = Resources.getString("null_text.date", locale); //$NON-NLS-1$
- } else {
- nullText = Resources.getString("null_text.time", locale); //$NON-NLS-1$
- }
- if (!hasSelection()) {
- updateText();
- }
- }
- }
-
- /**
- * tell the picker to update its view of the selection and reference time
- */
- private void updatePicker() {
- if (picker != null) {
- if (picker instanceof DatePicker) {
- ((DatePicker) picker).updateView();
- } else if (picker instanceof AnalogTimePicker) {
- ((AnalogTimePicker) picker).updateView();
- } else if (picker instanceof DiscreteTimePicker) {
- ((DiscreteTimePicker) picker).updateView();
- }
- }
- }
-
- /**
- * This is the only way that text is set to the text box.
- * The selection of the text in the text box is also set here (the active
- * field is selected) as well as if a field is being edited, it's "edit
- * text" is inserted for display. The getSelection property of
- * CDateTime remains unchanged.
- */
- private void updateText() {
- updateText(false);
- }
-
- /**
- * This is the only way that text is set to the text box.
- * The selection of the text in the text box is also set here (the active
- * field is selected) as well as if a field is being edited, it's "edit
- * text" is inserted for display. The getSelection property of
- * CDateTime remains unchanged.
- *
- * @param async
- * If true, this operation will be performed asynchronously (for
- * changes to text selection)
- */
- private void updateText(boolean async) {
- // TODO: save previous state and only update on changes...?
-
- String buffer = hasSelection() ? df.format(getSelection())
- : getNullText();
-
- int s0 = 0;
- int s1 = 0;
-
- if (!hasSelection()) {
- s0 = 0;
- s1 = buffer.length();
- } else if (activeField >= 0 && activeField < field.length) {
- AttributedCharacterIterator aci = df
- .formatToCharacterIterator(getSelection());
- for (char c = aci.first(); c != CharacterIterator.DONE; c = aci
- .next()) {
- if (aci.getAttribute(field[activeField]) != null) {
- s0 = aci.getRunStart();
- s1 = aci.getRunLimit();
- if (editField != null) {
- String str = editField.toString();
- buffer = buffer.substring(0, s0) + str
- + buffer.substring(s1);
- int oldS1 = s1;
- s1 = s0 + str.length();
- textSelectionOffset.x = Math.min(oldS1, s1);
- textSelectionOffset.y = oldS1 - s0 - str.length();
- } else {
- textSelectionOffset.x = buffer.length() + 1;
- textSelectionOffset.y = 0;
- }
- break;
- }
- }
- } else {
- setActiveField(FIELD_NONE);
- }
-
- final String string = buffer;
- final int selStart = s0;
- final int selEnd = s1;
-
- Runnable runnable = () -> {
- if (text != null && !text.isDisposed()) {
- if (!string.equals(text.getText())) {
- text.getControl().removeListener(SWT.Verify, textListener);
- text.setText(string);
- text.getControl().addListener(SWT.Verify, textListener);
- }
- if ((text.getControl().getStyle() & SWT.READ_ONLY) == 0) {
- text.getControl().setSelection(selStart, selEnd);
- }
- }
- };
-
- if (async) {
- getDisplay().asyncExec(runnable);
- } else {
- getDisplay().syncExec(runnable);
- }
- }
-
- /**
- * The Verify Event handler.
- * EVERYTHING is blocked via this handler (Event.doit is set to
- * false). Depending upon the input, a course of action is determined and
- * the displayed text is updated via the updateText() method.
- *
- * This method implements the following logic: If the event is a paste, the
- * pasted text is parsed for the entire date/time selection; if this parse
- * is successful, the result is committed to the selection property and is
- * displayed; otherwise, it is discarded. One-character pastes are discarded
- * without parsing. When user types characters one by one, all non-digits
- * are discarded (if they have effects, they have already been processed by
- * other event handlers) while digits are added to
- * this.editField without affecting the selection. Once
- * this.editField reaches its capacity for the active field,
- * its contents are attempted to be committed. If the commit is successful,
- * focus switches to the next field of CDateTime. Otherwise, the contents of
- * this.editField are discarded and the previous value of the
- * selection (before user started typing in this field) is restored; focus
- * stays in the same field. Example: if the seconds field contains
- * "23", and user types 8 in the seconds field, "08" is shown on screen
- * while getSelection still returns 23. If user types 9 after that, the
- * field reaches its capacity, the attempt to commit 89 seconds fails, and
- * 23 gets restored on screen.
- *
- * @param e
- * the event
- * @see CDateTime#updateText()
- */
- void verify(Event e) {
- // we don't want to reprocess the event
- if (e.doit == false) {
- return;
- }
-
- e.doit = false;
- if (field.length == 0 || activeField == FIELD_NONE || e.text == null) {
- return;
- }
-
- char c = e.character;
- if (e.text.length() == 1 && String.valueOf(c).equals(e.text)
- && Character.isDigit(c) || e.text.length() > 1) {
- if (e.text.length() == 1) {
- if (editField == null) {
- int cf = getCalendarField();
- if (cf >= 0) {
- int digits;
- switch (cf) {
- case Calendar.YEAR:
- digits = 4;
- break;
- case Calendar.DAY_OF_YEAR:
- digits = 3;
- break;
- case Calendar.AM_PM:
- case Calendar.DAY_OF_WEEK:
- case Calendar.ERA:
- digits = 1;
- break;
- case Calendar.MILLISECOND:
- digits = 3;
- break;
- default:
- digits = 2;
- }
- editField = new EditField(digits, calendar.get(cf));
- } else {
- return;
- }
- }
- if (editField.addChar(c)) {
- if (commitEditField()) {
- fieldNext();
- } else {
- editField = null;
- if (selection.length > 0) {
- selection[0] = calendar.getTime();
- }
- updateText();
- }
- }
- if (selection.length > 0) {
- selection[0] = calendar.getTime();
- }
- updatePicker();
- } else {
- try {
- setSelection(df.parse(e.text));
- fireSelectionChanged();
- } catch (ParseException pe) {
- // do nothing
- }
- }
- }
- updateText();
- }
-
- /**
- * @param pattern
- * @param allowedTimeZones
- * @throws IllegalArgumentException
- */
- public void setPattern(final String pattern,
- final TimeZone[] allowedTimeZones) throws IllegalArgumentException {
- this.setPattern(pattern);
- if (pattern.indexOf('z') != -1) {
- this.allowedTimezones = allowedTimeZones;
- }
- }
-
- /**
- * Returns the minimum date or null.
- *
- * @return Returns a clone of the minDate or null if not set.
- * @since 1.4
- */
- public Calendar getMinDate() {
- if (minDate == null) {
- return null;
- }
- return (Calendar) minDate.clone();
- }
-
- /**
- * Returns the maximum date or null.
- *
- * @return Returns a clone of the maxDate or null if not set.
- * @since 1.4
- */
- public Calendar getMaxDate() {
- if (maxDate == null) {
- return null;
- }
- return (Calendar) maxDate.clone();
- }
-
- /**
- * @see org.eclipse.swt.widgets.Control#setBackground(org.eclipse.swt.graphics.Color)
- */
- public void setBackground(Color color) {
- super.setBackground(color);
- if (spinner != null) {
- spinner.setBackground(color);
- }
- if (picker != null) {
- picker.updateColorsAndFont();
- }
- }
-
- public void setForeground(Color color) {
- super.setForeground(color);
- if (picker != null) {
- picker.updateColorsAndFont();
- }
- }
-
- /**
- * @param color
- * @since 1.5
- */
- public void setButtonHoverBackgroundColor(Color color) {
- checkWidget();
- this.buttonHoverBackgroundColor = color;
- if (picker != null) {
- picker.updateColorsAndFont();
- }
- }
-
- /**
- * @param color
- * @since 1.5
- */
- public void setButtonHoverBorderColor(Color color) {
- checkWidget();
- this.buttonHoverBorderColor = color;
- if (picker != null) {
- picker.updateColorsAndFont();
- }
- }
-
- /**
- * @param color
- * @since 1.5
- */
- public void setButtonSelectedBackgroundColor(Color color) {
- checkWidget();
- this.buttonSelectedBackgroundColor = color;
- if (picker != null) {
- picker.updateColorsAndFont();
- }
- }
-
- /**
- * @param color
- * @since 1.5
- */
- public void setButtonSelectedBorderColor(Color color) {
- checkWidget();
- this.buttonSelectedBorderColor = color;
- if (picker != null) {
- picker.updateColorsAndFont();
- }
- }
-
- /**
- * @return the picker foreground color
- * @since 1.5
- */
- public Color getPickerForegroundColor() {
- checkWidget();
- return pickerForegroundColor;
- }
-
- /**
- * @param pickerForegroundColor
- * @since 1.5
- */
- public void setPickerForegroundColor(Color pickerForegroundColor) {
- checkWidget();
- this.pickerForegroundColor = pickerForegroundColor;
- if (pickerForegroundColor != null && pickerPanel != null) {
- pickerPanel.setForeground(pickerForegroundColor);
- }
- if (picker != null && pickerPanel != null && pickerPanel != null) {
- picker.updateColorsAndFont();
- }
- }
-
- /**
- * @return the picker background color
- * @since 1.5
- */
- public Color getPickerBackgroundColor() {
- checkWidget();
- return pickerBackgroundColor;
- }
-
- /**
- * @param pickerBackgroundColor
- * @since 1.5
- */
- public void setPickerBackgroundColor(Color pickerBackgroundColor) {
- checkWidget();
- this.pickerBackgroundColor = pickerBackgroundColor;
- if (pickerBackgroundColor != null && pickerPanel != null) {
- pickerPanel.setBackground(pickerBackgroundColor);
- }
- if (picker != null) {
- picker.updateColorsAndFont();
- }
- }
-
- /**
- * @return the picker font
- * @since 1.5
- */
- public Font getPickerFont() {
- checkWidget();
- return pickerFont;
- }
-
- /**
- * @param pickerFont
- * @since 1.5
- */
- public void setPickerFont(Font pickerFont) {
- checkWidget();
- this.pickerFont = pickerFont;
- if (pickerFont != null && pickerPanel != null) {
- pickerPanel.setFont(pickerFont);
- }
- if (picker != null) {
- picker.updateColorsAndFont();
- }
- }
-
- /**
- * @return the bg color of the button hover
- * @since 1.5
- */
- public Color getButtonHoverBackgroundColor() {
- checkWidget();
- return buttonHoverBackgroundColor;
- }
-
- /**
- * @return the border color of the button hover
- * @since 1.5
- */
- public Color getButtonHoverBorderColor() {
- checkWidget();
- return buttonHoverBorderColor;
- }
-
- /**
- * @return the selected background of the button
- * @since 1.5
- */
- public Color getButtonSelectedBackgroundColor() {
- checkWidget();
- return buttonSelectedBackgroundColor;
- }
-
- /**
- * @return the border color of the selected button
- * @since 1.5
- */
- public Color getButtonSelectedBorderColor() {
- checkWidget();
- return buttonSelectedBorderColor;
- }
-
- /**
- * @return the color of the active day
- * @since 1.5
- */
- public Color getPickerActiveDayColor() {
- checkWidget();
- return pickerActiveDayColor;
- }
-
- /**
- * @param pickerActiveDayColor
- * @since 1.5
- */
- public void setPickerActiveDayColor(Color pickerActiveDayColor) {
- checkWidget();
- this.pickerActiveDayColor = pickerActiveDayColor;
- if (picker != null) {
- picker.updateColorsAndFont();
- }
- }
-
- /**
- * @return the color of the inactive day
- * @since 1.5
- */
- public Color getPickerInactiveDayColor() {
- checkWidget();
- return pickerInactiveDayColor;
- }
-
- /**
- * @param pickerInactiveDayColor
- * @since 1.5
- */
- public void setPickerInactiveDayColor(Color pickerInactiveDayColor) {
- checkWidget();
- this.pickerInactiveDayColor = pickerInactiveDayColor;
- if (picker != null) {
- picker.updateColorsAndFont();
- }
- }
-
- /**
- * @return the color of the "today" section
- * @since 1.5
- */
- public Color getPickerTodayColor() {
- checkWidget();
- return pickerTodayColor;
- }
-
- /**
- * @param pickerTodayColor
- * @since 1.5
- */
- public void setPickerTodayColor(Color pickerTodayColor) {
- checkWidget();
- this.pickerTodayColor = pickerTodayColor;
- if (picker != null) {
- picker.updateColorsAndFont();
- }
- }
-
- /**
- * @return the color of the minutes
- * @since 1.5
- */
- public Color getPickerMinutesColor() {
- checkWidget();
- return pickerMinutesColor;
- }
-
- /**
- * @param pickerMinutesColor
- * @since 1.5
- */
- public void setPickerMinutesColor(Color pickerMinutesColor) {
- checkWidget();
- this.pickerMinutesColor = pickerMinutesColor;
- if (picker != null) {
- picker.updateColorsAndFont();
- }
- }
-
- /**
- * @return the minutes background
- * @since 1.5
- */
- public Color getPickerMinutesBackgroundColor() {
- checkWidget();
- return pickerMinutesBackgroundColor;
- }
-
- /**
- * @param pickerMinutesBackgroundColor
- * @since 1.5
- */
- public void setPickerMinutesBackgroundColor(
- Color pickerMinutesBackgroundColor) {
- checkWidget();
- this.pickerMinutesBackgroundColor = pickerMinutesBackgroundColor;
- if (picker != null) {
- picker.updateColorsAndFont();
- }
- }
-
- /**
- * @return the foreground color of the "Ok" button
- */
- public Color getOkButtonColor() {
- checkWidget();
- return okButtonColor;
- }
-
- /**
- * @param okButtonColor the new foreground color of the "ok" button
- */
- public void setOkButtonColor(Color okButtonColor) {
- checkWidget();
- this.okButtonColor = okButtonColor;
- if (okButton != null) okButton.setForeground(okButtonColor);
- }
-
- /**
- * @return the foreground color of the "Cancel" button
- */
- public Color getCancelButtonColor() {
- checkWidget();
- return cancelButtonColor;
- }
-
- /**
- * @param cancelButtonColor the new foreground color of the "cancel" button
- */
- public void setCancelButtonColor(Color cancelButtonColor) {
- checkWidget();
- this.cancelButtonColor = cancelButtonColor;
- if (cancelButton != null) cancelButton.setForeground(cancelButtonColor);
- }
-
- /**
- * @return the foreground color of the "clear" button
- */
- public Color getClearButtonForegroundColor() {
- checkWidget();
- return clearButtonForegroundColor;
- }
-
- /**
- * @param clearButtonForegroundColor the new foreground color of the "clear" button
- */
- public void setClearButtonForegroundColor(
- Color clearButtonForegroundColor) {
- checkWidget();
- this.clearButtonForegroundColor = clearButtonForegroundColor;
- if (clearButton != null) clearButton.setForeground(clearButtonForegroundColor);
- }
-
- /**
- * @return the font of the "clear" button
- */
- public Font getClearButtonFont() {
- checkWidget();
- return clearButtonFont;
- }
-
- /**
- * @param clearButtonFont the new font of the "clear" button
- */
- public void setClearButtonFont(Font clearButtonFont) {
- checkWidget();
- this.clearButtonFont = clearButtonFont;
- if (clearButton != null) clearButton.setFont(clearButtonFont);
- }
-
-}
+/****************************************************************************
+ * Copyright (c) 2006-2019 Jeremy Dowdall
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Jeremy Dowdall - initial API and implementation
+ * Wim Jongman - https://bugs.eclipse.org/bugs/show_bug.cgi?id=362181
+ * Scott Klein - https://bugs.eclipse.org/bugs/show_bug.cgi?id=370605
+ * Baruch Youssin - https://bugs.eclipse.org/bugs/show_bug.cgi?id=261414
+ * Doug Showell - https://bugs.eclipse.org/bugs/show_bug.cgi?id=383589
+ * Bel Razom - https://bugs.eclipse.org/bugs/show_bug.cgi?id=527399
+ * Stefan Nöbauer - https://bugs.eclipse.org/bugs/show_bug.cgi?id=548149
+ *****************************************************************************/
+
+package org.eclipse.nebula.widgets.cdatetime;
+
+import java.text.AttributedCharacterIterator;
+import java.text.CharacterIterator;
+import java.text.DateFormat;
+import java.text.DateFormat.Field;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+
+import org.eclipse.nebula.cwt.base.BaseCombo;
+import org.eclipse.nebula.cwt.v.VButton;
+import org.eclipse.nebula.cwt.v.VCanvas;
+import org.eclipse.nebula.cwt.v.VGridLayout;
+import org.eclipse.nebula.cwt.v.VLabel;
+import org.eclipse.nebula.cwt.v.VLayout;
+import org.eclipse.nebula.cwt.v.VNative;
+import org.eclipse.nebula.cwt.v.VPanel;
+import org.eclipse.nebula.cwt.v.VTracker;
+import org.eclipse.nebula.widgets.cdatetime.CDT.PickerPart;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Spinner;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.TypedListener;
+
+/**
+ * The CDateTime provides both textual and graphical means selecting a
+ * date.
+ * As with other combo type widgets, there are three basic styles:
+ *
+ *
Text only (default)
+ *
Graphical only (CDT.SIMPLE)
+ *
Combo - a text selector with a drop-down graphical selector
+ * (CDT.DROP_DOWN)
+ *
+ *
+ * Styles are set using the constants provided in the CDT class.
+ *
+ *
+ * @see CDT
+ * @since 1.5
+ */
+public class CDateTime extends BaseCombo {
+
+ /**
+ * A simple class used for editing a field numerically.
+ */
+ private class EditField {
+
+ private String buffer;
+ private int digits;
+ private int count = 0;
+
+ EditField(int digits, int initialValue) {
+ this.digits = digits;
+ buffer = Integer.toString(initialValue);
+ }
+
+ /**
+ * Adds a character if it is a digit; in case the field exceeds its
+ * capacity, the oldest character is dropped from the buffer. Non-digits
+ * are dropped.
+ *
+ * @param c
+ * @return true if the new character is a digit and with its addition
+ * the active field reaches or exceeds its capacity, false
+ * otherwise
+ */
+ boolean addChar(char c) {
+ if (Character.isDigit(c)) {
+ buffer = count > 0 ? buffer : ""; //$NON-NLS-1$
+ buffer += String.valueOf(c);
+ if (buffer.length() > digits) {
+ buffer = buffer.substring(buffer.length() - digits,
+ buffer.length());
+ }
+ }
+ return ++count > digits - 1;
+ }
+
+ int getValue() {
+ return Integer.parseInt(buffer);
+ }
+
+ void removeLastCharacter() {
+ if (buffer.length() > 0) {
+ buffer = buffer.substring(0, buffer.length() - 1);
+ count--;
+ }
+ }
+
+ void reset() {
+ count = 0;
+ }
+
+ @Override
+ public String toString() {
+ if (buffer.length() < digits) {
+ char[] ca = new char[digits - buffer.length()];
+ Arrays.fill(ca, '0');
+ buffer = String.valueOf(ca).concat(buffer);
+ }
+ return buffer;
+ }
+ }
+
+ /**
+ * The layout used for a "basic" CDateTime - when it is neither of style
+ * SIMPLE or DROP_DOWN - with style of SPINNER.
+ * Note that there is a spinner, but no button for this style.
+ */
+ class SpinnerLayout extends VLayout {
+
+ @Override
+ protected Point computeSize(VPanel panel, int wHint, int hHint,
+ boolean flushCache) {
+ Point size = text.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+
+ Rectangle sRect = spinner.getControl().computeTrim(0, 0, 0, 0);
+ int sWidth = sRect.x + sRect.width
+ - 2 * spinner.getControl().getBorderWidth() + 1;
+
+ if (gtk && sWidth == 0) {
+ sWidth = 67;
+ }
+
+ size.x += sWidth;
+ size.x++;
+ size.y += textMarginHeight;
+
+ if (wHint != SWT.DEFAULT) {
+ size.x = Math.min(size.x, wHint);
+ }
+ if (hHint != SWT.DEFAULT) {
+ size.y = Math.min(size.y, hHint);
+ }
+ return size;
+ }
+
+ @Override
+ protected void layout(VPanel panel, boolean flushCache) {
+ Rectangle cRect = panel.getClientArea();
+ if (cRect.isEmpty()) {
+ return;
+ }
+
+ Point tSize = text.getControl().computeSize(SWT.DEFAULT,
+ SWT.DEFAULT);
+ tSize.y += textMarginHeight;
+
+ spinner.setBounds(cRect.x, cRect.y, cRect.width, tSize.y);
+
+ Rectangle sRect = spinner.getControl().computeTrim(0, 0, 0, 0);
+ int sWidth = sRect.x + sRect.width
+ - 2 * spinner.getControl().getBorderWidth() + 1;
+
+ if (gtk && sWidth == 0) {
+ sWidth = 67;
+ }
+
+ tSize.x = cRect.width - sWidth;
+
+ text.setBounds(cRect.x, cRect.y + getBorderWidth(), tSize.x,
+ tSize.y);
+ }
+ }
+
+ private static final int FIELD_NONE = -1;
+
+ private static final int DISCARD = 0;
+ private static final int WRAP = 1;
+ private static final int BLOCK = 2;
+
+ private static int convertStyle(int style) {
+ int rstyle = SWT.NONE;
+ if ((style & CDT.DROP_DOWN) != 0) {
+ rstyle |= SWT.DROP_DOWN;
+ }
+ if ((style & CDT.SIMPLE) != 0) {
+ rstyle |= SWT.SIMPLE;
+ }
+ if ((style & CDT.READ_ONLY) != 0) {
+ rstyle |= SWT.READ_ONLY;
+ }
+ if ((style & CDT.BUTTON_LEFT) != 0) {
+ rstyle |= SWT.LEFT;
+ }
+ if ((style & CDT.TEXT_LEAD) != 0) {
+ rstyle |= SWT.LEAD;
+ }
+ if ((style & CDT.BORDER) != 0) {
+ rstyle |= SWT.BORDER;
+ }
+ if (win32) {
+ rstyle |= SWT.DOUBLE_BUFFERED;
+ }
+ return rstyle;
+ }
+
+ VPanel picker;
+
+ VNative spinner;
+ boolean internalFocusShift = false;
+ boolean rightClick = false;
+
+ private Date cancelDate;
+ private Calendar calendar;
+ private Calendar minDate;
+ private Calendar maxDate;
+
+ private DateFormat df;
+ Locale locale;
+
+ TimeZone timezone;
+ Field[] field;
+ int activeField;
+
+ private boolean tabStops = false;
+ // Store these values so that the style can be reset automatically
+ // to update everything if/when the locale is changed
+ int style;
+ String pattern = null;
+
+ int format = -1;
+
+ private CDateTimePainter painter;
+
+ /**
+ * Delegates events to their appropriate handler
+ */
+ Listener textListener = event -> {
+ switch (event.type) {
+ case SWT.FocusIn:
+ rightClick = false;
+ if (internalFocusShift) {
+ if (activeField < 0) {
+ fieldFirst();
+ updateText();
+ }
+ } else {
+ if (VTracker.getLastTraverse() == SWT.TRAVERSE_TAB_PREVIOUS) {
+ fieldLast();
+ } else {
+ fieldFirst();
+ }
+ updateText();
+ }
+ break;
+ case SWT.FocusOut:
+ if (!rightClick && !internalFocusShift) {
+ if (commitEditField()) {
+ updateText();
+ } else {
+ editField = null;
+ }
+ }
+ break;
+ case SWT.KeyDown:
+ handleKey(event);
+ break;
+ case SWT.MouseDown:
+ if (event.button == 1) {
+ fieldFromTextSelection();
+ } else if (event.button == 2) {
+ fieldNext();
+ } else if (event.button == 3) {
+ rightClick = true;
+ }
+ break;
+ case SWT.MouseWheel:
+ Control focusedControl = getDisplay().getFocusControl();
+ if (getTextWidget() != null
+ && getTextWidget().getControl() != focusedControl) {
+ // Do not handle mousewheel events if the widget does not have
+ // focus
+ break;
+ }
+ if (event.count > 0) {
+ fieldAdjust(1);
+ } else {
+ fieldAdjust(-1);
+ }
+ event.doit = false;
+ break;
+ case SWT.MouseUp:
+ if (event.button == 1) {
+ fieldFromTextSelection();
+ }
+ break;
+ case SWT.Traverse:
+ handleTraverse(event);
+ break;
+ case SWT.Verify:
+ verify(event);
+ break;
+ }
+ };
+ private Point textSelectionOffset = new Point(0, 0); // x = selOffset start,
+ // y = selOffset
+ // amount
+ private EditField editField;
+
+ private String[] separator;
+ private int[] calendarFields;
+ private boolean isTime;
+ private boolean isDate;
+ // private boolean isNull = true;
+ private String nullText = null;
+
+ private boolean defaultNullText = true;
+ private boolean singleSelection;
+
+ // private boolean dragSelection;
+ private Date[] selection = new Date[0];
+
+ private boolean scrollable = true;
+
+ CDateTimeBuilder builder;
+
+ VPanel pickerPanel;
+
+ private TimeZone[] allowedTimezones;
+
+ Color buttonHoverBackgroundColor, buttonHoverBorderColor;
+ Color buttonSelectedBackgroundColor, buttonSelectedBorderColor;
+
+ Color pickerForegroundColor, pickerBackgroundColor;
+ Font pickerFont;
+
+ Color pickerActiveDayColor, pickerInactiveDayColor, pickerTodayColor;
+ Color pickerMinutesColor, pickerMinutesBackgroundColor;
+
+ Color okButtonColor, cancelButtonColor, clearButtonForegroundColor;
+ Font clearButtonFont;
+ private VButton okButton, clearButton, cancelButton;
+
+ /**
+ * Constructs a new instance of this class given its parent and a style
+ * value describing its behavior and appearance. The current date and the
+ * system's default locale are used.
+ *
+ * @param parent
+ * a widget which will be the parent of the new instance (cannot
+ * be null)
+ * @param style
+ * the style of widget to construct
+ */
+ public CDateTime(Composite parent, int style) {
+ super(parent, convertStyle(style));
+ init(style);
+ }
+
+ /**
+ * Adds the listener to the collection of listeners who will be notified
+ * when the receiver's selection changes, by sending it one of the messages
+ * defined in the SelectionListener interface.
+ *
+ * widgetSelected is called when the selection (date/time)
+ * changes. widgetDefaultSelected is when ENTER is pressed the
+ * text box.
+ *
+ * The event's data field will contain the newly selected Date object.
+ * The event's detail field will contain which Calendar Field was changed
+ *
+ * @param listener
+ * the listener which should be notified
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_NULL_ARGUMENT - if the listener is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+ public void addSelectionListener(SelectionListener listener) {
+ if (listener != null) {
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Selection, typedListener);
+ addListener(SWT.DefaultSelection, typedListener);
+ }
+ }
+
+ /**
+ * Adds the textListener for the appropriate SWT events to handle
+ * incrementing fields.
+ */
+ protected void addTextListener() {
+ removeTextListener();
+
+ Text control = text.getControl();
+ control.addListener(SWT.FocusIn, textListener);
+ control.addListener(SWT.FocusOut, textListener);
+ control.addListener(SWT.KeyDown, textListener);
+ control.addListener(SWT.MouseDown, textListener);
+ control.addListener(SWT.MouseWheel, textListener);
+ control.addListener(SWT.MouseUp, textListener);
+ control.addListener(SWT.Verify, textListener);
+
+ text.addListener(SWT.Traverse, textListener);
+ }
+
+ /**
+ * If a field is being edited (via keyboard), set the edit value to the
+ * active field of the calendar. Reset the count of the EditField so that a
+ * subsequent key press will overwrite its contents;
+ *
+ * @return true if the commit was successfull (the value was valid for the
+ * field) or there was no commit to be made (editField is null),
+ * false otherwise
+ */
+ private boolean commitEditField() {
+ if (editField != null) {
+ int cf = getCalendarField();
+ int val = editField.getValue();
+ editField.reset();
+ if (cf == Calendar.MONTH) {
+ val--;
+ }
+ return fieldSet(cf, val, DISCARD);
+ }
+ return true;
+ }
+
+ /**
+ * If style is neither SIMPLE or DROP_DOWN, then this method simply returns,
+ * otherwise it creates the picker.
+ */
+ private void createPicker() {
+ if (isSimple()) {
+ pickerPanel = panel;
+ setContent(panel.getComposite());
+ } else if (isDropDown()) {
+ disposePicker();
+
+ Shell shell = getContentShell();
+ int style = (isSimple() ? SWT.NONE : SWT.BORDER)
+ | SWT.DOUBLE_BUFFERED;
+ VCanvas canvas = new VCanvas(shell, style);
+ pickerPanel = canvas.getPanel();
+ pickerPanel.setWidget(canvas);
+ VGridLayout layout = new VGridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.verticalSpacing = 1;
+ pickerPanel.setLayout(layout);
+ setContent(pickerPanel.getComposite());
+
+ canvas.addListener(SWT.KeyDown, event -> {
+ if (SWT.ESC == event.keyCode) {
+ event.doit = false;
+ if (selection.length > 0 && selection[0] != cancelDate) {
+ setSelection(cancelDate);
+ fireSelectionChanged();
+ }
+ setOpen(false);
+ }
+ });
+
+ if (field.length > 1 || isTime) {
+ createPickerToolbar(pickerPanel);
+ }
+ }
+
+ if (pickerBackgroundColor != null) {
+ pickerPanel.setBackground(pickerBackgroundColor);
+ }
+ if (pickerForegroundColor != null) {
+ pickerPanel.setForeground(pickerForegroundColor);
+ }
+ if (pickerFont != null) {
+ pickerPanel.setFont(pickerFont);
+ }
+
+ if (isDate) {
+ DatePicker dp = new DatePicker(this);
+ dp.setScrollable(scrollable);
+ dp.setFields(calendarFields);
+ dp.updateView();
+ picker = dp;
+ } else if (isTime) {
+ if ((style & CDT.CLOCK_DISCRETE) != 0) {
+ DiscreteTimePicker dtp = new DiscreteTimePicker(this);
+ dtp.setFields(calendarFields);
+ dtp.updateView();
+ picker = dtp;
+ } else {
+ AnalogTimePicker atp = new AnalogTimePicker(this);
+ atp.setFields(calendarFields);
+ atp.updateView();
+ picker = atp;
+ }
+ }
+
+ if (isDropDown()) {
+ picker.setLayoutData(
+ new GridData(SWT.FILL, SWT.FILL, false, false));
+ }
+ }
+
+ private void createPickerToolbar(VPanel parent) {
+ VPanel tb = new VPanel(parent, SWT.NONE);
+ VGridLayout layout = new VGridLayout(3, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.horizontalSpacing = 2;
+ tb.setLayout(layout);
+ tb.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
+ tb.setData(CDT.PickerPart, PickerPart.Toolbar);
+
+ okButton = new VButton(tb, SWT.OK | SWT.NO_FOCUS);
+ okButton.setData(CDT.PickerPart, PickerPart.OkButton);
+ okButton.setToolTipText(Resources.getString("accept.text", locale)); //$NON-NLS-1$
+ okButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+ okButton.addListener(SWT.Selection, event -> setOpen(false));
+ okButton.setHoverBackgroundColor(buttonHoverBackgroundColor);
+ okButton.setHoverBorderColor(buttonHoverBorderColor);
+ okButton.setSelectedBackgroundColor(buttonSelectedBackgroundColor);
+ okButton.setSelectedBorderColor(buttonSelectedBorderColor);
+ okButton.setForeground(okButtonColor);
+
+ cancelButton = new VButton(tb, SWT.CANCEL | SWT.NO_FOCUS);
+ cancelButton.setData(CDT.PickerPart, PickerPart.CancelButton);
+ cancelButton.setToolTipText(Resources.getString("cancel.text", locale)); //$NON-NLS-1$
+ cancelButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+ cancelButton.addListener(SWT.Selection, event -> {
+ setSelection(cancelDate);
+ fireSelectionChanged();
+ setOpen(false);
+ });
+ cancelButton.setHoverBackgroundColor(buttonHoverBackgroundColor);
+ cancelButton.setHoverBorderColor(buttonHoverBorderColor);
+ cancelButton.setSelectedBackgroundColor(buttonSelectedBackgroundColor);
+ cancelButton.setSelectedBorderColor(buttonSelectedBorderColor);
+ cancelButton.setForeground(cancelButtonColor);
+
+ clearButton = new VButton(tb, SWT.NO_FOCUS);
+ clearButton.setData(CDT.PickerPart, PickerPart.ClearButton);
+ clearButton.setText(Resources.getString("clear.text", locale)); //$NON-NLS-1$
+ clearButton.setToolTipText(Resources.getString("clear.text", locale)); //$NON-NLS-1$
+ clearButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+ clearButton.addListener(SWT.Selection, event -> {
+ setOpen(false);
+ setSelection(null);
+ fireSelectionChanged();
+ });
+ clearButton.setForeground(clearButtonForegroundColor!=null?clearButtonForegroundColor:parent.getForeground());
+ clearButton.setFont(clearButtonFont!=null?clearButtonFont:parent.getFont());
+ clearButton.setHoverBackgroundColor(buttonHoverBackgroundColor);
+ clearButton.setHoverBorderColor(buttonHoverBorderColor);
+ clearButton.setSelectedBackgroundColor(buttonSelectedBackgroundColor);
+ clearButton.setSelectedBorderColor(buttonSelectedBorderColor);
+
+
+ VLabel sep = new VLabel(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
+ sep.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+ }
+
+ private void disposePicker() {
+ if (content != null) {
+ if (picker != null) {
+ picker.dispose();
+ picker = null;
+ }
+ if (isDropDown()) {
+ Control c = content;
+ setContent(null);
+ c.dispose();
+ if (contentShell != null) {
+ Display.getDefault().asyncExec(() -> {
+ if (contentShell != null
+ && !contentShell.isDisposed()) {
+ contentShell.dispose();
+ contentShell = null;
+ }
+ });
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds the given amount to the x² field, if there is one
+ */
+ void fieldAdjust(int amount) {
+ if (!hasSelection()) {
+ if (DatePicker.isValidDate(calendar, minDate, maxDate)) {
+ setSelection(calendar.getTime());
+ fireSelectionChanged();
+ } else {
+ setOpen(true);
+ }
+ } else {
+ int cf = getCalendarField();
+ if (cf >= 0) {
+ fieldRoll(cf, amount, WRAP);
+ }
+ }
+ }
+
+ void fieldFirst() {
+ // If the user has opted to have the user be able to
+ // change time zones then allow the next field to be the
+ // time zone field
+ if (this.allowedTimezones == null) {
+ if (Calendar.ZONE_OFFSET == getCalendarField(field[0])) {
+ setActiveField(1);
+ } else {
+ setActiveField(0);
+ }
+ } else {
+ // allowed time zones have been set, so let the user edit it
+ setActiveField(0);
+ }
+ }
+
+ /**
+ * Sets the active field from the select of the text box
+ */
+ void fieldFromTextSelection() {
+ if (!hasSelection()) {
+ // setActiveField(FIELD_ALL);
+ fieldNext();
+ } else {
+ Point sel = text.getControl().getSelection();
+ AttributedCharacterIterator aci = df
+ .formatToCharacterIterator(calendar.getTime());
+ if (sel.x > textSelectionOffset.x) {
+ sel.x += textSelectionOffset.y;
+ }
+ aci.setIndex(sel.x);
+ Object[] oa = aci.getAttributes().keySet().toArray();
+ if (oa.length == 0 && sel.x > 0) {
+ sel.x -= 1;
+ aci.setIndex(sel.x);
+ oa = aci.getAttributes().keySet().toArray();
+ }
+ if (oa.length > 0) {
+ for (int i = 0; i < field.length; i++) {
+ if (oa[0].equals(field[i])) {
+ // If the user has opted to have the user be able to
+ // change time zones then allow the next field to be the
+ // time zone field
+ if (this.allowedTimezones == null) {
+ if (Calendar.ZONE_OFFSET != getCalendarField(
+ field[i])) {
+ setActiveField(i);
+ }
+ } else {
+ // allowed time zones have been set, so let the user
+ // edit it
+ setActiveField(i);
+ }
+ break;
+ }
+ }
+ updateText();
+ }
+ }
+ }
+
+ void fieldLast() {
+ // If the user has opted to have the user be able to change
+ // time zones then allow the next field to be the time zone field
+ if (this.allowedTimezones == null) {
+ if (Calendar.ZONE_OFFSET == getCalendarField(
+ field[field.length - 1])) {
+ setActiveField(field.length - 2);
+ } else {
+ setActiveField(field.length - 1);
+ }
+ } else {
+ // allowed time zones have been set, so let the user edit it
+ setActiveField(field.length - 1);
+ }
+ }
+
+ /**
+ * Sets the active field to the next field; wraps if necessary and sets to
+ * last field if there is no current active field
+ */
+ void fieldNext() {
+ fieldNext(false);
+ }
+
+ /**
+ * Sets the active field to the next field; wraps if necessary and sets to
+ * last field if there is no current active field
+ *
+ * @param If
+ * true, the text update will be asynchronous (for changes to
+ * text selection)
+ */
+ void fieldNext(boolean async) {
+ if (activeField >= 0 && activeField < field.length - 1) {
+ // If the user has opted to have the user be able to change
+ // time zones then allow the next field to be the time zone field
+ if (this.allowedTimezones == null) {
+ if (Calendar.ZONE_OFFSET == getCalendarField(
+ field[activeField + 1])) {
+ if (activeField < field.length - 2) {
+ setActiveField(activeField + 2);
+ } else {
+ setActiveField(0);
+ }
+ } else {
+ setActiveField(activeField + 1);
+ }
+ } else {
+ // allowed time zones have been set, so let the user edit it
+ setActiveField(activeField + 1);
+ }
+ } else {
+ // If the user has opted to have the user be able to change
+ // time zones then allow the next field to be the time zone field
+ if (this.allowedTimezones == null) {
+ if (Calendar.ZONE_OFFSET == getCalendarField(field[0])) {
+ setActiveField(1);
+ } else {
+ setActiveField(0);
+ }
+ } else {
+ // allowed time zones have been set, so let the user edit it
+ setActiveField(0);
+ }
+ }
+ updateText(async);
+ }
+
+ /**
+ * Sets the active field to the previous field; wraps if necessary and sets
+ * to first field if there is no current active field
+ */
+ private void fieldPrev() {
+ fieldPrev(false);
+ }
+
+ /**
+ * Sets the active field to the previous field; wraps if necessary and sets
+ * to first field if there is no current active field
+ *
+ * @param If
+ * true, the text update will be asynchronous (for changes to
+ * text selection)
+ */
+ void fieldPrev(boolean async) {
+ if (activeField > 0 && activeField < field.length) {
+ // If the user has opted to have the user be able to change
+ // time zones then allow the next field to be the time zone field
+ if (this.allowedTimezones == null) {
+ if (Calendar.ZONE_OFFSET == getCalendarField(
+ field[activeField - 1])) {
+ if (activeField > 1) {
+ setActiveField(activeField - 2);
+ } else {
+ setActiveField(field.length - 1);
+ }
+ } else {
+ setActiveField(activeField - 1);
+ }
+ } else {
+ // allowed time zones have been set, so let the user edit it
+ setActiveField(activeField - 1);
+ }
+ } else {
+ // If the user has opted to have the user be able to change
+ // time zones then allow the next field to be the time zone field
+ if (this.allowedTimezones == null) {
+
+ if (Calendar.ZONE_OFFSET == getCalendarField(
+ field[field.length - 1])) {
+ setActiveField(field.length - 2);
+ } else {
+ setActiveField(field.length - 1);
+ }
+ } else {
+ // allowed time zones have been set, so let the user edit it
+ setActiveField(field.length - 1);
+ }
+ }
+ updateText(async);
+ }
+
+ private boolean fieldRoll(final int calendarField, final int rollAmount,
+ final int style) {
+ if (!getEditable()) {
+ return false;
+ }
+
+ long backup = calendar.getTimeInMillis();
+
+ if (calendarField == Calendar.ZONE_OFFSET
+ && this.allowedTimezones != null) {
+ boolean timeZoneSet = false;
+ for (int idx = 0; idx < this.allowedTimezones.length; idx++) {
+ TimeZone activeTimeZone = this.getTimeZone();
+ if (activeTimeZone.getID() == this.allowedTimezones[idx]
+ .getID()) {
+ if (rollAmount < 0) {
+ if (idx == 0) {
+ this.setTimeZone(
+ this.allowedTimezones[this.allowedTimezones.length
+ - 1]);
+ } else {
+ this.setTimeZone(this.allowedTimezones[idx - 1]);
+ }
+ } else if (rollAmount > 0) {
+ if (idx == this.allowedTimezones.length - 1) {
+ this.setTimeZone(this.allowedTimezones[0]);
+ } else {
+ this.setTimeZone(this.allowedTimezones[idx + 1]);
+ }
+ }
+ timeZoneSet = true;
+ break;
+ }
+ }
+ if (!timeZoneSet) {
+ this.setTimeZone(this.allowedTimezones[0]);
+ }
+ } else {
+ if ((this.style & CDT.ADD_ON_ROLL) != 0) {
+ calendar.add(calendarField, rollAmount);
+ } else {
+ if (calendarField == Calendar.YEAR
+ && calendar.get(Calendar.YEAR) == 1 && rollAmount < 0) {
+ return false;
+ }
+ calendar.roll(calendarField, rollAmount);
+ }
+ }
+
+ if (!DatePicker.isValidDate(calendar, minDate, maxDate)) {
+ calendar.setTimeInMillis(backup);
+ return false;
+ }
+ if (selection.length > 0) {
+ selection[0] = calendar.getTime();
+ }
+ updateText();
+ updatePicker();
+ fireSelectionChanged(calendarField);
+
+ return true;
+ }
+
+ /**
+ * Sets the given calendar field to the given value.
+ * NOTE: This is NOT the active field but a field in the "calendar"
+ * variable.
+ *
+ * @param calendarField
+ * the field of calendar to set
+ * @param value
+ * the value to set it to
+ * @param style
+ * the of set to perform; if the value is valid for the given
+ * calendarField then this has no affect, otherwise it will take
+ * an action according to this style int:
+ *
+ *
DISCARD: the value will be discarded and the method
+ * returns without performing and action
+ *
WRAP: if value is higher than its maximum it will be set
+ * to its minimum, and visa versa
+ *
BLOCK: if value is higher than its maximum it will be set
+ * to its maximum, and visa versa
+ *
+ * @return true if the field was set, false otherwise (as is possible with a
+ * DISCARD style)
+ */
+ private boolean fieldSet(int calendarField, int value, int style) {
+ if (!getEditable()) {
+ return false;
+ }
+ if (calendarField >= 0) {
+ if (value > calendar.getActualMaximum(calendarField)) {
+ if (style == DISCARD) {
+ return false;
+ } else if (style == WRAP) {
+ value = calendar.getActualMinimum(calendarField);
+ } else if (style == BLOCK) {
+ value = calendar.getActualMaximum(calendarField);
+ }
+ } else if (value < calendar.getActualMinimum(calendarField)) {
+ if (style == DISCARD) {
+ return false;
+ } else if (style == WRAP) {
+ value = calendar.getActualMaximum(calendarField);
+ } else if (style == BLOCK) {
+ value = calendar.getActualMinimum(calendarField);
+ }
+ }
+
+ Calendar tmp = (Calendar) calendar.clone();
+ tmp.set(calendarField, value);
+ tmp.getTime(); // call to set the Fields in the Calendar
+
+ if (!DatePicker.isValidDate(tmp, getMinDate(), getMaxDate())) {
+ return false;
+ }
+
+ calendar.set(calendarField, value);
+ if (selection.length > 0) {
+ selection[0] = calendar.getTime();
+ }
+ updateText();
+ updatePicker();
+ fireSelectionChanged(calendarField);
+ }
+ return true;
+ }
+
+ /**
+ *
+ * Notifies listeners that the selection for this CDateTime has changed
+ *
+ *
+ * This will fire both a regular selection event, and a default selection
+ * event.
+ *
+ *
+ * The data field is populated by {@link #getSelectedDates()}.
+ *
+ * Notifies listeners that a field of the selected date for this CDateTime
+ * has changed
+ *
+ *
+ * Note that this is only valid when {@link #singleSelection} is true, and
+ * will only fire a regular selection event (not a default selection event)
+ *
+ *
+ * The data field is populated by {@link #getSelection()} and the detail
+ * field holds the field which was changed.
+ *
+ *
+ * @param field
+ * the Calendar Field which caused the change, or -1 if
+ * setTime was called (thus setting all Calendar
+ * Fields)
+ */
+ void fireSelectionChanged(int field) {
+ Event event = new Event();
+ event.data = getSelection();
+ event.detail = field;
+ if (this.field.length == 1) {
+ if (isOpen()) {
+ setOpen(false);
+ }
+ notifyListeners(SWT.Selection, event);
+ notifyListeners(SWT.DefaultSelection, event);
+ } else {
+ notifyListeners(SWT.Selection, event);
+ }
+ }
+
+ VButton getButtonWidget() {
+ return button;
+ }
+
+ /**
+ * Gets the calendar field corresponding to the active field, if there is
+ * one.
+ *
+ * @return an int representing the calendar field, -1 if there isn't one.
+ */
+ int getCalendarField() {
+ return hasField(activeField) ? getCalendarField(field[activeField])
+ : -1;
+ }
+
+ int getCalendarField(Field field) {
+ int cf = field.getCalendarField();
+ if (cf < 0) {
+ if (field.toString().indexOf("hour 1") > -1) { //$NON-NLS-1$
+ cf = Calendar.HOUR;
+ } else if (field.toString().contains("zone")) { //$NON-NLS-1$
+ cf = Calendar.ZONE_OFFSET;
+ } else if (field.toString().contains("hour of day 1")) { //$NON-NLS-1$
+ cf = Calendar.HOUR_OF_DAY;
+ }
+ }
+ return cf;
+ }
+
+ Calendar getCalendarInstance() {
+ return getCalendarInstance(calendar.getTimeInMillis());
+ }
+
+ /**
+ *
+ * WARNING: Experimental API - this method may be removed in future
+ * versions
+ *
+ * Get a new instance of Calendar that is initialized with the timezone and
+ * locale of this CDateTime, and set to the given date.
+ *
+ * @param date
+ * the date that the Calendar will be set to, or null for the
+ * current system time
+ * @return a new instance of Calendar
+ */
+ public Calendar getCalendarInstance(Date date) {
+ if (date == null) {
+ return getCalendarInstance(System.currentTimeMillis());
+ } else {
+ return getCalendarInstance(date.getTime());
+ }
+ }
+
+ /**
+ *
+ * WARNING: Experimental API - this method may be removed in future
+ * versions
+ *
+ * Get a new instance of Calendar that is initialized with the timezone and
+ * locale of this CDateTime, and set to the given date.
+ *
+ * @param date
+ * the date, in millis, that the Calendar will be set to
+ * @return a new instance of Calendar
+ */
+ public Calendar getCalendarInstance(long date) {
+ Calendar cal = Calendar.getInstance(timezone, locale);
+ cal.setTimeInMillis(date);
+ return cal;
+ }
+
+ Date getCalendarTime() {
+ return calendar.getTime();
+ }
+
+ long getCalendarTimeInMillis() {
+ return calendar.getTimeInMillis();
+ }
+
+ @Override
+ public boolean getEditable() {
+ return !panel.hasStyle(SWT.READ_ONLY);
+ }
+
+ /**
+ * The locale currently in use by this CDateTime.
+ *
+ * @return the locale
+ * @see #setLocale(Locale)
+ */
+ public Locale getLocale() {
+ return locale;
+ }
+
+ /**
+ * Get the text which will be shown when the selection is set to null. Note
+ * that this will be equal to the default null text for the given locale
+ * unless the null text has been explicitly set using
+ * {@link #setNullText(String)}
+ *
+ * @return the text shown when the selection is null
+ * @see #setNullText(String)
+ */
+ public String getNullText() {
+ if (nullText == null) {
+ if (isDate) {
+ return Resources.getString("null_text.date", locale); //$NON-NLS-1$
+ } else {
+ return Resources.getString("null_text.time", locale); //$NON-NLS-1$
+ }
+ }
+ return nullText;
+ }
+
+ CDateTimePainter getPainter() {
+ if (painter == null) {
+ setPainter(new CDateTimePainter());
+ }
+ return painter;
+ }
+
+ /**
+ * Get the pattern of this CDateTime as used to set its format. If the
+ * format was NOT set using setFormat(String) this will return
+ * null.
+ *
+ * @return the pattern, null if there isn't one
+ * @see SimpleDateFormat
+ * @see #setFormat(int)
+ * @see #setPattern(String)
+ */
+ public String getPattern() {
+ return pattern;
+ }
+
+ /**
+ * Get the current selection of this CDateTime widget, or null if there is
+ * no selection.
+ *
+ * @return the current selection
+ */
+ public Date getSelection() {
+ return hasSelection() ? selection[0] : null;
+ }
+
+ @Override
+ public int getStyle() {
+ return style;
+ }
+
+ @Override
+ public String getText() {
+ return checkText() ? text.getText() : null;
+ }
+
+ VNative getTextWidget() {
+ return text;
+ }
+
+ /**
+ * The timezone currently in use by this CDateTime.
+ *
+ * @return the timezone
+ * @see #setTimeZone(String)
+ * @see #setTimeZone(TimeZone)
+ */
+ public TimeZone getTimeZone() {
+ return timezone;
+ }
+
+ /**
+ * The Key event handler
+ *
+ * @param event
+ * the event
+ */
+ void handleKey(Event event) {
+ if (event.stateMask != 0 && event.stateMask != SWT.SHIFT) {
+ return;
+ }
+ if ('\r' == event.keyCode || SWT.KEYPAD_CR == event.keyCode) {
+ fieldNext();
+ fireSelectionChanged(true);
+ } else if (SWT.BS == event.keyCode || SWT.DEL == event.keyCode) {
+ event.doit = false;
+ setSelection((Date) null);
+ fireSelectionChanged();
+ } else if (!hasField(activeField) && !hasSelection()) {
+ event.doit = false;
+ } else {
+ switch (event.keyCode) {
+ case '-':
+ case SWT.KEYPAD_SUBTRACT:
+ fieldAdjust(-1);
+ break;
+ case '=':
+ case '+':
+ case SWT.KEYPAD_ADD:
+ fieldAdjust(1);
+ break;
+ case SWT.BS:
+ if (editField != null) {
+ editField.removeLastCharacter();
+ }
+ break;
+ case SWT.CR:
+ fieldNext();
+ fireSelectionChanged();
+ break;
+ case SWT.ARROW_DOWN:
+ fieldAdjust(-1);
+ updateText(true);
+ break;
+ case SWT.ARROW_UP:
+ fieldAdjust(1);
+ updateText(true);
+ break;
+ case SWT.ARROW_LEFT:
+ fieldPrev(true);
+ break;
+ case SWT.ARROW_RIGHT:
+ fieldNext(true);
+ break;
+ case SWT.ESC:
+ if (contentShell != null) {
+ event.doit = false;
+ if (selection.length > 0 && selection[0] != cancelDate) {
+ setSelection(cancelDate);
+ fireSelectionChanged();
+ }
+ setOpen(false);
+ }
+ break;
+ default:
+ if (hasField(activeField) && activeField + 1 < separator.length
+ && String.valueOf(event.character)
+ .equals(separator[activeField + 1])) {
+ fieldNext();
+ } else if (!hasSelection()
+ && String.valueOf(event.character).matches("[0-9]")) { //$NON-NLS-1$
+ fieldAdjust(0);
+ fieldFirst();
+ }
+ }
+ }
+ }
+
+ /**
+ * The Travers event handler. Note that ARROW_UP and ARROW_DOWN are handled
+ * in the handleKey method.
+ *
+ * @param event
+ * the event
+ */
+ void handleTraverse(Event event) {
+ boolean allowTimeZoneEdit = this.allowedTimezones != null;
+
+ switch (event.detail) {
+ case SWT.TRAVERSE_ARROW_NEXT:
+ if (event.keyCode == SWT.ARROW_RIGHT) {
+ fieldNext();
+ } else if (event.keyCode == SWT.ARROW_DOWN) {
+ fieldAdjust(-1);
+ }
+ break;
+ case SWT.TRAVERSE_ARROW_PREVIOUS:
+ if (event.keyCode == SWT.ARROW_LEFT) {
+ fieldPrev();
+ } else if (event.keyCode == SWT.ARROW_UP) {
+ fieldAdjust(1);
+ }
+ break;
+ case SWT.CR:
+ fieldNext();
+ fireSelectionChanged();
+ break;
+ case SWT.TRAVERSE_TAB_NEXT:
+ if (tabStops && hasSelection()) {
+ // if we are at the last field, allow the tab out of the control
+ // the last field is also considered to be the 2nd to last if
+ // the last is a time zone
+ // we now check if the control allows time zone editing
+ if (activeField == field.length - 1
+ || activeField == field.length - 2
+ && Calendar.ZONE_OFFSET == getCalendarField(
+ field[field.length - 1])
+ && !allowTimeZoneEdit) {
+ event.doit = true;
+ } else {
+ event.doit = false;
+ if (activeField < 0) {
+ fieldPrev();
+ } else {
+ fieldNext();
+ }
+ }
+ }
+ break;
+ case SWT.TRAVERSE_TAB_PREVIOUS:
+ if (tabStops && hasSelection()) {
+ // if we are at the 1st field, allow the tab out of the control
+ // the 1st field is also considered to the the 2nd if the 1st
+ // is a time zone
+ if (activeField == 0 || activeField == 1
+ && Calendar.ZONE_OFFSET == getCalendarField(field[0])
+ && !allowTimeZoneEdit) {
+ event.doit = true;
+ } else {
+ event.doit = false;
+ if (activeField < 0) {
+ fieldNext();
+ } else {
+ fieldPrev();
+ }
+ }
+ }
+ break;
+ default:
+ }
+ }
+
+ /**
+ * Determines if the given field number is backed by a real field.
+ *
+ * @param field
+ * the field number to check
+ * @return true if the given field number corresponds to a field in the
+ * field array
+ */
+ private boolean hasField(int field) {
+ return field >= 0 && field <= this.field.length;
+ }
+
+ /**
+ * Return true if this CDateTime has one or more dates selected;
+ *
+ * @return true if a date is selected, false otherwise
+ */
+ public boolean hasSelection() {
+ return selection.length > 0;
+ }
+
+ private void init(int style) {
+ this.style = style;
+ locale = Locale.getDefault();
+ try {
+ timezone = TimeZone.getDefault();
+ } catch (Exception e) {
+ timezone = TimeZone.getTimeZone("GMT"); //$NON-NLS-1$
+ }
+ calendar = Calendar.getInstance(this.timezone, this.locale);
+ calendar.setTime(new Date());
+ tabStops = (style & CDT.TAB_FIELDS) != 0;
+ singleSelection = (style & CDT.SIMPLE) == 0 || (style & CDT.MULTI) == 0;
+
+ setFormat(style);
+
+ if (isSimple()) {
+ return;
+ }
+ if (isDropDown()) {
+ if ((style & CDT.BUTTON_AUTO) != 0) {
+ setButtonVisibility(BaseCombo.BUTTON_AUTO);
+ } else {
+ setButtonVisibility(BaseCombo.BUTTON_ALWAYS);
+ }
+ } else {
+ setButtonVisibility(BaseCombo.BUTTON_NEVER);
+ if ((style & CDT.SPINNER) != 0) {
+ int sStyle = SWT.VERTICAL;
+ if (gtk && (style & CDT.BORDER) != 0) {
+ sStyle |= SWT.BORDER;
+ }
+ spinner = VNative.create(Spinner.class, panel, sStyle);
+ if (win32) {
+ spinner.setBackground(text.getControl().getBackground());
+ }
+ spinner.getControl().setMinimum(0);
+ spinner.getControl().setMaximum(50);
+ spinner.getControl().setDigits(1);
+ spinner.getControl().setIncrement(1);
+ spinner.getControl().setPageIncrement(1);
+ spinner.getControl().setSelection(25);
+ spinner.getControl().addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusGained(FocusEvent e) {
+ internalFocusShift = true;
+ setFocus();
+ internalFocusShift = false;
+ }
+ });
+ spinner.getControl().addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseDown(MouseEvent e) {
+ if (e.button == 2) {
+ fieldNext();
+ }
+ }
+ });
+ spinner.getControl()
+ .addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (VTracker.getMouseDownButton() != 2) {
+ if (spinner.getControl()
+ .getSelection() > 25) {
+ fieldAdjust(1);
+ } else {
+ fieldAdjust(-1);
+ }
+ spinner.getControl().setSelection(25);
+ }
+ }
+ });
+ panel.setLayout(new SpinnerLayout());
+ }
+ }
+
+ updateText();
+ activeField = -5;
+ setActiveField(FIELD_NONE);
+
+ if (checkText()) {
+ addTextListener();
+ }
+ }
+
+ boolean isSelected(Date date) {
+ for (Date d : selection) {
+ if (d.equals(date)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ boolean isSingleSelection() {
+ return singleSelection;
+ }
+
+ /**
+ * Determine whether the provided field is the most precise field.
+ * According to the used pattern, e.g.
+ *
+ *
dd.mm.yyyy
+ *
MMMM yyyy
+ *
yyyy
+ *
+ * the date picker provides the panels for selecting a day, month or year
+ * respectively. The panel should close itself and set the selection in the
+ * CDateTime field when the user selects the most precise field. The
+ * constants from the {@link Calendar} class may be used to determine the
+ * most precise field:
+ *
+ *
{@link Calendar#YEAR} -> 1
+ *
{@link Calendar#MONTH} -> 2
+ *
{@link Calendar#DATE} -> 5
+ *
+ * e.g. the highest constant is the closing field.
+ *
+ * @param calendarField
+ * The calendar field identifying a pattern field
+ * @return true if the highest pattern field
+ */
+ boolean isClosingField(int calendarField) {
+ // find the "highest" constant in the pattern fields
+ int i = Integer.MIN_VALUE;
+ for (Field f : field) {
+ i = Math.max(i, f.getCalendarField());
+ }
+ // compare the highest constant with the field
+ if (i == calendarField) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected void postClose(Shell popup) {
+ disposePicker();
+ }
+
+ /**
+ * Removes the listener from the collection of listeners who will be
+ * notified when the receiver's selection changes.
+ *
+ * @param listener
+ * the listener which should no longer be notified
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_NULL_ARGUMENT - if the listener is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+ public void removeSelectionListener(SelectionListener listener) {
+ if (listener != null) {
+ TypedListener l = new TypedListener(listener);
+ removeListener(SWT.Selection, l);
+ removeListener(SWT.DefaultSelection, l);
+ }
+ }
+
+ /**
+ * Removes the textListener for the appropriate SWT events to handle
+ * incrementing fields.
+ */
+ protected void removeTextListener() {
+ Text control = text.getControl();
+ control.removeListener(SWT.KeyDown, textListener);
+ control.removeListener(SWT.MouseDown, textListener);
+ control.removeListener(SWT.MouseWheel, textListener);
+ control.removeListener(SWT.MouseUp, textListener);
+ control.removeListener(SWT.Verify, textListener);
+ text.removeListener(SWT.Traverse, textListener);
+ }
+
+ /**
+ * Sets the active field, which may or may not be a real field (it may also
+ * be FIELD_NONE)
+ *
+ * @param field
+ * the field to be set active
+ * @see CDateTime#hasField(int)
+ */
+ private void setActiveField(int field) {
+ if (activeField != field) {
+ commitEditField();
+ editField = null;
+ activeField = field;
+ }
+ }
+
+ /**
+ *
+ * WARNING: Experimental API - this method may be removed in future
+ * versions
+ *
+ * Sets the builder that this CDateTime widget will use to build its
+ * graphical selector to the given builder, or to a default builder if the
+ * given builder is null.
+ *
+ * @param builder
+ * the builder to use, or null to use a default builder
+ */
+ public void setBuilder(CDateTimeBuilder builder) {
+ this.builder = builder;
+ this.minDate = builder.getMinDate();
+ this.maxDate = builder.getMaxDate();
+
+ if (picker != null) {
+ disposePicker();
+ createPicker();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.nebula.cwt.base.BaseCombo#setButtonImage(org.eclipse.swt.
+ * graphics.Image)
+ */
+ @Override
+ public void setButtonImage(Image image) {
+ super.setButtonImage(image);
+ }
+
+ @Override
+ protected boolean setContentFocus() {
+ if (checkPicker()) {
+ internalFocusShift = true;
+ boolean result = picker.setFocus();
+ internalFocusShift = false;
+ return result;
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.nebula.cwt.base.BaseCombo#setEditable(boolean)
+ */
+ @Override
+ public void setEditable(boolean editable) {
+ super.setEditable(editable);
+ if (checkPicker()) {
+ if (picker instanceof DatePicker) {
+ ((DatePicker) picker).setEditable(editable);
+ } else {
+ picker.setActivatable(editable);
+ }
+ }
+ }
+
+ private boolean checkPicker() {
+ return picker != null && !picker.isDisposed();
+ }
+
+ /**
+ * Set the date and time format of this CDateTime uses style constants which
+ * correspond to the various forms of DateFormat.getXxxInstance(int).
+ *
+ * Styles are bitwise OR'ed together, but only one "DATE" and one "TIME" may
+ * be set at a time.
+ *
+ * Examples:
+ * setFormat(CDT.DATE_LONG);
+ * setFormat(CDT.DATE_SHORT | CDT.TIME_MEDIUM);
+ *
+ * @param format
+ * the bitwise OR'ed Date and Time format to be set
+ * @throws IllegalArgumentException
+ * @see #getPattern()
+ * @see #setPattern(String)
+ */
+ public void setFormat(int format) throws IllegalArgumentException {
+ int dateStyle = (format & CDT.DATE_SHORT) != 0 ? DateFormat.SHORT
+ : (format & CDT.DATE_MEDIUM) != 0 ? DateFormat.MEDIUM
+ : (format & CDT.DATE_LONG) != 0 ? DateFormat.LONG : -1;
+ int timeStyle = (format & CDT.TIME_SHORT) != 0 ? DateFormat.SHORT
+ : (format & CDT.TIME_MEDIUM) != 0 ? DateFormat.MEDIUM : -1;
+ String str = null;
+ if (dateStyle != -1 && timeStyle != -1) {
+ str = ((SimpleDateFormat) DateFormat.getDateTimeInstance(dateStyle,
+ timeStyle, locale)).toPattern();
+ } else if (dateStyle != -1) {
+ str = ((SimpleDateFormat) DateFormat.getDateInstance(dateStyle,
+ locale)).toPattern();
+ } else if (timeStyle != -1) {
+ str = ((SimpleDateFormat) DateFormat.getTimeInstance(timeStyle,
+ locale)).toPattern();
+ } else if (pattern == null) { // first call, so set to default
+ format = CDT.DATE_SHORT;
+ str = ((SimpleDateFormat) DateFormat
+ .getDateInstance(DateFormat.SHORT, locale)).toPattern();
+ }
+ if (str != null) {
+ this.format = format;
+ setPattern(str);
+ }
+ }
+
+ /**
+ * Sets the Locale to be used by this CDateTime and causes all affected
+ * attributes to be updated
+ * If the provided locale is the same as the current locale then this method
+ * simply returns. If the provided Locale is null then this CDateTime will
+ * use the system's default locale.
+ * If this CDateTime is of style DROP_DOWN then
+ * the associated CDateTime will be set to the same locale.
+ *
+ * @param locale
+ * the Locale, or null to use the system's default
+ * @see #getLocale()
+ */
+ public void setLocale(Locale locale) {
+ if (locale == null) {
+ locale = Locale.getDefault();
+ }
+ if (!this.locale.equals(locale)) {
+ this.locale = locale;
+ if (format > 0) {
+ setFormat(format);
+ } else {
+ setPattern(pattern);
+ }
+ updateNullText();
+ }
+ }
+
+ @Override
+ protected void setModifyEventProperties(Event e) {
+ e.data = calendar.getTime();
+ }
+
+ /**
+ * Set the text to be shown when the selection is null. Passing null into
+ * this method will cause the CDateTime widget to use a default null text
+ * for the given locale.
+ *
+ * @param text
+ */
+ public void setNullText(String text) {
+ defaultNullText = false;
+ nullText = text;
+ updateText();
+ }
+
+ @Override
+ public void setOpen(boolean open) {
+ setOpen(open, null);
+ }
+
+ @Override
+ public void setOpen(boolean open, Runnable callback) {
+ if (open) {
+ cancelDate = getSelection();
+ createPicker();
+ } else {
+ cancelDate = null;
+ }
+ super.setOpen(open, callback);
+ if (hasSelection()) {
+ show(getSelection());
+ }
+ }
+
+ /**
+ *
+ * WARNING: Experimental API - this method may be removed in future
+ * versions
+ *
+ * Sets the painter that this CDateTime widget will use to paint its
+ * graphical selector to the given painter, or to a default painter if the
+ * given painter is null.
+ *
+ * @param painter
+ * the painter to use, or null to use a default painter
+ */
+ public void setPainter(CDateTimePainter painter) {
+ if (painter != null) {
+ painter.setCDateTime(this);
+ }
+ this.painter = painter;
+ }
+
+ /**
+ * Set the style of this CDateTime to work with dates and / or times as
+ * determined by the given pattern. This will set the fields shown in the
+ * text box and, if DROP_DOWN style is set, the fields of the
+ * drop down component.
+ * This method is backed by an implementation of SimpleDateFormat, and as
+ * such, any string pattern which is valid for SimpleDateFormat may be used.
+ * Examples (US Locale):
+ * setPattern("MM/dd/yyyy h:mm a");
+ * setPattern("'Meeting @' h:mm a 'on' EEEE, MMM dd,
+ * yyyy");
+ *
+ * @param pattern
+ * the pattern to use, if it is invalid, the original is restored
+ * @throws IllegalArgumentException
+ * @see SimpleDateFormat
+ * @see #getPattern()
+ * @see #setFormat(int)
+ */
+ public void setPattern(String pattern) throws IllegalArgumentException {
+ this.allowedTimezones = null;
+ if (isOpen()) {
+ setOpen(false);
+ }
+ df = new SimpleDateFormat(pattern, locale);
+ df.setTimeZone(timezone);
+ if (updateFields()) {
+ this.pattern = pattern;
+ this.format = -1;
+ boolean wasDate = isDate;
+ boolean wasTime = isTime;
+ isDate = isTime = false;
+ calendarFields = new int[field.length];
+ for (int i = 0; i < calendarFields.length; i++) {
+ calendarFields[i] = getCalendarField(field[i]);
+ switch (calendarFields[i]) {
+ case Calendar.AM_PM:
+ case Calendar.HOUR:
+ case Calendar.HOUR_OF_DAY:
+ case Calendar.MILLISECOND:
+ case Calendar.MINUTE:
+ case Calendar.SECOND:
+ case Calendar.ZONE_OFFSET:
+ isTime = true;
+ break;
+ case Calendar.DAY_OF_MONTH:
+ case Calendar.DAY_OF_WEEK:
+ case Calendar.DAY_OF_WEEK_IN_MONTH:
+ case Calendar.DAY_OF_YEAR:
+ case Calendar.ERA:
+ case Calendar.MONTH:
+ case Calendar.WEEK_OF_MONTH:
+ case Calendar.WEEK_OF_YEAR:
+ case Calendar.YEAR:
+ isDate = true;
+ break;
+ default:
+ break;
+ }
+ }
+ if (checkButton() && (isDate != wasDate || isTime != wasTime)) {
+ if (defaultButtonImage) {
+ if (isDate && isTime) {
+ doSetButtonImage(Resources.getIconCalendarClock());
+ } else if (isDate) {
+ doSetButtonImage(Resources.getIconCalendar());
+ } else {
+ doSetButtonImage(Resources.getIconClock());
+ }
+ }
+ updateNullText();
+ }
+ if (checkText()) {
+ updateText();
+ }
+ if (isSimple()) {
+ disposePicker();
+ createPicker();
+ }
+ } else {
+ throw new IllegalArgumentException(
+ "Problem setting pattern: \"" + pattern + "\""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ void setScrollable(boolean scrollable) {
+ this.scrollable = scrollable;
+ if (isSimple() && !scrollable) {
+ if (picker != null && picker instanceof DatePicker) {
+ updatePicker();
+ }
+ }
+ }
+
+ /**
+ * Set the selection for this CDateTime to that of the provided
+ * Date object.
+ *
+ * @param selection
+ * the new selection, or null to clear the selection
+ */
+ public void setSelection(Date selection) {
+ if (getEditable()) {
+ if (selection == null) {
+ this.selection = new Date[0];
+ } else if (DatePicker.isValidDate(getCalendarInstance(selection),
+ minDate, maxDate)) {
+ this.selection = new Date[] { selection };
+ }
+ }
+ if (singleSelection && this.selection.length > 0) {
+ show(selection);
+ } else {
+ updateText();
+ updatePicker();
+ }
+ }
+
+ /**
+ * Sets the timezone to the timezone specified by the given zoneID, or to
+ * the system default if the given zoneID is null. If the give zoneID cannot
+ * be understood, then the timezone will be set to GMT.
+ *
+ * @param zoneID
+ * the id of the timezone to use, or null to use the system
+ * default
+ * @see #setTimeZone(TimeZone)
+ */
+ public void setTimeZone(String zoneID) {
+ if (zoneID == null) {
+ setTimeZone((TimeZone) null);
+ } else {
+ setTimeZone(TimeZone.getTimeZone(zoneID));
+ }
+ }
+
+ /**
+ * Sets the timezone to the given timezone, or to the system's default
+ * timezone if the given timezone is null.
+ *
+ * @param zone
+ * the timezone to use, or null to use the system default
+ * @see #setTimeZone(String)
+ */
+ public void setTimeZone(TimeZone zone) {
+ if (zone == null) {
+ timezone = TimeZone.getDefault();
+ }
+ if (!this.timezone.equals(zone)) {
+ this.timezone = zone;
+ calendar.setTimeZone(this.timezone);
+ df.setTimeZone(this.timezone);
+ updateText();
+ }
+ }
+
+ /**
+ * Shows the given date if it can be shown by the selector. In other words,
+ * for graphical selectors such as a calendar, the visible range of time is
+ * moved so that the given date is visible.
+ *
+ * @param date
+ * the date to show
+ */
+ public void show(Date date) {
+ if (date == null) {
+ calendar.setTime(new Date());
+ } else {
+ calendar.setTime(date);
+ }
+ updateText();
+ updatePicker();
+ }
+
+ /**
+ * Show the selection if it can be shown by the selector. Has no affect if
+ * there is no selection.
+ *
+ * @see #show(Date)
+ */
+ public void showSelection() {
+ if (selection.length > 0) {
+ show(selection[0]);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + " {" + getCalendarTime() + "}"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * inspects all of the calendar fields in the field array to
+ * determine what style is appropriate and then sets that style to the
+ * picker using the setPickerStyle method.
+ */
+ private boolean updateFields() {
+ Field[] bak = new Field[field == null ? 0 : field.length];
+ if (bak.length > 0) {
+ System.arraycopy(field, 0, bak, 0, field.length);
+ }
+
+ AttributedCharacterIterator aci = df
+ .formatToCharacterIterator(calendar.getTime());
+ field = new Field[aci.getAllAttributeKeys().size()];
+ separator = new String[field.length + 1]; // there can be a separator
+ // before and after
+ int i = 0;
+ Object last = null;
+ for (char c = aci.first(); c != CharacterIterator.DONE; c = aci
+ .next()) {
+ Object[] oa = aci.getAttributes().keySet().toArray();
+ if (oa.length > 0) {
+ if (oa[0] != last && i < field.length) {
+ if (getCalendarField((Field) oa[0]) < 0) {
+ if (bak.length > 0) {
+ field = new Field[bak.length];
+ System.arraycopy(bak, 0, field, 0, bak.length);
+ }
+ return false;
+ } else {
+ field[i] = (Field) oa[0];
+ last = oa[0];
+ }
+ i++;
+ }
+ } else {
+ if (separator[i] == null) {
+ separator[i] = String.valueOf(c);
+ }
+ }
+ }
+
+ df.setLenient(false);
+ setActiveField(FIELD_NONE);
+ return true;
+ }
+
+ private void updateNullText() {
+ if (defaultNullText) {
+ if (isDate) {
+ nullText = Resources.getString("null_text.date", locale); //$NON-NLS-1$
+ } else {
+ nullText = Resources.getString("null_text.time", locale); //$NON-NLS-1$
+ }
+ if (!hasSelection()) {
+ updateText();
+ }
+ }
+ }
+
+ /**
+ * tell the picker to update its view of the selection and reference time
+ */
+ private void updatePicker() {
+ if (picker != null) {
+ if (picker instanceof DatePicker) {
+ ((DatePicker) picker).updateView();
+ } else if (picker instanceof AnalogTimePicker) {
+ ((AnalogTimePicker) picker).updateView();
+ } else if (picker instanceof DiscreteTimePicker) {
+ ((DiscreteTimePicker) picker).updateView();
+ }
+ }
+ }
+
+ /**
+ * This is the only way that text is set to the text box.
+ * The selection of the text in the text box is also set here (the active
+ * field is selected) as well as if a field is being edited, it's "edit
+ * text" is inserted for display. The getSelection property of
+ * CDateTime remains unchanged.
+ */
+ private void updateText() {
+ updateText(false);
+ }
+
+ /**
+ * This is the only way that text is set to the text box.
+ * The selection of the text in the text box is also set here (the active
+ * field is selected) as well as if a field is being edited, it's "edit
+ * text" is inserted for display. The getSelection property of
+ * CDateTime remains unchanged.
+ *
+ * @param async
+ * If true, this operation will be performed asynchronously (for
+ * changes to text selection)
+ */
+ private void updateText(boolean async) {
+ // TODO: save previous state and only update on changes...?
+
+ String buffer = hasSelection() ? df.format(getSelection())
+ : getNullText();
+
+ int s0 = 0;
+ int s1 = 0;
+
+ if (!hasSelection()) {
+ s0 = 0;
+ s1 = buffer.length();
+ } else if (activeField >= 0 && activeField < field.length) {
+ AttributedCharacterIterator aci = df
+ .formatToCharacterIterator(getSelection());
+ for (char c = aci.first(); c != CharacterIterator.DONE; c = aci
+ .next()) {
+ if (aci.getAttribute(field[activeField]) != null) {
+ s0 = aci.getRunStart();
+ s1 = aci.getRunLimit();
+ if (editField != null) {
+ String str = editField.toString();
+ buffer = buffer.substring(0, s0) + str
+ + buffer.substring(s1);
+ int oldS1 = s1;
+ s1 = s0 + str.length();
+ textSelectionOffset.x = Math.min(oldS1, s1);
+ textSelectionOffset.y = oldS1 - s0 - str.length();
+ } else {
+ textSelectionOffset.x = buffer.length() + 1;
+ textSelectionOffset.y = 0;
+ }
+ break;
+ }
+ }
+ } else {
+ setActiveField(FIELD_NONE);
+ }
+
+ final String string = buffer;
+ final int selStart = s0;
+ final int selEnd = s1;
+
+ Runnable runnable = () -> {
+ if (text != null && !text.isDisposed()) {
+ if (!string.equals(text.getText())) {
+ text.getControl().removeListener(SWT.Verify, textListener);
+ text.setText(string);
+ text.getControl().addListener(SWT.Verify, textListener);
+ }
+ if ((text.getControl().getStyle() & SWT.READ_ONLY) == 0) {
+ text.getControl().setSelection(selStart, selEnd);
+ }
+ }
+ };
+
+ if (async) {
+ getDisplay().asyncExec(runnable);
+ } else {
+ getDisplay().syncExec(runnable);
+ }
+ }
+
+ /**
+ * The Verify Event handler.
+ * EVERYTHING is blocked via this handler (Event.doit is set to
+ * false). Depending upon the input, a course of action is determined and
+ * the displayed text is updated via the updateText() method.
+ *
+ * This method implements the following logic: If the event is a paste, the
+ * pasted text is parsed for the entire date/time selection; if this parse
+ * is successful, the result is committed to the selection property and is
+ * displayed; otherwise, it is discarded. One-character pastes are discarded
+ * without parsing. When user types characters one by one, all non-digits
+ * are discarded (if they have effects, they have already been processed by
+ * other event handlers) while digits are added to
+ * this.editField without affecting the selection. Once
+ * this.editField reaches its capacity for the active field,
+ * its contents are attempted to be committed. If the commit is successful,
+ * focus switches to the next field of CDateTime. Otherwise, the contents of
+ * this.editField are discarded and the previous value of the
+ * selection (before user started typing in this field) is restored; focus
+ * stays in the same field. Example: if the seconds field contains
+ * "23", and user types 8 in the seconds field, "08" is shown on screen
+ * while getSelection still returns 23. If user types 9 after that, the
+ * field reaches its capacity, the attempt to commit 89 seconds fails, and
+ * 23 gets restored on screen.
+ *
+ * @param e
+ * the event
+ * @see CDateTime#updateText()
+ */
+ void verify(Event e) {
+ // we don't want to reprocess the event
+ if (e.doit == false) {
+ return;
+ }
+
+ e.doit = false;
+ if (field.length == 0 || activeField == FIELD_NONE || e.text == null) {
+ return;
+ }
+
+ char c = e.character;
+ if (e.text.length() == 1 && String.valueOf(c).equals(e.text)
+ && Character.isDigit(c) || e.text.length() > 1) {
+ if (e.text.length() == 1) {
+ if (editField == null) {
+ int cf = getCalendarField();
+ if (cf >= 0) {
+ int digits;
+ switch (cf) {
+ case Calendar.YEAR:
+ digits = 4;
+ break;
+ case Calendar.DAY_OF_YEAR:
+ digits = 3;
+ break;
+ case Calendar.AM_PM:
+ case Calendar.DAY_OF_WEEK:
+ case Calendar.ERA:
+ digits = 1;
+ break;
+ case Calendar.MILLISECOND:
+ digits = 3;
+ break;
+ default:
+ digits = 2;
+ }
+ editField = new EditField(digits, calendar.get(cf));
+ } else {
+ return;
+ }
+ }
+ if (editField.addChar(c)) {
+ if (commitEditField()) {
+ fieldNext();
+ } else {
+ editField = null;
+ if (selection.length > 0) {
+ selection[0] = calendar.getTime();
+ }
+ updateText();
+ }
+ }
+ if (selection.length > 0) {
+ selection[0] = calendar.getTime();
+ }
+ updatePicker();
+ } else {
+ try {
+ setSelection(df.parse(e.text));
+ fireSelectionChanged();
+ } catch (ParseException pe) {
+ // do nothing
+ }
+ }
+ }
+ updateText();
+ }
+
+ /**
+ * @param pattern
+ * @param allowedTimeZones
+ * @throws IllegalArgumentException
+ */
+ public void setPattern(final String pattern,
+ final TimeZone[] allowedTimeZones) throws IllegalArgumentException {
+ this.setPattern(pattern);
+ if (pattern.indexOf('z') != -1) {
+ this.allowedTimezones = allowedTimeZones;
+ }
+ }
+
+ /**
+ * Returns the minimum date or null.
+ *
+ * @return Returns a clone of the minDate or null if not set.
+ * @since 1.4
+ */
+ public Calendar getMinDate() {
+ if (minDate == null) {
+ return null;
+ }
+ return (Calendar) minDate.clone();
+ }
+
+ /**
+ * Returns the maximum date or null.
+ *
+ * @return Returns a clone of the maxDate or null if not set.
+ * @since 1.4
+ */
+ public Calendar getMaxDate() {
+ if (maxDate == null) {
+ return null;
+ }
+ return (Calendar) maxDate.clone();
+ }
+
+ /**
+ * @see org.eclipse.swt.widgets.Control#setBackground(org.eclipse.swt.graphics.Color)
+ */
+ public void setBackground(Color color) {
+ super.setBackground(color);
+ if (spinner != null) {
+ spinner.setBackground(color);
+ }
+ if (picker != null) {
+ picker.updateColorsAndFont();
+ }
+ }
+
+ public void setForeground(Color color) {
+ super.setForeground(color);
+ if (picker != null) {
+ picker.updateColorsAndFont();
+ }
+ }
+
+ /**
+ * @param color
+ * @since 1.5
+ */
+ public void setButtonHoverBackgroundColor(Color color) {
+ checkWidget();
+ this.buttonHoverBackgroundColor = color;
+ if (picker != null) {
+ picker.updateColorsAndFont();
+ }
+ }
+
+ /**
+ * @param color
+ * @since 1.5
+ */
+ public void setButtonHoverBorderColor(Color color) {
+ checkWidget();
+ this.buttonHoverBorderColor = color;
+ if (picker != null) {
+ picker.updateColorsAndFont();
+ }
+ }
+
+ /**
+ * @param color
+ * @since 1.5
+ */
+ public void setButtonSelectedBackgroundColor(Color color) {
+ checkWidget();
+ this.buttonSelectedBackgroundColor = color;
+ if (picker != null) {
+ picker.updateColorsAndFont();
+ }
+ }
+
+ /**
+ * @param color
+ * @since 1.5
+ */
+ public void setButtonSelectedBorderColor(Color color) {
+ checkWidget();
+ this.buttonSelectedBorderColor = color;
+ if (picker != null) {
+ picker.updateColorsAndFont();
+ }
+ }
+
+ /**
+ * @return the picker foreground color
+ * @since 1.5
+ */
+ public Color getPickerForegroundColor() {
+ checkWidget();
+ return pickerForegroundColor;
+ }
+
+ /**
+ * @param pickerForegroundColor
+ * @since 1.5
+ */
+ public void setPickerForegroundColor(Color pickerForegroundColor) {
+ checkWidget();
+ this.pickerForegroundColor = pickerForegroundColor;
+ if (pickerForegroundColor != null && pickerPanel != null) {
+ pickerPanel.setForeground(pickerForegroundColor);
+ }
+ if (picker != null && pickerPanel != null && pickerPanel != null) {
+ picker.updateColorsAndFont();
+ }
+ }
+
+ /**
+ * @return the picker background color
+ * @since 1.5
+ */
+ public Color getPickerBackgroundColor() {
+ checkWidget();
+ return pickerBackgroundColor;
+ }
+
+ /**
+ * @param pickerBackgroundColor
+ * @since 1.5
+ */
+ public void setPickerBackgroundColor(Color pickerBackgroundColor) {
+ checkWidget();
+ this.pickerBackgroundColor = pickerBackgroundColor;
+ if (pickerBackgroundColor != null && pickerPanel != null) {
+ pickerPanel.setBackground(pickerBackgroundColor);
+ }
+ if (picker != null) {
+ picker.updateColorsAndFont();
+ }
+ }
+
+ /**
+ * @return the picker font
+ * @since 1.5
+ */
+ public Font getPickerFont() {
+ checkWidget();
+ return pickerFont;
+ }
+
+ /**
+ * @param pickerFont
+ * @since 1.5
+ */
+ public void setPickerFont(Font pickerFont) {
+ checkWidget();
+ this.pickerFont = pickerFont;
+ if (pickerFont != null && pickerPanel != null) {
+ pickerPanel.setFont(pickerFont);
+ }
+ if (picker != null) {
+ picker.updateColorsAndFont();
+ }
+ }
+
+ /**
+ * @return the bg color of the button hover
+ * @since 1.5
+ */
+ public Color getButtonHoverBackgroundColor() {
+ checkWidget();
+ return buttonHoverBackgroundColor;
+ }
+
+ /**
+ * @return the border color of the button hover
+ * @since 1.5
+ */
+ public Color getButtonHoverBorderColor() {
+ checkWidget();
+ return buttonHoverBorderColor;
+ }
+
+ /**
+ * @return the selected background of the button
+ * @since 1.5
+ */
+ public Color getButtonSelectedBackgroundColor() {
+ checkWidget();
+ return buttonSelectedBackgroundColor;
+ }
+
+ /**
+ * @return the border color of the selected button
+ * @since 1.5
+ */
+ public Color getButtonSelectedBorderColor() {
+ checkWidget();
+ return buttonSelectedBorderColor;
+ }
+
+ /**
+ * @return the color of the active day
+ * @since 1.5
+ */
+ public Color getPickerActiveDayColor() {
+ checkWidget();
+ return pickerActiveDayColor;
+ }
+
+ /**
+ * @param pickerActiveDayColor
+ * @since 1.5
+ */
+ public void setPickerActiveDayColor(Color pickerActiveDayColor) {
+ checkWidget();
+ this.pickerActiveDayColor = pickerActiveDayColor;
+ if (picker != null) {
+ picker.updateColorsAndFont();
+ }
+ }
+
+ /**
+ * @return the color of the inactive day
+ * @since 1.5
+ */
+ public Color getPickerInactiveDayColor() {
+ checkWidget();
+ return pickerInactiveDayColor;
+ }
+
+ /**
+ * @param pickerInactiveDayColor
+ * @since 1.5
+ */
+ public void setPickerInactiveDayColor(Color pickerInactiveDayColor) {
+ checkWidget();
+ this.pickerInactiveDayColor = pickerInactiveDayColor;
+ if (picker != null) {
+ picker.updateColorsAndFont();
+ }
+ }
+
+ /**
+ * @return the color of the "today" section
+ * @since 1.5
+ */
+ public Color getPickerTodayColor() {
+ checkWidget();
+ return pickerTodayColor;
+ }
+
+ /**
+ * @param pickerTodayColor
+ * @since 1.5
+ */
+ public void setPickerTodayColor(Color pickerTodayColor) {
+ checkWidget();
+ this.pickerTodayColor = pickerTodayColor;
+ if (picker != null) {
+ picker.updateColorsAndFont();
+ }
+ }
+
+ /**
+ * @return the color of the minutes
+ * @since 1.5
+ */
+ public Color getPickerMinutesColor() {
+ checkWidget();
+ return pickerMinutesColor;
+ }
+
+ /**
+ * @param pickerMinutesColor
+ * @since 1.5
+ */
+ public void setPickerMinutesColor(Color pickerMinutesColor) {
+ checkWidget();
+ this.pickerMinutesColor = pickerMinutesColor;
+ if (picker != null) {
+ picker.updateColorsAndFont();
+ }
+ }
+
+ /**
+ * @return the minutes background
+ * @since 1.5
+ */
+ public Color getPickerMinutesBackgroundColor() {
+ checkWidget();
+ return pickerMinutesBackgroundColor;
+ }
+
+ /**
+ * @param pickerMinutesBackgroundColor
+ * @since 1.5
+ */
+ public void setPickerMinutesBackgroundColor(
+ Color pickerMinutesBackgroundColor) {
+ checkWidget();
+ this.pickerMinutesBackgroundColor = pickerMinutesBackgroundColor;
+ if (picker != null) {
+ picker.updateColorsAndFont();
+ }
+ }
+
+ /**
+ * @return the foreground color of the "Ok" button
+ */
+ public Color getOkButtonColor() {
+ checkWidget();
+ return okButtonColor;
+ }
+
+ /**
+ * @param okButtonColor the new foreground color of the "ok" button
+ */
+ public void setOkButtonColor(Color okButtonColor) {
+ checkWidget();
+ this.okButtonColor = okButtonColor;
+ if (okButton != null) okButton.setForeground(okButtonColor);
+ }
+
+ /**
+ * @return the foreground color of the "Cancel" button
+ */
+ public Color getCancelButtonColor() {
+ checkWidget();
+ return cancelButtonColor;
+ }
+
+ /**
+ * @param cancelButtonColor the new foreground color of the "cancel" button
+ */
+ public void setCancelButtonColor(Color cancelButtonColor) {
+ checkWidget();
+ this.cancelButtonColor = cancelButtonColor;
+ if (cancelButton != null) cancelButton.setForeground(cancelButtonColor);
+ }
+
+ /**
+ * @return the foreground color of the "clear" button
+ */
+ public Color getClearButtonForegroundColor() {
+ checkWidget();
+ return clearButtonForegroundColor;
+ }
+
+ /**
+ * @param clearButtonForegroundColor the new foreground color of the "clear" button
+ */
+ public void setClearButtonForegroundColor(
+ Color clearButtonForegroundColor) {
+ checkWidget();
+ this.clearButtonForegroundColor = clearButtonForegroundColor;
+ if (clearButton != null) clearButton.setForeground(clearButtonForegroundColor);
+ }
+
+ /**
+ * @return the font of the "clear" button
+ */
+ public Font getClearButtonFont() {
+ checkWidget();
+ return clearButtonFont;
+ }
+
+ /**
+ * @param clearButtonFont the new font of the "clear" button
+ */
+ public void setClearButtonFont(Font clearButtonFont) {
+ checkWidget();
+ this.clearButtonFont = clearButtonFont;
+ if (clearButton != null) clearButton.setFont(clearButtonFont);
+ }
+
+}
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages.properties b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages.properties
index 1f6eec133..775b0b7b7 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages.properties
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages.properties
@@ -1,44 +1,44 @@
-null_text.date=
-null_text.time=
-accept.text=Accept
-cancel.text=Cancel
-clear.text=Clear
-nav_current_day=Go To Today
-nav_current_time=Go To Current Time
-nav_prev_month=Previous Month
-nav_next_month=Next Month
-nav_prev_year=Previous Year
-nav_next_year=Next Year
-today.text=Today
-today_verbose.text=Today is {0,date,EEEE}, the {1}
-date_ordinal_1=1st
-date_ordinal_2=2nd
-date_ordinal_3=3rd
-date_ordinal_4=4th
-date_ordinal_5=5th
-date_ordinal_6=6th
-date_ordinal_7=7th
-date_ordinal_8=8th
-date_ordinal_9=9th
-date_ordinal_10=10th
-date_ordinal_11=11th
-date_ordinal_12=12th
-date_ordinal_13=13th
-date_ordinal_14=14th
-date_ordinal_15=15th
-date_ordinal_16=16th
-date_ordinal_17=17th
-date_ordinal_18=18th
-date_ordinal_19=19th
-date_ordinal_20=20th
-date_ordinal_21=21st
-date_ordinal_22=22nd
-date_ordinal_23=23rd
-date_ordinal_24=24th
-date_ordinal_25=25th
-date_ordinal_26=26th
-date_ordinal_27=27th
-date_ordinal_28=28th
-date_ordinal_29=29th
-date_ordinal_30=30th
+null_text.date=
+null_text.time=
+accept.text=Accept
+cancel.text=Cancel
+clear.text=Clear
+nav_current_day=Go To Today
+nav_current_time=Go To Current Time
+nav_prev_month=Previous Month
+nav_next_month=Next Month
+nav_prev_year=Previous Year
+nav_next_year=Next Year
+today.text=Today
+today_verbose.text=Today is {0,date,EEEE}, the {1}
+date_ordinal_1=1st
+date_ordinal_2=2nd
+date_ordinal_3=3rd
+date_ordinal_4=4th
+date_ordinal_5=5th
+date_ordinal_6=6th
+date_ordinal_7=7th
+date_ordinal_8=8th
+date_ordinal_9=9th
+date_ordinal_10=10th
+date_ordinal_11=11th
+date_ordinal_12=12th
+date_ordinal_13=13th
+date_ordinal_14=14th
+date_ordinal_15=15th
+date_ordinal_16=16th
+date_ordinal_17=17th
+date_ordinal_18=18th
+date_ordinal_19=19th
+date_ordinal_20=20th
+date_ordinal_21=21st
+date_ordinal_22=22nd
+date_ordinal_23=23rd
+date_ordinal_24=24th
+date_ordinal_25=25th
+date_ordinal_26=26th
+date_ordinal_27=27th
+date_ordinal_28=28th
+date_ordinal_29=29th
+date_ordinal_30=30th
date_ordinal_31=31st
\ No newline at end of file
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_de.properties b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_de.properties
index 170c01d92..b88476ce2 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_de.properties
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_de.properties
@@ -1,44 +1,44 @@
-null_text.date=
-null_text.time=
-accept.text=OK
-cancel.text=Abbrechen
-clear.text=Löschen
-nav_current_day=Gehe zu Heute
-nav_current_time=Gehe zu aktueller Zeit
-nav_prev_month=Vorheriger Monat
-nav_next_month=Nächster Monat
-nav_prev_year=Vorheriges Jahr
-nav_next_year=Nächstes Jahr
-today.text=Heute
-today_verbose.text=Heute ist {0,date,EEEE}, der {1} {0,date,M}. {0,date,yyyy}
-date_ordinal_1=1.
-date_ordinal_2=2.
-date_ordinal_3=3.
-date_ordinal_4=4.
-date_ordinal_5=5.
-date_ordinal_6=6.
-date_ordinal_7=7.
-date_ordinal_8=8.
-date_ordinal_9=9.
-date_ordinal_10=10.
-date_ordinal_11=11.
-date_ordinal_12=12.
-date_ordinal_13=13.
-date_ordinal_14=14.
-date_ordinal_15=15.
-date_ordinal_16=16.
-date_ordinal_17=17.
-date_ordinal_18=18.
-date_ordinal_19=19.
-date_ordinal_20=20.
-date_ordinal_21=21.
-date_ordinal_22=22.
-date_ordinal_23=23.
-date_ordinal_24=24.
-date_ordinal_25=25.
-date_ordinal_26=26.
-date_ordinal_27=27.
-date_ordinal_28=28.
-date_ordinal_29=29.
-date_ordinal_30=30.
+null_text.date=
+null_text.time=
+accept.text=OK
+cancel.text=Abbrechen
+clear.text=Löschen
+nav_current_day=Gehe zu Heute
+nav_current_time=Gehe zu aktueller Zeit
+nav_prev_month=Vorheriger Monat
+nav_next_month=Nächster Monat
+nav_prev_year=Vorheriges Jahr
+nav_next_year=Nächstes Jahr
+today.text=Heute
+today_verbose.text=Heute ist {0,date,EEEE}, der {1} {0,date,M}. {0,date,yyyy}
+date_ordinal_1=1.
+date_ordinal_2=2.
+date_ordinal_3=3.
+date_ordinal_4=4.
+date_ordinal_5=5.
+date_ordinal_6=6.
+date_ordinal_7=7.
+date_ordinal_8=8.
+date_ordinal_9=9.
+date_ordinal_10=10.
+date_ordinal_11=11.
+date_ordinal_12=12.
+date_ordinal_13=13.
+date_ordinal_14=14.
+date_ordinal_15=15.
+date_ordinal_16=16.
+date_ordinal_17=17.
+date_ordinal_18=18.
+date_ordinal_19=19.
+date_ordinal_20=20.
+date_ordinal_21=21.
+date_ordinal_22=22.
+date_ordinal_23=23.
+date_ordinal_24=24.
+date_ordinal_25=25.
+date_ordinal_26=26.
+date_ordinal_27=27.
+date_ordinal_28=28.
+date_ordinal_29=29.
+date_ordinal_30=30.
date_ordinal_31=31.
\ No newline at end of file
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_el_GR.properties b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_el_GR.properties
index 3b8961954..66817e1d6 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_el_GR.properties
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_el_GR.properties
@@ -1,45 +1,45 @@
-null_text.date=<\u0395\u03c0\u03b9\u03bb\u03ad\u03be\u03c4\u03b5 \u03b7\u03bc\u03b5\u03c1/\u03bd\u03af\u03b1>
-null_text.time=<\u0395\u03c0\u03b9\u03bb\u03ad\u03be\u03c4\u03b5 \u03ce\u03c1\u03b1>
-accept.text=\u0391\u03c0\u03bf\u03b4\u03bf\u03c7\u03ae
-cancel.text=\u0391\u03ba\u03cd\u03c1\u03c9\u03c3\u03b7
-clear.text=\u0395\u03ba\u03ba\u03b1\u03b8\u03ac\u03c1\u03b9\u03c3\u03b7
-nav_current_day=\u03a4\u03c1\u03ad\u03c7\u03bf\u03c5\u03c3\u03b1 \u03b7\u03bc\u03ad\u03c1\u03b1
-nav_current_time=\u03a4\u03c1\u03ac\u03c7\u03bf\u03c5\u03c3\u03b1 \u03ce\u03c1\u03b1
-nav_prev_mon\u03bf\u03c2=\u03a0\u03c1\u03bf\u03b7\u03b3\u03bf\u03cd\u03bc\u03b5\u03bd\u03bf\u03c2 \u03bc\u03ae\u03bd\u03b1\u03c2
-nav_next_mon\u03bf\u03c2=\u0395\u03c0\u03cc\u03bc\u03b5\u03bd\u03bf\u03c2 \u03bc\u03ae\u03bd\u03b1\u03c2
-nav_prev_year=\u03a0\u03c1\u03bf\u03b7\u03b3\u03bf\u03cd\u03bc\u03b5\u03bd\u03bf\u03c2 \u03c7\u03c1\u03cc\u03bd\u03bf\u03c2
-nav_next_year=\u0395\u03c0\u03cc\u03bc\u03b5\u03bd\u03bf\u03c2 \u03c7\u03c1\u03cc\u03bd\u03bf\u03c2
-today.text=\u03a3\u03ae\u03bc\u03b5\u03c1\u03b1
-today_verbose.text=\u03a3\u03ae\u03bc\u03b5\u03c1\u03b1 \u03b5\u03af\u03bd\u03b1\u03b9 {0,date,EEEE} {1} {0,date,MMMMM} {0,date,yyyy}
-show_selection=\u0395\u03bc\u03c6\u03ac\u03bd\u03b9\u03c3\u03b7 \u03b5\u03c0\u03b9\u03bb\u03bf\u03b3\u03ae\u03c2
-date_ordinal_1=1\u03bf\u03c2
-date_ordinal_2=2\u03bf\u03c2
-date_ordinal_3=3\u03bf\u03c2
-date_ordinal_4=4\u03bf\u03c2
-date_ordinal_5=5\u03bf\u03c2
-date_ordinal_6=6\u03bf\u03c2
-date_ordinal_7=7\u03bf\u03c2
-date_ordinal_8=8\u03bf\u03c2
-date_ordinal_9=9\u03bf\u03c2
-date_ordinal_10=10\u03bf\u03c2
-date_ordinal_11=11\u03bf\u03c2
-date_ordinal_12=12\u03bf\u03c2
-date_ordinal_13=13\u03bf\u03c2
-date_ordinal_14=14\u03bf\u03c2
-date_ordinal_15=15\u03bf\u03c2
-date_ordinal_16=16\u03bf\u03c2
-date_ordinal_17=17\u03bf\u03c2
-date_ordinal_18=18\u03bf\u03c2
-date_ordinal_19=19\u03bf\u03c2
-date_ordinal_20=20\u03bf\u03c2
-date_ordinal_21=21\u03bf\u03c2
-date_ordinal_22=22\u03bf\u03c2
-date_ordinal_23=23\u03bf\u03c2
-date_ordinal_24=24\u03bf\u03c2
-date_ordinal_25=25\u03bf\u03c2
-date_ordinal_26=26\u03bf\u03c2
-date_ordinal_27=27\u03bf\u03c2
-date_ordinal_28=28\u03bf\u03c2
-date_ordinal_29=29\u03bf\u03c2
-date_ordinal_30=30\u03bf\u03c2
+null_text.date=<\u0395\u03c0\u03b9\u03bb\u03ad\u03be\u03c4\u03b5 \u03b7\u03bc\u03b5\u03c1/\u03bd\u03af\u03b1>
+null_text.time=<\u0395\u03c0\u03b9\u03bb\u03ad\u03be\u03c4\u03b5 \u03ce\u03c1\u03b1>
+accept.text=\u0391\u03c0\u03bf\u03b4\u03bf\u03c7\u03ae
+cancel.text=\u0391\u03ba\u03cd\u03c1\u03c9\u03c3\u03b7
+clear.text=\u0395\u03ba\u03ba\u03b1\u03b8\u03ac\u03c1\u03b9\u03c3\u03b7
+nav_current_day=\u03a4\u03c1\u03ad\u03c7\u03bf\u03c5\u03c3\u03b1 \u03b7\u03bc\u03ad\u03c1\u03b1
+nav_current_time=\u03a4\u03c1\u03ac\u03c7\u03bf\u03c5\u03c3\u03b1 \u03ce\u03c1\u03b1
+nav_prev_mon\u03bf\u03c2=\u03a0\u03c1\u03bf\u03b7\u03b3\u03bf\u03cd\u03bc\u03b5\u03bd\u03bf\u03c2 \u03bc\u03ae\u03bd\u03b1\u03c2
+nav_next_mon\u03bf\u03c2=\u0395\u03c0\u03cc\u03bc\u03b5\u03bd\u03bf\u03c2 \u03bc\u03ae\u03bd\u03b1\u03c2
+nav_prev_year=\u03a0\u03c1\u03bf\u03b7\u03b3\u03bf\u03cd\u03bc\u03b5\u03bd\u03bf\u03c2 \u03c7\u03c1\u03cc\u03bd\u03bf\u03c2
+nav_next_year=\u0395\u03c0\u03cc\u03bc\u03b5\u03bd\u03bf\u03c2 \u03c7\u03c1\u03cc\u03bd\u03bf\u03c2
+today.text=\u03a3\u03ae\u03bc\u03b5\u03c1\u03b1
+today_verbose.text=\u03a3\u03ae\u03bc\u03b5\u03c1\u03b1 \u03b5\u03af\u03bd\u03b1\u03b9 {0,date,EEEE} {1} {0,date,MMMMM} {0,date,yyyy}
+show_selection=\u0395\u03bc\u03c6\u03ac\u03bd\u03b9\u03c3\u03b7 \u03b5\u03c0\u03b9\u03bb\u03bf\u03b3\u03ae\u03c2
+date_ordinal_1=1\u03bf\u03c2
+date_ordinal_2=2\u03bf\u03c2
+date_ordinal_3=3\u03bf\u03c2
+date_ordinal_4=4\u03bf\u03c2
+date_ordinal_5=5\u03bf\u03c2
+date_ordinal_6=6\u03bf\u03c2
+date_ordinal_7=7\u03bf\u03c2
+date_ordinal_8=8\u03bf\u03c2
+date_ordinal_9=9\u03bf\u03c2
+date_ordinal_10=10\u03bf\u03c2
+date_ordinal_11=11\u03bf\u03c2
+date_ordinal_12=12\u03bf\u03c2
+date_ordinal_13=13\u03bf\u03c2
+date_ordinal_14=14\u03bf\u03c2
+date_ordinal_15=15\u03bf\u03c2
+date_ordinal_16=16\u03bf\u03c2
+date_ordinal_17=17\u03bf\u03c2
+date_ordinal_18=18\u03bf\u03c2
+date_ordinal_19=19\u03bf\u03c2
+date_ordinal_20=20\u03bf\u03c2
+date_ordinal_21=21\u03bf\u03c2
+date_ordinal_22=22\u03bf\u03c2
+date_ordinal_23=23\u03bf\u03c2
+date_ordinal_24=24\u03bf\u03c2
+date_ordinal_25=25\u03bf\u03c2
+date_ordinal_26=26\u03bf\u03c2
+date_ordinal_27=27\u03bf\u03c2
+date_ordinal_28=28\u03bf\u03c2
+date_ordinal_29=29\u03bf\u03c2
+date_ordinal_30=30\u03bf\u03c2
date_ordinal_31=31\u03bf\u03c2
\ No newline at end of file
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_en_US.properties b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_en_US.properties
index 28f0c2bd2..103a11fa1 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_en_US.properties
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_en_US.properties
@@ -1,45 +1,45 @@
-null_text.date=
-null_text.time=
-accept.text=Accept
-cancel.text=Cancel
-clear.text=Clear
-nav_current_day=Go To Today
-nav_current_time=Go To Current Time
-nav_prev_month=Previous Month
-nav_next_month=Next Month
-nav_prev_year=Previous Year
-nav_next_year=Next Year
-today.text=Today
-today_verbose.text=Today is {0,date,EEEE}, the {1}
-show_selection=Show Selection
-date_ordinal_1=1st
-date_ordinal_2=2nd
-date_ordinal_3=3rd
-date_ordinal_4=4th
-date_ordinal_5=5th
-date_ordinal_6=6th
-date_ordinal_7=7th
-date_ordinal_8=8th
-date_ordinal_9=9th
-date_ordinal_10=10th
-date_ordinal_11=11th
-date_ordinal_12=12th
-date_ordinal_13=13th
-date_ordinal_14=14th
-date_ordinal_15=15th
-date_ordinal_16=16th
-date_ordinal_17=17th
-date_ordinal_18=18th
-date_ordinal_19=19th
-date_ordinal_20=20th
-date_ordinal_21=21st
-date_ordinal_22=22nd
-date_ordinal_23=23rd
-date_ordinal_24=24th
-date_ordinal_25=25th
-date_ordinal_26=26th
-date_ordinal_27=27th
-date_ordinal_28=28th
-date_ordinal_29=29th
-date_ordinal_30=30th
+null_text.date=
+null_text.time=
+accept.text=Accept
+cancel.text=Cancel
+clear.text=Clear
+nav_current_day=Go To Today
+nav_current_time=Go To Current Time
+nav_prev_month=Previous Month
+nav_next_month=Next Month
+nav_prev_year=Previous Year
+nav_next_year=Next Year
+today.text=Today
+today_verbose.text=Today is {0,date,EEEE}, the {1}
+show_selection=Show Selection
+date_ordinal_1=1st
+date_ordinal_2=2nd
+date_ordinal_3=3rd
+date_ordinal_4=4th
+date_ordinal_5=5th
+date_ordinal_6=6th
+date_ordinal_7=7th
+date_ordinal_8=8th
+date_ordinal_9=9th
+date_ordinal_10=10th
+date_ordinal_11=11th
+date_ordinal_12=12th
+date_ordinal_13=13th
+date_ordinal_14=14th
+date_ordinal_15=15th
+date_ordinal_16=16th
+date_ordinal_17=17th
+date_ordinal_18=18th
+date_ordinal_19=19th
+date_ordinal_20=20th
+date_ordinal_21=21st
+date_ordinal_22=22nd
+date_ordinal_23=23rd
+date_ordinal_24=24th
+date_ordinal_25=25th
+date_ordinal_26=26th
+date_ordinal_27=27th
+date_ordinal_28=28th
+date_ordinal_29=29th
+date_ordinal_30=30th
date_ordinal_31=31st
\ No newline at end of file
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_es_ES.properties b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_es_ES.properties
index 954819b54..1bd7db2ad 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_es_ES.properties
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_es_ES.properties
@@ -1,44 +1,44 @@
-null_text.date=
-null_text.time=
-accept.text=Aceptar
-cancel.text=Cancelar
-clear.text=Despejar
-nav_current_day=Ir a Hoy
-nav_current_time=Ir a la Hora Actual
-nav_prev_month=Mes Anterior
-nav_next_month=Siguiente Mes
-nav_prev_year=Año Anterior
-nav_next_year=Siguiente Año
-today.text=Hoy
-today_verbose.text=Hoy es {0,date,EEEE}, {1}
-date_ordinal_1=1º
-date_ordinal_2=2º
-date_ordinal_3=3º
-date_ordinal_4=4º
-date_ordinal_5=5º
-date_ordinal_6=6º
-date_ordinal_7=7º
-date_ordinal_8=8º
-date_ordinal_9=9º
-date_ordinal_10=10º
-date_ordinal_11=11º
-date_ordinal_12=12º
-date_ordinal_13=13º
-date_ordinal_14=14º
-date_ordinal_15=15º
-date_ordinal_16=16º
-date_ordinal_17=17º
-date_ordinal_18=18º
-date_ordinal_19=19º
-date_ordinal_20=20º
-date_ordinal_21=21º
-date_ordinal_22=22º
-date_ordinal_23=23º
-date_ordinal_24=24º
-date_ordinal_25=25º
-date_ordinal_26=26º
-date_ordinal_27=27º
-date_ordinal_28=28º
-date_ordinal_29=29º
-date_ordinal_30=30º
+null_text.date=
+null_text.time=
+accept.text=Aceptar
+cancel.text=Cancelar
+clear.text=Despejar
+nav_current_day=Ir a Hoy
+nav_current_time=Ir a la Hora Actual
+nav_prev_month=Mes Anterior
+nav_next_month=Siguiente Mes
+nav_prev_year=Año Anterior
+nav_next_year=Siguiente Año
+today.text=Hoy
+today_verbose.text=Hoy es {0,date,EEEE}, {1}
+date_ordinal_1=1º
+date_ordinal_2=2º
+date_ordinal_3=3º
+date_ordinal_4=4º
+date_ordinal_5=5º
+date_ordinal_6=6º
+date_ordinal_7=7º
+date_ordinal_8=8º
+date_ordinal_9=9º
+date_ordinal_10=10º
+date_ordinal_11=11º
+date_ordinal_12=12º
+date_ordinal_13=13º
+date_ordinal_14=14º
+date_ordinal_15=15º
+date_ordinal_16=16º
+date_ordinal_17=17º
+date_ordinal_18=18º
+date_ordinal_19=19º
+date_ordinal_20=20º
+date_ordinal_21=21º
+date_ordinal_22=22º
+date_ordinal_23=23º
+date_ordinal_24=24º
+date_ordinal_25=25º
+date_ordinal_26=26º
+date_ordinal_27=27º
+date_ordinal_28=28º
+date_ordinal_29=29º
+date_ordinal_30=30º
date_ordinal_31=31º
\ No newline at end of file
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_fr.properties b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_fr.properties
index aa2f2243c..7d5c97e69 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_fr.properties
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_fr.properties
@@ -1,44 +1,44 @@
-null_text.date=
-null_text.time=
-accept.text=Accepter
-cancel.text=Annuler
-clear.text=Supprimer
-nav_current_day=Aller \u00E0 aujourd'hui
-nav_current_time=Aller \u00E0 l''heure actuelle
-nav_prev_month=Mois pr\u00E9c\u00E9dent
-nav_next_month=Mois suivant
-nav_prev_year=Ann\u00E9e pr\u00E9c\u00E9dente
-nav_next_year=Ann\u00E9e suivante
-today.text=Aujourd'hui
-today_verbose.text=Aujourd''hui nous sommes le {0,date,EEEE} {1} {0,date,MMMMM} {0,date,yyyy}
-date_ordinal_1=1er
-date_ordinal_2=2
-date_ordinal_3=3
-date_ordinal_4=4
-date_ordinal_5=5
-date_ordinal_6=6
-date_ordinal_7=7
-date_ordinal_8=8
-date_ordinal_9=9
-date_ordinal_10=10
-date_ordinal_11=11
-date_ordinal_12=12
-date_ordinal_13=13
-date_ordinal_14=14
-date_ordinal_15=15
-date_ordinal_16=16
-date_ordinal_17=17
-date_ordinal_18=18
-date_ordinal_19=19
-date_ordinal_20=20
-date_ordinal_21=21
-date_ordinal_22=22
-date_ordinal_23=23
-date_ordinal_24=24
-date_ordinal_25=25
-date_ordinal_26=26
-date_ordinal_27=27
-date_ordinal_28=28
-date_ordinal_29=29
-date_ordinal_30=30
-date_ordinal_31=31
+null_text.date=
+null_text.time=
+accept.text=Accepter
+cancel.text=Annuler
+clear.text=Supprimer
+nav_current_day=Aller \u00E0 aujourd'hui
+nav_current_time=Aller \u00E0 l''heure actuelle
+nav_prev_month=Mois pr\u00E9c\u00E9dent
+nav_next_month=Mois suivant
+nav_prev_year=Ann\u00E9e pr\u00E9c\u00E9dente
+nav_next_year=Ann\u00E9e suivante
+today.text=Aujourd'hui
+today_verbose.text=Aujourd''hui nous sommes le {0,date,EEEE} {1} {0,date,MMMMM} {0,date,yyyy}
+date_ordinal_1=1er
+date_ordinal_2=2
+date_ordinal_3=3
+date_ordinal_4=4
+date_ordinal_5=5
+date_ordinal_6=6
+date_ordinal_7=7
+date_ordinal_8=8
+date_ordinal_9=9
+date_ordinal_10=10
+date_ordinal_11=11
+date_ordinal_12=12
+date_ordinal_13=13
+date_ordinal_14=14
+date_ordinal_15=15
+date_ordinal_16=16
+date_ordinal_17=17
+date_ordinal_18=18
+date_ordinal_19=19
+date_ordinal_20=20
+date_ordinal_21=21
+date_ordinal_22=22
+date_ordinal_23=23
+date_ordinal_24=24
+date_ordinal_25=25
+date_ordinal_26=26
+date_ordinal_27=27
+date_ordinal_28=28
+date_ordinal_29=29
+date_ordinal_30=30
+date_ordinal_31=31
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_hu_HU.properties b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_hu_HU.properties
index 0224b7c20..3d6675904 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_hu_HU.properties
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_hu_HU.properties
@@ -1,89 +1,89 @@
-
-accept.text = Elfogad
-
-cancel.text = M\u00E9gse
-
-clear.text = T\u00F6r\u00F6l
-
-date_ordinal_1 = 1.
-
-date_ordinal_10 = 10.
-
-date_ordinal_11 = 11.
-
-date_ordinal_12 = 12.
-
-date_ordinal_13 = 13.
-
-date_ordinal_14 = 14.
-
-date_ordinal_15 = 15.
-
-date_ordinal_16 = 16.
-
-date_ordinal_17 = 17.
-
-date_ordinal_18 = 18.
-
-date_ordinal_19 = 19.
-
-date_ordinal_2 = 2.
-
-date_ordinal_20 = 20.
-
-date_ordinal_21 = 21.
-
-date_ordinal_22 = 22.
-
-date_ordinal_23 = 23.
-
-date_ordinal_24 = 24.
-
-date_ordinal_25 = 25.
-
-date_ordinal_26 = 26.
-
-date_ordinal_27 = 27.
-
-date_ordinal_28 = 28.
-
-date_ordinal_29 = 29.
-
-date_ordinal_3 = 3.
-
-date_ordinal_30 = 30.
-
-date_ordinal_31 = 31.
-
-date_ordinal_4 = 4.
-
-date_ordinal_5 = 5.
-
-date_ordinal_6 = 6.
-
-date_ordinal_7 = 7.
-
-date_ordinal_8 = 8.
-
-date_ordinal_9 = 9.
-
-nav_current_day = Ugr\u00E1s a mai napra
-
-nav_current_time = Aktu\u00E1lis id\u0151
-
-nav_next_month = K\u00F6vetkez\u0151 h\u00F3nap
-
-nav_next_year = K\u00F6vetkez\u0151 \u00E9v
-
-nav_prev_month = El\u0151z\u0151 h\u00F3nap
-
-nav_prev_year = El\u0151z\u0151 \u00E9v
-
-null_text.date =
-null_text.time =
-
-show_selection = Kiv\u00E1laszt\u00E1. mutat
-
-today.text = Ma
-
-today_verbose.text = Ma {0,date,EEEE}, {1} van
+
+accept.text = Elfogad
+
+cancel.text = M\u00E9gse
+
+clear.text = T\u00F6r\u00F6l
+
+date_ordinal_1 = 1.
+
+date_ordinal_10 = 10.
+
+date_ordinal_11 = 11.
+
+date_ordinal_12 = 12.
+
+date_ordinal_13 = 13.
+
+date_ordinal_14 = 14.
+
+date_ordinal_15 = 15.
+
+date_ordinal_16 = 16.
+
+date_ordinal_17 = 17.
+
+date_ordinal_18 = 18.
+
+date_ordinal_19 = 19.
+
+date_ordinal_2 = 2.
+
+date_ordinal_20 = 20.
+
+date_ordinal_21 = 21.
+
+date_ordinal_22 = 22.
+
+date_ordinal_23 = 23.
+
+date_ordinal_24 = 24.
+
+date_ordinal_25 = 25.
+
+date_ordinal_26 = 26.
+
+date_ordinal_27 = 27.
+
+date_ordinal_28 = 28.
+
+date_ordinal_29 = 29.
+
+date_ordinal_3 = 3.
+
+date_ordinal_30 = 30.
+
+date_ordinal_31 = 31.
+
+date_ordinal_4 = 4.
+
+date_ordinal_5 = 5.
+
+date_ordinal_6 = 6.
+
+date_ordinal_7 = 7.
+
+date_ordinal_8 = 8.
+
+date_ordinal_9 = 9.
+
+nav_current_day = Ugr\u00E1s a mai napra
+
+nav_current_time = Aktu\u00E1lis id\u0151
+
+nav_next_month = K\u00F6vetkez\u0151 h\u00F3nap
+
+nav_next_year = K\u00F6vetkez\u0151 \u00E9v
+
+nav_prev_month = El\u0151z\u0151 h\u00F3nap
+
+nav_prev_year = El\u0151z\u0151 \u00E9v
+
+null_text.date =
+null_text.time =
+
+show_selection = Kiv\u00E1laszt\u00E1. mutat
+
+today.text = Ma
+
+today_verbose.text = Ma {0,date,EEEE}, {1} van
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_it_IT.properties b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_it_IT.properties
index 79b809242..27adb7810 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_it_IT.properties
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_it_IT.properties
@@ -1,44 +1,44 @@
-null_text.date=
-null_text.time=
-accept.text=Accetta
-cancel.text=Cancella
-clear.text=Selezione Libera
-nav_current_day=Vai a Oggi
-nav_current_time=Vai all'ora corrente
-nav_prev_month=Mese Precedente
-nav_next_month=Prossimo Mese
-nav_prev_year=Anno Precedente
-nav_next_year=Prossimo Anno
-today.text=Oggi
-today_verbose.text=Oggi è {0,date,EEEE}, il {1} giorno
-date_ordinal_1=1°
-date_ordinal_2=2°
-date_ordinal_3=3°
-date_ordinal_4=4°
-date_ordinal_5=5°
-date_ordinal_6=6°
-date_ordinal_7=7°
-date_ordinal_8=8°
-date_ordinal_9=9°
-date_ordinal_10=10°
-date_ordinal_11=11°
-date_ordinal_12=12°
-date_ordinal_13=13°
-date_ordinal_14=14°
-date_ordinal_15=15°
-date_ordinal_16=16°
-date_ordinal_17=17°
-date_ordinal_18=18°
-date_ordinal_19=19°
-date_ordinal_20=20°
-date_ordinal_21=21°
-date_ordinal_22=22°
-date_ordinal_23=23°
-date_ordinal_24=24°
-date_ordinal_25=25°
-date_ordinal_26=26°
-date_ordinal_27=27°
-date_ordinal_28=28°
-date_ordinal_29=29°
-date_ordinal_30=30°
+null_text.date=
+null_text.time=
+accept.text=Accetta
+cancel.text=Cancella
+clear.text=Selezione Libera
+nav_current_day=Vai a Oggi
+nav_current_time=Vai all'ora corrente
+nav_prev_month=Mese Precedente
+nav_next_month=Prossimo Mese
+nav_prev_year=Anno Precedente
+nav_next_year=Prossimo Anno
+today.text=Oggi
+today_verbose.text=Oggi è {0,date,EEEE}, il {1} giorno
+date_ordinal_1=1°
+date_ordinal_2=2°
+date_ordinal_3=3°
+date_ordinal_4=4°
+date_ordinal_5=5°
+date_ordinal_6=6°
+date_ordinal_7=7°
+date_ordinal_8=8°
+date_ordinal_9=9°
+date_ordinal_10=10°
+date_ordinal_11=11°
+date_ordinal_12=12°
+date_ordinal_13=13°
+date_ordinal_14=14°
+date_ordinal_15=15°
+date_ordinal_16=16°
+date_ordinal_17=17°
+date_ordinal_18=18°
+date_ordinal_19=19°
+date_ordinal_20=20°
+date_ordinal_21=21°
+date_ordinal_22=22°
+date_ordinal_23=23°
+date_ordinal_24=24°
+date_ordinal_25=25°
+date_ordinal_26=26°
+date_ordinal_27=27°
+date_ordinal_28=28°
+date_ordinal_29=29°
+date_ordinal_30=30°
date_ordinal_31=31°
\ No newline at end of file
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_nl_NL.properties b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_nl_NL.properties
index 849f066d4..7397ab53a 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_nl_NL.properties
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_nl_NL.properties
@@ -1,45 +1,45 @@
-null_text.date=
-null_text.time=
-accept.text=Accepteren
-cancel.text=Afbreken
-clear.text=Wissen
-nav_current_day=Vandaag
-nav_current_time=Huidige Tijd
-nav_prev_month=Vorige Maand
-nav_next_month=Volgende Maand
-nav_prev_year=Vorig Jaar
-nav_next_year=Volgend Jaar
-today.text=Vandaag
-today_verbose.text=Vandaag is het {0,date,EEEE}, de {1}
-show_selection=Toon Selectie
-date_ordinal_1=1e
-date_ordinal_2=2e
-date_ordinal_3=3e
-date_ordinal_4=4e
-date_ordinal_5=5e
-date_ordinal_6=6e
-date_ordinal_7=7e
-date_ordinal_8=8e
-date_ordinal_9=9e
-date_ordinal_10=10e
-date_ordinal_11=11e
-date_ordinal_12=12e
-date_ordinal_13=13e
-date_ordinal_14=14e
-date_ordinal_15=15e
-date_ordinal_16=16e
-date_ordinal_17=17e
-date_ordinal_18=18e
-date_ordinal_19=19e
-date_ordinal_20=20e
-date_ordinal_21=21e
-date_ordinal_22=22e
-date_ordinal_23=23e
-date_ordinal_24=24e
-date_ordinal_25=25e
-date_ordinal_26=26e
-date_ordinal_27=27e
-date_ordinal_28=28e
-date_ordinal_29=29e
-date_ordinal_30=30e
+null_text.date=
+null_text.time=
+accept.text=Accepteren
+cancel.text=Afbreken
+clear.text=Wissen
+nav_current_day=Vandaag
+nav_current_time=Huidige Tijd
+nav_prev_month=Vorige Maand
+nav_next_month=Volgende Maand
+nav_prev_year=Vorig Jaar
+nav_next_year=Volgend Jaar
+today.text=Vandaag
+today_verbose.text=Vandaag is het {0,date,EEEE}, de {1}
+show_selection=Toon Selectie
+date_ordinal_1=1e
+date_ordinal_2=2e
+date_ordinal_3=3e
+date_ordinal_4=4e
+date_ordinal_5=5e
+date_ordinal_6=6e
+date_ordinal_7=7e
+date_ordinal_8=8e
+date_ordinal_9=9e
+date_ordinal_10=10e
+date_ordinal_11=11e
+date_ordinal_12=12e
+date_ordinal_13=13e
+date_ordinal_14=14e
+date_ordinal_15=15e
+date_ordinal_16=16e
+date_ordinal_17=17e
+date_ordinal_18=18e
+date_ordinal_19=19e
+date_ordinal_20=20e
+date_ordinal_21=21e
+date_ordinal_22=22e
+date_ordinal_23=23e
+date_ordinal_24=24e
+date_ordinal_25=25e
+date_ordinal_26=26e
+date_ordinal_27=27e
+date_ordinal_28=28e
+date_ordinal_29=29e
+date_ordinal_30=30e
date_ordinal_31=31e
\ No newline at end of file
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_no_NO.properties b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_no_NO.properties
index 9aa602ea5..5823bef1b 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_no_NO.properties
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_no_NO.properties
@@ -1,44 +1,44 @@
-null_text.date=
-null_text.time=
-accept.text=Velg
-cancel.text=Avbryt
-clear.text=Clear
-nav_current_day=Gå Til Idag
-nav_current_time=Gå Til Nå
-nav_prev_month=Forrige Måned
-nav_next_month=Neste Måned
-nav_prev_year=Forrige År
-nav_next_year=Neste År
-today.text=Idag
-today_verbose.text=Idag er {0,date,EEEE} den {1}
-date_ordinal_1=1ste
-date_ordinal_2=2dre
-date_ordinal_3=3dje
-date_ordinal_4=4de
-date_ordinal_5=5te
-date_ordinal_6=6te
-date_ordinal_7=7nde
-date_ordinal_8=8nde
-date_ordinal_9=9nde
-date_ordinal_10=10nde
-date_ordinal_11=11te
-date_ordinal_12=12te
-date_ordinal_13=13nde
-date_ordinal_14=14nde
-date_ordinal_15=15nde
-date_ordinal_16=16nde
-date_ordinal_17=17nde
-date_ordinal_18=18nde
-date_ordinal_19=19nde
-date_ordinal_20=20nde
-date_ordinal_21=21ste
-date_ordinal_22=22dre
-date_ordinal_23=23dje
-date_ordinal_24=24de
-date_ordinal_25=25te
-date_ordinal_26=26te
-date_ordinal_27=27nde
-date_ordinal_28=28nde
-date_ordinal_29=29nde
-date_ordinal_30=30te
+null_text.date=
+null_text.time=
+accept.text=Velg
+cancel.text=Avbryt
+clear.text=Clear
+nav_current_day=Gå Til Idag
+nav_current_time=Gå Til Nå
+nav_prev_month=Forrige Måned
+nav_next_month=Neste Måned
+nav_prev_year=Forrige År
+nav_next_year=Neste År
+today.text=Idag
+today_verbose.text=Idag er {0,date,EEEE} den {1}
+date_ordinal_1=1ste
+date_ordinal_2=2dre
+date_ordinal_3=3dje
+date_ordinal_4=4de
+date_ordinal_5=5te
+date_ordinal_6=6te
+date_ordinal_7=7nde
+date_ordinal_8=8nde
+date_ordinal_9=9nde
+date_ordinal_10=10nde
+date_ordinal_11=11te
+date_ordinal_12=12te
+date_ordinal_13=13nde
+date_ordinal_14=14nde
+date_ordinal_15=15nde
+date_ordinal_16=16nde
+date_ordinal_17=17nde
+date_ordinal_18=18nde
+date_ordinal_19=19nde
+date_ordinal_20=20nde
+date_ordinal_21=21ste
+date_ordinal_22=22dre
+date_ordinal_23=23dje
+date_ordinal_24=24de
+date_ordinal_25=25te
+date_ordinal_26=26te
+date_ordinal_27=27nde
+date_ordinal_28=28nde
+date_ordinal_29=29nde
+date_ordinal_30=30te
date_ordinal_31=31ste
\ No newline at end of file
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_pl_PL.properties b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_pl_PL.properties
index 4d2df38aa..d46252ee4 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_pl_PL.properties
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_pl_PL.properties
@@ -1,44 +1,44 @@
-null_text.date=
-null_text.time=
-accept.text=Akceptuj
-cancel.text=Anuluj
-clear.text=Clear
-nav_current_day=Id\u017a do dzisiejszej daty
-nav_current_time=Id\u017a do obecnego czasu
-nav_prev_month=Poprzedni miesi\u0105c
-nav_next_month=Nast\u0119pny miesi\u0105c
-nav_prev_year=Poprzedni rok
-nav_next_year=Nast\u0119pny rok
-today.text=Dzi\u015b
-today_verbose.text=Dzi\u015b jest {0,date,EEEE}, {1} {0,date,MMMM}
-date_ordinal_1=1.
-date_ordinal_2=2.
-date_ordinal_3=3.
-date_ordinal_4=4.
-date_ordinal_5=5.
-date_ordinal_6=6.
-date_ordinal_7=7.
-date_ordinal_8=8.
-date_ordinal_9=9.
-date_ordinal_10=10.
-date_ordinal_11=11.
-date_ordinal_12=12.
-date_ordinal_13=13.
-date_ordinal_14=14.
-date_ordinal_15=15.
-date_ordinal_16=16.
-date_ordinal_17=17.
-date_ordinal_18=18.
-date_ordinal_19=19.
-date_ordinal_20=20.
-date_ordinal_21=21.
-date_ordinal_22=22.
-date_ordinal_23=23.
-date_ordinal_24=24.
-date_ordinal_25=25.
-date_ordinal_26=26.
-date_ordinal_27=27.
-date_ordinal_28=28.
-date_ordinal_29=29.
-date_ordinal_30=30.
+null_text.date=
+null_text.time=
+accept.text=Akceptuj
+cancel.text=Anuluj
+clear.text=Clear
+nav_current_day=Id\u017a do dzisiejszej daty
+nav_current_time=Id\u017a do obecnego czasu
+nav_prev_month=Poprzedni miesi\u0105c
+nav_next_month=Nast\u0119pny miesi\u0105c
+nav_prev_year=Poprzedni rok
+nav_next_year=Nast\u0119pny rok
+today.text=Dzi\u015b
+today_verbose.text=Dzi\u015b jest {0,date,EEEE}, {1} {0,date,MMMM}
+date_ordinal_1=1.
+date_ordinal_2=2.
+date_ordinal_3=3.
+date_ordinal_4=4.
+date_ordinal_5=5.
+date_ordinal_6=6.
+date_ordinal_7=7.
+date_ordinal_8=8.
+date_ordinal_9=9.
+date_ordinal_10=10.
+date_ordinal_11=11.
+date_ordinal_12=12.
+date_ordinal_13=13.
+date_ordinal_14=14.
+date_ordinal_15=15.
+date_ordinal_16=16.
+date_ordinal_17=17.
+date_ordinal_18=18.
+date_ordinal_19=19.
+date_ordinal_20=20.
+date_ordinal_21=21.
+date_ordinal_22=22.
+date_ordinal_23=23.
+date_ordinal_24=24.
+date_ordinal_25=25.
+date_ordinal_26=26.
+date_ordinal_27=27.
+date_ordinal_28=28.
+date_ordinal_29=29.
+date_ordinal_30=30.
date_ordinal_31=31.
\ No newline at end of file
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_pt_BR.properties b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_pt_BR.properties
index 18e20fe9f..0a251bb0a 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_pt_BR.properties
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_pt_BR.properties
@@ -1,45 +1,45 @@
-null_text.date=
-null_text.time=
-accept.text=OK
-cancel.text=Cancelar
-clear.text=Limpar
-nav_current_day=Ir Para a Data Atual
-nav_current_time=Ir Para a Hora Atual
-nav_prev_month=Mês Anterior
-nav_next_month=Próximo Mês
-nav_prev_year=Ano Anterior
-nav_next_year=Próximo Ano
-today.text=Hoje
-today_verbose.text=Hoje é {0,date,EEEE}, dia {1}
-show_selection=Mostrar Seleção
-date_ordinal_1=1
-date_ordinal_2=2
-date_ordinal_3=3
-date_ordinal_4=4
-date_ordinal_5=5
-date_ordinal_6=6
-date_ordinal_7=7
-date_ordinal_8=8
-date_ordinal_9=9
-date_ordinal_10=10
-date_ordinal_11=11
-date_ordinal_12=12
-date_ordinal_13=13
-date_ordinal_14=14
-date_ordinal_15=15
-date_ordinal_16=16
-date_ordinal_17=17
-date_ordinal_18=18
-date_ordinal_19=19
-date_ordinal_20=20
-date_ordinal_21=21
-date_ordinal_22=22
-date_ordinal_23=23
-date_ordinal_24=24
-date_ordinal_25=25
-date_ordinal_26=26
-date_ordinal_27=27
-date_ordinal_28=28
-date_ordinal_29=29
-date_ordinal_30=30
-date_ordinal_31=31
+null_text.date=
+null_text.time=
+accept.text=OK
+cancel.text=Cancelar
+clear.text=Limpar
+nav_current_day=Ir Para a Data Atual
+nav_current_time=Ir Para a Hora Atual
+nav_prev_month=Mês Anterior
+nav_next_month=Próximo Mês
+nav_prev_year=Ano Anterior
+nav_next_year=Próximo Ano
+today.text=Hoje
+today_verbose.text=Hoje é {0,date,EEEE}, dia {1}
+show_selection=Mostrar Seleção
+date_ordinal_1=1
+date_ordinal_2=2
+date_ordinal_3=3
+date_ordinal_4=4
+date_ordinal_5=5
+date_ordinal_6=6
+date_ordinal_7=7
+date_ordinal_8=8
+date_ordinal_9=9
+date_ordinal_10=10
+date_ordinal_11=11
+date_ordinal_12=12
+date_ordinal_13=13
+date_ordinal_14=14
+date_ordinal_15=15
+date_ordinal_16=16
+date_ordinal_17=17
+date_ordinal_18=18
+date_ordinal_19=19
+date_ordinal_20=20
+date_ordinal_21=21
+date_ordinal_22=22
+date_ordinal_23=23
+date_ordinal_24=24
+date_ordinal_25=25
+date_ordinal_26=26
+date_ordinal_27=27
+date_ordinal_28=28
+date_ordinal_29=29
+date_ordinal_30=30
+date_ordinal_31=31
diff --git a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_ru.properties b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_ru.properties
index de82a69f7..f9da0a25d 100644
--- a/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_ru.properties
+++ b/widgets/cdatetime/org.eclipse.nebula.widgets.cdatetime/src/org/eclipse/nebula/widgets/cdatetime/messages_ru.properties
@@ -1,89 +1,89 @@
-
-accept.text = \u041F\u0440\u0438\u043D\u044F\u0442\u044C
-
-cancel.text = \u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C
-
-clear.text = \u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C
-
-date_ordinal_1 = 1
-
-date_ordinal_10 = 10
-
-date_ordinal_11 = 11
-
-date_ordinal_12 = 12
-
-date_ordinal_13 = 13
-
-date_ordinal_14 = 14
-
-date_ordinal_15 = 15
-
-date_ordinal_16 = 16
-
-date_ordinal_17 = 17
-
-date_ordinal_18 = 18
-
-date_ordinal_19 = 19
-
-date_ordinal_2 = 2
-
-date_ordinal_20 = 20
-
-date_ordinal_21 = 21
-
-date_ordinal_22 = 22
-
-date_ordinal_23 = 23
-
-date_ordinal_24 = 24
-
-date_ordinal_25 = 25
-
-date_ordinal_26 = 26
-
-date_ordinal_27 = 27
-
-date_ordinal_28 = 28
-
-date_ordinal_29 = 29
-
-date_ordinal_3 = 3
-
-date_ordinal_30 = 30
-
-date_ordinal_31 = 31
-
-date_ordinal_4 = 4
-
-date_ordinal_5 = 5
-
-date_ordinal_6 = 6
-
-date_ordinal_7 = 7
-
-date_ordinal_8 = 8
-
-date_ordinal_9 = 9
-
-nav_current_day = \u041F\u0435\u0440\u0435\u0439\u0442\u0438 \u043A \u0441\u0435\u0433\u043E\u0434\u043D\u044F\u0448\u043D\u0435\u0439 \u0434\u0430\u0442\u0435
-
-nav_current_time = \u0423\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C \u0442\u0435\u043A\u0443\u0449\u0435\u0435 \u0432\u0440\u0435\u043C\u044F
-
-nav_next_month = \u0421\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0439 \u043C\u0435\u0441\u044F\u0446
-
-nav_next_year = \u0421\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0439 \u0433\u043E\u0434
-
-nav_prev_month = \u041F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0438\u0439 \u043C\u0435\u0441\u044F\u0446
-
-nav_prev_year = \u041F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0438\u0439 \u0433\u043E\u0434
-
-null_text.date = <\u0432\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0434\u0430\u0442\u0443>
-null_text.time = <\u0432\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0432\u0440\u0435\u043C\u044F>
-
-show_selection = \u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0432\u044B\u0431\u0440\u0430\u043D\u043D\u044B\u0435 \u0434\u0430\u0442\u0443 \u0438 \u0432\u0440\u0435\u043C\u044F
-
-today.text = \u0421\u0435\u0433\u043E\u0434\u043D\u044F
-
-today_verbose.text = \u0421\u0435\u0433\u043E\u0434\u043D\u044F {0,date,EEEE, d MMM.}
+
+accept.text = \u041F\u0440\u0438\u043D\u044F\u0442\u044C
+
+cancel.text = \u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C
+
+clear.text = \u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C
+
+date_ordinal_1 = 1
+
+date_ordinal_10 = 10
+
+date_ordinal_11 = 11
+
+date_ordinal_12 = 12
+
+date_ordinal_13 = 13
+
+date_ordinal_14 = 14
+
+date_ordinal_15 = 15
+
+date_ordinal_16 = 16
+
+date_ordinal_17 = 17
+
+date_ordinal_18 = 18
+
+date_ordinal_19 = 19
+
+date_ordinal_2 = 2
+
+date_ordinal_20 = 20
+
+date_ordinal_21 = 21
+
+date_ordinal_22 = 22
+
+date_ordinal_23 = 23
+
+date_ordinal_24 = 24
+
+date_ordinal_25 = 25
+
+date_ordinal_26 = 26
+
+date_ordinal_27 = 27
+
+date_ordinal_28 = 28
+
+date_ordinal_29 = 29
+
+date_ordinal_3 = 3
+
+date_ordinal_30 = 30
+
+date_ordinal_31 = 31
+
+date_ordinal_4 = 4
+
+date_ordinal_5 = 5
+
+date_ordinal_6 = 6
+
+date_ordinal_7 = 7
+
+date_ordinal_8 = 8
+
+date_ordinal_9 = 9
+
+nav_current_day = \u041F\u0435\u0440\u0435\u0439\u0442\u0438 \u043A \u0441\u0435\u0433\u043E\u0434\u043D\u044F\u0448\u043D\u0435\u0439 \u0434\u0430\u0442\u0435
+
+nav_current_time = \u0423\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C \u0442\u0435\u043A\u0443\u0449\u0435\u0435 \u0432\u0440\u0435\u043C\u044F
+
+nav_next_month = \u0421\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0439 \u043C\u0435\u0441\u044F\u0446
+
+nav_next_year = \u0421\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0439 \u0433\u043E\u0434
+
+nav_prev_month = \u041F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0438\u0439 \u043C\u0435\u0441\u044F\u0446
+
+nav_prev_year = \u041F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0438\u0439 \u0433\u043E\u0434
+
+null_text.date = <\u0432\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0434\u0430\u0442\u0443>
+null_text.time = <\u0432\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0432\u0440\u0435\u043C\u044F>
+
+show_selection = \u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0432\u044B\u0431\u0440\u0430\u043D\u043D\u044B\u0435 \u0434\u0430\u0442\u0443 \u0438 \u0432\u0440\u0435\u043C\u044F
+
+today.text = \u0421\u0435\u0433\u043E\u0434\u043D\u044F
+
+today_verbose.text = \u0421\u0435\u0433\u043E\u0434\u043D\u044F {0,date,EEEE, d MMM.}
diff --git a/widgets/chips/org.eclipse.nebula.widgets.chips.feature/.project b/widgets/chips/org.eclipse.nebula.widgets.chips.feature/.project
index 7e8bc136f..3614e50d6 100644
--- a/widgets/chips/org.eclipse.nebula.widgets.chips.feature/.project
+++ b/widgets/chips/org.eclipse.nebula.widgets.chips.feature/.project
@@ -1,17 +1,17 @@
-
-
- org.eclipse.nebula.widgets.chips.feature
-
-
-
-
-
- org.eclipse.pde.FeatureBuilder
-
-
-
-
-
- org.eclipse.pde.FeatureNature
-
-
+
+
+ org.eclipse.nebula.widgets.chips.feature
+
+
+
+
+
+ org.eclipse.pde.FeatureBuilder
+
+
+
+
+
+ org.eclipse.pde.FeatureNature
+
+
diff --git a/widgets/chips/org.eclipse.nebula.widgets.chips.feature/build.properties b/widgets/chips/org.eclipse.nebula.widgets.chips.feature/build.properties
index f9fa03db0..b40f03f72 100644
--- a/widgets/chips/org.eclipse.nebula.widgets.chips.feature/build.properties
+++ b/widgets/chips/org.eclipse.nebula.widgets.chips.feature/build.properties
@@ -1,4 +1,4 @@
-bin.includes = feature.xml,\
- epl-2.0.html,\
- feature.properties,\
- license.html
+bin.includes = feature.xml,\
+ epl-2.0.html,\
+ feature.properties,\
+ license.html
diff --git a/widgets/chips/org.eclipse.nebula.widgets.chips.feature/feature.properties b/widgets/chips/org.eclipse.nebula.widgets.chips.feature/feature.properties
index ce26a1b1f..9dd2dd546 100644
--- a/widgets/chips/org.eclipse.nebula.widgets.chips.feature/feature.properties
+++ b/widgets/chips/org.eclipse.nebula.widgets.chips.feature/feature.properties
@@ -1,148 +1,148 @@
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-licenseURL=license.html
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-license=\
-Eclipse Foundation Software User Agreement\n\
-\n\
-November 22, 2017\n\
-\n\
-Usage Of Content\n\
-\n\
-THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION\n\
-AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF\n\
-THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE\n\
-TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
-BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED\n\
-BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE\n\
-AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY\n\
-APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU\n\
-MAY NOT USE THE CONTENT.\n\
-\n\
-Applicable Licenses\n\
-\n\
-Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\
-is provided to you under the terms and conditions of the Eclipse Public License\n\
-Version 2.0 ("EPL"). A copy of the EPL is provided with this Content and is also\n\
-available at http://www.eclipse.org/legal/epl-2.0. For purposes of the EPL,\n\
-"Program" will mean the Content.\n\
-\n\
-Content includes, but is not limited to, source code, object code, documentation\n\
-and other files maintained in the Eclipse Foundation source code repository\n\
-("Repository") in software modules ("Modules") and made available as\n\
-downloadable archives ("Downloads").\n\
-\n\
-- Content may be structured and packaged into modules to facilitate\n\
- delivering, extending, and upgrading the Content. Typical modules may\n\
- include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and\n\
- features ("Features").\n\
-- Each Plug-in or Fragment may be packaged as a sub-directory or JAR\n\
- (Java\u2122 ARchive) in a directory named "plugins".\n\
-- A Feature is a bundle of one or more Plug-ins and/or Fragments and\n\
- associated material. Each Feature may be packaged as a sub-directory in a\n\
- directory named "features". Within a Feature, files named "feature.xml" may\n\
- contain a list of the names and version numbers of the Plug-ins and/or\n\
- Fragments associated with that Feature.\n\
-- Features may also include other Features ("Included Features"). Within a\n\
- Feature, files named "feature.xml" may contain a list of the names and\n\
- version numbers of Included Features.\n\
-\n\
-The terms and conditions governing Plug-ins and Fragments should be contained in\n\
-files named "about.html" ("Abouts"). The terms and conditions governing Features\n\
-and Included Features should be contained in files named "license.html"\n\
-("Feature Licenses"). Abouts and Feature Licenses may be located in any\n\
-directory of a Download or Module including, but not limited to the following\n\
-locations:\n\
-\n\
-- The top-level (root) directory\n\
-- Plug-in and Fragment directories\n\
-- Inside Plug-ins and Fragments packaged as JARs\n\
-- Sub-directories of the directory named "src" of certain Plug-ins\n\
-- Feature directories\n\
-\n\
-Note: if a Feature made available by the Eclipse Foundation is installed using\n\
-the Provisioning Technology (as defined below), you must agree to a license\n\
-("Feature Update License") during the installation process. If the Feature\n\
-contains Included Features, the Feature Update License should either provide you\n\
-with the terms and conditions governing the Included Features or inform you\n\
-where you can locate them. Feature Update Licenses may be found in the "license"\n\
-property of files named "feature.properties" found within a Feature. Such\n\
-Abouts, Feature Licenses, and Feature Update Licenses contain the terms and\n\
-conditions (or references to such terms and conditions) that govern your use of\n\
-the associated Content in that directory.\n\
-\n\
-THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL\n\
-OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE\n\
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
-\n\
-- Eclipse Public License Version 1.0 (available at\n\
- http://www.eclipse.org/legal/epl-v10.html)\n\
-- Eclipse Distribution License Version 1.0 (available at\n\
- http://www.eclipse.org/licenses/edl-v1.0.html)\n\
-- Common Public License Version 1.0 (available at\n\
- http://www.eclipse.org/legal/cpl-v10.html)\n\
-- Apache Software License 1.1 (available at\n\
- http://www.apache.org/licenses/LICENSE)\n\
-- Apache Software License 2.0 (available at\n\
- http://www.apache.org/licenses/LICENSE-2.0)\n\
-- Mozilla Public License Version 1.1 (available at\n\
- http://www.mozilla.org/MPL/MPL-1.1.html)\n\
-\n\
-IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO\n\
-USE OF THE CONTENT. If no About, Feature License, or Feature Update License is\n\
-provided, please contact the Eclipse Foundation to determine what terms and\n\
-conditions govern that particular Content.\n\
-\n\
-Use of Provisioning Technology\n\
-\n\
-The Eclipse Foundation makes available provisioning software, examples of which\n\
-include, but are not limited to, p2 and the Eclipse Update Manager\n\
-("Provisioning Technology") for the purpose of allowing users to install\n\
-software, documentation, information and/or other materials (collectively\n\
-"Installable Software"). This capability is provided with the intent of allowing\n\
-such users to install, extend and update Eclipse-based products. Information\n\
-about packaging Installable Software is available at\n\
-http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\
-\n\
-You may use Provisioning Technology to allow other parties to install\n\
-Installable Software. You shall be responsible for enabling the applicable\n\
-license agreements relating to the Installable Software to be presented to, and\n\
-accepted by, the users of the Provisioning Technology in accordance with the\n\
-Specification. By using Provisioning Technology in such a manner and making it\n\
-available in accordance with the Specification, you further acknowledge your\n\
-agreement to, and the acquisition of all necessary rights to permit the\n\
-following:\n\
-\n\
-1. A series of actions may occur ("Provisioning Process") in which a user may\n\
- execute the Provisioning Technology on a machine ("Target Machine") with the\n\
- intent of installing, extending or updating the functionality of an\n\
- Eclipse-based product.\n\
-2. During the Provisioning Process, the Provisioning Technology may cause third\n\
- party Installable Software or a portion thereof to be accessed and copied to\n\
- the Target Machine.\n\
-3. Pursuant to the Specification, you will provide to the user the terms and\n\
- conditions that govern the use of the Installable Software ("Installable\n\
- Software Agreement") and such Installable Software Agreement shall be\n\
- accessed from the Target Machine in accordance with the Specification. Such\n\
- Installable Software Agreement must inform the user of the terms and\n\
- conditions that govern the Installable Software and must solicit acceptance\n\
- by the end user in the manner prescribed in such Installable\n\
- Software Agreement. Upon such indication of agreement by the user, the\n\
- provisioning Technology will complete installation of the\n\
- Installable Software.\n\
-\n\
-Cryptography\n\
-\n\
-Content may contain encryption software. The country in which you are currently\n\
-may have restrictions on the import, possession, and use, and/or re-export to\n\
-another country, of encryption software. BEFORE using any encryption software,\n\
-please check the country's laws, regulations and policies concerning the import,\n\
-possession, or use, and re-export of encryption software, to see if this is\n\
-permitted.\n\
-\n\
-Java and all Java-based trademarks are trademarks of Oracle Corporation in the\n\
-United States, other countries, or both.\n
-########### end of license property ##########################################
+# "licenseURL" property - URL of the "Feature License"
+# do not translate value - just change to point to a locale-specific HTML page
+licenseURL=license.html
+
+# "license" property - text of the "Feature Update License"
+# should be plain text version of license agreement pointed to be "licenseURL"
+license=\
+Eclipse Foundation Software User Agreement\n\
+\n\
+November 22, 2017\n\
+\n\
+Usage Of Content\n\
+\n\
+THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION\n\
+AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF\n\
+THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE\n\
+TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
+BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED\n\
+BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE\n\
+AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
+TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY\n\
+APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU\n\
+MAY NOT USE THE CONTENT.\n\
+\n\
+Applicable Licenses\n\
+\n\
+Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\
+is provided to you under the terms and conditions of the Eclipse Public License\n\
+Version 2.0 ("EPL"). A copy of the EPL is provided with this Content and is also\n\
+available at http://www.eclipse.org/legal/epl-2.0. For purposes of the EPL,\n\
+"Program" will mean the Content.\n\
+\n\
+Content includes, but is not limited to, source code, object code, documentation\n\
+and other files maintained in the Eclipse Foundation source code repository\n\
+("Repository") in software modules ("Modules") and made available as\n\
+downloadable archives ("Downloads").\n\
+\n\
+- Content may be structured and packaged into modules to facilitate\n\
+ delivering, extending, and upgrading the Content. Typical modules may\n\
+ include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and\n\
+ features ("Features").\n\
+- Each Plug-in or Fragment may be packaged as a sub-directory or JAR\n\
+ (Java\u2122 ARchive) in a directory named "plugins".\n\
+- A Feature is a bundle of one or more Plug-ins and/or Fragments and\n\
+ associated material. Each Feature may be packaged as a sub-directory in a\n\
+ directory named "features". Within a Feature, files named "feature.xml" may\n\
+ contain a list of the names and version numbers of the Plug-ins and/or\n\
+ Fragments associated with that Feature.\n\
+- Features may also include other Features ("Included Features"). Within a\n\
+ Feature, files named "feature.xml" may contain a list of the names and\n\
+ version numbers of Included Features.\n\
+\n\
+The terms and conditions governing Plug-ins and Fragments should be contained in\n\
+files named "about.html" ("Abouts"). The terms and conditions governing Features\n\
+and Included Features should be contained in files named "license.html"\n\
+("Feature Licenses"). Abouts and Feature Licenses may be located in any\n\
+directory of a Download or Module including, but not limited to the following\n\
+locations:\n\
+\n\
+- The top-level (root) directory\n\
+- Plug-in and Fragment directories\n\
+- Inside Plug-ins and Fragments packaged as JARs\n\
+- Sub-directories of the directory named "src" of certain Plug-ins\n\
+- Feature directories\n\
+\n\
+Note: if a Feature made available by the Eclipse Foundation is installed using\n\
+the Provisioning Technology (as defined below), you must agree to a license\n\
+("Feature Update License") during the installation process. If the Feature\n\
+contains Included Features, the Feature Update License should either provide you\n\
+with the terms and conditions governing the Included Features or inform you\n\
+where you can locate them. Feature Update Licenses may be found in the "license"\n\
+property of files named "feature.properties" found within a Feature. Such\n\
+Abouts, Feature Licenses, and Feature Update Licenses contain the terms and\n\
+conditions (or references to such terms and conditions) that govern your use of\n\
+the associated Content in that directory.\n\
+\n\
+THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL\n\
+OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE\n\
+OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
+\n\
+- Eclipse Public License Version 1.0 (available at\n\
+ http://www.eclipse.org/legal/epl-v10.html)\n\
+- Eclipse Distribution License Version 1.0 (available at\n\
+ http://www.eclipse.org/licenses/edl-v1.0.html)\n\
+- Common Public License Version 1.0 (available at\n\
+ http://www.eclipse.org/legal/cpl-v10.html)\n\
+- Apache Software License 1.1 (available at\n\
+ http://www.apache.org/licenses/LICENSE)\n\
+- Apache Software License 2.0 (available at\n\
+ http://www.apache.org/licenses/LICENSE-2.0)\n\
+- Mozilla Public License Version 1.1 (available at\n\
+ http://www.mozilla.org/MPL/MPL-1.1.html)\n\
+\n\
+IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO\n\
+USE OF THE CONTENT. If no About, Feature License, or Feature Update License is\n\
+provided, please contact the Eclipse Foundation to determine what terms and\n\
+conditions govern that particular Content.\n\
+\n\
+Use of Provisioning Technology\n\
+\n\
+The Eclipse Foundation makes available provisioning software, examples of which\n\
+include, but are not limited to, p2 and the Eclipse Update Manager\n\
+("Provisioning Technology") for the purpose of allowing users to install\n\
+software, documentation, information and/or other materials (collectively\n\
+"Installable Software"). This capability is provided with the intent of allowing\n\
+such users to install, extend and update Eclipse-based products. Information\n\
+about packaging Installable Software is available at\n\
+http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\
+\n\
+You may use Provisioning Technology to allow other parties to install\n\
+Installable Software. You shall be responsible for enabling the applicable\n\
+license agreements relating to the Installable Software to be presented to, and\n\
+accepted by, the users of the Provisioning Technology in accordance with the\n\
+Specification. By using Provisioning Technology in such a manner and making it\n\
+available in accordance with the Specification, you further acknowledge your\n\
+agreement to, and the acquisition of all necessary rights to permit the\n\
+following:\n\
+\n\
+1. A series of actions may occur ("Provisioning Process") in which a user may\n\
+ execute the Provisioning Technology on a machine ("Target Machine") with the\n\
+ intent of installing, extending or updating the functionality of an\n\
+ Eclipse-based product.\n\
+2. During the Provisioning Process, the Provisioning Technology may cause third\n\
+ party Installable Software or a portion thereof to be accessed and copied to\n\
+ the Target Machine.\n\
+3. Pursuant to the Specification, you will provide to the user the terms and\n\
+ conditions that govern the use of the Installable Software ("Installable\n\
+ Software Agreement") and such Installable Software Agreement shall be\n\
+ accessed from the Target Machine in accordance with the Specification. Such\n\
+ Installable Software Agreement must inform the user of the terms and\n\
+ conditions that govern the Installable Software and must solicit acceptance\n\
+ by the end user in the manner prescribed in such Installable\n\
+ Software Agreement. Upon such indication of agreement by the user, the\n\
+ provisioning Technology will complete installation of the\n\
+ Installable Software.\n\
+\n\
+Cryptography\n\
+\n\
+Content may contain encryption software. The country in which you are currently\n\
+may have restrictions on the import, possession, and use, and/or re-export to\n\
+another country, of encryption software. BEFORE using any encryption software,\n\
+please check the country's laws, regulations and policies concerning the import,\n\
+possession, or use, and re-export of encryption software, to see if this is\n\
+permitted.\n\
+\n\
+Java and all Java-based trademarks are trademarks of Oracle Corporation in the\n\
+United States, other countries, or both.\n
+########### end of license property ##########################################
diff --git a/widgets/chips/org.eclipse.nebula.widgets.chips.feature/feature.xml b/widgets/chips/org.eclipse.nebula.widgets.chips.feature/feature.xml
index 8f7e36b7c..cf9a97b9a 100644
--- a/widgets/chips/org.eclipse.nebula.widgets.chips.feature/feature.xml
+++ b/widgets/chips/org.eclipse.nebula.widgets.chips.feature/feature.xml
@@ -1,34 +1,34 @@
-
-
-
-
- Chips Widget
-
-
-
- %license
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ Chips Widget
+
+
+
+ %license
+
+
+
+
+
+
+
+
+
+
+
diff --git a/widgets/chips/org.eclipse.nebula.widgets.chips.feature/pom.xml b/widgets/chips/org.eclipse.nebula.widgets.chips.feature/pom.xml
index 9a5744395..95325b749 100644
--- a/widgets/chips/org.eclipse.nebula.widgets.chips.feature/pom.xml
+++ b/widgets/chips/org.eclipse.nebula.widgets.chips.feature/pom.xml
@@ -1,31 +1,31 @@
-
-
-
- 4.0.0
-
-
- org.eclipse.nebula
- chips
- 1.0.0-SNAPSHOT
-
-
- org.eclipse.nebula.widgets.chips.feature
- eclipse-feature
- 1.0.0-SNAPSHOT
-
- Nebula Chips Feature
-
-
+
+
+
+ 4.0.0
+
+
+ org.eclipse.nebula
+ chips
+ 1.0.0-SNAPSHOT
+
+
+ org.eclipse.nebula.widgets.chips.feature
+ eclipse-feature
+ 1.0.0-SNAPSHOT
+
+ Nebula Chips Feature
+
+
diff --git a/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/.classpath b/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/.classpath
index ca3785c41..e801ebfb4 100644
--- a/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/.classpath
+++ b/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/.classpath
@@ -1,7 +1,7 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/.project b/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/.project
index 97576d320..e21a1652b 100644
--- a/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/.project
+++ b/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/.project
@@ -1,28 +1,28 @@
-
-
- org.eclipse.nebula.widgets.chips.snippets
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
-
- org.eclipse.pde.PluginNature
- org.eclipse.jdt.core.javanature
-
-
+
+
+ org.eclipse.nebula.widgets.chips.snippets
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/.settings/org.eclipse.jdt.core.prefs b/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/.settings/org.eclipse.jdt.core.prefs
index 11265a345..7adc0fb9a 100644
--- a/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/.settings/org.eclipse.jdt.core.prefs
+++ b/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,10 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
-org.eclipse.jdt.core.compiler.compliance=11
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
-org.eclipse.jdt.core.compiler.release=enabled
-org.eclipse.jdt.core.compiler.source=11
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
+org.eclipse.jdt.core.compiler.compliance=11
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=11
diff --git a/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/META-INF/MANIFEST.MF b/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/META-INF/MANIFEST.MF
index 74acb8648..e97980c74 100644
--- a/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/META-INF/MANIFEST.MF
+++ b/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/META-INF/MANIFEST.MF
@@ -1,10 +1,10 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Nebula Chips Snippets
-Bundle-SymbolicName: org.eclipse.nebula.widgets.chips.snippets
-Bundle-Version: 1.0.0.qualifier
-Bundle-Vendor: Eclipse Nebula
-Bundle-RequiredExecutionEnvironment: JavaSE-11
-Require-Bundle: org.eclipse.nebula.widgets.chips;bundle-version="1.0.0",
- org.eclipse.swt
-Automatic-Module-Name: org.eclipse.nebula.widgets.chips.snippets
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Nebula Chips Snippets
+Bundle-SymbolicName: org.eclipse.nebula.widgets.chips.snippets
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: Eclipse Nebula
+Bundle-RequiredExecutionEnvironment: JavaSE-11
+Require-Bundle: org.eclipse.nebula.widgets.chips;bundle-version="1.0.0",
+ org.eclipse.swt
+Automatic-Module-Name: org.eclipse.nebula.widgets.chips.snippets
diff --git a/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/build.properties b/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/build.properties
index 41eb6ade2..34d2e4d2d 100644
--- a/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/build.properties
+++ b/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/build.properties
@@ -1,4 +1,4 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/pom.xml b/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/pom.xml
index e78b35fa8..0c31cb9aa 100644
--- a/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/pom.xml
+++ b/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/pom.xml
@@ -1,24 +1,24 @@
-
-
-
- 4.0.0
-
-
- org.eclipse.nebula
- chips
- 1.0.0-SNAPSHOT
-
-
- org.eclipse.nebula.widgets.chips.snippets
- eclipse-plugin
-
-
+
+
+
+ 4.0.0
+
+
+ org.eclipse.nebula
+ chips
+ 1.0.0-SNAPSHOT
+
+
+ org.eclipse.nebula.widgets.chips.snippets
+ eclipse-plugin
+
+
diff --git a/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/src/org/eclipse/nebula/widgets/chips/ChipsSnippet.java b/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/src/org/eclipse/nebula/widgets/chips/ChipsSnippet.java
index d421fdb13..1e007ea7c 100644
--- a/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/src/org/eclipse/nebula/widgets/chips/ChipsSnippet.java
+++ b/widgets/chips/org.eclipse.nebula.widgets.chips.snippets/src/org/eclipse/nebula/widgets/chips/ChipsSnippet.java
@@ -1,341 +1,341 @@
-/*******************************************************************************
- * Copyright (c) 2020 Laurent CARON.
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors: Laurent CARON (laurent.caron at gmail dot com) - initial API and
- * implementation
- *******************************************************************************/
-package org.eclipse.nebula.widgets.chips;
-
-import org.eclipse.nebula.widgets.opal.commons.SWTGraphicUtil;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Snippet for the Chips widget
- */
-public class ChipsSnippet {
-
- private static Shell shell;
-
- /**
- * @param args
- */
- public static void main(final String[] args) {
- final Display display = new Display();
- shell = new Shell(display);
- shell.setText("Chips Snippet");
- shell.setLayout(new GridLayout(1, false));
- shell.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
-
- createColoredChipsArea();
- createCloseChipsArea();
- createCloseImageChipsArea();
- createCheckedChipsArea();
- createPushChipsArea();
-
- shell.pack();
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
-
- display.dispose();
-
- }
-
- private static void createColoredChipsArea() {
- final Label lbl = new Label(shell, SWT.CENTER);
- lbl.setText("Colored chips (Eclipse Projects) - Read Only");
- lbl.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- final Composite cmp = new Composite(shell, SWT.NONE);
- cmp.setLayoutData(new GridData(GridData.CENTER, GridData.FILL, false, false));
- cmp.setLayout(new GridLayout(5, false));
- cmp.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
-
- final Chips chip1 = new Chips(cmp, SWT.NONE);
- chip1.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip1.setChipsBackground(SWTGraphicUtil.getColorSafely(227, 22, 91));
- chip1.setText("Equinox");
- chip1.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
-
- final Chips chip2 = new Chips(cmp, SWT.NONE);
- chip2.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip2.setChipsBackground(SWTGraphicUtil.getColorSafely(3, 120, 213));
- chip2.setText("Nebula");
- chip2.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
-
- final Chips chip3 = new Chips(cmp, SWT.NONE);
- chip3.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip3.setChipsBackground(SWTGraphicUtil.getColorSafely(77, 132, 29));
- chip3.setText("XText");
- chip3.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
-
- final Chips chip4 = new Chips(cmp, SWT.NONE);
- chip4.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip4.setChipsBackground(SWTGraphicUtil.getColorSafely(214, 65, 19));
- chip4.setText("Wild Web Developer");
- chip4.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
-
- final Chips chip5 = new Chips(cmp, SWT.NONE);
- chip5.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip5.setChipsBackground(SWTGraphicUtil.getColorSafely(193, 87, 0));
- chip5.setText("JDT");
- chip5.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- }
-
- private static void createCloseChipsArea() {
- final Label lbl = new Label(shell, SWT.CENTER);
- lbl.setText("Close chips (Eclipse Fundation Members)");
- lbl.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- final Composite cmp = new Composite(shell, SWT.NONE);
- cmp.setLayoutData(new GridData(GridData.CENTER, GridData.FILL, false, false));
- cmp.setLayout(new GridLayout(4, false));
- cmp.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
-
- final Color bgColor = SWTGraphicUtil.getColorSafely(224, 224, 244);
-
- final Chips chip1 = new Chips(cmp, SWT.CLOSE);
- chip1.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip1.setChipsBackground(bgColor);
- chip1.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip1.setText("IBM");
-
- final Chips chip2 = new Chips(cmp, SWT.CLOSE);
- chip2.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip2.setChipsBackground(bgColor);
- chip2.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip2.setText("Red Hat");
-
- final Chips chip3 = new Chips(cmp, SWT.CLOSE);
- chip3.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip3.setChipsBackground(bgColor);
- chip3.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip3.setText("Remain Software");
-
- final Chips chip4 = new Chips(cmp, SWT.CLOSE);
- chip4.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip4.setChipsBackground(bgColor);
- chip4.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip4.setText("Vogella");
-
- final CloseListener closeListener = event -> {
- final Chips chip = (Chips) event.widget;
- System.out.println("Closed on " + chip.getText());
- chip.dispose();
- cmp.layout(true);
- };
-
- chip1.addCloseListener(closeListener);
- chip2.addCloseListener(closeListener);
- chip3.addCloseListener(closeListener);
- chip4.addCloseListener(closeListener);
- }
-
- private static void createCloseImageChipsArea() {
- final Label lbl = new Label(shell, SWT.CENTER);
- lbl.setText("Close & Images (Nebula Devs)");
- lbl.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- final Composite cmp = new Composite(shell, SWT.NONE);
- cmp.setLayoutData(new GridData(GridData.CENTER, GridData.FILL, false, false));
- cmp.setLayout(new GridLayout(5, false));
- cmp.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
-
- final Color bgColor = SWTGraphicUtil.getColorSafely(224, 224, 244);
-
- final Chips chip1 = new Chips(cmp, SWT.CLOSE);
- chip1.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip1.setChipsBackground(bgColor);
- chip1.setHoverForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip1.setHoverBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip1.setImage(loadImage("dirk.png"));
- chip1.setText("Dirk");
- chip1.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
-
- final Chips chip2 = new Chips(cmp, SWT.CLOSE);
- chip2.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip2.setChipsBackground(bgColor);
- chip2.setHoverForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip2.setHoverBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip2.setImage(loadImage("donald.png"));
- chip2.setText("Donald");
- chip2.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
-
- final Chips chip3 = new Chips(cmp, SWT.CLOSE);
- chip3.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip3.setChipsBackground(bgColor);
- chip3.setHoverForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip3.setHoverBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip3.setImage(loadImage("johannes.png"));
- chip3.setText("Johannes");
- chip3.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
-
- final Chips chip4 = new Chips(cmp, SWT.CLOSE);
- chip4.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip4.setChipsBackground(bgColor);
- chip4.setHoverForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip4.setHoverBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip4.setImage(loadImage("laurent.png"));
- chip4.setText("Laurent");
- chip4.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
-
- final Chips chip5 = new Chips(cmp, SWT.CLOSE);
- chip5.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip5.setChipsBackground(bgColor);
- chip5.setHoverForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip5.setHoverBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip5.setImage(loadImage("wim.png"));
- chip5.setText("Wim");
- chip5.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
-
- final CloseListener closeListener = event -> {
- final Chips chip = (Chips) event.widget;
- System.out.println("Closed on " + chip.getText());
- chip.dispose();
- cmp.layout(true);
- };
-
- chip1.addCloseListener(closeListener);
- chip2.addCloseListener(closeListener);
- chip3.addCloseListener(closeListener);
- chip4.addCloseListener(closeListener);
-
- }
-
- private static Image loadImage(final String img) {
- return new Image(shell.getDisplay(), ChipsSnippet.class.getResourceAsStream(img));
- }
-
- private static void createCheckedChipsArea() {
- final Label lbl = new Label(shell, SWT.CENTER);
- lbl.setText("Checked chips : Skills");
- lbl.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- final Composite cmp = new Composite(shell, SWT.NONE);
- cmp.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
- cmp.setLayout(new GridLayout(5, false));
- cmp.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
-
- final Color bgColor = SWTGraphicUtil.getColorSafely(224, 224, 244);
- final Color checkColor = SWTGraphicUtil.getColorSafely(188, 188, 188);
-
- final Chips chip1 = new Chips(cmp, SWT.CHECK);
- chip1.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip1.setChipsBackground(bgColor);
- chip1.setPushedStateForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip1.setPushedStateBackground(checkColor);
- chip1.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip1.setText("Java");
- chip1.setSelection(true);
- chip1.setLayoutData(new GridData(GridData.END, GridData.FILL, true, false));
-
- final Chips chip2 = new Chips(cmp, SWT.CHECK);
- chip2.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip2.setChipsBackground(bgColor);
- chip2.setPushedStateForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip2.setPushedStateBackground(checkColor);
- chip2.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip2.setText("SWT");
-
- final Chips chip3 = new Chips(cmp, SWT.CHECK);
- chip3.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip3.setChipsBackground(bgColor);
- chip3.setPushedStateForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip3.setPushedStateBackground(checkColor);
- chip3.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip3.setText("JFace");
-
- final Chips chip4 = new Chips(cmp, SWT.CHECK);
- chip4.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip4.setChipsBackground(bgColor);
- chip4.setPushedStateForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip4.setPushedStateBackground(checkColor);
- chip4.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip4.setText("EMF");
- chip4.setLayoutData(new GridData(GridData.BEGINNING, GridData.FILL, true, false));
-
- final Listener listener = event -> {
- final Chips chip = (Chips) event.widget;
- System.out.println("Click on " + chip.getText());
- };
-
- chip1.addListener(SWT.Selection, listener);
- chip2.addListener(SWT.Selection, listener);
- chip3.addListener(SWT.Selection, listener);
- chip4.addListener(SWT.Selection, listener);
-
- }
-
- private static void createPushChipsArea() {
- final Label lbl = new Label(shell, SWT.CENTER);
- lbl.setText("Push chips");
- lbl.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- final Composite cmp = new Composite(shell, SWT.NONE);
- cmp.setLayoutData(new GridData(GridData.CENTER, GridData.FILL, false, false));
- cmp.setLayout(new GridLayout(4, false));
- cmp.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
-
- final Color checkColor = SWTGraphicUtil.getColorSafely(227, 22, 91);
-
- final Chips chip1 = new Chips(cmp, SWT.PUSH);
- chip1.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip1.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip1.setChipsBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip1.setBorderColor(checkColor);
- chip1.setPushedStateForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip1.setPushedStateBackground(checkColor);
- chip1.setImage(loadImage("icons/bubble1_b.png"));
- chip1.setPushImage(loadImage("icons/bubble1_w.png"));
- chip1.setText("One");
-
- final Chips chip2 = new Chips(cmp, SWT.PUSH);
- chip2.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip2.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip2.setChipsBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip2.setPushedStateForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip2.setPushedStateBackground(checkColor);
- chip2.setImage(loadImage("icons/bubble2_b.png"));
- chip2.setPushImage(loadImage("icons/bubble2_w.png"));
- chip2.setBorderColor(checkColor);
-
- chip2.setText("Two");
-
- final Chips chip3 = new Chips(cmp, SWT.PUSH);
- chip3.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip3.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip3.setChipsBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip3.setPushedStateForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip3.setPushedStateBackground(checkColor);
- chip3.setImage(loadImage("icons/bubble3_b.png"));
- chip3.setPushImage(loadImage("icons/bubble3_w.png"));
- chip3.setBorderColor(checkColor);
- chip3.setText("Three");
-
- final Chips chip4 = new Chips(cmp, SWT.PUSH);
- chip4.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chip4.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip4.setChipsBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip4.setPushedStateForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- chip4.setPushedStateBackground(checkColor);
- chip4.setImage(loadImage("icons/email_b.png"));
- chip4.setPushImage(loadImage("icons/email_w.png"));
- chip4.setBorderColor(checkColor);
- chip4.setText("Mail");
-
- }
-
+/*******************************************************************************
+ * Copyright (c) 2020 Laurent CARON.
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors: Laurent CARON (laurent.caron at gmail dot com) - initial API and
+ * implementation
+ *******************************************************************************/
+package org.eclipse.nebula.widgets.chips;
+
+import org.eclipse.nebula.widgets.opal.commons.SWTGraphicUtil;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Snippet for the Chips widget
+ */
+public class ChipsSnippet {
+
+ private static Shell shell;
+
+ /**
+ * @param args
+ */
+ public static void main(final String[] args) {
+ final Display display = new Display();
+ shell = new Shell(display);
+ shell.setText("Chips Snippet");
+ shell.setLayout(new GridLayout(1, false));
+ shell.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+
+ createColoredChipsArea();
+ createCloseChipsArea();
+ createCloseImageChipsArea();
+ createCheckedChipsArea();
+ createPushChipsArea();
+
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+
+ display.dispose();
+
+ }
+
+ private static void createColoredChipsArea() {
+ final Label lbl = new Label(shell, SWT.CENTER);
+ lbl.setText("Colored chips (Eclipse Projects) - Read Only");
+ lbl.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ final Composite cmp = new Composite(shell, SWT.NONE);
+ cmp.setLayoutData(new GridData(GridData.CENTER, GridData.FILL, false, false));
+ cmp.setLayout(new GridLayout(5, false));
+ cmp.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+
+ final Chips chip1 = new Chips(cmp, SWT.NONE);
+ chip1.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip1.setChipsBackground(SWTGraphicUtil.getColorSafely(227, 22, 91));
+ chip1.setText("Equinox");
+ chip1.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+
+ final Chips chip2 = new Chips(cmp, SWT.NONE);
+ chip2.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip2.setChipsBackground(SWTGraphicUtil.getColorSafely(3, 120, 213));
+ chip2.setText("Nebula");
+ chip2.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+
+ final Chips chip3 = new Chips(cmp, SWT.NONE);
+ chip3.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip3.setChipsBackground(SWTGraphicUtil.getColorSafely(77, 132, 29));
+ chip3.setText("XText");
+ chip3.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+
+ final Chips chip4 = new Chips(cmp, SWT.NONE);
+ chip4.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip4.setChipsBackground(SWTGraphicUtil.getColorSafely(214, 65, 19));
+ chip4.setText("Wild Web Developer");
+ chip4.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+
+ final Chips chip5 = new Chips(cmp, SWT.NONE);
+ chip5.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip5.setChipsBackground(SWTGraphicUtil.getColorSafely(193, 87, 0));
+ chip5.setText("JDT");
+ chip5.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ }
+
+ private static void createCloseChipsArea() {
+ final Label lbl = new Label(shell, SWT.CENTER);
+ lbl.setText("Close chips (Eclipse Fundation Members)");
+ lbl.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ final Composite cmp = new Composite(shell, SWT.NONE);
+ cmp.setLayoutData(new GridData(GridData.CENTER, GridData.FILL, false, false));
+ cmp.setLayout(new GridLayout(4, false));
+ cmp.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+
+ final Color bgColor = SWTGraphicUtil.getColorSafely(224, 224, 244);
+
+ final Chips chip1 = new Chips(cmp, SWT.CLOSE);
+ chip1.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip1.setChipsBackground(bgColor);
+ chip1.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip1.setText("IBM");
+
+ final Chips chip2 = new Chips(cmp, SWT.CLOSE);
+ chip2.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip2.setChipsBackground(bgColor);
+ chip2.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip2.setText("Red Hat");
+
+ final Chips chip3 = new Chips(cmp, SWT.CLOSE);
+ chip3.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip3.setChipsBackground(bgColor);
+ chip3.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip3.setText("Remain Software");
+
+ final Chips chip4 = new Chips(cmp, SWT.CLOSE);
+ chip4.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip4.setChipsBackground(bgColor);
+ chip4.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip4.setText("Vogella");
+
+ final CloseListener closeListener = event -> {
+ final Chips chip = (Chips) event.widget;
+ System.out.println("Closed on " + chip.getText());
+ chip.dispose();
+ cmp.layout(true);
+ };
+
+ chip1.addCloseListener(closeListener);
+ chip2.addCloseListener(closeListener);
+ chip3.addCloseListener(closeListener);
+ chip4.addCloseListener(closeListener);
+ }
+
+ private static void createCloseImageChipsArea() {
+ final Label lbl = new Label(shell, SWT.CENTER);
+ lbl.setText("Close & Images (Nebula Devs)");
+ lbl.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ final Composite cmp = new Composite(shell, SWT.NONE);
+ cmp.setLayoutData(new GridData(GridData.CENTER, GridData.FILL, false, false));
+ cmp.setLayout(new GridLayout(5, false));
+ cmp.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+
+ final Color bgColor = SWTGraphicUtil.getColorSafely(224, 224, 244);
+
+ final Chips chip1 = new Chips(cmp, SWT.CLOSE);
+ chip1.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip1.setChipsBackground(bgColor);
+ chip1.setHoverForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip1.setHoverBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip1.setImage(loadImage("dirk.png"));
+ chip1.setText("Dirk");
+ chip1.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+
+ final Chips chip2 = new Chips(cmp, SWT.CLOSE);
+ chip2.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip2.setChipsBackground(bgColor);
+ chip2.setHoverForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip2.setHoverBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip2.setImage(loadImage("donald.png"));
+ chip2.setText("Donald");
+ chip2.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+
+ final Chips chip3 = new Chips(cmp, SWT.CLOSE);
+ chip3.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip3.setChipsBackground(bgColor);
+ chip3.setHoverForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip3.setHoverBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip3.setImage(loadImage("johannes.png"));
+ chip3.setText("Johannes");
+ chip3.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+
+ final Chips chip4 = new Chips(cmp, SWT.CLOSE);
+ chip4.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip4.setChipsBackground(bgColor);
+ chip4.setHoverForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip4.setHoverBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip4.setImage(loadImage("laurent.png"));
+ chip4.setText("Laurent");
+ chip4.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+
+ final Chips chip5 = new Chips(cmp, SWT.CLOSE);
+ chip5.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip5.setChipsBackground(bgColor);
+ chip5.setHoverForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip5.setHoverBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip5.setImage(loadImage("wim.png"));
+ chip5.setText("Wim");
+ chip5.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+
+ final CloseListener closeListener = event -> {
+ final Chips chip = (Chips) event.widget;
+ System.out.println("Closed on " + chip.getText());
+ chip.dispose();
+ cmp.layout(true);
+ };
+
+ chip1.addCloseListener(closeListener);
+ chip2.addCloseListener(closeListener);
+ chip3.addCloseListener(closeListener);
+ chip4.addCloseListener(closeListener);
+
+ }
+
+ private static Image loadImage(final String img) {
+ return new Image(shell.getDisplay(), ChipsSnippet.class.getResourceAsStream(img));
+ }
+
+ private static void createCheckedChipsArea() {
+ final Label lbl = new Label(shell, SWT.CENTER);
+ lbl.setText("Checked chips : Skills");
+ lbl.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ final Composite cmp = new Composite(shell, SWT.NONE);
+ cmp.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
+ cmp.setLayout(new GridLayout(5, false));
+ cmp.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+
+ final Color bgColor = SWTGraphicUtil.getColorSafely(224, 224, 244);
+ final Color checkColor = SWTGraphicUtil.getColorSafely(188, 188, 188);
+
+ final Chips chip1 = new Chips(cmp, SWT.CHECK);
+ chip1.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip1.setChipsBackground(bgColor);
+ chip1.setPushedStateForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip1.setPushedStateBackground(checkColor);
+ chip1.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip1.setText("Java");
+ chip1.setSelection(true);
+ chip1.setLayoutData(new GridData(GridData.END, GridData.FILL, true, false));
+
+ final Chips chip2 = new Chips(cmp, SWT.CHECK);
+ chip2.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip2.setChipsBackground(bgColor);
+ chip2.setPushedStateForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip2.setPushedStateBackground(checkColor);
+ chip2.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip2.setText("SWT");
+
+ final Chips chip3 = new Chips(cmp, SWT.CHECK);
+ chip3.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip3.setChipsBackground(bgColor);
+ chip3.setPushedStateForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip3.setPushedStateBackground(checkColor);
+ chip3.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip3.setText("JFace");
+
+ final Chips chip4 = new Chips(cmp, SWT.CHECK);
+ chip4.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip4.setChipsBackground(bgColor);
+ chip4.setPushedStateForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip4.setPushedStateBackground(checkColor);
+ chip4.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip4.setText("EMF");
+ chip4.setLayoutData(new GridData(GridData.BEGINNING, GridData.FILL, true, false));
+
+ final Listener listener = event -> {
+ final Chips chip = (Chips) event.widget;
+ System.out.println("Click on " + chip.getText());
+ };
+
+ chip1.addListener(SWT.Selection, listener);
+ chip2.addListener(SWT.Selection, listener);
+ chip3.addListener(SWT.Selection, listener);
+ chip4.addListener(SWT.Selection, listener);
+
+ }
+
+ private static void createPushChipsArea() {
+ final Label lbl = new Label(shell, SWT.CENTER);
+ lbl.setText("Push chips");
+ lbl.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ final Composite cmp = new Composite(shell, SWT.NONE);
+ cmp.setLayoutData(new GridData(GridData.CENTER, GridData.FILL, false, false));
+ cmp.setLayout(new GridLayout(4, false));
+ cmp.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+
+ final Color checkColor = SWTGraphicUtil.getColorSafely(227, 22, 91);
+
+ final Chips chip1 = new Chips(cmp, SWT.PUSH);
+ chip1.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip1.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip1.setChipsBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip1.setBorderColor(checkColor);
+ chip1.setPushedStateForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip1.setPushedStateBackground(checkColor);
+ chip1.setImage(loadImage("icons/bubble1_b.png"));
+ chip1.setPushImage(loadImage("icons/bubble1_w.png"));
+ chip1.setText("One");
+
+ final Chips chip2 = new Chips(cmp, SWT.PUSH);
+ chip2.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip2.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip2.setChipsBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip2.setPushedStateForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip2.setPushedStateBackground(checkColor);
+ chip2.setImage(loadImage("icons/bubble2_b.png"));
+ chip2.setPushImage(loadImage("icons/bubble2_w.png"));
+ chip2.setBorderColor(checkColor);
+
+ chip2.setText("Two");
+
+ final Chips chip3 = new Chips(cmp, SWT.PUSH);
+ chip3.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip3.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip3.setChipsBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip3.setPushedStateForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip3.setPushedStateBackground(checkColor);
+ chip3.setImage(loadImage("icons/bubble3_b.png"));
+ chip3.setPushImage(loadImage("icons/bubble3_w.png"));
+ chip3.setBorderColor(checkColor);
+ chip3.setText("Three");
+
+ final Chips chip4 = new Chips(cmp, SWT.PUSH);
+ chip4.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chip4.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip4.setChipsBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip4.setPushedStateForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ chip4.setPushedStateBackground(checkColor);
+ chip4.setImage(loadImage("icons/email_b.png"));
+ chip4.setPushImage(loadImage("icons/email_w.png"));
+ chip4.setBorderColor(checkColor);
+ chip4.setText("Mail");
+
+ }
+
}
\ No newline at end of file
diff --git a/widgets/chips/org.eclipse.nebula.widgets.chips/.classpath b/widgets/chips/org.eclipse.nebula.widgets.chips/.classpath
index ca3785c41..e801ebfb4 100644
--- a/widgets/chips/org.eclipse.nebula.widgets.chips/.classpath
+++ b/widgets/chips/org.eclipse.nebula.widgets.chips/.classpath
@@ -1,7 +1,7 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/widgets/chips/org.eclipse.nebula.widgets.chips/.project b/widgets/chips/org.eclipse.nebula.widgets.chips/.project
index 4a76145bb..94ee36f57 100644
--- a/widgets/chips/org.eclipse.nebula.widgets.chips/.project
+++ b/widgets/chips/org.eclipse.nebula.widgets.chips/.project
@@ -1,28 +1,28 @@
-
-
- org.eclipse.nebula.widgets.chips
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
-
- org.eclipse.pde.PluginNature
- org.eclipse.jdt.core.javanature
-
-
+
+
+ org.eclipse.nebula.widgets.chips
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/widgets/chips/org.eclipse.nebula.widgets.chips/.settings/org.eclipse.jdt.core.prefs b/widgets/chips/org.eclipse.nebula.widgets.chips/.settings/org.eclipse.jdt.core.prefs
index 11265a345..7adc0fb9a 100644
--- a/widgets/chips/org.eclipse.nebula.widgets.chips/.settings/org.eclipse.jdt.core.prefs
+++ b/widgets/chips/org.eclipse.nebula.widgets.chips/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,10 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
-org.eclipse.jdt.core.compiler.compliance=11
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
-org.eclipse.jdt.core.compiler.release=enabled
-org.eclipse.jdt.core.compiler.source=11
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
+org.eclipse.jdt.core.compiler.compliance=11
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=11
diff --git a/widgets/chips/org.eclipse.nebula.widgets.chips/META-INF/MANIFEST.MF b/widgets/chips/org.eclipse.nebula.widgets.chips/META-INF/MANIFEST.MF
index f9e79d513..30cd11839 100644
--- a/widgets/chips/org.eclipse.nebula.widgets.chips/META-INF/MANIFEST.MF
+++ b/widgets/chips/org.eclipse.nebula.widgets.chips/META-INF/MANIFEST.MF
@@ -1,11 +1,11 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Nebula Chips widget
-Bundle-SymbolicName: org.eclipse.nebula.widgets.chips
-Bundle-Version: 1.0.0.qualifier
-Bundle-Vendor: Eclipse Nebula
-Bundle-RequiredExecutionEnvironment: JavaSE-11
-Export-Package: org.eclipse.nebula.widgets.chips
-Require-Bundle: org.eclipse.nebula.widgets.opal.commons;visibility:=reexport,
- org.eclipse.swt
-Automatic-Module-Name: org.eclipse.nebula.widgets.chips
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Nebula Chips widget
+Bundle-SymbolicName: org.eclipse.nebula.widgets.chips
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: Eclipse Nebula
+Bundle-RequiredExecutionEnvironment: JavaSE-11
+Export-Package: org.eclipse.nebula.widgets.chips
+Require-Bundle: org.eclipse.nebula.widgets.opal.commons;visibility:=reexport,
+ org.eclipse.swt
+Automatic-Module-Name: org.eclipse.nebula.widgets.chips
diff --git a/widgets/chips/org.eclipse.nebula.widgets.chips/build.properties b/widgets/chips/org.eclipse.nebula.widgets.chips/build.properties
index 41eb6ade2..34d2e4d2d 100644
--- a/widgets/chips/org.eclipse.nebula.widgets.chips/build.properties
+++ b/widgets/chips/org.eclipse.nebula.widgets.chips/build.properties
@@ -1,4 +1,4 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/widgets/chips/org.eclipse.nebula.widgets.chips/pom.xml b/widgets/chips/org.eclipse.nebula.widgets.chips/pom.xml
index 419968fd7..3cc63cf8b 100644
--- a/widgets/chips/org.eclipse.nebula.widgets.chips/pom.xml
+++ b/widgets/chips/org.eclipse.nebula.widgets.chips/pom.xml
@@ -1,24 +1,24 @@
-
-
-
- 4.0.0
-
-
- org.eclipse.nebula
- chips
- 1.0.0-SNAPSHOT
-
-
- org.eclipse.nebula.widgets.chips
- eclipse-plugin
-
-
+
+
+
+ 4.0.0
+
+
+ org.eclipse.nebula
+ chips
+ 1.0.0-SNAPSHOT
+
+
+ org.eclipse.nebula.widgets.chips
+ eclipse-plugin
+
+
diff --git a/widgets/chips/org.eclipse.nebula.widgets.chips/src/org/eclipse/nebula/widgets/chips/Chips.java b/widgets/chips/org.eclipse.nebula.widgets.chips/src/org/eclipse/nebula/widgets/chips/Chips.java
index fe032f6c1..8a7ce73c3 100644
--- a/widgets/chips/org.eclipse.nebula.widgets.chips/src/org/eclipse/nebula/widgets/chips/Chips.java
+++ b/widgets/chips/org.eclipse.nebula.widgets.chips/src/org/eclipse/nebula/widgets/chips/Chips.java
@@ -1,1204 +1,1204 @@
-/*******************************************************************************
- * Copyright (c) 2020 Laurent CARON.
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors: Laurent CARON (laurent.caron at gmail dot com) - initial API and
- * implementation
- *******************************************************************************/
-package org.eclipse.nebula.widgets.chips;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.nebula.widgets.opal.commons.SWTGraphicUtil;
-import org.eclipse.nebula.widgets.opal.commons.SelectionListenerUtil;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-
-/**
- * Instances of this class represent a "chips". This is a kind of rounded-shapped button. It can display information,
- * or be used like a check or a push button. You can also add a close button.
- *
- *
- *
Styles:
- *
SWT.CLOSE
- *
SWT.CHECK
- *
SWT.PUSH
- *
Events:
- *
SWT.Close, SWT.Selection
- *
- */
-public class Chips extends Canvas {
-
- private static final int CLOSE_CIRCLE_RAY = 7;
-
- private Color hoverForeground, hoverBackground;
- private Color closeButtonForeground, closeButtonBackground;
- private Color closeButtonHoverForeground, closeButtonHoverBackground;
- private Color pushedStateForeground, pushedStateBackground;
- private Color borderColor, hoverBorderColor, pushedStateBorderColor;
- private Color chipsBackground;
- private String text;
- private Image image, pushImage, hoverImage;
- private boolean selection;
- private final boolean isCheck;
- private final boolean isPush;
- private final boolean isClose;
- private final List closeListeners = new ArrayList<>();
- private boolean cursorInside;
- private Point closeCenter;
-
- /**
- * Constructs a new instance of this class given its parent and a style value
- * describing its behavior and appearance.
- *
- * The style value is either one of the style constants defined in class
- * SWT which is applicable to instances of this class, or must be
- * built by bitwise OR'ing together (that is, using the
- * int "|" operator) two or more of those SWT style
- * constants. The class description lists the style constants that are
- * applicable to the class. Style bits are also inherited from superclasses.
- *
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_NULL_ARGUMENT - if the parent is null
- *
- * @exception SWTException
- *
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the parent
- *
ERROR_INVALID_SUBCLASS - if this class is not an allowed
- * subclass
- *
- *
- */
- public Chips(final Composite parent, final int style) {
- super(parent, checkStyle(style));
- initDefaultColors();
- text = "";
- isCheck = (getStyle() & SWT.CHECK) != 0;
- isPush = (getStyle() & SWT.PUSH) != 0;
- isClose = (getStyle() & SWT.CLOSE) != 0;
-
- addListener(SWT.Paint, e -> {
- final GC gc = e.gc;
- gc.setFont(getFont());
- gc.setAdvanced(true);
- gc.setTextAntialias(SWT.ON);
- gc.setAntialias(SWT.ON);
- final Color previousForeground = gc.getForeground();
- final Color previousBackground = gc.getBackground();
-
- int x = drawBackground(gc);
- drawWidgetBorder(gc);
- if (isCheck && selection) {
- x = drawCheck(gc, x);
- }
-
- if (image != null) {
- x = drawImage(gc, x);
- }
-
- if (text != null) {
- x = drawText(gc, x);
- }
-
- if (isClose) {
- drawClose(gc, x);
- }
- gc.setBackground(previousBackground);
- gc.setForeground(previousForeground);
-
- });
-
- addListener(SWT.MouseEnter, e -> {
- cursorInside = isPush || isCheck || isClose;
- if (cursorInside) {
- setCursor(getDisplay().getSystemCursor(SWT.CURSOR_HAND));
- }
- redraw();
- });
- addListener(SWT.MouseExit, e -> {
- cursorInside = false;
- if (isPush || isCheck || isClose) {
- setCursor(getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
- }
- redraw();
- });
- addListener(SWT.MouseUp, e -> {
- if (!isClose && !isCheck && !isPush) {
- return;
- }
- if (isClose) {
- final float dist = (float) Math.sqrt((e.x - closeCenter.x) * (e.x - closeCenter.x) + (e.y - closeCenter.y) * (e.y - closeCenter.y));
- if (dist < CLOSE_CIRCLE_RAY) {
- final CloseEvent event = new CloseEvent(e);
- for (final CloseListener listener : closeListeners) {
- listener.onClose(event);
- if (!event.doit) {
- break;
- }
- }
- }
- }
- if (isDisposed()) {
- return;
- }
- setSelection(!selection);
- SelectionListenerUtil.fireSelectionListeners(this, e);
- });
- }
-
- private static int checkStyle(final int style) {
- final int mask = SWT.CLOSE | SWT.CHECK | SWT.PUSH;
- int newStyle = style & mask;
- newStyle |= SWT.DOUBLE_BUFFERED;
- return newStyle;
- }
-
- private int drawBackground(final GC gc) {
- final Rectangle rect = getClientArea();
-
- final Color color = determineBackgroundColor();
- gc.setBackground(color);
- gc.fillRoundRectangle(0, 0, rect.width, rect.height, rect.height, rect.height);
-
- return rect.height / 2 + 2;
- }
-
- private void drawWidgetBorder(final GC gc) {
- final Rectangle rect = getClientArea();
- Color color = borderColor;
- if (cursorInside) {
- color = hoverBorderColor;
- } else if (isPush && selection) {
- color = pushedStateBorderColor;
- }
-
- if (color == null) {
- // No border
- return;
- }
-
- gc.setForeground(color);
- gc.drawRoundRectangle(0, 0, rect.width - 2, rect.height - 2, rect.height, rect.height);
-
- }
-
- private Color determineBackgroundColor() {
- if (cursorInside) {
- return hoverBackground == null ? getBackground() : hoverBackground;
- }
- if (isPush && selection) {
- return pushedStateBackground == null ? getBackground() : pushedStateBackground;
- }
- return getChipsBackground() == null ? getBackground() : getChipsBackground();
- }
-
- private int drawCheck(final GC gc, final int x) {
- Color foreground = null;
- if (cursorInside) {
- foreground = hoverForeground;
- } else if (isPush && selection) {
- foreground = pushedStateForeground;
- }
- foreground = foreground == null ? getForeground() : foreground;
- gc.setForeground(foreground);
- gc.setLineWidth(2);
-
- final Rectangle rect = getClientArea();
-
- final int centerX = x + 4 + CLOSE_CIRCLE_RAY;
- final int centerY = (rect.height - 2 * CLOSE_CIRCLE_RAY) / 2 + CLOSE_CIRCLE_RAY;
- gc.drawLine(x + 6, centerY, x + 9, centerY + 4);
- gc.drawLine(x + 9, centerY + 4, centerX + 4, centerY - 3);
- return x + 16;
- }
-
- private int drawImage(final GC gc, final int x) {
- Image img = image;
- if (cursorInside) {
- img = hoverImage == null ? img : hoverImage;
- }
- if (isPush && selection) {
- img = pushImage == null ? img : pushImage;
- }
-
- final Rectangle rect = getClientArea();
- gc.drawImage(img, x + 2, (rect.height - img.getBounds().height) / 2);
-
- return x + 4 + img.getBounds().width;
- }
-
- private int drawText(final GC gc, final int x) {
- final Point textSize = gc.stringExtent(text);
- Color color = null;
- if (cursorInside) {
- color = hoverForeground;
- } else if (isPush && selection) {
- color = pushedStateForeground;
- }
- color = color == null ? getForeground() : color;
- gc.setForeground(color);
-
- gc.drawText(text, x + 2, (getClientArea().height - textSize.y) / 2, true);
-
- return x + 2 + textSize.x;
- }
-
- private void drawClose(final GC gc, final int x) {
- final Color foreground = cursorInside ? closeButtonHoverForeground : closeButtonForeground;
- final Color background = cursorInside ? closeButtonHoverBackground : closeButtonBackground;
- final Rectangle rect = getClientArea();
-
- gc.setBackground(background);
- gc.setForeground(foreground);
- closeCenter = new Point(x + 4 + CLOSE_CIRCLE_RAY, (rect.height - 2 * CLOSE_CIRCLE_RAY) / 2 + CLOSE_CIRCLE_RAY);
- gc.fillOval(x + 4, (rect.height - 2 * CLOSE_CIRCLE_RAY) / 2, 2 * CLOSE_CIRCLE_RAY, 2 * CLOSE_CIRCLE_RAY);
-
- // Cross
- gc.setLineWidth(2);
- gc.drawLine(closeCenter.x - 3, closeCenter.y - 3, closeCenter.x + 3, closeCenter.y + 3);
- gc.drawLine(closeCenter.x + 3, closeCenter.y - 3, closeCenter.x - 3, closeCenter.y + 3);
- }
-
- private void initDefaultColors() {
- setForeground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
- chipsBackground = SWTGraphicUtil.getColorSafely(224, 224, 224);
-
- hoverForeground = SWTGraphicUtil.getColorSafely(62, 28, 96);
- hoverBackground = SWTGraphicUtil.getColorSafely(214, 214, 214);
-
- closeButtonForeground = SWTGraphicUtil.getColorSafely(229, 229, 229);
- closeButtonBackground = SWTGraphicUtil.getColorSafely(100, 100, 100);
- closeButtonHoverForeground = SWTGraphicUtil.getColorSafely(214, 214, 214);
- closeButtonHoverBackground = SWTGraphicUtil.getColorSafely(64, 64, 64);
-
- pushedStateForeground = SWTGraphicUtil.getColorSafely(224, 224, 224);
- pushedStateBackground = getDisplay().getSystemColor(SWT.COLOR_BLACK);
- }
-
- /**
- * @see org.eclipse.swt.widgets.Control#computeSize(int, int, boolean)
- */
- @Override
- public Point computeSize(final int wHint, final int hHint, final boolean changed) {
- checkWidget();
- int width = 0; // Border
- int height = 20;
- if (image != null) {
- final Rectangle imageSize = image.getBounds();
- width += 4 + imageSize.width;
- height = Math.max(height, imageSize.height + 4);
-
- }
-
- if (text != null) {
- final GC gc = new GC(this);
- final Point textSize = gc.stringExtent(text);
- width += 4 + textSize.x;
- height = Math.max(height, textSize.y);
- gc.dispose();
- }
-
- if (isCheck && selection || isClose) {
- width += 20;
- }
-
- width += Math.max(height, hHint); // Size for left & right half-circle
- return new Point(Math.max(width, wHint), Math.max(height, hHint));
- }
-
- /**
- * Adds the listener to the collection of listeners who will be notified when
- * the control is closed by the user, by sending it one of the messages
- * defined in the CodeListener interface.
- *
- * widgetDefaultSelected is not called.
- *
- *
- * @param listener the listener which should be notified when the control is
- * closed by the user,
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_NULL_ARGUMENT - if the listener is null
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- *
- * @see CloseListener
- * @see #removeCloseListener
- * @see SelectionEvent
- */
- public void addCloseListener(final CloseListener listener) {
- checkWidget();
- if (listener == null) {
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- }
- closeListeners.add(listener);
- }
-
- /**
- * @see org.eclipse.swt.widgets.Widget#addListener(int, org.eclipse.swt.widgets.Listener)
- */
- @Override
- public void addListener(final int eventType, final Listener listener) {
- if (eventType == SWT.Close) {
- closeListeners.add(e -> {
- final Event event = new Event();
- event.widget = Chips.this;
- event.display = getDisplay();
- event.type = SWT.Close;
- listener.handleEvent(event);
- });
- return;
- }
- super.addListener(eventType, listener);
- }
-
- /**
- * Adds the listener to the collection of listeners who will be notified when
- * the control is selected by the user, by sending it one of the messages
- * defined in the SelectionListener interface.
- *
- * widgetDefaultSelected is not called.
- *
- *
- * @param listener the listener which should be notified when the control is
- * selected by the user,
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_NULL_ARGUMENT - if the listener is null
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
- public void addSelectionListener(final SelectionListener listener) {
- checkWidget();
- SelectionListenerUtil.addSelectionListener(this, listener);
- }
-
- /**
- * Removes the listener from the collection of listeners who will be notified
- * when the control is closed by the user.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_NULL_ARGUMENT - if the listener is null
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- *
- * @see CloseListener
- * @see #addCloseListener
- */
- public void removeCloseListener(final CloseListener listener) {
- checkWidget();
- if (listener == null) {
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- }
- closeListeners.remove(listener);
- }
-
- /**
- * Removes the listener from the collection of listeners who will be notified
- * when the control is selected by the user.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_NULL_ARGUMENT - if the listener is null
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public Color getChipsBackground() {
- checkWidget();
- return chipsBackground;
- }
-
- /**
- * Returns the receiver's foreground color when mouse is hover the widget.
- *
- * Note: This operation is only available if at least one the SWT.CHECK, SWT.PUSH and SWT.CLOSE flag is set.
- *
- *
- * @return the foreground color
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public Color getHoverForeground() {
- checkWidget();
- return hoverForeground;
- }
-
- /**
- * Returns the receiver's background color when mouse is hover the widget.
- *
- * Note: This operation is only available if at least one the SWT.CHECK, SWT.PUSH and SWT.CLOSE flag is set.
- *
- *
- * @return the background color
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public Color getHoverBackground() {
- checkWidget();
- return hoverBackground;
- }
-
- /**
- * Returns the receiver's close item foreground color.
- *
- * Note: This operation is only available if the SWT.CLOSE flag is set.
- *
- *
- * @return the foreground color
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public Color getCloseButtonForeground() {
- checkWidget();
- return closeButtonForeground;
- }
-
- /**
- * Returns the receiver's close item background color.
- *
- * Note: This operation is only available if the SWT.CLOSE flag is set.
- *
- *
- * @return the background color
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public Color getCloseButtonBackground() {
- checkWidget();
- return closeButtonBackground;
- }
-
- /**
- * Returns the receiver's close item foreground color when the mouse is hover the widget.
- *
- * Note: This operation is only available if the SWT.CLOSE flag is set.
- *
- *
- * @return the foreground color
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public Color getCloseButtonHoverForeground() {
- checkWidget();
- return closeButtonHoverForeground;
- }
-
- /**
- * Returns the receiver's close item background color when the mouse is hover the widget.
- *
- * Note: This operation is only available if the SWT.CLOSE flag is set.
- *
- *
- * @return the background color
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public Color getCloseButtonHoverBackground() {
- checkWidget();
- return closeButtonHoverBackground;
- }
-
- /**
- * Returns the receiver's foreground color when the widget is "pushed" (selected).
- *
- * Note: This operation is only available if the SWT.PUSH flag is set.
- *
- *
- * @return the foreground color
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public Color getPushedStateForeground() {
- checkWidget();
- return pushedStateForeground;
- }
-
- /**
- * Returns the receiver's background color when the widget is "pushed" (selected).
- *
- * Note: This operation is only available if the SWT.PUSH flag is set.
- *
- *
- * @return the background color
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public Color getPushedStateBackground() {
- checkWidget();
- return pushedStateBackground;
- }
-
- /**
- * Returns the receiver's color for the border of the widget.
- *
- * @return the border color
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public Color getBorderColor() {
- checkWidget();
- return borderColor;
- }
-
- /**
- * Returns the receiver's color for the border when the mouse is hover the widget
- *
- * Note: This operation is only available if at least one the SWT.CHECK, SWT.PUSH and SWT.CLOSE flag is set.
- *
- *
- * @return the border color
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public Color getHoverBorderColor() {
- checkWidget();
- return hoverBorderColor;
- }
-
- /**
- * Returns the receiver's color for the border when the widget is "pushed" (selected)
- *
- * Note: This operation is only available if the SWT.PUSH flag is set.
- *
- *
- * @return the border color
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public Color getPushedStateBorderColor() {
- checkWidget();
- return pushedStateBorderColor;
- }
-
- /**
- * Returns the receiver's text, which will be an empty
- * string if it has never been set.
- *
- * @return the receiver's text
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public String getText() {
- checkWidget();
- return text;
- }
-
- /**
- * Returns the receiver's image if it has one, or null
- * if it does not.
- *
- * @return the receiver's image
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public Image getImage() {
- checkWidget();
- return image;
- }
-
- /**
- * Returns the receiver's image when the widget is pushed (selected) if it has one, or null
- * if it does not.
- *
- * Note: This operation is only available if the SWT.PUSH flag is set.
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public Image getPushImage() {
- checkWidget();
- return pushImage;
- }
-
- /**
- * Returns the receiver's image when the mouse is hover the widget if it has one, or null
- * if it does not.
- *
- * Note: This operation is only available if at least one the SWT.CHECK, SWT.PUSH and SWT.CLOSE flag is set.
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public Image getHoverImage() {
- checkWidget();
- return hoverImage;
- }
-
- /**
- * Returns true if the receiver is selected,
- * and false otherwise.
- *
- * Note: This operation is only available if the SWT.CHECK or the SWT.PUSH flag is set.
- *
- *
- * @return the selection state
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public boolean getSelection() {
- checkWidget();
- return selection;
- }
-
- /**
- * Sets the receiver's background color to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setChipsBackground(final Color chipsBackground) {
- checkWidget();
- this.chipsBackground = chipsBackground;
- }
-
- /**
- * Sets the receiver's foreground color to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- *
- * Note: This operation is only available if at least one the SWT.CHECK, SWT.PUSH and SWT.CLOSE flag is set.
- *
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setHoverForeground(final Color hoverForeground) {
- checkWidget();
- this.hoverForeground = hoverForeground;
- }
-
- /**
- * Sets the receiver's background color to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- *
- * Note: This operation is only available if at least one the SWT.CHECK, SWT.PUSH and SWT.CLOSE flag is set.
- *
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setHoverBackground(final Color hoverBackground) {
- checkWidget();
- this.hoverBackground = hoverBackground;
- }
-
- /**
- * Sets the receiver's close button foreground color to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- *
- * Note: This operation is only available if the SWT.CLOSE flag is set.
- *
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setCloseButtonForeground(final Color closeButtonForeground) {
- checkWidget();
- this.closeButtonForeground = closeButtonForeground;
- }
-
- /**
- * Sets the receiver's close button background color to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- *
- * Note: This operation is only available if the SWT.CLOSE flag is set.
- *
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setCloseButtonBackground(final Color closeButtonBackground) {
- checkWidget();
- this.closeButtonBackground = closeButtonBackground;
- }
-
- /**
- * Sets the receiver's close button foreground color (when the mouse is hover the widget) to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- *
- * Note: This operation is only available if the SWT.CLOSE flag is set.
- *
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setCloseButtonHoverForeground(final Color closeButtonHoverForeground) {
- checkWidget();
- this.closeButtonHoverForeground = closeButtonHoverForeground;
- }
-
- /**
- * Sets the receiver's close button background color (when the mouse is hover the widget) to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- *
- * Note: This operation is only available if the SWT.CLOSE flag is set.
- *
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setCloseButtonHoverBackground(final Color closeButtonHoverBackground) {
- checkWidget();
- this.closeButtonHoverBackground = closeButtonHoverBackground;
- }
-
- /**
- * Sets the receiver's foreground color when the button is "pushed" (=selected) to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- *
- * Note: This operation is only available if the SWT.PUSH flag is set.
- *
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setPushedStateForeground(final Color pushedStateForeground) {
- checkWidget();
- this.pushedStateForeground = pushedStateForeground;
- }
-
- /**
- * Sets the receiver's background color when the button is "pushed" (=selected) to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- *
- * Note: This operation is only available if the SWT.PUSH flag is set.
- *
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setPushedStateBackground(final Color pushedStateBackground) {
- checkWidget();
- this.pushedStateBackground = pushedStateBackground;
- }
-
- /**
- * Sets the receiver's border color to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setBorderColor(final Color borderColor) {
- checkWidget();
- this.borderColor = borderColor;
- }
-
- /**
- * Sets the receiver's border color (when the mouse is hover the widget) to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- *
- * Note: This operation is only available if at least one the SWT.CHECK, SWT.PUSH and SWT.CLOSE flag is set.
- *
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setHoverBorderColor(final Color hoverBorderColor) {
- checkWidget();
- this.hoverBorderColor = hoverBorderColor;
- }
-
- /**
- * Sets the receiver's border color when the button is "pushed" (selected) to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- *
- * Note: This operation is a hint and may be overridden by the platform.
- *
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setPushedStateBorderColor(final Color pushedStateBorderColor) {
- checkWidget();
- this.pushedStateBorderColor = pushedStateBorderColor;
- }
-
- /**
- * Sets the receiver's text.
- *
- * This method sets the widget label. The label may include
- * the mnemonic character and line delimiters.
- *
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_NULL_ARGUMENT - if the text is null
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setText(final String text) {
- checkWidget();
- this.text = text;
- }
-
- /**
- * Sets the receiver's image to the argument, which may be
- * null indicating that no image should be displayed.
- *
- * @param image the image to display on the receiver (may be null)
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the image has been disposed
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setImage(final Image image) {
- checkWidget();
- this.image = image;
- }
-
- /**
- * Sets the receiver's image to the argument when the widget is "pushed" (=selected), which may be
- * null indicating that no image should be displayed.
- *
- * Note: This operation is only available if the SWT.PUSH flag is set.
- *
- *
- * @param image the image to display on the receiver (may be null)
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the image has been disposed
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setPushImage(final Image pushImage) {
- checkWidget();
- this.pushImage = pushImage;
- }
-
- /**
- * Sets the receiver's image to the argument when the mouse is hover the widget, which may be
- * null indicating that no image should be displayed.
- *
- * Note: This operation is only available if at least one the SWT.CHECK, SWT.PUSH and SWT.CLOSE flag is set.
- *
- *
- * @param image the image to display on the receiver (may be null)
- *
- * @exception IllegalArgumentException
- *
- *
ERROR_INVALID_ARGUMENT - if the image has been disposed
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setHoverImage(final Image hoverImage) {
- checkWidget();
- this.hoverImage = hoverImage;
- }
-
- /**
- * Sets the selection state of the receiver, if it is of type CHECK or
- * PUSH.
- *
- *
- * When the receiver is of type CHECK or RADIO,
- * it is selected when it is checked. When it is of type TOGGLE,
- * it is selected when it is pushed in.
- *
- * @param selected the new selection state
- *
- * @exception SWTException
- *
- *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- *
- */
- public void setSelection(final boolean selected) {
- checkWidget();
- selection = selected;
- if (isCheck) {
- getParent().layout(new Control[] { this });
- }
- redraw();
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2020 Laurent CARON.
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors: Laurent CARON (laurent.caron at gmail dot com) - initial API and
+ * implementation
+ *******************************************************************************/
+package org.eclipse.nebula.widgets.chips;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.nebula.widgets.opal.commons.SWTGraphicUtil;
+import org.eclipse.nebula.widgets.opal.commons.SelectionListenerUtil;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+
+/**
+ * Instances of this class represent a "chips". This is a kind of rounded-shapped button. It can display information,
+ * or be used like a check or a push button. You can also add a close button.
+ *
+ *
+ *
Styles:
+ *
SWT.CLOSE
+ *
SWT.CHECK
+ *
SWT.PUSH
+ *
Events:
+ *
SWT.Close, SWT.Selection
+ *
+ */
+public class Chips extends Canvas {
+
+ private static final int CLOSE_CIRCLE_RAY = 7;
+
+ private Color hoverForeground, hoverBackground;
+ private Color closeButtonForeground, closeButtonBackground;
+ private Color closeButtonHoverForeground, closeButtonHoverBackground;
+ private Color pushedStateForeground, pushedStateBackground;
+ private Color borderColor, hoverBorderColor, pushedStateBorderColor;
+ private Color chipsBackground;
+ private String text;
+ private Image image, pushImage, hoverImage;
+ private boolean selection;
+ private final boolean isCheck;
+ private final boolean isPush;
+ private final boolean isClose;
+ private final List closeListeners = new ArrayList<>();
+ private boolean cursorInside;
+ private Point closeCenter;
+
+ /**
+ * Constructs a new instance of this class given its parent and a style value
+ * describing its behavior and appearance.
+ *
+ * The style value is either one of the style constants defined in class
+ * SWT which is applicable to instances of this class, or must be
+ * built by bitwise OR'ing together (that is, using the
+ * int "|" operator) two or more of those SWT style
+ * constants. The class description lists the style constants that are
+ * applicable to the class. Style bits are also inherited from superclasses.
+ *
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_NULL_ARGUMENT - if the parent is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the parent
+ *
ERROR_INVALID_SUBCLASS - if this class is not an allowed
+ * subclass
+ *
+ *
+ */
+ public Chips(final Composite parent, final int style) {
+ super(parent, checkStyle(style));
+ initDefaultColors();
+ text = "";
+ isCheck = (getStyle() & SWT.CHECK) != 0;
+ isPush = (getStyle() & SWT.PUSH) != 0;
+ isClose = (getStyle() & SWT.CLOSE) != 0;
+
+ addListener(SWT.Paint, e -> {
+ final GC gc = e.gc;
+ gc.setFont(getFont());
+ gc.setAdvanced(true);
+ gc.setTextAntialias(SWT.ON);
+ gc.setAntialias(SWT.ON);
+ final Color previousForeground = gc.getForeground();
+ final Color previousBackground = gc.getBackground();
+
+ int x = drawBackground(gc);
+ drawWidgetBorder(gc);
+ if (isCheck && selection) {
+ x = drawCheck(gc, x);
+ }
+
+ if (image != null) {
+ x = drawImage(gc, x);
+ }
+
+ if (text != null) {
+ x = drawText(gc, x);
+ }
+
+ if (isClose) {
+ drawClose(gc, x);
+ }
+ gc.setBackground(previousBackground);
+ gc.setForeground(previousForeground);
+
+ });
+
+ addListener(SWT.MouseEnter, e -> {
+ cursorInside = isPush || isCheck || isClose;
+ if (cursorInside) {
+ setCursor(getDisplay().getSystemCursor(SWT.CURSOR_HAND));
+ }
+ redraw();
+ });
+ addListener(SWT.MouseExit, e -> {
+ cursorInside = false;
+ if (isPush || isCheck || isClose) {
+ setCursor(getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
+ }
+ redraw();
+ });
+ addListener(SWT.MouseUp, e -> {
+ if (!isClose && !isCheck && !isPush) {
+ return;
+ }
+ if (isClose) {
+ final float dist = (float) Math.sqrt((e.x - closeCenter.x) * (e.x - closeCenter.x) + (e.y - closeCenter.y) * (e.y - closeCenter.y));
+ if (dist < CLOSE_CIRCLE_RAY) {
+ final CloseEvent event = new CloseEvent(e);
+ for (final CloseListener listener : closeListeners) {
+ listener.onClose(event);
+ if (!event.doit) {
+ break;
+ }
+ }
+ }
+ }
+ if (isDisposed()) {
+ return;
+ }
+ setSelection(!selection);
+ SelectionListenerUtil.fireSelectionListeners(this, e);
+ });
+ }
+
+ private static int checkStyle(final int style) {
+ final int mask = SWT.CLOSE | SWT.CHECK | SWT.PUSH;
+ int newStyle = style & mask;
+ newStyle |= SWT.DOUBLE_BUFFERED;
+ return newStyle;
+ }
+
+ private int drawBackground(final GC gc) {
+ final Rectangle rect = getClientArea();
+
+ final Color color = determineBackgroundColor();
+ gc.setBackground(color);
+ gc.fillRoundRectangle(0, 0, rect.width, rect.height, rect.height, rect.height);
+
+ return rect.height / 2 + 2;
+ }
+
+ private void drawWidgetBorder(final GC gc) {
+ final Rectangle rect = getClientArea();
+ Color color = borderColor;
+ if (cursorInside) {
+ color = hoverBorderColor;
+ } else if (isPush && selection) {
+ color = pushedStateBorderColor;
+ }
+
+ if (color == null) {
+ // No border
+ return;
+ }
+
+ gc.setForeground(color);
+ gc.drawRoundRectangle(0, 0, rect.width - 2, rect.height - 2, rect.height, rect.height);
+
+ }
+
+ private Color determineBackgroundColor() {
+ if (cursorInside) {
+ return hoverBackground == null ? getBackground() : hoverBackground;
+ }
+ if (isPush && selection) {
+ return pushedStateBackground == null ? getBackground() : pushedStateBackground;
+ }
+ return getChipsBackground() == null ? getBackground() : getChipsBackground();
+ }
+
+ private int drawCheck(final GC gc, final int x) {
+ Color foreground = null;
+ if (cursorInside) {
+ foreground = hoverForeground;
+ } else if (isPush && selection) {
+ foreground = pushedStateForeground;
+ }
+ foreground = foreground == null ? getForeground() : foreground;
+ gc.setForeground(foreground);
+ gc.setLineWidth(2);
+
+ final Rectangle rect = getClientArea();
+
+ final int centerX = x + 4 + CLOSE_CIRCLE_RAY;
+ final int centerY = (rect.height - 2 * CLOSE_CIRCLE_RAY) / 2 + CLOSE_CIRCLE_RAY;
+ gc.drawLine(x + 6, centerY, x + 9, centerY + 4);
+ gc.drawLine(x + 9, centerY + 4, centerX + 4, centerY - 3);
+ return x + 16;
+ }
+
+ private int drawImage(final GC gc, final int x) {
+ Image img = image;
+ if (cursorInside) {
+ img = hoverImage == null ? img : hoverImage;
+ }
+ if (isPush && selection) {
+ img = pushImage == null ? img : pushImage;
+ }
+
+ final Rectangle rect = getClientArea();
+ gc.drawImage(img, x + 2, (rect.height - img.getBounds().height) / 2);
+
+ return x + 4 + img.getBounds().width;
+ }
+
+ private int drawText(final GC gc, final int x) {
+ final Point textSize = gc.stringExtent(text);
+ Color color = null;
+ if (cursorInside) {
+ color = hoverForeground;
+ } else if (isPush && selection) {
+ color = pushedStateForeground;
+ }
+ color = color == null ? getForeground() : color;
+ gc.setForeground(color);
+
+ gc.drawText(text, x + 2, (getClientArea().height - textSize.y) / 2, true);
+
+ return x + 2 + textSize.x;
+ }
+
+ private void drawClose(final GC gc, final int x) {
+ final Color foreground = cursorInside ? closeButtonHoverForeground : closeButtonForeground;
+ final Color background = cursorInside ? closeButtonHoverBackground : closeButtonBackground;
+ final Rectangle rect = getClientArea();
+
+ gc.setBackground(background);
+ gc.setForeground(foreground);
+ closeCenter = new Point(x + 4 + CLOSE_CIRCLE_RAY, (rect.height - 2 * CLOSE_CIRCLE_RAY) / 2 + CLOSE_CIRCLE_RAY);
+ gc.fillOval(x + 4, (rect.height - 2 * CLOSE_CIRCLE_RAY) / 2, 2 * CLOSE_CIRCLE_RAY, 2 * CLOSE_CIRCLE_RAY);
+
+ // Cross
+ gc.setLineWidth(2);
+ gc.drawLine(closeCenter.x - 3, closeCenter.y - 3, closeCenter.x + 3, closeCenter.y + 3);
+ gc.drawLine(closeCenter.x + 3, closeCenter.y - 3, closeCenter.x - 3, closeCenter.y + 3);
+ }
+
+ private void initDefaultColors() {
+ setForeground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ chipsBackground = SWTGraphicUtil.getColorSafely(224, 224, 224);
+
+ hoverForeground = SWTGraphicUtil.getColorSafely(62, 28, 96);
+ hoverBackground = SWTGraphicUtil.getColorSafely(214, 214, 214);
+
+ closeButtonForeground = SWTGraphicUtil.getColorSafely(229, 229, 229);
+ closeButtonBackground = SWTGraphicUtil.getColorSafely(100, 100, 100);
+ closeButtonHoverForeground = SWTGraphicUtil.getColorSafely(214, 214, 214);
+ closeButtonHoverBackground = SWTGraphicUtil.getColorSafely(64, 64, 64);
+
+ pushedStateForeground = SWTGraphicUtil.getColorSafely(224, 224, 224);
+ pushedStateBackground = getDisplay().getSystemColor(SWT.COLOR_BLACK);
+ }
+
+ /**
+ * @see org.eclipse.swt.widgets.Control#computeSize(int, int, boolean)
+ */
+ @Override
+ public Point computeSize(final int wHint, final int hHint, final boolean changed) {
+ checkWidget();
+ int width = 0; // Border
+ int height = 20;
+ if (image != null) {
+ final Rectangle imageSize = image.getBounds();
+ width += 4 + imageSize.width;
+ height = Math.max(height, imageSize.height + 4);
+
+ }
+
+ if (text != null) {
+ final GC gc = new GC(this);
+ final Point textSize = gc.stringExtent(text);
+ width += 4 + textSize.x;
+ height = Math.max(height, textSize.y);
+ gc.dispose();
+ }
+
+ if (isCheck && selection || isClose) {
+ width += 20;
+ }
+
+ width += Math.max(height, hHint); // Size for left & right half-circle
+ return new Point(Math.max(width, wHint), Math.max(height, hHint));
+ }
+
+ /**
+ * Adds the listener to the collection of listeners who will be notified when
+ * the control is closed by the user, by sending it one of the messages
+ * defined in the CodeListener interface.
+ *
+ * widgetDefaultSelected is not called.
+ *
+ *
+ * @param listener the listener which should be notified when the control is
+ * closed by the user,
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_NULL_ARGUMENT - if the listener is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ *
+ * @see CloseListener
+ * @see #removeCloseListener
+ * @see SelectionEvent
+ */
+ public void addCloseListener(final CloseListener listener) {
+ checkWidget();
+ if (listener == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ closeListeners.add(listener);
+ }
+
+ /**
+ * @see org.eclipse.swt.widgets.Widget#addListener(int, org.eclipse.swt.widgets.Listener)
+ */
+ @Override
+ public void addListener(final int eventType, final Listener listener) {
+ if (eventType == SWT.Close) {
+ closeListeners.add(e -> {
+ final Event event = new Event();
+ event.widget = Chips.this;
+ event.display = getDisplay();
+ event.type = SWT.Close;
+ listener.handleEvent(event);
+ });
+ return;
+ }
+ super.addListener(eventType, listener);
+ }
+
+ /**
+ * Adds the listener to the collection of listeners who will be notified when
+ * the control is selected by the user, by sending it one of the messages
+ * defined in the SelectionListener interface.
+ *
+ * widgetDefaultSelected is not called.
+ *
+ *
+ * @param listener the listener which should be notified when the control is
+ * selected by the user,
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_NULL_ARGUMENT - if the listener is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+ public void addSelectionListener(final SelectionListener listener) {
+ checkWidget();
+ SelectionListenerUtil.addSelectionListener(this, listener);
+ }
+
+ /**
+ * Removes the listener from the collection of listeners who will be notified
+ * when the control is closed by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_NULL_ARGUMENT - if the listener is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
+ *
+ *
+ * @see CloseListener
+ * @see #addCloseListener
+ */
+ public void removeCloseListener(final CloseListener listener) {
+ checkWidget();
+ if (listener == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ closeListeners.remove(listener);
+ }
+
+ /**
+ * Removes the listener from the collection of listeners who will be notified
+ * when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_NULL_ARGUMENT - if the listener is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the
+ * thread that created the receiver
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public Color getChipsBackground() {
+ checkWidget();
+ return chipsBackground;
+ }
+
+ /**
+ * Returns the receiver's foreground color when mouse is hover the widget.
+ *
+ * Note: This operation is only available if at least one the SWT.CHECK, SWT.PUSH and SWT.CLOSE flag is set.
+ *
+ *
+ * @return the foreground color
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public Color getHoverForeground() {
+ checkWidget();
+ return hoverForeground;
+ }
+
+ /**
+ * Returns the receiver's background color when mouse is hover the widget.
+ *
+ * Note: This operation is only available if at least one the SWT.CHECK, SWT.PUSH and SWT.CLOSE flag is set.
+ *
+ *
+ * @return the background color
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public Color getHoverBackground() {
+ checkWidget();
+ return hoverBackground;
+ }
+
+ /**
+ * Returns the receiver's close item foreground color.
+ *
+ * Note: This operation is only available if the SWT.CLOSE flag is set.
+ *
+ *
+ * @return the foreground color
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public Color getCloseButtonForeground() {
+ checkWidget();
+ return closeButtonForeground;
+ }
+
+ /**
+ * Returns the receiver's close item background color.
+ *
+ * Note: This operation is only available if the SWT.CLOSE flag is set.
+ *
+ *
+ * @return the background color
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public Color getCloseButtonBackground() {
+ checkWidget();
+ return closeButtonBackground;
+ }
+
+ /**
+ * Returns the receiver's close item foreground color when the mouse is hover the widget.
+ *
+ * Note: This operation is only available if the SWT.CLOSE flag is set.
+ *
+ *
+ * @return the foreground color
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public Color getCloseButtonHoverForeground() {
+ checkWidget();
+ return closeButtonHoverForeground;
+ }
+
+ /**
+ * Returns the receiver's close item background color when the mouse is hover the widget.
+ *
+ * Note: This operation is only available if the SWT.CLOSE flag is set.
+ *
+ *
+ * @return the background color
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public Color getCloseButtonHoverBackground() {
+ checkWidget();
+ return closeButtonHoverBackground;
+ }
+
+ /**
+ * Returns the receiver's foreground color when the widget is "pushed" (selected).
+ *
+ * Note: This operation is only available if the SWT.PUSH flag is set.
+ *
+ *
+ * @return the foreground color
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public Color getPushedStateForeground() {
+ checkWidget();
+ return pushedStateForeground;
+ }
+
+ /**
+ * Returns the receiver's background color when the widget is "pushed" (selected).
+ *
+ * Note: This operation is only available if the SWT.PUSH flag is set.
+ *
+ *
+ * @return the background color
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public Color getPushedStateBackground() {
+ checkWidget();
+ return pushedStateBackground;
+ }
+
+ /**
+ * Returns the receiver's color for the border of the widget.
+ *
+ * @return the border color
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public Color getBorderColor() {
+ checkWidget();
+ return borderColor;
+ }
+
+ /**
+ * Returns the receiver's color for the border when the mouse is hover the widget
+ *
+ * Note: This operation is only available if at least one the SWT.CHECK, SWT.PUSH and SWT.CLOSE flag is set.
+ *
+ *
+ * @return the border color
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public Color getHoverBorderColor() {
+ checkWidget();
+ return hoverBorderColor;
+ }
+
+ /**
+ * Returns the receiver's color for the border when the widget is "pushed" (selected)
+ *
+ * Note: This operation is only available if the SWT.PUSH flag is set.
+ *
+ *
+ * @return the border color
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public Color getPushedStateBorderColor() {
+ checkWidget();
+ return pushedStateBorderColor;
+ }
+
+ /**
+ * Returns the receiver's text, which will be an empty
+ * string if it has never been set.
+ *
+ * @return the receiver's text
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public String getText() {
+ checkWidget();
+ return text;
+ }
+
+ /**
+ * Returns the receiver's image if it has one, or null
+ * if it does not.
+ *
+ * @return the receiver's image
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public Image getImage() {
+ checkWidget();
+ return image;
+ }
+
+ /**
+ * Returns the receiver's image when the widget is pushed (selected) if it has one, or null
+ * if it does not.
+ *
+ * Note: This operation is only available if the SWT.PUSH flag is set.
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public Image getPushImage() {
+ checkWidget();
+ return pushImage;
+ }
+
+ /**
+ * Returns the receiver's image when the mouse is hover the widget if it has one, or null
+ * if it does not.
+ *
+ * Note: This operation is only available if at least one the SWT.CHECK, SWT.PUSH and SWT.CLOSE flag is set.
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public Image getHoverImage() {
+ checkWidget();
+ return hoverImage;
+ }
+
+ /**
+ * Returns true if the receiver is selected,
+ * and false otherwise.
+ *
+ * Note: This operation is only available if the SWT.CHECK or the SWT.PUSH flag is set.
+ *
+ *
+ * @return the selection state
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public boolean getSelection() {
+ checkWidget();
+ return selection;
+ }
+
+ /**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setChipsBackground(final Color chipsBackground) {
+ checkWidget();
+ this.chipsBackground = chipsBackground;
+ }
+
+ /**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * Note: This operation is only available if at least one the SWT.CHECK, SWT.PUSH and SWT.CLOSE flag is set.
+ *
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setHoverForeground(final Color hoverForeground) {
+ checkWidget();
+ this.hoverForeground = hoverForeground;
+ }
+
+ /**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * Note: This operation is only available if at least one the SWT.CHECK, SWT.PUSH and SWT.CLOSE flag is set.
+ *
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setHoverBackground(final Color hoverBackground) {
+ checkWidget();
+ this.hoverBackground = hoverBackground;
+ }
+
+ /**
+ * Sets the receiver's close button foreground color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * Note: This operation is only available if the SWT.CLOSE flag is set.
+ *
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setCloseButtonForeground(final Color closeButtonForeground) {
+ checkWidget();
+ this.closeButtonForeground = closeButtonForeground;
+ }
+
+ /**
+ * Sets the receiver's close button background color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * Note: This operation is only available if the SWT.CLOSE flag is set.
+ *
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setCloseButtonBackground(final Color closeButtonBackground) {
+ checkWidget();
+ this.closeButtonBackground = closeButtonBackground;
+ }
+
+ /**
+ * Sets the receiver's close button foreground color (when the mouse is hover the widget) to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * Note: This operation is only available if the SWT.CLOSE flag is set.
+ *
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setCloseButtonHoverForeground(final Color closeButtonHoverForeground) {
+ checkWidget();
+ this.closeButtonHoverForeground = closeButtonHoverForeground;
+ }
+
+ /**
+ * Sets the receiver's close button background color (when the mouse is hover the widget) to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * Note: This operation is only available if the SWT.CLOSE flag is set.
+ *
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setCloseButtonHoverBackground(final Color closeButtonHoverBackground) {
+ checkWidget();
+ this.closeButtonHoverBackground = closeButtonHoverBackground;
+ }
+
+ /**
+ * Sets the receiver's foreground color when the button is "pushed" (=selected) to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * Note: This operation is only available if the SWT.PUSH flag is set.
+ *
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setPushedStateForeground(final Color pushedStateForeground) {
+ checkWidget();
+ this.pushedStateForeground = pushedStateForeground;
+ }
+
+ /**
+ * Sets the receiver's background color when the button is "pushed" (=selected) to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * Note: This operation is only available if the SWT.PUSH flag is set.
+ *
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setPushedStateBackground(final Color pushedStateBackground) {
+ checkWidget();
+ this.pushedStateBackground = pushedStateBackground;
+ }
+
+ /**
+ * Sets the receiver's border color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setBorderColor(final Color borderColor) {
+ checkWidget();
+ this.borderColor = borderColor;
+ }
+
+ /**
+ * Sets the receiver's border color (when the mouse is hover the widget) to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * Note: This operation is only available if at least one the SWT.CHECK, SWT.PUSH and SWT.CLOSE flag is set.
+ *
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setHoverBorderColor(final Color hoverBorderColor) {
+ checkWidget();
+ this.hoverBorderColor = hoverBorderColor;
+ }
+
+ /**
+ * Sets the receiver's border color when the button is "pushed" (selected) to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * Note: This operation is a hint and may be overridden by the platform.
+ *
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the argument has been disposed
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setPushedStateBorderColor(final Color pushedStateBorderColor) {
+ checkWidget();
+ this.pushedStateBorderColor = pushedStateBorderColor;
+ }
+
+ /**
+ * Sets the receiver's text.
+ *
+ * This method sets the widget label. The label may include
+ * the mnemonic character and line delimiters.
+ *
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_NULL_ARGUMENT - if the text is null
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setText(final String text) {
+ checkWidget();
+ this.text = text;
+ }
+
+ /**
+ * Sets the receiver's image to the argument, which may be
+ * null indicating that no image should be displayed.
+ *
+ * @param image the image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the image has been disposed
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setImage(final Image image) {
+ checkWidget();
+ this.image = image;
+ }
+
+ /**
+ * Sets the receiver's image to the argument when the widget is "pushed" (=selected), which may be
+ * null indicating that no image should be displayed.
+ *
+ * Note: This operation is only available if the SWT.PUSH flag is set.
+ *
+ *
+ * @param image the image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the image has been disposed
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setPushImage(final Image pushImage) {
+ checkWidget();
+ this.pushImage = pushImage;
+ }
+
+ /**
+ * Sets the receiver's image to the argument when the mouse is hover the widget, which may be
+ * null indicating that no image should be displayed.
+ *
+ * Note: This operation is only available if at least one the SWT.CHECK, SWT.PUSH and SWT.CLOSE flag is set.
+ *
+ *
+ * @param image the image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException
+ *
+ *
ERROR_INVALID_ARGUMENT - if the image has been disposed
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setHoverImage(final Image hoverImage) {
+ checkWidget();
+ this.hoverImage = hoverImage;
+ }
+
+ /**
+ * Sets the selection state of the receiver, if it is of type CHECK or
+ * PUSH.
+ *
+ *
+ * When the receiver is of type CHECK or RADIO,
+ * it is selected when it is checked. When it is of type TOGGLE,
+ * it is selected when it is pushed in.
+ *
+ * @param selected the new selection state
+ *
+ * @exception SWTException
+ *
+ *
ERROR_WIDGET_DISPOSED - if the receiver has been disposed
+ *
ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
+ *
+ */
+ public void setSelection(final boolean selected) {
+ checkWidget();
+ selection = selected;
+ if (isCheck) {
+ getParent().layout(new Control[] { this });
+ }
+ redraw();
+ }
+
+}
diff --git a/widgets/chips/org.eclipse.nebula.widgets.chips/src/org/eclipse/nebula/widgets/chips/CloseEvent.java b/widgets/chips/org.eclipse.nebula.widgets.chips/src/org/eclipse/nebula/widgets/chips/CloseEvent.java
index cc6b5e04c..ccac601bb 100644
--- a/widgets/chips/org.eclipse.nebula.widgets.chips/src/org/eclipse/nebula/widgets/chips/CloseEvent.java
+++ b/widgets/chips/org.eclipse.nebula.widgets.chips/src/org/eclipse/nebula/widgets/chips/CloseEvent.java
@@ -1,47 +1,47 @@
-/*******************************************************************************
- * Copyright (c) 2020 Laurent CARON.
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors: Laurent CARON (laurent.caron at gmail dot com) - initial API and
- * implementation
- *******************************************************************************/
-package org.eclipse.nebula.widgets.chips;
-
-import org.eclipse.swt.events.TypedEvent;
-import org.eclipse.swt.widgets.Event;
-
-/**
- * Instances of this class are sent as a result of
- * widgets being closed.
- *
- * Note: The fields that are filled in depend on the widget.
- *
- *
- * @see CloseListener
- */
-public class CloseEvent extends TypedEvent {
-
- private static final long serialVersionUID = 5028668219476966408L;
-
- /**
- * A flag indicating whether the operation should be allowed.
- * Setting this field to false will cancel the
- * operation, depending on the widget.
- */
- public boolean doit;
-
- /**
- * Constructs a new instance of this class based on the
- * information in the given untyped event.
- *
- * @param e the untyped event containing the information
- */
- public CloseEvent(final Event e) {
- super(e);
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2020 Laurent CARON.
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors: Laurent CARON (laurent.caron at gmail dot com) - initial API and
+ * implementation
+ *******************************************************************************/
+package org.eclipse.nebula.widgets.chips;
+
+import org.eclipse.swt.events.TypedEvent;
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * widgets being closed.
+ *
+ * Note: The fields that are filled in depend on the widget.
+ *
+ *
+ * @see CloseListener
+ */
+public class CloseEvent extends TypedEvent {
+
+ private static final long serialVersionUID = 5028668219476966408L;
+
+ /**
+ * A flag indicating whether the operation should be allowed.
+ * Setting this field to false will cancel the
+ * operation, depending on the widget.
+ */
+ public boolean doit;
+
+ /**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+ public CloseEvent(final Event e) {
+ super(e);
+ }
+}
diff --git a/widgets/chips/org.eclipse.nebula.widgets.chips/src/org/eclipse/nebula/widgets/chips/CloseListener.java b/widgets/chips/org.eclipse.nebula.widgets.chips/src/org/eclipse/nebula/widgets/chips/CloseListener.java
index 5379e2d7e..d1d595e0b 100644
--- a/widgets/chips/org.eclipse.nebula.widgets.chips/src/org/eclipse/nebula/widgets/chips/CloseListener.java
+++ b/widgets/chips/org.eclipse.nebula.widgets.chips/src/org/eclipse/nebula/widgets/chips/CloseListener.java
@@ -1,40 +1,40 @@
-/*******************************************************************************
- * Copyright (c) 2020 Laurent CARON.
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors: Laurent CARON (laurent.caron at gmail dot com) - initial API and
- * implementation
- *******************************************************************************/
-package org.eclipse.nebula.widgets.chips;
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * Classes which implement this interface provide methods
- * that deal with the events that are generated when a Chips widget is closed.
- *
- * After creating an instance of a class that implements
- * this interface it can be added to a control using the
- * addCloseListener method and removed using
- * the removeCloseListener method. When
- * selection occurs in a control the appropriate method
- * will be invoked.
- *
- *
- * @see CloseEvent
- */
-@SuppressWarnings("restriction")
-@FunctionalInterface
-public interface CloseListener extends SWTEventListener {
- /**
- * Sent when a Chips widget is closed.
- *
- * @param e an event containing information about the chips that is closed
- */
- void onClose(CloseEvent event);
-}
+/*******************************************************************************
+ * Copyright (c) 2020 Laurent CARON.
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors: Laurent CARON (laurent.caron at gmail dot com) - initial API and
+ * implementation
+ *******************************************************************************/
+package org.eclipse.nebula.widgets.chips;
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated when a Chips widget is closed.
+ *
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * addCloseListener method and removed using
+ * the removeCloseListener method. When
+ * selection occurs in a control the appropriate method
+ * will be invoked.
+ *
- * Website
- * If you want more info or more documentation, please visit: http://www.hexapixel.com
- *
- * Description
- * ButtonComposite is a Widget that displays a vertical row of buttons similar
- * to the way that Microsoft® shows buttons in the bottom left of the
- * Microsoft Outlook 2005, and 2007 editions. The button bar is a collapsible
- * bar that contains an image, text, and an associated toolbar at the very
- * bottom where buttons that are currently "collapsed" are shown. There is also
- * a menu which is activated by clicking a small arrow icon on the toolbar that
- * will allow you to do actions that are similar to the actions you can do with
- * the mouse.
- *
- * The bar is resized by dragging the handle-bar which is at the very top. When
- * the mouse is clicked on the handlebar and dragged either up or down, buttons
- * will be shown and hidden accordingly. The button bar also has a feature where
- * - if there's no space to show the actively shown buttons due to progam window
- * size, buttons will automatically collapse to conserve space, and then
- * automatically expand back to the original number of visible buttons when the
- * program window is returned to a size where they can be shown.
- *
- * Where to put it
- * It is important to point out that due to the nature of the ButtonComposite,
- * it is important to put it inside a layout that will allow it to
- * expand/collapse with the widgets that are around it - as whenever a button is
- * shown/hidden, the actual physical size of the widget changes, which should
- * cause surrounding widgets to take up either more or less space. I personally
- * recommend putting the ButtonBar inside either a ViewForm, SashForm.
- *
- * If you still wish to put it on a plain composite, I suggest doing it the
- * following way:
- *
- *
- * // outer layer wrapper
- * Composite bcWrapper = new Composite(parentComposite, SWT.None);
- * GridLayout gl = new GridLayout(1, true);
- * gl.marginBottom = 0;
- * gl.marginHeight = 0;
- * gl.marginWidth = 0;
- * gl.marginHeight = 0;
- * inner.setLayout(gl);
- *
- * CollapsibleButtons cButtons = new CollapsibleButtons(bcWrapper, SWT.NONE);
- * // will ensure the composite takes up the appropriate amount of space and gets aligned correctly, we align it at the end as that is where it should live
- * cButtons.setLayoutData(new GridData(GridData.GRAB_VERTICAL | GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_END));
- * cButtons.addButton(...);
- *
- *
- * Customizing
- * As many people wish to customize the widget beyond the capabilities it
- * already has, there are a few ways you may basically take control over as much
- * or little as you please. First, there are three interfaces that are of
- * importance (apart from the IButtonListener), one is the IButtonPainter, the
- * IColorManager and the ISettings. Let's start with the IColorManager.
- *
- * IColorManager
- * If you don't specify a color manager, the DefaultColorManager will be used.
- * The color manager's job is to return colors to the method that is painting
- * the button when the button is drawn, when you move over a button, when you
- * select a button, and when you hover over a selected button. The colors that
- * are returned from the ColorManager will determine everything as far as looks
- * go.
- *
- * IButtonPainter
- * Then there's the IButtonPainter. The IButtonPainter lets you take over 3
- * methods, which are how A. The background colors of the button are painted. B.
- * How the text is drawn, and C. How the image is painted. As this is basically
- * 100% of how a button is drawn, you can control every aspect of the button
- * look and feel. By default, if no IButtonPainter is assigned, the
- * DefaultButtonPainter will be used. The IButtonPainter's paintBackground(...)
- * method is also used to draw all aspects of the tool bar. That way, the
- * toolbar automatically gets the same colors etc like the normal buttons.
- *
- * ISettings
- * To control a lot of the features, such as, whether to show the toolbar or
- * not, whether you want certain size buttons, painted borders, and so on, you
- * can create a class that implements ISettings and set it as the Settings
- * manager when you create a ButtonComposite. If you don't specify one,
- * DefaultSettings will be used.
- *
- * Each button is esentially a composite inside a custom layout, and the toolbar
- * is a composite by itself.
- *
- * If a toolbar is not wanted, you may control its visibility by implementing
- * ISettings
- *
+ * Website
+ * If you want more info or more documentation, please visit: http://www.hexapixel.com
+ *
+ * Description
+ * ButtonComposite is a Widget that displays a vertical row of buttons similar
+ * to the way that Microsoft® shows buttons in the bottom left of the
+ * Microsoft Outlook 2005, and 2007 editions. The button bar is a collapsible
+ * bar that contains an image, text, and an associated toolbar at the very
+ * bottom where buttons that are currently "collapsed" are shown. There is also
+ * a menu which is activated by clicking a small arrow icon on the toolbar that
+ * will allow you to do actions that are similar to the actions you can do with
+ * the mouse.
+ *
+ * The bar is resized by dragging the handle-bar which is at the very top. When
+ * the mouse is clicked on the handlebar and dragged either up or down, buttons
+ * will be shown and hidden accordingly. The button bar also has a feature where
+ * - if there's no space to show the actively shown buttons due to progam window
+ * size, buttons will automatically collapse to conserve space, and then
+ * automatically expand back to the original number of visible buttons when the
+ * program window is returned to a size where they can be shown.
+ *
+ * Where to put it
+ * It is important to point out that due to the nature of the ButtonComposite,
+ * it is important to put it inside a layout that will allow it to
+ * expand/collapse with the widgets that are around it - as whenever a button is
+ * shown/hidden, the actual physical size of the widget changes, which should
+ * cause surrounding widgets to take up either more or less space. I personally
+ * recommend putting the ButtonBar inside either a ViewForm, SashForm.
+ *
+ * If you still wish to put it on a plain composite, I suggest doing it the
+ * following way:
+ *
+ *
+ * // outer layer wrapper
+ * Composite bcWrapper = new Composite(parentComposite, SWT.None);
+ * GridLayout gl = new GridLayout(1, true);
+ * gl.marginBottom = 0;
+ * gl.marginHeight = 0;
+ * gl.marginWidth = 0;
+ * gl.marginHeight = 0;
+ * inner.setLayout(gl);
+ *
+ * CollapsibleButtons cButtons = new CollapsibleButtons(bcWrapper, SWT.NONE);
+ * // will ensure the composite takes up the appropriate amount of space and gets aligned correctly, we align it at the end as that is where it should live
+ * cButtons.setLayoutData(new GridData(GridData.GRAB_VERTICAL | GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_END));
+ * cButtons.addButton(...);
+ *
+ *
+ * Customizing
+ * As many people wish to customize the widget beyond the capabilities it
+ * already has, there are a few ways you may basically take control over as much
+ * or little as you please. First, there are three interfaces that are of
+ * importance (apart from the IButtonListener), one is the IButtonPainter, the
+ * IColorManager and the ISettings. Let's start with the IColorManager.
+ *
+ * IColorManager
+ * If you don't specify a color manager, the DefaultColorManager will be used.
+ * The color manager's job is to return colors to the method that is painting
+ * the button when the button is drawn, when you move over a button, when you
+ * select a button, and when you hover over a selected button. The colors that
+ * are returned from the ColorManager will determine everything as far as looks
+ * go.
+ *
+ * IButtonPainter
+ * Then there's the IButtonPainter. The IButtonPainter lets you take over 3
+ * methods, which are how A. The background colors of the button are painted. B.
+ * How the text is drawn, and C. How the image is painted. As this is basically
+ * 100% of how a button is drawn, you can control every aspect of the button
+ * look and feel. By default, if no IButtonPainter is assigned, the
+ * DefaultButtonPainter will be used. The IButtonPainter's paintBackground(...)
+ * method is also used to draw all aspects of the tool bar. That way, the
+ * toolbar automatically gets the same colors etc like the normal buttons.
+ *
+ * ISettings
+ * To control a lot of the features, such as, whether to show the toolbar or
+ * not, whether you want certain size buttons, painted borders, and so on, you
+ * can create a class that implements ISettings and set it as the Settings
+ * manager when you create a ButtonComposite. If you don't specify one,
+ * DefaultSettings will be used.
+ *
+ * Each button is esentially a composite inside a custom layout, and the toolbar
+ * is a composite by itself.
+ *
+ * If a toolbar is not wanted, you may control its visibility by implementing
+ * ISettings
+ *
+ * Double Buffering
+ * It is also important to note that the widget uses custom double buffering as
+ * neither Windows XP's or SWT's DOUBLE_BUFFER flag do the job well enough. To
+ * do a proper double buffer, the widget is first drawn into a cached Graphics
+ * object that is then copied onto the actual graphics object. This reduces
+ * flickering and other odd widget behavior. If you intend to run the widget on
+ * either Linux or Macintosh (which both know how to double buffer in the OS),
+ * you may turn it off.
+ *
+ * @author Emil Crumhorn
+ * @version 1.0
+ *
+ */
+public class CollapsibleButtons extends Composite implements MouseListener, MouseMoveListener, MouseTrackListener {
+
+ // cursors we'll use, hand is for mouse-button-overs, size-tool for resize
+ // bar
+ private static final Cursor CURSOR_SIZENS = CursorCache.getCursor(SWT.CURSOR_SIZENS);
+ private static final Cursor CURSOR_HAND = CursorCache.getCursor(SWT.CURSOR_HAND);
+
+ private int mResizeBarSize;
+
+ private Rectangle mBounds;
+ private Rectangle mMoveBar;
+
+ private List mButtons;
+
+ private int mButtonHeight;
+
+ private CustomButton mSelectedButton;
+
+ private boolean mMouseIsDown;
+ private int mStartY = 0;
+
+ private int mHiddenButtons = 0;
+
+ private ToolbarComposite mToolBarComposite;
+
+ // beats the built-in double buffering via SWT.DOUBLE_BUFFER
+ private boolean mEnableDoubleBuffering = true;
+ private boolean mCreated;
+
+ private int mInvoluntaryButtonLevel = -1;
+
+ private List mHidden;
+ private Composite mParent;
+
+ private int mColorTheme = IColorManager.SKIN_AUTO_DETECT;
+
+ private IColorManager mColorManager;
+ private List mButtonListeners;
+
+ private ISettings mSettings;
+ private ILanguageSettings mLanguage;
+
+ private List mMenuListeners;
+
+ /**
+ * Creates a new ButtonComposite. Add buttons using the addButton(...)
+ * method call.
+ *
+ * @param parent Parent composite
+ * @param style Composite style, SWT.NO_BACKGROUND will be appended to the
+ * style.
+ */
+ public CollapsibleButtons(Composite parent, int style) {
+ super(parent, checkStyle(style));
+ this.mParent = parent;
+ init();
+ }
+
+ /**
+ * Creates a new ButtonComposite with a given language manager.
+ *
+ * @param parent Parent composite
+ * @param style style
+ * @param language Language manager
+ */
+ public CollapsibleButtons(Composite parent, int style, ILanguageSettings language) {
+ this(parent, style, IColorManager.SKIN_AUTO_DETECT, null, null, language);
+ }
+
+ /**
+ * Creates a new ButtonComposite with a given settings and language manager.
+ *
+ * @param parent Parent composite
+ * @param style style
+ * @param settings Settings manager
+ * @param language Language manager
+ */
+ public CollapsibleButtons(Composite parent, int style, ISettings settings, ILanguageSettings language) {
+ this(parent, style, IColorManager.SKIN_AUTO_DETECT, null, settings, language);
+ }
+
+ /**
+ * Creates a new ButtonComposite. Add buttons using the addButton(...)
+ * method call.
+ *
+ * By default, unless you set a theme, the theme will be read from whatever
+ * the active color scheme is in Windows XP. If you are using a custom theme
+ * and the color scheme cannot be determined, the fall-back will be the
+ * Windows XP Blue theme.
+ *
+ * NOTE: If you want the Office 2007 theme, you have to set it manually as
+ * there is no way to guess if you have office 2007 installed or 2005.
+ *
+ * @param parent Parent composite
+ * @param style Composite style, SWT.NO_BACKGROUND will be appended to the
+ * style
+ * @param theme IColorManager.STYLE_
+ */
+ public CollapsibleButtons(Composite parent, int style, int theme) {
+ super(parent, checkStyle(style));
+ this.mColorTheme = theme;
+ this.mParent = parent;
+ init();
+ }
+
+ /**
+ * Creates a new ButtonComposite. Add buttons using the addButton(...)
+ * method call.
+ *
+ * @param parent Parent composite
+ * @param style Composite style, SWT.NO_BACKGROUND will be appended to the
+ * style
+ * @param colorManager IColorManager implementation. Set to null to use the
+ * default
+ */
+ public CollapsibleButtons(Composite parent, int style, IColorManager colorManager) {
+ super(parent, checkStyle(style));
+ this.mParent = parent;
+ init();
+ }
+
+ /**
+ * Creates a new ButtonComposite. Add buttons using the addButton(...)
+ * method call.
+ *
+ * By default, unless you set a theme, the theme will be read from whatever
+ * the active color scheme is in Windows XP. If you are using a custom theme
+ * and the color scheme cannot be determined, the fall-back will be the
+ * Windows XP Blue theme.
+ *
+ * NOTE: If you want the Office 2007 theme, you have to set it manually as
+ * there is no way to guess if you have office 2007 installed or 2005.
+ *
+ * @param parent Parent composite
+ * @param style Composite style, SWT.NO_BACKGROUND will be appended to the
+ * style
+ * @param theme IColorManager.STYLE_
+ * @param colorManager IColorManager implementation. Set to null to use the
+ * default
+ */
+ public CollapsibleButtons(Composite parent, int style, int theme, IColorManager colorManager) {
+ super(parent, checkStyle(style));
+ this.mColorTheme = theme;
+ this.mParent = parent;
+ init();
+ }
+
+ /**
+ * Creates a new ButtonComposite. Add buttons using the addButton(...)
+ * method call.
+ *
+ * By default, unless you set a theme, the theme will be read from whatever
+ * the active color scheme is in Windows XP. If you are using a custom theme
+ * and the color scheme cannot be determined, the fall-back will be the
+ * Windows XP Blue theme.
+ *
+ * NOTE: If you want the Office 2007 theme, you have to set it manually as
+ * there is no way to guess if you have office 2007 installed or 2005.
+ *
+ * @param parent Parent composite
+ * @param style Composite style, SWT.NO_BACKGROUND will be appended to the
+ * style
+ * @param theme IColorManager.STYLE_
+ * @param colorManager IColorManager implementation. Set to null to use the
+ * default
+ * @param settings ISettings implementation. Set to null to use the default
+ * @param language ILanguage implementations. Set to null to use the
+ * default.
+ */
+ public CollapsibleButtons(Composite parent, int style, int theme, IColorManager colorManager, ISettings settings, ILanguageSettings language) {
+ super(parent, checkStyle(style));
+ this.mColorTheme = theme;
+ this.mColorManager = colorManager;
+ this.mParent = parent;
+ this.mSettings = settings;
+ this.mLanguage = language;
+ init();
+ }
+
+ private static int checkStyle(int style) {
+ int mask = SWT.BORDER | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT | SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.MULTI | SWT.NO_FOCUS | SWT.CHECK | SWT.VIRTUAL;
+ int newStyle = style & mask;
+ newStyle |= SWT.NO_BACKGROUND;
+ return newStyle;
+ }
+
+ /**
+ * Adds a new IButtonListener listener that will report clicks and other
+ * events.
+ *
+ * @param listener IButtonListener
+ */
+ public void addButtonListener(IButtonListener listener) {
+ checkWidget();
+ if (!mButtonListeners.contains(listener))
+ mButtonListeners.add(listener);
+ }
+
+ /**
+ * Removes an IButtonListener
+ *
+ * @param listener IButtonListener
+ */
+ public void removeButtonListener(IButtonListener listener) {
+ checkWidget();
+ mButtonListeners.remove(listener);
+ }
+
+ private void init() {
+ // we need one, or *crash*
+ if (mColorManager == null)
+ mColorManager = new DefaultColorManager(mColorTheme);
+
+ // same here
+ if (mSettings == null)
+ mSettings = new DefaultSettings();
+
+ if (mLanguage == null)
+ mLanguage = new DefaultLanguageManager();
+
+ // outlook 2007 specific
+ if (mColorTheme == IColorManager.SKIN_OFFICE_2007)
+ mResizeBarSize = mSettings.getOutlook2007ResizeBarSize();
+ else
+ mResizeBarSize = mSettings.getOutlook2005ResizeBarSize();
+
+ mButtonHeight = mSettings.getButtonHeight();
+
+ mMenuListeners = new ArrayList<>();
+ mButtons = new ArrayList<>();
+ mHidden = new ArrayList<>();
+ mButtonListeners = new ArrayList<>();
+
+ // this lets us auto-fit the buttons to the aviaiable space when the
+ // parent composite is resized.
+ // Outlook does the same thing when the buttons don't have enough space.
+ // We hide 1 button per call,
+ // which should be enough as the next call will to 99.9% certainty in
+ // less than 31 pixels (or whatever the button size is).
+ // when the control is manually resized we reset the invuluntary size as
+ // a "new size" has been picked, and that's
+ // the starting point for the next invuluntary size if any. Confusing?
+ // Just try it then look at the code.
+ mParent.addListener(SWT.Resize, e-> {
+ int availableHeight = mParent.getClientArea().height;
+ int neededHeight = getBounds().height;
+
+ if (availableHeight < neededHeight) {
+ if (mInvoluntaryButtonLevel == -1) {
+ mInvoluntaryButtonLevel = getNumVisibleButtons();
+ }
+
+ hideNextButton();
+ }
+
+ if (mInvoluntaryButtonLevel != -1) {
+ if (availableHeight - mButtonHeight > neededHeight) {
+ if (getNumVisibleButtons() < mInvoluntaryButtonLevel) {
+ showNextButton();
+ }
+ }
+ }
+ });
+
+ addListener(SWT.Paint, event -> repaint(event));
+ addListener(SWT.FocusOut, event -> redraw());
+ addListener(SWT.MouseExit, event -> setCursor(null));
+
+ addMouseListener(this);
+
+ addListener(SWT.MouseMove, event -> {
+ Point p = toDisplay(new Point(event.x, event.y));
+
+ if (!mMouseIsDown) {
+ if (isInside(event.x, event.y, mMoveBar)) {
+ if (mSettings.allowButtonResizing()) {
+ setCursor(CURSOR_SIZENS);
+ }
+ } else {
+ setCursor(null);
+ }
+ }
+
+ if (mMouseIsDown) {
+ // reset the "forced size" value, as we resized it to pick
+ // what size we wanted
+ mInvoluntaryButtonLevel = -1;
+ int diff = p.y - mStartY;
+
+ if (diff > mButtonHeight) {
+ // ensures bar doesn't get smaller unless mouse pointer
+ // is south of the move-bar
+ if (event.y < mMoveBar.y) {
+ return;
+ }
+
+ hideNextButton();
+ mStartY = p.y;
+ } else {
+ if (Math.abs(diff) > mButtonHeight) {
+ showNextButton();
+ mStartY = p.y;
+ }
+ }
+ }
+ });
+
+ setLayout(new VerticalLayout());
+ }
+
+ private void repaint(Event event) {
+ GC gc = event.gc;
+ if (mCreated && mEnableDoubleBuffering) {
+ try {
+ Image buffer = new Image(Display.getDefault(), super.getBounds());
+ GC gc2 = new GC(buffer);
+ drawOntoGC(gc2);
+
+ // transfer the image buffer onto this canvas
+ // just drawImage(buffer, w, h) didn't work, so we do the whole
+ // source transfer call
+ Rectangle b = getBounds();
+ gc.drawImage(buffer, 0, 0, b.width, b.height, 0, 0, b.width, b.height);
+
+ // dispose the buffer, very important or we'll run out of
+ // address space for buffered images
+ buffer.dispose();
+ gc2.dispose();
+ } catch (IllegalArgumentException iea) {
+ // seems to come here for some reason when we switch phases
+ // while the gantt chart is being viewed, I'm not sure why
+ // but no time to figure it out for the demo.. so instead of
+ // buffering, just draw it onto the GC
+ drawOntoGC(gc);
+ }
+ } else {
+ drawOntoGC(gc);
+ mCreated = true;
+
+ }
+ }
+
+ private void drawOntoGC(GC gc) {
+ gc.setBackground(mColorManager.getBorderColor());
+ gc.fillRectangle(getClientArea());
+
+ mBounds = super.getBounds();
+
+ gc.setBackground(mColorManager.getDarkResizeColor());
+ gc.setForeground(mColorManager.getLightResizeColor());
+
+ gc.fillGradientRectangle(0, 0, mBounds.width, mResizeBarSize, true);
+ mMoveBar = new Rectangle(0, 0, mBounds.width, mResizeBarSize);
+
+ // office 2007 draws a 1 pixel around the resize bar, let's do that too
+ if (mColorManager.getTheme() == IColorManager.SKIN_OFFICE_2007) {
+ // top line inside is white, rest is gradient down to the next dark
+ // color that is the border
+ gc.setForeground(IColorManager.white);
+ gc.drawLine(0, 0, mBounds.width, 0);
+
+ // do the gradient
+ gc.setBackground(mColorManager.getDarkResizeColor());
+ gc.setForeground(mColorManager.getLightResizeColor());
+
+ gc.fillGradientRectangle(0, 2, mBounds.width, mResizeBarSize - 2, true);
+
+ gc.setForeground(mColorManager.getBorderColor());
+ gc.drawLine(0, 0, mBounds.width, 0);
+ gc.drawLine(0, mResizeBarSize - 1, mBounds.width, mResizeBarSize - 1);
+
+ if (mSettings.drawBorder()) {
+ gc.drawLine(0, 0, 0, mResizeBarSize);
+ gc.drawLine(mBounds.width - 1, 0, mBounds.width - 1, mResizeBarSize);
+ }
+ }
+
+ drawMarkers(gc);
+ }
+
+ private void drawMarkers(GC gc) {
+ int numMarkers;
+ if (mColorManager.getTheme() == IColorManager.SKIN_OFFICE_2007)
+ numMarkers = mSettings.getOutlook2007ResizeDotNumber();
+ else
+ numMarkers = mSettings.getOutlook2005ResizeDotNumber();
+
+ int start = (mBounds.width / 2) - numMarkers * 2;
+ int extra = 0;
+
+ // -1 is to align
+ int y = (mResizeBarSize / 2) - 1;
+ if (y < 0)
+ y = 0;
+
+ for (int i = 0; i < numMarkers; i++) {
+ drawMarker(gc, start + extra, y);
+ extra += 4;
+ }
+ }
+
+ // draws a squared "shaded" marker on the resize bar
+ private void drawMarker(GC gc, int x, int y) {
+ gc.setBackground(mColorManager.getDotDarkColor());
+ gc.fillRectangle(x, y, 2, 2);
+ gc.setBackground(mColorManager.getDotMiddleColor());
+ gc.fillRectangle(x + 1, y + 1, 2, 2);
+ gc.setBackground(mColorManager.getDotLightColor());
+ gc.fillRectangle(x + 1, y + 1, 1, 1);
+ }
+
+ public void mouseMove(MouseEvent event) {
+ }
+
+ /**
+ * Returns the number of currently visible buttons.
+ *
+ * @return Number of visible buttons
+ */
+ public int getNumVisibleButtons() {
+ checkWidget();
+ int num = 0;
+ for (int i = 0; i < mButtons.size(); i++) {
+ CustomButton b = mButtons.get(i);
+ if (b.isVisible())
+ num++;
+ }
+ return num;
+ }
+
+ /**
+ * Hides the button from the list and the toolbar.
+ *
+ * @param button Button to hide
+ */
+ public void permanentlyHideButton(CustomButton button) {
+ checkWidget();
+ if (mHidden.contains(button))
+ return;
+
+ mHidden.add(button);
+
+ for (int i = 0; i < mButtons.size(); i++) {
+ CustomButton b = mButtons.get(i);
+ if (b == button) {
+ if (b.isVisible()) {
+ b.setVisible(false);
+ // Don't redraw until stuff is laid out, that way, no
+ // toolbar ghosting!
+ mHiddenButtons++;
+ setRedraw(false);
+ // parent needs to re-adjust it's size, which in turn
+ // adjusts our size via (true) as that forces
+ // children (us) to resize.
+ getParent().layout(true);
+ setRedraw(true);
+ }
+
+ // mToolBarComposite.removeItem(b);
+ mToolBarComposite.hideButton(b);
+ mToolBarComposite.redraw();
+ break;
+ }
+ }
+ }
+
+ /**
+ * Un-hides a button that has been hidden from toolbar and ButtonComposite
+ * view.
+ *
+ * @param button Button to show
+ */
+ public void permanentlyShowButton(CustomButton button) {
+ checkWidget();
+ mHidden.remove(button);
+
+ for (int i = 0; i < mButtons.size(); i++) {
+ CustomButton b = mButtons.get(i);
+
+ if (b == button) {
+ if (!b.isVisible()) {
+ b.setVisible(true);
+ mHiddenButtons--;
+ // Don't redraw until stuff is laid out, that way, no
+ // toolbar ghosting!
+ setRedraw(false);
+ // parent needs to re-adjust it's size, which in turn
+ // adjusts our size via (true) as that forces
+ // children (us) to resize.
+ getParent().layout(true);
+ setRedraw(true);
+ }
+
+ mToolBarComposite.removeItem(b);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Hides the given button (and adds it to the toolbar).
+ *
+ * @param button Button to hide
+ */
+ public void hideButton(CustomButton button) {
+ checkWidget();
+ for (int i = 0; i < mButtons.size(); i++) {
+ CustomButton b = mButtons.get(i);
+ if (b == button) {
+ // if (label.isVisible() == true) {
+ b.setVisible(false);
+ // Don't redraw until stuff is laid out, that way, no toolbar
+ // ghosting!
+ mHiddenButtons++;
+ setRedraw(false);
+ // parent needs to re-adjust it's size, which in turn adjusts
+ // our size via (true) as that forces
+ // children (us) to resize.
+ getParent().layout(true);
+ setRedraw(true);
+ // }
+
+ mToolBarComposite.addItem(b);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Shows the given button (and removes it from the toolbar).
+ *
+ * @param button Button to show
+ */
+ public void showButton(CustomButton button) {
+ checkWidget();
+ for (int i = 0; i < mButtons.size(); i++) {
+ CustomButton b = mButtons.get(i);
+
+ if (b == button) {
+ if (!b.isVisible()) {
+ b.setVisible(true);
+ mHiddenButtons--;
+ // Don't redraw until stuff is laid out, that way, no
+ // toolbar ghosting!
+ setRedraw(false);
+ // parent needs to re-adjust it's size, which in turn
+ // adjusts our size via (true) as that forces
+ // children (us) to resize.
+ getParent().layout(true);
+ setRedraw(true);
+ }
+
+ mToolBarComposite.addItem(b);
+ mToolBarComposite.redraw();
+ break;
+ }
+ }
+ }
+
+ /**
+ * If a button is permanently hidden or permanently shown.
+ *
+ * @param button CustomButton to check
+ * @return true or false
+ */
+ public boolean isVisible(CustomButton button) {
+ checkWidget();
+ return !mHidden.contains(button);
+ }
+
+ /**
+ * Hides the next button furthest down in the list. If there are no more
+ * buttons left to hide, nothing will happen.
+ *
+ */
+ public void hideNextButton() {
+ checkWidget();
+ if (!mSettings.allowButtonResizing()) {
+ return;
+ }
+
+ for (int i = (mButtons.size() - 1); i >= 0; i--) {
+ CustomButton b = mButtons.get(i);
+
+ if (mHidden.contains(b))
+ continue;
+
+ if (b.isVisible()) {
+ mHiddenButtons++;
+ b.setVisible(false);
+ // laying out the parent with true forces us to layout too, so
+ // don't overdo it by calling layout(true) locally
+ setRedraw(false);
+ getParent().layout(true);
+ setRedraw(true);
+
+ mToolBarComposite.addItem(b);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Should you ever need to force a re-layout of the composite, this is the
+ * method to call. It is not recommended to be used.
+ *
+ */
+ public void forceLayoutUpdate() {
+ checkWidget();
+ getParent().layout(true);
+ }
+
+ /**
+ * Shows the next button from the list of buttons that are currently hidden.
+ * If there are no more buttons hiding, nothing will happen.
+ *
+ */
+ public void showNextButton() {
+ checkWidget();
+ if (!mSettings.allowButtonResizing()) {
+ return;
+ }
+
+ for (int i = 0; i < mButtons.size(); i++) {
+ CustomButton b = mButtons.get(i);
+
+ if (mHidden.contains(b))
+ continue;
+
+ if (!b.isVisible()) {
+ mHiddenButtons--;
+ b.setVisible(true);
+ // Don't redraw until stuff is laid out, that way, no toolbar
+ // ghosting!
+ setRedraw(false);
+ // parent needs to re-adjust it's size, which in turn adjusts
+ // our size via (true) as that forces
+ // children (us) to resize.
+ getParent().layout(true);
+ setRedraw(true);
+
+ mToolBarComposite.removeItem(b);
+ break;
+ }
+ }
+ }
+
+ // rectangle intersection, the easier way
+ private boolean isInside(int x, int y, Rectangle rect) {
+ if (rect == null)
+ return false;
+
+ return x >= rect.x && y >= rect.y && x <= (rect.x + rect.width) && y <= (rect.y + rect.height);
+ }
+
+ /**
+ * Adds a button to the composite. Button will be added at the bottom of any
+ * previously existing buttons.
+ *
+ * @param name Text that should be displayed on button. May be null.
+ * @param toolTip Tooltip that is displayed when mouse moves over both
+ * button and tool bar icon. Recommended null.
+ * @param bigImage Image displayed on the button. Ideally 24x24 pixels
+ * transparent PNG image.
+ * @param toolbarImage Image displayed on the toolbar and on any menu items.
+ * Ideally 16x16 pixels transparent GIF image.
+ * @return CustomButton for further pre-launch modification.
+ */
+ public CustomButton addButton(String name, String toolTip, Image bigImage, Image toolbarImage) {
+ checkWidget();
+ return addButton(name, toolTip, bigImage, toolbarImage, false);
+ }
+
+ // _addButton
+ private CustomButton addButton(String name, String toolTip, Image bigImage, Image toolbarImage, boolean selected) {
+ checkWidget();
+ CustomButton cb = new CustomButton(this, SWT.FLAT, name, bigImage, toolbarImage, toolTip, mSettings);
+
+ cb.addMouseListener(this);
+ cb.addMouseTrackListener(this);
+
+ mButtons.add(cb);
+
+ if (mToolBarComposite == null)
+ mToolBarComposite = new ToolbarComposite(this, SWT.NONE);
+
+ mParent.redraw();
+ mParent.layout();
+
+ reindexButtons();
+ return cb;
+
+ }
+
+ private void reindexButtons() {
+ for (int i = 0; i < mButtons.size(); i++) {
+ mButtons.get(i).setNumber(i);
+ }
+ }
+
+ public void mouseDoubleClick(MouseEvent event) {
+ checkWidget();
+ }
+
+ public void mouseDown(MouseEvent event) {
+ checkWidget();
+ Point p = toDisplay(new Point(event.x, event.y));
+ mStartY = p.y;
+ mMouseIsDown = true;
+
+ if (event.widget instanceof CustomButton) {
+ CustomButton cb = (CustomButton) event.widget;
+ if (event.button == 1) {
+ if (mSelectedButton != null && cb.equals(mSelectedButton))
+ return;
+
+ for (int i = 0; i < mButtonListeners.size(); i++) {
+ IButtonListener inav = mButtonListeners.get(i);
+ inav.buttonClicked(cb, event);
+ }
+
+ selectButton(cb);
+ }
+ }
+ }
+
+ public void mouseUp(MouseEvent event) {
+ checkWidget();
+ setCursor(null);
+ mMouseIsDown = false;
+ }
+
+ public Point getSize() {
+ checkWidget();
+ int bs = mButtons.size() - mHiddenButtons;
+ int y = bs * (mButtonHeight + 1);
+ if (mSettings.showToolBar()) {
+ y += mButtonHeight;
+ }
+
+ y += mResizeBarSize;
+
+ return new Point(super.getSize().x, y);
+ }
+
+ public void mouseEnter(MouseEvent event) {
+ checkWidget();
+ if (event.widget instanceof CustomButton) {
+ CustomButton cb = (CustomButton) event.widget;
+
+ setCursor(CURSOR_HAND);
+
+ cb.updateHover(true);
+
+ for (int i = 0; i < mButtonListeners.size(); i++) {
+ IButtonListener inav = mButtonListeners.get(i);
+ inav.buttonEnter(cb, event);
+ }
+ }
+ }
+
+ public void mouseExit(MouseEvent event) {
+ checkWidget();
+ if (event.widget instanceof CustomButton) {
+ CustomButton cb = (CustomButton) event.widget;
+ cb.updateHover(false);
+
+ setCursor(null);
+
+ for (int i = 0; i < mButtonListeners.size(); i++) {
+ IButtonListener inav = mButtonListeners.get(i);
+ inav.buttonExit(cb, event);
+ }
+ }
+ }
+
+ public void mouseHover(MouseEvent event) {
+ checkWidget();
+ if (event.widget instanceof CustomButton) {
+ CustomButton cb = (CustomButton) event.widget;
+
+ for (int i = 0; i < mButtonListeners.size(); i++) {
+ IButtonListener inav = mButtonListeners.get(i);
+ inav.buttonHover(cb, event);
+ }
+ }
+ }
+
+ /**
+ * Flags a button as selected and pretends it got clicked.
+ *
+ * @param button Button to select and click
+ */
+ public void selectItemAndLoad(CustomButton button) {
+ checkWidget();
+ selectItem(button);
+ for (int i = 0; i < mButtonListeners.size(); i++) {
+ IButtonListener inav = mButtonListeners.get(i);
+ inav.buttonClicked(getSelection(), null);
+ }
+ }
+
+ /**
+ * Selects a specific CustomButton.
+ *
+ * @param button CustomButton to select
+ */
+ public void selectItem(CustomButton button) {
+ checkWidget();
+ for (int i = 0; i < mButtons.size(); i++) {
+ CustomButton b = mButtons.get(i);
+ if (b == button) {
+ selectButton(button);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Deselects all buttons
+ */
+ public void deselectAll() {
+ if (mSelectedButton != null) {
+ mSelectedButton.updateSelection(false);
+ }
+ mSelectedButton = null;
+ mToolBarComposite.setSelectedItem(null);
+ redraw();
+ }
+
+ // selects a button
+ private void selectButton(CustomButton button) {
+ if (mSelectedButton != null) {
+ if (mSelectedButton.equals(button))
+ return;
+
+ // clear old selection
+ mSelectedButton.updateSelection(false);
+ }
+
+ // set new selection
+ button.updateSelection(true);
+ mSelectedButton = button;
+ mToolBarComposite.setSelectedItem(mSelectedButton);
+ }
+
+ /**
+ * Returns the list of all buttons.
+ *
+ * @return List of buttons
+ */
+ public List getItems() {
+ checkWidget();
+ return mButtons;
+ }
+
+ /**
+ * Returns the current selection, or null if none.
+ *
+ * @return Selected button.
+ */
+ public CustomButton getSelection() {
+ checkWidget();
+ return mSelectedButton;
+ }
+
+ /**
+ * Returns the number of buttons in the list.
+ *
+ * @return Button count
+ */
+ public int itemCount() {
+ checkWidget();
+ return mButtons.size();
+ }
+
+ /**
+ * Returns the active color manager.
+ *
+ * @return IColorManager
+ */
+ public IColorManager getColorManager() {
+ checkWidget();
+ return mColorManager;
+ }
+
+ /**
+ * Returns the current Settings manager.
+ *
+ * @return ISettings
+ */
+ public ISettings getSettings() {
+ checkWidget();
+ return mSettings;
+ }
+
+ /**
+ * Returns the current Language settings manager.
+ *
+ * @return ILanguageSettings
+ */
+ public ILanguageSettings getLanguageSettings() {
+ checkWidget();
+ return mLanguage;
+ }
+
+ /**
+ * Returns the toolbar composite.
+ *
+ * @return ToolbarComposite
+ */
+ public ToolbarComposite getToolbarComposite() {
+ checkWidget();
+ return mToolBarComposite;
+ }
+
+ /**
+ * Adds a menu listener that is notified before and after the menu popup is shown.
+ *
+ * @param listener Listener to add
+ */
+ public void addMenuListener(IMenuListener listener) {
+ if (!mMenuListeners.contains(listener))
+ mMenuListeners.add(listener);
+ }
+
+ /**
+ * Removes a menu listener.
+ *
+ * @param listener Listener to remove
+ */
+ public void removeMenuListener(IMenuListener listener) {
+ mMenuListeners.remove(listener);
+ }
+
+ /**
+ * Removes all buttons.
+ */
+ public void removeAllButtons() {
+ checkWidget();
+
+ // remove them in reverse or we'll have some interesting issues
+ for (int i = mButtons.size()-1; i >= 0; i--) {
+ mButtons.get(i).dispose();
+ }
+
+ if (mToolBarComposite != null)
+ mToolBarComposite.removeAll();
+
+ mButtonListeners.clear();
+ mButtons.clear();
+ mParent.redraw();
+ mParent.layout();
+ }
+
+ /**
+ * Same method that is called when {@link CustomButton#dispose()} is called.
+ *
+ * @param cb CustomButton to remove
+ */
+ public void removeButton(CustomButton cb) {
+ checkWidget();
+ remove(cb, true);
+ }
+
+ // internal remove of button
+ void remove(CustomButton cb, boolean callDispose) {
+ cb.removeMouseListener(this);
+ cb.removeMouseTrackListener(this);
+
+ mButtons.remove(cb);
+
+ if (mToolBarComposite != null)
+ mToolBarComposite.removeItem(cb);
+
+ mParent.redraw();
+ mParent.layout();
+
+ if (callDispose)
+ cb.dispose();
+
+ reindexButtons();
+ }
+
+ List getMenuListeners() {
+ return mMenuListeners;
+ }
+
+ // layout class that deals with the actual layout of the buttons, toolbar
+ // and other drawn items
+ class VerticalLayout extends Layout {
+
+ public VerticalLayout() {
+ }
+
+ protected Point computeSize(Composite aComposite, int wHint, int hHint, boolean flushCache) {
+ return getSize();
+ }
+
+ protected void layout(final Composite aComposite, boolean flushCache) {
+ int top = mResizeBarSize;
+ int left = (mSettings.drawBorder() ? 1 : 0);
+
+ if (mSettings.showToolBar()) {
+ int toolTop = top;
+
+ // calculate where toolbar goes first, causes less ghosting
+ for (int i = 0; i < mButtons.size(); i++) {
+ CustomButton button = mButtons.get(i);
+ if (!button.isVisible()) {
+ continue;
+ }
+
+ toolTop += mButtonHeight + 1;
+ }
+
+ if (mToolBarComposite != null)
+ mToolBarComposite.setBounds(left, toolTop, aComposite.getBounds().width - (mSettings.drawBorder() ? 2 : 0), mButtonHeight);
+ }
+
+ // now set the toolbars
+ for (int i = 0; i < mButtons.size(); i++) {
+ CustomButton button = mButtons.get(i);
+ if (!button.isVisible()) {
+ continue;
+ }
+
+ button.setBounds(left, top, aComposite.getBounds().width - (mSettings.drawBorder() ? 2 : 0), mButtonHeight);
+ top += mButtonHeight + 1;
+ }
+ }
+ }
+}
diff --git a/widgets/collapsiblebuttons/org.eclipse.nebula.widgets.collapsiblebuttons/src/org/eclipse/nebula/widgets/collapsiblebuttons/ColorCache.java b/widgets/collapsiblebuttons/org.eclipse.nebula.widgets.collapsiblebuttons/src/org/eclipse/nebula/widgets/collapsiblebuttons/ColorCache.java
index e3c256abc..c4ef137ca 100644
--- a/widgets/collapsiblebuttons/org.eclipse.nebula.widgets.collapsiblebuttons/src/org/eclipse/nebula/widgets/collapsiblebuttons/ColorCache.java
+++ b/widgets/collapsiblebuttons/org.eclipse.nebula.widgets.collapsiblebuttons/src/org/eclipse/nebula/widgets/collapsiblebuttons/ColorCache.java
@@ -1,327 +1,327 @@
-/*******************************************************************************
- * Copyright (c) Emil Crumhorn - Hexapixel.com - emil.crumhorn@gmail.com
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * emil.crumhorn@gmail.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.nebula.widgets.collapsiblebuttons;
-
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
-
-public class ColorCache {
-
- public static final RGB BLACK = new RGB(0, 0, 0);
- public static final RGB WHITE = new RGB(255, 255, 255);
-
- private static HashMap mColorTable;
- private static ColorCache mInstance;
-
- public static final int SKIN_NONE = -1;
- public static final int SKIN_AUTO = 0; // auto detect
- public static final int SKIN_BLUE = 1;
- public static final int SKIN_OLIVE = 2;
- public static final int SKIN_SILVER = 3;
- public static final int SKIN_OFFICE_2007 = 4;
-
- public static final int SKIN_FALLBACK = SKIN_BLUE; // if auto fails, what skin to use
-
- public static int SKIN_CURRENT = SKIN_AUTO;
-
- /**
- * Disposes all colors held in the cache and colors created when class is created.
- *
- * IMPORTANT: ONLY CALL WHEN YOU WANT TO DISPOSE THE WIDGET USING THIS CLASS!
- *
- * If you only wish to dispose colors you have created through the use of the class, please use disposeCachedColors()
- *
- * @see #disposeCachedColor()
- */
- public static void disposeAll() {
- mInstance.dispose();
-
- blueHeaderColor = null;
- lightBlueButtonColor = null;
- blueButtonBackground = null;
- blueToolbarColor = null;
- lightBlueToolbarcolor = null;
- oliveHeaderColor = null;
- lightOliveButtonColor = null;
- lightOliveButtonColor = null;
- oliveButtonBackground = null;
- oliveToolbarColor = null;
- lightOliveToolbarcolor = null;
- silverHeaderColor = null;
- lightSilverButtonColor = null;
- silverButtonBackground = null;
- silverToolbarColor = null;
- lightSilverToolbarcolor = null;
- lightBrownColor = null;
- lightBrownColorReverse = null;
- darkBrownColor = null;
- calendarBlueHeader = null;
- calendarBlueBorder = null;
- calendarOliveHeader = null;
- calendarOliveBorder = null;
- calendarSilverBorder = null;
- calendarSilverHeader = null;
- }
-
- /**
- * Disposes the cached colors only.
- */
- public static void disposeCachedColor() {
- Iterator e = mColorTable.values().iterator();
- while (e.hasNext()) e.next().dispose();
-
- mColorTable.clear();
- }
-
- // -- blue skin
- public static Color [] blueHeaderColor = new Color[]{
- ColorCache.getColor(89, 135, 214),
- ColorCache.getColor(3, 56, 148),
- ColorCache.getColor(89, 135, 214)
- };
-
- public static Color [] lightBlueButtonColor = new Color[]{
- ColorCache.getColor(203, 225, 252),
- ColorCache.getColor(125, 165, 224),
- ColorCache.getColor(203, 225, 252)
- };
-
- public static Color blueButtonBackground = ColorCache.getColor(3, 56, 148);
-
- public static Color blueToolbarColor = ColorCache.getColor(77, 124, 205);
- public static Color lightBlueToolbarcolor = ColorCache.getColor(170, 199, 246);
- // -- end blue skin
-
- // toolbar
- public static Color [] oliveHeaderColor = new Color[]{
- ColorCache.getColor(175, 192, 130), // light
- ColorCache.getColor(99, 122, 68), // dark
- ColorCache.getColor(175, 192, 130) // light
- };
-
- // buttons
- public static Color [] lightOliveButtonColor = new Color[]{
- ColorCache.getColor(232, 238, 204),
- ColorCache.getColor(177, 192, 140),
- ColorCache.getColor(232, 238, 204)
- };
-
- public static Color oliveButtonBackground = ColorCache.getColor(99, 122, 68);
-
- public static Color oliveToolbarColor = ColorCache.getColor(230, 230, 200);
- public static Color lightOliveToolbarcolor = ColorCache.getColor(232, 232, 206);
- // -- end olive skin
-
- // -- silver skin
- public static Color [] silverHeaderColor = new Color[]{
- ColorCache.getColor(168, 167, 191), // light
- ColorCache.getColor(124, 124, 148), // dark
- ColorCache.getColor(168, 167, 191) // light
- };
-
- // buttons
- public static Color [] lightSilverButtonColor = new Color[]{
- ColorCache.getColor(225, 226, 236),
- ColorCache.getColor(149, 147, 177),
- ColorCache.getColor(225, 226, 236)
- };
-
- public static Color silverButtonBackground = ColorCache.getColor(124, 124, 148);
-
- public static Color silverToolbarColor = ColorCache.getColor(164, 163, 187);
- public static Color lightSilverToolbarcolor = ColorCache.getColor(231, 231, 239);
- // -- end silver skin
-
- public static Color [] lightBrownColor = new Color[]{
- ColorCache.getColor(254, 252, 215),
- ColorCache.getColor(247, 192, 91),
- ColorCache.getColor(254, 252, 215)
- };
-
- public static Color [] lightBrownColorReverse = new Color[]{
- ColorCache.getColor(247, 192, 91),
- ColorCache.getColor(254, 252, 215),
- ColorCache.getColor(247, 192, 91)
- };
-
- public static Color [] darkBrownColor = new Color[]{
- ColorCache.getColor(232, 127, 8),
- ColorCache.getColor(247, 218, 124),
- ColorCache.getColor(232, 127, 8)
- };
-
- public static Color calendarBlueHeader = ColorCache.getColor(158, 190, 245);
- public static Color calendarBlueBorder = ColorCache.getColor(127, 157, 185);
-
- public static Color calendarOliveHeader = ColorCache.getColor(217, 217, 167);
- public static Color calendarOliveBorder = ColorCache.getColor(164, 185, 127);
-
- public static Color calendarSilverHeader = ColorCache.getColor(215, 215, 229);
- public static Color calendarSilverBorder = ColorCache.getColor(157, 157, 161);
-
- // office 2007 does chrome gradients, top color goes 12 pixels down
- public static Color o2007blueTop = ColorCache.getColor(227, 239, 255);
- public static Color o2007blueMid = ColorCache.getColor(173, 209, 255);
- public static Color o2007blueBot = ColorCache.getColor(192, 219, 255);
-
- public static Color o2007orangeSelectedTop = ColorCache.getColor(255, 217, 170);
- public static Color o2007orangeSelectedMid = ColorCache.getColor(255, 187, 110);
- public static Color o2007orangeSelectedBot = ColorCache.getColor(254, 225, 122);
-
- public static Color o2007orangeHoveredTop = ColorCache.getColor(255, 254, 228);
- public static Color o2007orangeHoveredMid = ColorCache.getColor(255, 232, 167);
- public static Color o2007orangeHoveredBot = ColorCache.getColor(255, 230, 158);
-
- public static Color o2007buttonBackgroundColor = ColorCache.getColor(101, 147, 207);
-
- private ColorCache() {
- if (mColorTable == null) {
- mColorTable = new HashMap<>();
- }
- }
-
- private static void checkInstance() {
- if (mInstance == null)
- mInstance = new ColorCache();
- }
-
- // see disposeAll();
- private void dispose() {
- checkInstance();
-
- Iterator e = mColorTable.values().iterator();
- while (e.hasNext()) e.next().dispose();
-
- mColorTable.clear();
-
- for (int i = 0; i < blueHeaderColor.length; i++) {
- Color color = blueHeaderColor[i];
- color.dispose();
- }
-
- for (int i = 0; i < darkBrownColor.length; i++) {
- Color color = darkBrownColor[i];
- color.dispose();
- }
-
- for (int i = 0; i < lightBlueButtonColor.length; i++) {
- Color color = lightBlueButtonColor[i];
- color.dispose();
- }
-
- for (int i = 0; i < lightBrownColor.length; i++) {
- Color color = lightBrownColor[i];
- color.dispose();
- }
-
- for (int i = 0; i < lightBrownColorReverse.length; i++) {
- Color color = lightBrownColorReverse[i];
- color.dispose();
- }
-
- for (int i = 0; i < lightOliveButtonColor.length; i++) {
- Color color = lightOliveButtonColor[i];
- color.dispose();
- }
-
- for (int i = 0; i < lightSilverButtonColor.length; i++) {
- Color color = lightSilverButtonColor[i];
- color.dispose();
- }
-
- for (int i = 0; i < oliveHeaderColor.length; i++) {
- Color color = oliveHeaderColor[i];
- color.dispose();
- }
-
- for (int i = 0; i < silverHeaderColor.length; i++) {
- Color color = silverHeaderColor[i];
- color.dispose();
- }
-
- blueButtonBackground.dispose();
- blueToolbarColor.dispose();
- silverButtonBackground.dispose();
- silverToolbarColor.dispose();
- oliveButtonBackground.dispose();
- oliveToolbarColor.dispose();
- lightBlueToolbarcolor.dispose();
- lightOliveToolbarcolor.dispose();
- lightSilverToolbarcolor.dispose();
-
- calendarBlueBorder.dispose();
- calendarBlueHeader.dispose();
- calendarOliveBorder.dispose();
- calendarOliveHeader.dispose();
- calendarSilverBorder.dispose();
- calendarSilverHeader.dispose();
- }
-
- /**
- * Returns the color white R255, G255, B255
- *
- * @return White color
- */
- public static Color getWhite() {
- checkInstance();
- return getColor(WHITE);
- }
-
- /**
- * Returns the color black R0, G0, B0
- *
- * @return Black color
- */
- public static Color getBlack() {
- checkInstance();
- return getColor(BLACK);
- }
-
- /**
- * Returns a color that is also cached if it has not been created before.
- *
- * @param rgb RGB colors
- * @return Color
- */
- public static Color getColor(RGB rgb) {
- checkInstance();
- Color color = mColorTable.get(rgb);
-
- if (color == null) {
- color = new Color(Display.getCurrent(), rgb);
- mColorTable.put(rgb, color);
- }
-
- return color;
- }
-
- /**
- * Returns a color that is also cached if it has not been created before.
- *
- * @param r Red
- * @param g Green
- * @param b Blue
- * @return Color
- */
- public static Color getColor(int r, int g, int b) {
- checkInstance();
- RGB rgb = new RGB(r, g, b);
- return getColor(rgb);
- }
-}
+/*******************************************************************************
+ * Copyright (c) Emil Crumhorn - Hexapixel.com - emil.crumhorn@gmail.com
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * emil.crumhorn@gmail.com - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.nebula.widgets.collapsiblebuttons;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+
+public class ColorCache {
+
+ public static final RGB BLACK = new RGB(0, 0, 0);
+ public static final RGB WHITE = new RGB(255, 255, 255);
+
+ private static HashMap mColorTable;
+ private static ColorCache mInstance;
+
+ public static final int SKIN_NONE = -1;
+ public static final int SKIN_AUTO = 0; // auto detect
+ public static final int SKIN_BLUE = 1;
+ public static final int SKIN_OLIVE = 2;
+ public static final int SKIN_SILVER = 3;
+ public static final int SKIN_OFFICE_2007 = 4;
+
+ public static final int SKIN_FALLBACK = SKIN_BLUE; // if auto fails, what skin to use
+
+ public static int SKIN_CURRENT = SKIN_AUTO;
+
+ /**
+ * Disposes all colors held in the cache and colors created when class is created.
+ *
+ * IMPORTANT: ONLY CALL WHEN YOU WANT TO DISPOSE THE WIDGET USING THIS CLASS!
+ *
+ * If you only wish to dispose colors you have created through the use of the class, please use disposeCachedColors()
+ *
+ * @see #disposeCachedColor()
+ */
+ public static void disposeAll() {
+ mInstance.dispose();
+
+ blueHeaderColor = null;
+ lightBlueButtonColor = null;
+ blueButtonBackground = null;
+ blueToolbarColor = null;
+ lightBlueToolbarcolor = null;
+ oliveHeaderColor = null;
+ lightOliveButtonColor = null;
+ lightOliveButtonColor = null;
+ oliveButtonBackground = null;
+ oliveToolbarColor = null;
+ lightOliveToolbarcolor = null;
+ silverHeaderColor = null;
+ lightSilverButtonColor = null;
+ silverButtonBackground = null;
+ silverToolbarColor = null;
+ lightSilverToolbarcolor = null;
+ lightBrownColor = null;
+ lightBrownColorReverse = null;
+ darkBrownColor = null;
+ calendarBlueHeader = null;
+ calendarBlueBorder = null;
+ calendarOliveHeader = null;
+ calendarOliveBorder = null;
+ calendarSilverBorder = null;
+ calendarSilverHeader = null;
+ }
+
+ /**
+ * Disposes the cached colors only.
+ */
+ public static void disposeCachedColor() {
+ Iterator e = mColorTable.values().iterator();
+ while (e.hasNext()) e.next().dispose();
+
+ mColorTable.clear();
+ }
+
+ // -- blue skin
+ public static Color [] blueHeaderColor = new Color[]{
+ ColorCache.getColor(89, 135, 214),
+ ColorCache.getColor(3, 56, 148),
+ ColorCache.getColor(89, 135, 214)
+ };
+
+ public static Color [] lightBlueButtonColor = new Color[]{
+ ColorCache.getColor(203, 225, 252),
+ ColorCache.getColor(125, 165, 224),
+ ColorCache.getColor(203, 225, 252)
+ };
+
+ public static Color blueButtonBackground = ColorCache.getColor(3, 56, 148);
+
+ public static Color blueToolbarColor = ColorCache.getColor(77, 124, 205);
+ public static Color lightBlueToolbarcolor = ColorCache.getColor(170, 199, 246);
+ // -- end blue skin
+
+ // toolbar
+ public static Color [] oliveHeaderColor = new Color[]{
+ ColorCache.getColor(175, 192, 130), // light
+ ColorCache.getColor(99, 122, 68), // dark
+ ColorCache.getColor(175, 192, 130) // light
+ };
+
+ // buttons
+ public static Color [] lightOliveButtonColor = new Color[]{
+ ColorCache.getColor(232, 238, 204),
+ ColorCache.getColor(177, 192, 140),
+ ColorCache.getColor(232, 238, 204)
+ };
+
+ public static Color oliveButtonBackground = ColorCache.getColor(99, 122, 68);
+
+ public static Color oliveToolbarColor = ColorCache.getColor(230, 230, 200);
+ public static Color lightOliveToolbarcolor = ColorCache.getColor(232, 232, 206);
+ // -- end olive skin
+
+ // -- silver skin
+ public static Color [] silverHeaderColor = new Color[]{
+ ColorCache.getColor(168, 167, 191), // light
+ ColorCache.getColor(124, 124, 148), // dark
+ ColorCache.getColor(168, 167, 191) // light
+ };
+
+ // buttons
+ public static Color [] lightSilverButtonColor = new Color[]{
+ ColorCache.getColor(225, 226, 236),
+ ColorCache.getColor(149, 147, 177),
+ ColorCache.getColor(225, 226, 236)
+ };
+
+ public static Color silverButtonBackground = ColorCache.getColor(124, 124, 148);
+
+ public static Color silverToolbarColor = ColorCache.getColor(164, 163, 187);
+ public static Color lightSilverToolbarcolor = ColorCache.getColor(231, 231, 239);
+ // -- end silver skin
+
+ public static Color [] lightBrownColor = new Color[]{
+ ColorCache.getColor(254, 252, 215),
+ ColorCache.getColor(247, 192, 91),
+ ColorCache.getColor(254, 252, 215)
+ };
+
+ public static Color [] lightBrownColorReverse = new Color[]{
+ ColorCache.getColor(247, 192, 91),
+ ColorCache.getColor(254, 252, 215),
+ ColorCache.getColor(247, 192, 91)
+ };
+
+ public static Color [] darkBrownColor = new Color[]{
+ ColorCache.getColor(232, 127, 8),
+ ColorCache.getColor(247, 218, 124),
+ ColorCache.getColor(232, 127, 8)
+ };
+
+ public static Color calendarBlueHeader = ColorCache.getColor(158, 190, 245);
+ public static Color calendarBlueBorder = ColorCache.getColor(127, 157, 185);
+
+ public static Color calendarOliveHeader = ColorCache.getColor(217, 217, 167);
+ public static Color calendarOliveBorder = ColorCache.getColor(164, 185, 127);
+
+ public static Color calendarSilverHeader = ColorCache.getColor(215, 215, 229);
+ public static Color calendarSilverBorder = ColorCache.getColor(157, 157, 161);
+
+ // office 2007 does chrome gradients, top color goes 12 pixels down
+ public static Color o2007blueTop = ColorCache.getColor(227, 239, 255);
+ public static Color o2007blueMid = ColorCache.getColor(173, 209, 255);
+ public static Color o2007blueBot = ColorCache.getColor(192, 219, 255);
+
+ public static Color o2007orangeSelectedTop = ColorCache.getColor(255, 217, 170);
+ public static Color o2007orangeSelectedMid = ColorCache.getColor(255, 187, 110);
+ public static Color o2007orangeSelectedBot = ColorCache.getColor(254, 225, 122);
+
+ public static Color o2007orangeHoveredTop = ColorCache.getColor(255, 254, 228);
+ public static Color o2007orangeHoveredMid = ColorCache.getColor(255, 232, 167);
+ public static Color o2007orangeHoveredBot = ColorCache.getColor(255, 230, 158);
+
+ public static Color o2007buttonBackgroundColor = ColorCache.getColor(101, 147, 207);
+
+ private ColorCache() {
+ if (mColorTable == null) {
+ mColorTable = new HashMap<>();
+ }
+ }
+
+ private static void checkInstance() {
+ if (mInstance == null)
+ mInstance = new ColorCache();
+ }
+
+ // see disposeAll();
+ private void dispose() {
+ checkInstance();
+
+ Iterator e = mColorTable.values().iterator();
+ while (e.hasNext()) e.next().dispose();
+
+ mColorTable.clear();
+
+ for (int i = 0; i < blueHeaderColor.length; i++) {
+ Color color = blueHeaderColor[i];
+ color.dispose();
+ }
+
+ for (int i = 0; i < darkBrownColor.length; i++) {
+ Color color = darkBrownColor[i];
+ color.dispose();
+ }
+
+ for (int i = 0; i < lightBlueButtonColor.length; i++) {
+ Color color = lightBlueButtonColor[i];
+ color.dispose();
+ }
+
+ for (int i = 0; i < lightBrownColor.length; i++) {
+ Color color = lightBrownColor[i];
+ color.dispose();
+ }
+
+ for (int i = 0; i < lightBrownColorReverse.length; i++) {
+ Color color = lightBrownColorReverse[i];
+ color.dispose();
+ }
+
+ for (int i = 0; i < lightOliveButtonColor.length; i++) {
+ Color color = lightOliveButtonColor[i];
+ color.dispose();
+ }
+
+ for (int i = 0; i < lightSilverButtonColor.length; i++) {
+ Color color = lightSilverButtonColor[i];
+ color.dispose();
+ }
+
+ for (int i = 0; i < oliveHeaderColor.length; i++) {
+ Color color = oliveHeaderColor[i];
+ color.dispose();
+ }
+
+ for (int i = 0; i < silverHeaderColor.length; i++) {
+ Color color = silverHeaderColor[i];
+ color.dispose();
+ }
+
+ blueButtonBackground.dispose();
+ blueToolbarColor.dispose();
+ silverButtonBackground.dispose();
+ silverToolbarColor.dispose();
+ oliveButtonBackground.dispose();
+ oliveToolbarColor.dispose();
+ lightBlueToolbarcolor.dispose();
+ lightOliveToolbarcolor.dispose();
+ lightSilverToolbarcolor.dispose();
+
+ calendarBlueBorder.dispose();
+ calendarBlueHeader.dispose();
+ calendarOliveBorder.dispose();
+ calendarOliveHeader.dispose();
+ calendarSilverBorder.dispose();
+ calendarSilverHeader.dispose();
+ }
+
+ /**
+ * Returns the color white R255, G255, B255
+ *
+ * @return White color
+ */
+ public static Color getWhite() {
+ checkInstance();
+ return getColor(WHITE);
+ }
+
+ /**
+ * Returns the color black R0, G0, B0
+ *
+ * @return Black color
+ */
+ public static Color getBlack() {
+ checkInstance();
+ return getColor(BLACK);
+ }
+
+ /**
+ * Returns a color that is also cached if it has not been created before.
+ *
+ * @param rgb RGB colors
+ * @return Color
+ */
+ public static Color getColor(RGB rgb) {
+ checkInstance();
+ Color color = mColorTable.get(rgb);
+
+ if (color == null) {
+ color = new Color(Display.getCurrent(), rgb);
+ mColorTable.put(rgb, color);
+ }
+
+ return color;
+ }
+
+ /**
+ * Returns a color that is also cached if it has not been created before.
+ *
+ * @param r Red
+ * @param g Green
+ * @param b Blue
+ * @return Color
+ */
+ public static Color getColor(int r, int g, int b) {
+ checkInstance();
+ RGB rgb = new RGB(r, g, b);
+ return getColor(rgb);
+ }
+}
diff --git a/widgets/collapsiblebuttons/org.eclipse.nebula.widgets.collapsiblebuttons/src/org/eclipse/nebula/widgets/collapsiblebuttons/CursorCache.java b/widgets/collapsiblebuttons/org.eclipse.nebula.widgets.collapsiblebuttons/src/org/eclipse/nebula/widgets/collapsiblebuttons/CursorCache.java
index 35639aa3a..68e737e0f 100644
--- a/widgets/collapsiblebuttons/org.eclipse.nebula.widgets.collapsiblebuttons/src/org/eclipse/nebula/widgets/collapsiblebuttons/CursorCache.java
+++ b/widgets/collapsiblebuttons/org.eclipse.nebula.widgets.collapsiblebuttons/src/org/eclipse/nebula/widgets/collapsiblebuttons/CursorCache.java
@@ -1,59 +1,59 @@
-/*******************************************************************************
- * Copyright (c) Emil Crumhorn - Hexapixel.com - emil.crumhorn@gmail.com
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * emil.crumhorn@gmail.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.nebula.widgets.collapsiblebuttons;
-
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.widgets.Display;
-
-public class CursorCache {
-
- private static HashMap map = new HashMap<>();
-
- /**
- * Returns a cursor that is also cached as to not create more handles for each time the cursor type is fetched.
- *
- * @param type Cursor Type to fetch
- * @return Cursor
- */
- public static Cursor getCursor(int type) {
- if (map.get(new Integer(type)) != null) {
- return map.get(new Integer(type));
- } else {
- Cursor c = new Cursor(Display.getDefault(), type);
- map.put(new Integer(type), c);
- return c;
- }
- }
-
- /**
- * Disposes all cursors held in the cache.
- *
- * IMPORTANT: ONLY CALL WHEN YOU WANT TO DISPOSE ALL CACHED CURSORS!
- *
- */
- public static void dispose() {
- if (map != null && map.keySet() != null) {
- Iterator keys = map.keySet().iterator();
- while (keys.hasNext()) {
- Object key = keys.next();
- map.get(key).dispose();
- }
- }
- map = null;
- }
-}
+/*******************************************************************************
+ * Copyright (c) Emil Crumhorn - Hexapixel.com - emil.crumhorn@gmail.com
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * emil.crumhorn@gmail.com - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.nebula.widgets.collapsiblebuttons;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.widgets.Display;
+
+public class CursorCache {
+
+ private static HashMap map = new HashMap<>();
+
+ /**
+ * Returns a cursor that is also cached as to not create more handles for each time the cursor type is fetched.
+ *
+ * @param type Cursor Type to fetch
+ * @return Cursor
+ */
+ public static Cursor getCursor(int type) {
+ if (map.get(new Integer(type)) != null) {
+ return map.get(new Integer(type));
+ } else {
+ Cursor c = new Cursor(Display.getDefault(), type);
+ map.put(new Integer(type), c);
+ return c;
+ }
+ }
+
+ /**
+ * Disposes all cursors held in the cache.
+ *
+ * IMPORTANT: ONLY CALL WHEN YOU WANT TO DISPOSE ALL CACHED CURSORS!
+ *
+ */
+ public static void dispose() {
+ if (map != null && map.keySet() != null) {
+ Iterator keys = map.keySet().iterator();
+ while (keys.hasNext()) {
+ Object key = keys.next();
+ map.get(key).dispose();
+ }
+ }
+ map = null;
+ }
+}
diff --git a/widgets/collapsiblebuttons/org.eclipse.nebula.widgets.collapsiblebuttons/src/org/eclipse/nebula/widgets/collapsiblebuttons/CustomButton.java b/widgets/collapsiblebuttons/org.eclipse.nebula.widgets.collapsiblebuttons/src/org/eclipse/nebula/widgets/collapsiblebuttons/CustomButton.java
index ad4fff25a..096d5440d 100644
--- a/widgets/collapsiblebuttons/org.eclipse.nebula.widgets.collapsiblebuttons/src/org/eclipse/nebula/widgets/collapsiblebuttons/CustomButton.java
+++ b/widgets/collapsiblebuttons/org.eclipse.nebula.widgets.collapsiblebuttons/src/org/eclipse/nebula/widgets/collapsiblebuttons/CustomButton.java
@@ -1,228 +1,228 @@
-/*******************************************************************************
- * Copyright (c) Emil Crumhorn - Hexapixel.com - emil.crumhorn@gmail.com
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * emil.crumhorn@gmail.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.nebula.widgets.collapsiblebuttons;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-
-public class CustomButton extends Composite {
-
- public static final int BUTTON_HEIGHT = 31;
-
- private Image mImage;
- private String mText;
- private Rectangle mBounds;
- private Image mToolBarImage;
- private String mToolTip;
-
- private boolean mHover;
- private boolean mSelected;
- private ISettings mSettings;
- private CollapsibleButtons mParent;
- private IColorManager mColorManager;
-
- private int mOrderNumber;
-
- /**
- * Creates a new CustomButton.
- *
- * @param parent ButtonComposite parent
- * @param style Widget style
- * @param text Label text
- * @param image Image to show, null if none
- * @param toolBarImage Tooolbar image, null if none
- * @param toolTip Tooltip text
- * @param settings Button painter class that decides look and feel of button
- */
- public CustomButton(CollapsibleButtons parent, int style, String text, Image image, Image toolBarImage, String toolTip, ISettings settings) {
- super(parent, style);
- mImage = image;
- mText = text;
- mToolTip = toolTip;
- mToolBarImage = toolBarImage;
- mSettings = settings;
- mParent = parent;
- mColorManager = mParent.getColorManager();
-
- setToolTipText(toolTip);
-
- init();
- }
-
- private void init() {
- addListener(SWT.Paint, event-> repaint(event.gc));
- addListener(SWT.Resize, event ->redraw());
- }
-
- /**
- * Updates the hover state.
- *
- * @param hover true for hover, false for off
- */
- public void updateHover(boolean hover) {
- if (isDisposed())
- return;
-
- if (hover && mHover)
- return;
-
- if (!hover && !mHover)
- return;
-
- mHover = hover;
- redraw();
- }
-
- /**
- * Updates the selection state.
- *
- * @param selected true for selected, false for not
- */
- public void updateSelection(boolean selected) {
- if (isDisposed())
- return;
-
- if (selected && mSelected)
- return;
-
- if (!selected && !mSelected)
- return;
-
- mSelected = selected;
- redraw();
- }
-
- /**
- * Returns the button label text
- *
- * @return Button text
- */
- public String getText() {
- return mText;
- }
-
- /**
- * Returns the tooltip text
- *
- * @return Tooltip text
- */
- public String getToolTip() {
- return mToolTip;
- }
-
- /**
- * Returns the toolbar image
- *
- * @return Toolbar image
- */
- public Image getToolBarImage() {
- return mToolBarImage;
- }
-
- /**
- * Sets the visible text
- *
- * @param text
- */
- public void setText(String text) {
- mText = text;
- }
-
- /**
- * Sets the toolbar image.
- *
- * @param toolBarImage
- */
- public void setToolBarImage(Image toolBarImage) {
- mToolBarImage = toolBarImage;
- }
-
- /**
- * Sets the tooltip text.
- *
- * @param toolTip
- */
- public void setToolTip(String toolTip) {
- mToolTip = toolTip;
- }
-
- /**
- * Returns the big image.
- *
- * @return Image
- */
- public Image getImage() {
- return mImage;
- }
-
- /**
- * Sets the big image.
- *
- * @param image to set
- */
- public void setImage(Image image) {
- mImage = image;
- }
-
- private void repaint(GC gc) {
- mBounds = new Rectangle(0, 0, super.getBounds().width, BUTTON_HEIGHT);
-
- IButtonPainter bp = mSettings.getButtonPainter();
-
- bp.paintBackground(gc, mColorManager, mSettings, mBounds, mHover, mSelected);
- bp.paintImage(gc, mColorManager, mSettings, mBounds, mHover, mSelected, mImage);
- bp.paintText(gc, mColorManager, mSettings, mBounds, (mImage == null ? null : mImage.getBounds()), mHover, mSelected, mText);
- }
-
- /**
- * Internal function.
- * This is used to keep a list of numbered buttons in memory via an ever-increasing integer value for setting the
- * order of buttons back to their original position when buttons are permanently hidden/shown.
- *
- * Should you wish to use this, for some reason, then make sure that there is no gap in numbers in the buttons and that they
- * start at 0.
- *
- * @param number
- */
- public void setNumber(int number) {
- mOrderNumber = number;
- }
-
- /**
- * Internal function.
- * Returns the current number for this button. The number reflects what position in the list the button has - visually.
- *
- * @return Number
- */
- public int getNumber() {
- return mOrderNumber;
- }
-
- public String toString() {
- return "[CustomButton '"+mText+"']";
- }
-
- /**
- * Disposes this button and removes it from the control.
- */
- public void dispose() {
- mParent.remove(this, false);
- super.dispose();
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) Emil Crumhorn - Hexapixel.com - emil.crumhorn@gmail.com
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * emil.crumhorn@gmail.com - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.nebula.widgets.collapsiblebuttons;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+
+public class CustomButton extends Composite {
+
+ public static final int BUTTON_HEIGHT = 31;
+
+ private Image mImage;
+ private String mText;
+ private Rectangle mBounds;
+ private Image mToolBarImage;
+ private String mToolTip;
+
+ private boolean mHover;
+ private boolean mSelected;
+ private ISettings mSettings;
+ private CollapsibleButtons mParent;
+ private IColorManager mColorManager;
+
+ private int mOrderNumber;
+
+ /**
+ * Creates a new CustomButton.
+ *
+ * @param parent ButtonComposite parent
+ * @param style Widget style
+ * @param text Label text
+ * @param image Image to show, null if none
+ * @param toolBarImage Tooolbar image, null if none
+ * @param toolTip Tooltip text
+ * @param settings Button painter class that decides look and feel of button
+ */
+ public CustomButton(CollapsibleButtons parent, int style, String text, Image image, Image toolBarImage, String toolTip, ISettings settings) {
+ super(parent, style);
+ mImage = image;
+ mText = text;
+ mToolTip = toolTip;
+ mToolBarImage = toolBarImage;
+ mSettings = settings;
+ mParent = parent;
+ mColorManager = mParent.getColorManager();
+
+ setToolTipText(toolTip);
+
+ init();
+ }
+
+ private void init() {
+ addListener(SWT.Paint, event-> repaint(event.gc));
+ addListener(SWT.Resize, event ->redraw());
+ }
+
+ /**
+ * Updates the hover state.
+ *
+ * @param hover true for hover, false for off
+ */
+ public void updateHover(boolean hover) {
+ if (isDisposed())
+ return;
+
+ if (hover && mHover)
+ return;
+
+ if (!hover && !mHover)
+ return;
+
+ mHover = hover;
+ redraw();
+ }
+
+ /**
+ * Updates the selection state.
+ *
+ * @param selected true for selected, false for not
+ */
+ public void updateSelection(boolean selected) {
+ if (isDisposed())
+ return;
+
+ if (selected && mSelected)
+ return;
+
+ if (!selected && !mSelected)
+ return;
+
+ mSelected = selected;
+ redraw();
+ }
+
+ /**
+ * Returns the button label text
+ *
+ * @return Button text
+ */
+ public String getText() {
+ return mText;
+ }
+
+ /**
+ * Returns the tooltip text
+ *
+ * @return Tooltip text
+ */
+ public String getToolTip() {
+ return mToolTip;
+ }
+
+ /**
+ * Returns the toolbar image
+ *
+ * @return Toolbar image
+ */
+ public Image getToolBarImage() {
+ return mToolBarImage;
+ }
+
+ /**
+ * Sets the visible text
+ *
+ * @param text
+ */
+ public void setText(String text) {
+ mText = text;
+ }
+
+ /**
+ * Sets the toolbar image.
+ *
+ * @param toolBarImage
+ */
+ public void setToolBarImage(Image toolBarImage) {
+ mToolBarImage = toolBarImage;
+ }
+
+ /**
+ * Sets the tooltip text.
+ *
+ * @param toolTip
+ */
+ public void setToolTip(String toolTip) {
+ mToolTip = toolTip;
+ }
+
+ /**
+ * Returns the big image.
+ *
+ * @return Image
+ */
+ public Image getImage() {
+ return mImage;
+ }
+
+ /**
+ * Sets the big image.
+ *
+ * @param image to set
+ */
+ public void setImage(Image image) {
+ mImage = image;
+ }
+
+ private void repaint(GC gc) {
+ mBounds = new Rectangle(0, 0, super.getBounds().width, BUTTON_HEIGHT);
+
+ IButtonPainter bp = mSettings.getButtonPainter();
+
+ bp.paintBackground(gc, mColorManager, mSettings, mBounds, mHover, mSelected);
+ bp.paintImage(gc, mColorManager, mSettings, mBounds, mHover, mSelected, mImage);
+ bp.paintText(gc, mColorManager, mSettings, mBounds, (mImage == null ? null : mImage.getBounds()), mHover, mSelected, mText);
+ }
+
+ /**
+ * Internal function.
+ * This is used to keep a list of numbered buttons in memory via an ever-increasing integer value for setting the
+ * order of buttons back to their original position when buttons are permanently hidden/shown.
+ *
+ * Should you wish to use this, for some reason, then make sure that there is no gap in numbers in the buttons and that they
+ * start at 0.
+ *
+ * @param number
+ */
+ public void setNumber(int number) {
+ mOrderNumber = number;
+ }
+
+ /**
+ * Internal function.
+ * Returns the current number for this button. The number reflects what position in the list the button has - visually.
+ *
+ * @return Number
+ */
+ public int getNumber() {
+ return mOrderNumber;
+ }
+
+ public String toString() {
+ return "[CustomButton '"+mText+"']";
+ }
+
+ /**
+ * Disposes this button and removes it from the control.
+ */
+ public void dispose() {
+ mParent.remove(this, false);
+ super.dispose();
+ }
+
+}
diff --git a/widgets/collapsiblebuttons/org.eclipse.nebula.widgets.collapsiblebuttons/src/org/eclipse/nebula/widgets/collapsiblebuttons/ImageCache.java b/widgets/collapsiblebuttons/org.eclipse.nebula.widgets.collapsiblebuttons/src/org/eclipse/nebula/widgets/collapsiblebuttons/ImageCache.java
index fe5ae0722..b564b6275 100644
--- a/widgets/collapsiblebuttons/org.eclipse.nebula.widgets.collapsiblebuttons/src/org/eclipse/nebula/widgets/collapsiblebuttons/ImageCache.java
+++ b/widgets/collapsiblebuttons/org.eclipse.nebula.widgets.collapsiblebuttons/src/org/eclipse/nebula/widgets/collapsiblebuttons/ImageCache.java
@@ -1,88 +1,88 @@
-/*******************************************************************************
- * Copyright (c) Emil Crumhorn - Hexapixel.com - emil.crumhorn@gmail.com
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * emil.crumhorn@gmail.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.nebula.widgets.collapsiblebuttons;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-public class ImageCache {
-
- private static HashMap mImageMap;
-
- static {
- mImageMap = new HashMap<>();
- }
-
- /**
- * Returns an image that is also cached if it has to be created and does not already exist in the cache.
- *
- * @param fileName Filename of image to fetch
- * @return Image file or null if it could not be found
- */
- public static Image getImage(String fileName) {
- Image image = mImageMap.get(fileName);
- if (image == null) {
- image = createImage(fileName);
- mImageMap.put(fileName, image);
- }
- return image;
- }
-
- // creates the image, and tries really hard to do so
- private static Image createImage(String fileName) {
- ClassLoader classLoader = ImageCache.class.getClassLoader();
- InputStream is = classLoader.getResourceAsStream(fileName);
- if (is == null) {
- // the old way didn't have leading slash, so if we can't find the image stream,
- // let's see if the old way works.
- is = classLoader.getResourceAsStream(fileName.substring(1));
-
- if (is == null) {
- is = classLoader.getResourceAsStream(fileName);
- if (is == null) {
- is = classLoader.getResourceAsStream(fileName.substring(1));
- if (is == null) {
- //logger.debug("null input stream for both " + path + " and " + path);
- return null;
- }
- }
- }
- }
-
- Image img = new Image(Display.getDefault(), is);
- try {
- is.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- return img;
- }
-
- /**
- * Disposes ALL images that have been cached.
- *
- */
- public static void dispose() {
- Iterator e = mImageMap.values().iterator();
- while (e.hasNext())
- e.next().dispose();
- }
-}
+/*******************************************************************************
+ * Copyright (c) Emil Crumhorn - Hexapixel.com - emil.crumhorn@gmail.com
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * emil.crumhorn@gmail.com - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.nebula.widgets.collapsiblebuttons;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+public class ImageCache {
+
+ private static HashMap mImageMap;
+
+ static {
+ mImageMap = new HashMap<>();
+ }
+
+ /**
+ * Returns an image that is also cached if it has to be created and does not already exist in the cache.
+ *
+ * @param fileName Filename of image to fetch
+ * @return Image file or null if it could not be found
+ */
+ public static Image getImage(String fileName) {
+ Image image = mImageMap.get(fileName);
+ if (image == null) {
+ image = createImage(fileName);
+ mImageMap.put(fileName, image);
+ }
+ return image;
+ }
+
+ // creates the image, and tries really hard to do so
+ private static Image createImage(String fileName) {
+ ClassLoader classLoader = ImageCache.class.getClassLoader();
+ InputStream is = classLoader.getResourceAsStream(fileName);
+ if (is == null) {
+ // the old way didn't have leading slash, so if we can't find the image stream,
+ // let's see if the old way works.
+ is = classLoader.getResourceAsStream(fileName.substring(1));
+
+ if (is == null) {
+ is = classLoader.getResourceAsStream(fileName);
+ if (is == null) {
+ is = classLoader.getResourceAsStream(fileName.substring(1));
+ if (is == null) {
+ //logger.debug("null input stream for both " + path + " and " + path);
+ return null;
+ }
+ }
+ }
+ }
+
+ Image img = new Image(Display.getDefault(), is);
+ try {
+ is.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return img;
+ }
+
+ /**
+ * Disposes ALL images that have been cached.
+ *
+ */
+ public static void dispose() {
+ Iterator e = mImageMap.values().iterator();
+ while (e.hasNext())
+ e.next().dispose();
+ }
+}
diff --git a/widgets/collapsiblebuttons/org.eclipse.nebula.widgets.collapsiblebuttons/src/org/eclipse/nebula/widgets/collapsiblebuttons/ToolbarComposite.java b/widgets/collapsiblebuttons/org.eclipse.nebula.widgets.collapsiblebuttons/src/org/eclipse/nebula/widgets/collapsiblebuttons/ToolbarComposite.java
index 2aba2c93f..b36d04f32 100644
--- a/widgets/collapsiblebuttons/org.eclipse.nebula.widgets.collapsiblebuttons/src/org/eclipse/nebula/widgets/collapsiblebuttons/ToolbarComposite.java
+++ b/widgets/collapsiblebuttons/org.eclipse.nebula.widgets.collapsiblebuttons/src/org/eclipse/nebula/widgets/collapsiblebuttons/ToolbarComposite.java
@@ -1,493 +1,493 @@
-/*******************************************************************************
- * Copyright (c) Emil Crumhorn - Hexapixel.com - emil.crumhorn@gmail.com
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * emil.crumhorn@gmail.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.nebula.widgets.collapsiblebuttons;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.MouseTrackListener;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-
-public class ToolbarComposite extends Composite implements MouseListener, MouseMoveListener, MouseTrackListener {
-
- private List mToolBarItems;
- private TBItem mLastHover;
- private CustomButton mSelectedItem;
- private CollapsibleButtons mButtonComposite;
-
- private boolean mEnableDoubleBuffering = true;
- private boolean mCreated = false;
-
- private static Image mOutlook2005ArrowsImage = ImageCache.getImage("icons/arrows.gif");
- private static Image mOutlook2007ArrowImage = ImageCache.getImage("icons/o2007arrow.gif");
- private Rectangle mArrowsBounds;
- private boolean mArrowHover = false;
-
- private IColorManager mColorManager;
- private AbstractButtonPainter mButtonPainter;
-
- private Image mArrowImage;
- private ISettings mSettings;
- private ILanguageSettings mLanguage;
-
- /**
- * Creates a new toolbar composite.
- *
- * @param bc ButtonComposite parent
- * @param style Composite style
- */
- public ToolbarComposite(CollapsibleButtons bc, int style) {
- super(bc, style | SWT.NO_BACKGROUND);
-
- this.mLanguage = bc.getLanguageSettings();
- this.mButtonPainter = new AbstractButtonPainter();
- this.mButtonComposite = bc;
- this.mColorManager = bc.getColorManager();
- this.mSettings = bc.getSettings();
-
- if (mColorManager.getTheme() == IColorManager.SKIN_OFFICE_2007)
- mArrowImage = mOutlook2007ArrowImage;
- else
- mArrowImage = mOutlook2005ArrowsImage;
-
- mToolBarItems = new ArrayList<>();
-
- addListener(SWT.Paint, event -> repaint(event));
- addMouseListener(this);
- addMouseTrackListener(this);
- addMouseMoveListener(this);
- }
-
- private void repaint(Event event) {
- GC gc = event.gc;
- if (mCreated && mEnableDoubleBuffering) {
- try {
- Image buffer = new Image(Display.getDefault(), super.getBounds());
- GC gc2 = new GC(buffer);
- drawOntoGC(gc2);
-
- // transfer the image buffer onto this canvas
- // just drawImage(buffer, w, h) didn't work, so we do the whole
- // source transfer call
- Rectangle b = getBounds();
- gc.drawImage(buffer, 0, 0, b.width, b.height, 0, 0, b.width, b.height);
-
- // dispose the buffer, very important or we'll run out of
- // address space for buffered images
- buffer.dispose();
- gc2.dispose();
- } catch (IllegalArgumentException iea) {
- // seems to come here for some reason when we switch phases
- // while the gantt chart is being viewed, I'm not sure why
- // but no time to figure it out for the demo.. so instead of
- // buffering, just draw it onto the GC
- drawOntoGC(gc);
- }
- } else {
- drawOntoGC(gc);
- mCreated = true;
- }
-
- gc.dispose();
- }
-
- private void drawOntoGC(GC gc) {
- Rectangle rect = getClientArea();
- Rectangle imageBounds = (mArrowImage != null ? mArrowImage.getBounds() : new Rectangle(0, 0, 0, 0));
- int verticalLoc = (getBounds().height / 2) - (mArrowImage == null ? 0 : mArrowImage.getBounds().height / 2);
- // move it down just a smidge, the human eye percieves things
- // mis-aligned when exactly centered
- verticalLoc += 1;
- mButtonPainter.paintBackground(gc, mColorManager, mSettings, rect, false, false);
-
- int right = rect.width;
-
- if (mArrowImage != null)
- gc.drawImage(mArrowImage, rect.width - imageBounds.width, verticalLoc);
- mArrowsBounds = new Rectangle(rect.width - imageBounds.width, verticalLoc, imageBounds.width, imageBounds.height);
- right -= imageBounds.width + mSettings.getToolBarSpacing();
-
- // reorganize items if stuff have been hidden/shown (permanently)
- orderItems();
-
- for (int i = 0; i < mToolBarItems.size(); i++) {
- TBItem tb = mToolBarItems.get(i);
- if (tb.getHidden())
- continue;
-
- if (tb.getButton() == mSelectedItem) {
- Rectangle cur = tb.getBounds();
- // TODO: Clean up code-repeat
- if (cur == null) {
- if (tb.getButton().getToolBarImage() != null) {
- Rectangle imBounds = tb.getButton().getToolBarImage().getBounds();
- cur = new Rectangle(right - imBounds.width, verticalLoc, imBounds.width, imBounds.width);
- tb.setBounds(cur);
- } else {
- // basically a non-existent button, but no image = no
- // button, so that's fine
- tb.setBounds(new Rectangle(right, verticalLoc, 0, 0));
- continue;
- }
- }
-
- Rectangle bounds = new Rectangle(cur.x - mSettings.getToolBarLeftSpacer(), cur.y, cur.width + mSettings.getToolBarRightSpacer(), cur.height);
- mButtonPainter.paintBackground(gc, mColorManager, mSettings, bounds, false, true);
- }
-
- Rectangle imBounds = null;
- if (tb.getButton().getToolBarImage() != null) {
- imBounds = tb.getButton().getToolBarImage().getBounds();
- gc.drawImage(tb.getButton().getToolBarImage(), right - imBounds.width, verticalLoc);
- tb.setBounds(new Rectangle(right - imBounds.width, verticalLoc, imBounds.width, imBounds.width));
- }
-
- right -= (imBounds == null ? 0 : imBounds.width) + mSettings.getToolBarSpacing();
- }
- }
-
- private void orderItems() {
- if (mToolBarItems.size() == 0)
- return;
-
- Collections.sort(mToolBarItems);
- }
-
- public Point getSize() {
- checkWidget();
- return new Point(super.getSize().x, CustomButton.BUTTON_HEIGHT);
- }
-
- public void addItem(CustomButton button) {
- checkWidget();
- mToolBarItems.add(new TBItem(button));
- }
-
- public void removeAll() {
- checkWidget();
- mToolBarItems.clear();
- }
-
- public void removeItem(CustomButton button) {
- checkWidget();
- for (int i = 0; i < mToolBarItems.size(); i++) {
- TBItem item = mToolBarItems.get(i);
- if (item.getButton() == button) {
- mToolBarItems.remove(item);
- break;
- }
- }
- }
-
- public void hideButton(CustomButton button) {
- checkWidget();
- for (int i = 0; i < mToolBarItems.size(); i++) {
- TBItem item = mToolBarItems.get(i);
- if (item.getButton() == button) {
- item.setHidden(true);
- break;
- }
- }
- }
-
- public void setSelectedItem(CustomButton button) {
- checkWidget();
- clearHover();
- clearArrowsHover();
- clearSelection();
- mSelectedItem = button;
-
- for (int i = 0; i < mToolBarItems.size(); i++) {
- TBItem item = mToolBarItems.get(i);
-
- if (item.getButton() == mSelectedItem) {
- Rectangle lb = item.getBounds();
- GC gc = new GC(this);
- Rectangle rect = new Rectangle(lb.x - mSettings.getToolBarLeftSpacer(), 0, lb.width + mSettings.getToolBarRightSpacer(), CustomButton.BUTTON_HEIGHT);
- mButtonPainter.paintBackground(gc, mColorManager, mSettings, rect, false, true);
- gc.drawImage(item.getButton().getToolBarImage(), lb.x, lb.y);
- gc.dispose();
- }
- }
-
- }
-
- public void mouseDoubleClick(MouseEvent event) {
- checkWidget();
- }
-
- public void mouseDown(MouseEvent event) {
- checkWidget();
- Rectangle bigArrowsBounds = new Rectangle(mArrowsBounds.x, 0, mArrowsBounds.width, CustomButton.BUTTON_HEIGHT);
- if (isInside(event.x, event.y, bigArrowsBounds)) {
- GC gc = new GC(this);
- Rectangle rect = new Rectangle(mArrowsBounds.x - mSettings.getToolBarLeftSpacer(), 0, mArrowsBounds.width + mSettings.getToolBarRightSpacer(),
- CustomButton.BUTTON_HEIGHT);
- mButtonPainter.paintBackground(gc, mColorManager, mSettings, rect, false, true);
-
- gc.drawImage(mArrowImage, mArrowsBounds.x, mArrowsBounds.y);
-
- gc.dispose();
-
- Menu mainMenu = new Menu(Display.getDefault().getActiveShell(), SWT.POP_UP);
-
- List menuListeners = mButtonComposite.getMenuListeners();
- for (int i = 0; i < menuListeners.size(); i++) {
- menuListeners.get(i).preMenuItemsCreated(mainMenu);
- }
-
- MenuItem menuShowMoreButtons = new MenuItem(mainMenu, SWT.PUSH);
- MenuItem menuShowFewerButtons = new MenuItem(mainMenu, SWT.PUSH);
- menuShowFewerButtons.addListener(SWT.Selection, e -> mButtonComposite.hideNextButton());
- menuShowMoreButtons.addListener(SWT.Selection, e-> mButtonComposite.showNextButton());
-
- menuShowMoreButtons.setText(mLanguage.getShowMoreButtonsText());
- menuShowFewerButtons.setText(mLanguage.getShowFewerButtonsText());
-
- new MenuItem(mainMenu, SWT.SEPARATOR);
- MenuItem more = new MenuItem(mainMenu, SWT.CASCADE);
- more.setText(mLanguage.getAddOrRemoveButtonsText());
- Menu moreMenu = new Menu(more);
- more.setMenu(moreMenu);
-
- List cbs = mButtonComposite.getItems();
- for (int i = 0; i < cbs.size(); i++) {
- final CustomButton cb = cbs.get(i);
- final MenuItem temp = new MenuItem(moreMenu, SWT.CHECK);
- temp.setText(cb.getText());
- temp.setImage(cb.getToolBarImage());
- temp.setSelection(mButtonComposite.isVisible(cb));
- temp.addListener(SWT.Selection, e -> {
- if (mButtonComposite.isVisible(cb)) {
- mButtonComposite.permanentlyHideButton(cb);
- temp.setSelection(false);
- } else {
- mButtonComposite.permanentlyShowButton(cb);
- temp.setSelection(true);
- }
- });
- }
-
- for (int i = 0; i < menuListeners.size(); i++) {
- menuListeners.get(i).postMenuItemsCreated(mainMenu);
- }
-
- mainMenu.setVisible(true);
- return;
- }
-
- for (int i = 0; i < mToolBarItems.size(); i++) {
- TBItem item = mToolBarItems.get(i);
- if (item.getBounds() != null) {
- if (isInside(event.x, event.y, item.getBounds())) {
- mButtonComposite.selectItemAndLoad(item.getButton());
- break;
- }
- }
- }
- }
-
- public void mouseUp(MouseEvent event) {
- checkWidget();
- }
-
- public void mouseMove(MouseEvent event) {
- checkWidget();
- TBItem found = null;
-
- Rectangle bigArrowsBounds = new Rectangle(mArrowsBounds.x, 0, mArrowsBounds.width, CustomButton.BUTTON_HEIGHT);
- if (isInside(event.x, event.y, bigArrowsBounds)) {
- setToolTipText(null);
- GC gc = new GC(this);
- Rectangle rect = new Rectangle(mArrowsBounds.x - mSettings.getToolBarLeftSpacer(), 0, mArrowsBounds.width + mSettings.getToolBarRightSpacer(),
- CustomButton.BUTTON_HEIGHT);
- mButtonPainter.paintBackground(gc, mColorManager, mSettings, rect, true, false);
-
- gc.drawImage(mArrowImage, mArrowsBounds.x, mArrowsBounds.y);
- gc.dispose();
- mArrowHover = true;
- return;
- }
-
- clearArrowsHover();
-
- for (int i = 0; i < mToolBarItems.size(); i++) {
- TBItem item = mToolBarItems.get(i);
- if (item.getBounds() != null) {
- if (isInside(event.x, event.y, item.getBounds())) {
- found = item;
- break;
- }
- }
- }
-
- if (found == null) {
- clearHover();
- return;
- }
-
- setToolTipText(found.getButton().getToolTip());
-
- if (found.isHovered()) {
- return;
- }
-
- if (found.getButton() == mSelectedItem) {
- return;
- }
-
- clearHover();
-
- GC gc = new GC(this);
- Rectangle tbBounds = found.getBounds();
- Rectangle toUse = new Rectangle(tbBounds.x - mSettings.getToolBarLeftSpacer(), 0, tbBounds.width + mSettings.getToolBarRightSpacer(), CustomButton.BUTTON_HEIGHT);
- mButtonPainter.paintBackground(gc, mColorManager, mSettings, toUse, true, false);
- gc.drawImage(found.getButton().getToolBarImage(), tbBounds.x, tbBounds.y);
- gc.dispose();
- found.setHovered(true);
- mLastHover = found;
- }
-
- public void mouseEnter(MouseEvent event) {
-
- }
-
- public void mouseExit(MouseEvent event) {
- checkWidget();
- clearHover();
- clearArrowsHover();
- }
-
- public void mouseHover(MouseEvent event) {
-
- }
-
- private void clearSelection() {
- for (int i = 0; i < mToolBarItems.size(); i++) {
- TBItem item = mToolBarItems.get(i);
- if (item.getButton() == mSelectedItem) {
- GC gc = new GC(this);
- Rectangle lb = item.getBounds();
- redraw(lb.x - mSettings.getToolBarLeftSpacer(), 0, lb.width + mSettings.getToolBarRightSpacer(), CustomButton.BUTTON_HEIGHT, false);
- if (item.getButton().getToolBarImage() != null)
- gc.drawImage(item.getButton().getToolBarImage(), lb.x, lb.y);
- gc.dispose();
- }
- }
- }
-
- private void clearHover() {
- if (mLastHover != null) {
- GC gc = new GC(this);
- Rectangle lb = mLastHover.getBounds();
- redraw(lb.x - mSettings.getToolBarLeftSpacer(), 0, lb.width + mSettings.getToolBarRightSpacer(), CustomButton.BUTTON_HEIGHT, false);
- gc.drawImage(mLastHover.getButton().getToolBarImage(), lb.x, lb.y);
- gc.dispose();
- mLastHover.setHovered(false);
- mLastHover = null;
- setToolTipText(null);
- }
- }
-
- private void clearArrowsHover() {
- if (mArrowHover) {
- GC gc = new GC(this);
- redraw(mArrowsBounds.x - mSettings.getToolBarLeftSpacer(), 0, mArrowsBounds.width + mSettings.getToolBarRightSpacer(), CustomButton.BUTTON_HEIGHT, false);
- gc.drawImage(mArrowImage, mArrowsBounds.x, mArrowsBounds.y);
- gc.dispose();
- mArrowHover = false;
- }
- }
-
- private boolean isInside(int x, int y, Rectangle rect) {
- if (rect == null) {
- return false;
- }
-
- if (x >= rect.x && y >= rect.y && x <= (rect.x + rect.width) && y <= (rect.y + rect.height)) {
- return true;
- }
-
- return false;
- }
-
- class TBItem implements Comparable