Method: execute(ExecutionEvent)

1: /*
2: * #%~
3: * Code Generator Plugin
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.ide.plugins.javagen.commands;
23:
24: import java.io.InputStream;
25:
26: import org.eclipse.core.commands.AbstractHandler;
27: import org.eclipse.core.commands.ExecutionEvent;
28: import org.eclipse.core.commands.ExecutionException;
29: import org.eclipse.core.runtime.Status;
30: import org.eclipse.jface.dialogs.MessageDialog;
31: import org.eclipse.swt.widgets.Shell;
32: import org.eclipse.ui.handlers.HandlerUtil;
33: import org.overture.codegen.utils.GeneralUtils;
34: import org.overture.ide.plugins.javagen.Activator;
35: import org.overture.ide.plugins.javagen.util.PluginVdm2JavaUtil;
36:
37: public class AboutCommand extends AbstractHandler
38: {
39:         @Override
40:         public Object execute(ExecutionEvent event) throws ExecutionException
41:         {
42:                 InputStream fileStream = AboutCommand.class.getResourceAsStream("/textfiles/AboutMessage.txt");
43:
44:                 try
45:                 {
46:
47:                         Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();
48:                         String title = "VDM to Java Code Generator";
49:                         String about = GeneralUtils.readFromInputStream(fileStream).toString();
50:                         about = String.format(about, PluginVdm2JavaUtil.CODEGEN_RUNTIME_BIN_FILE,
51:                                         PluginVdm2JavaUtil.CODEGEN_RUNTIME_SOURCES_FILE,
52:                                         PluginVdm2JavaUtil.CODEGEN_RUNTIME_LIB_FOLDER);
53:
54:                         MessageDialog.openInformation(shell, title, about);
55:
56:                         return Status.OK_STATUS;
57:
58:                 } catch (Exception ex)
59:                 {
60:
61:                         Activator.log("Could not load the VDM to Java Code Generator About Message", ex);
62:
63:                 }
64:
65:                 return Status.ERROR;
66:         }
67: }