⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myworkplugin.java

📁 mywork是rcp开发的很好的例子
💻 JAVA
字号:
package net.sf.pim.plugin;

import java.io.File;
import java.io.IOException;
import java.net.BindException;
import java.net.ServerSocket;

import net.sf.component.config.ConfigHelper;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

/**
 * The main plugin class to be used in the desktop.
 */
public class MyworkPlugin extends AbstractUIPlugin {
	public static String PLUGIN_ID="net.sf.psp";
	// The shared instance.
	private static MyworkPlugin plugin;

	/**
	 * The constructor.
	 */
	public MyworkPlugin() {
		super();
		plugin = this;
	}

	/**
	 * This method is called upon plug-in activation
	 */
	public void start(BundleContext context) throws Exception {
		super.start(context);
		//删除安装遗留文件Hidecmd.exe
		if(new File("Hidecmd.exe").exists())
			new File("Hidecmd.exe").delete();
		//不允许启动第二个实例
		final int port = ConfigHelper.getIntegerProperty("work.port");
		if (port != 0) {
			new Thread(){
				public void run() {
					try {
						ServerSocket ss = new ServerSocket(port);
						ss.accept();
					}catch(BindException be){
						//second instance not allowed
						System.out.println("不允许启动第二个实例,请设置参数work.port");
						System.exit(0);
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
			}.start();
		}
	}

	/**
	 * This method is called when the plug-in is stopped
	 */
	public void stop(BundleContext context) throws Exception {
		super.stop(context);
	}

	/**
	 * Returns the shared instance.
	 */
	public static MyworkPlugin getDefault() {
		return plugin;
	}
	
	public static ImageDescriptor getImageDescriptor(String path) {
		return imageDescriptorFromPlugin(PLUGIN_ID, path);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -