treeviewplugin.java
来自「TTreeview 的 Java实例 Eclipes环境下」· Java 代码 · 共 86 行
JAVA
86 行
package demo.pluginA.treeview;
import java.util.ArrayList;
import org.eclipse.ui.plugin.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IPluginRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.osgi.framework.BundleContext;
import demo.pluginA.treeview.data.IDataFactory;
/**
* The main plugin class to be used in the desktop.
*/
public class TreeviewPlugin extends AbstractUIPlugin {
//The shared instance.
private static TreeviewPlugin plugin;
/**
* The constructor.
*/
public TreeviewPlugin() {
plugin = this;
}
/**
* This method is called upon plug-in activation
*/
public void start(BundleContext context) throws Exception {
super.start(context);
}
/**
* 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 TreeviewPlugin 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("demo.pluginA.treeview", path);
}
public static Object loadDataFactory(Boolean isNew, String path){
ArrayList list = new ArrayList();
IPluginRegistry r=Platform. getPluginRegistry();
String pluginID="demo.pluginA.treeview";
String extensionPointID = "datafactory";
IExtensionPoint p=r.getExtensionPoint( pluginID, extensionPointID);
IConfigurationElement[] c=p.getConfigurationElements();
if( c != null) {
for( int i= 0; i <c.length; i++) {
IDataFactory data = null;
try {
data=( IDataFactory)c[i].createExecutableExtension("class");
if( data != null){
list.add(data.createTreeData(isNew,path));
}
} catch( CoreException x) {
// handle exception } } }
}
}
}
return list.get(list.size()-1);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?