01: package com.bostechcorp.cbesb.ui.ide.actions;
02:
03: import org.eclipse.core.resources.IFile;
04: import org.eclipse.core.resources.IProject;
05: import org.eclipse.core.resources.IResource;
06: import org.eclipse.jface.action.IAction;
07: import org.eclipse.jface.viewers.StructuredSelection;
08: import org.eclipse.ui.IEditorPart;
09: import org.eclipse.ui.PlatformUI;
10: import org.eclipse.ui.part.FileEditorInput;
11:
12: import com.bostechcorp.cbesb.common.i18n.I18N;
13: import com.bostechcorp.cbesb.common.i18n.Message;
14: import com.bostechcorp.cbesb.common.i18n.Messages;
15: import com.bostechcorp.cbesb.common.util.project.ProjectUtil;
16: import com.bostechcorp.cbesb.ui.util.MsgUtil;
17: import com.bostechcorp.cbesb.ui.util.ViewUtil;
18: import com.bostechcorp.cbesb.ui.util.log.ESBLog;
19:
20: public class BuildProjectCleanAction extends BuildProjectAction {
21:
22: public void run(IAction action) {
23: StructuredSelection sele = (StructuredSelection) selection;
24: IProject project = null;
25: if (sele.getFirstElement() instanceof IProject) {
26: project = (IProject) sele.getFirstElement();
27:
28: } else if (sele.getFirstElement() instanceof IFile) {
29: IFile f = (IFile) sele.getFirstElement();
30: project = f.getProject();
31: }
32:
33: IEditorPart[] editors = PlatformUI.getWorkbench()
34: .getActiveWorkbenchWindow().getActivePage()
35: .getEditors();
36: String editorName = "";
37: for (IEditorPart editor : editors) {
38: if (editor.getTitle().startsWith("Test:")) {
39: FileEditorInput fei = (FileEditorInput) editor
40: .getEditorInput();
41: String projectName = fei.getFile().getProject()
42: .getName();
43: if (project != null
44: && project.getName().equals(projectName)) {
45: editorName += editor.getTitle() + ",";
46: }
47: }
48: }
49: if (!editorName.equals("")) {
50: MsgUtil.warningMsg(new Message(Messages.CLEAN_WARNING, "["
51: + editorName.substring(0, editorName.length() - 1)
52: + "]").getMessage());
53: return;
54: }
55:
56: boolean openView = ViewUtil.displayConsoleView(ESBLog.ID);
57:
58: if (project != null) {
59: try {
60: ProjectUtil.buildProjectClean(project.getLocation()
61: .toString());
62: project.refreshLocal(IResource.DEPTH_INFINITE, null);
63:
64: } catch (Exception ex) {
65: ex.printStackTrace();
66: MsgUtil.warningMsg(ex.getMessage());
67: return;
68: }
69: MsgUtil.confirmMsg(PlatformUI.getWorkbench()
70: .getActiveWorkbenchWindow().getShell(), I18N
71: .getString(Messages.IDE_BUILD_CLEAN_SUCC));
72: }
73: }
74: }
|