Bug 466731 - Bad readability of textfield at application model-->part-->
supplementary
Change-Id: Ia4dea236b00fde506c88106e77728333d28cd22b
Signed-off-by: Olivier Prouvost <olivier.prouvost@opcoach.com>
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.java
index 360ab30..65e1f1b 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.java
@@ -10,6 +10,7 @@
* Marco Descher <marco@descher.at> - Bug 395982, 396975, 426653
* Steven Spungin <steven@spungin.tv> - Bug 431735, 430717
* Jonas Helming <jhelming@eclipsesource.com - Bug 444340
+ * Olivier Prouvost <olivier.prouvost@opcoach.com> - Bug 466731
******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal;
@@ -19,6 +20,8 @@
public String XmiTab_TypeTextToSearch;
public String ModelEditor_Import3x;
public String E4StringPickList_Replace;
+ public String E4StringPickList_NewValue;
+ public String E4StringPickList_ToolTipNewValue;
public String MarkDuplicateAttributesHandler_MarkDuplicates;
public String MarkDuplicateAttributesHandler_SelectAnAttributeToMarkeDuplicate;
public String VCommandEditor_ImportCommands;
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.properties b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.properties
index 0fba44f..1fa6c0d 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.properties
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.properties
@@ -11,12 +11,15 @@
# * Marco Descher <marco@descher.at> - Bug 395982, 396975, 426653
# * Steven Spungin <steven@spungin.tv> - Bug 431735, 430717, Ongoing Maintenance
# * Lars Vogel <Lars.Vogel@gmail.com> - Bug 440159
+# * Olivier Prouvost <olivier.prouvost@opcoach.com> - Bug 466731
# ******************************************************************************
PartEditor_InputPart=Input Part
XmiTab_TypeTextToSearch0=type text to search (press <ENTER> to search for next instance)
ModelEditor_Import3x=Import 3x
E4StringPickList_Replace=Replace
+E4StringPickList_NewValue=New Value :
+E4StringPickList_ToolTipNewValue=Enter your value and press Enter or click the Add button to add it. \nYou can add several values using a semi-colon separated string like this :\n value1;value2;value3
MarkDuplicateAttributesHandler_MarkDuplicates=Mark Duplicates
MarkDuplicateAttributesHandler_SelectAnAttributeToMarkeDuplicate=Select an attribute to mark duplicate values
VCommandEditor_ImportCommands=Import Commands
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/AbstractPickList.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/AbstractPickList.java
index e10de6e..b44f1b3 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/AbstractPickList.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/AbstractPickList.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Steven Spungin <steven@spungin.tv> - initial API and implementation
+ * Olivier Prouvost <olivier.prouvost@opcoach.com> - Bug 466731
*******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common;
@@ -30,6 +31,7 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -58,14 +60,14 @@
private final Group group;
private final Composite toolBar;
- private final Button tiRemove;
- private final Button tiUp;
- private final Button tiDown;
- private final Button tiAdd;
+ protected final Button tiRemove;
+ protected final Button tiUp;
+ protected final Button tiDown;
+ protected final Button tiAdd;
// private final AutoCompleteField autoCompleteField;
public AbstractPickList(Composite parent, int style, List<PickListFeatures> listFeatures, Messages messages,
- AbstractComponentEditor componentEditor) {
+ AbstractComponentEditor componentEditor) {
super(parent, style);
// TODO remove dependency to Messages and AbstractComponentEditor. They
@@ -110,6 +112,7 @@
layout.marginWidth = 0;
toolBar.setLayout(layout);
toolBar.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+ toolBar.setFont(group.getFont());
picker.addOpenListener(new IOpenListener() {
@@ -123,6 +126,7 @@
tiAdd.setText(messages.ModelTooling_Common_AddEllipsis);
tiAdd.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
tiAdd.setImage(componentEditor.createImage(ResourceProvider.IMG_Obj16_table_add));
+ tiAdd.setFont(getButtonFont());
tiAdd.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -134,6 +138,7 @@
tiRemove.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
tiRemove.setText(messages.ModelTooling_Common_Remove);
tiRemove.setImage(componentEditor.createImage(ResourceProvider.IMG_Obj16_table_delete));
+ tiRemove.setFont(getButtonFont());
tiRemove.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -145,6 +150,7 @@
tiDown.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
tiDown.setText(messages.ModelTooling_Common_Down);
tiDown.setImage(componentEditor.createImage(ResourceProvider.IMG_Obj16_arrow_down));
+ tiDown.setFont(getButtonFont());
tiDown.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -156,6 +162,7 @@
tiUp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
tiUp.setText(messages.ModelTooling_Common_Up);
tiUp.setImage(componentEditor.createImage(ResourceProvider.IMG_Obj16_arrow_up));
+ tiUp.setFont(getButtonFont());
tiUp.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -191,6 +198,10 @@
}
+ protected Font getButtonFont() {
+ return group.getFont();
+ }
+
protected void addPressed() {
}
@@ -253,10 +264,11 @@
final IStructuredSelection selection = (IStructuredSelection) getList().getSelection();
final boolean selected = selection.size() > 0;
final int count = getItemCount();
+ final boolean tableIsFocused = getList().getTable().isFocusControl();
if (tiDown.isDisposed() == false) {
- tiDown.setEnabled(selected && count > 1);
- tiUp.setEnabled(selected && count > 1);
+ tiDown.setEnabled(selected && count > 1 && tableIsFocused);
+ tiUp.setEnabled(selected && count > 1 && tableIsFocused);
}
- tiRemove.setEnabled(selected);
+ tiRemove.setEnabled(selected && tableIsFocused);
}
}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/E4StringPickList.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/E4StringPickList.java
index aa9c06e..f86fa91 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/E4StringPickList.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/E4StringPickList.java
@@ -7,12 +7,14 @@
*
* Contributors:
* Steven Spungin <steven@spungin.tv> - initial API and implementation, Ongoing Maintenance
+ * Olivier Prouvost <olivier.prouvost@opcoach.com> - Bug 466731
*******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common;
import java.util.Arrays;
import java.util.List;
+
import org.eclipse.e4.tools.emf.ui.common.component.AbstractComponentEditor;
import org.eclipse.e4.tools.emf.ui.internal.Messages;
import org.eclipse.e4.tools.emf.ui.internal.ResourceProvider;
@@ -27,13 +29,17 @@
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
/**
@@ -61,9 +67,18 @@
tiReplace = new Button(getToolBar(), SWT.PUSH);
tiReplace.setText(messages.E4StringPickList_Replace);
tiReplace.setImage(editor.createImage(ResourceProvider.IMG_Obj16_world_edit));
+ tiReplace.setFont(getButtonFont());
- text = new Text(getToolBar().getParent(), SWT.SINGLE | SWT.LEAD | SWT.BORDER);
- text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
+ Composite valueParent = new Composite(getToolBar().getParent(), SWT.BORDER);
+ valueParent.setLayout(new GridLayout(2, false));
+ valueParent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
+
+ Label l = new Label(valueParent, SWT.NONE);
+ l.setText(messages.E4StringPickList_NewValue);
+ l.setToolTipText(messages.E4StringPickList_ToolTipNewValue);
+ text = new Text(valueParent, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
+ text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+ text.setToolTipText(messages.E4StringPickList_ToolTipNewValue);
tiReplace.addSelectionListener(new SelectionAdapter() {
@Override
@@ -82,6 +97,15 @@
}
});
+ text.addFocusListener(new FocusAdapter() {
+
+ @Override
+ public void focusGained(FocusEvent e) {
+ updateUiState();
+
+ }
+ });
+
updateUiState();
}
@@ -153,11 +177,13 @@
public void updateUiState() {
super.updateUiState();
- if (getTextWidget() != null) {
+ if (text != null) {
IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
Object firstViewerElement = sel.getFirstElement();
- boolean diff = !getTextWidget().getText().equals(firstViewerElement);
+ String txt = text.getText();
+ boolean diff = !txt.equals(firstViewerElement);
tiReplace.setEnabled(firstViewerElement != null && !getTextWidget().getText().isEmpty() && diff);
+ tiAdd.setEnabled(txt.length() > 0 && text.isFocusControl());
}
}