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/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/VioletPlugin.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
138 lines (113 sloc)
4.64 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) 2007 Cay S. Horstmann (http://horstmann.com) | |
Alexandre de Pellegrin (http://alexdp.free.fr); | |
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.eclipseplugin; | |
import java.util.ArrayList; | |
import java.util.List; | |
import org.eclipse.jface.resource.ImageDescriptor; | |
import org.eclipse.ui.plugin.AbstractUIPlugin; | |
import org.osgi.framework.BundleContext; | |
import com.horstmann.violet.eclipseplugin.editors.EclipseDialogFactory; | |
import com.horstmann.violet.eclipseplugin.file.EclipseFileChooserService; | |
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.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.ITheme; | |
import com.horstmann.violet.framework.theme.ThemeManager; | |
import com.horstmann.violet.framework.userpreferences.DefaultUserPreferencesDao; | |
import com.horstmann.violet.framework.userpreferences.IUserPreferencesDao; | |
/** | |
* The main plugin class to be used in the desktop. This plugin embeds Violet in Eclipse | |
* | |
* @author Alexandre de Pellegrin | |
*/ | |
public class VioletPlugin extends AbstractUIPlugin | |
{ | |
// The shared instance. | |
private static VioletPlugin plugin; | |
@InjectedBean | |
private PluginLoader pluginLoader; | |
/** | |
* The constructor. | |
*/ | |
public VioletPlugin() | |
{ | |
plugin = this; | |
} | |
/** | |
* This method is called upon plug-in activation | |
*/ | |
public void start(BundleContext context) throws Exception | |
{ | |
super.start(context); | |
initBeanFactory(); | |
BeanInjector.getInjector().inject(this); | |
EclipseDialogFactory.init(); | |
installPlugins(); | |
} | |
private void initBeanFactory() { | |
IUserPreferencesDao userPreferencesDao = new DefaultUserPreferencesDao(); | |
BeanFactory.getFactory().register(IUserPreferencesDao.class, userPreferencesDao); | |
ThemeManager themeManager = new ThemeManager(); | |
List<ITheme> themeList = new ArrayList<ITheme>(); | |
themeManager.setInstalledThemes(themeList); | |
BeanFactory.getFactory().register(ThemeManager.class, themeManager); | |
IFilePersistenceService filePersistenceService = new StandardJavaFilePersistenceService(); | |
BeanFactory.getFactory().register(IFilePersistenceService.class, filePersistenceService); | |
DialogFactory dialogFactory = new DialogFactory(DialogFactoryMode.DELEGATED); | |
BeanFactory.getFactory().register(DialogFactory.class, dialogFactory); | |
IFileChooserService fileChooserService = new EclipseFileChooserService(); | |
BeanFactory.getFactory().register(IFileChooserService.class, fileChooserService); | |
} | |
/** | |
* This method is called when the plug-in is stopped | |
*/ | |
public void stop(BundleContext context) throws Exception | |
{ | |
super.stop(context); | |
plugin = null; | |
} | |
/** | |
* Returns the shared instance. | |
*/ | |
public static VioletPlugin getDefault() | |
{ | |
return plugin; | |
} | |
/** | |
* Returns an image descriptor for the image file at the given plug-in relative path. | |
* | |
* @param path the path | |
* @return the image descriptor | |
*/ | |
public static ImageDescriptor getImageDescriptor(String path) | |
{ | |
return AbstractUIPlugin.imageDescriptorFromPlugin("VioletPlugin", path); | |
} | |
/** | |
* Install plugins | |
*/ | |
private void installPlugins() | |
{ | |
this.pluginLoader.installPlugins(); | |
} | |
} |