diff options
Diffstat (limited to 'plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer')
11 files changed, 0 insertions, 994 deletions
diff --git a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/OwnerKind.java b/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/OwnerKind.java deleted file mode 100644 index edca814dc4e..00000000000 --- a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/OwnerKind.java +++ /dev/null @@ -1,27 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2014 Cedric Dumoulin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer;
-
-
-/**
- * A fake OwnerKind.
- *
- * @author dumoulin
- *
- */
-public enum OwnerKind {
-
- owned, inherited;
-}
diff --git a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/PropertyCatalog.java b/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/PropertyCatalog.java deleted file mode 100644 index 2e1138edde1..00000000000 --- a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/PropertyCatalog.java +++ /dev/null @@ -1,79 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2014 Cedric Dumoulin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * A catalog of fake {@link PropertyModel}.
- *
- * @author dumoulin
- *
- */
-public class PropertyCatalog {
-
- /**
- * {@link TypeLibrary} used to find Types
- */
- protected TypeLibrary typeLibrary;
-
- protected List<PropertyModel> properties;
-
- protected void init() {
- properties = new ArrayList<PropertyModel>();
-
- properties.add(new PropertyModel("p1", typeLibrary.BOOLEAN, OwnerKind.owned));
- properties.add(new PropertyModel("p2", typeLibrary.INT, OwnerKind.owned));
- properties.add(new PropertyModel("p3", typeLibrary.DOUBLE, OwnerKind.owned));
- properties.add(new PropertyModel("p4", typeLibrary.INT, OwnerKind.inherited));
- properties.add(new PropertyModel("p5", typeLibrary.STRING, OwnerKind.owned));
- }
-
-
- /**
- * Constructor.
- *
- * @param typeLibrary TypeLibrary used to find types.
- */
- public PropertyCatalog(TypeLibrary typeLibrary) {
- this.typeLibrary = typeLibrary;
- init();
- }
-
- /**
- * @return the typeLibrary
- */
- public TypeLibrary getTypeLibrary() {
- return typeLibrary;
- }
-
-
- /**
- * @param typeLibrary the typeLibrary to set
- */
- public void setTypeLibrary(TypeLibrary typeLibrary) {
- this.typeLibrary = typeLibrary;
- }
-
-
- /**
- * @return the properties
- */
- public List<PropertyModel> getProperties() {
- return properties;
- }
-}
diff --git a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/PropertyModel.java b/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/PropertyModel.java deleted file mode 100644 index bfb619c3e20..00000000000 --- a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/PropertyModel.java +++ /dev/null @@ -1,102 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2014 Cedric Dumoulin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer;
-
-
-/**
- * @author dumoulin
- *
- */
-public class PropertyModel {
-
- protected String name;
- protected Type type;
- protected OwnerKind ownerKind;
-
- /**
- * Constructor.
- *
- */
- public PropertyModel() {
- // TODO Auto-generated constructor stub
- }
-
-
- /**
- * Constructor.
- *
- * @param name
- * @param type
- * @param ownerKind
- */
- public PropertyModel(String name, Type type, OwnerKind ownerKind) {
- this.name = name;
- this.type = type;
- this.ownerKind = ownerKind;
- }
-
-
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
-
-
- /**
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
-
-
- /**
- * @return the type
- */
- public Type getType() {
- return type;
- }
-
-
-
- /**
- * @param type the type to set
- */
- public void setType(Type type) {
- this.type = type;
- }
-
-
- /**
- * @return the ownerKind
- */
- public OwnerKind getOwnerKind() {
- return ownerKind;
- }
-
-
- /**
- * @param ownerKind the ownerKind to set
- */
- public void setOwnerKind(OwnerKind ownerKind) {
- this.ownerKind = ownerKind;
- }
-
-}
diff --git a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TableViewerExample.java b/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TableViewerExample.java deleted file mode 100644 index 23d18b3dd1e..00000000000 --- a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TableViewerExample.java +++ /dev/null @@ -1,211 +0,0 @@ -package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer; - -import java.util.List; - -import org.eclipse.core.databinding.observable.Realm; -import org.eclipse.jface.databinding.swt.SWTObservables; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ComboBoxViewerCellEditor; -import org.eclipse.jface.viewers.ICellModifier; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.window.ApplicationWindow; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; - -/** - * Example of a Table with editable cells. - * To be run as Java code - * - * @author cedric dumoulin - * - */ -public class TableViewerExample { - - static String[] COLUMN_NAMES = new String[] { "names", "types", "types2", "owner" }; - static int[] COLUMN_WIDTHS = new int[] { 300, 200, 200, 100 }; - static String[] COLUMNS_PROPERTIES = new String[] { "names_prop", "types_prop", "types2_prop", "owner_prop" }; - - static class ModelContentProvider implements IStructuredContentProvider { - - @SuppressWarnings("unchecked") - @Override - public Object[] getElements(Object inputElement) { - // The inputElement comes from view.setInput() - if (inputElement instanceof List) { - List models = (List) inputElement; - return models.toArray(); - } - return new Object[0]; - } - - @Override - public void dispose() { - } - - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - - } - - static class ModelLabelProvider extends LabelProvider implements ITableLabelProvider { - - @Override - public Image getColumnImage(Object element, int columnIndex) { - // no image to show - return null; - } - - @Override - public String getColumnText(Object element, int columnIndex) { - // each element comes from the ContentProvider.getElements(Object) - if (!(element instanceof PropertyModel)) { - return ""; - } - PropertyModel model = (PropertyModel) element; - switch (columnIndex) { - case 0: - return model.getName(); - case 1: - return model.getType().getName(); - case 2: - return model.getType().getName(); - case 3: - return model.getOwnerKind().toString(); - default: - break; - } - return ""; - } - } - - static class ModelCellModifier implements ICellModifier { - TableViewer viewer; - - public ModelCellModifier(TableViewer viewer) { - this.viewer = viewer; - } - - @Override - public boolean canModify(Object element, String property) { - // property is defined by viewer.setColumnProperties() - // allow the FOO column can be modified. - return ("names_prop".equals(property) - || "types_prop".equals(property) - || "types2_prop".equals(property) - ); - - } - - @Override - public Object getValue(Object element, String property) { - if ("names_prop".equals(property)) { - return ((PropertyModel) element).getName(); - } - if ("types_prop".equals(property)) { - return ((PropertyModel) element).getType(); - } - if ("types2_prop".equals(property)) { - return ((PropertyModel) element).getType(); - } - return ""; - } - - @Override - public void modify(Object element, String property, Object value) { - if ("names_prop".equals(property)) { - TableItem item = (TableItem) element; - ((PropertyModel) item.getData()).setName("" + value); - - // refresh the viewer to show the changes to our user. - viewer.refresh(); - } - else if ("types_prop".equals(property)) { - TableItem item = (TableItem) element; - System.out.println("modify.type(" + value + ")"); - if( value instanceof Type) { - ((PropertyModel) item.getData()).setType((Type)value); - } - // refresh the viewer to show the changes to our user. - viewer.refresh(); - } - else if ("types2_prop".equals(property)) { - TableItem item = (TableItem) element; - System.out.println("modify.type2(" + value + ")"); - if( value instanceof Type) { - ((PropertyModel) item.getData()).setType((Type)value); - } - // refresh the viewer to show the changes to our user. - viewer.refresh(); - } - } - } - - public static void main(String[] args) { - - final TypeLibrary typeLibrary = new TypeLibrary(); - final PropertyCatalog propertyCatalog = new PropertyCatalog(typeLibrary); - final TypeLabelProvider typeLabelProvider = new TypeLabelProvider(); - - - final ApplicationWindow app = new ApplicationWindow(null) { - @Override - protected Control createContents(Composite parent) { - TableViewer tableViewer = new TableViewer(parent, SWT.SINGLE | SWT.FULL_SELECTION); - Table table = tableViewer.getTable(); - table.setHeaderVisible(true); - table.setLinesVisible(true); - - for (int i = 0; i < COLUMN_NAMES.length; i++) { - TableColumn tableColumn = new TableColumn(table, SWT.LEFT); - tableColumn.setText(COLUMN_NAMES[i]); - tableColumn.setWidth(COLUMN_WIDTHS[i]); - } - - tableViewer.setContentProvider(new ModelContentProvider()); - tableViewer.setLabelProvider(new ModelLabelProvider()); - - // Create a ComboBoxViewerCellEditor for types - // - ComboBoxViewerCellEditor comboBoxViewerCellEditor = new ComboBoxViewerCellEditor(table); - comboBoxViewerCellEditor.setContentProvider(ArrayContentProvider.getInstance()); - comboBoxViewerCellEditor.setLabelProvider(typeLabelProvider); - comboBoxViewerCellEditor.setInput(typeLibrary.getTypes()); - // Create editor support - tableViewer.setColumnProperties(COLUMNS_PROPERTIES); - tableViewer.setCellEditors(new CellEditor[] { - new TextCellEditor(table), - new TypeSelectorCellEditor(table, typeLibrary, typeLabelProvider), - comboBoxViewerCellEditor - }); - tableViewer.setCellModifier(new ModelCellModifier(tableViewer)); - - tableViewer.setInput(propertyCatalog.getProperties()); - return parent; - } - }; - - Realm.runWithDefault(SWTObservables.getRealm(Display.getDefault()), - new Runnable() { - @Override - public void run() { - app.setBlockOnOpen(true); - app.open(); - Display.getDefault().dispose(); - } - }); - - } -} diff --git a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/Type.java b/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/Type.java deleted file mode 100644 index 0b57389fc9a..00000000000 --- a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/Type.java +++ /dev/null @@ -1,54 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2014 Cedric Dumoulin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer;
-
-
-/**
- * A fake type for tests
- *
- * @author cedric dumoulin
- *
- */
-public class Type {
-
- protected String name;
-
-
- /**
- * Constructor.
- *
- * @param name
- */
- public Type(String name) {
- this.name = name;
- }
-
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
-
- /**
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
-}
diff --git a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TypeLabelProvider.java b/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TypeLabelProvider.java deleted file mode 100644 index 1c67a84b8d0..00000000000 --- a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TypeLabelProvider.java +++ /dev/null @@ -1,35 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2014 Cedric Dumoulin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer;
-
-import org.eclipse.jface.viewers.LabelProvider;
-
-
-/**
- * @author cedric dumoulin
- *
- */
-public class TypeLabelProvider extends LabelProvider {
-
-
- @Override
- public String getText(Object element) {
- if(element instanceof Type) {
- return ((Type)element).getName();
- }
-
- return super.getText(element);
- }
-}
diff --git a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TypeLibrary.java b/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TypeLibrary.java deleted file mode 100644 index 3cf5ef99b3b..00000000000 --- a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TypeLibrary.java +++ /dev/null @@ -1,72 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2014 Cedric Dumoulin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * A library of predefined types
- *
- * @author cedric dumoulin
- *
- */
-public class TypeLibrary {
-
- final public Type INT = new Type("int");
- final public Type STRING = new Type("String");
- final public Type BOOLEAN = new Type("boolean");
- final public Type DOUBLE = new Type("double");
-
- protected List<Type> types;
-
-
-
-
- /**
- * Constructor.
- *
- */
- public TypeLibrary() {
- init();
- }
-
-
- protected void init() {
- types = new ArrayList<Type>();
-
- types.add(INT);
- types.add(STRING);
- types.add(BOOLEAN);
- types.add(DOUBLE);
-
- }
-
- /**
- * @return the types
- */
- public List<Type> getTypes() {
- return types;
- }
-
-
- public Object getDefaultType() {
- return STRING;
- }
-
-
-
-}
diff --git a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TypeSelectorCellEditor.java b/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TypeSelectorCellEditor.java deleted file mode 100644 index d8b2fe9a0b8..00000000000 --- a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/TypeSelectorCellEditor.java +++ /dev/null @@ -1,198 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2014 Cedric Dumoulin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.bindings.keys.KeyStroke;
-import org.eclipse.jface.fieldassist.ContentProposalAdapter;
-import org.eclipse.jface.fieldassist.IContentProposal;
-import org.eclipse.jface.fieldassist.IContentProposalListener;
-import org.eclipse.jface.fieldassist.IContentProposalProvider;
-import org.eclipse.jface.fieldassist.TextContentAdapter;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer.contentassist.TypeContentProposal;
-import org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer.contentassist.TypeContentProposalProvider;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Text;
-
-
-/**
- * A {@link TextCellEditor} with content assist.
- *
- * @author cedric dumoulin
- *
- */
-public class TypeSelectorCellEditor extends TextCellEditor {
-
- /**
- * Type catalog used to propose existing types.
- */
- protected TypeLibrary typeCatalog;
-
- protected Type type;
-
- /**
- * Label provider for type names
- */
- protected ILabelProvider typeLabelProvider;
-
- /**
- * Constructor.
- *
- */
- public TypeSelectorCellEditor( TypeLibrary typeLibrary, ILabelProvider typeLabelProvider) {
- this.typeCatalog = typeLibrary;
- this.typeLabelProvider = typeLabelProvider;
- setDefaultType();
- // Try to install content assist
- // Content assist is not installed if this method is called for the first time from the Constructor.
- // This is because the typeCatalog is not set.
- // So constructors need to also try to set the content assist, after typeCatalog is set.
- installContentAssistantProvider();
- }
-
- /**
- * Constructor.
- *
- * @param parent
- * @param typeLibrary
- */
- public TypeSelectorCellEditor(Composite parent, TypeLibrary typeLibrary, ILabelProvider typeLabelProvider) {
- super(parent);
- this.typeCatalog = typeLibrary;
- this.typeLabelProvider = typeLabelProvider;
- setDefaultType();
- // Try to install content assist
- // Content assist is not installed if this method is called for the first time from the Constructor.
- // This is because the typeCatalog is not set.
- // So constructors need to also try to set the content assist, after typeCatalog is set.
- installContentAssistantProvider();
- }
-
- /**
- * Constructor.
- *
- * @param parent
- * @param style
- */
- public TypeSelectorCellEditor(Composite parent, int style, TypeLibrary typeLibrary, ILabelProvider typeLabelProvider) {
- super(parent, style);
- this.typeCatalog = typeLibrary;
- this.typeLabelProvider = typeLabelProvider;
- setDefaultType();
- // Try to install content assist
- // Content assist is not installed if this method is called for the first time from the Constructor.
- // This is because the typeCatalog is not set.
- // So constructors need to also try to set the content assist, after typeCatalog is set.
- installContentAssistantProvider();
- }
-
- /**
- * Call parent to create the {@link Text} and install contentAssist
- * @see org.eclipse.jface.viewers.TextCellEditor#createControl(org.eclipse.swt.widgets.Composite)
- *
- * @param parent
- * @return
- */
- protected Control createControl(Composite parent) {
-
- Control control = super.createControl(parent);
- // Try to install content assist
- // Content assist is not installed if this method is called for the first time from the Constructor.
- // This is because the typeCatalog is not set.
- // So constructors need to also try to set the content assist, after typeCatalog is set.
- installContentAssistantProvider();
-
- return control;
- }
-
- /**
- * Install the ContentAssistant if all required property are already set.
- *
- */
- protected void installContentAssistantProvider() {
-
- if( text==null || typeCatalog == null ) {
- return;
- }
-
- installContentAssistantProvider( new TypeContentProposalProvider(typeCatalog));
- }
-
- /**
- * Install content assistant provider.
- *
- * @param control The control to which content assist is installed.
- *
- * @param contentProposalProvider The associated {@link ContentProposalAdapter}.
- */
- protected void installContentAssistantProvider( IContentProposalProvider contentProposalProvider) {
-// KeyStroke keyStroke = KeyStroke.getInstance("Ctrl+Space");
- KeyStroke keyStroke = null;
- char[] autoActivationCharacters = null;
- int autoActivationDelay = 500;
-
- ContentProposalAdapter adapter = new ContentProposalAdapter(text, new TextContentAdapter(), contentProposalProvider, keyStroke, autoActivationCharacters);
- adapter.setAutoActivationDelay(autoActivationDelay);
-
- // filter proposals as keys are pressed and proposals popup is present
- adapter.setFilterStyle(ContentProposalAdapter.FILTER_NONE);
-
- // replace all text
- adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_IGNORE);
-
- // Listener called when a selection is made.
- // Use the associated type to set the Type.
- adapter.addContentProposalListener(new IContentProposalListener() {
-
- @Override
- public void proposalAccepted(IContentProposal proposal) {
- // set the corresponding type
- if( proposal instanceof TypeContentProposal ) {
- TypeContentProposal typeProposal = (TypeContentProposal)proposal;
- setType(typeProposal.getType());
- }
-
- }
- });
-
- }
-
- public Type getType() {
- return type;
- }
-
- public void setType( Type type) {
- setValue(type);
- }
-
- public void setDefaultType() {
- setValue(typeCatalog.getDefaultType());
- }
-
- @Override
- protected void doSetValue(Object value) {
- Assert.isTrue(value != null && (value instanceof Type));
- type = (Type)value;
- super.doSetValue(typeLabelProvider.getText(type));
- }
-
- @Override
- protected Object doGetValue() {
- return type;
- }
-}
diff --git a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/contentassist/TypeContentProposal.java b/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/contentassist/TypeContentProposal.java deleted file mode 100644 index 8996be22a32..00000000000 --- a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/contentassist/TypeContentProposal.java +++ /dev/null @@ -1,69 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2014 Cedric Dumoulin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer.contentassist;
-
-import org.eclipse.jface.fieldassist.IContentProposal;
-import org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer.Type;
-
-
-/**
- * Field assist {@link IContentProposal} .
- * This implementation is used to render one proposal of a {@link Stereotype} as a short name:
- * shortName (profil)
- *
- * @author cedric dumoulin
- *
- */
-public class TypeContentProposal extends TypeContentProposalBase implements IContentProposal, Comparable<IContentProposal> {
-
- /**
- * Constructor.
- *
- * @param stereotype
- */
- public TypeContentProposal(Type type) {
- super( type );
- }
-
- /**
- * @see org.eclipse.jface.fieldassist.IContentProposal#getContent()
- *
- * @return
- */
- public String getContent() {
- return type.getName() ;
- }
-
- /**
- * @see org.eclipse.jface.fieldassist.IContentProposal#getCursorPosition()
- *
- * @return
- */
- public int getCursorPosition() {
- return getContent().length();
- }
-
- /**
- * @see org.eclipse.jface.fieldassist.IContentProposal#getLabel()
- *
- * @return
- */
- public String getLabel() {
-
- return type.getName();
- }
-
-
-}
diff --git a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/contentassist/TypeContentProposalBase.java b/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/contentassist/TypeContentProposalBase.java deleted file mode 100644 index 1287ec101f0..00000000000 --- a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/contentassist/TypeContentProposalBase.java +++ /dev/null @@ -1,70 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2014 Cedric Dumoulin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer.contentassist;
-
-import java.util.List;
-
-import org.eclipse.jface.fieldassist.IContentProposal;
-import org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer.Type;
-
-
-/**
- * Field assist {@link IContentProposal} .
- * Base class for TypeContentProposal.
- *
- *
- * @author cedric dumoulin
- *
- */
-public abstract class TypeContentProposalBase implements IContentProposal, Comparable<IContentProposal> {
-
- /**
- * The type that is render.
- */
- protected Type type;
-
-
- /**
- * Constructor.
- *
- * @param stereotype
- */
- public TypeContentProposalBase(Type type) {
- this.type = type;
- }
-
- /**
- * @see org.eclipse.jface.fieldassist.IContentProposal#getDescription()
- *
- * @return
- */
- public String getDescription() {
-
- return type.getName();
- }
-
- public int compareTo(IContentProposal o) {
- return this.getLabel().compareTo(o.getLabel());
- }
-
-
- /**
- * @return the type
- */
- public Type getType() {
- return type;
- }
-
-}
diff --git a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/contentassist/TypeContentProposalProvider.java b/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/contentassist/TypeContentProposalProvider.java deleted file mode 100644 index 12fc3604e10..00000000000 --- a/plugins/uml/profile/org.eclipse.papyrus.uml.profile.drafter.tests/test/org/eclipse/papyrus/uml/profile/drafter/tests/ui/propertyviewer/contentassist/TypeContentProposalProvider.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer.contentassist;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.jface.fieldassist.IContentProposal;
-import org.eclipse.jface.fieldassist.IContentProposalProvider;
-import org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer.Type;
-import org.eclipse.papyrus.uml.profile.drafter.tests.ui.propertyviewer.TypeLibrary;
-
-/**
- * A {@link IContentProposalProvider} providing {@link Type} names.
- *
- * @author cedric dumoulin
- *
- */
-public class TypeContentProposalProvider implements IContentProposalProvider {
-
- /**
- * The types that will be proposed.
- */
- private TypeLibrary typeCatalog;
-
- /**
- * Constructor.
- *
- * @param stereotypes
- */
- public TypeContentProposalProvider(TypeLibrary typeCatalog) {
- this.typeCatalog = typeCatalog;
- }
-
-
- /**
- *
- * @see org.eclipse.jface.fieldassist.IContentProposalProvider#getProposals(java.lang.String, int)
- *
- * @param contents
- * @param position
- * @return
- */
- public IContentProposal[] getProposals(String contents, int position) {
-
- List<TypeContentProposalBase> shortProposals = new ArrayList<TypeContentProposalBase>();
-
-
- List<Type> types = typeCatalog.getTypes();
-
- for( Type type : types) {
- final String simpleName = type.getName();
-
- if(match(simpleName, contents, position)) {
- shortProposals.add(new TypeContentProposal(type));
- }
- }
-
- // Now concat both list
- Collections.sort(shortProposals);
-
- return shortProposals.toArray(new IContentProposal[shortProposals.size()]);
- }
-
-
- /**
- * Return true if the actual proposal math the provided name. False otherwise.
- *
- * @param name The name to check
- * @param proposal The actual proposal of user
- * @param position The cursor position in the user proposal.
- * @return
- */
- private boolean match(final String name, String proposal, int position) {
- return position < name.length() && proposal.substring(0, position).equalsIgnoreCase(name.substring(0, position));
- }
-
-}
|