本文整理汇总了Java中org.openide.cookies.EditorCookie类的典型用法代码示例。如果您正苦于以下问题:Java EditorCookie类的具体用法?Java EditorCookie怎么用?Java EditorCookie使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EditorCookie类属于org.openide.cookies包,在下文中一共展示了EditorCookie类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isDocumentValid
import org.openide.cookies.EditorCookie; //导入依赖的package包/类
private boolean isDocumentValid() {
DataObject dob = NbEditorUtilities.getDataObject(doc);
if (dob != null) {
EditorCookie ec = dob.getCookie(EditorCookie.class);
if (ec != null) {
StyledDocument openedDoc;
try {
openedDoc = ec.openDocument();
} catch (IOException e) {
openedDoc = null; // should return in next if stmt
}
return (openedDoc == doc);
}
}
return false;
}
示例2: highlightDetail
import org.openide.cookies.EditorCookie; //导入依赖的package包/类
private void highlightDetail(EditorCookie edCookie) {
if (markLength > 0) {
final JEditorPane[] panes = edCookie.getOpenedPanes();
if (panes != null && panes.length > 0) {
// Necessary since above lineObj.show leads to invoke
// later as well.
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
try {
Caret caret = panes[0].getCaret(); // #23626
caret.moveDot(caret.getDot() + markLength);
} catch (Exception e) { // #217038
StatusDisplayer.getDefault().setStatusText(
Bundle.MSG_CannotShowTextDetai());
LOG.log(Level.FINE,
Bundle.MSG_CannotShowTextDetai(), e);
}
}
});
}
}
}
示例3: linePart
import org.openide.cookies.EditorCookie; //导入依赖的package包/类
public static PositionBounds linePart(FileObject file, int start, int end) {
try {
DataObject od = DataObject.find(file);
if (od == null)
return null;
EditorCookie ec = od.getCookie(EditorCookie.class);
if (!(ec instanceof CloneableEditorSupport)) {
return null;
}
final CloneableEditorSupport ces = (CloneableEditorSupport) ec;
checkOffsetsAndLog(start, end);
return new PositionBounds(ces.createPositionRef(start, Position.Bias.Forward), ces.createPositionRef(end, Position.Bias.Backward));
} catch (IOException e) {
LOG.log(Level.INFO, null, e);
return null;
}
}
示例4: performAction
import org.openide.cookies.EditorCookie; //导入依赖的package包/类
@Override
protected void performAction(Node[] nodes) {
for (Node node : nodes) {
WsdlSaas saas = getWsdlSaas(node);
String location = saas.getWsdlData().getWsdlFile();
FileObject wsdlFileObject = saas.getLocalWsdlFile();
if (wsdlFileObject == null) {
String errorMessage = NbBundle.getMessage(ViewWSDLAction.class, "WSDL_FILE_NOT_FOUND", location); // NOI18N
NotifyDescriptor d = new NotifyDescriptor.Message(errorMessage);
DialogDisplayer.getDefault().notify(d);
continue;
}
//TODO: open in read-only mode
try {
DataObject wsdlDataObject = DataObject.find(wsdlFileObject);
EditorCookie editorCookie = wsdlDataObject.getLookup().lookup(EditorCookie.class);
editorCookie.open();
} catch (Exception e) {
Exceptions.printStackTrace(e);
}
}
}
示例5: openEditor
import org.openide.cookies.EditorCookie; //导入依赖的package包/类
@Override
public void openEditor(PrimitiveData metadata) {
String javaFilePath = metadata.classFQN.replace('.', '/') + ".java";
for (FileObject curRoot : GlobalPathRegistry.getDefault().getSourceRoots()) {
FileObject fileObject = curRoot.getFileObject(javaFilePath);
if (fileObject != null) {
DataObject dobj = null;
try {
dobj = DataObject.find(fileObject);
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
if (dobj != null) {
EditorCookie ec = (EditorCookie) dobj.getCookie(EditorCookie.class);
if (ec != null) {
ec.open();
}
}
}
}
}
示例6: findEditorCookie
import org.openide.cookies.EditorCookie; //导入依赖的package包/类
public static EditorCookie findEditorCookie(BookmarkInfo info) {
EditorCookie ec = null;
FileBookmarks fileBookmarks = info.getFileBookmarks();
if (fileBookmarks != null) {
FileObject fo = fileBookmarks.getFileObject();
if (fo != null) {
try {
DataObject dob = DataObject.find(fo);
ec = dob.getCookie(EditorCookie.class);
} catch (DataObjectNotFoundException ex) {
// Leave ec == null
}
}
}
return ec;
}
示例7: propertyChange
import org.openide.cookies.EditorCookie; //导入依赖的package包/类
@Override
public void propertyChange(PropertyChangeEvent evt) {
FileObject closedFile = null;
if (!EditorCookie.Observable.PROP_DOCUMENT.equals(evt.getPropertyName())) {
return;
}
synchronized (this) {
Document old = (Document)evt.getOldValue();
if (old != null && docWL != null) {
old.removeDocumentListener(docWL);
docWL = null;
}
Document nue = (Document)evt.getNewValue();
if (nue != null) {
nue.addDocumentListener(docWL = WeakListeners.document(this, nue));
} else {
closedFile = extractFileObject(old);
}
}
if (closedFile != null) {
invalidate(closedFile);
}
}
示例8: 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;
}
}
}
示例9: getDocument
import org.openide.cookies.EditorCookie; //导入依赖的package包/类
public static Document getDocument(FileObject modelSourceFileObject){
Document result = null;
try {
DataObject dObject = DataObject.find(modelSourceFileObject);
EditorCookie ec = (EditorCookie)dObject.getCookie(EditorCookie.class);
Document doc = ec.openDocument();
if(doc instanceof BaseDocument)
return doc;
result = new org.netbeans.editor.BaseDocument(true, modelSourceFileObject.getMIMEType());
String str = doc.getText(0, doc.getLength());
result.insertString(0,str,null);
} catch (Exception dObjEx) {
return null;
}
return result;
}
示例10: attachDataObject
import org.openide.cookies.EditorCookie; //导入依赖的package包/类
/** A hacky fix for XMLSyncSupport - I need to call EditorCookie.close when the navigator
* is deactivated and there is not view pane for the navigated document. Then a the synchronization
* support releases a strong reference to NbEditorDocument. */
private void attachDataObject(DataObject replaceObject) {
final DataObject dobj;
synchronized (this) {
dobj = peerDO;
if (dobj == replaceObject) {
// no change
return;
}
LOG.fine(this + ": Closing doucment " + dobj + ", replacing with " + replaceObject);
peerDO = replaceObject;
if (dobj != null) {
EditorCookie.Observable cake = dobj.getCookie(EditorCookie.Observable.class);
if (cake != null) {
cake.removePropertyChangeListener(peerWL);
}
}
peerWL = null;
if (replaceObject != null) {
attachEditorObservableListener(replaceObject);
}
}
}
示例11: 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));
}
}
}
示例12: collectToolbars
import org.openide.cookies.EditorCookie; //导入依赖的package包/类
private static void collectToolbars(final List<JToolBar> toolbars, final EditorCookie oc) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
JEditorPane [] jeps = oc.getOpenedPanes();
for(JEditorPane jep : jeps) {
EditorUI editorUI = Utilities.getEditorUI(jep);
assertNotNull(editorUI);
JToolBar toolbar = editorUI.getToolBarComponent();
assertNotNull(toolbar);
toolbars.add(toolbar);
TopComponent tc = findTopComponent(jep);
//System.out.println("tc = " + tc);
assertNotNull(tc);
boolean closed = tc.close();
assertTrue("Can't close TC", closed);
}
}
});
}
示例13: postCloseCleanup
import org.openide.cookies.EditorCookie; //导入依赖的package包/类
private void postCloseCleanup() {
try {
// try to close the dataobject
DataObject d = DataObject.find(getConsoleFile());
EditorCookie cake = d.getLookup().lookup(EditorCookie.class);
cake.close();
// discard the dataobject
synchronized (this) {
if (document == null) {
return;
}
document = null;
}
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
if (controlsIO) {
inputOutput.closeInputOutput();
}
ShellRegistry.get().closed(this);
}
示例14: initDataObject
import org.openide.cookies.EditorCookie; //导入依赖的package包/类
private BookDataObject initDataObject() throws IOException {
BookDataObject ret = null;
File f = Helper.getBookFile(getDataDir(), getWorkDir());
FileObject fo = FileUtil.toFileObject(f);
assertNotNull(fo);
doSetPreferredLoader(fo, loader);
DataObject dObj = DataObject.find(fo);
assertNotNull("Book DataObject not found", dObj);
assertEquals(BookDataObject.class, dObj.getClass());
ret = (BookDataObject) dObj;
((EditCookie) ret.getCookie(EditCookie.class)).edit();
// wait to open the document
Helper.waitForDispatchThread();
XmlMultiViewEditorSupport editor = (XmlMultiViewEditorSupport) ret.getCookie(EditorCookie.class);
Document doc = Helper.getDocument(editor);
assertTrue("The document is empty :", doc == null || doc.getLength() > 0);
return ret;
}
示例15: getDocument
import org.openide.cookies.EditorCookie; //导入依赖的package包/类
@Override
protected BaseDocument getDocument(FileObject fo, String mimeType, Language language) {
// for some reason GsfTestBase is not using DataObjects for BaseDocument construction
// which means that for example Java formatter which does call EditorCookie to retrieve
// document will get difference instance of BaseDocument for indentation
try {
DataObject dobj = DataObject.find(fo);
assertNotNull(dobj);
EditorCookie ec = dobj.getLookup().lookup(EditorCookie.class);
assertNotNull(ec);
return (BaseDocument) ec.openDocument();
} catch (Exception ex) {
fail(ex.toString());
return null;
}
}