1 19 20 package org.netbeans.modules.loadgenerator.api.impl; 21 22 import java.util.Map ; 23 import java.util.WeakHashMap ; 24 import javax.swing.Action ; 25 import org.netbeans.modules.loadgenerator.actions.LoadAction; 26 import org.netbeans.modules.loadgenerator.actions.StartAction; 27 import org.netbeans.modules.loadgenerator.actions.StopAction; 28 import org.netbeans.modules.loadgenerator.spi.Engine; 29 import org.netbeans.modules.loadgenerator.spi.ProcessInstance; 30 31 35 public class ManagerOutputWindowRegistry { 36 final private static ManagerOutputWindowRegistry instance = new ManagerOutputWindowRegistry(); 37 38 final private Map <ProcessInstance, ManagerOutputWindow> windows = new WeakHashMap <ProcessInstance, ManagerOutputWindow>(); 39 40 41 private ManagerOutputWindowRegistry() { 42 } 43 44 final public static ManagerOutputWindowRegistry getDefault() { 45 return instance; 46 } 47 48 public ManagerOutputWindow open(final ProcessInstance instance) { 49 ManagerOutputWindow mngrWin = windows.get(instance); 51 if (mngrWin == null) { 52 mngrWin = new ManagerOutputWindow(new Action []{ 53 new LoadAction((Engine)instance.getFactory()), 54 new StartAction((ProcessInstance)instance), 55 new StopAction((ProcessInstance)instance)}); 56 windows.put(instance, mngrWin); 57 } 58 mngrWin.attach(instance); 60 return mngrWin; 61 } 62 63 public void close(final ProcessInstance instance) { 64 ManagerOutputWindow mngrWin = windows.get(instance); 65 if (mngrWin != null) { 66 mngrWin.close(instance); 67 } 68 } 69 70 public ManagerOutputWindow find(final ProcessInstance instance) { 71 return windows.get(instance); 72 } 73 } 74 | Popular Tags |