Author: adietish
Date: 2011-02-01 03:49:17 -0500 (Tue, 01 Feb 2011)
New Revision: 28817
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/ContentProposalFactory.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java
Log:
[JBIDE-8259] added content proposals for cloud name, cloud url, username
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/ContentProposalFactory.java
(from rev 28780,
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/ContentProposalFactory.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/ContentProposalFactory.java 2011-02-01
08:49:17 UTC (rev 28817)
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.internal.deltacloud.ui.utils;
+
+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.StringsPreferenceValue;
+
+/**
+ * @author André Dietisheim
+ */
+public class ContentProposalFactory {
+
+ public static ContentProposalAdapter addPreferencesProposalAdapter(final Text text,
String preferencesKey) {
+ final ControlDecoration decoration = createContenAssistDecoration(text);
+
+ final StringsPreferenceValue preferencesValues =
+ new StringsPreferenceValue(',', 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);
+ 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("History available");
+ decoration.setShowHover(true);
+ decoration.hide();
+ return decoration;
+ }
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/ContentProposalFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java 2011-02-01
07:37:54 UTC (rev 28816)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java 2011-02-01
08:49:17 UTC (rev 28817)
@@ -66,7 +66,7 @@
import org.jboss.tools.internal.deltacloud.ui.common.swt.JFaceUtils;
import org.jboss.tools.internal.deltacloud.ui.preferences.IPreferenceKeys;
import org.jboss.tools.internal.deltacloud.ui.preferences.StringPreferenceValue;
-import org.jboss.tools.internal.deltacloud.ui.utils.DeltaCloudUIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.ContentProposalFactory;
/**
* @author Jeff Jonhston
@@ -334,7 +334,7 @@
Label nameLabel = new Label(container, SWT.NULL);
nameLabel.setText(WizardMessages.getString(NAME_LABEL));
Text nameText = new Text(container, SWT.BORDER | SWT.SINGLE);
- DeltaCloudUIUtils.addPreferencesProposalAdapter(nameText, NAME_PROPOSAL_KEY);
+ ContentProposalFactory.addPreferencesProposalAdapter(nameText, NAME_PROPOSAL_KEY);
bindName(dbc, nameText);
// url
@@ -342,7 +342,7 @@
urlLabel.setText(WizardMessages.getString(URL_LABEL));
Point p1 = urlLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT);
Text urlText = new Text(container, SWT.BORDER | SWT.SINGLE);
- DeltaCloudUIUtils.addPreferencesProposalAdapter(urlText, URL_PROPOSAL_KEY);
+ ContentProposalFactory.addPreferencesProposalAdapter(urlText, URL_PROPOSAL_KEY);
dbc.bindValue(
WidgetProperties.text(SWT.Modify).observe(urlText),
BeanProperties.value(
@@ -367,7 +367,7 @@
Label usernameLabel = new Label(container, SWT.NULL);
usernameLabel.setText(WizardMessages.getString(USERNAME_LABEL));
Text usernameText = new Text(container, SWT.BORDER | SWT.SINGLE);
- DeltaCloudUIUtils.addPreferencesProposalAdapter(usernameText, USERNAME_PROPOSAL_KEY);
+ ContentProposalFactory.addPreferencesProposalAdapter(usernameText,
USERNAME_PROPOSAL_KEY);
IObservableValue usernameObservable =
WidgetProperties.text(SWT.Modify).observe(usernameText);
dbc.bindValue(
usernameObservable,