blob: 64055a428650b3f4d7eeda238c3285df532dc190 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009 Zoltan Ujhelyi and Daniel Varro.
* 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:
* Zoltan Ujhelyi - initial API and implementation
*******************************************************************************/
package org.eclipse.viatra2.visualisation.modelspace.actions;
import org.eclipse.jface.action.Action;
import org.eclipse.ui.PlatformUI;
import org.eclipse.viatra2.visualisation.layouts.IViatraLayoutAlgorithm;
import org.eclipse.viatra2.visualisation.view.ViatraVisualisationView;
/**
* Selects and applies a new layout algorithm to the visualisation.
* @author Zoltan Ujhelyi
*
*/
public class SelectLayoutAction extends Action {
IViatraLayoutAlgorithm algorithm;
/**
* Initializes a new select layout action with a given name and layout algorithm.
* @param name the name to set.
* @param algorithm the algorithm to set.
*/
public SelectLayoutAction(String name, IViatraLayoutAlgorithm algorithm) {
super(name);
this.algorithm = algorithm;
setToolTipText("Selects the " + name + " layout algorithm for the current graph.");
}
/* (non-Javadoc)
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
String viewId = "org.eclipse.viatra2.visualisation.view";
ViatraVisualisationView view = (ViatraVisualisationView) PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.findViewReference(viewId).getView(false);
view.setLayoutAlgorithm(algorithm);
}
}