TCI - Remove warnings
* small refactoring to remove deprecation warnings
* add java doc
* other small changes
Change-Id: I186997e7d3974fec982bd13b48e7b1bc64b4404d
Signed-off-by: Eugen Neufeld <eneufeld@eclipsesource.com>
diff --git a/bundles/org.eclipse.emf.ecp.core/src/org/eclipse/emf/ecp/internal/core/util/ExtensionParser.java b/bundles/org.eclipse.emf.ecp.core/src/org/eclipse/emf/ecp/internal/core/util/ExtensionParser.java
index e19c313..c89baaa 100644
--- a/bundles/org.eclipse.emf.ecp.core/src/org/eclipse/emf/ecp/internal/core/util/ExtensionParser.java
+++ b/bundles/org.eclipse.emf.ecp.core/src/org/eclipse/emf/ecp/internal/core/util/ExtensionParser.java
@@ -75,6 +75,8 @@
case IExtensionDelta.REMOVED:
removeExtension(extension, remove);
break;
+ default:
+ break;
}
}
@@ -130,6 +132,7 @@
/**
* @author Eike Stepper
+ * @param <ELEMENT> The type of this descriptor which must extend {@link InternalRegistryElement}
*/
public static class ExtensionDescriptor<ELEMENT extends InternalRegistryElement>
extends ElementDescriptor<ELEMENT> {
diff --git a/bundles/org.eclipse.emf.ecp.core/src/org/eclipse/emf/ecp/spi/core/util/InternalElementRegistry.java b/bundles/org.eclipse.emf.ecp.core/src/org/eclipse/emf/ecp/spi/core/util/InternalElementRegistry.java
index 1fb6da2..e02670a 100644
--- a/bundles/org.eclipse.emf.ecp.core/src/org/eclipse/emf/ecp/spi/core/util/InternalElementRegistry.java
+++ b/bundles/org.eclipse.emf.ecp.core/src/org/eclipse/emf/ecp/spi/core/util/InternalElementRegistry.java
@@ -28,6 +28,7 @@
/**
* @author Eike Stepper
+ * @param <ELEMENT> The type of this listener, must extend an {@link ECPElement}
*/
public interface ResolveListener<ELEMENT extends ECPElement> {
void descriptorChanged(InternalDescriptor<ELEMENT> descriptor, boolean resolved) throws Exception;
diff --git a/bundles/org.eclipse.emf.ecp.edit.swt/src/org/eclipse/emf/ecp/edit/internal/swt/controls/AttributeMultiControlTester.java b/bundles/org.eclipse.emf.ecp.edit.swt/src/org/eclipse/emf/ecp/edit/internal/swt/controls/AttributeMultiControlTester.java
index 19b12e6..4a3d7bd 100644
--- a/bundles/org.eclipse.emf.ecp.edit.swt/src/org/eclipse/emf/ecp/edit/internal/swt/controls/AttributeMultiControlTester.java
+++ b/bundles/org.eclipse.emf.ecp.edit.swt/src/org/eclipse/emf/ecp/edit/internal/swt/controls/AttributeMultiControlTester.java
@@ -94,26 +94,24 @@
if (EAttribute.class.isInstance(feature)) {
final Class<?> instanceClass = ((EAttribute) feature).getEAttributeType().getInstanceClass();
- if (instanceClass != null) {
- if (instanceClass.isPrimitive()) {
- try {
- final Class<?> primitive = (Class<?>) tester.getSupportedClassType().getField("TYPE").get(null);//$NON-NLS-1$
- if (!primitive.equals(instanceClass)) {
- return NOT_APPLICABLE;
- }
-
- } catch (final IllegalArgumentException e) {
- return NOT_APPLICABLE;
- } catch (final SecurityException e) {
- return NOT_APPLICABLE;
- } catch (final IllegalAccessException e) {
- return NOT_APPLICABLE;
- } catch (final NoSuchFieldException e) {
+ if (instanceClass != null && instanceClass.isPrimitive()) {
+ try {
+ final Class<?> primitive = (Class<?>) tester.getSupportedClassType().getField("TYPE").get(null);//$NON-NLS-1$
+ if (!primitive.equals(instanceClass)) {
return NOT_APPLICABLE;
}
- } else if (!tester.getSupportedClassType().isAssignableFrom(instanceClass)) {
+
+ } catch (final IllegalArgumentException e) {
+ return NOT_APPLICABLE;
+ } catch (final SecurityException e) {
+ return NOT_APPLICABLE;
+ } catch (final IllegalAccessException e) {
+ return NOT_APPLICABLE;
+ } catch (final NoSuchFieldException e) {
return NOT_APPLICABLE;
}
+ } else if (instanceClass != null && !tester.getSupportedClassType().isAssignableFrom(instanceClass)) {
+ return NOT_APPLICABLE;
}
} else if (EReference.class.isInstance(feature)) {
return NOT_APPLICABLE;
diff --git a/bundles/org.eclipse.emf.ecp.edit.swt/src/org/eclipse/emf/ecp/edit/internal/swt/controls/NumericalControl.java b/bundles/org.eclipse.emf.ecp.edit.swt/src/org/eclipse/emf/ecp/edit/internal/swt/controls/NumericalControl.java
index 544431e..709a211 100644
--- a/bundles/org.eclipse.emf.ecp.edit.swt/src/org/eclipse/emf/ecp/edit/internal/swt/controls/NumericalControl.java
+++ b/bundles/org.eclipse.emf.ecp.edit.swt/src/org/eclipse/emf/ecp/edit/internal/swt/controls/NumericalControl.java
@@ -188,28 +188,12 @@
boolean maxValue = false;
final Class<?> instanceClass = getInstanceClass();
String formatedValue = ""; //$NON-NLS-1$
- try {
- if (Integer.class.isAssignableFrom(instanceClass)
- || Integer.class.getField("TYPE").get(null).equals(instanceClass)) { //$NON-NLS-1$
- if (Integer.MAX_VALUE == number.intValue()) {
- maxValue = true;
- formatedValue = format.format(Integer.MAX_VALUE);
- }
- } else if (Long.class.isAssignableFrom(instanceClass)
- || Long.class.getField("TYPE").get(null).equals(instanceClass)) { //$NON-NLS-1$
- if (Long.MAX_VALUE == number.longValue()) {
- maxValue = true;
- formatedValue = format.format(Long.MAX_VALUE);
- }
- }
- } catch (final IllegalArgumentException ex) {
- Activator.logException(ex);
- } catch (final SecurityException ex) {
- Activator.logException(ex);
- } catch (final IllegalAccessException ex) {
- Activator.logException(ex);
- } catch (final NoSuchFieldException ex) {
- Activator.logException(ex);
+ if (isOfClass(Integer.class, instanceClass) && Integer.MAX_VALUE == number.intValue()) {
+ maxValue = true;
+ formatedValue = format.format(Integer.MAX_VALUE);
+ } else if (isOfClass(Long.class, instanceClass) && Long.MAX_VALUE == number.longValue()) {
+ maxValue = true;
+ formatedValue = format.format(Long.MAX_VALUE);
}
if (maxValue) {
@@ -238,6 +222,16 @@
}
}
+ private <T extends Number> boolean isOfClass(Class<T> clazz, Class<?> toCheck) {
+ try {
+ return clazz.isAssignableFrom(toCheck)
+ || clazz.getField("TYPE").get(null).equals(toCheck); //$NON-NLS-1$
+ } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException ex) {
+ Activator.logException(ex);
+ return false;
+ }
+ }
+
private Object revertToOldValue(final Object value) {
if (getFirstStructuralFeature().getDefaultValue() == null && (value == null || value.equals(""))) { //$NON-NLS-1$
diff --git a/bundles/org.eclipse.emf.ecp.edit.swt/src/org/eclipse/emf/ecp/edit/internal/swt/reference/ReferenceMultiControl.java b/bundles/org.eclipse.emf.ecp.edit.swt/src/org/eclipse/emf/ecp/edit/internal/swt/reference/ReferenceMultiControl.java
index b8d493f..628b4ef 100644
--- a/bundles/org.eclipse.emf.ecp.edit.swt/src/org/eclipse/emf/ecp/edit/internal/swt/reference/ReferenceMultiControl.java
+++ b/bundles/org.eclipse.emf.ecp.edit.swt/src/org/eclipse/emf/ecp/edit/internal/swt/reference/ReferenceMultiControl.java
@@ -15,7 +15,6 @@
package org.eclipse.emf.ecp.edit.internal.swt.reference;
import org.eclipse.emf.ecore.EStructuralFeature.Setting;
-import org.eclipse.emf.ecp.edit.internal.swt.Activator;
import org.eclipse.emf.ecp.edit.internal.swt.controls.MultiControl;
import org.eclipse.emf.ecp.edit.spi.ReferenceService;
import org.eclipse.emf.ecp.edit.spi.swt.actions.ECPSWTAction;
diff --git a/bundles/org.eclipse.emf.ecp.edit.swt/src/org/eclipse/emf/ecp/edit/internal/swt/table/NumberCellEditor.java b/bundles/org.eclipse.emf.ecp.edit.swt/src/org/eclipse/emf/ecp/edit/internal/swt/table/NumberCellEditor.java
index 4880d75..dfddaf3 100644
--- a/bundles/org.eclipse.emf.ecp.edit.swt/src/org/eclipse/emf/ecp/edit/internal/swt/table/NumberCellEditor.java
+++ b/bundles/org.eclipse.emf.ecp.edit.swt/src/org/eclipse/emf/ecp/edit/internal/swt/table/NumberCellEditor.java
@@ -82,28 +82,12 @@
boolean maxValue = false;
final Class<?> instanceClass = getInstanceClass();
String formatedValue = ""; //$NON-NLS-1$
- try {
- if (Integer.class.isAssignableFrom(instanceClass)
- || Integer.class.getField("TYPE").get(null).equals(instanceClass)) { //$NON-NLS-1$
- if (Integer.MAX_VALUE == number.intValue()) {
- maxValue = true;
- formatedValue = format.format(Integer.MAX_VALUE);
- }
- } else if (Long.class.isAssignableFrom(instanceClass)
- || Long.class.getField("TYPE").get(null).equals(instanceClass)) { //$NON-NLS-1$
- if (Long.MAX_VALUE == number.longValue()) {
- maxValue = true;
- formatedValue = format.format(Long.MAX_VALUE);
- }
- }
- } catch (final IllegalArgumentException ex) {
- Activator.logException(ex);
- } catch (final SecurityException ex) {
- Activator.logException(ex);
- } catch (final IllegalAccessException ex) {
- Activator.logException(ex);
- } catch (final NoSuchFieldException ex) {
- Activator.logException(ex);
+ if (isOfClass(Integer.class, instanceClass) && Integer.MAX_VALUE == number.intValue()) {
+ maxValue = true;
+ formatedValue = format.format(Integer.MAX_VALUE);
+ } else if (isOfClass(Long.class, instanceClass) && Long.MAX_VALUE == number.longValue()) {
+ maxValue = true;
+ formatedValue = format.format(Long.MAX_VALUE);
}
if (maxValue) {
@@ -132,6 +116,16 @@
}
}
+ private <T extends Number> boolean isOfClass(Class<T> clazz, Class<?> toCheck) {
+ try {
+ return clazz.isAssignableFrom(toCheck)
+ || clazz.getField("TYPE").get(null).equals(toCheck); //$NON-NLS-1$
+ } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException ex) {
+ Activator.logException(ex);
+ return false;
+ }
+ }
+
private Object revertToOldValue(final Object value) {
if (eStructuralFeature.getDefaultValue() == null && (value == null || value.equals(""))) { //$NON-NLS-1$
diff --git a/bundles/org.eclipse.emf.ecp.ui/src/org/eclipse/emf/ecp/internal/ui/model/PropertiesLabelProvider.java b/bundles/org.eclipse.emf.ecp.ui/src/org/eclipse/emf/ecp/internal/ui/model/PropertiesLabelProvider.java
index 76b0fe4..42a8da2 100644
--- a/bundles/org.eclipse.emf.ecp.ui/src/org/eclipse/emf/ecp/internal/ui/model/PropertiesLabelProvider.java
+++ b/bundles/org.eclipse.emf.ecp.ui/src/org/eclipse/emf/ecp/internal/ui/model/PropertiesLabelProvider.java
@@ -21,15 +21,19 @@
import org.eclipse.swt.graphics.Image;
/**
+ * A {@link LabelProvider} for properties.
+ *
* @author Eike Stepper
*/
public class PropertiesLabelProvider extends LabelProvider implements ITableLabelProvider {
private static final Image PROPERTY = Activator.getImage("icons/property_obj.gif"); //$NON-NLS-1$
+ /**
+ * Default constructor.
+ */
public PropertiesLabelProvider() {
}
- /** {@inheritDoc} */
@Override
public String getColumnText(Object element, int columnIndex) {
if (element instanceof Map.Entry) {
@@ -41,19 +45,22 @@
case 1:
return entry.getValue();
+ default:
+ return null;
}
}
return null;
}
- /** {@inheritDoc} */
@Override
public Image getColumnImage(Object element, int columnIndex) {
if (element instanceof Map.Entry) {
switch (columnIndex) {
case 0:
return PROPERTY;
+ default:
+ return null;
}
}
diff --git a/bundles/org.eclipse.emf.ecp.ui/src/org/eclipse/emf/ecp/ui/common/ECPCompositeFactory.java b/bundles/org.eclipse.emf.ecp.ui/src/org/eclipse/emf/ecp/ui/common/ECPCompositeFactory.java
index b767136..5684c6d 100644
--- a/bundles/org.eclipse.emf.ecp.ui/src/org/eclipse/emf/ecp/ui/common/ECPCompositeFactory.java
+++ b/bundles/org.eclipse.emf.ecp.ui/src/org/eclipse/emf/ecp/ui/common/ECPCompositeFactory.java
@@ -70,6 +70,7 @@
}
/**
+ * Util method to create a composite which allows to ceate an ECP project.
*
* @param providers the providers to be considered to create a new project
* @return A {@link CreateProjectComposite} allowing to create a new project
@@ -78,16 +79,38 @@
return new CreateProjectCompositeImpl(providers);
}
+ /**
+ * Util method to create a composite which allows to select Classes from {@link EPackage}s with a checkbox.
+ *
+ * @param ePackages The {@link EPackage}s to select from.
+ * @return The {@link CheckedModelClassComposite}
+ */
public static CheckedModelClassComposite getCheckedModelClassComposite(Collection<EPackage> ePackages) {
return new CheckedSelectModelClassCompositeImpl(new HashSet<EPackage>(), ePackages, new HashSet<EClass>());
}
+ /**
+ * Util method to create a composite which allows to select an {@link EClass} based on all known {@link EPackage}s
+ * in the registry by applying the provided filters.
+ *
+ * @param unsupportedEPackages The {@link EPackage}s that should not be available (blacklist)
+ * @param filteredEPackages The {@link EPackage}s that should be available (whitelist)
+ * @param filteredEClasses The {@link EClass}es that should be available (whitelist)
+ * @return The {@link SelectionComposite} based on a {@link TreeViewer}
+ */
public static SelectionComposite<TreeViewer> getSelectModelClassComposite(
Collection<EPackage> unsupportedEPackages, Collection<EPackage> filteredEPackages,
Collection<EClass> filteredEClasses) {
return new SelectModelClassCompositeImpl(unsupportedEPackages, filteredEPackages, filteredEClasses);
}
+ /**
+ * Util method to create a composite which allows to select an {@link EClass} based on all known {@link EPackage}s
+ * in the registry by applying the filters in the provided project.
+ *
+ * @param project The {@link ECPProject} to use as a filter
+ * @return The {@link SelectionComposite} based on a {@link TreeViewer}
+ */
public static SelectionComposite<TreeViewer> getSelectModelClassComposite(ECPProject project) {
return new ECPProjectSelectionModelClassCompositeImpl(project);
}
diff --git a/bundles/org.eclipse.emf.ecp.ui/src/org/eclipse/emf/ecp/ui/common/ECPViewerFactory.java b/bundles/org.eclipse.emf.ecp.ui/src/org/eclipse/emf/ecp/ui/common/ECPViewerFactory.java
index b2629fc..b6b3266 100644
--- a/bundles/org.eclipse.emf.ecp.ui/src/org/eclipse/emf/ecp/ui/common/ECPViewerFactory.java
+++ b/bundles/org.eclipse.emf.ecp.ui/src/org/eclipse/emf/ecp/ui/common/ECPViewerFactory.java
@@ -44,11 +44,24 @@
import org.eclipse.swt.widgets.Composite;
/**
- * @author Eugen
+ * Utility class to create components for ECP.
+ *
+ * @author Eugen Neufeld
*
*/
-public class ECPViewerFactory {
+public final class ECPViewerFactory {
+ private ECPViewerFactory() {
+ }
+
+ /**
+ * Create the ECP ModelExplorer View which is based on the {@link TreeViewer}.
+ *
+ * @param parent The {@link Composite} to create onto
+ * @param hasDnD Whether dnd should be enabled
+ * @param labelDecorator The {@link ILabelDecorator} to use on labels.
+ * @return The created {@link TreeViewer}
+ */
public static TreeViewer createModelExplorerViewer(Composite parent, boolean hasDnD,
ILabelDecorator labelDecorator) {
final ModelContentProvider contentProvider = new ModelContentProvider();
@@ -90,20 +103,15 @@
return viewer;
}
- /**
- * @param contentProvider
- * @param viewer
- * @return
- */
private static ECPDropAdapter getDropAdapter(ModelContentProvider contentProvider, TreeViewer viewer) {
ECPDropAdapter dropAdapter = null;
// read extensionpoint, if no defined take default
final IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(
- "org.eclipse.emf.ecp.ui.dropAdapter");
+ "org.eclipse.emf.ecp.ui.dropAdapter"); //$NON-NLS-1$
for (final IExtension extension : extensionPoint.getExtensions()) {
final IConfigurationElement configurationElement = extension.getConfigurationElements()[0];
try {
- dropAdapter = (ECPDropAdapter) configurationElement.createExecutableExtension("class");
+ dropAdapter = (ECPDropAdapter) configurationElement.createExecutableExtension("class"); //$NON-NLS-1$
dropAdapter.setViewer(viewer);
break;
} catch (final CoreException ex) {
@@ -116,20 +124,15 @@
return dropAdapter;
}
- /**
- * @param contentProvider
- * @param viewer
- * @return
- */
private static ILabelProvider getLabelProvider(ModelContentProvider contentProvider) {
IECPLabelProvider labelProvider = null;
// read extensionpoint, if no defined take default
final IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(
- "org.eclipse.emf.ecp.ui.labelProvider");
+ "org.eclipse.emf.ecp.ui.labelProvider"); //$NON-NLS-1$
for (final IExtension extension : extensionPoint.getExtensions()) {
final IConfigurationElement configurationElement = extension.getConfigurationElements()[0];
try {
- labelProvider = (IECPLabelProvider) configurationElement.createExecutableExtension("class");
+ labelProvider = (IECPLabelProvider) configurationElement.createExecutableExtension("class"); //$NON-NLS-1$
labelProvider.setModelContextProvider(contentProvider);
return labelProvider;
} catch (final CoreException ex) {
@@ -141,6 +144,13 @@
return labelProvider;
}
+ /**
+ * Create the ECP RepositoryExplorer View which is based on the {@link TreeViewer}.
+ *
+ * @param parent The {@link Composite} to create onto
+ * @param labelDecorator The {@link ILabelDecorator} to use on labels
+ * @return The create {@link TreeViewer}
+ */
public static TreeViewer createRepositoryExplorerViewer(Composite parent, ILabelDecorator labelDecorator) {
final RepositoriesContentProvider contentProvider = new RepositoriesContentProvider();
final TreeViewer viewer = TreeViewerFactory.createTreeViewer(parent, new RepositoriesLabelProvider(
diff --git a/bundles/org.eclipse.emfforms.common.validation/src/org/eclipse/emfforms/common/internal/validation/ValidationServiceImpl.java b/bundles/org.eclipse.emfforms.common.validation/src/org/eclipse/emfforms/common/internal/validation/ValidationServiceImpl.java
index 1ca57e2..31ffeed 100644
--- a/bundles/org.eclipse.emfforms.common.validation/src/org/eclipse/emfforms/common/internal/validation/ValidationServiceImpl.java
+++ b/bundles/org.eclipse.emfforms.common.validation/src/org/eclipse/emfforms/common/internal/validation/ValidationServiceImpl.java
@@ -283,6 +283,7 @@
validators.remove(validator);
}
+ @Deprecated
@Override
public void registerValidationFilter(ValidationFilter filter) {
if (filter instanceof ObjectFilter) {
@@ -296,6 +297,7 @@
}
}
+ @Deprecated
@Override
public void unregisterValidationFilter(ValidationFilter filter) {
getObjectFilters().remove(filter);
diff --git a/bundles/org.eclipse.emfforms.ide.builder/src/org/eclipse/emfforms/ide/internal/builder/ViewModelValidationDelegate.java b/bundles/org.eclipse.emfforms.ide.builder/src/org/eclipse/emfforms/ide/internal/builder/ViewModelValidationDelegate.java
index 6172c51..5ce72e3 100644
--- a/bundles/org.eclipse.emfforms.ide.builder/src/org/eclipse/emfforms/ide/internal/builder/ViewModelValidationDelegate.java
+++ b/bundles/org.eclipse.emfforms.ide.builder/src/org/eclipse/emfforms/ide/internal/builder/ViewModelValidationDelegate.java
@@ -20,7 +20,6 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
@@ -32,12 +31,9 @@
import org.eclipse.emf.ecp.view.spi.model.VView;
import org.eclipse.emf.ecp.view.spi.model.VViewModelProperties;
import org.eclipse.emf.ecp.view.spi.model.util.ViewModelPropertiesHelper;
-import org.eclipse.emf.ecp.view.spi.model.util.ViewValidator;
import org.eclipse.emfforms.bazaar.Bid;
import org.eclipse.emfforms.bazaar.Create;
-import org.eclipse.emfforms.common.Optional;
import org.eclipse.emfforms.common.spi.validation.ValidationService;
-import org.eclipse.emfforms.common.spi.validation.filter.AbstractComplexFilter;
import org.eclipse.emfforms.ide.builder.ValidationDelegate;
import org.eclipse.emfforms.ide.builder.ValidationDelegateProvider;
import org.eclipse.emfforms.ide.builder.ValidationServiceDelegate;
@@ -97,23 +93,11 @@
final VViewModelProperties properties = ViewModelPropertiesHelper.getInhertitedPropertiesOrEmpty(view);
view.setLoadingProperties(properties);
- validationService.registerValidationFilter(new ViewValidatorDuplicateFilter());
+ validationService.addObjectFilter(this::skipValidation);
}
- /**
- * Filter to avoid duplications in validation from {@link ViewValidator}.
- */
- private class ViewValidatorDuplicateFilter extends AbstractComplexFilter {
- @Override
- public boolean skipSubtree(EObject eObject, Optional<Diagnostic> diagnostic) {
- return false;
- }
-
- @Override
- public boolean skipValidation(EObject eObject) {
- return VDomainModelReference.class.isInstance(eObject);
- }
-
+ private boolean skipValidation(EObject eObject) {
+ return VDomainModelReference.class.isInstance(eObject);
}
//