blob: 2c1fccc5614b6360dae0741fa8e9a15a22e47813 [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.common.action;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.ui.PlatformUI;
import org.eclipse.viatra2.visualisation.view.ViatraVisualisationView;
/**
* An action that allows setting the content provider for the graph viewer
* @author Zoltan Ujhelyi
*
*/
public class SelectProviderAction extends Action {
IContentProvider provider;
/**
* Initializes a Select Provider action
* @param name the name in the user interface that represents the content provider
* @param provider the content provider
*/
public SelectProviderAction(String name, IContentProvider provider) {
super(name,AS_RADIO_BUTTON);
this.provider = provider;
setToolTipText("Selects the " + name + " provider.");
}
/* (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.setProvider(provider);
}
}