Author: adietish
Date: 2011-01-31 11:19:57 -0500 (Mon, 31 Jan 2011)
New Revision: 28775
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/DeltaCloudUIUtils.java
Log:
[JBIDE-8259] added content proposals for cloud name, cloud url, username
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/DeltaCloudUIUtils.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/DeltaCloudUIUtils.java 2011-01-31
16:17:33 UTC (rev 28774)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/DeltaCloudUIUtils.java 2011-01-31
16:19:57 UTC (rev 28775)
@@ -12,11 +12,15 @@
import org.eclipse.jface.bindings.keys.KeyStroke;
import org.eclipse.jface.fieldassist.ContentProposalAdapter;
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
import org.eclipse.jface.fieldassist.SimpleContentProposalProvider;
import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;
import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.internal.deltacloud.ui.preferences.StringEntriesPreferenceValue;
@@ -27,21 +31,41 @@
public class DeltaCloudUIUtils {
public static ContentProposalAdapter createPreferencesProposalAdapter(final Text text,
String preferencesKey) {
- final StringEntriesPreferenceValue preferencesValues = new
StringEntriesPreferenceValue(",", preferencesKey, Activator.PLUGIN_ID);
+ final ControlDecoration decoration = createContenAssistDecoration(text);
+ final StringEntriesPreferenceValue preferencesValues = new
StringEntriesPreferenceValue(",", preferencesKey,
+ Activator.PLUGIN_ID);
SimpleContentProposalProvider proposalProvider = new
SimpleContentProposalProvider(preferencesValues.get());
proposalProvider.setFiltering(true);
text.addFocusListener(new FocusAdapter() {
@Override
+ public void focusGained(FocusEvent e) {
+ decoration.show();
+ }
+
+ @Override
public void focusLost(FocusEvent e) {
+ decoration.hide();
preferencesValues.add(text.getText());
preferencesValues.store();
}
});
KeyStroke keyStroke = KeyStroke.getInstance(SWT.CONTROL, ' ');
- ContentProposalAdapter proposalAdapter = new ContentProposalAdapter(text, new
TextContentAdapter(), proposalProvider, keyStroke, null);
+ ContentProposalAdapter proposalAdapter = new ContentProposalAdapter(text, new
TextContentAdapter(),
+ proposalProvider, keyStroke, null);
proposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
return proposalAdapter;
}
+
+ private static ControlDecoration createContenAssistDecoration(Control control) {
+ ControlDecoration decoration = new ControlDecoration(control, SWT.RIGHT | SWT.TOP);
+ Image errorImage = FieldDecorationRegistry.getDefault()
+ .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL).getImage();
+ decoration.setImage(errorImage);
+ decoration.setDescriptionText("Content Assist Available");
+ decoration.setShowHover(true);
+ decoration.hide();
+ return decoration;
+ }
}
Show replies by date