| Revision | 18 (tree) |
|---|---|
| Time | 2015-08-17 15:31:07 |
| Author | t_nakayama1971 |
(empty log message)
| @@ -0,0 +1,70 @@ | ||
| 1 | +package online.plugin.actiongenerate.popup.actions; | |
| 2 | + | |
| 3 | + | |
| 4 | +import java.util.List; | |
| 5 | + | |
| 6 | +import online.plugin.actiongenerate.wizards.ActionGenerateWizard; | |
| 7 | + | |
| 8 | +import org.eclipse.core.resources.IFile; | |
| 9 | +import org.eclipse.jface.action.IAction; | |
| 10 | +import org.eclipse.jface.viewers.ISelection; | |
| 11 | +import org.eclipse.jface.viewers.IStructuredSelection; | |
| 12 | +import org.eclipse.jface.wizard.WizardDialog; | |
| 13 | +import org.eclipse.ui.IObjectActionDelegate; | |
| 14 | +import org.eclipse.ui.IWorkbench; | |
| 15 | +import org.eclipse.ui.IWorkbenchPart; | |
| 16 | +import org.eclipse.ui.PlatformUI; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * アクション生成クラス | |
| 20 | + * | |
| 21 | + * @author Tadashi Nakayama | |
| 22 | + * @version 1.0.0 | |
| 23 | + */ | |
| 24 | +public final class GenerateAction implements IObjectActionDelegate { | |
| 25 | + | |
| 26 | + /** ターゲット */ | |
| 27 | + private IWorkbenchPart workbench; | |
| 28 | + /** ターゲットファイルリスト */ | |
| 29 | + private List<IFile> flist; | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * Constructor. | |
| 33 | + */ | |
| 34 | + public GenerateAction() { | |
| 35 | + super(); | |
| 36 | + } | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) | |
| 40 | + */ | |
| 41 | + public void setActivePart(final IAction action, final IWorkbenchPart targetPart) { | |
| 42 | + this.workbench = targetPart; | |
| 43 | + } | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * @see IObjectActionDelegate#run(IAction) | |
| 47 | + */ | |
| 48 | + public void run(final IAction action) { | |
| 49 | + | |
| 50 | + IWorkbench wb = PlatformUI.getWorkbench(); | |
| 51 | + wb.saveAllEditors(false); | |
| 52 | + | |
| 53 | + if (this.flist != null) { | |
| 54 | + WizardDialog wd = new WizardDialog(this.workbench.getSite().getShell(), | |
| 55 | + new ActionGenerateWizard(this.flist)); | |
| 56 | + wd.open(); | |
| 57 | + } | |
| 58 | + } | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * @see IObjectActionDelegate#selectionChanged(IAction, ISelection) | |
| 62 | + */ | |
| 63 | + @SuppressWarnings("unchecked") | |
| 64 | + public void selectionChanged(final IAction action, final ISelection selection) { | |
| 65 | + this.flist = null; | |
| 66 | + if (selection instanceof IStructuredSelection) { | |
| 67 | + this.flist = ((IStructuredSelection)selection).toList(); | |
| 68 | + } | |
| 69 | + } | |
| 70 | +} |
| @@ -0,0 +1,41 @@ | ||
| 1 | +package online.plugin.actiongenerate.wizards; | |
| 2 | + | |
| 3 | +import org.eclipse.jface.viewers.IStructuredSelection; | |
| 4 | +import org.eclipse.jface.wizard.Wizard; | |
| 5 | +import org.eclipse.ui.INewWizard; | |
| 6 | +import org.eclipse.ui.IWorkbench; | |
| 7 | + | |
| 8 | +public final class GenerateWizard extends Wizard implements INewWizard { | |
| 9 | + | |
| 10 | + /** | |
| 11 | + * コンストラクタ | |
| 12 | + */ | |
| 13 | + public GenerateWizard() { | |
| 14 | + setWindowTitle("新ウィザード"); | |
| 15 | + } | |
| 16 | + | |
| 17 | + /** | |
| 18 | + * @see org.eclipse.jface.wizard.Wizard#addPages() | |
| 19 | + */ | |
| 20 | + @Override | |
| 21 | + public void addPages() { | |
| 22 | + addPage(new GenerateWizardPage()); | |
| 23 | + } | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * @see org.eclipse.jface.wizard.Wizard#performFinish() | |
| 27 | + */ | |
| 28 | + @Override | |
| 29 | + public boolean performFinish() { | |
| 30 | + return true; | |
| 31 | + } | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * @see org.eclipse.ui.IWorkbenchWizard | |
| 35 | + * #init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) | |
| 36 | + */ | |
| 37 | + @Override | |
| 38 | + public void init(final IWorkbench workbench, final IStructuredSelection selection) { | |
| 39 | + // NOP | |
| 40 | + } | |
| 41 | +} |
| @@ -0,0 +1,249 @@ | ||
| 1 | +package online.plugin.actiongenerate.wizards; | |
| 2 | + | |
| 3 | +import java.io.BufferedReader; | |
| 4 | +import java.io.File; | |
| 5 | +import java.io.FileReader; | |
| 6 | +import java.io.IOException; | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +import javax.swing.text.html.parser.ParserDelegator; | |
| 10 | + | |
| 11 | +import online.plugin.actiongenerate.ParserCallback; | |
| 12 | + | |
| 13 | +import org.eclipse.core.resources.IFile; | |
| 14 | +import org.eclipse.jface.dialogs.MessageDialog; | |
| 15 | +import org.eclipse.jface.wizard.WizardPage; | |
| 16 | +import org.eclipse.swt.SWT; | |
| 17 | +import org.eclipse.swt.events.ModifyEvent; | |
| 18 | +import org.eclipse.swt.events.ModifyListener; | |
| 19 | +import org.eclipse.swt.events.SelectionEvent; | |
| 20 | +import org.eclipse.swt.events.SelectionListener; | |
| 21 | +import org.eclipse.swt.layout.FillLayout; | |
| 22 | +import org.eclipse.swt.layout.GridData; | |
| 23 | +import org.eclipse.swt.layout.GridLayout; | |
| 24 | +import org.eclipse.swt.widgets.Button; | |
| 25 | +import org.eclipse.swt.widgets.Composite; | |
| 26 | +import org.eclipse.swt.widgets.Group; | |
| 27 | +import org.eclipse.swt.widgets.Label; | |
| 28 | +import org.eclipse.swt.widgets.Text; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * アクション生成ウィザードページ | |
| 32 | + * | |
| 33 | + * @author Tadashi Nakayama | |
| 34 | + * @version 1.0.0 | |
| 35 | + */ | |
| 36 | +public final class ActionGenerateWizardPage extends WizardPage { | |
| 37 | + /** ファイル */ | |
| 38 | + private final IFile ifile; | |
| 39 | + /** ターゲットパースリスト */ | |
| 40 | + private final List<ParserCallback> plist; | |
| 41 | + | |
| 42 | + /** url */ | |
| 43 | + private Text url; | |
| 44 | + /** keepid */ | |
| 45 | + private Text keep; | |
| 46 | + /** button1 */ | |
| 47 | + private Button bt1; | |
| 48 | + /** button1 */ | |
| 49 | + private Button bt2; | |
| 50 | + /** ParserCallback */ | |
| 51 | + private ParserCallback cb; | |
| 52 | + | |
| 53 | + /** | |
| 54 | + * コンストラクタ | |
| 55 | + * | |
| 56 | + * @param file ターゲットファイル | |
| 57 | + * @param list ターゲットパースリスト | |
| 58 | + */ | |
| 59 | + ActionGenerateWizardPage(final IFile file, final List<ParserCallback> list) { | |
| 60 | + super(file.getName()); | |
| 61 | + setTitle("アクション生成ウィザードページ"); | |
| 62 | + setDescription("アクション生成ウィザード [" + file.getName() + "]"); | |
| 63 | + this.ifile = file; | |
| 64 | + this.plist = list; | |
| 65 | + } | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * @see org.eclipse.jface.dialogs.IDialogPage | |
| 69 | + * #createControl(org.eclipse.swt.widgets.Composite) | |
| 70 | + */ | |
| 71 | + @Override | |
| 72 | + public void createControl(final Composite parent) { | |
| 73 | + | |
| 74 | + this.cb = parse(this.ifile); | |
| 75 | + if (this.cb == null) { | |
| 76 | + return; | |
| 77 | + } | |
| 78 | + | |
| 79 | + Composite comp = new Composite(parent, SWT.NULL); | |
| 80 | + comp.setLayout(new GridLayout(3, false)); | |
| 81 | + | |
| 82 | + GridData gd2 = new GridData(GridData.HORIZONTAL_ALIGN_FILL); | |
| 83 | + gd2.horizontalSpan = 2; | |
| 84 | + | |
| 85 | + // URL | |
| 86 | + Label label = new Label(comp, SWT.NULL); | |
| 87 | + label.setText("URL:"); | |
| 88 | + label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); | |
| 89 | + this.url = new Text(comp, SWT.BORDER); | |
| 90 | + this.url.setLayoutData(gd2); | |
| 91 | + this.url.addModifyListener(new ModifyListener() { | |
| 92 | + public void modifyText(final ModifyEvent evt) { | |
| 93 | + validateUrl(); | |
| 94 | + } | |
| 95 | + }); | |
| 96 | + String name = this.ifile.getName(); | |
| 97 | + this.url.setText(name.substring(0, name.indexOf("."))); | |
| 98 | + | |
| 99 | + // KeepId | |
| 100 | + label = new Label(comp, SWT.NULL); | |
| 101 | + label.setText("KeepId:"); | |
| 102 | + label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); | |
| 103 | + this.keep = new Text(comp, SWT.BORDER); | |
| 104 | + this.keep.addModifyListener(new ModifyListener() { | |
| 105 | + public void modifyText(final ModifyEvent evt) { | |
| 106 | + validateKeepId(); | |
| 107 | + } | |
| 108 | + }); | |
| 109 | + | |
| 110 | + // sessionType | |
| 111 | + Group group = new Group(comp, SWT.NULL); | |
| 112 | + group.setText("セションタイプ"); | |
| 113 | + group.setLayout(new FillLayout()); | |
| 114 | + this.bt1 = new Button(group, SWT.RADIO); | |
| 115 | + this.bt1.setText("シングル"); | |
| 116 | + this.bt1.setSelection(true); | |
| 117 | + this.bt1.addSelectionListener(new SelectionListener() { | |
| 118 | + public void widgetSelected(final SelectionEvent evt) { | |
| 119 | + validateMulti(); | |
| 120 | + } | |
| 121 | + public void widgetDefaultSelected(final SelectionEvent evt) { | |
| 122 | + // NOP | |
| 123 | + } | |
| 124 | + }); | |
| 125 | + this.bt2 = new Button(group, SWT.RADIO); | |
| 126 | + this.bt2.setText("マルチ"); | |
| 127 | + this.bt2.addSelectionListener(new SelectionListener() { | |
| 128 | + public void widgetSelected(final SelectionEvent evt) { | |
| 129 | + validateMulti(); | |
| 130 | + } | |
| 131 | + public void widgetDefaultSelected(final SelectionEvent evt) { | |
| 132 | + // NOP | |
| 133 | + } | |
| 134 | + }); | |
| 135 | + | |
| 136 | + // 空行 | |
| 137 | + GridData gd3 = new GridData(GridData.HORIZONTAL_ALIGN_FILL); | |
| 138 | + gd3.horizontalSpan = 3; | |
| 139 | + new Label(comp, SWT.NULL).setLayoutData(gd3); | |
| 140 | + | |
| 141 | + // 項目名 | |
| 142 | + label = new Label(comp, SWT.NULL); | |
| 143 | + label.setText("項目名"); | |
| 144 | + label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); | |
| 145 | + | |
| 146 | + // クラス | |
| 147 | + label = new Label(comp, SWT.NULL); | |
| 148 | + label.setText("class(ドメイン)"); | |
| 149 | + GridData gdc = new GridData(GridData.HORIZONTAL_ALIGN_CENTER); | |
| 150 | + gdc.horizontalSpan = 2; | |
| 151 | + label.setLayoutData(gdc); | |
| 152 | + | |
| 153 | + for (int i = 0; i < this.cb.getNameList().size(); i++) { | |
| 154 | + label = new Label(comp, SWT.NULL); | |
| 155 | + label.setText(this.cb.getNameList().get(i)); | |
| 156 | + label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); | |
| 157 | + | |
| 158 | + Text text = new Text(comp, SWT.BORDER); | |
| 159 | + text.setLayoutData(gd2); | |
| 160 | + if (this.cb.getClassList().get(i) != null) { | |
| 161 | + text.setText(this.cb.getClassList().get(i)); | |
| 162 | + } | |
| 163 | + } | |
| 164 | + | |
| 165 | + validateUrl(); | |
| 166 | + validateKeepId(); | |
| 167 | + | |
| 168 | + setControl(comp); | |
| 169 | + | |
| 170 | + this.plist.add(this.cb); | |
| 171 | + } | |
| 172 | + | |
| 173 | + /** | |
| 174 | + * url検証 | |
| 175 | + */ | |
| 176 | + void validateUrl() { | |
| 177 | + if (this.url.getText().length() == 0) { | |
| 178 | + setErrorMessage("URLを入力してください。"); | |
| 179 | + setPageComplete(false); | |
| 180 | + | |
| 181 | + this.cb.setUrl(null); | |
| 182 | + } else { | |
| 183 | + setErrorMessage(null); | |
| 184 | + setPageComplete(true); | |
| 185 | + | |
| 186 | + this.cb.setUrl(this.url.getText()); | |
| 187 | + } | |
| 188 | + } | |
| 189 | + | |
| 190 | + /** | |
| 191 | + * keepId検証 | |
| 192 | + */ | |
| 193 | + void validateKeepId() { | |
| 194 | + boolean bool = (0 < this.keep.getText().length()); | |
| 195 | + this.bt1.setEnabled(bool); | |
| 196 | + this.bt2.setEnabled(bool); | |
| 197 | + | |
| 198 | + this.cb.setKeepId(null); | |
| 199 | + if (bool) { | |
| 200 | + this.cb.setKeepId(this.keep.getText()); | |
| 201 | + } | |
| 202 | + validateMulti(); | |
| 203 | + } | |
| 204 | + | |
| 205 | + /** | |
| 206 | + * multi検証 | |
| 207 | + */ | |
| 208 | + void validateMulti() { | |
| 209 | + this.cb.setMulti(this.bt2.getSelection()); | |
| 210 | + } | |
| 211 | + | |
| 212 | + /** | |
| 213 | + * パース処理 | |
| 214 | + * | |
| 215 | + * @param file ファイル | |
| 216 | + * @return パースコールバック | |
| 217 | + */ | |
| 218 | + private ParserCallback parse(final IFile file) { | |
| 219 | + FileReader fr = null; | |
| 220 | + BufferedReader br = null; | |
| 221 | + try { | |
| 222 | + fr = new FileReader(new File(file.getRawLocationURI())); | |
| 223 | + br = new BufferedReader(fr); | |
| 224 | + ParserDelegator pd = new ParserDelegator(); | |
| 225 | + ParserCallback pc = new ParserCallback(); | |
| 226 | + pd.parse(br, pc, true); | |
| 227 | + return pc; | |
| 228 | + | |
| 229 | + } catch (IOException ex) { | |
| 230 | + MessageDialog.openError(this.getShell(), "IOException", ex.getMessage()); | |
| 231 | + return null; | |
| 232 | + } finally { | |
| 233 | + if (br != null) { | |
| 234 | + try { | |
| 235 | + br.close(); | |
| 236 | + } catch (IOException ex) { | |
| 237 | + MessageDialog.openError(this.getShell(), "IOException", ex.getMessage()); | |
| 238 | + } | |
| 239 | + } | |
| 240 | + if (fr != null) { | |
| 241 | + try { | |
| 242 | + fr.close(); | |
| 243 | + } catch (IOException ex) { | |
| 244 | + MessageDialog.openError(this.getShell(), "IOException", ex.getMessage()); | |
| 245 | + } | |
| 246 | + } | |
| 247 | + } | |
| 248 | + } | |
| 249 | +} |
| @@ -0,0 +1,61 @@ | ||
| 1 | +package online.plugin.actiongenerate.wizards; | |
| 2 | + | |
| 3 | +import org.eclipse.jface.wizard.WizardPage; | |
| 4 | +import org.eclipse.swt.SWT; | |
| 5 | +import org.eclipse.swt.events.ModifyEvent; | |
| 6 | +import org.eclipse.swt.events.ModifyListener; | |
| 7 | +import org.eclipse.swt.layout.GridData; | |
| 8 | +import org.eclipse.swt.layout.GridLayout; | |
| 9 | +import org.eclipse.swt.widgets.Composite; | |
| 10 | +import org.eclipse.swt.widgets.Label; | |
| 11 | +import org.eclipse.swt.widgets.Text; | |
| 12 | + | |
| 13 | +public final class GenerateWizardPage extends WizardPage { | |
| 14 | + /** テキスト */ | |
| 15 | + private Text text; | |
| 16 | + | |
| 17 | + /** | |
| 18 | + * コンストラクタ | |
| 19 | + */ | |
| 20 | + GenerateWizardPage() { | |
| 21 | + super("NewWizard"); | |
| 22 | + setTitle("新ウィザードページ"); | |
| 23 | + setDescription("test"); | |
| 24 | + } | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * @see org.eclipse.jface.dialogs.IDialogPage | |
| 28 | + * #createControl(org.eclipse.swt.widgets.Composite) | |
| 29 | + */ | |
| 30 | + @Override | |
| 31 | + public void createControl(final Composite parent) { | |
| 32 | + Composite comp = new Composite(parent, SWT.NULL); | |
| 33 | + comp.setLayout(new GridLayout(2, false)); | |
| 34 | + | |
| 35 | + Label label = new Label(comp, SWT.NULL); | |
| 36 | + label.setText("ファイル名:"); | |
| 37 | + | |
| 38 | + this.text = new Text(comp, SWT.BORDER); | |
| 39 | + this.text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); | |
| 40 | + | |
| 41 | + this.text.addModifyListener(new ModifyListener() { | |
| 42 | + public void modifyText(final ModifyEvent evt) { | |
| 43 | + doValidate(); | |
| 44 | + } | |
| 45 | + }); | |
| 46 | + | |
| 47 | + doValidate(); | |
| 48 | + setControl(comp); | |
| 49 | + } | |
| 50 | + | |
| 51 | + void doValidate() { | |
| 52 | + if (this.text.getText().length() == 0) { | |
| 53 | + setErrorMessage("input filen name"); | |
| 54 | + setPageComplete(false); | |
| 55 | + return; | |
| 56 | + } | |
| 57 | + | |
| 58 | + setErrorMessage(null); | |
| 59 | + setPageComplete(true); | |
| 60 | + } | |
| 61 | +} |
| @@ -0,0 +1,66 @@ | ||
| 1 | +package online.plugin.actiongenerate.wizards; | |
| 2 | + | |
| 3 | +import java.util.ArrayList; | |
| 4 | +import java.util.List; | |
| 5 | + | |
| 6 | +import online.plugin.actiongenerate.ParserCallback; | |
| 7 | + | |
| 8 | +import org.eclipse.core.resources.IFile; | |
| 9 | +import org.eclipse.jface.viewers.IStructuredSelection; | |
| 10 | +import org.eclipse.jface.wizard.Wizard; | |
| 11 | +import org.eclipse.ui.INewWizard; | |
| 12 | +import org.eclipse.ui.IWorkbench; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * アクション生成ウィザード | |
| 16 | + * | |
| 17 | + * @author Tadashi Nakayama | |
| 18 | + * @version 1.0.0 | |
| 19 | + */ | |
| 20 | +public final class ActionGenerateWizard extends Wizard implements INewWizard { | |
| 21 | + | |
| 22 | + /** ターゲットファイルリスト */ | |
| 23 | + private final List<IFile> flist; | |
| 24 | + /** ターゲットパースリスト */ | |
| 25 | + private final List<ParserCallback> plist = new ArrayList<ParserCallback>(); | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * コンストラクタ | |
| 29 | + * | |
| 30 | + * @param list ターゲットファイルリスト | |
| 31 | + */ | |
| 32 | + public ActionGenerateWizard(final List<IFile> list) { | |
| 33 | + setWindowTitle("アクション生成ウィザード"); | |
| 34 | + this.flist = list; | |
| 35 | + } | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * @see org.eclipse.jface.wizard.Wizard#addPages() | |
| 39 | + */ | |
| 40 | + @Override | |
| 41 | + public void addPages() { | |
| 42 | + if (this.flist != null) { | |
| 43 | + for (final IFile file : this.flist) { | |
| 44 | + addPage(new ActionGenerateWizardPage(file, this.plist)); | |
| 45 | + } | |
| 46 | + } | |
| 47 | + } | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * @see org.eclipse.jface.wizard.Wizard#performFinish() | |
| 51 | + */ | |
| 52 | + @Override | |
| 53 | + public boolean performFinish() { | |
| 54 | + // TODO: | |
| 55 | + return true; | |
| 56 | + } | |
| 57 | + | |
| 58 | + /** | |
| 59 | + * @see org.eclipse.ui.IWorkbenchWizard | |
| 60 | + * #init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) | |
| 61 | + */ | |
| 62 | + @Override | |
| 63 | + public void init(final IWorkbench workbench, final IStructuredSelection selection) { | |
| 64 | + // NOP | |
| 65 | + } | |
| 66 | +} |
| @@ -0,0 +1,132 @@ | ||
| 1 | +package online.plugin.actiongenerate; | |
| 2 | + | |
| 3 | +import java.util.ArrayList; | |
| 4 | +import java.util.List; | |
| 5 | + | |
| 6 | +import javax.swing.text.MutableAttributeSet; | |
| 7 | +import javax.swing.text.html.HTMLEditorKit; | |
| 8 | +import javax.swing.text.html.HTML.Attribute; | |
| 9 | +import javax.swing.text.html.HTML.Tag; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * パーサーコールバック | |
| 13 | + * | |
| 14 | + * @author Tadashi Nakayama | |
| 15 | + * @version 1.0.0 | |
| 16 | + */ | |
| 17 | +public final class ParserCallback extends HTMLEditorKit.ParserCallback { | |
| 18 | + | |
| 19 | + /** 名前リスト */ | |
| 20 | + private final List<String> nlist = new ArrayList<String>(); | |
| 21 | + /** クラスリスト */ | |
| 22 | + private final List<String> clist = new ArrayList<String>(); | |
| 23 | + | |
| 24 | + /** url */ | |
| 25 | + private String url = null; | |
| 26 | + /** keepId */ | |
| 27 | + private String keepId = null; | |
| 28 | + /** multi */ | |
| 29 | + private boolean multi = false; | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 名前リスト取得 | |
| 33 | + * | |
| 34 | + * @return 名前リスト | |
| 35 | + */ | |
| 36 | + public List<String> getNameList() { | |
| 37 | + return this.nlist; | |
| 38 | + } | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * クラスリスト取得 | |
| 42 | + * | |
| 43 | + * @return クラスリスト | |
| 44 | + */ | |
| 45 | + public List<String> getClassList() { | |
| 46 | + return this.clist; | |
| 47 | + } | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * ulr取得 | |
| 51 | + * | |
| 52 | + * @return url | |
| 53 | + */ | |
| 54 | + public String getUrl() { | |
| 55 | + return this.url; | |
| 56 | + } | |
| 57 | + | |
| 58 | + /** | |
| 59 | + * url設定 | |
| 60 | + * | |
| 61 | + * @param val url | |
| 62 | + */ | |
| 63 | + public void setUrl(final String val) { | |
| 64 | + this.url = val; | |
| 65 | + } | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * keepId取得 | |
| 69 | + * | |
| 70 | + * @return keepId | |
| 71 | + */ | |
| 72 | + public String getKeepId() { | |
| 73 | + return this.keepId; | |
| 74 | + } | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * keepId設定 | |
| 78 | + * | |
| 79 | + * @param val keepId | |
| 80 | + */ | |
| 81 | + public void setKeepId(final String val) { | |
| 82 | + this.keepId = val; | |
| 83 | + } | |
| 84 | + | |
| 85 | + /** | |
| 86 | + * 多重確認 | |
| 87 | + * | |
| 88 | + * @return 多重の場合 true を返す。 | |
| 89 | + */ | |
| 90 | + public boolean isMulti() { | |
| 91 | + return this.multi; | |
| 92 | + } | |
| 93 | + | |
| 94 | + /** | |
| 95 | + * 多重設定 | |
| 96 | + * | |
| 97 | + * @param val 多重の場合 true | |
| 98 | + */ | |
| 99 | + public void setMulti(final boolean val) { | |
| 100 | + this.multi = val; | |
| 101 | + } | |
| 102 | + | |
| 103 | + /** | |
| 104 | + * @see javax.swing.text.html.HTMLEditorKit.ParserCallback | |
| 105 | + * #handleStartTag(javax.swing.text.html.HTML.Tag, javax.swing.text.MutableAttributeSet, int) | |
| 106 | + */ | |
| 107 | + @Override | |
| 108 | + public void handleStartTag(final Tag tag, final MutableAttributeSet attr, final int pos) { | |
| 109 | + if (tag.equals(Tag.TEXTAREA) || tag.equals(Tag.SELECT)) { | |
| 110 | + this.nlist.add((String)attr.getAttribute(Attribute.NAME)); | |
| 111 | + this.clist.add((String)attr.getAttribute(Attribute.CLASS)); | |
| 112 | + } | |
| 113 | + } | |
| 114 | + | |
| 115 | + /** | |
| 116 | + * @see javax.swing.text.html.HTMLEditorKit.ParserCallback | |
| 117 | + * #handleSimpleTag(javax.swing.text.html.HTML.Tag, javax.swing.text.MutableAttributeSet, int) | |
| 118 | + */ | |
| 119 | + @Override | |
| 120 | + public void handleSimpleTag(final Tag tag, final MutableAttributeSet attr, final int pos) { | |
| 121 | + if (tag.equals(Tag.INPUT)) { | |
| 122 | + String type = (String)attr.getAttribute(Attribute.TYPE); | |
| 123 | + if (type.equalsIgnoreCase("submit") || type.equalsIgnoreCase("reset") | |
| 124 | + || type.equalsIgnoreCase("button") || type.equalsIgnoreCase("image")) { | |
| 125 | + return; | |
| 126 | + } | |
| 127 | + | |
| 128 | + this.nlist.add((String)attr.getAttribute(Attribute.NAME)); | |
| 129 | + this.clist.add((String)attr.getAttribute(Attribute.CLASS)); | |
| 130 | + } | |
| 131 | + } | |
| 132 | +} |
| @@ -0,0 +1,71 @@ | ||
| 1 | +package online.plugin.actiongenerate; | |
| 2 | + | |
| 3 | +import org.eclipse.jface.resource.ImageDescriptor; | |
| 4 | +import org.eclipse.ui.plugin.AbstractUIPlugin; | |
| 5 | +import org.osgi.framework.BundleContext; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * The activator class controls the plug-in life cycle | |
| 9 | + */ | |
| 10 | +public final class Activator extends AbstractUIPlugin { | |
| 11 | + | |
| 12 | + /** The plug-in ID */ | |
| 13 | + public static final String PLUGIN_ID = "online.plugin.actiongenerate"; | |
| 14 | + | |
| 15 | + /** The shared instance */ | |
| 16 | + private static Activator plugin; | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * The constructor | |
| 20 | + */ | |
| 21 | + public Activator() { | |
| 22 | + // NOP | |
| 23 | + } | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) | |
| 27 | + */ | |
| 28 | + @Override | |
| 29 | + public void start(final BundleContext context) throws Exception { | |
| 30 | + super.start(context); | |
| 31 | + setActivator(this); | |
| 32 | + } | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) | |
| 36 | + */ | |
| 37 | + @Override | |
| 38 | + public void stop(final BundleContext context) throws Exception { | |
| 39 | + setActivator(null); | |
| 40 | + super.stop(context); | |
| 41 | + } | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * Returns the shared instance | |
| 45 | + * | |
| 46 | + * @return the shared instance | |
| 47 | + */ | |
| 48 | + public static Activator getDefault() { | |
| 49 | + return plugin; | |
| 50 | + } | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * Returns an image descriptor for the image file at the given | |
| 54 | + * plug-in relative path | |
| 55 | + * | |
| 56 | + * @param path the path | |
| 57 | + * @return the image descriptor | |
| 58 | + */ | |
| 59 | + public static ImageDescriptor getImageDescriptor(final String path) { | |
| 60 | + return imageDescriptorFromPlugin(PLUGIN_ID, path); | |
| 61 | + } | |
| 62 | + | |
| 63 | + /** | |
| 64 | + * Activator設定 | |
| 65 | + * | |
| 66 | + * @param val Activator | |
| 67 | + */ | |
| 68 | + private static void setActivator(final Activator val) { | |
| 69 | + plugin = val; | |
| 70 | + } | |
| 71 | +} |
| @@ -0,0 +1,39 @@ | ||
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<?eclipse version="3.2"?> | |
| 3 | +<plugin> | |
| 4 | + | |
| 5 | + <extension | |
| 6 | + point="org.eclipse.ui.popupMenus"> | |
| 7 | + <objectContribution | |
| 8 | + adaptable="true" | |
| 9 | + id="online.plugin.actiongenerate.contribution" | |
| 10 | + objectClass="org.eclipse.core.resources.IFile"> | |
| 11 | + <filter | |
| 12 | + name="name" | |
| 13 | + value="*.jsp"> | |
| 14 | + </filter> | |
| 15 | + <action | |
| 16 | + label="アクション生成" | |
| 17 | + class="online.plugin.actiongenerate.popup.actions.GenerateAction" | |
| 18 | + menubarPath="additions" | |
| 19 | + enablesFor="+" | |
| 20 | + id="online.plugin.actiongenerate.newAction"> | |
| 21 | + </action> | |
| 22 | + </objectContribution> | |
| 23 | + </extension> | |
| 24 | + <extension | |
| 25 | + point="org.eclipse.ui.newWizards"> | |
| 26 | + <category | |
| 27 | + id="online.plugin.actiongenerate.category" | |
| 28 | + name="ソース"> | |
| 29 | + </category> | |
| 30 | + <wizard | |
| 31 | + category="online.plugin.actiongenerate.category" | |
| 32 | + class="online.plugin.actiongenerate.wizards.GenerateWizard" | |
| 33 | + finalPerspective="org.eclipse.jdt.ui.JavaPerspective" | |
| 34 | + id="online.plugin.actiongenerate.wizard" | |
| 35 | + name="生成"> | |
| 36 | + </wizard> | |
| 37 | + </extension> | |
| 38 | + | |
| 39 | +</plugin> |
| @@ -0,0 +1,127 @@ | ||
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<project name="com.sysdeo.eclipse.tomcat" default="zip.plugin" basedir="."> | |
| 3 | + | |
| 4 | + <property name="bootclasspath" value=""/> | |
| 5 | + <property name="ws" value="win32"/> | |
| 6 | + <property name="os" value="win32"/> | |
| 7 | + <property name="arch" value="x86"/> | |
| 8 | + <property name="build.workdir" value="C:/temp"/> | |
| 9 | + | |
| 10 | + <target name="init" depends="properties"> | |
| 11 | + <property name="plugin" value="com.sysdeo.eclipse.tomcat"/> | |
| 12 | + <property name="version.suffix" value="_3.2.1"/> | |
| 13 | + <property name="full.name" value="${plugin}${version.suffix}"/> | |
| 14 | + <property name="temp.folder" value="${build.workdir}/temp.folder"/> | |
| 15 | + <property name="plugin.destination" value="${build.workdir}"/> | |
| 16 | + <property name="build.result.folder" value="${build.workdir}"/> | |
| 17 | + </target> | |
| 18 | + | |
| 19 | + <target name="properties" if="eclipse.running"> | |
| 20 | + <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/> | |
| 21 | + </target> | |
| 22 | + | |
| 23 | + <target name="build.update.jar" depends="init"> | |
| 24 | + <delete dir="${temp.folder}"/> | |
| 25 | + <mkdir dir="${temp.folder}"/> | |
| 26 | + <antcall target="build.jars"/> | |
| 27 | + <antcall target="gather.bin.parts"> | |
| 28 | + <param name="destination.temp.folder" value="${temp.folder}/"/> | |
| 29 | + </antcall> | |
| 30 | + <zip zipfile="${plugin.destination}/${full.name}.jar" basedir="${temp.folder}/${full.name}" filesonly="false" update="no"/> | |
| 31 | + <delete dir="${temp.folder}"/> | |
| 32 | + </target> | |
| 33 | + | |
| 34 | + <target name="gather.bin.parts" depends="init" if="destination.temp.folder"> | |
| 35 | + <mkdir dir="${destination.temp.folder}/${full.name}"/> | |
| 36 | + <copy file="${build.result.folder}/tomcat.jar" todir="${destination.temp.folder}/${full.name}"/> | |
| 37 | + <copy todir="${destination.temp.folder}/${full.name}"> | |
| 38 | + <fileset dir="${basedir}" includes="plugin.xml,*.jar,DevLoader.zip,*.txt,*.html,icons/*,img/*,plugin*.properties"/> | |
| 39 | + </copy> | |
| 40 | + </target> | |
| 41 | + | |
| 42 | + <target name="tomcat.jar" depends="init" unless="tomcat.jar"> | |
| 43 | + <property name="destdir" value="${temp.folder}/tomcat.jar.bin"/> | |
| 44 | + <delete dir="${temp.folder}/tomcat.jar.bin"/> | |
| 45 | + <mkdir dir="${temp.folder}/tomcat.jar.bin"/> | |
| 46 | + <!-- compile the source code | |
| 47 | + <javac destdir="${temp.folder}/tomcat.jar.bin" failonerror="false" verbose="true" debug="on" includeAntRuntime="no" bootclasspath="${bootclasspath}" classpath="D:/java/eclipse/plugins/org.eclipse.jdt.ui_2.1.0/bin;D:/java/eclipse/plugins/org.eclipse.core.boot_2.1.0/boot.jar;D:/java/eclipse/plugins/org.eclipse.swt.win32_2.1.0/ws/${ws}/swt.jar;D:/java/eclipse/plugins/org.eclipse.core.resources.win32_2.1.0/resources.jar;D:/java/eclipse/plugins/org.eclipse.jface.text_2.1.0/bin;D:/java/eclipse/plugins/org.eclipse.core.resources_2.1.0/bin;D:/java/eclipse/plugins/org.eclipse.jface_2.1.0/jface.jar;D:/java/eclipse/plugins/org.eclipse.jface.text_2.1.0/jfacetext.jar;D:/java/eclipse/plugins/org.eclipse.ui.workbench.texteditor_2.1.0/bin;D:/java/eclipse/plugins/org.eclipse.jface_2.1.0/bin;D:/java/eclipse/plugins/org.eclipse.jdt.launching_2.1.0/launching.jar;D:/java/eclipse/plugins/org.eclipse.jdt.debug.ui_2.1.0/bin;D:/java/eclipse/plugins/org.eclipse.debug.ui_2.1.0/bin;D:/java/eclipse/plugins/org.eclipse.ui.editors_2.1.0/editors.jar;D:/java/eclipse/plugins/org.eclipse.ui.workbench.texteditor_2.1.0/texteditor.jar;D:/java/eclipse/plugins/org.eclipse.jdt.debug_2.1.0/bin;D:/java/eclipse/plugins/org.eclipse.ui.views_2.1.0/views.jar;D:/java/eclipse/plugins/org.eclipse.ui.win32_2.1.0/workbench.jar;D:/java/eclipse/plugins/org.eclipse.ui_2.1.0/bin;D:/java/eclipse/plugins/org.eclipse.core.boot_2.1.0/bin;D:/java/eclipse/plugins/org.eclipse.jdt.debug.ui_2.1.0/jdiui.jar;D:/java/eclipse/plugins/org.eclipse.core.runtime_2.1.0/bin;D:/java/eclipse/plugins/org.eclipse.jdt.core_2.1.0/jdtcore.jar;D:/java/eclipse/plugins/org.eclipse.jdt.core_2.1.0/bin;D:/java/eclipse/plugins/org.eclipse.core.runtime_2.1.0/runtime.jar;D:/java/eclipse/plugins/org.eclipse.text_2.1.0/text.jar;D:/java/eclipse/plugins/org.eclipse.jdt.debug_2.1.0/jdi.jar;D:/java/eclipse/plugins/org.eclipse.debug.core_2.1.0/bin;D:/java/eclipse/plugins/org.eclipse.ui_2.1.0/ui.jar;D:/java/eclipse/plugins/org.eclipse.core.resources_2.1.0/resources.jar;D:/java/eclipse/plugins/org.eclipse.swt_2.1.0/bin;D:/java/eclipse/plugins/org.eclipse.swt_2.1.0/ws/${ws}/swt.jar;D:/java/eclipse/plugins/org.eclipse.text_2.1.0/bin;D:/java/eclipse/plugins/org.eclipse.jdt.debug_2.1.0/jdimodel.jar;D:/java/eclipse/plugins/org.eclipse.jdt.debug_2.1.0/tools.jar;D:/java/eclipse/plugins/org.eclipse.ui.editors_2.1.0/bin;D:/java/eclipse/plugins/org.eclipse.ui.views_2.1.0/bin;D:/java/eclipse/plugins/org.eclipse.debug.ui_2.1.0/dtui.jar;D:/java/eclipse/plugins/org.eclipse.jdt.launching_2.1.0/bin;D:/java/eclipse/plugins/org.eclipse.ui.workbench_2.1.0/bin;D:/java/eclipse/plugins/org.eclipse.debug.core_2.1.0/dtcore.jar;D:/java/eclipse/plugins/org.eclipse.ui.workbench_2.1.0/workbench.jar;D:/java/eclipse/plugins/org.eclipse.jdt.ui_2.1.0/jdt.jar;D:/java/eclipse/plugins/org.eclipse.ui.win32_2.1.0/workbenchwin32.jar"> | |
| 48 | + <src path="src/"/> | |
| 49 | + </javac> | |
| 50 | + --> | |
| 51 | + <!-- copy necessary resources --> | |
| 52 | + <copy todir="${temp.folder}/tomcat.jar.bin"> | |
| 53 | + <fileset dir="bin/" includes="**/*"/> | |
| 54 | + </copy> | |
| 55 | + <mkdir dir="${build.result.folder}"/> | |
| 56 | + <jar jarfile="${build.result.folder}/tomcat.jar" basedir="${temp.folder}/tomcat.jar.bin"/> | |
| 57 | + <delete dir="${temp.folder}/tomcat.jar.bin"/> | |
| 58 | + </target> | |
| 59 | + | |
| 60 | + <target name="tomcatsrc.zip" depends="init" unless="tomcatsrc.zip"> | |
| 61 | + <mkdir dir="${build.result.folder}"/> | |
| 62 | + <zip zipfile="${build.result.folder}/tomcatsrc.zip" filesonly="false" update="no"> | |
| 63 | +<!-- <fileset dir="src/" includes="**/*.java"/> | |
| 64 | +--> | |
| 65 | + <fileset dir="${basedir}" excludes="**/bin/**/*.*,**/CVS"/> | |
| 66 | + </zip> | |
| 67 | + </target> | |
| 68 | + | |
| 69 | + <target name="build.jars" depends="init"> | |
| 70 | + <available property="tomcat.jar" file="${build.result.folder}/tomcat.jar"/> | |
| 71 | + <antcall target="tomcat.jar"/> | |
| 72 | + </target> | |
| 73 | + | |
| 74 | + <target name="build.sources" depends="init"> | |
| 75 | + <available property="tomcatsrc.zip" file="${build.result.folder}/tomcatsrc.zip"/> | |
| 76 | + <antcall target="tomcatsrc.zip"/> | |
| 77 | + </target> | |
| 78 | + | |
| 79 | + <target name="build.zips" depends="init"> | |
| 80 | + </target> | |
| 81 | + | |
| 82 | + <target name="gather.sources" depends="init" if="destination.temp.folder"> | |
| 83 | + <mkdir dir="${destination.temp.folder}/${full.name}"/> | |
| 84 | + <copy file="${build.result.folder}/tomcatsrc.zip" todir="${destination.temp.folder}/${full.name}"/> | |
| 85 | + </target> | |
| 86 | + | |
| 87 | + <target name="gather.logs" depends="init" if="destination.temp.folder"> | |
| 88 | + <mkdir dir="${destination.temp.folder}/${full.name}"/> | |
| 89 | + <copy file="${temp.folder}/tomcat.jar.bin.log" todir="${destination.temp.folder}/${full.name}"/> | |
| 90 | + </target> | |
| 91 | + | |
| 92 | + <target name="clean" depends="init"> | |
| 93 | + <delete file="${build.result.folder}/tomcat.jar"/> | |
| 94 | + <delete file="${build.result.folder}/tomcatsrc.zip"/> | |
| 95 | + <delete file="${plugin.destination}/${full.name}.jar"/> | |
| 96 | + <delete file="${plugin.destination}/${full.name}.zip"/> | |
| 97 | + <delete dir="${temp.folder}"/> | |
| 98 | + </target> | |
| 99 | + | |
| 100 | + <target name="refresh" depends="init" if="eclipse.running"> | |
| 101 | + <eclipse.refreshLocal resource="${plugin}" depth="infinite"/> | |
| 102 | + </target> | |
| 103 | + | |
| 104 | + <target name="zip.plugin" depends="init"> | |
| 105 | + <delete dir="${temp.folder}"/> | |
| 106 | + <delete file="${build.result.folder}/tomcat.jar"/> | |
| 107 | + <delete file="${build.result.folder}/tomcatsrc.zip"/> | |
| 108 | + <mkdir dir="${temp.folder}"/> | |
| 109 | + <antcall target="build.sources"/> | |
| 110 | + <antcall target="build.jars"/> | |
| 111 | + <antcall target="gather.bin.parts"> | |
| 112 | + <param name="destination.temp.folder" value="${temp.folder}/"/> | |
| 113 | + </antcall> | |
| 114 | + <antcall target="gather.sources"> | |
| 115 | + <param name="destination.temp.folder" value="${temp.folder}/"/> | |
| 116 | + </antcall> | |
| 117 | + <delete> | |
| 118 | + <fileset dir="${temp.folder}" includes="**/*.bin.log"/> | |
| 119 | + </delete> | |
| 120 | + <antcall target="zip.folder"/> | |
| 121 | + <delete dir="${temp.folder}"/> | |
| 122 | + </target> | |
| 123 | + <target name="zip.folder" depends="init"> | |
| 124 | + <zip zipfile="${plugin.destination}/${full.name}.zip" basedir="${temp.folder}" filesonly="true" update="no" excludes="**/*.bin.log"/> | |
| 125 | + </target> | |
| 126 | + | |
| 127 | +</project> |
| @@ -0,0 +1,62 @@ | ||
| 1 | +package com.sysdeo.eclipse.tomcat.actions; | |
| 2 | + | |
| 3 | +/* | |
| 4 | + * (c) Copyright Sysdeo SA 2001, 2002. | |
| 5 | + * All Rights Reserved. | |
| 6 | + */ | |
| 7 | + | |
| 8 | +import org.eclipse.core.resources.IProject; | |
| 9 | +import org.eclipse.core.resources.IResource; | |
| 10 | +import org.eclipse.jface.action.IAction; | |
| 11 | +import org.eclipse.jface.viewers.ISelection; | |
| 12 | +import org.eclipse.ui.IWorkbenchWindow; | |
| 13 | +import org.eclipse.ui.IWorkbenchWindowActionDelegate; | |
| 14 | + | |
| 15 | +import com.sysdeo.eclipse.tomcat.TomcatLauncherPlugin; | |
| 16 | + | |
| 17 | +public class StartActionDelegate implements IWorkbenchWindowActionDelegate { | |
| 18 | + private IWorkbenchWindow window; | |
| 19 | + | |
| 20 | + /* | |
| 21 | + * @see IWorkbenchWindowActionDelegate#dispose() | |
| 22 | + */ | |
| 23 | + public void dispose() { | |
| 24 | + } | |
| 25 | + | |
| 26 | + /* | |
| 27 | + * @see IWorkbenchWindowActionDelegate#init(IWorkbenchWindow) | |
| 28 | + */ | |
| 29 | + public void init(IWorkbenchWindow window) { | |
| 30 | + this.window = window; | |
| 31 | + } | |
| 32 | + | |
| 33 | + /* | |
| 34 | + * @see IActionDelegate#run(IAction) | |
| 35 | + */ | |
| 36 | + public void run(IAction action) { | |
| 37 | + if(TomcatLauncherPlugin.checkTomcatSettingsAndWarn()) { | |
| 38 | + //TomcatLauncherPlugin.log(TomcatLauncherPlugin.getResourceString("msg.start")); | |
| 39 | + try { | |
| 40 | + TomcatLauncherPlugin.getDefault().getTomcatBootstrap().start(); | |
| 41 | + IProject[] projects = TomcatLauncherPlugin.getWorkspace().getRoot().getProjects(); | |
| 42 | + for (int i = 0; i < projects.length; i++) { | |
| 43 | + projects[i].refreshLocal(IResource.DEPTH_ONE, null); | |
| 44 | + } | |
| 45 | + } catch (Exception ex) { | |
| 46 | + String msg = TomcatLauncherPlugin.getResourceString("msg.start.failed"); | |
| 47 | + TomcatLauncherPlugin.log(msg + "/n"); | |
| 48 | + TomcatLauncherPlugin.log(ex); | |
| 49 | + } | |
| 50 | + } | |
| 51 | + } | |
| 52 | + | |
| 53 | + | |
| 54 | + /* | |
| 55 | + * @see IActionDelegate#selectionChanged(IAction, ISelection) | |
| 56 | + */ | |
| 57 | + public void selectionChanged(IAction action, ISelection selection) { | |
| 58 | + | |
| 59 | + } | |
| 60 | + | |
| 61 | +} | |
| 62 | + |
| @@ -0,0 +1,62 @@ | ||
| 1 | +package com.sysdeo.eclipse.tomcat.actions; | |
| 2 | + | |
| 3 | +/* | |
| 4 | + * (c) Copyright Sysdeo SA 2001, 2002. | |
| 5 | + * All Rights Reserved. | |
| 6 | + */ | |
| 7 | + | |
| 8 | + | |
| 9 | +import org.eclipse.core.resources.IProject; | |
| 10 | +import org.eclipse.core.resources.IResource; | |
| 11 | +import org.eclipse.jface.action.IAction; | |
| 12 | +import org.eclipse.jface.viewers.ISelection; | |
| 13 | +import org.eclipse.ui.IWorkbenchWindow; | |
| 14 | +import org.eclipse.ui.IWorkbenchWindowActionDelegate; | |
| 15 | + | |
| 16 | +import com.sysdeo.eclipse.tomcat.TomcatLauncherPlugin; | |
| 17 | + | |
| 18 | +public class RestartActionDelegate implements IWorkbenchWindowActionDelegate { | |
| 19 | + private IWorkbenchWindow window; | |
| 20 | + | |
| 21 | + /* | |
| 22 | + * @see IWorkbenchWindowActionDelegate#dispose() | |
| 23 | + */ | |
| 24 | + public void dispose() { | |
| 25 | + } | |
| 26 | + | |
| 27 | + /* | |
| 28 | + * @see IWorkbenchWindowActionDelegate#init(IWorkbenchWindow) | |
| 29 | + */ | |
| 30 | + public void init(IWorkbenchWindow window) { | |
| 31 | + this.window = window; | |
| 32 | + } | |
| 33 | + | |
| 34 | + /* | |
| 35 | + * @see IActionDelegate#run(IAction) | |
| 36 | + */ | |
| 37 | + public void run(IAction action) { | |
| 38 | + if(TomcatLauncherPlugin.checkTomcatSettingsAndWarn()) { | |
| 39 | + //TomcatLauncherPlugin.log(TomcatLauncherPlugin.getResourceString("msg.restart")); | |
| 40 | + try { | |
| 41 | + TomcatLauncherPlugin.getDefault().getTomcatBootstrap().restart(); | |
| 42 | + IProject[] projects = TomcatLauncherPlugin.getWorkspace().getRoot().getProjects(); | |
| 43 | + for (int i = 0; i < projects.length; i++) { | |
| 44 | + projects[i].refreshLocal(IResource.DEPTH_ONE, null); | |
| 45 | + } | |
| 46 | + } catch (Exception ex) { | |
| 47 | + String msg = TomcatLauncherPlugin.getResourceString("msg.restart.failed"); | |
| 48 | + TomcatLauncherPlugin.log(msg + "/n"); | |
| 49 | + TomcatLauncherPlugin.log(ex); | |
| 50 | + } | |
| 51 | + } | |
| 52 | + } | |
| 53 | + | |
| 54 | + /* | |
| 55 | + * @see IActionDelegate#selectionChanged(IAction, ISelection) | |
| 56 | + */ | |
| 57 | + public void selectionChanged(IAction action, ISelection selection) { | |
| 58 | + | |
| 59 | + } | |
| 60 | + | |
| 61 | +} | |
| 62 | + |