solving of bug number 3043572
[indepmod.git] / Plugins / ProcessHierarchy / NotationProcessHierarchy / src / cz / cvut / promod / hierarchyNotation / ProcessHierarchyNotation.java
blob7314e2ece06e5adf8ee43d7fa7231a1fec5feda1
1 package cz.cvut.promod.hierarchyNotation;
3 import com.jgoodies.binding.PresentationModel;
4 import com.jgoodies.binding.value.ValueModel;
5 import com.jidesoft.status.LabelStatusBarItem;
6 import com.jidesoft.swing.JideBoxLayout;
7 import cz.cvut.promod.gui.Modeler;
8 import cz.cvut.promod.gui.settings.SettingPageData;
9 import cz.cvut.promod.hierarchyNotation.ioController.ProcessHierarchyIOController;
10 import cz.cvut.promod.hierarchyNotation.modelFactory.ProcessHierarchyModelFactory;
11 import cz.cvut.promod.hierarchyNotation.resources.Resources;
12 import cz.cvut.promod.plugin.notationSpecificPlugIn.DockableFrameData;
13 import cz.cvut.promod.plugin.notationSpecificPlugIn.notation.NotationWorkspaceData;
14 import cz.cvut.promod.plugin.notationSpecificPlugIn.notation.factory.DiagramModelFactory;
15 import cz.cvut.promod.plugin.notationSpecificPlugIn.notation.localIOController.NotationLocalIOController;
16 import cz.cvut.promod.services.ModelerSession;
17 import cz.cvut.promod.services.actionService.actionUtils.ProModAction;
18 import cz.cvut.promod.services.menuService.MenuService;
19 import cz.cvut.promod.services.menuService.utils.InsertMenuItemResult;
20 import cz.cvut.promod.services.menuService.utils.MenuItemPosition;
22 import javax.swing.*;
23 import java.util.List;
24 import java.util.Set;
26 /**
27 * ProMod, master thesis project
28 * User: Petr Zverina, petr.zverina@gmail.com
29 * Date: 23:30:50, 25.11.2009
31 * Implementation of a ProcessHierarchyNotation plugin.
33 public class ProcessHierarchyNotation implements cz.cvut.promod.plugin.notationSpecificPlugIn.notation.Notation{
35 private final ProcessHierarchyNotationModel model;
37 private final ProcessHierarchyModelFactory modelFactory;
39 private final ProcessHierarchyIOController ioController;
41 private final ValueModel checkTreeStructureModel;
43 private static final Icon ICON = Resources.getIcon(Resources.ICONS + Resources.DIAGRAM);
45 private final LabelStatusBarItem statusBarItem = ModelerSession.getComponentFactoryService().createLabelStatusBarItem();
47 /**
48 * Parameter-less constructor.
50 public ProcessHierarchyNotation(){
51 model = new ProcessHierarchyNotationModel(statusBarItem);
53 final PresentationModel<ProcessHierarchyNotationModel> presentation =
54 new PresentationModel<ProcessHierarchyNotationModel>(model);
56 checkTreeStructureModel = presentation.getModel(ProcessHierarchyNotationModel.CHECK_TREE_STRUCTURE_PROPERTY);
58 checkTreeStructureModel.setValue(true); // initialize is this check turned on
60 modelFactory = new ProcessHierarchyModelFactory();
62 ioController = new ProcessHierarchyIOController(model.getExtension(), getIdentifier());
64 initComponents();
67 /** {@inheritDoc} */
68 public String getName() {
69 return model.getName();
72 /** {@inheritDoc} */
73 public String getDescription() {
74 return model.getDescription();
77 /** {@inheritDoc} */
78 private void initComponents() {
79 statusBarItem.setHorizontalAlignment(JLabel.RIGHT);
82 /** {@inheritDoc} */
83 public Set<DockableFrameData> getDockableFrames() {
84 return model.getDockableFrames();
87 /** {@inheritDoc} */
88 public String getFullName() {
89 return model.getFullName();
92 /** {@inheritDoc} */
93 public String getAbbreviation() {
94 return model.getAbbreviation();
97 /** {@inheritDoc} */
98 public Icon getNotationIcon() {
99 return ICON;
102 /** {@inheritDoc} */
103 public String getNotationToolTip() {
104 return "Process Hierarchy.";
107 /** {@inheritDoc} */
108 public NotationWorkspaceData getNotationWorkspaceData() {
109 return model.getWorkspace();
112 /** {@inheritDoc} */
113 public ImageIcon getNotationPreviewImage() {
114 return Resources.getIcon(Resources.ICONS + Resources.PREVIEW);
117 /** {@inheritDoc} */
118 public String getNotationPreviewText() {
119 return "Process Hierarchy Notation is supposed to be used for a process or organization hierarchy modeling. It is not a standard kind of flow-chart. Use the processes and build the hierarchical structure.";
122 /** {@inheritDoc} */
123 public DiagramModelFactory getDiagramModelFactory() {
124 return modelFactory;
127 /** {@inheritDoc} */
128 public NotationLocalIOController getLocalIOController() {
129 return ioController;
132 /** {@inheritDoc} */
133 public String getIdentifier() {
134 return model.getIdentifier();
138 * Process Hierarchy notation does NOT support popup menu functionality.
140 * {@inheritDoc}
142 public InsertMenuItemResult addPopupMenuItem(ProModAction proModAction, MenuItemPosition menuItemPosition, MenuService.MenuSeparator menuSeparator, boolean checkable){
143 return InsertMenuItemResult.POPUP_NOT_SUPPORTED;
146 /** {@inheritDoc} */
147 public List<SettingPageData> getSettingPages() {
148 return null;
151 /** {@inheritDoc} */
152 public void init() {
153 initActions();
155 initToolBar();
157 initStatusBar();
159 initMainMenu();
162 private void initMainMenu() {
163 ModelerSession.getMenuService().insertMainMenuItem(
164 model.getAction(ProcessHierarchyNotationModel.SAVE_ACTION_KEY),
165 new MenuItemPosition(Modeler.FILE_LABEL, MenuItemPosition.PlacementStyle.FIRST
169 ModelerSession.getMenuService().insertMainMenuItem(
170 model.getAction(ProcessHierarchyNotationModel.REFRESH_ACTION_KEY),
171 new MenuItemPosition(ProcessHierarchyNotationModel.PROCESS_HIERARCHY_LABEL)
175 private void initStatusBar() {
177 ModelerSession.getStatusBarService().addStatusBarItem(
178 getIdentifier(), statusBarItem, JideBoxLayout.VARY
182 private void initToolBar() {
183 ModelerSession.getToolBarService().addAction(
184 getIdentifier(),
185 model.getAction(ProcessHierarchyNotationModel.SAVE_ACTION_KEY)
188 ModelerSession.getToolBarService().addAction(
189 getIdentifier(),
190 model.getAction(ProcessHierarchyNotationModel.SAVE_ALL_ACTION_KEY)
193 ModelerSession.getToolBarControlService().getCommandBar(getIdentifier()).addSeparator();
195 ModelerSession.getToolBarService().addAction(
196 getIdentifier(),
197 model.getAction(ProcessHierarchyNotationModel.REFRESH_ACTION_KEY)
200 ModelerSession.getToolBarService().addAction(
201 getIdentifier(),
202 model.getAction(ProcessHierarchyNotationModel.DELETE_ACTION_KEY)
205 ModelerSession.getToolBarControlService().getCommandBar(getIdentifier()).addSeparator();
207 ModelerSession.getToolBarControlService().getCommandBar(getIdentifier()).add(createTreeTestCheckBox());
210 private JCheckBox createTreeTestCheckBox() {
211 final JCheckBox checkBox = ModelerSession.getComponentFactoryService().createCheckBox();
212 checkBox.setText(ProcessHierarchyNotationModel.CHECK_TREE_STRUCTURE_LABEL);
214 com.jgoodies.binding.adapter.Bindings.bind(checkBox, checkTreeStructureModel);
216 return checkBox;
219 private void initActions() {
220 ModelerSession.getActionService().registerAction(
221 getIdentifier(),
222 ProcessHierarchyNotationModel.REFRESH_ACTION_KEY,
223 model.getAction(ProcessHierarchyNotationModel.REFRESH_ACTION_KEY)
226 ModelerSession.getActionService().registerAction(
227 getIdentifier(),
228 ProcessHierarchyNotationModel.DELETE_ACTION_KEY,
229 model.getAction(ProcessHierarchyNotationModel.DELETE_ACTION_KEY)
232 ModelerSession.getActionService().registerAction(
233 getIdentifier(),
234 ProcessHierarchyNotationModel.SAVE_ACTION_KEY,
235 model.getAction(ProcessHierarchyNotationModel.SAVE_ACTION_KEY)
238 ModelerSession.getActionService().registerAction(
239 getIdentifier(),
240 ProcessHierarchyNotationModel.SAVE_ALL_ACTION_KEY,
241 model.getAction(ProcessHierarchyNotationModel.SAVE_ALL_ACTION_KEY)
245 /** {@inheritDoc} */
246 public void finish() { }
248 public boolean checkTreeStructure(){
249 return (Boolean) checkTreeStructureModel.getValue();
253 * Sets a text to the label status bar item.
255 * @param text is the text to be displayed in the status bar
257 public void setStatusInfoText(final String text){
258 statusBarItem.setText(text);