Author: vyemialyanchyk
Date: 2008-01-18 09:16:08 -0500 (Fri, 18 Jan 2008)
New Revision: 5804
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/model/
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/model/IParentEl.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/model/IParentElImpl.java
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/META-INF/MANIFEST.MF
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/KnownConfigurations.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-1422
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/META-INF/MANIFEST.MF
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/META-INF/MANIFEST.MF 2008-01-18
14:10:35 UTC (rev 5803)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/META-INF/MANIFEST.MF 2008-01-18
14:16:08 UTC (rev 5804)
@@ -278,6 +278,7 @@
org.hibernate.connection,
org.hibernate.console,
org.hibernate.console.execution,
+ org.hibernate.console.model,
org.hibernate.console.node,
org.hibernate.console.preferences,
org.hibernate.context,
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2008-01-18
14:10:35 UTC (rev 5803)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2008-01-18
14:16:08 UTC (rev 5804)
@@ -55,6 +55,7 @@
import org.hibernate.console.execution.ExecutionContext;
import org.hibernate.console.execution.ExecutionContextHolder;
import org.hibernate.console.execution.ExecutionContext.Command;
+import org.hibernate.console.model.IParentElImpl;
import org.hibernate.console.preferences.ConsoleConfigurationPreferences;
import
org.hibernate.console.preferences.ConsoleConfigurationPreferences.ConfigurationMode;
import org.hibernate.util.ConfigHelper;
@@ -65,7 +66,7 @@
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
-public class ConsoleConfiguration implements ExecutionContextHolder {
+public class ConsoleConfiguration extends IParentElImpl implements ExecutionContextHolder
{
private ExecutionContext executionContext;
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/KnownConfigurations.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/KnownConfigurations.java 2008-01-18
14:10:35 UTC (rev 5803)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/KnownConfigurations.java 2008-01-18
14:16:08 UTC (rev 5804)
@@ -51,6 +51,7 @@
import org.eclipse.ui.console.MessageConsole;
import org.eclipse.ui.console.MessageConsoleStream;
import org.hibernate.SessionFactory;
+import org.hibernate.console.model.IParentEl;
import org.hibernate.console.node.BaseNode;
import org.hibernate.console.node.ConfigurationListNode;
import org.hibernate.eclipse.HibernatePlugin;
@@ -62,7 +63,7 @@
* This class keeps track of the Hibernate Configurations that are known to
* the Hibernate Console plugin.
*/
-public class KnownConfigurations {
+public class KnownConfigurations implements IParentEl {
// TODO: is the best way for the querypage model ?
private QueryPageModel queryPages = new QueryPageModel();
@@ -345,7 +346,43 @@
public List getQueryParameterList() {
return queryParameters;
+ }
+
+ public Object[] getChildren() {
+ return getConfigurationsSortedByName();
+ }
+
+ public boolean hasChildren() {
+ if (null == configurations) {
+ return true;
+ }
+ return( configurations.size() > 0 );
}
+
+ public void setChildren(Object[] children) {
+ for (int i = 0; i < children.length; i++) {
+ if (!(children[i] instanceof ConsoleConfiguration)) {
+ continue;
+ }
+ ConsoleConfiguration configuration = (ConsoleConfiguration)children[i];
+ addConfiguration(configuration, true);
+ }
+ }
+
+ public void addChild(Object child) {
+ if (!(child instanceof ConsoleConfiguration)) {
+ return;
+ }
+ ConsoleConfiguration configuration = (ConsoleConfiguration)child;
+ addConfiguration(configuration, true);
+ }
+
+ public void removeChild(Object child) {
+ if (!(child instanceof ConsoleConfiguration)) {
+ return;
+ }
+ ConsoleConfiguration configuration = (ConsoleConfiguration)child;
+ removeConfiguration(configuration, true);
+ }
-
}
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/model/IParentEl.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/model/IParentEl.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/model/IParentEl.java 2008-01-18
14:16:08 UTC (rev 5804)
@@ -0,0 +1,29 @@
+package org.hibernate.console.model;
+
+/**
+ * Common protocol for elements that contain other elements.
+ */
+public interface IParentEl {
+ /**
+ * Returns the immediate children of this element.
+ * Unless otherwise specified by the implementing element,
+ * the children are in no particular order.
+ *
+ * @return the immediate children of this element
+ */
+ Object[] getChildren();
+ /**
+ * Returns whether this element has one or more immediate children.
+ * This is a convenience method, and may be more efficient than
+ * testing whether <code>getChildren</code> is an empty array.
+ *
+ * @return true if the immediate children of this element, false otherwise
+ */
+ boolean hasChildren();
+ //
+ void setChildren(Object[] children);
+ //
+ void addChild(Object child);
+ //
+ void removeChild(Object child);
+}
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/model/IParentElImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/model/IParentElImpl.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/model/IParentElImpl.java 2008-01-18
14:16:08 UTC (rev 5804)
@@ -0,0 +1,42 @@
+package org.hibernate.console.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class IParentElImpl implements IParentEl {
+
+ private List children = null;
+
+ public Object[] getChildren() {
+ if (null == children) {
+ return null;
+ }
+ return children.toArray();
+ }
+
+ public boolean hasChildren() {
+ if (null == children) {
+ return true;
+ }
+ return( children.size() > 0 );
+ }
+
+ public void setChildren(Object[] children) {
+ if (null == children || 0 == children.length) {
+ return;
+ }
+ this.children = new ArrayList(children.length);
+ for (int i = 0; i < children.length; i++) {
+ this.children.add(children[i]);
+ }
+ }
+
+ public void addChild(Object child) {
+ this.children.add(child);
+ }
+
+ public void removeChild(Object child) {
+ this.children.remove(child);
+ }
+
+}