| Revision | 191 (tree) |
|---|---|
| Time | 2016-01-02 01:32:10 |
| Author | t_nakayama1971 |
correct ClassCastException
| @@ -1,83 +0,0 @@ | ||
| 1 | -/* | |
| 2 | - * (c) Copyright Sysdeo SA 2001, 2002. | |
| 3 | - * All Rights Reserved. | |
| 4 | - */ | |
| 5 | - | |
| 6 | -package com.sysdeo.eclipse.tomcat.actions; | |
| 7 | - | |
| 8 | -import org.eclipse.core.commands.ExecutionEvent; | |
| 9 | -import org.eclipse.core.commands.ExecutionException; | |
| 10 | -import org.eclipse.core.commands.IHandler; | |
| 11 | -import org.eclipse.core.commands.IHandlerListener; | |
| 12 | -import org.eclipse.core.runtime.CoreException; | |
| 13 | - | |
| 14 | -import com.sysdeo.eclipse.tomcat.TomcatLauncherPlugin; | |
| 15 | - | |
| 16 | -/** | |
| 17 | - * RestartActionDelegate | |
| 18 | - * | |
| 19 | - */ | |
| 20 | -public class RestartActionHandler implements IHandler { | |
| 21 | - | |
| 22 | - /** IHandlerListener */ | |
| 23 | - private IHandlerListener listener; | |
| 24 | - | |
| 25 | - /** | |
| 26 | - * @see org.eclipse.core.commands.IHandler#addHandlerListener(org.eclipse.core.commands.IHandlerListener) | |
| 27 | - */ | |
| 28 | - @Override | |
| 29 | - public void addHandlerListener(final IHandlerListener handlerListener) { | |
| 30 | - this.listener = handlerListener; | |
| 31 | - } | |
| 32 | - | |
| 33 | - /** | |
| 34 | - * @see org.eclipse.core.commands.IHandler#dispose() | |
| 35 | - */ | |
| 36 | - @Override | |
| 37 | - public void dispose() { | |
| 38 | - if (this.listener != null) { | |
| 39 | - this.listener = null; | |
| 40 | - } | |
| 41 | - } | |
| 42 | - | |
| 43 | - /** | |
| 44 | - * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) | |
| 45 | - */ | |
| 46 | - @Override | |
| 47 | - public Object execute(final ExecutionEvent event) throws ExecutionException { | |
| 48 | - if (TomcatLauncherPlugin.checkTomcatSettingsAndWarn()) { | |
| 49 | - try { | |
| 50 | - TomcatLauncherPlugin.getTomcatBootstrap().restart(); | |
| 51 | - } catch (final CoreException ex) { | |
| 52 | - String msg = TomcatLauncherPlugin.getResourceString("msg.restart.failed"); | |
| 53 | - TomcatLauncherPlugin.log(msg + "/n"); | |
| 54 | - TomcatLauncherPlugin.log(ex); | |
| 55 | - } | |
| 56 | - } | |
| 57 | - return null; | |
| 58 | - } | |
| 59 | - | |
| 60 | - /** | |
| 61 | - * @see org.eclipse.core.commands.IHandler#isEnabled() | |
| 62 | - */ | |
| 63 | - @Override | |
| 64 | - public boolean isEnabled() { | |
| 65 | - return true; | |
| 66 | - } | |
| 67 | - | |
| 68 | - /** | |
| 69 | - * @see org.eclipse.core.commands.IHandler#isHandled() | |
| 70 | - */ | |
| 71 | - @Override | |
| 72 | - public boolean isHandled() { | |
| 73 | - return true; | |
| 74 | - } | |
| 75 | - | |
| 76 | - /** | |
| 77 | - * @see org.eclipse.core.commands.IHandler#removeHandlerListener(org.eclipse.core.commands.IHandlerListener) | |
| 78 | - */ | |
| 79 | - @Override | |
| 80 | - public void removeHandlerListener(final IHandlerListener handlerListener) { | |
| 81 | - this.listener = null; | |
| 82 | - } | |
| 83 | -} |
| @@ -1,83 +0,0 @@ | ||
| 1 | -/* | |
| 2 | - * (c) Copyright Sysdeo SA 2001, 2002. | |
| 3 | - * All Rights Reserved. | |
| 4 | - */ | |
| 5 | - | |
| 6 | -package com.sysdeo.eclipse.tomcat.actions; | |
| 7 | - | |
| 8 | -import org.eclipse.core.commands.ExecutionEvent; | |
| 9 | -import org.eclipse.core.commands.ExecutionException; | |
| 10 | -import org.eclipse.core.commands.IHandler; | |
| 11 | -import org.eclipse.core.commands.IHandlerListener; | |
| 12 | -import org.eclipse.core.runtime.CoreException; | |
| 13 | - | |
| 14 | -import com.sysdeo.eclipse.tomcat.TomcatLauncherPlugin; | |
| 15 | - | |
| 16 | -/** | |
| 17 | - * StopActionDelegate | |
| 18 | - * | |
| 19 | - */ | |
| 20 | -public class StopActionHandler implements IHandler { | |
| 21 | - | |
| 22 | - /** IHandlerListener */ | |
| 23 | - private IHandlerListener listener; | |
| 24 | - | |
| 25 | - /** | |
| 26 | - * @see org.eclipse.core.commands.IHandler#addHandlerListener(org.eclipse.core.commands.IHandlerListener) | |
| 27 | - */ | |
| 28 | - @Override | |
| 29 | - public void addHandlerListener(final IHandlerListener handlerListener) { | |
| 30 | - this.listener = handlerListener; | |
| 31 | - } | |
| 32 | - | |
| 33 | - /** | |
| 34 | - * @see org.eclipse.core.commands.IHandler#dispose() | |
| 35 | - */ | |
| 36 | - @Override | |
| 37 | - public void dispose() { | |
| 38 | - if (this.listener != null) { | |
| 39 | - this.listener = null; | |
| 40 | - } | |
| 41 | - } | |
| 42 | - | |
| 43 | - /** | |
| 44 | - * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) | |
| 45 | - */ | |
| 46 | - @Override | |
| 47 | - public Object execute(final ExecutionEvent event) throws ExecutionException { | |
| 48 | - if (TomcatLauncherPlugin.checkTomcatSettingsAndWarn()) { | |
| 49 | - try { | |
| 50 | - TomcatLauncherPlugin.getTomcatBootstrap().stop(); | |
| 51 | - } catch (final CoreException ex) { | |
| 52 | - String msg = TomcatLauncherPlugin.getResourceString("msg.stop.failed"); | |
| 53 | - TomcatLauncherPlugin.log(msg + "/n"); | |
| 54 | - TomcatLauncherPlugin.log(ex); | |
| 55 | - } | |
| 56 | - } | |
| 57 | - return null; | |
| 58 | - } | |
| 59 | - | |
| 60 | - /** | |
| 61 | - * @see org.eclipse.core.commands.IHandler#isEnabled() | |
| 62 | - */ | |
| 63 | - @Override | |
| 64 | - public boolean isEnabled() { | |
| 65 | - return true; | |
| 66 | - } | |
| 67 | - | |
| 68 | - /** | |
| 69 | - * @see org.eclipse.core.commands.IHandler#isHandled() | |
| 70 | - */ | |
| 71 | - @Override | |
| 72 | - public boolean isHandled() { | |
| 73 | - return true; | |
| 74 | - } | |
| 75 | - | |
| 76 | - /** | |
| 77 | - * @see org.eclipse.core.commands.IHandler#removeHandlerListener(org.eclipse.core.commands.IHandlerListener) | |
| 78 | - */ | |
| 79 | - @Override | |
| 80 | - public void removeHandlerListener(final IHandlerListener handlerListener) { | |
| 81 | - this.listener = null; | |
| 82 | - } | |
| 83 | -} |
| @@ -1,83 +0,0 @@ | ||
| 1 | -/* | |
| 2 | - * (c) Copyright Sysdeo SA 2001, 2002. | |
| 3 | - * All Rights Reserved. | |
| 4 | - */ | |
| 5 | - | |
| 6 | -package com.sysdeo.eclipse.tomcat.actions; | |
| 7 | - | |
| 8 | -import org.eclipse.core.commands.ExecutionEvent; | |
| 9 | -import org.eclipse.core.commands.ExecutionException; | |
| 10 | -import org.eclipse.core.commands.IHandler; | |
| 11 | -import org.eclipse.core.commands.IHandlerListener; | |
| 12 | -import org.eclipse.core.runtime.CoreException; | |
| 13 | - | |
| 14 | -import com.sysdeo.eclipse.tomcat.TomcatLauncherPlugin; | |
| 15 | - | |
| 16 | -/** | |
| 17 | - * StartActionHandler | |
| 18 | - * | |
| 19 | - */ | |
| 20 | -public class StartActionHandler implements IHandler { | |
| 21 | - | |
| 22 | - /** IHandlerListener */ | |
| 23 | - private IHandlerListener listener; | |
| 24 | - | |
| 25 | - /** | |
| 26 | - * @see org.eclipse.core.commands.IHandler#addHandlerListener(org.eclipse.core.commands.IHandlerListener) | |
| 27 | - */ | |
| 28 | - @Override | |
| 29 | - public void addHandlerListener(final IHandlerListener handlerListener) { | |
| 30 | - this.listener = handlerListener; | |
| 31 | - } | |
| 32 | - | |
| 33 | - /** | |
| 34 | - * @see org.eclipse.core.commands.IHandler#dispose() | |
| 35 | - */ | |
| 36 | - @Override | |
| 37 | - public void dispose() { | |
| 38 | - if (this.listener != null) { | |
| 39 | - this.listener = null; | |
| 40 | - } | |
| 41 | - } | |
| 42 | - | |
| 43 | - /** | |
| 44 | - * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) | |
| 45 | - */ | |
| 46 | - @Override | |
| 47 | - public Object execute(final ExecutionEvent event) throws ExecutionException { | |
| 48 | - if (TomcatLauncherPlugin.checkTomcatSettingsAndWarn()) { | |
| 49 | - try { | |
| 50 | - TomcatLauncherPlugin.getTomcatBootstrap().start(); | |
| 51 | - } catch (final CoreException ex) { | |
| 52 | - String msg = TomcatLauncherPlugin.getResourceString("msg.start.failed"); | |
| 53 | - TomcatLauncherPlugin.log(msg + "/n"); | |
| 54 | - TomcatLauncherPlugin.log(ex); | |
| 55 | - } | |
| 56 | - } | |
| 57 | - return null; | |
| 58 | - } | |
| 59 | - | |
| 60 | - /** | |
| 61 | - * @see org.eclipse.core.commands.IHandler#isEnabled() | |
| 62 | - */ | |
| 63 | - @Override | |
| 64 | - public boolean isEnabled() { | |
| 65 | - return true; | |
| 66 | - } | |
| 67 | - | |
| 68 | - /** | |
| 69 | - * @see org.eclipse.core.commands.IHandler#isHandled() | |
| 70 | - */ | |
| 71 | - @Override | |
| 72 | - public boolean isHandled() { | |
| 73 | - return true; | |
| 74 | - } | |
| 75 | - | |
| 76 | - /** | |
| 77 | - * @see org.eclipse.core.commands.IHandler#removeHandlerListener(org.eclipse.core.commands.IHandlerListener) | |
| 78 | - */ | |
| 79 | - @Override | |
| 80 | - public void removeHandlerListener(final IHandlerListener handlerListener) { | |
| 81 | - this.listener = null; | |
| 82 | - } | |
| 83 | -} |
| @@ -0,0 +1,176 @@ | ||
| 1 | +/* | |
| 2 | + * (c) Copyright Sysdeo SA 2001, 2002. | |
| 3 | + * All Rights Reserved. | |
| 4 | + */ | |
| 5 | + | |
| 6 | +package com.sysdeo.eclipse.tomcat.handler; | |
| 7 | + | |
| 8 | +import org.eclipse.core.commands.ExecutionEvent; | |
| 9 | +import org.eclipse.core.commands.ExecutionException; | |
| 10 | +import org.eclipse.core.commands.IHandler; | |
| 11 | +import org.eclipse.core.commands.IHandlerListener; | |
| 12 | +import org.eclipse.core.resources.IProject; | |
| 13 | +import org.eclipse.core.runtime.CoreException; | |
| 14 | +import org.eclipse.jdt.core.IJavaProject; | |
| 15 | +import org.eclipse.jdt.internal.ui.JavaPlugin; | |
| 16 | +import org.eclipse.jface.dialogs.MessageDialog; | |
| 17 | +import org.eclipse.jface.viewers.ISelection; | |
| 18 | +import org.eclipse.jface.viewers.IStructuredSelection; | |
| 19 | +import org.eclipse.swt.widgets.Shell; | |
| 20 | +import org.eclipse.ui.IWorkbenchWindow; | |
| 21 | + | |
| 22 | +import com.sysdeo.eclipse.tomcat.TomcatLauncherPlugin; | |
| 23 | +import com.sysdeo.eclipse.tomcat.TomcatProject; | |
| 24 | +import com.sysdeo.eclipse.tomcat.actions.TomcatActionException; | |
| 25 | + | |
| 26 | +/** | |
| 27 | + * TomcatProjectAbstractActionDelegate | |
| 28 | + * | |
| 29 | + */ | |
| 30 | +public abstract class TomcatProjectAbstractActionHandler implements IHandler { | |
| 31 | + | |
| 32 | + /** IHandlerListener */ | |
| 33 | + private IHandlerListener listener; | |
| 34 | + /** msg */ | |
| 35 | + private String msg; | |
| 36 | + /** showMessageBox */ | |
| 37 | + private boolean showMessageBox = true; | |
| 38 | + | |
| 39 | + /** | |
| 40 | + * @return the showMessageBox | |
| 41 | + */ | |
| 42 | + protected boolean isShowMessageBox() { | |
| 43 | + return this.showMessageBox; | |
| 44 | + } | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * @param show the showMessageBox to set | |
| 48 | + */ | |
| 49 | + protected void setShowMessageBox(final boolean show) { | |
| 50 | + this.showMessageBox = show; | |
| 51 | + } | |
| 52 | + | |
| 53 | + /** | |
| 54 | + * @see org.eclipse.core.commands.IHandler#dispose() | |
| 55 | + */ | |
| 56 | + @Override | |
| 57 | + public void dispose() { | |
| 58 | + if (this.listener != null) { | |
| 59 | + this.listener = null; | |
| 60 | + } | |
| 61 | + } | |
| 62 | + | |
| 63 | + /** | |
| 64 | + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) | |
| 65 | + */ | |
| 66 | + @Override | |
| 67 | + public Object execute(final ExecutionEvent event) throws ExecutionException { | |
| 68 | + setMsgToSuccess(); | |
| 69 | + try { | |
| 70 | + TomcatProject prj = getCurrentSelection(); | |
| 71 | + if (prj != null) { | |
| 72 | + doActionOn(prj); | |
| 73 | + } | |
| 74 | + } catch (final TomcatActionException ex) { | |
| 75 | + setMsgToFail(ex.getMessage(), false); | |
| 76 | + } catch (final CoreException ex) { | |
| 77 | + TomcatLauncherPlugin.log(ex); | |
| 78 | + setMsgToFail(ex.getMessage(), true); | |
| 79 | + } | |
| 80 | + | |
| 81 | + if (this.showMessageBox) { | |
| 82 | + Shell shell = TomcatLauncherPlugin.getShell(); | |
| 83 | + MessageDialog.openInformation(shell, "Tomcat", this.msg); | |
| 84 | + } | |
| 85 | + return null; | |
| 86 | + } | |
| 87 | + | |
| 88 | + /** | |
| 89 | + * | |
| 90 | + * @return TomcatProject | |
| 91 | + */ | |
| 92 | + protected TomcatProject getCurrentSelection() { | |
| 93 | + return getProject(); | |
| 94 | + } | |
| 95 | + | |
| 96 | + /** | |
| 97 | + * | |
| 98 | + * @param prj TomcatProject | |
| 99 | + * @throws CoreException CoreException | |
| 100 | + */ | |
| 101 | + public abstract void doActionOn(final TomcatProject prj) throws CoreException; | |
| 102 | + | |
| 103 | + | |
| 104 | + /** | |
| 105 | + * @return TomcatProject | |
| 106 | + */ | |
| 107 | + private TomcatProject getProject() { | |
| 108 | + IWorkbenchWindow win = JavaPlugin.getActiveWorkbenchWindow(); | |
| 109 | + TomcatProject result = null; | |
| 110 | + if (win != null) { | |
| 111 | + ISelection selection = win.getSelectionService().getSelection(); | |
| 112 | + if (selection instanceof IStructuredSelection) { | |
| 113 | + Object project = ((IStructuredSelection)selection).getFirstElement(); | |
| 114 | + if (project instanceof IProject) { | |
| 115 | + result = TomcatProject.create((IProject)project); | |
| 116 | + } else if (project instanceof IJavaProject) { | |
| 117 | + result = TomcatProject.create((IJavaProject)project); | |
| 118 | + } | |
| 119 | + } | |
| 120 | + } | |
| 121 | + return result; | |
| 122 | + } | |
| 123 | + | |
| 124 | + /** | |
| 125 | + * Sets the msg. | |
| 126 | + * @param detail String | |
| 127 | + * @param seelog boolean | |
| 128 | + */ | |
| 129 | + private void setMsgToFail(final String detail, final boolean seelog) { | |
| 130 | + this.msg = TomcatLauncherPlugin.getResourceString("msg.action.failed"); | |
| 131 | + this.msg += "\n"; | |
| 132 | + this.msg += detail; | |
| 133 | + if (seelog) { | |
| 134 | + this.msg += TomcatLauncherPlugin.getResourceString("msg.action.seelog"); | |
| 135 | + } | |
| 136 | + } | |
| 137 | + | |
| 138 | + /** | |
| 139 | + * Sets the msg. | |
| 140 | + */ | |
| 141 | + private void setMsgToSuccess() { | |
| 142 | + this.msg = TomcatLauncherPlugin.getResourceString("msg.action.succeeded"); | |
| 143 | + } | |
| 144 | + | |
| 145 | + /** | |
| 146 | + * @see org.eclipse.core.commands.IHandler#addHandlerListener(org.eclipse.core.commands.IHandlerListener) | |
| 147 | + */ | |
| 148 | + @Override | |
| 149 | + public void addHandlerListener(final IHandlerListener handlerListener) { | |
| 150 | + this.listener = handlerListener; | |
| 151 | + } | |
| 152 | + | |
| 153 | + /** | |
| 154 | + * @see org.eclipse.core.commands.IHandler#isEnabled() | |
| 155 | + */ | |
| 156 | + @Override | |
| 157 | + public boolean isEnabled() { | |
| 158 | + return true; | |
| 159 | + } | |
| 160 | + | |
| 161 | + /** | |
| 162 | + * @see org.eclipse.core.commands.IHandler#isHandled() | |
| 163 | + */ | |
| 164 | + @Override | |
| 165 | + public boolean isHandled() { | |
| 166 | + return true; | |
| 167 | + } | |
| 168 | + | |
| 169 | + /** | |
| 170 | + * @see org.eclipse.core.commands.IHandler#removeHandlerListener(org.eclipse.core.commands.IHandlerListener) | |
| 171 | + */ | |
| 172 | + @Override | |
| 173 | + public void removeHandlerListener(final IHandlerListener handlerListener) { | |
| 174 | + this.listener = null; | |
| 175 | + } | |
| 176 | +} |
| @@ -0,0 +1,83 @@ | ||
| 1 | +/* | |
| 2 | + * (c) Copyright Sysdeo SA 2001, 2002. | |
| 3 | + * All Rights Reserved. | |
| 4 | + */ | |
| 5 | + | |
| 6 | +package com.sysdeo.eclipse.tomcat.handler; | |
| 7 | + | |
| 8 | +import org.eclipse.core.commands.ExecutionEvent; | |
| 9 | +import org.eclipse.core.commands.ExecutionException; | |
| 10 | +import org.eclipse.core.commands.IHandler; | |
| 11 | +import org.eclipse.core.commands.IHandlerListener; | |
| 12 | +import org.eclipse.core.runtime.CoreException; | |
| 13 | + | |
| 14 | +import com.sysdeo.eclipse.tomcat.TomcatLauncherPlugin; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * RestartActionDelegate | |
| 18 | + * | |
| 19 | + */ | |
| 20 | +public class RestartActionHandler implements IHandler { | |
| 21 | + | |
| 22 | + /** IHandlerListener */ | |
| 23 | + private IHandlerListener listener; | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * @see org.eclipse.core.commands.IHandler#addHandlerListener(org.eclipse.core.commands.IHandlerListener) | |
| 27 | + */ | |
| 28 | + @Override | |
| 29 | + public void addHandlerListener(final IHandlerListener handlerListener) { | |
| 30 | + this.listener = handlerListener; | |
| 31 | + } | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * @see org.eclipse.core.commands.IHandler#dispose() | |
| 35 | + */ | |
| 36 | + @Override | |
| 37 | + public void dispose() { | |
| 38 | + if (this.listener != null) { | |
| 39 | + this.listener = null; | |
| 40 | + } | |
| 41 | + } | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) | |
| 45 | + */ | |
| 46 | + @Override | |
| 47 | + public Object execute(final ExecutionEvent event) throws ExecutionException { | |
| 48 | + if (TomcatLauncherPlugin.checkTomcatSettingsAndWarn()) { | |
| 49 | + try { | |
| 50 | + TomcatLauncherPlugin.getTomcatBootstrap().restart(); | |
| 51 | + } catch (final CoreException ex) { | |
| 52 | + String msg = TomcatLauncherPlugin.getResourceString("msg.restart.failed"); | |
| 53 | + TomcatLauncherPlugin.log(msg + "/n"); | |
| 54 | + TomcatLauncherPlugin.log(ex); | |
| 55 | + } | |
| 56 | + } | |
| 57 | + return null; | |
| 58 | + } | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * @see org.eclipse.core.commands.IHandler#isEnabled() | |
| 62 | + */ | |
| 63 | + @Override | |
| 64 | + public boolean isEnabled() { | |
| 65 | + return true; | |
| 66 | + } | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * @see org.eclipse.core.commands.IHandler#isHandled() | |
| 70 | + */ | |
| 71 | + @Override | |
| 72 | + public boolean isHandled() { | |
| 73 | + return true; | |
| 74 | + } | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * @see org.eclipse.core.commands.IHandler#removeHandlerListener(org.eclipse.core.commands.IHandlerListener) | |
| 78 | + */ | |
| 79 | + @Override | |
| 80 | + public void removeHandlerListener(final IHandlerListener handlerListener) { | |
| 81 | + this.listener = null; | |
| 82 | + } | |
| 83 | +} |
| @@ -0,0 +1,83 @@ | ||
| 1 | +/* | |
| 2 | + * (c) Copyright Sysdeo SA 2001, 2002. | |
| 3 | + * All Rights Reserved. | |
| 4 | + */ | |
| 5 | + | |
| 6 | +package com.sysdeo.eclipse.tomcat.handler; | |
| 7 | + | |
| 8 | +import org.eclipse.core.commands.ExecutionEvent; | |
| 9 | +import org.eclipse.core.commands.ExecutionException; | |
| 10 | +import org.eclipse.core.commands.IHandler; | |
| 11 | +import org.eclipse.core.commands.IHandlerListener; | |
| 12 | +import org.eclipse.core.runtime.CoreException; | |
| 13 | + | |
| 14 | +import com.sysdeo.eclipse.tomcat.TomcatLauncherPlugin; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * StopActionDelegate | |
| 18 | + * | |
| 19 | + */ | |
| 20 | +public class StopActionHandler implements IHandler { | |
| 21 | + | |
| 22 | + /** IHandlerListener */ | |
| 23 | + private IHandlerListener listener; | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * @see org.eclipse.core.commands.IHandler#addHandlerListener(org.eclipse.core.commands.IHandlerListener) | |
| 27 | + */ | |
| 28 | + @Override | |
| 29 | + public void addHandlerListener(final IHandlerListener handlerListener) { | |
| 30 | + this.listener = handlerListener; | |
| 31 | + } | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * @see org.eclipse.core.commands.IHandler#dispose() | |
| 35 | + */ | |
| 36 | + @Override | |
| 37 | + public void dispose() { | |
| 38 | + if (this.listener != null) { | |
| 39 | + this.listener = null; | |
| 40 | + } | |
| 41 | + } | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) | |
| 45 | + */ | |
| 46 | + @Override | |
| 47 | + public Object execute(final ExecutionEvent event) throws ExecutionException { | |
| 48 | + if (TomcatLauncherPlugin.checkTomcatSettingsAndWarn()) { | |
| 49 | + try { | |
| 50 | + TomcatLauncherPlugin.getTomcatBootstrap().stop(); | |
| 51 | + } catch (final CoreException ex) { | |
| 52 | + String msg = TomcatLauncherPlugin.getResourceString("msg.stop.failed"); | |
| 53 | + TomcatLauncherPlugin.log(msg + "/n"); | |
| 54 | + TomcatLauncherPlugin.log(ex); | |
| 55 | + } | |
| 56 | + } | |
| 57 | + return null; | |
| 58 | + } | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * @see org.eclipse.core.commands.IHandler#isEnabled() | |
| 62 | + */ | |
| 63 | + @Override | |
| 64 | + public boolean isEnabled() { | |
| 65 | + return true; | |
| 66 | + } | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * @see org.eclipse.core.commands.IHandler#isHandled() | |
| 70 | + */ | |
| 71 | + @Override | |
| 72 | + public boolean isHandled() { | |
| 73 | + return true; | |
| 74 | + } | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * @see org.eclipse.core.commands.IHandler#removeHandlerListener(org.eclipse.core.commands.IHandlerListener) | |
| 78 | + */ | |
| 79 | + @Override | |
| 80 | + public void removeHandlerListener(final IHandlerListener handlerListener) { | |
| 81 | + this.listener = null; | |
| 82 | + } | |
| 83 | +} |
| @@ -0,0 +1,40 @@ | ||
| 1 | +/* | |
| 2 | + * (c) Copyright Sysdeo SA 2001, 2002. | |
| 3 | + * All Rights Reserved. | |
| 4 | + */ | |
| 5 | + | |
| 6 | +package com.sysdeo.eclipse.tomcat.handler; | |
| 7 | + | |
| 8 | +import org.eclipse.core.runtime.CoreException; | |
| 9 | + | |
| 10 | +import com.sysdeo.eclipse.tomcat.TomcatLauncherPlugin; | |
| 11 | +import com.sysdeo.eclipse.tomcat.TomcatProject; | |
| 12 | +import com.sysdeo.eclipse.tomcat.actions.TomcatActionException; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * CreateJSPWorkDirectoryActionDelegate | |
| 16 | + * | |
| 17 | + */ | |
| 18 | +public class CreateJSPWorkDirectoryActionHandler extends TomcatProjectAbstractActionHandler { | |
| 19 | + | |
| 20 | + /** | |
| 21 | + * @see com.sysdeo.eclipse.tomcat.actions.TomcatProjectAbstractActionDelegate | |
| 22 | + * #doActionOn(com.sysdeo.eclipse.tomcat.TomcatProject) | |
| 23 | + */ | |
| 24 | + @Override | |
| 25 | + public void doActionOn(final TomcatProject prj) throws CoreException { | |
| 26 | + prj.createWorkFolder(); | |
| 27 | + try { | |
| 28 | + prj.setWorkAsSourceFolder(); | |
| 29 | + } catch (final CoreException ex) { | |
| 30 | + TomcatLauncherPlugin.log(ex.getMessage()); | |
| 31 | + } | |
| 32 | + | |
| 33 | + if (prj.getUpdateXml()) { | |
| 34 | + prj.updateContext(); | |
| 35 | + } else { | |
| 36 | + throw new TomcatActionException( | |
| 37 | + TomcatLauncherPlugin.getResourceString("msg.action.updateServerXML.failed")); | |
| 38 | + } | |
| 39 | + } | |
| 40 | +} |
| @@ -0,0 +1,66 @@ | ||
| 1 | +/* | |
| 2 | + * (c) Copyright Sysdeo SA 2001, 2002. | |
| 3 | + * All Rights Reserved. | |
| 4 | + */ | |
| 5 | + | |
| 6 | +package com.sysdeo.eclipse.tomcat.handler; | |
| 7 | + | |
| 8 | +import java.io.IOException; | |
| 9 | +import java.net.Authenticator; | |
| 10 | +import java.net.HttpURLConnection; | |
| 11 | +import java.net.PasswordAuthentication; | |
| 12 | +import java.net.URL; | |
| 13 | + | |
| 14 | +import org.eclipse.core.runtime.CoreException; | |
| 15 | + | |
| 16 | +import com.sysdeo.eclipse.tomcat.TomcatLauncherPlugin; | |
| 17 | +import com.sysdeo.eclipse.tomcat.TomcatProject; | |
| 18 | +import com.sysdeo.eclipse.tomcat.actions.TomcatActionException; | |
| 19 | + | |
| 20 | +/** | |
| 21 | + * RestartContextActionDelegate | |
| 22 | + * | |
| 23 | + */ | |
| 24 | +public class RestartContextActionHandler extends TomcatProjectAbstractActionHandler { | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * @see com.sysdeo.eclipse.tomcat.actions.TomcatProjectAbstractActionDelegate | |
| 28 | + * #doActionOn(com.sysdeo.eclipse.tomcat.TomcatProject) | |
| 29 | + */ | |
| 30 | + @Override | |
| 31 | + public void doActionOn(final TomcatProject prj) throws CoreException { | |
| 32 | + String path = TomcatLauncherPlugin.getManagerAppUrl(); | |
| 33 | + path += "/reload?path=" + prj.getWebPath(); | |
| 34 | + | |
| 35 | + Authenticator.setDefault(new PasswordAuthenticator()); | |
| 36 | + | |
| 37 | + try { | |
| 38 | + URL url = new URL(path); | |
| 39 | + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); | |
| 40 | + connection.getContent(); | |
| 41 | + connection.disconnect(); | |
| 42 | + Authenticator.setDefault(null); | |
| 43 | + | |
| 44 | + } catch (final IOException e) { | |
| 45 | + throw new TomcatActionException(e.getMessage() | |
| 46 | + + "The following url was used : \n" + path | |
| 47 | + + "\n\nCheck manager app settings (username and password)\n\n"); | |
| 48 | + } | |
| 49 | + } | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * PasswordAuthenticator | |
| 53 | + * | |
| 54 | + */ | |
| 55 | + static final class PasswordAuthenticator extends Authenticator { | |
| 56 | + /** | |
| 57 | + * @see java.net.Authenticator#getPasswordAuthentication() | |
| 58 | + */ | |
| 59 | + @Override | |
| 60 | + protected PasswordAuthentication getPasswordAuthentication() { | |
| 61 | + String user = TomcatLauncherPlugin.getManagerAppUser(); | |
| 62 | + String password = TomcatLauncherPlugin.getManagerAppPassword(); | |
| 63 | + return new PasswordAuthentication(user, password.toCharArray()); | |
| 64 | + } | |
| 65 | + } | |
| 66 | +} |
| @@ -0,0 +1,34 @@ | ||
| 1 | +/* | |
| 2 | + * (c) Copyright Sysdeo SA 2001, 2002. | |
| 3 | + * All Rights Reserved. | |
| 4 | + */ | |
| 5 | + | |
| 6 | +package com.sysdeo.eclipse.tomcat.handler; | |
| 7 | + | |
| 8 | +import org.eclipse.core.runtime.CoreException; | |
| 9 | + | |
| 10 | +import com.sysdeo.eclipse.tomcat.TomcatLauncherPlugin; | |
| 11 | +import com.sysdeo.eclipse.tomcat.TomcatProject; | |
| 12 | +import com.sysdeo.eclipse.tomcat.actions.TomcatActionException; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * RemoveTomcatContextActionDelegate | |
| 16 | + * | |
| 17 | + */ | |
| 18 | +public class RemoveTomcatContextActionHandler extends TomcatProjectAbstractActionHandler { | |
| 19 | + | |
| 20 | + /** | |
| 21 | + * @see com.sysdeo.eclipse.tomcat.actions.TomcatProjectAbstractActionDelegate | |
| 22 | + * #doActionOn(com.sysdeo.eclipse.tomcat.TomcatProject) | |
| 23 | + */ | |
| 24 | + @Override | |
| 25 | + public void doActionOn(final TomcatProject prj) throws CoreException { | |
| 26 | + | |
| 27 | + if (prj.getUpdateXml()) { | |
| 28 | + prj.removeContext(); | |
| 29 | + } else { | |
| 30 | + throw new TomcatActionException( | |
| 31 | + TomcatLauncherPlugin.getResourceString("msg.action.updateServerXML.failed")); | |
| 32 | + } | |
| 33 | + } | |
| 34 | +} |
| @@ -0,0 +1,27 @@ | ||
| 1 | +/* | |
| 2 | + * (c) Copyright Sysdeo SA 2001, 2002. | |
| 3 | + * All Rights Reserved. | |
| 4 | + */ | |
| 5 | + | |
| 6 | +package com.sysdeo.eclipse.tomcat.handler; | |
| 7 | + | |
| 8 | +import org.eclipse.core.runtime.CoreException; | |
| 9 | + | |
| 10 | +import com.sysdeo.eclipse.tomcat.TomcatProject; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * AddTomcatJarActionDelegate | |
| 14 | + * | |
| 15 | + */ | |
| 16 | +public class AddTomcatJarActionHandler extends TomcatProjectAbstractActionHandler { | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * @see com.sysdeo.eclipse.tomcat.actions.TomcatProjectAbstractActionDelegate | |
| 20 | + * #doActionOn(com.sysdeo.eclipse.tomcat.TomcatProject) | |
| 21 | + */ | |
| 22 | + @Override | |
| 23 | + public void doActionOn(final TomcatProject prj) throws CoreException { | |
| 24 | + prj.addTomcatJarToProjectClasspath(); | |
| 25 | + } | |
| 26 | + | |
| 27 | +} |
| @@ -0,0 +1,83 @@ | ||
| 1 | +/* | |
| 2 | + * (c) Copyright Sysdeo SA 2001, 2002. | |
| 3 | + * All Rights Reserved. | |
| 4 | + */ | |
| 5 | + | |
| 6 | +package com.sysdeo.eclipse.tomcat.handler; | |
| 7 | + | |
| 8 | +import org.eclipse.core.commands.ExecutionEvent; | |
| 9 | +import org.eclipse.core.commands.ExecutionException; | |
| 10 | +import org.eclipse.core.commands.IHandler; | |
| 11 | +import org.eclipse.core.commands.IHandlerListener; | |
| 12 | +import org.eclipse.core.runtime.CoreException; | |
| 13 | + | |
| 14 | +import com.sysdeo.eclipse.tomcat.TomcatLauncherPlugin; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * StartActionHandler | |
| 18 | + * | |
| 19 | + */ | |
| 20 | +public class StartActionHandler implements IHandler { | |
| 21 | + | |
| 22 | + /** IHandlerListener */ | |
| 23 | + private IHandlerListener listener; | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * @see org.eclipse.core.commands.IHandler#addHandlerListener(org.eclipse.core.commands.IHandlerListener) | |
| 27 | + */ | |
| 28 | + @Override | |
| 29 | + public void addHandlerListener(final IHandlerListener handlerListener) { | |
| 30 | + this.listener = handlerListener; | |
| 31 | + } | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * @see org.eclipse.core.commands.IHandler#dispose() | |
| 35 | + */ | |
| 36 | + @Override | |
| 37 | + public void dispose() { | |
| 38 | + if (this.listener != null) { | |
| 39 | + this.listener = null; | |
| 40 | + } | |
| 41 | + } | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) | |
| 45 | + */ | |
| 46 | + @Override | |
| 47 | + public Object execute(final ExecutionEvent event) throws ExecutionException { | |
| 48 | + if (TomcatLauncherPlugin.checkTomcatSettingsAndWarn()) { | |
| 49 | + try { | |
| 50 | + TomcatLauncherPlugin.getTomcatBootstrap().start(); | |
| 51 | + } catch (final CoreException ex) { | |
| 52 | + String msg = TomcatLauncherPlugin.getResourceString("msg.start.failed"); | |
| 53 | + TomcatLauncherPlugin.log(msg + "/n"); | |
| 54 | + TomcatLauncherPlugin.log(ex); | |
| 55 | + } | |
| 56 | + } | |
| 57 | + return null; | |
| 58 | + } | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * @see org.eclipse.core.commands.IHandler#isEnabled() | |
| 62 | + */ | |
| 63 | + @Override | |
| 64 | + public boolean isEnabled() { | |
| 65 | + return true; | |
| 66 | + } | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * @see org.eclipse.core.commands.IHandler#isHandled() | |
| 70 | + */ | |
| 71 | + @Override | |
| 72 | + public boolean isHandled() { | |
| 73 | + return true; | |
| 74 | + } | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * @see org.eclipse.core.commands.IHandler#removeHandlerListener(org.eclipse.core.commands.IHandlerListener) | |
| 78 | + */ | |
| 79 | + @Override | |
| 80 | + public void removeHandlerListener(final IHandlerListener handlerListener) { | |
| 81 | + this.listener = null; | |
| 82 | + } | |
| 83 | +} |
| @@ -0,0 +1,40 @@ | ||
| 1 | +/* | |
| 2 | + * (c) Copyright Sysdeo SA 2001, 2002. | |
| 3 | + * All Rights Reserved. | |
| 4 | + */ | |
| 5 | + | |
| 6 | +package com.sysdeo.eclipse.tomcat.handler; | |
| 7 | + | |
| 8 | +import java.io.IOException; | |
| 9 | + | |
| 10 | +import org.eclipse.core.runtime.CoreException; | |
| 11 | + | |
| 12 | +import com.sysdeo.eclipse.tomcat.TomcatLauncherPlugin; | |
| 13 | +import com.sysdeo.eclipse.tomcat.TomcatProject; | |
| 14 | +import com.sysdeo.eclipse.tomcat.actions.TomcatActionException; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * ExportToWarActionDelegate | |
| 18 | + * | |
| 19 | + */ | |
| 20 | +public class ExportToWarActionHandler extends TomcatProjectAbstractActionHandler { | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * @see com.sysdeo.eclipse.tomcat.actions.TomcatProjectAbstractActionDelegate | |
| 24 | + * #doActionOn(com.sysdeo.eclipse.tomcat.TomcatProject) | |
| 25 | + */ | |
| 26 | + @Override | |
| 27 | + public void doActionOn(final TomcatProject prj) throws CoreException { | |
| 28 | + | |
| 29 | + if (!prj.getWarLocation().isEmpty()) { | |
| 30 | + try { | |
| 31 | + prj.exportToWar(); | |
| 32 | + } catch (final IOException ex) { | |
| 33 | + throw new TomcatActionException(ex.getMessage()); | |
| 34 | + } | |
| 35 | + } else { | |
| 36 | + throw new TomcatActionException( | |
| 37 | + TomcatLauncherPlugin.getResourceString("msg.action.exportWAR.failed")); | |
| 38 | + } | |
| 39 | + } | |
| 40 | +} |
| @@ -0,0 +1,34 @@ | ||
| 1 | +/* | |
| 2 | + * (c) Copyright Sysdeo SA 2001, 2002. | |
| 3 | + * All Rights Reserved. | |
| 4 | + */ | |
| 5 | + | |
| 6 | +package com.sysdeo.eclipse.tomcat.handler; | |
| 7 | + | |
| 8 | +import org.eclipse.core.runtime.CoreException; | |
| 9 | + | |
| 10 | +import com.sysdeo.eclipse.tomcat.TomcatLauncherPlugin; | |
| 11 | +import com.sysdeo.eclipse.tomcat.TomcatProject; | |
| 12 | +import com.sysdeo.eclipse.tomcat.actions.TomcatActionException; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * UpdateTomcatContextActionDelegate | |
| 16 | + * | |
| 17 | + */ | |
| 18 | +public class UpdateTomcatContextActionHandler extends TomcatProjectAbstractActionHandler { | |
| 19 | + | |
| 20 | + /** | |
| 21 | + * @see com.sysdeo.eclipse.tomcat.actions.TomcatProjectAbstractActionDelegate | |
| 22 | + * #doActionOn(com.sysdeo.eclipse.tomcat.TomcatProject) | |
| 23 | + */ | |
| 24 | + @Override | |
| 25 | + public void doActionOn(final TomcatProject prj) throws CoreException { | |
| 26 | + | |
| 27 | + if (prj.getUpdateXml()) { | |
| 28 | + prj.updateContext(); | |
| 29 | + } else { | |
| 30 | + throw new TomcatActionException( | |
| 31 | + TomcatLauncherPlugin.getResourceString("msg.action.updateServerXML.failed")); | |
| 32 | + } | |
| 33 | + } | |
| 34 | +} |
| @@ -25,15 +25,15 @@ | ||
| 25 | 25 | <extension point="org.eclipse.ui.handlers"> |
| 26 | 26 | <handler |
| 27 | 27 | commandId="com.sysdeo.eclipse.tomcat.start" |
| 28 | - class="com.sysdeo.eclipse.tomcat.actions.StartActionHandler" | |
| 28 | + class="com.sysdeo.eclipse.tomcat.handler.StartActionHandler" | |
| 29 | 29 | /> |
| 30 | 30 | <handler |
| 31 | 31 | commandId="com.sysdeo.eclipse.tomcat.stop" |
| 32 | - class="com.sysdeo.eclipse.tomcat.actions.StopActionHandler" | |
| 32 | + class="com.sysdeo.eclipse.tomcat.handler.StopActionHandler" | |
| 33 | 33 | /> |
| 34 | 34 | <handler |
| 35 | 35 | commandId="com.sysdeo.eclipse.tomcat.restart" |
| 36 | - class="com.sysdeo.eclipse.tomcat.actions.RestartActionHandler" | |
| 36 | + class="com.sysdeo.eclipse.tomcat.handler.RestartActionHandler" | |
| 37 | 37 | /> |
| 38 | 38 | </extension> |
| 39 | 39 |
| @@ -197,27 +197,27 @@ | ||
| 197 | 197 | <extension point="org.eclipse.ui.handlers"> |
| 198 | 198 | <handler |
| 199 | 199 | commandId="com.sysdeo.eclipse.tomcat.createWork" |
| 200 | - class="com.sysdeo.eclipse.tomcat.actions.CreateJSPWorkDirectoryActionDelegate" | |
| 200 | + class="com.sysdeo.eclipse.tomcat.handler.CreateJSPWorkDirectoryActionHandler" | |
| 201 | 201 | /> |
| 202 | 202 | <handler |
| 203 | 203 | commandId="com.sysdeo.eclipse.tomcat.addTomcatJar" |
| 204 | - class="com.sysdeo.eclipse.tomcat.actions.AddTomcatJarActionDelegate" | |
| 204 | + class="com.sysdeo.eclipse.tomcat.handler.AddTomcatJarActionHandler" | |
| 205 | 205 | /> |
| 206 | 206 | <handler |
| 207 | 207 | commandId="com.sysdeo.eclipse.tomcat.updateContext" |
| 208 | - class="com.sysdeo.eclipse.tomcat.actions.UpdateTomcatContextActionDelegate" | |
| 208 | + class="com.sysdeo.eclipse.tomcat.handler.UpdateTomcatContextActionHandler" | |
| 209 | 209 | /> |
| 210 | 210 | <handler |
| 211 | 211 | commandId="com.sysdeo.eclipse.tomcat.removeContext" |
| 212 | - class="com.sysdeo.eclipse.tomcat.actions.RemoveTomcatContextActionDelegate" | |
| 212 | + class="com.sysdeo.eclipse.tomcat.handler.RemoveTomcatContextActionHandler" | |
| 213 | 213 | /> |
| 214 | 214 | <handler |
| 215 | 215 | commandId="com.sysdeo.eclipse.tomcat.exportToWar" |
| 216 | - class="com.sysdeo.eclipse.tomcat.actions.ExportToWarActionDelegate" | |
| 216 | + class="com.sysdeo.eclipse.tomcat.handler.ExportToWarActionHandler" | |
| 217 | 217 | /> |
| 218 | 218 | <handler |
| 219 | 219 | commandId="com.sysdeo.eclipse.tomcat.restartContext" |
| 220 | - class="com.sysdeo.eclipse.tomcat.actions.RestartContextActionDelegate" | |
| 220 | + class="com.sysdeo.eclipse.tomcat.handler.RestartContextActionHandler" | |
| 221 | 221 | /> |
| 222 | 222 | </extension> |
| 223 | 223 |