changeset 102:4acc8348d4fe

Move Ref classes from client to common.
author Roman Kennke <rkennke@redhat.com>
date Tue, 06 Mar 2012 22:43:32 +0100
parents abed8154068a
children dd82a9bcf94c
files client/src/main/java/com/redhat/thermostat/client/HostPanelFacadeImpl.java client/src/main/java/com/redhat/thermostat/client/HostRef.java client/src/main/java/com/redhat/thermostat/client/MainWindowFacade.java client/src/main/java/com/redhat/thermostat/client/MainWindowFacadeImpl.java client/src/main/java/com/redhat/thermostat/client/Ref.java client/src/main/java/com/redhat/thermostat/client/UiFacadeFactory.java client/src/main/java/com/redhat/thermostat/client/UiFacadeFactoryImpl.java client/src/main/java/com/redhat/thermostat/client/VmPanelFacadeImpl.java client/src/main/java/com/redhat/thermostat/client/VmRef.java client/src/main/java/com/redhat/thermostat/client/ui/MainWindow.java common/src/main/java/com/redhat/thermostat/common/dao/HostRef.java common/src/main/java/com/redhat/thermostat/common/dao/Ref.java common/src/main/java/com/redhat/thermostat/common/dao/VmRef.java
diffstat 13 files changed, 251 insertions(+), 237 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/main/java/com/redhat/thermostat/client/HostPanelFacadeImpl.java	Fri Mar 02 10:46:18 2012 -0500
+++ b/client/src/main/java/com/redhat/thermostat/client/HostPanelFacadeImpl.java	Tue Mar 06 22:43:32 2012 +0100
@@ -65,6 +65,7 @@
 import com.redhat.thermostat.client.locale.LocaleResources;
 import com.redhat.thermostat.common.NetworkInfo;
 import com.redhat.thermostat.common.NetworkInterfaceInfo;
