本文整理汇总了Java中org.fife.ui.rsyntaxtextarea.FileLocation类的典型用法代码示例。如果您正苦于以下问题:Java FileLocation类的具体用法?Java FileLocation怎么用?Java FileLocation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileLocation类属于org.fife.ui.rsyntaxtextarea包,在下文中一共展示了FileLocation类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EditorPanel
import org.fife.ui.rsyntaxtextarea.FileLocation; //导入依赖的package包/类
public EditorPanel(Script script) {
try {
filename = script.getName();
editor = new TextEditorPane(RTextArea.INSERT_MODE, false, FileLocation.create(new File(filename)));
editor.setText(script.getCode());
editor.setCaretPosition(0);
// editor tweaks
editor.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_PYTHON);
editor.setCodeFoldingEnabled(true);
editor.setAntiAliasingEnabled(true);
// auto-completion
/*
if (ac != null) {
ac.install(editor);
ac.setShowDescWindow(true);
}
*/
panel = new RTextScrollPane(editor);
} catch (Exception e) {
Logging.logError(e);
}
}
示例2: openFile
import org.fife.ui.rsyntaxtextarea.FileLocation; //导入依赖的package包/类
/**
* Opens a file. Prompts the user to save if the existing file is dirty.
*
* @param file The file to open.
*/
private void openFile(File file) {
if (webDemoCheck()) {
return;
}
if (!saveIfDirty()) {
return;
}
FileLocation loc = FileLocation.create(file);
try {
((TextEditorPane)textArea).load(loc, null);
refreshTitle();
} catch (IOException ioe) {
String message = "Error load file " + loc.getFileName() + ":\n" +
ioe.getMessage();
String title = "Could not load file";
JOptionPane.showMessageDialog(this, message, title,
JOptionPane.ERROR_MESSAGE);
ioe.printStackTrace();
}
}
示例3: EditorPanel
import org.fife.ui.rsyntaxtextarea.FileLocation; //导入依赖的package包/类
public EditorPanel(Script script) {
try {
filename = script.getName();
editor = new TextEditorPane(RTextArea.INSERT_MODE, false, FileLocation.create(new File(filename)));
editor.setText(script.getCode());
editor.setCaretPosition(0);
panel = createEditorPane();
} catch (Exception e) {
Logging.logError(e);
}
}
示例4: saveImpl
import org.fife.ui.rsyntaxtextarea.FileLocation; //导入依赖的package包/类
private boolean saveImpl(FileLocation newLoc) {
boolean success = true;
if (!webDemo) {
TextEditorPane textArea = (TextEditorPane)this.textArea;
try {
if (newLoc!=null) {
textArea.saveAs(newLoc);
refreshTitle();
}
else {
textArea.save();
}
} catch (IOException ioe) {
String message = "Error saving file:\n" + ioe.getMessage();
String title = "Could not save file";
JOptionPane.showMessageDialog(this, message, title,
JOptionPane.ERROR_MESSAGE);
ioe.printStackTrace();
success = false;
}
}
return success;
}
示例5: actionPerformed
import org.fife.ui.rsyntaxtextarea.FileLocation; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
if (webDemoCheck()) {
return;
}
if (chooser==null) {
createFileChooser();
}
int rc = chooser.showSaveDialog(DemoRootPane.this);
if (rc!=JFileChooser.APPROVE_OPTION) {
return;
}
File file = chooser.getSelectedFile();
if (file.exists()) {
String msg = "File already exists:\n" +
file.getAbsolutePath() + "\n" +
"Do you wish to overwrite it?";
rc = JOptionPane.showConfirmDialog(DemoRootPane.this, msg);
if (rc!=JOptionPane.YES_OPTION) {
return;
}
}
FileLocation loc = FileLocation.create(file);
saveImpl(loc);
}