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=refs%2Fchanges%2F63%2F3663%2F1;hp=f95c875f3aa21c1374a9e759ed2f23c956c764bb;hpb=289aaab900078ef56efc8779e4b15830e472149e;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 f95c875f..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,99 +1,22 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -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); + } + }