Author: scabanovich
Date: 2009-02-03 09:09:04 -0500 (Tue, 03 Feb 2009)
New Revision: 13449
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/AttributeContentProposalProviderFactory.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/DialogCellEditorEx.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringEditor.java
Log:
JBIDE-3647
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/AttributeContentProposalProviderFactory.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/AttributeContentProposalProviderFactory.java 2009-02-03
14:01:19 UTC (rev 13448)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/AttributeContentProposalProviderFactory.java 2009-02-03
14:09:04 UTC (rev 13449)
@@ -26,6 +26,7 @@
import org.eclipse.jface.fieldassist.FieldDecoration;
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
import org.eclipse.jface.fieldassist.IContentProposal;
+import org.eclipse.jface.fieldassist.IContentProposalListener2;
import org.eclipse.jface.fieldassist.IContentProposalProvider;
import org.eclipse.jface.fieldassist.IControlContentAdapter;
import org.eclipse.jface.fieldassist.TextContentAdapter;
@@ -62,15 +63,23 @@
}
public static void registerContentAssist(DefaultValueAdapter valueAdapter, Control
control) {
+ registerContentAssist(valueAdapter, control, null);
+ }
+
+ public static void registerContentAssist(DefaultValueAdapter valueAdapter, Control
control, IContentProposalListener2 listener) {
XModelObject object = valueAdapter.getModelObject();
XAttribute attr = valueAdapter.getAttribute();
if (attr == null && valueAdapter.getAttributeData() != null) {
attr = valueAdapter.getAttributeData().getAttribute();
}
- registerContentAssist(object, attr, control);
+ registerContentAssist(object, attr, control, listener);
}
public static void registerContentAssist(XModelObject object, XAttribute attr, Control
control) {
+ registerContentAssist(object, attr, control, null);
+ }
+
+ public static void registerContentAssist(XModelObject object, XAttribute attr, Control
control, IContentProposalListener2 listener) {
IControlContentAdapter controlAdapter = control instanceof Text
? new TextContentAdapter()
: control instanceof Combo
@@ -96,6 +105,9 @@
null);
adapter.setPropagateKeys(true);
adapter.setProposalAcceptanceStyle(p.getProposalAcceptanceStyle());
+ if(listener != null) {
+ adapter.addContentProposalListener(listener);
+ }
added = true;
}
if (!ps.isEmpty()) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/DialogCellEditorEx.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/DialogCellEditorEx.java 2009-02-03
14:01:19 UTC (rev 13448)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/DialogCellEditorEx.java 2009-02-03
14:09:04 UTC (rev 13449)
@@ -12,8 +12,11 @@
import org.jboss.tools.common.model.ui.IValueChangeListener;
import org.jboss.tools.common.model.ui.IValueProvider;
+import
org.jboss.tools.common.model.ui.attribute.AttributeContentProposalProviderFactory;
import org.jboss.tools.common.model.ui.attribute.adapter.DefaultValueAdapter;
import org.eclipse.jdt.internal.ui.refactoring.contentassist.ControlContentAssistHelper;
+import org.eclipse.jface.fieldassist.ContentProposalAdapter;
+import org.eclipse.jface.fieldassist.IContentProposalListener2;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.resource.JFaceResources;
@@ -146,10 +149,11 @@
public void setPropertyEditor(PropertyEditor editor) {
propertyEditor = editor;
if(editor != null) {
- IContentAssistProcessor processor =
(IContentAssistProcessor)editor.getAdapter(IContentAssistProcessor.class);
- if(processor != null) {
- ControlContentAssistHelper.createTextContentAssistant(text, processor);
- }
+ addContentAssist(text);
+// IContentAssistProcessor processor =
(IContentAssistProcessor)editor.getAdapter(IContentAssistProcessor.class);
+// if(processor != null) {
+// ControlContentAssistHelper.createTextContentAssistant(text, processor);
+// }
}
}
@@ -169,6 +173,7 @@
text.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if ((byte)e.character == (byte)13) { // Enter
+ if(popup.isPopupOpened) return;
fireApplyEditorValue();
fireCancelEditor();
}
@@ -257,7 +262,28 @@
}
else if(text != null && !text.isDisposed() && editable)
text.forceFocus();
}
+
+ protected void addContentAssist(Text text) {
+ if(propertyEditor != null && propertyEditor.getInput() instanceof
DefaultValueAdapter) {
+ DefaultValueAdapter valueAdapter = (DefaultValueAdapter)propertyEditor.getInput();
+ AttributeContentProposalProviderFactory.registerContentAssist(valueAdapter, text,
popup);
+ }
+ }
+
+ CPL2 popup = new CPL2();
+ class CPL2 implements IContentProposalListener2 {
+ boolean isPopupOpened = false;
+
+ public void proposalPopupClosed(ContentProposalAdapter adapter) {
+ isPopupOpened = false;
+ }
+
+ public void proposalPopupOpened(ContentProposalAdapter adapter) {
+ isPopupOpened = true;
+ }
+ }
+
protected void fireCancelEditor() {
skipDeactivate = Boolean.TRUE.booleanValue();
super.fireCancelEditor();
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringEditor.java 2009-02-03
14:01:19 UTC (rev 13448)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/StringEditor.java 2009-02-03
14:09:04 UTC (rev 13449)
@@ -14,7 +14,10 @@
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import
org.jboss.tools.common.model.ui.attribute.AttributeContentProposalProviderFactory;
+import org.jboss.tools.common.model.ui.attribute.adapter.DefaultValueAdapter;
import org.jboss.tools.common.model.ui.widgets.IWidgetSettings;
public class StringEditor extends ValueEditor {
@@ -27,7 +30,11 @@
}
protected CellEditor createCellEditor(Composite parent) {
- return (cellEditor = new TextCellEditor(parent, SWT.NONE));
+ TextCellEditor t = new TextCellEditor(parent, SWT.NONE);
+ Text text = (Text)t.getControl();
+ DefaultValueAdapter valueAdapter = (DefaultValueAdapter)getInput();
+ AttributeContentProposalProviderFactory.registerContentAssist(valueAdapter, text);
+ return (cellEditor = t);
}
protected ExtendedFieldEditor createFieldEditor(Composite parent) {
Show replies by date