001 /* 002 * Copyright 2002-2004 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 005 * use this file except in compliance with the License. You may obtain a copy of 006 * the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 013 * License for the specific language governing permissions and limitations under 014 * the License. 015 */ 016 package org.springframework.richclient.application.support; 017 018 import java.util.ArrayList; 019 import java.util.Collections; 020 import java.util.Iterator; 021 import java.util.List; 022 023 import org.springframework.richclient.command.ActionCommand; 024 import org.springframework.richclient.command.CommandRegistry; 025 import org.springframework.richclient.command.CommandServices; 026 import org.springframework.richclient.command.support.DefaultCommandManager; 027 028 public class ApplicationWindowCommandManager extends DefaultCommandManager { 029 private List sharedCommands; 030 031 public ApplicationWindowCommandManager() { 032 super(); 033 } 034 035 public ApplicationWindowCommandManager(CommandRegistry parent) { 036 super(parent); 037 } 038 039 public ApplicationWindowCommandManager(CommandServices commandServices) { 040 super(commandServices); 041 } 042 043 public void setSharedCommandIds(String[] sharedCommandIds) { 044 if (sharedCommandIds.length == 0) { 045 sharedCommands = Collections.EMPTY_LIST; 046 } 047 else { 048 this.sharedCommands = new ArrayList(sharedCommandIds.length); 049 for (int i = 0; i < sharedCommandIds.length; i++) { 050 ActionCommand globalCommand = createTargetableActionCommand(sharedCommandIds[i], null); 051 sharedCommands.add(globalCommand); 052 } 053 } 054 } 055 056 public Iterator getSharedCommands() { 057 if (sharedCommands == null) { 058 return Collections.EMPTY_LIST.iterator(); 059 } 060 return sharedCommands.iterator(); 061 } 062 063 }