Skip to main content
summaryrefslogtreecommitdiffstats
blob: 7801f414f25979d32080a1fe892ad089717e95e6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*******************************************************************************
 * Copyright (c) 2003, 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - Initial API and implementation
 *******************************************************************************/
package org.eclipse.wst.server.ui.internal.wizard;

import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IModuleArtifact;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.TaskModel;
import org.eclipse.wst.server.core.internal.IClient;
import org.eclipse.wst.server.core.internal.ILaunchableAdapter;
import org.eclipse.wst.server.ui.internal.Messages;
import org.eclipse.wst.server.ui.internal.wizard.fragment.RunOnServerWizardFragment;
/**
 * A wizard used for Run on Server.
 */
public class RunOnServerWizard extends TaskWizard {
	/**
	 * RunOnServerWizard constructor comment.
	 * 
	 * @param module a module
	 * @param launchMode a launch mode
	 * @param moduleArtifact a module artifact
	 */
	public RunOnServerWizard(IModule module, String launchMode, IModuleArtifact moduleArtifact) {
		super(Messages.wizRunOnServerTitle, new RunOnServerWizardFragment(module, launchMode, moduleArtifact));
		
		setNeedsProgressMonitor(true);
		if (ILaunchManager.DEBUG_MODE.equals(launchMode))
			setWindowTitle(Messages.wizDebugOnServerTitle);
		else if (ILaunchManager.PROFILE_MODE.equals(launchMode))
			setWindowTitle(Messages.wizProfileOnServerTitle);
		getTaskModel().putObject(TaskModel.TASK_LAUNCH_MODE, launchMode);
	}

	/**
	 * RunOnServerWizard constructor comment.
	 * 
	 * @param server a server
	 * @param launchMode a launch mode
	 * @param moduleArtifact a module artifact
	 */
	public RunOnServerWizard(IServer server, String launchMode, IModuleArtifact moduleArtifact) {
		super(Messages.wizRunOnServerTitle, new RunOnServerWizardFragment(server, launchMode, moduleArtifact));
		
		setNeedsProgressMonitor(true);
		if (ILaunchManager.DEBUG_MODE.equals(launchMode))
			setWindowTitle(Messages.wizDebugOnServerTitle);
		else if (ILaunchManager.PROFILE_MODE.equals(launchMode))
			setWindowTitle(Messages.wizProfileOnServerTitle);
		
		getTaskModel().putObject(TaskModel.TASK_SERVER, server);
		getTaskModel().putObject(TaskModel.TASK_LAUNCH_MODE, launchMode);
		addPages();
	}

	/**
	 * Return the server.
	 * 
	 * @return the server
	 */
	public IServer getServer() {
		try {
			return (IServer) getTaskModel().getObject(TaskModel.TASK_SERVER);
		} catch (Exception e) {
			return null;
		}
	}

	/**
	 * Return if the user wants to use the server as a default.
	 * 
	 * @return true if the server should be the default
	 */
	public boolean isPreferredServer() {
		try {
			Boolean b = (Boolean) getTaskModel().getObject(WizardTaskUtil.TASK_DEFAULT_SERVER);
			return b.booleanValue();
		} catch (Exception e) {
			return false;
		}
	}

	/**
	 * Return the selected client.
	 * 
	 * @return the client
	 */
	public IClient getSelectedClient() {
		try {
			return (IClient) getTaskModel().getObject(WizardTaskUtil.TASK_CLIENT);
		} catch (Exception e) {
			return null;
		}
	}

	/**
	 * Return the launchable adapter.
	 * 
	 * @return the adapter
	 */
	public ILaunchableAdapter getLaunchableAdapter() {
		try {
			return (ILaunchableAdapter) getTaskModel().getObject(WizardTaskUtil.TASK_LAUNCHABLE_ADAPTER);
		} catch (Exception e) {
			return null;
		}
	}

	/**
	 * Returns true if this wizard should be shown to the user.
	 * 
	 * @return <code>true</code> if this wizard should be shown, and <code>false</code>
	 *    otherwise
	 */
	public boolean shouldAppear() {
		return getServer() == null || hasTasks() || hasClients();
	}

	/**
	 * Return <code>true</code> if this wizard has tasks.
	 * 
	 * @return <code>true</code> if this wizard has tasks, and <code>false</code>
	 *    otherwise
	 */
	protected boolean hasTasks() {
		try {
			Boolean b = (Boolean) getTaskModel().getObject(WizardTaskUtil.TASK_HAS_TASKS);
			return b.booleanValue();
		} catch (Exception e) {
			return false;
		}
	}

	/**
	 * Return <code>true</code> if this wizard has multiple clients to show.
	 * 
	 * @return <code>true</code> if this wizard has multiple clients, and <code>false</code>
	 *    otherwise
	 */
	protected boolean hasClients() {
		try {
			Boolean b = (Boolean) getTaskModel().getObject(WizardTaskUtil.TASK_HAS_CLIENTS);
			return b.booleanValue();
		} catch (Exception e) {
			return false;
		}
	}
}

Back to the top