Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Violet/VioletProductSwing/VioletProduct.swing/src/main/java/com/horstmann/violet/UMLEditorApplet.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
125 lines (104 sloc)
4.58 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Violet - A program for editing UML diagrams. | |
Copyright (C) 2002 Cay S. Horstmann (http://horstmann.com) | |
This program is free software; you can redistribute it and/or modify | |
it under the terms of the GNU General Public License as published by | |
the Free Software Foundation; either version 2 of the License, or | |
(at your option) any later version. | |
This program 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 General Public License for more details. | |
You should have received a copy of the GNU General Public License | |
along with this program; if not, write to the Free Software | |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
*/ | |
package com.horstmann.violet; | |
import java.awt.event.WindowAdapter; | |
import java.awt.event.WindowEvent; | |
import java.util.ArrayList; | |
import java.util.List; | |
import javax.swing.JApplet; | |
import javax.swing.JFrame; | |
import com.horstmann.violet.application.gui.MainFrame; | |
import com.horstmann.violet.framework.dialog.DialogFactory; | |
import com.horstmann.violet.framework.dialog.DialogFactoryMode; | |
import com.horstmann.violet.framework.file.chooser.IFileChooserService; | |
import com.horstmann.violet.framework.file.chooser.JFileChooserService; | |
import com.horstmann.violet.framework.file.persistence.IFilePersistenceService; | |
import com.horstmann.violet.framework.file.persistence.StandardJavaFilePersistenceService; | |
import com.horstmann.violet.framework.injection.bean.ManiocFramework.BeanFactory; | |
import com.horstmann.violet.framework.injection.bean.ManiocFramework.BeanInjector; | |
import com.horstmann.violet.framework.injection.bean.ManiocFramework.InjectedBean; | |
import com.horstmann.violet.framework.plugin.PluginLoader; | |
import com.horstmann.violet.framework.theme.ClassicMetalTheme; | |
import com.horstmann.violet.framework.theme.ITheme; | |
import com.horstmann.violet.framework.theme.ThemeManager; | |
import com.horstmann.violet.framework.theme.VistaBlueTheme; | |
import com.horstmann.violet.framework.userpreferences.AppletUserPreferencesDao; | |
import com.horstmann.violet.framework.userpreferences.IUserPreferencesDao; | |
/** | |
* A program for editing UML diagrams. | |
*/ | |
public class UMLEditorApplet extends JApplet | |
{ | |
/* | |
* Applet entry point (non-Javadoc) | |
* | |
* @see java.applet.Applet#init() | |
*/ | |
public void init() | |
{ | |
initBeanFactory(); | |
BeanInjector.getInjector().inject(this); | |
createAppletWorkspace(); | |
} | |
private void initBeanFactory() { | |
IUserPreferencesDao userPreferencesDao = new AppletUserPreferencesDao(); | |
BeanFactory.getFactory().register(IUserPreferencesDao.class, userPreferencesDao); | |
ThemeManager themeManager = new ThemeManager(); | |
ITheme theme1 = new ClassicMetalTheme(); | |
ITheme theme2 = new VistaBlueTheme(); | |
List<ITheme> themeList = new ArrayList<ITheme>(); | |
themeList.add(theme1); | |
themeList.add(theme2); | |
themeManager.setInstalledThemes(themeList); | |
themeManager.setInstalledThemes(themeList); | |
BeanFactory.getFactory().register(ThemeManager.class, themeManager); | |
themeManager.applyPreferedTheme(); | |
IFilePersistenceService filePersistenceService = new StandardJavaFilePersistenceService(); | |
BeanFactory.getFactory().register(IFilePersistenceService.class, filePersistenceService); | |
DialogFactory dialogFactory = new DialogFactory(DialogFactoryMode.INTERNAL); | |
BeanFactory.getFactory().register(DialogFactory.class, dialogFactory); | |
IFileChooserService fileChooserService = new JFileChooserService(); | |
BeanFactory.getFactory().register(IFileChooserService.class, fileChooserService); | |
} | |
/** | |
* Creates workspace when application works as an applet. It contains :<br> | |
* + plugins loading + GUI theme management + launging argments to open diagram<br> | |
*/ | |
private void createAppletWorkspace() | |
{ | |
installPlugins(); | |
MainFrame mainFrame = new MainFrame(); | |
mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); | |
mainFrame.addWindowListener(new WindowAdapter() | |
{ | |
public void windowClosed(WindowEvent e) | |
{ | |
System.out.println("editor closed"); | |
} | |
}); | |
setContentPane(mainFrame.getContentPane()); | |
setJMenuBar(mainFrame.getJMenuBar()); | |
} | |
/** | |
* Install plugins | |
*/ | |
private void installPlugins() | |
{ | |
this.pluginLoader.installPlugins(); | |
} | |
@InjectedBean | |
private PluginLoader pluginLoader; | |
} |