tinydtplugin.java
来自「plugin for eclipse」· Java 代码 · 共 141 行
JAVA
141 行
package isis.tinydt;
import isis.tinydt.editors.nesceditor.CompilationUnitDocumentProvider;
import isis.tinydt.editors.nesceditor.NesCColorProvider;
import java.io.File;
import java.util.Iterator;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.IConsoleManager;
import org.eclipse.ui.console.MessageConsole;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The main plugin class to be used in the desktop.
*/
public class TinydtPlugin extends AbstractUIPlugin
{
private static TinydtPlugin plugin;
private ResourceBundle resourceBundle;
private NesCColorProvider colorProvider = new NesCColorProvider();
private CompilationUnitDocumentProvider documentProvider = new CompilationUnitDocumentProvider();
// private IResourceChangeListener resourceChangeListener = new ResourceChangeListener();
private MessageConsole console = null;
public TinydtPlugin()
{
super();
plugin = this;
try
{
resourceBundle = ResourceBundle.getBundle("isis.tinydt.TinydtPluginResources");
}
catch (MissingResourceException x)
{
resourceBundle = null;
}
}
/**
* This method is called upon plug-in activation
*/
public void start(BundleContext context) throws Exception
{
super.start(context);
// register resource change listener
//ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener);
// open console
IConsoleManager cm = ConsolePlugin.getDefault().getConsoleManager();
console = new MessageConsole("Tinydt make output", null);
cm.addConsoles( new IConsole[]{console} );
cm.showConsoleView(console);
// makeTempDir();
//emptyTempDir();
}
public MessageConsole getConsole()
{
return console;
}
// private void makeTempDir()
// {
// File tempDir = new File(TinydtPlugin.TEMP_DIR);
// tempDir.mkdirs();
// }
/**
* This method is called when the plug-in is stopped
*/
public void stop(BundleContext context) throws Exception
{
// // delete temp files
// Iterator it = TinydtProject.getTinydtProjects().iterator();
// while( it.hasNext() )
// {
// TinydtProject p = (TinydtProject)it.next();
// p.deleteTempFiles();
// }
super.stop(context);
}
/**
* Returns the shared instance.
*/
public static TinydtPlugin getDefault()
{
return plugin;
}
/**
* Returns the string from the plugin's resource bundle,
* or 'key' if not found.
*/
public static String getResourceString(String key)
{
ResourceBundle bundle = TinydtPlugin.getDefault().getResourceBundle();
try
{
return (bundle != null) ? bundle.getString(key) : key;
}
catch (MissingResourceException e)
{
return key;
}
}
/**
* Returns the plugin's resource bundle,
*/
public ResourceBundle getResourceBundle()
{
return resourceBundle;
}
public NesCColorProvider getColorProvider()
{
return colorProvider;
}
public CompilationUnitDocumentProvider getDocumentProvider()
{
return documentProvider;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?