+import com.redhat.thermostat.common.dao.HostRef;
 
 public class HostPanelFacadeImpl implements HostPanelFacade {
 
--- a/client/src/main/java/com/redhat/thermostat/client/HostRef.java	Fri Mar 02 10:46:18 2012 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-/*
- * Copyright 2012 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat 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.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.client;
-
-public class HostRef implements Ref {
-
-    private final String uid;
-    private final String name;
-
-    public HostRef(String id, String name) {
-        this.uid = id;
-        this.name = name;
-    }
-
-    @Override
-    public String toString() {
-        return name;
-    }
-
-    public String getAgentId() {
-        return uid;
-    }
-
-    public String getHostName() {
-        return name;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        }
-        if (obj == this) {
-            return true;
-        }
-        if (obj.getClass() != this.getClass()) {
-            return false;
-        }
-        HostRef other = (HostRef) obj;
-        if (equals(this.uid, other.uid) && equals(this.name, other.name)) {
-            return true;
-        }
-        return false;
-    }
-
-    private static boolean equals(Object obj1, Object obj2) {
-        return (obj1 == null && obj2 == null) || (obj1 != null && obj1.equals(obj2));
-    }
-
-    @Override
-    public int hashCode() {
-        return uid.hashCode();
-    }
-
-    @Override
-    public boolean matches(String filter) {
-        return getHostName().contains(filter) || getAgentId().contains(filter);
-    }
-}
--- a/client/src/main/java/com/redhat/thermostat/client/MainWindowFacade.java	Fri Mar 02 10:46:18 2012 -0500
+++ b/client/src/main/java/com/redhat/thermostat/client/MainWindowFacade.java	Tue Mar 06 22:43:32 2012 +0100
@@ -38,6 +38,9 @@
 
 import javax.swing.tree.TreeModel;
 
+import com.redhat.thermostat.common.dao.HostRef;
+import com.redhat.thermostat.common.dao.VmRef;
+
 public interface MainWindowFacade extends AsyncUiFacade {
 
     public HostRef[] getHosts();
--- a/client/src/main/java/com/redhat/thermostat/client/MainWindowFacadeImpl.java	Fri Mar 02 10:46:18 2012 -0500
+++ b/client/src/main/java/com/redhat/thermostat/client/MainWindowFacadeImpl.java	Tue Mar 06 22:43:32 2012 +0100
@@ -62,6 +62,9 @@
 import com.mongodb.DBCursor;
 import com.mongodb.DBObject;
 import com.redhat.thermostat.client.locale.LocaleResources;
+import com.redhat.thermostat.common.dao.HostRef;
+import com.redhat.thermostat.common.dao.Ref;
+import com.redhat.thermostat.common.dao.VmRef;
 import com.redhat.thermostat.common.utils.LoggingUtils;
 import com.redhat.thermostat.common.utils.StringUtils;
 
--- a/client/src/main/java/com/redhat/thermostat/client/Ref.java	Fri Mar 02 10:46:18 2012 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * Copyright 2012 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat 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.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.client;
-
-public interface Ref {
-
-    public boolean matches(String filter);
-
-}
--- a/client/src/main/java/com/redhat/thermostat/client/UiFacadeFactory.java	Fri Mar 02 10:46:18 2012 -0500
+++ b/client/src/main/java/com/redhat/thermostat/client/UiFacadeFactory.java	Tue Mar 06 22:43:32 2012 +0100
@@ -36,6 +36,9 @@
 
 package com.redhat.thermostat.client;
 
+import com.redhat.thermostat.common.dao.HostRef;
+import com.redhat.thermostat.common.dao.VmRef;
+
 public interface UiFacadeFactory {
 
     public MainWindowFacade getMainWindow();
--- a/client/src/main/java/com/redhat/thermostat/client/UiFacadeFactoryImpl.java	Fri Mar 02 10:46:18 2012 -0500
+++ b/client/src/main/java/com/redhat/thermostat/client/UiFacadeFactoryImpl.java	Tue Mar 06 22:43:32 2012 +0100
@@ -36,6 +36,9 @@
 
 package com.redhat.thermostat.client;
 
+import com.redhat.thermostat.common.dao.HostRef;
+import com.redhat.thermostat.common.dao.VmRef;
+
 public class UiFacadeFactoryImpl implements UiFacadeFactory {
 
     private MongoConnection connection;
--- a/client/src/main/java/com/redhat/thermostat/client/VmPanelFacadeImpl.java	Fri Mar 02 10:46:18 2012 -0500
+++ b/client/src/main/java/com/redhat/thermostat/client/VmPanelFacadeImpl.java	Tue Mar 06 22:43:32 2012 +0100
@@ -65,6 +65,7 @@
 import com.redhat.thermostat.common.VmMemoryStat;
 import com.redhat.thermostat.common.VmMemoryStat.Generation;
 import com.redhat.thermostat.common.VmMemoryStat.Space;
+import com.redhat.thermostat.common.dao.VmRef;
 
 public class VmPanelFacadeImpl implements VmPanelFacade {
 
--- a/client/src/main/java/com/redhat/thermostat/client/VmRef.java	Fri Mar 02 10:46:18 2012 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-/*
- * Copyright 2012 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat 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.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.client;
-
-public class VmRef implements Ref {
-
-    private final HostRef hostRef;
-    private final String uid;
-    private final String name;
-
-    public VmRef(HostRef hostRef, Integer id, String name) {
-        this.hostRef = hostRef;
-        this.uid = id.toString();
-        this.name = name;
-    }
-
-    @Override
-    public String toString() {
-        return name;
-    }
-
-    public HostRef getAgent() {
-        return hostRef;
-    }
-
-    public String getId() {
-        return uid;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        }
-        if (obj == this) {
-            return true;
-        }
-        if (obj.getClass() != this.getClass()) {
-            return false;
-        }
-        VmRef other = (VmRef) obj;
-        if (equals(this.hostRef, other.hostRef) && equals(this.uid, other.uid) && equals(this.name, other.name)) {
-            return true;
-        }
-        return false;
-    }
-
-    private static boolean equals(Object obj1, Object obj2) {
-        return (obj1 == null && obj2 == null) || (obj1 != null && obj1.equals(obj2));
-    }
-
-    @Override
-    public int hashCode() {
-        return uid.hashCode();
-    }
-
-    @Override
-    public boolean matches(String filter) {
-        return getName().contains(filter) || getId().contains(filter);
-    }
-}
--- a/client/src/main/java/com/redhat/thermostat/client/ui/MainWindow.java	Fri Mar 02 10:46:18 2012 -0500
+++ b/client/src/main/java/com/redhat/thermostat/client/ui/MainWindow.java	Tue Mar 06 22:43:32 2012 +0100
@@ -80,11 +80,11 @@
 import javax.swing.tree.TreeSelectionModel;
 
 import com.redhat.thermostat.client.ApplicationInfo;
-import com.redhat.thermostat.client.HostRef;
 import com.redhat.thermostat.client.MainWindowFacade;
 import com.redhat.thermostat.client.UiFacadeFactory;
-import com.redhat.thermostat.client.VmRef;
 import com.redhat.thermostat.client.locale.LocaleResources;
+import com.redhat.thermostat.common.dao.HostRef;
+import com.redhat.thermostat.common.dao.VmRef;
 
 public class MainWindow extends JFrame {
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/HostRef.java	Tue Mar 06 22:43:32 2012 +0100
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat 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.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+public class HostRef implements Ref {
+
+    private final String uid;
+    private final String name;
+
+    public HostRef(String id, String name) {
+        this.uid = id;
+        this.name = name;
+    }
+
+    @Override
+    public String toString() {
+        return name;
+    }
+
+    public String getAgentId() {
+        return uid;
+    }
+
+    public String getHostName() {
+        return name;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == null) {
+            return false;
+        }
+        if (obj == this) {
+            return true;
+        }
+        if (obj.getClass() != this.getClass()) {
+            return false;
+        }
+        HostRef other = (HostRef) obj;
+        if (equals(this.uid, other.uid) && equals(this.name, other.name)) {
+            return true;
+        }
+        return false;
+    }
+
+    private static boolean equals(Object obj1, Object obj2) {
+        return (obj1 == null && obj2 == null) || (obj1 != null && obj1.equals(obj2));
+    }
+
+    @Override
+    public int hashCode() {
+        return uid.hashCode();
+    }
+
+    @Override
+    public boolean matches(String filter) {
+        return getHostName().contains(filter) || getAgentId().contains(filter);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/Ref.java	Tue Mar 06 22:43:32 2012 +0100
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat 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.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+public interface Ref {
+
+    public boolean matches(String filter);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/VmRef.java	Tue Mar 06 22:43:32 2012 +0100
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat 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.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+public class VmRef implements Ref {
+
+    private final HostRef hostRef;
+    private final String uid;
+    private final String name;
+
+    public VmRef(HostRef hostRef, Integer id, String name) {
+        this.hostRef = hostRef;
+        this.uid = id.toString();
+        this.name = name;
+    }
+
+    @Override
+    public String toString() {
+        return name;
+    }
+
+    public HostRef getAgent() {
+        return hostRef;
+    }
+
+    public String getId() {
+        return uid;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == null) {
+            return false;
+        }
+        if (obj == this) {
+            return true;
+        }
+        if (obj.getClass() != this.getClass()) {
+            return false;
+        }
+        VmRef other = (VmRef) obj;
+        if (equals(this.hostRef, other.hostRef) && equals(this.uid, other.uid) && equals(this.name, other.name)) {
+            return true;
+        }
+        return false;
+    }
+
+    private static boolean equals(Object obj1, Object obj2) {
+        return (obj1 == null && obj2 == null) || (obj1 != null && obj1.equals(obj2));
+    }
+
+    @Override
+    public int hashCode() {
+        return uid.hashCode();
+    }
+
+    @Override
+    public boolean matches(String filter) {
+        return getName().contains(filter) || getId().contains(filter);
+    }
+}