Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchris.poon2015-09-01 00:23:54 +0000
committerGerrit Code Review @ Eclipse.org2015-09-02 22:16:54 +0000
commit304393bd6fde6b648d93870a825377a3b7eb6872 (patch)
tree91b1632c7c38edf4e02bcd7e716dd0050c45d8e0 /org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui
parent9f4de2dba03de7b00c4db82f7e14ede218697447 (diff)
downloadorg.eclipse.mylyn.tasks-304393bd6fde6b648d93870a825377a3b7eb6872.tar.gz
org.eclipse.mylyn.tasks-304393bd6fde6b648d93870a825377a3b7eb6872.tar.xz
org.eclipse.mylyn.tasks-304393bd6fde6b648d93870a825377a3b7eb6872.zip
476383: add an attribute editor for label fields
Add a text attribute editor that supports single and multi values and has content assist Change-Id: I9e53666e713abb1affbb7b6376c5af7192174ddb Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=476383 Signed-off-by: chris.poon <chris.poon@tasktop.com>
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AttributeEditorToolkit.java37
1 files changed, 29 insertions, 8 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AttributeEditorToolkit.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AttributeEditorToolkit.java
index 47ac0b39f..b2a14c98a 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AttributeEditorToolkit.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AttributeEditorToolkit.java
@@ -28,9 +28,11 @@ import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.mylyn.commons.ui.compatibility.CommonThemes;
import org.eclipse.mylyn.commons.workbench.editors.CommonTextSupport;
+import org.eclipse.mylyn.internal.tasks.ui.OptionsProposalProvider;
import org.eclipse.mylyn.internal.tasks.ui.PersonProposalLabelProvider;
import org.eclipse.mylyn.internal.tasks.ui.PersonProposalProvider;
import org.eclipse.mylyn.internal.tasks.ui.editors.EditorUtil;
+import org.eclipse.mylyn.internal.tasks.ui.editors.LabelsAttributeEditor;
import org.eclipse.mylyn.internal.tasks.ui.editors.Messages;
import org.eclipse.mylyn.internal.tasks.ui.editors.PersonAttributeEditor;
import org.eclipse.mylyn.internal.tasks.ui.editors.RepositoryTextViewerConfiguration.Mode;
@@ -81,7 +83,16 @@ public class AttributeEditorToolkit {
}
public void adapt(AbstractAttributeEditor editor) {
- if (editor.getControl() instanceof Text || editor.getControl() instanceof CCombo
+ if (editor instanceof LabelsAttributeEditor) {
+ Control control = editor.getControl();
+ IContentProposalProvider contentProposalProvider = createContentProposalProvider(editor);
+ if (contentProposalProvider != null) {
+ ContentAssistCommandAdapter adapter = createContentAssistCommandAdapter(control,
+ contentProposalProvider);
+ adapter.setAutoActivationCharacters(null);
+ adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
+ }
+ } else if (editor.getControl() instanceof Text || editor.getControl() instanceof CCombo
|| editor instanceof PersonAttributeEditor) {
Control control = (editor instanceof PersonAttributeEditor)
? ((PersonAttributeEditor) editor).getText()
@@ -91,12 +102,11 @@ public class AttributeEditorToolkit {
control = editor.getControl();
}
if (!editor.isReadOnly() && hasContentAssist(editor.getTaskAttribute())) {
- IContentProposalProvider contentProposalProvider = createContentProposalProvider(editor.getTaskAttribute());
+ IContentProposalProvider contentProposalProvider = createContentProposalProvider(editor);
ILabelProvider labelPropsalProvider = createLabelProposalProvider(editor.getTaskAttribute());
if (contentProposalProvider != null && labelPropsalProvider != null) {
- ContentAssistCommandAdapter adapter = new ContentAssistCommandAdapter(control,
- getContentAdapter(control), contentProposalProvider,
- ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, new char[0], true);
+ ContentAssistCommandAdapter adapter = createContentAssistCommandAdapter(control,
+ contentProposalProvider);
adapter.setLabelProvider(labelPropsalProvider);
adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
if (editor instanceof PersonAttributeEditor) {
@@ -127,6 +137,12 @@ public class AttributeEditorToolkit {
editor.decorate(getColorIncoming());
}
+ ContentAssistCommandAdapter createContentAssistCommandAdapter(Control control,
+ IContentProposalProvider proposalProvider) {
+ return new ContentAssistCommandAdapter(control, getContentAdapter(control), proposalProvider,
+ ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, new char[0], true);
+ }
+
private IControlContentAdapter getContentAdapter(Control control) {
if (control instanceof Combo) {
return new ComboContentAdapter();
@@ -171,12 +187,17 @@ public class AttributeEditorToolkit {
/**
* Creates an IContentProposalProvider to provide content assist proposals for the given attribute.
*
- * @param attribute
- * attribute for which to provide content assist.
+ * @param editor
+ * editor for which to provide content assist.
* @return the IContentProposalProvider.
*/
- private IContentProposalProvider createContentProposalProvider(TaskAttribute attribute) {
+ IContentProposalProvider createContentProposalProvider(AbstractAttributeEditor editor) {
+ TaskAttribute attribute = editor.getTaskAttribute();
Map<String, String> proposals = attribute.getTaskData().getAttributeMapper().getOptions(attribute);
+ if (editor instanceof LabelsAttributeEditor) {
+ return new OptionsProposalProvider(proposals,
+ TaskAttribute.TYPE_MULTI_SELECT.equals(attribute.getMetaData().getType()));
+ }
return new PersonProposalProvider(null, attribute.getTaskData(), proposals);
}

Back to the top