01 package org.jpn.xucker.rcp.optipngwrapper;
02
03
04 import org.eclipse.core.runtime.Platform;
05 import org.eclipse.core.runtime.Plugin;
06 import org.eclipse.jface.preference.IPreferenceStore;
07 import org.eclipse.ui.plugin.AbstractUIPlugin;
08 import org.jpn.xucker.commons.swt.ui.FileListImage;
09 import org.osgi.framework.BundleContext;
10
11 import java.io.File;
12 /**
13 * The main plugin class to be used in the desktop.
14 */
15 public class OptipngWrapperPlugin extends AbstractUIPlugin {
16
17 private static OptipngWrapperPlugin plugin;
18
19
20 private FileListImage fileListImage;
21 private ResultView resultView;
22 private OptipngWrapperView wrapperView;
23 public FileListImage getFileListImage() {
24 return fileListImage;
25 }
26 public void setFileListImage(FileListImage fileListImage) {
27 this.fileListImage = fileListImage;
28 }
29 public ResultView getResultView() {
30 return resultView;
31 }
32 public void setResultView(ResultView resultView) {
33 this.resultView = resultView;
34 }
35 /**
36 * The constructor.
37 */
38 public OptipngWrapperPlugin() {
39 super();
40 plugin = this;
41 }
42
43
44 protected void initializeDefaultPreferences(IPreferenceStore preference) {
45 // you should preference initialized here.
46
47 preference.setDefault("keepmodified",true);
48 preference.setDefault("sameoutput",true);
49 preference.setDefault("dobackup",true);
50 preference.setDefault("level",""+5);
51
52 File path=new File(toPluginDir(OptipngWrapperPlugin.getDefault()),"optipng/optipng.exe");
53 preference.setDefault("optipng_path",path.getAbsolutePath());
54 }
55
56
57 public void start(BundleContext context) throws Exception {
58 super.start(context);
59
60
61 }
62
63 //return plugin file dir. i don't know this is best way.
64 public File toPluginDir(Plugin plugin){
65 return new File(Platform.getInstallLocation().getURL().getPath(),
66 "plugins/"
67 +plugin.getBundle().getSymbolicName()
68 +"_"
69 +plugin.getBundle().getHeaders().get("Bundle-Version"));
70 }
71
72
73 public void stop(BundleContext context) throws Exception {
74 super.stop(context);
75 }
76
77
78 public static OptipngWrapperPlugin getDefault() {
79 return plugin;
80 }
81
82
83
84 //i use here as center.
85 public OptipngWrapperView getWrapperView() {
86 return wrapperView;
87 }
88 public void setWrapperView(OptipngWrapperView wrapperView) {
89 this.wrapperView = wrapperView;
90 }
91 }
|