X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d.vtk%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fvtk%2Faction%2FvtkAction.java;h=da9088049bcefd98f2a80458136b1efe4172e2f8;hb=b6de12aa6ceb6d0a77264ee7a1b2e01f3138411c;hp=d4c127bface47986e91c6cf76f9d06beaf1d926c;hpb=87b3241ec277ba3d8e414b26186a032c9cdcaeed;p=simantics%2F3d.git diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/action/vtkAction.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/action/vtkAction.java index d4c127bf..da908804 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/action/vtkAction.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/action/vtkAction.java @@ -1,88 +1,22 @@ -package org.simantics.g3d.vtk.action; - -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; - -import org.eclipse.jface.action.Action; -import org.simantics.g3d.vtk.common.InteractiveVtkPanel; - -public abstract class vtkAction extends Action implements KeyListener, MouseListener, MouseMotionListener { - - protected InteractiveVtkPanel panel; - - public vtkAction(InteractiveVtkPanel panel) { - this.panel = panel; - } - - @Override - public void run() { - panel.setActiveAction(this); - } - - - public void attach() { - - panel.addKeyListener(this); - panel.addMouseListener(this); - panel.addMouseMotionListener(this); - - } - - public void deattach() { - panel.removeKeyListener(this); - panel.removeMouseListener(this); - panel.removeMouseMotionListener(this); - } - - @Override - public void keyPressed(KeyEvent e) { - - } - - @Override - public void keyReleased(KeyEvent e) { - - } - - @Override - public void keyTyped(KeyEvent e) { - - } - - public void mouseClicked(java.awt.event.MouseEvent e) { - - }; - - @Override - public void mouseDragged(MouseEvent e) { - - } - - @Override - public void mouseEntered(MouseEvent e) { - - } - - @Override - public void mouseExited(MouseEvent e) { - - } - - @Override - public void mouseMoved(MouseEvent e) { - - } - - @Override - public void mousePressed(MouseEvent e) { - - } - - @Override - public void mouseReleased(MouseEvent e) { - - } -} +package org.simantics.g3d.vtk.action; + +import org.eclipse.core.commands.Command; +import org.eclipse.core.commands.State; +import org.eclipse.jface.action.Action; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.commands.ICommandService; +import org.simantics.ui.states.TrackedTextState; + +public abstract class vtkAction extends Action{ + + public abstract void attach(); + public abstract void deattach(); + + + protected void setDBUndo(boolean enabled) { + ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); + Command command = service.getCommand( TrackedTextState.COMMAND_ID ); + State state = command.getState( TrackedTextState.STATE_ID ); + state.setValue(enabled); + } + }