/* * Moonlight|3D Copyright (C) 2005 The Moonlight|3D team * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Created on Jul 15, 2005 */ package ml.ui.core; /** * \package ml.ui.core * * This is the core user interface framework for Moonlight|3D. * It contains all the code to dynamically build views and menu bars * from the configuration files. * * This package is part of the core program. */ import java.util.ArrayList; import ml.core.exceptions.Exception; import ml.core.helper.Factory; import com.trolltech.qt.gui.QApplication; import com.trolltech.qt.gui.QSyntaxHighlighter; import com.trolltech.qt.gui.QWidget; public class UIManager { private ArrayList layouts; private ArrayList windows; private ArrayList mainWidgetFactories; private ArrayList actions; private ArrayList actionGenerators; private ArrayList syntaxHighlighterFactories; public UIManager() { layouts=new ArrayList(); windows=new ArrayList(); mainWidgetFactories=new ArrayList(); actions=new ArrayList(); actionGenerators=new ArrayList(); syntaxHighlighterFactories=new ArrayList(); } public void addOrReplaceLayout(FrameLayout newLayout) { for(FrameLayout layout : layouts) { if(layout.getName().equals(newLayout.getName())) { layouts.remove(layout); break; } } layouts.add(newLayout); } public FrameLayout getLayout(String name) throws Exception { for(int i=0;i getApplicationWindows() { return (ArrayList) windows.clone(); } public ApplicationWindow getActiveApplicationWindow() { return (ApplicationWindow) QApplication.activeWindow(); } public void registerAction(Action action) { actions.add(action); } public void unregisterAction(Action action) { actions.remove(action); } public void unregisterAction(String actionName) { for(Action action : actions) { if(action.getName().equals(actionName)) { actions.remove(action); return; } } } public ArrayList getActions() { return (ArrayList) actions.clone(); } public Action getActionByName(String actionName) throws Exception { for(Action action : actions) { if(action.getName().equals(actionName)) { return action; } } throw new Exception("No action named \"" + actionName + "\" registered"); } public void registerActionGenerator(ActionGenerator generator) { actionGenerators.add(generator); } public void unregisterActionGenerator(ActionGenerator generator) { actionGenerators.remove(generator); } public void unregisterActionGenerator(String generatorName) { for(ActionGenerator generator : actionGenerators) { if(generator.getName().equals(generatorName)) { actionGenerators.remove(generator); return; } } } public ArrayList getActionGenerators() { return (ArrayList) actionGenerators.clone(); } public ActionGenerator getActionGeneratorByName(String generatorName) throws Exception { for(ActionGenerator generator : actionGenerators) { if(generator.getName().equals(generatorName)) { return generator; } } throw new Exception("No action generator named \"" + generatorName + "\" registered"); } public void registerMainWidgetFactory(MainWidgetFactory factory) { mainWidgetFactories.add(factory); } public void unregisterMainWidgetFactory(String name) { for(int i=0;i