| /******************************************************************************* |
| * 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.patterns.actions; |
| |
| import java.util.Arrays; |
| import java.util.List; |
| |
| import org.eclipse.jface.action.IMenuManager; |
| import org.eclipse.jface.action.MenuManager; |
| import org.eclipse.ui.actions.ActionGroup; |
| import org.eclipse.viatra2.visualisation.common.action.SelectProviderAction; |
| import org.eclipse.viatra2.visualisation.patterns.sources.PatternContentProvider; |
| import org.eclipse.viatra2.visualisation.patterns.sources.PatternFullProvider; |
| import org.eclipse.viatra2.visualisation.patterns.sources.PatternReducedProvider; |
| |
| /** |
| * A group of content providers for the model space visualisation. The group |
| * manages the list of providers and their graphical display. |
| * @author Zoltan Ujhelyi |
| */ |
| public class PatternProviderGroup extends ActionGroup { |
| |
| PatternReducedProvider reducedProvider = new PatternReducedProvider(); |
| PatternFullProvider fullProvider = new PatternFullProvider(); |
| List<? extends PatternContentProvider> providers = Arrays.asList(reducedProvider, fullProvider); |
| |
| /* |
| * (non-Javadoc) |
| * |
| * @see |
| * org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface. |
| * action.IMenuManager) |
| */ |
| @Override |
| public void fillContextMenu(IMenuManager manager) { |
| IMenuManager menu = new MenuManager("Display Relations"); |
| manager.add(menu); |
| SelectProviderAction reducedAction = new SelectProviderAction( |
| "As Arcs", reducedProvider); |
| menu.add(reducedAction); |
| SelectProviderAction fullAction = new SelectProviderAction( |
| "As Nodes", fullProvider); |
| fullAction.setChecked(true); |
| menu.add(fullAction); |
| } |
| |
| /** |
| * Returns the list of content providers managed by the group. |
| * @return the providers |
| */ |
| public List<? extends PatternContentProvider> getProviders() { |
| return providers; |
| } |
| |
| /** |
| * Returns the default content provider from the group. |
| * @return the default content provider |
| */ |
| public PatternContentProvider getDefaultProvider() { |
| return reducedProvider; |
| } |
| } |