Math2mat

/home/ythoma/docs/math2mat/svn/wp1/framework/m2mGUI/src/m2m/frontend/actions/M2MAction.java

Go to the documentation of this file.
00001 
00019 package m2m.frontend.actions;
00020 
00021 import org.eclipse.jface.action.Action;
00022 import org.eclipse.jface.dialogs.MessageDialog;
00023 import org.eclipse.ui.IEditorPart;
00024 import org.eclipse.ui.IWorkbenchPage;
00025 import org.eclipse.ui.IWorkbenchWindow;
00026 import org.eclipse.ui.PartInitException;
00027 import org.eclipse.ui.PlatformUI;
00028 
00029 import m2m.frontend.view.Editor;
00030 import m2m.frontend.view.M2MConsole;
00031 
00036 public abstract class M2MAction extends Action {
00037         
00038 
00039         protected M2MAction(IWorkbenchWindow window, String label) {
00040                 setEnabled(true);
00041                 this.window = window;
00042                 setText(label);
00043         }
00044         
00045         protected Editor editor;
00046 
00047         protected IWorkbenchWindow window;
00048         
00049         protected boolean getEditor(String messTitle,String errMess) {
00050                 editor = null;
00051                 IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
00052                 //get the current editor
00053                 if (editorPart instanceof Editor) {
00054                         editor = (Editor)editorPart;
00055                 } else {
00056                         MessageDialog.openError(window.getShell(), messTitle, errMess);
00057                         return false;
00058                 }
00059                 return true;
00060         }
00061         
00062         protected void activateConsole() {              
00063                 //activate the console
00064                 IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
00065                 try {
00066                         page.showView(M2MConsole.ID);
00067                 } catch (PartInitException e1) {
00068                         e1.printStackTrace();
00069                 }
00070         }
00071 }
 All Classes Namespaces Files Functions Variables Enumerations