/******************************************************************************* * Copyright (c) 2007- VTT Technical Research Centre of Finland. * 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.proconf.g3d.actions; import java.util.List; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.resource.ImageDescriptor; import org.simantics.proconf.g3d.Activator; import org.simantics.proconf.g3d.base.ConstraintDetector; import org.simantics.proconf.g3d.base.JmeRenderingComponent; import org.simantics.proconf.g3d.base.ThreeDimensionalEditorBase; import org.simantics.proconf.g3d.common.OrbitalCamera; public abstract class ConstrainedTransformAction extends WriteInteractiveAction { private static final ImageDescriptor LOCK_ICON = Activator.imageDescriptorFromPlugin("org.simantic.proconf.g3d", "icons/silk/lock.png"); private static final ImageDescriptor LOCK_OPEN_ICON = Activator.imageDescriptorFromPlugin("org.simantic.proconf.g3d", "icons/silk/lock_open.png"); protected JmeRenderingComponent component; protected OrbitalCamera camera; protected boolean useConstraints = false; protected ConstraintDetector detector; protected Action useConstraintsAction; //protected IToolBarManager manager; public ConstrainedTransformAction(ThreeDimensionalEditorBase editor) { super(editor, true); component = parent.getRenderingComponent(); camera = parent.getCamera(); detector = new ConstraintDetector(parent); useConstraintsAction = new Action("Constraints", Action.AS_CHECK_BOX) { public void run() { useConstraints = this.isChecked(); } public void setChecked(boolean b) { super.setChecked(b); if (b) { setImageDescriptor(LOCK_ICON); } else { setImageDescriptor(LOCK_OPEN_ICON); } } }; useConstraintsAction.setImageDescriptor(LOCK_OPEN_ICON); } @Override public void deactivate() { detector.clearConstraintHighlights(); } @Override public void fillToolBar(IToolBarManager manager) { //this.manager = manager; useConstraintsAction.setChecked(useConstraints); manager.add(useConstraintsAction); } }