1 package fr.ifremer.quadrige2.magicdraw; 2 3 /*- 4 * #%L 5 * Quadrige2 Core :: Quadrige2 Magicdraw plugin 6 * $Id:$ 7 * $HeadURL:$ 8 * %% 9 * Copyright (C) 2017 Ifremer 10 * %% 11 * This program is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Affero General Public License as published by 13 * the Free Software Foundation, either version 3 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU Affero General Public License 22 * along with this program. If not, see <http://www.gnu.org/licenses/>. 23 * #L% 24 */ 25 26 27 import com.nomagic.actions.ActionsCategory; 28 import com.nomagic.actions.NMAction; 29 import com.nomagic.magicdraw.actions.ActionsConfiguratorsManager; 30 import fr.ifremer.quadrige2.magicdraw.action.TeamWorkPortRedirectionAction; 31 import fr.ifremer.quadrige2.magicdraw.action.TransformModelAction; 32 import fr.ifremer.quadrige2.magicdraw.action.TransformationType; 33 import fr.ifremer.quadrige2.magicdraw.menu.MainMenuConfigurator; 34 35 public class Plugin extends com.nomagic.magicdraw.plugins.Plugin 36 { 37 38 /** 39 * @see com.nomagic.magicdraw.plugins.Plugin#init() 40 */ 41 @Override 42 public void init() 43 { 44 ActionsConfiguratorsManager manager = ActionsConfiguratorsManager.getInstance(); 45 // adding actions with separator 46 manager.addMainMenuConfigurator(new MainMenuConfigurator(getSeparatedActions())); 47 } 48 49 /** 50 * @see com.nomagic.magicdraw.plugins.Plugin#close() 51 */ 52 @Override 53 public boolean close() 54 { 55 return true; 56 } 57 58 /** 59 * @see com.nomagic.magicdraw.plugins.Plugin#isSupported() 60 */ 61 @Override 62 public boolean isSupported() 63 { 64 return true; 65 } 66 67 /** 68 * Creates group of actions. This group is separated from others using menu separator (when it represented in menu). 69 * Separator is added for group of actions in one actions category. 70 */ 71 private NMAction getSeparatedActions() 72 { 73 ActionsCategory category = new ActionsCategory(null, null); 74 75 String propertyFile = "quadrige2-magicdraw-plugin.properties"; 76 if (System.getProperty("quadrige2-magicdraw-plugin.properties") != null) { 77 propertyFile = System.getProperty("quadrige2-magicdraw-plugin.properties"); 78 } 79 80 // -------------------------------------------- 81 // This commented code was used for migration 82 // -------------------------------------------- 83 //{ 84 //String migrationPropertyFile = "quadrige2-magicdraw-plugin-migration.properties"; 85 //if (System.getProperty("quadrige2-magicdraw-plugin-migration.properties") != null) { 86 // migrationPropertyFile = System.getProperty("quadrige2-magicdraw-plugin-migration.properties"); 87 //} 88 // category.addAction(new TransformModelQuadrigeAction(null, "Init Package / Dispatch / Entity ", 89 // TransformationType.QUADRIGE2_INIT, migrationPropertyFile)); 90 // category.addAction(new TransformModelQuadrigeAction(null, "Reset Package / Dispatch / Entity ", 91 // TransformationType.QUADRIGE2_RESET, migrationPropertyFile)); 92 // category.addAction(new TransformModelQuadrigeAction(null, "Apply Assigned Stereotype", 93 // TransformationType.QUADRIGE2_APPLY_STEREOTYPE_ASSIGNED, migrationPropertyFile)); 94 // category.addAction(new TransformModelQuadrigeAction(null, "Remove Assigned Stereotype", 95 // TransformationType.QUADRIGE2_REMOVE_STEREOTYPE_ASSIGNED, migrationPropertyFile)); 96 // 97 // category.addAction(new TransformModelAction(null, "Migrate to AndroMDA (<<Entity>> only)", 98 // TransformationType.MIGRATION_TO_ANDROMDA, migrationPropertyFile)); 99 //} 100 // -------------------------------------------- 101 102 category.addAction(new TransformModelAction(null, "Transform model as PIM", TransformationType.PIM, propertyFile)); 103 category.addAction(new TransformModelAction(null, "Transform model for PSF/server", TransformationType.PSF_SERVER, propertyFile)); 104 category.addAction(new TransformModelAction(null, "Transform model for PSF/client", TransformationType.PSF_CLIENT, propertyFile)); 105 106 // Action need for port redirection (need for TeamWork server) 107 category.addAction(new TeamWorkPortRedirectionAction(null, "TeamWork > Start port redirection...", propertyFile)); 108 109 return category; 110 } 111 112 113 }