Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-09-12 23:40:43 +0000
committerChristian W. Damus2014-09-12 23:44:07 +0000
commit6ace73dd3a914645d70f9746856018ae5bd028ed (patch)
tree995cddbb82c0cd0ae2c18c8be535623b8a150ca7
parent0105aa574623555296950a32d08a489172c163b5 (diff)
downloadorg.eclipse.papyrus-6ace73dd3a914645d70f9746856018ae5bd028ed.tar.gz
org.eclipse.papyrus-6ace73dd3a914645d70f9746856018ae5bd028ed.tar.xz
org.eclipse.papyrus-6ace73dd3a914645d70f9746856018ae5bd028ed.zip
443830: [CDO] FindBugs Problems in UI
https://bugs.eclipse.org/bugs/show_bug.cgi?id=443830 Address potential and actual bugs reported by FindBugs.
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui.customization.properties/src/org/eclipse/papyrus/cdo/internal/ui/customization/properties/storage/CDOContextStorageProvider.java6
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui.customization.properties/src/org/eclipse/papyrus/cdo/internal/ui/customization/properties/storage/action/CDOContextStorageActionProvider.java6
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/ItemProviderFilterRegistry.java10
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/ModelReferencesPage.java9
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/META-INF/MANIFEST.MF1
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/build.properties3
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/plugin.xml13
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/src/org/eclipse/papyrus/cdo/internal/ui/views/tests/ItemProviderFilterRegistryTest.java65
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/src/org/eclipse/papyrus/cdo/ui/tests/AllTests.java8
9 files changed, 106 insertions, 15 deletions
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.customization.properties/src/org/eclipse/papyrus/cdo/internal/ui/customization/properties/storage/CDOContextStorageProvider.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.customization.properties/src/org/eclipse/papyrus/cdo/internal/ui/customization/properties/storage/CDOContextStorageProvider.java
index d8b6b841acc..5028bcb67c7 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.customization.properties/src/org/eclipse/papyrus/cdo/internal/ui/customization/properties/storage/CDOContextStorageProvider.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.customization.properties/src/org/eclipse/papyrus/cdo/internal/ui/customization/properties/storage/CDOContextStorageProvider.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 443830
+ *
*****************************************************************************/
package org.eclipse.papyrus.cdo.internal.ui.customization.properties.storage;
@@ -96,7 +98,7 @@ public class CDOContextStorageProvider extends AbstractContextStorageProvider {
@Override
public boolean providesFor(Context context) {
URI uri = EcoreUtil.getURI(context);
- return (uri != null) && CDOUtils.isCDOURI(uri) || CDOTextURIHandler.SCHEME.equals(uri.scheme());
+ return (uri != null) && (CDOUtils.isCDOURI(uri) || CDOTextURIHandler.SCHEME.equals(uri.scheme()));
}
@Override
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.customization.properties/src/org/eclipse/papyrus/cdo/internal/ui/customization/properties/storage/action/CDOContextStorageActionProvider.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.customization.properties/src/org/eclipse/papyrus/cdo/internal/ui/customization/properties/storage/action/CDOContextStorageActionProvider.java
index af2e7ccf2f1..d332414952d 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.customization.properties/src/org/eclipse/papyrus/cdo/internal/ui/customization/properties/storage/action/CDOContextStorageActionProvider.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.customization.properties/src/org/eclipse/papyrus/cdo/internal/ui/customization/properties/storage/action/CDOContextStorageActionProvider.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 443830
+ *
*****************************************************************************/
package org.eclipse.papyrus.cdo.internal.ui.customization.properties.storage.action;
@@ -34,7 +36,7 @@ public class CDOContextStorageActionProvider extends AbstractContextStorageActio
@Override
public boolean providesFor(Context context) {
URI uri = EcoreUtil.getURI(context);
- return (uri != null) && CDOUtils.isCDOURI(uri) || CDOTextURIHandler.SCHEME.equals(uri.scheme());
+ return (uri != null) && (CDOUtils.isCDOURI(uri) || CDOTextURIHandler.SCHEME.equals(uri.scheme()));
}
@Override
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/ItemProviderFilterRegistry.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/ItemProviderFilterRegistry.java
index 83434f3b438..5f346962147 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/ItemProviderFilterRegistry.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/ItemProviderFilterRegistry.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2014 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 443830
+ *
*****************************************************************************/
package org.eclipse.papyrus.cdo.internal.ui.views;
@@ -153,7 +155,7 @@ class ItemProviderFilterRegistry {
private final Supplier<? extends IElementFilter> filter;
- private boolean enabled;
+ private boolean enabled = true;
ElementFilterFilter(String id, Supplier<? extends IElementFilter> filter) {
super(id);
@@ -177,7 +179,7 @@ class ItemProviderFilterRegistry {
private final Supplier<? extends Predicate<Object>> predicate;
- private boolean enabled;
+ private boolean enabled = true;
PredicateFilter(String id, Supplier<? extends Predicate<Object>> predicate) {
super(id);
@@ -283,7 +285,7 @@ class ItemProviderFilterRegistry {
result = createLabelPatternFilter(config);
} else if (E_ELEMENT_FILTER.equals(name)) {
result = createElementFilterFilter(config);
- } else if (E_PREDICATE.equals(config)) {
+ } else if (E_PREDICATE.equals(name)) {
result = createPredicateFilter(config);
}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/ModelReferencesPage.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/ModelReferencesPage.java
index 88902c160ee..513da34d912 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/ModelReferencesPage.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/ModelReferencesPage.java
@@ -9,6 +9,7 @@
* Contributors:
* CEA LIST - Initial API and implementation
* Christian W. Damus (CEA) - bug 429242
+ * Christian W. Damus (CEA) - bug 433830
*
*****************************************************************************/
package org.eclipse.papyrus.cdo.internal.ui.wizards;
@@ -305,16 +306,16 @@ public class ModelReferencesPage extends ModelImportWizardPage {
Object[] result = elements;
if ((inputElement != config) || (result == null)) {
- IModelTransferConfiguration config = (IModelTransferConfiguration) inputElement;
- List<TreeNode> nodes = Lists.newArrayListWithCapacity(config.getModelsToTransfer().size());
+ IModelTransferConfiguration inputConfig = (IModelTransferConfiguration) inputElement;
+ List<TreeNode> nodes = Lists.newArrayListWithCapacity(inputConfig.getModelsToTransfer().size());
- for (IModelTransferNode next : config.getModelsToTransfer()) {
+ for (IModelTransferNode next : inputConfig.getModelsToTransfer()) {
nodes.add(new TreeNode(next));
}
result = nodes.toArray();
- if (inputElement == config) {
+ if (inputConfig == config) {
// cache the result
elements = result;
}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/META-INF/MANIFEST.MF b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/META-INF/MANIFEST.MF
index 40a490d8de6..040dd46f587 100644
--- a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/META-INF/MANIFEST.MF
@@ -22,6 +22,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.papyrus.junit.framework;bundle-version="1.0.1"
Export-Package: org.eclipse.papyrus.cdo.internal.ui.editors.tests;x-internal:=true,
org.eclipse.papyrus.cdo.internal.ui.markers.tests;x-internal:=true,
+ org.eclipse.papyrus.cdo.internal.ui.views.tests;x-internal:=true,
org.eclipse.papyrus.cdo.ui.tests
Bundle-Vendor: %providerName
Bundle-Version: 1.0.1.qualifier
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/build.properties b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/build.properties
index 9de44fbc9f5..5371490a2c7 100644
--- a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/build.properties
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/build.properties
@@ -4,5 +4,6 @@ bin.includes = META-INF/,\
.,\
plugin.properties,\
about.html,\
- resources/
+ resources/,\
+ plugin.xml
src.includes = about.html
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/plugin.xml b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/plugin.xml
new file mode 100644
index 00000000000..118a250b55d
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/plugin.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.cdo.ui.repositoryFilters">
+ <itemProviderFilter
+ id="org.eclipse.papyrus.cdo.ui.tests.itemProviderFilter1">
+ <predicate
+ class="org.eclipse.papyrus.cdo.internal.ui.views.tests.ItemProviderFilterRegistryTest$TestFilter"/>
+ </itemProviderFilter>
+ </extension>
+
+</plugin>
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/src/org/eclipse/papyrus/cdo/internal/ui/views/tests/ItemProviderFilterRegistryTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/src/org/eclipse/papyrus/cdo/internal/ui/views/tests/ItemProviderFilterRegistryTest.java
new file mode 100644
index 00000000000..f32f763186c
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/src/org/eclipse/papyrus/cdo/internal/ui/views/tests/ItemProviderFilterRegistryTest.java
@@ -0,0 +1,65 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST and others.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.cdo.internal.ui.views.tests;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.util.Arrays;
+import java.util.Collections;
+
+import org.eclipse.papyrus.cdo.core.tests.AbstractPapyrusCDOTest;
+import org.eclipse.papyrus.cdo.internal.core.PapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.ui.views.ModelRepositoryItemProvider;
+import org.junit.After;
+import org.junit.Test;
+
+import com.google.common.base.Predicate;
+
+/**
+ * Tests the {@code ItemProviderFilterRegistry} class.
+ */
+public class ItemProviderFilterRegistryTest extends AbstractPapyrusCDOTest {
+
+ public ItemProviderFilterRegistryTest() {
+ super();
+ }
+
+ @Test
+ public void testPredicateFilter() {
+ TestFilter.banned = getPapyrusRepository();
+ ModelRepositoryItemProvider itemProvider = new ModelRepositoryItemProvider(null);
+ itemProvider.inputChanged(null, null, PapyrusRepositoryManager.INSTANCE);
+
+ assertThat(Arrays.asList(itemProvider.getChildren(PapyrusRepositoryManager.INSTANCE)), is(Collections.EMPTY_LIST));
+ }
+
+ //
+ // Test framework
+ //
+
+ @After
+ public void tearDown() {
+ TestFilter.banned = null;
+ }
+
+ public static final class TestFilter implements Predicate<Object> {
+ static Object banned;
+
+ @Override
+ public boolean apply(Object input) {
+ return (banned != null) && (input == banned);
+ }
+ }
+}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/src/org/eclipse/papyrus/cdo/ui/tests/AllTests.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/src/org/eclipse/papyrus/cdo/ui/tests/AllTests.java
index 4c02a05d91b..ce83603aa4a 100644
--- a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/src/org/eclipse/papyrus/cdo/ui/tests/AllTests.java
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.tests/src/org/eclipse/papyrus/cdo/ui/tests/AllTests.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 443830
+ *
*****************************************************************************/
package org.eclipse.papyrus.cdo.ui.tests;
@@ -15,6 +17,7 @@ import org.eclipse.papyrus.cdo.internal.ui.editors.tests.BasicEditorTest;
import org.eclipse.papyrus.cdo.internal.ui.editors.tests.DawnEditorAdapterTest;
import org.eclipse.papyrus.cdo.internal.ui.markers.tests.CDOPapyrusMarkerTest;
import org.eclipse.papyrus.cdo.internal.ui.markers.tests.ModelValidationMarkersTest;
+import org.eclipse.papyrus.cdo.internal.ui.views.tests.ItemProviderFilterRegistryTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@@ -24,7 +27,8 @@ import org.junit.runners.Suite.SuiteClasses;
*/
@RunWith(Suite.class)
@SuiteClasses({ BasicEditorTest.class, DawnEditorAdapterTest.class, //
-ModelValidationMarkersTest.class, CDOPapyrusMarkerTest.class })
+ ModelValidationMarkersTest.class, CDOPapyrusMarkerTest.class, //
+ ItemProviderFilterRegistryTest.class })
public class AllTests {
public AllTests() {

Back to the top