KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > swingclient > workflowadmin > cache > CacheManagement


1 package org.enhydra.shark.swingclient.workflowadmin.cache;
2
3 import javax.swing.*;
4
5 import java.awt.Component JavaDoc;
6 import java.awt.Dimension JavaDoc;
7 import javax.swing.border.Border JavaDoc;
8 import org.enhydra.shark.api.client.wfservice.CacheAdministration;
9 import org.enhydra.shark.swingclient.ActionPanel;
10 import org.enhydra.shark.swingclient.ResourceManager;
11 import org.enhydra.shark.swingclient.workflowadmin.SharkAdmin;
12 import org.enhydra.shark.swingclient.workflowadmin.cache.actions.ClearProcessCache;
13 import org.enhydra.shark.swingclient.workflowadmin.cache.actions.ClearResourceCache;
14 import org.enhydra.shark.swingclient.workflowadmin.cache.actions.SetProcessCacheSize;
15 import org.enhydra.shark.swingclient.workflowadmin.cache.actions.SetResourceCacheSize;
16
17 /**
18  * Implements the user interface and program logic to manage shark's caches
19  *
20  * @author Sasa Bojanic
21  * @version 1.0
22  */

23 public class CacheManagement extends ActionPanel {
24    private static Dimension JavaDoc textFieldDimension=new Dimension JavaDoc(300,20);
25
26    private SharkAdmin workflowAdmin;
27
28    private JTextField procCacheSize=new JTextField();
29    private JTextField procCacheItems=new JTextField();
30    private JTextField resCacheSize=new JTextField();
31    private JTextField resCacheItems=new JTextField();
32
33
34    public CacheManagement (SharkAdmin wa) {
35       super();
36       this.workflowAdmin=wa;
37       super.init();
38    }
39
40    protected void createActions () {
41       defaultActions=new Action[] {
42          new SetProcessCacheSize(this),
43          new ClearProcessCache(this),
44          new SetResourceCacheSize(this),
45          new ClearResourceCache(this)
46       };
47    }
48
49    protected Component JavaDoc createCenterComponent() {
50       procCacheSize.setEditable(false);
51       procCacheItems.setEditable(false);
52       resCacheSize.setEditable(false);
53       resCacheItems.setEditable(false);
54
55       JPanel pp=new JPanel();
56       Border JavaDoc emptyb=BorderFactory.createEmptyBorder(10,10,10,10);
57       Border JavaDoc inb=BorderFactory.createEmptyBorder(1,1,1,1);
58       inb=BorderFactory.createTitledBorder(inb,
59                                            ResourceManager.getLanguageDependentString("ProcessCacheKey"));
60       pp.setBorder(BorderFactory.createCompoundBorder(emptyb,inb));
61       pp.setLayout(new BoxLayout(pp,BoxLayout.Y_AXIS));
62
63       JPanel pp1=new JPanel();
64       pp1.setLayout(new BoxLayout(pp1,BoxLayout.X_AXIS));
65       pp1.add(Box.createHorizontalGlue());
66       pp1.add(new JLabel(ResourceManager.getLanguageDependentString("ProcessCacheSizeKey")+": "));
67       procCacheSize.setMinimumSize(new Dimension JavaDoc(textFieldDimension));
68       procCacheSize.setMaximumSize(new Dimension JavaDoc(textFieldDimension));
69       procCacheSize.setPreferredSize(new Dimension JavaDoc(textFieldDimension));
70       pp1.add(procCacheSize);
71       pp.add(pp1);
72
73       pp1=new JPanel();
74       pp1.setLayout(new BoxLayout(pp1,BoxLayout.X_AXIS));
75       pp1.add(Box.createHorizontalGlue());
76       pp1.add(new JLabel(ResourceManager.getLanguageDependentString("NoOfProcessesInCacheKey")+": "));
77       procCacheItems.setMinimumSize(new Dimension JavaDoc(textFieldDimension));
78       procCacheItems.setMaximumSize(new Dimension JavaDoc(textFieldDimension));
79       procCacheItems.setPreferredSize(new Dimension JavaDoc(textFieldDimension));
80       pp1.add(procCacheItems);
81       pp.add(pp1);
82
83
84       JPanel rp=new JPanel();
85       inb=BorderFactory.createEmptyBorder(1,1,1,1);
86       inb=BorderFactory.createTitledBorder(inb,
87                                            ResourceManager.getLanguageDependentString("ResourceCacheKey"));
88       rp.setBorder(BorderFactory.createCompoundBorder(emptyb,inb));
89       rp.setLayout(new BoxLayout(rp,BoxLayout.Y_AXIS));
90
91       JPanel rp1=new JPanel();
92       rp1.setLayout(new BoxLayout(rp1,BoxLayout.X_AXIS));
93       rp1.add(Box.createHorizontalGlue());
94       rp1.add(new JLabel(ResourceManager.getLanguageDependentString("ResourceCacheSizeKey")+": "));
95       resCacheSize.setMinimumSize(new Dimension JavaDoc(textFieldDimension));
96       resCacheSize.setMaximumSize(new Dimension JavaDoc(textFieldDimension));
97       resCacheSize.setPreferredSize(new Dimension JavaDoc(textFieldDimension));
98       rp1.add(resCacheSize);
99       rp.add(rp1);
100
101       rp1=new JPanel();
102       rp1.setLayout(new BoxLayout(rp1,BoxLayout.X_AXIS));
103       rp1.add(Box.createHorizontalGlue());
104       rp1.add(new JLabel(ResourceManager.getLanguageDependentString("NoOfResourcesInCacheKey")+": "));
105       resCacheItems.setMinimumSize(new Dimension JavaDoc(textFieldDimension));
106       resCacheItems.setMaximumSize(new Dimension JavaDoc(textFieldDimension));
107       resCacheItems.setPreferredSize(new Dimension JavaDoc(textFieldDimension));
108       rp1.add(resCacheItems);
109       rp.add(rp1);
110
111       JPanel mp=new JPanel();
112       mp.setBorder(BorderFactory.createEtchedBorder());
113       mp.setLayout(new BoxLayout(mp,BoxLayout.Y_AXIS));
114
115       mp.add(pp);
116       mp.add(rp);
117
118       return mp;
119    }
120
121    public SharkAdmin getWorkflowAdmin () {
122       return workflowAdmin;
123    }
124
125    public void clear () {
126    }
127
128    public synchronized void refresh (boolean mandatoryRefreshing) {
129 // if (isShowing() || mandatoryRefreshing) {
130
try {
131             CacheAdministration ca=SharkAdmin.getCacheAdmin();
132             procCacheSize.setText(String.valueOf(ca.getProcessCacheSize()));
133             procCacheItems.setText(String.valueOf(ca.howManyCachedProcesses()));
134             resCacheSize.setText(String.valueOf(ca.getResourceCacheSize()));
135             resCacheItems.setText(String.valueOf(ca.howManyCachedResources()));
136          } catch (Exception JavaDoc ex) {
137             procCacheSize.setText("???");
138             procCacheItems.setText("???");
139             resCacheSize.setText("???");
140             resCacheItems.setText("???");
141          }
142       }
143 // }
144

145 }
146
Popular Tags