Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-02-19 16:45:27 +0000
committerUwe Stieber2012-02-19 16:45:27 +0000
commitb953bce70507af630a13163d6b82868f9b5e7711 (patch)
treede7baf9edefb6b9d3ae816ce9cb22506bea5e4cf /target_explorer/plugins/org.eclipse.tcf.te.runtime.model
parent71bd059af3fb739c3a2ba6859e5b6a94243ec905 (diff)
downloadorg.eclipse.tcf-b953bce70507af630a13163d6b82868f9b5e7711.tar.gz
org.eclipse.tcf-b953bce70507af630a13163d6b82868f9b5e7711.tar.xz
org.eclipse.tcf-b953bce70507af630a13163d6b82868f9b5e7711.zip
Target Explorer: Continued launch context selector work
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.runtime.model')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/factory/AbstractFactoryDelegate2.java20
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/factory/Factory.java25
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/interfaces/factory/IFactory.java16
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/interfaces/factory/IFactoryDelegate2.java37
4 files changed, 90 insertions, 8 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/factory/AbstractFactoryDelegate2.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/factory/AbstractFactoryDelegate2.java
new file mode 100644
index 000000000..410afb33f
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/factory/AbstractFactoryDelegate2.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.runtime.model.factory;
+
+import org.eclipse.tcf.te.runtime.model.interfaces.factory.IFactoryDelegate2;
+
+
+/**
+ * Abstract model node factory delegate implementing {@link IFactoryDelegate2}.
+ */
+public abstract class AbstractFactoryDelegate2 extends AbstractFactoryDelegate implements IFactoryDelegate2 {
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/factory/Factory.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/factory/Factory.java
index b4c47aad7..926b9129a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/factory/Factory.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/factory/Factory.java
@@ -14,6 +14,7 @@ import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
import org.eclipse.tcf.te.runtime.model.interfaces.factory.IFactory;
import org.eclipse.tcf.te.runtime.model.interfaces.factory.IFactoryDelegate;
+import org.eclipse.tcf.te.runtime.model.interfaces.factory.IFactoryDelegate2;
import org.eclipse.tcf.te.runtime.model.internal.factory.FactoryDelegateManager;
/**
@@ -43,13 +44,8 @@ public final class Factory extends PlatformObject implements IFactory {
super();
}
- /**
- * Creates an new instance of the model node object implementing
- * the specified node interface.
- *
- * @param nodeInterface The node interface to be implemented by the model node object to create.
- * Must not be <code>null</code>.
- * @return The model not object implementing the specified node interface or <code>null</code>.
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.model.interfaces.factory.IFactory#newInstance(java.lang.Class)
*/
@Override
public <V extends IModelNode> V newInstance(Class<V> nodeInterface) {
@@ -58,6 +54,19 @@ public final class Factory extends PlatformObject implements IFactory {
// Determine the model node factory delegate to use
IFactoryDelegate delegate = manager.getFactoryDelegate(nodeInterface);
// Return the model node instance
- return delegate != null ? (V)delegate.newInstance(nodeInterface) : null;
+ return delegate != null ? (V) delegate.newInstance(nodeInterface) : null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.model.interfaces.factory.IFactory#newInstance(java.lang.Class, java.lang.Object[])
+ */
+ @Override
+ public <V extends IModelNode> V newInstance(Class<V> nodeInterface, Object[] args) {
+ Assert.isNotNull(nodeInterface);
+
+ // Determine the model node factory delegate to use
+ IFactoryDelegate delegate = manager.getFactoryDelegate(nodeInterface);
+ // Return the model node instance
+ return delegate instanceof IFactoryDelegate2 ? (V) ((IFactoryDelegate2)delegate).newInstance(nodeInterface, args) : null;
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/interfaces/factory/IFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/interfaces/factory/IFactory.java
index 0c1b5b407..176023481 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/interfaces/factory/IFactory.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/interfaces/factory/IFactory.java
@@ -25,4 +25,20 @@ public interface IFactory extends IAdaptable {
* @return The node object implementing the specified node interface or <code>null</code>.
*/
public <V extends IModelNode> V newInstance(Class<V> nodeInterface);
+
+ /**
+ * Creates an new instance of an node object implementing the specified node interface.
+ * <p>
+ * <b>Note:</b> Factory delegates must implement {@link IFactoryDelegate2} to be invoked by
+ * this method.
+ *
+ * @param nodeInterface The node interface to be implemented by the node object to be created.
+ * Must not be <code>null</code>.
+ * @param args The arguments to be passed to a matching constructor, or <code>null</code>.
+ *
+ * @return The node object implementing the specified node interface or <code>null</code>.
+ *
+ * @see IFactoryDelegate2#newInstance(Class, Object[])
+ */
+ public <V extends IModelNode> V newInstance(Class<V> nodeInterface, Object[] args);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/interfaces/factory/IFactoryDelegate2.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/interfaces/factory/IFactoryDelegate2.java
new file mode 100644
index 000000000..6b3f6cc72
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/interfaces/factory/IFactoryDelegate2.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.runtime.model.interfaces.factory;
+
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+
+/**
+ * Interface to be implemented by model node factory delegates.
+ */
+public interface IFactoryDelegate2 extends IFactoryDelegate {
+
+ /**
+ * Returns a new instance of an node object implementing the given node interface.
+ * <p>
+ * If <code>args</code> is <code>null</code>, the node object returned by this method
+ * should be the same as by calling {@link #newInstance(Class)}.
+ * <p>
+ * If <code>args</code> is not <code>null</code>, the method is matching the argument
+ * types with the argument types of the node object constructor(s) and call the matched
+ * constructor. If no constructor is matching the argument types, the method does return
+ * <code>null</code>.
+ *
+ * @param nodeInterface The node interface to be implemented by the node object to be created.
+ * Must not be <code>null</code>.
+ * @param args The arguments to be passed to a matching constructor, or <code>null</code>.
+ *
+ * @return The node object implementing the specified node interface or <code>null</code>.
+ */
+ public <V extends IModelNode> V newInstance(Class<V> nodeInterface, Object[] args);
+}

Back to the top