1 19 package org.openharmonise.him.window.toolbars; 20 21 import java.awt.*; 22 import java.util.*; 23 24 import javax.swing.*; 25 26 import org.openharmonise.him.actions.*; 27 import org.openharmonise.him.actions.file.*; 28 import org.openharmonise.him.actions.publish.*; 29 import org.openharmonise.him.actions.xslt.*; 30 import org.openharmonise.vfs.context.*; 31 32 33 39 public class ToolBar extends JToolBar implements ContextListener { 40 41 private ArrayList m_aActions = new ArrayList(); 42 43 46 public ToolBar() { 47 super("Main toolbar"); 48 this.setup(); 49 } 50 51 54 private ToolBar(int arg0) { 55 super(arg0); 56 } 57 58 61 private ToolBar(String arg0) { 62 super(arg0); 63 } 64 65 69 private ToolBar(String arg0, int arg1) { 70 super(arg0, arg1); 71 } 72 73 private void setup() { 74 HIMAction action = new ActionNewFile(); 75 this.m_aActions.add(action); 76 this.add( action.getButton()); 77 78 action = new ActionOpen(); 79 this.m_aActions.add(action); 80 this.add( action.getButton()); 81 82 this.addSeparator(); 83 84 action = new ActionPreview(); 85 this.m_aActions.add(action); 86 this.add( action.getButton()); 87 88 this.addSeparator(); 89 90 action = new ActionPublishToInternet(); 91 this.m_aActions.add(action); 92 this.add( action.getButton()); 93 94 this.addSeparator(); 95 96 action = new ActionSynchronise(); 97 this.m_aActions.add(action); 98 this.add( action.getButton()); 99 100 this.addSeparator(); 101 102 action = new ActionDownloadImports(); 103 this.m_aActions.add(action); 104 this.add( action.getButton()); 105 106 ContextHandler.getInstance().addListener( 107 ContextType.CONTEXT_FILES, 108 this); 109 ContextHandler.getInstance().addListener( 110 ContextType.CONTEXT_DIRS, 111 this); 112 ContextHandler.getInstance().addListener( 113 ContextType.CONTEXT_TABS, 114 this); 115 116 this.setPreferredSize(new Dimension(this.getPreferredSize().width, 30) ); 117 } 118 119 122 public void contextMessage(ContextEvent ce) { 123 if (ce.CONTEXT_TYPE == ContextType.CONTEXT_DIRS) { 124 Iterator itor = this.m_aActions.iterator(); 125 while(itor.hasNext()) { 126 HIMAction action = (HIMAction) itor.next(); 127 action.isEnabled(ce); 128 } 129 } else if (ce.CONTEXT_TYPE == ContextType.CONTEXT_FILES) { 130 Iterator itor = this.m_aActions.iterator(); 131 while(itor.hasNext()) { 132 HIMAction action = (HIMAction) itor.next(); 133 action.isEnabled(ce); 134 } 135 } else if (ce.CONTEXT_TYPE == ContextType.CONTEXT_TABS) { 136 Iterator itor = this.m_aActions.iterator(); 137 while(itor.hasNext()) { 138 HIMAction action = (HIMAction) itor.next(); 139 action.isEnabled(ce); 140 } 141 } 142 } 143 144 } 145 | Popular Tags |