There were done some refactoring in the MenuControlServiceImpl and was created MenuVa...
[indepmod.git] / Plugins / EPC / NotationEPC / src / cz / cvut / promod / epc / EPCNotation.java
blob298e0ae854e75dfb8b282a2daf12cbd630dc6ccd
1 package cz.cvut.promod.epc;
3 import com.jidesoft.dialog.AbstractDialogPage;
4 import com.jidesoft.status.LabelStatusBarItem;
5 import com.jidesoft.swing.JideBoxLayout;
6 import cz.cvut.promod.epc.ioController.EPCNotationIOController;
7 import cz.cvut.promod.epc.modelFactory.EPCNotationModelFactory;
8 import cz.cvut.promod.epc.resources.Resources;
9 import cz.cvut.promod.epc.settings.EPCSettings;
10 import cz.cvut.promod.gui.Modeler;
11 import cz.cvut.promod.plugin.notationSpecificPlugIn.DockableFrameData;
12 import cz.cvut.promod.plugin.notationSpecificPlugIn.notation.NotationWorkspaceData;
13 import cz.cvut.promod.plugin.notationSpecificPlugIn.notation.factory.DiagramModelFactory;
14 import cz.cvut.promod.plugin.notationSpecificPlugIn.notation.localIOController.NotationLocalIOController;
15 import cz.cvut.promod.services.ModelerSession;
16 import cz.cvut.promod.services.menuService.MenuService;
17 import cz.cvut.promod.services.menuService.utils.InsertMenuItemResult;
18 import cz.cvut.promod.services.menuService.utils.MenuItemPosition;
19 import org.apache.log4j.Logger;
20 import cz.cvut.promod.services.actionService.actionUtils.ProModAction;
22 import javax.swing.*;
23 import java.io.File;
24 import java.io.FileReader;
25 import java.io.IOException;
26 import java.util.List;
27 import java.util.Properties;
28 import java.util.Set;
30 /**
31 * ProMod, master thesis project
32 * User: Petr Zverina, petr.zverina@gmail.com
33 * Date: 19:41:58, 5.12.2009
35 * Implementation of EPC modeling notation.
37 public class EPCNotation implements cz.cvut.promod.plugin.notationSpecificPlugIn.notation.Notation{
39 private static final Logger LOG = Logger.getLogger(EPCNotation.class);
41 public static final String EPC_LABEL = Resources.getResources().getString("epc.menu.epc");
43 private final LabelStatusBarItem selectedToolStatusBarItem;
45 private final EPCNotationModel model;
47 private final EPCNotationModelFactory modelFactory;
49 private final EPCNotationIOController ioController;
51 private final String NOTATION_DESCRIPTION =
52 Resources.getResources().getString("epc.description");
53 private final String NOTATION_TOOL_TIP =
54 Resources.getResources().getString("epc.tool.tip");
57 public EPCNotation(final File propertiesFile) throws InstantiationException {
58 final Properties properties = new Properties();
59 try {
60 properties.load(new FileReader(propertiesFile));
61 } catch (IOException e) {
62 LOG.error("Properties for the EPC Notations couldn't be read.", e);
63 throw new InstantiationException("Mandatory properties couldn't be read.");
66 final EPCSettings settings = new EPCSettings(properties);
67 EPCSettings.setInstance(settings);
69 selectedToolStatusBarItem = new LabelStatusBarItem();
71 model = new EPCNotationModel(properties, selectedToolStatusBarItem);
73 modelFactory = new EPCNotationModelFactory();
75 ioController = new EPCNotationIOController(model.getExtension(), getIdentifier());
78 /** {@inheritDoc} */
79 public String getName() {
80 return model.getName();
83 /** {@inheritDoc} */
84 public String getDescription() {
85 return model.getDescription();
88 /** {@inheritDoc} */
89 public Set<DockableFrameData> getDockableFrames() {
90 return model.getDockableFrames();
93 /** {@inheritDoc} */
94 public String getFullName() {
95 return model.getFullName();
98 /** {@inheritDoc} */
99 public String getAbbreviation() {
100 return model.getAbbreviation();
103 /** {@inheritDoc} */
104 public Icon getNotationIcon() {
105 return Resources.getIcon(Resources.ICONS + Resources.DIAGRAM);
108 /** {@inheritDoc} */
109 public String getNotationToolTip() {
110 return NOTATION_TOOL_TIP;
113 /** {@inheritDoc} */
114 public NotationWorkspaceData getNotationWorkspaceData() {
115 return model.getWorkspace();
118 /** {@inheritDoc} */
119 public ImageIcon getNotationPreviewImage() {
120 return Resources.getIcon(Resources.ICONS + Resources.PREVIEW);
123 /** {@inheritDoc} */
124 public String getNotationPreviewText() {
125 return NOTATION_DESCRIPTION;
128 /** {@inheritDoc} */
129 public DiagramModelFactory getDiagramModelFactory() {
130 return modelFactory;
133 /** {@inheritDoc} */
134 public NotationLocalIOController getLocalIOController() {
135 return ioController;
138 /** {@inheritDoc} */
139 public String getIdentifier() {
140 return model.getIdentifier();
143 public InsertMenuItemResult addPopupMenuItem(final ProModAction proModAction, final MenuItemPosition menuItemPosition,final MenuService.MenuSeparator menuSeparator, final boolean checkable){
144 return model.addPopupMenuAction(proModAction, menuItemPosition, menuSeparator, checkable);
147 /** {@inheritDoc} */
148 public void init() {
149 initActions();
151 initMainMenu();
153 initToolBar();
155 initStatusBar();
159 * Initialize epc notation specific status bar items.
161 private void initStatusBar() {
162 ModelerSession.getStatusBarService().addStatusBarItem(
163 getIdentifier(), selectedToolStatusBarItem, JideBoxLayout.FIX
167 private void initToolBar() {
168 ModelerSession.getToolBarService().addAction(
169 getIdentifier(),
170 model.getAction(EPCNotationModel.UNDO_ACTION_KEY)
173 ModelerSession.getToolBarService().addAction(
174 getIdentifier(),
175 model.getAction(EPCNotationModel.REDO_ACTION_KEY)
178 ModelerSession.getToolBarService().addAction(
179 getIdentifier(),
180 model.getAction(EPCNotationModel.SAVE_ACTION_KEY)
183 ModelerSession.getToolBarService().addAction(
184 getIdentifier(),
185 model.getAction(EPCNotationModel.SAVE_ALL_ACTION_KEY)
189 /** {@inheritDoc} */
190 public void finish() { }
192 private void initActions() {
193 ModelerSession.getActionService().registerAction(
194 getIdentifier(),
195 model.getActionIdentifier(EPCNotationModel.REFRESH_ACTION_KEY),
196 model.getAction(EPCNotationModel.REFRESH_ACTION_KEY)
199 ModelerSession.getActionService().registerAction(
200 getIdentifier(),
201 model.getActionIdentifier(EPCNotationModel.DELETE_ACTION_KEY),
202 model.getAction(EPCNotationModel.DELETE_ACTION_KEY)
205 ModelerSession.getActionService().registerAction(
206 getIdentifier(),
207 model.getActionIdentifier(EPCNotationModel.UNDO_ACTION_KEY),
208 model.getAction(EPCNotationModel.UNDO_ACTION_KEY)
211 ModelerSession.getActionService().registerAction(
212 getIdentifier(),
213 model.getActionIdentifier(EPCNotationModel.REDO_ACTION_KEY),
214 model.getAction(EPCNotationModel.REDO_ACTION_KEY)
217 ModelerSession.getActionService().registerAction(
218 getIdentifier(),
219 model.getActionIdentifier(EPCNotationModel.SAVE_ACTION_KEY),
220 model.getAction(EPCNotationModel.SAVE_ACTION_KEY)
223 ModelerSession.getActionService().registerAction(
224 getIdentifier(),
225 model.getActionIdentifier(EPCNotationModel.SAVE_ALL_ACTION_KEY),
226 model.getAction(EPCNotationModel.SAVE_ALL_ACTION_KEY)
230 private void initMainMenu() {
231 ModelerSession.getMenuService().insertMainMenuItem(
232 model.getAction(EPCNotationModel.SAVE_ACTION_KEY),
233 new MenuItemPosition(Modeler.FILE_LABEL, MenuItemPosition.PlacementStyle.FIRST)
237 ModelerSession.getMenuService().insertMainMenuItem(
238 model.getAction(EPCNotationModel.REFRESH_ACTION_KEY),
239 new MenuItemPosition(EPC_LABEL)
243 /** {@inheritDoc} */
244 public List<AbstractDialogPage> getSettingPages() {
245 return EPCSettings.getInstance().getSettingPages();