blob: d6eb19a06ba5e6f82f90330b8fc34bc32b410c33 (
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
|
/*******************************************************************************
* Copyright (c) 2003, 2005 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.view.servers;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.ui.internal.EclipseUtil;
/**
* Restart a module on a server.
*/
public class RestartModuleAction extends Action {
protected IServer server;
protected IModule module;
public RestartModuleAction(IServer server, IModule module) {
super();
this.server = server;
this.module = module;
setText(module.getName());
IProject project = module.getProject();
if (project != null) {
ImageDescriptor descriptor = EclipseUtil.getProjectImageDescriptor(project);
if (descriptor != null)
setImageDescriptor(descriptor);
}
// enable or disable
if (server == null || module == null) {
setEnabled(false);
return;
}
/*if (!(dr.getServerState() == IServer2.STATE_STARTED ||
dr.getServerState() == IServer2.STATE_STARTED_DEBUG) ||
!dr.canRestartModule(module)) {
setEnabled(false);
return;
}*/
setEnabled(server.canRestartModule(module).isOK());
}
/**
* Implementation of method defined on <code>IAction</code>.
*/
public void run() {
try {
server.restartModule(module, new NullProgressMonitor());
} catch (CoreException e) {
// ignore
}
}
}
|