| /******************************************************************************* |
| * 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: |
| * Zoltan Ujhelyi - initial API and implementation |
| * Istvan Rath - modification to new extension point schema |
| *******************************************************************************/ |
| package org.eclipse.viatra2.visualisation.modelspace.actions.groups; |
| |
| import org.eclipse.jface.action.IMenuManager; |
| import org.eclipse.jface.action.MenuManager; |
| import org.eclipse.ui.actions.ActionGroup; |
| import org.eclipse.viatra2.visualisation.common.extensions.Category; |
| import org.eclipse.viatra2.visualisation.common.extensions.NamedElement; |
| import org.eclipse.viatra2.visualisation.common.extensions.VisualisationPreset; |
| import org.eclipse.viatra2.visualisation.common.extensions.internal.ExtensionAccess; |
| import org.eclipse.viatra2.visualisation.modelspace.actions.SelectPresetAction; |
| |
| /** |
| * @author Istvan Rath |
| */ |
| public class PresetGroup extends ActionGroup { |
| |
| |
| /** |
| * default preset to use. |
| */ |
| VisualisationPreset defaultPreset; |
| |
| public VisualisationPreset getDefaultPreset() { |
| return defaultPreset; |
| } |
| |
| public PresetGroup() { |
| // ExtensionAccess.reInit(); |
| for (Category c : ExtensionAccess.getAllCategories()) { |
| for (NamedElement<VisualisationPreset> vp_named : c.presets.values()) { |
| if (vp_named.element.id.equals("org.eclipse.viatra2.visualisation.preset.default")) { |
| defaultPreset = vp_named.element; |
| } |
| } |
| } |
| } |
| |
| /* |
| * (non-Javadoc) |
| * |
| * @see |
| * org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface. |
| * action.IMenuManager) |
| */ |
| @Override |
| public void fillContextMenu(IMenuManager manager) { |
| |
| IMenuManager menu = new MenuManager("Presets"); |
| manager.add(menu); |
| // ExtensionAccess.reInit(); |
| for (Category c : ExtensionAccess.getAllCategories()) { |
| IMenuManager cateroryMenu = new MenuManager(c.name); |
| for (NamedElement<VisualisationPreset> vp_named : c.presets.values()) { |
| SelectPresetAction action = new SelectPresetAction(vp_named.name, vp_named.element); |
| cateroryMenu.add(action); |
| |
| if (vp_named.element.id.equals("org.eclipse.viatra2.visualisation.preset.default")) { |
| defaultPreset = vp_named.element; |
| } |
| } |
| menu.add(cateroryMenu); |
| } |
| |
| } |
| |
| } |