Author: rozagh
Date: 2012-03-12 13:04:55 -0700 (Mon, 12 Mar 2012)
New Revision: 28498
Removed:
core3/api/trunk/work-api/src/main/java/org/cytoscape/work/ProvidesGUI.java
core3/api/trunk/work-api/src/test/java/org/cytoscape/work/ProvidesGUIExample.java
Modified:
core3/api/trunk/work-api/src/main/java/org/cytoscape/work/AbstractTunableInterceptor.java
core3/api/trunk/work-api/src/test/java/org/cytoscape/work/AbstractTunableInterceptorTest.java
core3/support/trunk/task-testing-impl/src/main/java/org/cytoscape/internal/test/MultiTunableAction.java
core3/support/trunk/task-testing-impl/src/main/java/org/cytoscape/internal/test/tunables/TunablesTestTask.java
Log:
fixes #689 removed ProvidesGUI and all of the references to it.
Modified:
core3/api/trunk/work-api/src/main/java/org/cytoscape/work/AbstractTunableInterceptor.java
===================================================================
---
core3/api/trunk/work-api/src/main/java/org/cytoscape/work/AbstractTunableInterceptor.java
2012-03-12 20:00:35 UTC (rev 28497)
+++
core3/api/trunk/work-api/src/main/java/org/cytoscape/work/AbstractTunableInterceptor.java
2012-03-12 20:04:55 UTC (rev 28498)
@@ -130,37 +130,21 @@
// See if the method is annotated as a Tunable.
if (method.isAnnotationPresent(Tunable.class)) {
try {
-
final Tunable tunable =
method.getAnnotation(Tunable.class);
final String rootName =
validateAndExtractRootName(method);
final Method setter =
findCompatibleSetter(obj, rootName, method.getReturnType());
-
+
// Get a handler with for get
and set methods:
final T handler =
getHandler(method, setter, obj, tunable);
-
if (handler == null) {
logOrThrowException("Failed to create a handler for " + setter.getName() +
"()!",null);
} else {
handlerList.put("getset" + rootName, handler);
}
-
} catch (Throwable t) {
logOrThrowException("tunable
method intercept failed for " + method.toString(), t);
}
-
- // See if the method is annotated as providing
a GUI...
- } else if
(method.isAnnotationPresent(ProvidesGUI.class)) {
- if
(!isJPanelOrJPanelDescendent(method.getReturnType())) {
- throw new
IllegalArgumentException(method.getName() + " annotated with @ProvidesGUI must
return JPanel!");
- } else if
(method.getParameterTypes().length != 0) {
- throw new
IllegalArgumentException(method.getName() + " annotated with @ProvidesGUI must
take 0 arguments!");
- } else {
- if (!guiProviderMap.isEmpty())
- throw new
IllegalArgumentException("Classes must have at most a single @ProvidesGUI
annotated method but + "
- +
method.getDeclaringClass().getName() + " has more than one!");
- guiProviderMap.put(obj, method);
- }
- } else if
(method.isAnnotationPresent(ProvidesTitle.class)) {
+ }else if
(method.isAnnotationPresent(ProvidesTitle.class)) {
if
(!String.class.isAssignableFrom(method.getReturnType())) {
throw new
IllegalArgumentException(method.getName() + " annotated with @ProvidesTitle
must return String!");
} else if
(method.getParameterTypes().length != 0) {
@@ -178,7 +162,8 @@
handlerMap.put(obj, handlerList);
}
}
-
+
+
private boolean isJPanelOrJPanelDescendent(final Class c) {
Class c0 = c;
while (c0 != null && c0 != Object.class) {
@@ -253,7 +238,7 @@
return true;
}
for (final Method method : o.getClass().getMethods()) {
- if (method.isAnnotationPresent(Tunable.class) ||
method.isAnnotationPresent(ProvidesGUI.class))
+ if (method.isAnnotationPresent(Tunable.class))
return true;
}
Deleted:
core3/api/trunk/work-api/src/main/java/org/cytoscape/work/ProvidesGUI.java
===================================================================
--- core3/api/trunk/work-api/src/main/java/org/cytoscape/work/ProvidesGUI.java
2012-03-12 20:00:35 UTC (rev 28497)
+++ core3/api/trunk/work-api/src/main/java/org/cytoscape/work/ProvidesGUI.java
2012-03-12 20:04:55 UTC (rev 28498)
@@ -1,29 +0,0 @@
-package org.cytoscape.work;
-
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-
-/**
- * An annotation type that can be applied to a <i>method</i> in order to
- * allow a <code>TunableInterceptor</code>
- * to catch it, and so to use its members to create a corresponding interface
- * for a user.
- *
- * Here is an example of how to use a <code>ProvidesGUI</code> annotation:
- *
- * <pre>
- * @ProvidesGUI
- * public JPanel getGUI() { return mySetupPanel; }
- * </pre>
- *
- * Please note that the method annotated with this needs to return a JPanel
and take no arguments.
- * @CyAPI.Api.Interface
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD})
-public @interface ProvidesGUI {
-}
Modified:
core3/api/trunk/work-api/src/test/java/org/cytoscape/work/AbstractTunableInterceptorTest.java
===================================================================
---
core3/api/trunk/work-api/src/test/java/org/cytoscape/work/AbstractTunableInterceptorTest.java
2012-03-12 20:00:35 UTC (rev 28497)
+++
core3/api/trunk/work-api/src/test/java/org/cytoscape/work/AbstractTunableInterceptorTest.java
2012-03-12 20:04:55 UTC (rev 28498)
@@ -45,7 +45,6 @@
private AbstractTunableInterceptor interceptor;
private HasAnnotatedField hasAnnotatedField;
private HasAnnotatedSetterAndGetterMethods
hasAnnotatedSetterAndGetterMethods;
- private ProvidesGUIExample providesGUI;
@Before
public void init() {
@@ -54,7 +53,6 @@
interceptor.addTunableHandlerFactory( new
BasicTunableHandlerFactory(FakeTunableHandler.class,int.class,Integer.class),null);
hasAnnotatedField = new HasAnnotatedField();
hasAnnotatedSetterAndGetterMethods = new
HasAnnotatedSetterAndGetterMethods();
- providesGUI = new ProvidesGUIExample();
}
@@ -62,14 +60,12 @@
public final void testLoadTunables() {
interceptor.loadTunables(hasAnnotatedField);
interceptor.loadTunables(hasAnnotatedSetterAndGetterMethods);
- interceptor.loadTunables(providesGUI);
}
@Test
public final void testHasTunables() {
assertTrue("Should have found tunables!",
interceptor.hasTunables(hasAnnotatedField));
assertTrue("Should have found tunables!",
interceptor.hasTunables(hasAnnotatedSetterAndGetterMethods));
- assertTrue("Should have found tunables!",
interceptor.hasTunables(providesGUI));
}
@Test(expected=IllegalArgumentException.class)
@@ -97,27 +93,8 @@
interceptor.loadTunables(new HasInvalidAnotatedType());
}
- @Test(expected=IllegalArgumentException.class)
- public final void testInvalidProvidesGUIReturnType() {
- interceptor.loadTunables(new HasInvalidProvidesGUIMethod());
- }
@Test(expected=IllegalArgumentException.class)
- public final void testInvalidProvidesGUIReturnType2() {
- interceptor.loadTunables(new HasInvalidProvidesGUIMethod2());
- }
-
- @Test(expected=IllegalArgumentException.class)
- public final void testInvalidProvidesGUIMethodWithArg() {
- interceptor.loadTunables(new
HasInvalidProvidesGUIMethodWithArg());
- }
-
- @Test(expected=IllegalArgumentException.class)
- public final void testInvalidMultipleProvidesGUIMethods() {
- interceptor.loadTunables(new Has2ProvidesGUIMethods());
- }
-
- @Test(expected=IllegalArgumentException.class)
public final void testSetterAnnotatedInsteadOfGetter() {
interceptor.loadTunables(new SetterAnnotatedInsteadOfGetter());
}
@@ -207,31 +184,7 @@
}
-class HasInvalidProvidesGUIMethod {
- @ProvidesGUI
- public void badReturnType() { }
-}
-class HasInvalidProvidesGUIMethod2 {
- @ProvidesGUI
- public Double badReturnType() { return null; }
-}
-
-
-class HasInvalidProvidesGUIMethodWithArg {
- @ProvidesGUI
- public JPanel bad(int i) { return null; }
-}
-
-
-class Has2ProvidesGUIMethods {
- @ProvidesGUI
- public JPanel providesGUI1() { return null; }
-
- @ProvidesGUI
- public JPanel providesGUI2() { return null; }
-}
-
class BaseFieldClass {
@Tunable
public int value;
Deleted:
core3/api/trunk/work-api/src/test/java/org/cytoscape/work/ProvidesGUIExample.java
===================================================================
---
core3/api/trunk/work-api/src/test/java/org/cytoscape/work/ProvidesGUIExample.java
2012-03-12 20:00:35 UTC (rev 28497)
+++
core3/api/trunk/work-api/src/test/java/org/cytoscape/work/ProvidesGUIExample.java
2012-03-12 20:04:55 UTC (rev 28498)
@@ -1,37 +0,0 @@
-/*
- Copyright (c) 2010, The Cytoscape Consortium (www.cytoscape.org)
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications. In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage. See
- the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
-package org.cytoscape.work;
-
-
-import javax.swing.JPanel;
-
-
-class ProvidesGUIExample {
- @ProvidesGUI
- public JPanel getGUI() { return new JPanel(); }
-}
Modified:
core3/support/trunk/task-testing-impl/src/main/java/org/cytoscape/internal/test/MultiTunableAction.java
===================================================================
---
core3/support/trunk/task-testing-impl/src/main/java/org/cytoscape/internal/test/MultiTunableAction.java
2012-03-12 20:00:35 UTC (rev 28497)
+++
core3/support/trunk/task-testing-impl/src/main/java/org/cytoscape/internal/test/MultiTunableAction.java
2012-03-12 20:04:55 UTC (rev 28498)
@@ -79,16 +79,11 @@
public class DummyTask2 extends AbstractTask {
- @ProvidesGUI
- public JPanel getGUI() {
- JPanel jpanel = new JPanel();
- jpanel.add( new JLabel("hello"));
- return jpanel;
- }
-
+ @Tunable(description="int value2")
+ public int value;
public void run(TaskMonitor taskMonitor) throws Exception {
Thread.sleep(1000);
- System.out.println("dummy 2 executed ");
+ System.out.println("dummy 2 got value: " + value);
Thread.sleep(1000);
}
}
Modified:
core3/support/trunk/task-testing-impl/src/main/java/org/cytoscape/internal/test/tunables/TunablesTestTask.java
===================================================================
---
core3/support/trunk/task-testing-impl/src/main/java/org/cytoscape/internal/test/tunables/TunablesTestTask.java
2012-03-12 20:00:35 UTC (rev 28497)
+++
core3/support/trunk/task-testing-impl/src/main/java/org/cytoscape/internal/test/tunables/TunablesTestTask.java
2012-03-12 20:04:55 UTC (rev 28498)
@@ -40,7 +40,6 @@
import org.cytoscape.work.Task;
import org.cytoscape.work.TaskMonitor;
import org.cytoscape.work.Tunable;
-import org.cytoscape.work.ProvidesGUI;
import org.cytoscape.work.TunableValidator;
import org.cytoscape.work.TunableValidator.ValidationState;
import org.cytoscape.work.util.BoundedDouble;
@@ -142,10 +141,4 @@
}
}
-// @ProvidesGUI
- public JPanel getGUI() {
- final JPanel panel = new JPanel();
- panel.add(new JLabel("Panel from an @ProvidesGUI-annotated
class!"));
- return panel;
- }
}
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.