Skip to content
Snippets Groups Projects
Commit 0e2babab authored by Christoph Döbber's avatar Christoph Döbber
Browse files

added data state variables and icons to field assist

refs 563
parent 6f9e8e2f
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,8 @@ import org.eclipse.jface.fieldassist.IContentProposal; ...@@ -22,6 +22,8 @@ import org.eclipse.jface.fieldassist.IContentProposal;
import org.eclipse.jface.fieldassist.IContentProposalListener; import org.eclipse.jface.fieldassist.IContentProposalListener;
import org.eclipse.jface.fieldassist.SimpleContentProposalProvider; import org.eclipse.jface.fieldassist.SimpleContentProposalProvider;
import org.eclipse.jface.fieldassist.TextContentAdapter; import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Text;
/** /**
...@@ -70,6 +72,30 @@ public class FieldAssist { ...@@ -70,6 +72,30 @@ public class FieldAssist {
concreteProvider.getAutoActivationChars()); concreteProvider.getAutoActivationChars());
adapter.setPropagateKeys(true); adapter.setPropagateKeys(true);
adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_IGNORE); adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_IGNORE);
adapter.setLabelProvider(new LabelProvider() {
/** {@inheritDoc} */
@Override
public String getText(Object element) {
if (element instanceof IContentProposal) {
IContentProposal prop = (IContentProposal) element;
if (prop.getLabel() == null) {
return prop.getContent();
}
return prop.getLabel();
}
return element.toString();
}
/** {@inheritDoc} */
@Override
public Image getImage(Object element) {
return FieldAssistImageRegistry.getIcon(getText(element));
}
});
adapter.addContentProposalListener(new IContentProposalListener() { adapter.addContentProposalListener(new IContentProposalListener() {
@Override @Override
......
/*--------------------------------------------------------------------------+
$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
| |
| Copyright 2012 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.fieldassist;
import java.util.HashMap;
import org.eclipse.swt.graphics.Image;
/**
* Class for managing the icons to display in FieldAssist.
*
* @author doebber
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public class FieldAssistImageRegistry {
/** Stores the mapping of displayed proposal string to icon. */
private static HashMap<String, Image> map = new HashMap<String, Image>();
/** Assigns icon to proposal. */
public static void put(String proposal, Image icon) {
map.put(proposal, icon);
}
/** Returns the icons assigned to this proposal. */
public static Image getIcon(String proposal) {
return map.get(proposal);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment