summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/gui/tabs/CollectionPane.java
diff options
context:
space:
mode:
Diffstat (limited to 'source/com/c2kernel/gui/tabs/CollectionPane.java')
-rwxr-xr-xsource/com/c2kernel/gui/tabs/CollectionPane.java100
1 files changed, 100 insertions, 0 deletions
diff --git a/source/com/c2kernel/gui/tabs/CollectionPane.java b/source/com/c2kernel/gui/tabs/CollectionPane.java
new file mode 100755
index 0000000..92492fc
--- /dev/null
+++ b/source/com/c2kernel/gui/tabs/CollectionPane.java
@@ -0,0 +1,100 @@
+package com.c2kernel.gui.tabs;
+import java.awt.GridBagConstraints;
+
+import javax.swing.JTabbedPane;
+
+import com.c2kernel.collection.Aggregation;
+import com.c2kernel.collection.Collection;
+import com.c2kernel.collection.Dependency;
+import com.c2kernel.entity.C2KLocalObject;
+import com.c2kernel.entity.proxy.EntityProxyObserver;
+import com.c2kernel.entity.proxy.ItemProxy;
+import com.c2kernel.gui.tabs.collection.AggregationView;
+import com.c2kernel.gui.tabs.collection.CollectionView;
+import com.c2kernel.gui.tabs.collection.DependencyView;
+import com.c2kernel.persistency.ClusterStorage;
+import com.c2kernel.process.Gateway;
+import com.c2kernel.utils.Logger;
+/**
+ * @version $Revision: 1.36 $ $Date: 2005/10/06 06:51:15 $
+ * @author $Author: abranson $
+ */
+public class CollectionPane extends EntityTabPane implements EntityProxyObserver
+{
+ JTabbedPane collTabs;
+
+ public CollectionPane()
+ {
+ super("Collection", "Item Collection");
+ createLayout();
+ }
+
+ public void add(C2KLocalObject contents)
+ {
+ Logger.msg(5, "Got "+contents.getName()+": "+contents.getClass().getName());
+ if (!(contents instanceof Collection))
+ {
+ // ignore member control objects
+ return;
+ }
+ Logger.msg(7, "Looking for existing "+contents.getName());
+ CollectionView thisCollView = findTabForCollName(contents.getName());
+ if (thisCollView == null){
+ if (contents instanceof Aggregation)
+ thisCollView = new AggregationView();
+ else if (contents instanceof Dependency)
+ thisCollView = new DependencyView();
+ else {
+ Logger.error("Collection type "+contents.getClass().getName()+" not known");
+ return;
+ }
+ Logger.msg(3, "Adding new "+thisCollView.getClass().getName());
+ thisCollView.setItem((ItemProxy)sourceEntity.getEntity());
+ collTabs.add(contents.getName(), thisCollView);
+ }
+ thisCollView.setCollection((Collection)contents);
+ }
+
+ public void remove(String id)
+ {
+
+ }
+
+ private CollectionView findTabForCollName(String collName) {
+ CollectionView thisCollView = null;
+ for (int i = 0; i < collTabs.getTabCount(); i++) {
+ String tabName = collTabs.getTitleAt(i);
+ if (tabName.equals(collName)) {
+ thisCollView = (CollectionView)collTabs.getComponentAt(i);
+ }
+ }
+ return thisCollView;
+ }
+
+ protected void createLayout()
+ {
+ initPanel();
+ // Add the collection tab pane
+ getGridBagConstraints();
+ c.gridx = 0;
+ c.gridy = 1;
+ c.fill = GridBagConstraints.BOTH;
+ c.weighty = 2.0;
+ collTabs = new JTabbedPane();
+ gridbag.setConstraints(collTabs, c);
+ add(collTabs);
+ }
+
+ public void run()
+ {
+ Thread.currentThread().setName("Collection Loader");
+ sourceEntity.getEntity().subscribe(this, ClusterStorage.COLLECTION, true);
+ }
+
+ public void reload()
+ {
+ Gateway.getStorage().clearCache(sourceEntity.getSysKey(), ClusterStorage.COLLECTION);
+ collTabs.removeAll();
+ initForEntity(sourceEntity);
+ }
+}