blob: 23fa90ef7d8950dbb1248d0d3efbcd4df53fe2d0 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009 Zoltan Ujhelyi and Istvan Rath 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:
* Istvan Rath - 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.ViatraColoredLabelProvider;
import org.eclipse.viatra2.visualisation.view.ViatraVisualisationView;
/**
* Selects and applies a new label provider to the visualisation.
* @author Istvan Rath
*
*/
public class SelectLabelProviderAction extends Action {
ViatraColoredLabelProvider lp;
/**
* Initializes a new select label provider action with a given name and label provider.
* @param name the name to set.
* @param lp the label provider to set.
*/
public SelectLabelProviderAction(String name, ViatraColoredLabelProvider lp) {
super(name);
this.lp = lp;
setToolTipText("Selects the " + name + " label provider 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.setLabelProvider(lp);
}
}