19 package com.generalrobotix.ui.item;
21 import java.io.BufferedReader;
23 import java.io.FileNotFoundException;
24 import java.io.FileReader;
25 import java.io.FileWriter;
26 import java.io.IOException;
28 import org.eclipse.jface.action.Action;
29 import org.eclipse.jface.dialogs.MessageDialog;
30 import org.eclipse.swt.SWT;
31 import org.eclipse.swt.widgets.FileDialog;
39 import org.eclipse.swt.widgets.Text;
41 @SuppressWarnings(
"serial")
43 public static final String TITLE =
"Text Item";
44 public static final String FILE_EXTENSION =
"txt";
46 private long lastModified_ = 0;
47 private String old =
"";
48 private int caretPosition_ = 0;
52 Action
item =
new Action(){
54 public void run(){ save(); }
59 public void run(){ saveAs(); }
67 file_ =
new File(getDefaultDir()+
File.separator+getName()+
"."+getFileExtention());
68 setURL(file_.getPath());
71 lastModified_ = file_.lastModified();
79 String delimiter = Text.DELIMITER;
81 BufferedReader
b =
new BufferedReader(
new FileReader(f));
82 StringBuffer
buf =
new StringBuffer();
84 buf.append(b.readLine() + delimiter);
86 setValue(buf.toString());
87 }
catch (FileNotFoundException e) {
90 }
catch (IOException e) {
96 lastModified_ = file_.lastModified();
103 String p = file_.getParent();
104 super.rename(newName);
105 file_ =
new File(p+
File.separator+getName()+
"."+getFileExtention());
106 setURL(file_.getPath());
114 FileWriter fw =
new FileWriter(file_);
115 fw.write(getValue());
119 lastModified_ = file_.lastModified();
120 }
catch (IOException e) {
129 fdlg.setFileName(getName()+
"."+getFileExtention());
130 fdlg.setFilterExtensions(
new String[]{
"*."+getFileExtention()});
131 fdlg.setFilterPath(getDefaultDir().getAbsolutePath());
132 final String fPath = fdlg.open();
141 }
catch (IOException e) {
145 String newName = f.getName().split(
"[.]")[0];
146 manager_.renamePlugin(
this, newName);
147 if (getName().equals(newName)) {
150 setDefaultDirectory(f.getParent());
158 return (String)super.getValue();
162 return !old.equals(getValue());
166 if (lastModified_ < file_.lastModified()) {
167 lastModified_ = file_.lastModified();
178 caretPosition_ = pos;
182 return caretPosition_;
static final String get(String key)
#define null
our own NULL pointer
boolean isModifiedExternally()
png_infop png_charpp name
void setCaretPosition(int pos)
void rename(String newName)
static Shell getCurrentShell()
static void println(String s)
プラグイン管理クラス GrxUIの核になるクラス。プラグインのロード等の、初期化を実行する。 プラグインとそ...
GrxTextItem(String name, GrxPluginManager manager)
def getText(self, nodes=None)