?? tanghanplugin.java
字號(hào):
package com.tanghan.plugin;
import org.eclipse.ui.plugin.*;
//import org.eclipse.core.internal.plugins.PluginClassLoader;
import org.eclipse.core.runtime.*;
import org.eclipse.core.resources.*;
import org.eclipse.jface.preference.IPreferenceStore;
//import org.eclipse.swt.graphics.*;
import java.util.*;
//import java.io.*;
import org.apache.log4j.Logger;
import com.tanghan.plugin.dataSave.DBDealDataSaveXML;
import com.tanghan.plugin.dataSave.IDBDealDataSave;
import com.tanghan.util.Log;
import com.tanghan.util.PageList;
//import org.eclipse.jface.resource.ImageRegistry;
/**
* The main plugin class to be used in the desktop.
* @author Jerry Tang
* @version v0.1.0
* @copyright (C) 2003 Tanghan工作組
*/
public class TanghanPlugin extends AbstractUIPlugin implements ILogListener{
public static final String PLUGIN_ID = ITanghanConstants.PLUGIN_ID;
private static TanghanClassLoader tanghanClassLoader = new TanghanClassLoader(TanghanPlugin.class.getClassLoader());
private static Logger logger = Log.getInstanse().getLogger();
//The shared instance.
private static TanghanPlugin plugin;
//Resource bundle.
private ResourceBundle resourceBundle;
/**處理存儲(chǔ)數(shù)據(jù)的接口*/
IDBDealDataSave dealDataSave;
/**
* The constructor.
*/
public TanghanPlugin(IPluginDescriptor descriptor) {
super(descriptor);
plugin = this;
this.getLog().addLogListener(this);
// initImageResources();
try {
resourceBundle= ResourceBundle.getBundle("com.tanghan.plugin.TanghanPluginResources");
} catch (MissingResourceException x) {
resourceBundle = null;
}
//getLog().log(new Status(IStatus.ERROR, plugin.toString(),IStatus.OK,this.getStateLocation().toFile().toString(),null));
//((PluginClassLoader)getClass().getClassLoader()).newInstance()
}
/**
* Returns the shared instance.
*/
public static TanghanPlugin getDefault() {
return plugin;
}
/**
* Returns the workspace instance.
*/
public static IWorkspace getWorkspace() {
return ResourcesPlugin.getWorkspace();
}
/**
* Returns the string from the plugin's resource bundle,
* or 'key' if not found.
*/
public static String getResourceString(String key) {
ResourceBundle bundle= TanghanPlugin.getDefault().getResourceBundle();
try {
return bundle.getString(key);
} catch (MissingResourceException e) {
return key;
}
}
/**
* Returns the plugin's resource bundle,
*/
public ResourceBundle getResourceBundle() {
return resourceBundle;
}
public IPublicImages getPublicImages(){
return NowPublicImages.getInstance();
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.ILogListener#logging(org.eclipse.core.runtime.IStatus, java.lang.String)
*/
public void logging(IStatus status, String plugin) {
//Logger logger = Log.getInstanse().getLogger(plugin);
switch(status.getSeverity()){
case IStatus.ERROR:
if(status.getException()==null){
logger.error(status.getMessage());
}else{
logger.error(status.getMessage(),status.getException());
}
break;
case IStatus.WARNING:
if(status.getException()==null){
logger.warn(status.getMessage());
}else{
logger.warn(status.getMessage(),status.getException());
}
break;
default:
if(status.getException()==null){
logger.info(status.getMessage());
}else{
logger.info(status.getMessage(),status.getException());
}
break;
}
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.Plugin#startup()
*/
public void startup() throws CoreException {
// TO_DO 載入TanghanPlugin的配置文件。
super.startup();
this.dealDataSave = new DBDealDataSaveXML();
try{
dealDataSave.loadData(this);
}catch(Exception ex){
//TODO 處理改意外
}
}
/**
* Sets default preference values. These values will be used
* until some preferences are actually set using Preference dialog.
*/
protected void initializeDefaultPreferences(IPreferenceStore store) {
store.setValue(ITanghanConstants.PAGELIST_SHOWALL, false);
store.setValue(ITanghanConstants.PAGELIST_LIST, 20);
}
public PageList getDefaultPageList(){
IPreferenceStore store = this.getPreferenceStore();
boolean showAll = store.getBoolean(ITanghanConstants.PAGELIST_SHOWALL);
PageList pl = new PageList(1,store.getInt(ITanghanConstants.PAGELIST_LIST));
pl.setShowAll(showAll);
return pl;
}
/**
* @return
*/
public IDBDealDataSave getDealDataSave() {
return dealDataSave;
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.Plugin#shutdown()
*/
public void shutdown() throws CoreException {
super.shutdown();
//保存數(shù)據(jù)到文件
try{
this.dealDataSave.saveData();
}catch(Exception ex){
getLog().log(new Status(IStatus.ERROR, plugin.toString(),IStatus.OK,ex.getMessage(),ex));
ex.printStackTrace();
//TO_DO 處理改意外
}
int o =0 ;
}
/**
* @return
*/
public TanghanClassLoader getTanghanClassLoader() {
return tanghanClassLoader;
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -