本文整理汇总了Java中org.openide.cookies.EditorCookie.Observable方法的典型用法代码示例。如果您正苦于以下问题:Java EditorCookie.Observable方法的具体用法?Java EditorCookie.Observable怎么用?Java EditorCookie.Observable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.cookies.EditorCookie
的用法示例。
在下文中一共展示了EditorCookie.Observable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPosition
import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
@Override
public PositionBounds getPosition() {
try {
DataObject dobj = DataObject.find(getParentFile());
if (dobj != null) {
EditorCookie.Observable obs = (EditorCookie.Observable)dobj.getLookup().lookup(EditorCookie.Observable.class);
if (obs != null && obs instanceof CloneableEditorSupport) {
CloneableEditorSupport supp = (CloneableEditorSupport)obs;
PositionBounds bounds = new PositionBounds(
supp.createPositionRef(loc[0], Position.Bias.Forward),
supp.createPositionRef(Math.max(loc[0], loc[1]), Position.Bias.Forward)
);
return bounds;
}
}
} catch (DataObjectNotFoundException ex) {
LOG.log(Level.INFO, "Can't resolve", ex);//NOI18N
}
return null;
}
示例2: getEditor
import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
private synchronized EditorCookie.Observable getEditor() {
FileObject file = getFileObject();
if (file == null) return null;
EditorCookie.Observable editor = editorRef == null ? null : editorRef.get();
if (editor == null) {
try {
editor = DataObject.find(file).getLookup().lookup(EditorCookie.Observable.class);
if (editor != null) {
editor.addPropertyChangeListener(WeakListeners.propertyChange(this, editor));
editorRef = new WeakReference<EditorCookie.Observable>(editor);
}
} catch (DataObjectNotFoundException donfe) {
LOG.log(Level.INFO, "no editor for " + fo, donfe);
}
}
return editor;
}
示例3: setModel
import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
@Override
public void setModel (DiffNode[] nodes, EditorCookie[] editorCookies, Object modelData) {
this.editorCookies = editorCookies;
tableModel.setNodes(this.nodes = nodes);
changeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent e) {
Object source = e.getSource();
String propertyName = e.getPropertyName();
if (EditorCookie.Observable.PROP_MODIFIED.equals(propertyName)
&& (source instanceof EditorCookie.Observable)) {
statusModifiedChanged((EditorCookie.Observable) source);
}
}
};
for (EditorCookie editorCookie : this.editorCookies) {
if (editorCookie instanceof EditorCookie.Observable) {
((EditorCookie.Observable) editorCookie).addPropertyChangeListener(WeakListeners.propertyChange(changeListener, editorCookie));
}
}
}
示例4: validateData
import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
@Override
protected void validateData(Object[] data) throws IllegalArgumentException {
super.validateData(data);
boolean observableEditorCookiePresent = false;
boolean fileObjectPresent = false;
for (Object o : data) {
if (o instanceof EditorCookie.Observable) {
if (observableEditorCookiePresent) {
throw new IllegalArgumentException(
"multiple instances of EditorCookie.Observable in the data"); //NOI18N
}
observableEditorCookiePresent = true;
}
if (o instanceof FileObject) {
if (fileObjectPresent) {
throw new IllegalArgumentException(
"multiple instances of FileObject in the data"); //NOI18N
}
fileObjectPresent = true;
}
}
}
示例5: get
import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
public static synchronized AnnotationsHolder get(FileObject file) {
try {
DataObject od = DataObject.find(file);
AnnotationsHolder a = file2Annotations.get(od);
if (a != null) {
return a;
}
EditorCookie.Observable ec = od.getLookup().lookup(EditorCookie.Observable.class);
if (ec == null) {
return null;
}
file2Annotations.put(od, a = new AnnotationsHolder(od, ec));
return a;
} catch (IOException ex) {
LOGGER.log(Level.INFO, null, ex);
return null;
}
}
示例6: close
import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
@Override
public void close () {
if (start) {
// not yet initialized
return;
}
EditorCookie.Observable ec = getEditableCookie(remoteFile);
if (ec != null && ec.getOpenedPanes() == null && !ec.isModified()) {
ec.close();
}
super.close();
}
示例7: getEditableCookie
import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
private static EditorCookie.Observable getEditableCookie (File file) {
EditorCookie.Observable editorCookie = null;
if (file == null) {
return null;
}
FileObject fileObj = FileUtil.toFileObject(file);
if (fileObj != null) {
try {
DataObject dao = DataObject.find(fileObj);
if (dao instanceof MultiDataObject) {
MultiDataObject mdao = (MultiDataObject) dao;
for (MultiDataObject.Entry entry : mdao.secondaryEntries()) {
if (fileObj == entry.getFile() && entry instanceof CookieSet.Factory) {
CookieSet.Factory factory = (CookieSet.Factory) entry;
EditorCookie ec = factory.createCookie(EditorCookie.class);
if (ec instanceof EditorCookie.Observable) {
editorCookie = (EditorCookie.Observable) ec;
}
}
}
}
if (editorCookie == null) {
EditorCookie cookie = dao.getCookie(EditorCookie.class);
if (cookie instanceof EditorCookie.Observable) {
editorCookie = (EditorCookie.Observable) cookie;
}
}
} catch (DataObjectNotFoundException ex) {
}
}
return editorCookie;
}
示例8: attachEditorObservableListener
import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
private void attachEditorObservableListener(DataObject d) {
EditorCookie.Observable obs = d.getCookie(EditorCookie.Observable.class);
if (obs == null) {
ErrorManager.getDefault().log(ErrorManager.INFORMATIONAL, "The DataObject " + d.getName() + "(class=" + d.getClass().getName() + ") has no EditorCookie.Observable!");
} else {
obs.addPropertyChangeListener(peerWL = WeakListeners.propertyChange(NavigatorContent.this, obs));
}
}
示例9: paneFor
import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
private JEditorPane paneFor(FileObject src, String fileName, String code) throws Exception, DataObjectNotFoundException, IOException {
FileObject fromFO = FileUtil.createData(src, fileName);
TestUtilities.copyStringToFile(fromFO, code);
DataObject od = DataObject.find(fromFO);
final EditorCookie.Observable ec = od.getCookie(EditorCookie.Observable.class);
final Exchanger<JEditorPane> exch = new Exchanger<>();
class L implements PropertyChangeListener {
@Override
public void propertyChange(PropertyChangeEvent evt) {
try {
if (!EditorCookie.Observable.PROP_OPENED_PANES.equals(evt.getPropertyName())) {
return;
}
// we are in AWT
JEditorPane[] panes = ec.getOpenedPanes();
if (panes == null) {
return;
}
exch.exchange(panes[0]);
} catch (InterruptedException ex) {
}
}
}
L listener = new L();
ec.addPropertyChangeListener(listener);
JEditorPane pane = null;
try {
ec.open();
ec.openDocument().putProperty(Language.class, JavaTokenId.language());
pane = exch.exchange(null, 5, TimeUnit.SECONDS);
} finally {
ec.removePropertyChangeListener(listener);
}
assertNotNull("Editor pane not opened", pane);
return pane;
}
示例10: DocumentParseSupport
import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
/**
* Create a support based on an editor cookie and lock.
* @param edit the container for the document containing some parsable data
* @param lock a lock
*/
protected DocumentParseSupport(EditorCookie.Observable edit, RWLock lock) {
super(lock);
this.edit = edit;
listener = new Listener();
edit.addPropertyChangeListener(listener);
cookieListenerCount++;
}
示例11: SetCursorTask
import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
private SetCursorTask(EditorCookie editorCookie, int offset) {
this.editorCookie = editorCookie;
this.observable = (editorCookie instanceof EditorCookie.Observable)
? (EditorCookie.Observable) editorCookie
: null;
this.offset = offset;
if (log.isLoggable(FINEST)) {
log.finest("SetCursorTask.<init>"); //NOI18N
log.log(FINEST, " - observable: {0}", (observable != null));//NOI18N
}
}
示例12: getEditorCookie
import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
/**
* @since 1.9.1
*/
public static EditorCookie getEditorCookie(StreamSource source) {
if (!source.isEditable()) {
return null;
}
Lookup lookup = source.getLookup();
EditorCookie plain = null;
FileObject fileObj = lookup.lookup(FileObject.class);
if (fileObj != null) {
try {
EditorCookie editorCookie = getEditorCookie(
DataObject.find(fileObj), true);
if (editorCookie instanceof EditorCookie.Observable) {
return (EditorCookie.Observable) editorCookie;
}
plain = editorCookie;
} catch (Exception e) {
// fallback to other means of obtaining the source
}
}
Document streamDoc = lookup.lookup(Document.class);
if (streamDoc != null) {
return chooseBetterEditorCookie(getEditorCookie(streamDoc), plain);
}
return plain; //null or non-null
}
示例13: Holder
import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
Holder(Cache c, FileObject f) {
this.cache = c;
this.file = f;
try {
DataObject d = DataObject.find(f);
EditorCookie.Observable obs = d.getLookup().lookup(EditorCookie.Observable.class);
if (obs != null) {
obs.addPropertyChangeListener(WeakListeners.propertyChange(this, obs));
}
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
}
示例14: init
import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
void init(FileObject workRoot) throws IOException {
this.workRoot = workRoot;
workRoot.setAttribute("jshell.scratch", true);
consoleFile = workRoot.createData("console.jsh");
EditorCookie.Observable eob = consoleFile.getLookup().lookup(EditorCookie.Observable.class);
inst = new L();
eob.addPropertyChangeListener(WeakListeners.propertyChange(inst, eob));
platform = org.netbeans.modules.jshell.project.ShellProjectUtils.findPlatform(project);
}
示例15: AnnotationsHolder
import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
private AnnotationsHolder(DataObject file, EditorCookie.Observable ec) {
this.file = file;
this.ec = ec;
this.annotations = new ArrayList<IsOverriddenAnnotation>();
ec.addPropertyChangeListener(this);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
checkForReset();
}
});
Logger.getLogger("TIMER").log(Level.FINE, "Overridden AnnotationsHolder", new Object[] {file.getPrimaryFile(), this}); //NOI18N
}