01: /*
02: * Utils.java
03: *
04: * To change this template, choose Tools | Options and locate the template under
05: * the Source Creation and Management node. Right-click the template and choose
06: * Open. You can then make changes to the template in the Source Editor.
07: */
08:
09: package gui;
10:
11: import java.text.SimpleDateFormat;
12: import java.util.Date;
13: import java.util.Locale;
14: import org.netbeans.jellytools.RuntimeTabOperator;
15: import org.netbeans.jellytools.nodes.Node;
16: import org.netbeans.jemmy.operators.JButtonOperator;
17: import org.netbeans.jemmy.operators.JFrameOperator;
18: import gui.ProgressSupport;
19:
20: /**
21: *
22: * @author lm97939
23: */
24: public class Utils {
25:
26: private static final String SERVER_REGISTRY = org.netbeans.jellytools.Bundle
27: .getStringTrimmed(
28: "org.netbeans.modules.j2ee.deployment.impl.ui.Bundle",
29: "SERVER_REGISTRY_NODE");
30:
31: public static String getTimeIndex() {
32: return new SimpleDateFormat("HHmmssS", Locale.US)
33: .format(new Date());
34: }
35:
36: public static void startStopServer(boolean start) {
37: RuntimeTabOperator runtimeTab = RuntimeTabOperator.invoke();
38: Node serverNode = new Node(runtimeTab.getRootNode(),
39: SERVER_REGISTRY + "|Glassfish V2");
40: try {
41: new org.netbeans.jemmy.EventTool().waitNoEvent(5000);
42: if (start)
43: serverNode.performPopupAction("Start");
44: else
45: serverNode.performPopupAction("Stop");
46: new org.netbeans.jemmy.EventTool().waitNoEvent(5000);
47: ProgressSupport.waitFinished((start ? "Starting"
48: : "Stopping")
49: + "Glassfish V2", 300000);
50: } catch (org.netbeans.jemmy.TimeoutExpiredException tee) {
51: }
52: new org.netbeans.jemmy.EventTool().waitNoEvent(2000);
53: }
54:
55: }
|