001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.him.window.toolbars;
020:
021: import java.awt.*;
022: import java.util.*;
023:
024: import javax.swing.*;
025:
026: import org.openharmonise.him.actions.*;
027: import org.openharmonise.him.actions.file.*;
028: import org.openharmonise.him.actions.publish.*;
029: import org.openharmonise.him.actions.xslt.*;
030: import org.openharmonise.vfs.context.*;
031:
032: /**
033: *
034: * @author Matthew Large
035: * @version $Revision: 1.1 $
036: *
037: */
038: public class ToolBar extends JToolBar implements ContextListener {
039:
040: private ArrayList m_aActions = new ArrayList();
041:
042: /**
043: *
044: */
045: public ToolBar() {
046: super ("Main toolbar");
047: this .setup();
048: }
049:
050: /**
051: * @param arg0
052: */
053: private ToolBar(int arg0) {
054: super (arg0);
055: }
056:
057: /**
058: * @param arg0
059: */
060: private ToolBar(String arg0) {
061: super (arg0);
062: }
063:
064: /**
065: * @param arg0
066: * @param arg1
067: */
068: private ToolBar(String arg0, int arg1) {
069: super (arg0, arg1);
070: }
071:
072: private void setup() {
073: HIMAction action = new ActionNewFile();
074: this .m_aActions.add(action);
075: this .add(action.getButton());
076:
077: action = new ActionOpen();
078: this .m_aActions.add(action);
079: this .add(action.getButton());
080:
081: this .addSeparator();
082:
083: action = new ActionPreview();
084: this .m_aActions.add(action);
085: this .add(action.getButton());
086:
087: this .addSeparator();
088:
089: action = new ActionPublishToInternet();
090: this .m_aActions.add(action);
091: this .add(action.getButton());
092:
093: this .addSeparator();
094:
095: action = new ActionSynchronise();
096: this .m_aActions.add(action);
097: this .add(action.getButton());
098:
099: this .addSeparator();
100:
101: action = new ActionDownloadImports();
102: this .m_aActions.add(action);
103: this .add(action.getButton());
104:
105: ContextHandler.getInstance().addListener(
106: ContextType.CONTEXT_FILES, this );
107: ContextHandler.getInstance().addListener(
108: ContextType.CONTEXT_DIRS, this );
109: ContextHandler.getInstance().addListener(
110: ContextType.CONTEXT_TABS, this );
111:
112: this .setPreferredSize(new Dimension(
113: this .getPreferredSize().width, 30));
114: }
115:
116: /* (non-Javadoc)
117: * @see com.simulacramedia.contentmanager.context.ContextListener#contextMessage(com.simulacramedia.contentmanager.context.ContextEvent)
118: */
119: public void contextMessage(ContextEvent ce) {
120: if (ce.CONTEXT_TYPE == ContextType.CONTEXT_DIRS) {
121: Iterator itor = this .m_aActions.iterator();
122: while (itor.hasNext()) {
123: HIMAction action = (HIMAction) itor.next();
124: action.isEnabled(ce);
125: }
126: } else if (ce.CONTEXT_TYPE == ContextType.CONTEXT_FILES) {
127: Iterator itor = this .m_aActions.iterator();
128: while (itor.hasNext()) {
129: HIMAction action = (HIMAction) itor.next();
130: action.isEnabled(ce);
131: }
132: } else if (ce.CONTEXT_TYPE == ContextType.CONTEXT_TABS) {
133: Iterator itor = this .m_aActions.iterator();
134: while (itor.hasNext()) {
135: HIMAction action = (HIMAction) itor.next();
136: action.isEnabled(ce);
137: }
138: }
139: }
140:
141: }
|