Converted all CRLF to LF.
[indepmod/experimental.git] / IndependentModeler / src / cz / cvut / promod / services / statusBarService / StatusBarControlServiceImpl.java
blob81aaf859c48312c3fa8dafe0344918d34d59db91
1 package cz.cvut.promod.services.statusBarService;
3 import com.jidesoft.status.StatusBar;
4 import com.jidesoft.status.StatusBarItem;
5 import com.jidesoft.swing.JideBoxLayout;
7 import java.util.Map;
8 import java.util.HashMap;
10 import cz.cvut.promod.services.ModelerSession;
11 import cz.cvut.promod.services.statusBarService.utils.InsertStatusBarItemResult;
12 import cz.cvut.promod.gui.ModelerModel;
13 import org.apache.log4j.Logger;
15 /**
16 * ProMod, master thesis project
17 * User: Petr Zverina, petr.zverina@gmail.com
18 * Date: 14:54:23, 21.1.2010
21 /**
22 * StatusBarControlService implementation.
24 public class StatusBarControlServiceImpl implements StatusBarControlService{
26 private static final Logger LOG = Logger.getLogger(StatusBarControlServiceImpl.class);
28 private final Map<String, StatusBar> statusBarMap;
31 /**
32 * Constructs a new StatusBarControlServiceImpl instance.
34 public StatusBarControlServiceImpl() {
35 statusBarMap = new HashMap<String, StatusBar>();
38 /** {@inheritDoc} */
39 public StatusBar getStatusBar(final String notationIdentifier) {
40 if(notationIdentifier == null){
41 return null;
44 if(!ModelerSession.getNotationService().existNotation(notationIdentifier)
45 && !notationIdentifier.equals(ModelerModel.MODELER_IDENTIFIER)){
46 return null;
49 if(statusBarMap.containsKey(notationIdentifier)){
50 return statusBarMap.get(notationIdentifier);
53 final StatusBar statusBar = ModelerSession.getComponentFactoryService().createStatusBar();
54 statusBarMap.put(notationIdentifier, statusBar);
56 return statusBar;
59 /** {@inheritDoc} */
60 public InsertStatusBarItemResult addStatusBarItem(final String notationIdentifier,
61 final StatusBarItem statusBarItem,
62 String itemLayout) {
64 if(!ModelerSession.getNotationService().existNotation(notationIdentifier)
65 && !ModelerModel.MODELER_IDENTIFIER.equals(notationIdentifier)){
66 LOG.error("Not possible to insert action to the tool bar of not existing notation.");
67 return InsertStatusBarItemResult.INVALID_NOTATION;
70 if(statusBarItem == null){
71 LOG.error("Invalid status bar item to be inserted.");
72 return InsertStatusBarItemResult.INVALID_STATUS_BAR_ITEM;
75 if(itemLayout == null){
76 LOG.info("Setting status bar layout to implicit value");
77 itemLayout = JideBoxLayout.FIX;
80 final StatusBar statusBar = getStatusBar(notationIdentifier);
82 if(!(itemLayout.equals(JideBoxLayout.FIX)
83 || itemLayout.equals(JideBoxLayout.FLEXIBLE)
84 || itemLayout.equals(JideBoxLayout.VARY))){
86 itemLayout = JideBoxLayout.FIX;
89 statusBar.add(statusBarItem, itemLayout);
91 return InsertStatusBarItemResult.SUCCESS;
94 /** {@inheritDoc} */
95 public boolean check() {
96 return true;