1 package org.enhydra.shark.corbaclient.workflowadmin; 2 3 import java.awt.*; 4 import java.awt.event.*; 5 import java.net.*; 6 import java.util.Iterator ; 7 8 import javax.swing.*; 9 10 import org.omg.WfBase.*; 11 import org.enhydra.shark.corbaclient.*; 12 import org.enhydra.shark.corbaclient.workflowadmin.actions.*; 13 import org.enhydra.shark.corbaclient.workflowadmin.definition.*; 14 import org.enhydra.shark.corbaclient.workflowadmin.instantiation.*; 15 import org.enhydra.shark.corbaclient.workflowadmin.monitoring.*; 16 import org.enhydra.shark.corbaclient.workflowadmin.application.*; 17 import org.enhydra.shark.corbaclient.workflowadmin.report.*; 18 import org.enhydra.shark.corbaclient.workflowadmin.repository.*; 19 import org.enhydra.shark.corbaclient.workflowadmin.user.*; 20 import org.enhydra.shark.corbaclient.workflowadmin.worklist.*; 21 import org.enhydra.shark.corbaclient.workflowadmin.cache.*; 22 23 import org.enhydra.jawe.xml.*; 24 25 35 public class SharkAdmin extends SharkClient { 36 37 private JTabbedPane tabbedPane; 38 39 private EngineTreeModel engineTreeModel; 40 private RepositoryManagement repositoryManagement; 41 private PackageManagement packageManagement; 42 private ProcessInstantiationManagement processInstantiationManagement; 43 private ProcessMonitor processMonitor; 44 private UserManagement userManagement; 45 private ApplicationMappingManagement applicationMapping; 46 private CacheManagement cacheManagement; 47 private WorklistManagement worklistManagement; 48 private ReportManagement reportManagement; 49 50 private DeadlineChecker deadlineChecker; 51 private LimitChecker limitChecker; 52 53 private long deadlineCheckingTime=30000; 54 private long limitCheckingTime=30000; 55 56 58 public SharkAdmin (JFrame frame) { 59 super(frame); 60 } 61 63 protected void createActions () { 64 super.createActions(); 65 Action[] newActions=new Action[defaultActions.length+3]; 66 System.arraycopy(defaultActions,0,newActions,0,defaultActions.length); 67 newActions[defaultActions.length]=new AutomaticallyCheckDeadlines(this); 68 newActions[defaultActions.length+1]=new AutomaticallyCheckLimits(this); 69 newActions[defaultActions.length+2]=new ShowHideFinishedProcesses(this); 70 defaultActions=newActions; 71 } 72 73 protected Component createCenterComponent () { 74 engineTreeModel=new EngineTreeModel(this); 75 repositoryManagement=new RepositoryManagement(this); 76 packageManagement=new PackageManagement(this); 77 processInstantiationManagement=new ProcessInstantiationManagement(this); 78 processMonitor=new ProcessMonitor(this); 79 userManagement=new UserManagement(this); 80 applicationMapping=new ApplicationMappingManagement(this); 81 cacheManagement=new CacheManagement(this); 82 worklistManagement=new WorklistManagement(this); 83 reportManagement=new ReportManagement(this); 84 85 tabbedPane=new JTabbedPane(); 87 tabbedPane.addTab( 88 ResourceManager.getLanguageDependentString("RepositoryManagementKey"), 89 repositoryManagement); 90 tabbedPane.addTab( 91 ResourceManager.getLanguageDependentString("PackageManagementKey"), 92 packageManagement); 93 tabbedPane.addTab( 94 ResourceManager.getLanguageDependentString("ProcessInstantiationManagementKey"), 95 processInstantiationManagement); 96 tabbedPane.addTab(ResourceManager.getLanguageDependentString("ProcessMonitorKey"),processMonitor); 97 tabbedPane.addTab(ResourceManager.getLanguageDependentString("UserManagementKey"),userManagement); 98 tabbedPane.addTab(ResourceManager.getLanguageDependentString("ApplicationMappingKey"),applicationMapping); 99 tabbedPane.addTab(ResourceManager.getLanguageDependentString("CacheManagementKey"),cacheManagement); 100 tabbedPane.addTab(ResourceManager.getLanguageDependentString("WorklistManagementKey"),worklistManagement); 101 tabbedPane.setVisible(false); 103 104 return tabbedPane; 105 } 106 107 113 public synchronized void refresh (boolean mandatoryRefreshing) { 114 tabbedPane.setVisible(true); 115 engineTreeModel.refresh(mandatoryRefreshing); 116 packageManagement.refresh(mandatoryRefreshing); 117 processInstantiationManagement.refresh(mandatoryRefreshing); 118 processMonitor.refresh(mandatoryRefreshing); 119 repositoryManagement.refresh(mandatoryRefreshing); 120 userManagement.refresh(mandatoryRefreshing); 121 applicationMapping.refresh(mandatoryRefreshing); 122 cacheManagement.refresh(mandatoryRefreshing); 123 worklistManagement.refresh(mandatoryRefreshing); 124 reportManagement.refresh(mandatoryRefreshing); 125 } 126 127 public void refreshAfterUpdate () { 128 stopRefresher(); 129 while (isRefresherActive()); 133 engineTreeModel.clear(); 134 repositoryManagement.refresh(false); 135 packageManagement.refresh(true); 136 processInstantiationManagement.clear(); 137 processInstantiationManagement.refresh(true); 138 processMonitor.clear(); 139 userManagement.clear(); 140 applicationMapping.clear(); 141 cacheManagement.clear(); 142 worklistManagement.clear(); 143 reportManagement.clear(); 144 startRefresher(); 145 refresh(true); 146 } 147 148 151 public void clearComponents() { 152 try { 153 setTitle(); 154 tabbedPane.setVisible(false); 155 tabbedPane.setSelectedIndex(0); 156 stopRefresher(); 157 while (isRefresherActive()); 161 engineTreeModel.clear(); 162 repositoryManagement.clear(); 163 packageManagement.refresh(true); 164 processInstantiationManagement.clear(); 165 processInstantiationManagement.refresh(true); 166 processMonitor.clear(); 167 userManagement.clear(); 168 applicationMapping.clear(); 169 cacheManagement.clear(); 170 worklistManagement.clear(); 171 reportManagement.clear(); 172 } catch (Exception ex) {ex.printStackTrace();} 173 } 174 175 protected String getAppTitleResourceString() { 176 return "WorkflowAdminTitle"; 177 } 178 179 protected String getLogoResourceString() { 180 return "workflowadminLogo"; 181 } 182 183 protected String getIconResourceString() { 184 return "workflowadminIcon"; 185 } 186 protected String getMenubarResourceString() { 187 return "adminmainmenubar"; 188 } 189 190 protected String getRefreshingRateString () { 191 return "RefreshingRateInSecondsForWorkflowAdmin"; 192 } 193 194 public EngineTreeModel getEngineTreeModel() { 195 return engineTreeModel; 196 } 197 198 public RepositoryManagement getRepositoryManagement () { 199 return repositoryManagement; 200 } 201 202 public PackageManagement getPackageManagement () { 203 return packageManagement; 204 } 205 206 public ProcessInstantiationManagement getProcessInstantiationManagement () { 207 return processInstantiationManagement; 208 } 209 210 public ProcessMonitor getProcessMonitor () { 211 return processMonitor; 212 } 213 214 public UserManagement getUserManagement () { 215 return userManagement; 216 } 217 218 public ApplicationMappingManagement getApplicationMapping () { 219 return applicationMapping; 220 } 221 222 public CacheManagement getCacheManagement () { 223 return cacheManagement; 224 } 225 226 public WorklistManagement getWorklistManagement () { 227 return worklistManagement; 228 } 229 230 public ReportManagement getReportManagement () { 231 return reportManagement; 232 } 233 234 public void enableControls (boolean enable) { 235 super.enableControls(enable); 236 tabbedPane.setEnabled(enable); 237 } 238 239 public void showXPDLErrorsReport (String xpdlErrors) { 240 try { 241 String title=ResourceManager.getLanguageDependentString("XPDLErrorReportKey"); 242 final JDialog report=new JDialog(myFrame,title,true); 243 JEditorPane text = new JEditorPane("text/html",xpdlErrors); 244 text.setEditable(false); 245 text.getCaret().setDot(0); 246 JScrollPane sp = new JScrollPane(text); 247 sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 248 sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 249 report.getContentPane().setLayout(new BorderLayout()); 250 report.getContentPane().add(sp); 251 252 JPanel buttonPanel=new JPanel(); 253 buttonPanel.setAlignmentX(Component.LEFT_ALIGNMENT); 254 buttonPanel.setAlignmentY(Component.TOP_ALIGNMENT); 255 256 JButton buttonOK=new JButton(ResourceManager.getLanguageDependentString("OKKey")); 257 java.net.URL u = ResourceManager.getResource("OKImage"); 258 if (u!=null) { 259 buttonOK.setIcon(new ImageIcon(u)); 260 } 261 buttonPanel.add(buttonOK); 262 263 Container cp=report.getContentPane(); 264 cp.setLayout(new BorderLayout()); 265 cp.add(sp,BorderLayout.CENTER); 266 cp.add(buttonPanel,BorderLayout.SOUTH); 267 268 buttonOK.addActionListener(new ActionListener(){ 270 public void actionPerformed( ActionEvent ae ){ 271 report.dispose(); 272 } 273 }); 274 275 buttonOK.setDefaultCapable(true); 276 report.getRootPane().setDefaultButton(buttonOK); 277 278 279 report.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) 280 .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0,false),"Cancel"); 281 report.getRootPane().getActionMap().put("Cancel", new AbstractAction() { 282 public void actionPerformed(ActionEvent e) { 283 report.dispose(); 284 } 285 }); 286 287 org.enhydra.jawe.Utils.center(report,100,150); 288 289 report.show(); 290 } catch (Exception ex) {ex.printStackTrace();} 291 } 292 293 public void showOrHideFinishedProcesses () { 294 engineTreeModel.setShowFinishedProcesses( 295 !engineTreeModel.getShowFinishedProcesses()); 296 } 297 298 public void setAutomaticDeadlineCheck (boolean checkAutomatically) { 299 if (deadlineChecker==null) { 300 deadlineChecker=new DeadlineChecker(getDeadlineAdmin(),deadlineCheckingTime); 301 } 302 if (checkAutomatically) { 303 deadlineChecker.startChecker(); 304 } else { 305 deadlineChecker.stopChecker(); 306 } 307 } 308 309 public void setAutomaticLimitCheck (boolean checkAutomatically) { 310 if (limitChecker==null) { 311 limitChecker=new LimitChecker(getLimitAdmin(),limitCheckingTime); 312 } 313 if (checkAutomatically) { 314 limitChecker.startChecker(); 315 } else { 316 limitChecker.stopChecker(); 317 } 318 } 319 320 public void onDisconnectOrShutdown () { 321 if (execAdmin==null) return; 322 Iterator it=ProcessInstantiatorPOA.getInstantiators().iterator(); 323 while (it.hasNext()) { 324 ProcessInstantiatorInterface pi=(ProcessInstantiatorInterface)it.next(); 325 pi.releaseProcesses(); 326 } 327 } 328 329 330 public static void main(String [] args) throws Exception { 331 String vers = System.getProperty("java.version"); 333 if (vers.compareTo("1.4") < 0) { 334 System.out.println("!!!WARNING: Shark Workflow Administrator must be run with a " + 335 "1.4 or higher version VM!!!"); 336 System.exit(1); 337 } 338 SharkAdmin sa=new SharkAdmin(new JFrame()); 339 340 if (args!=null && args.length>0) { 342 sa.deadlineCheckingTime=Long.parseLong(args[0]); 343 } 344 345 String ldelay=null; 347 if (args!=null && args.length>1) { 348 sa.limitCheckingTime=Long.parseLong(args[1]); 349 } 350 } 351 352 353 } 354 | Popular Tags |