]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/winterwell.markdown/src/winterwell/markdown/editors/ActionBarContributor.java
migrated to svn revision 33108
[simantics/platform.git] / bundles / winterwell.markdown / src / winterwell / markdown / editors / ActionBarContributor.java
diff --git a/bundles/winterwell.markdown/src/winterwell/markdown/editors/ActionBarContributor.java b/bundles/winterwell.markdown/src/winterwell/markdown/editors/ActionBarContributor.java
new file mode 100644 (file)
index 0000000..e41793f
--- /dev/null
@@ -0,0 +1,49 @@
+package winterwell.markdown.editors;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.editors.text.TextEditorActionContributor;
+
+import winterwell.markdown.views.MarkdownPreview;
+
+public class ActionBarContributor extends TextEditorActionContributor {
+       
+       private static IEditorPart activeEditor = null;
+
+//     IAction print = new PrintAction();
+
+       public void setActiveEditor(IEditorPart targetEditor) {
+               super.setActiveEditor(targetEditor);
+               activeEditor  = targetEditor;
+               // add print action
+               IActionBars bars= getActionBars();
+           if (bars != null) {
+//             todo bars.setGlobalActionHandler(ActionFactory.PRINT.getId(), print);
+//             bars.updateActionBars();
+           }
+           // Update preview?
+               if (MarkdownPreview.preview != null) {
+                       MarkdownPreview.preview.update();
+               }
+       }
+       public static IEditorPart getActiveEditor() {
+               return activeEditor;
+       }
+       
+       @Override
+       public void contributeToMenu(IMenuManager menu) {       
+               super.contributeToMenu(menu);
+               // Add format action
+               IMenuManager edit = menu.findMenuUsingPath("edit");
+               if (edit != null) {
+                       edit.add(new FormatAction());
+               }
+               // Add Export action
+               IMenuManager file = menu.findMenuUsingPath("file");
+               if (file != null) {
+                       file.appendToGroup("import.ext", new ExportHTMLAction());
+               }               
+       }
+
+}