本文整理汇总了Java中org.openide.loaders.DataObject.isValid方法的典型用法代码示例。如果您正苦于以下问题:Java DataObject.isValid方法的具体用法?Java DataObject.isValid怎么用?Java DataObject.isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.loaders.DataObject
的用法示例。
在下文中一共展示了DataObject.isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkFileObjectValid
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
/**
* Check whether the file object is valid and a valid data object can be
* found for it. It should be checked after original node is destroyed. It
* does not have to mean the the file was deleted, but also that a module
* that contain data loader was enabled. In the letter case, the node should
* be updated for new data object.
*/
private void checkFileObjectValid() {
FileObject fo = matchingObject.getFileObject();
if (fo != null && fo.isValid()) {
try {
DataObject reloaded = DataObject.find(fo);
matchingObject.updateDataObject(reloaded);
valid = reloaded.isValid();
if (valid) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
resetValidOriginal();
}
});
}
} catch (DataObjectNotFoundException ex) {
// still invalid, the file was probably really deleted
}
}
}
示例2: getFileStreamFromDocument
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
private Reader getFileStreamFromDocument(File resultFile) {
FileObject fo = FileUtil.toFileObject(FileUtil.normalizeFile(resultFile));
if(fo != null){
DataObject dobj = null;
try {
dobj = DataObject.find(fo);
} catch (DataObjectNotFoundException ex) {
return null;
}
if(dobj.isValid() && dobj.isModified()){
// DataObjectAdapters does not implement getByteStream
// so calling this here will effectively return null
return DataObjectAdapters.inputSource(dobj).getCharacterStream();
} else{
//return null so that the validator will use normal file path to access doc
return null;
}
}
return null;
}
示例3: ShortcutAction
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
/** Create a new presenter.
* @param obj XML file describing it
*/
public ShortcutAction(DataObject obj, String helpID, boolean showmaster) {
this.obj = obj;
this.helpID = helpID;
this.showmaster = showmaster;
putValue("noIconInMenu", true); // NOI18N
Installer.log.log(Level.FINE, "new ShortcutAction: {0} {1} showmaster={2}", new Object[] {obj, helpID, showmaster});
updateText();
updateIcon();
updateEnabled();
if (obj.isValid()) {
Node n = obj.getNodeDelegate();
n.addNodeListener(org.openide.nodes.NodeOp.weakNodeListener (this, n));
}
Help h = findHelp();
if (h != null) {
h.addChangeListener(WeakListeners.change(this, h));
}
}
示例4: paste
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
public Transferable paste() throws IOException {
if (targetFolder != null) {
for (Iterator iterator = sourceDataObjects.iterator(); iterator.hasNext();) {
DataObject dataObject = (DataObject) iterator.next();
boolean isValid = dataObject != null && dataObject.isValid();
if (isValid && pasteOperation == LoaderTransfer.CLIPBOARD_COPY) {
dataObject.createShadow(targetFolder);
}
if (isValid && pasteOperation == LoaderTransfer.CLIPBOARD_CUT) {
dataObject.move(targetFolder);
}
}
}
return null;
}
示例5: updateTCTitle
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
/** Sets navigator title according to active context */
private void updateTCTitle (Node[] nodes) {
String newTitle;
if (nodes != null && nodes.length > 0) {
Node node = nodes[0];
DataObject dObj = obtainNodeDO(node);
if (dObj != null && dObj.isValid() || updateWhenNotShown) { // updateWhenNotShown is used because of tests - test nodes does not have DO
newTitle = NbBundle.getMessage(NavigatorTC.class, "FMT_Navigator", node.getDisplayName()); //NOI18N
} else {
newTitle = NbBundle.getMessage(NavigatorTC.class, "LBL_Navigator"); //NOI18N
}
} else {
newTitle = NbBundle.getMessage(NavigatorTC.class, "LBL_Navigator"); //NOI18N
}
navigatorTC.setDisplayName(newTitle);
}
示例6: display
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
private void display(Collection<? extends DataObject> selectedFiles) {
// Show list of targets for selected file:
if (selectedFiles.size() == 1) {
DataObject d = selectedFiles.iterator().next();
if (d.isValid()) { // #145571
manager.setRootContext(d.getNodeDelegate());
return;
}
}
// Fallback:
manager.setRootContext(Node.EMPTY);
}
示例7: getListCellRendererComponent
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent (JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) // the list and the cell have the focus
{
final DataObject obj = (DataObject)value;
if (!obj.isValid()) {
// #17059: it might be invalid already.
// #18886: but if so, remove it later, otherwise BasicListUI gets confused.
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
listModel.removeElement(obj);
}
});
setText("");
return this;
}
Node node = obj.getNodeDelegate();
ImageIcon icon = new ImageIcon(node.getIcon(BeanInfo.ICON_COLOR_16x16));
super.setIcon(icon);
setText(node.getDisplayName());
if (isSelected){
this.setBackground(UIManager.getColor("List.selectionBackground")); // NOI18N
this.setForeground(UIManager.getColor("List.selectionForeground")); // NOI18N
}
else {
this.setBackground(list.getBackground());
this.setForeground(list.getForeground());
}
this.setBorder(cellHasFocus ? hasFocusBorder : noFocusBorder);
return this;
}
示例8: getCurrentProject
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
/**
* Returns the project that the active node's fileobject belongs to.
* If this cannot be determined for some reason, returns the main project.
*
* @return the project that the active node's fileobject belongs to
*/
private Project getCurrentProject() {
Node[] nodes = TopComponent.getRegistry ().getActivatedNodes ();
if (nodes == null || nodes.length == 0) {
return MainProjectManager.getDefault().getMainProject();
}
DataObject dao = (DataObject) nodes[0].getLookup().lookup(DataObject.class);
if (dao == null || !dao.isValid()) {
return MainProjectManager.getDefault().getMainProject();
}
return FileOwnerQuery.getOwner(dao.getPrimaryFile());
}
示例9: createPane
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
@Override
protected Pane createPane() {
DataObject dobj = getDataObject();
if (dobj == null || !dobj.isValid()) {
return super.createPane();
}
return (Pane) MultiViews.createCloneableMultiView(MIME_BEAN_INFO, getDataObject());
}
示例10: getCurrentEditorCookie
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
/**
* Returns current editor component instance.
*
* @return current editor component instance
*/
private static EditorCookie getCurrentEditorCookie () {
Node[] nodes = TopComponent.getRegistry ().getActivatedNodes ();
if ((nodes == null) || (nodes.length != 1)) return null;
Node node = nodes [0];
DataObject dob = node.getLookup().lookup (DataObject.class);
if (dob != null && !dob.isValid()) {
return null;
}
return node.getLookup().lookup (EditorCookie.class);
}
示例11: close
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
@Override
protected boolean close(boolean ask) {
boolean closed = super.close(ask);
DataObject dobj = getDataObject();
if(closed && dobj.isValid()) {
//set the original property sets
HtmlDataNode nodeDelegate = (HtmlDataNode)dobj.getNodeDelegate();
nodeDelegate.setPropertySets(null);
}
return closed;
}
示例12: getCopiedBeanClassSource
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
@Override
public ClassSource getCopiedBeanClassSource(Transferable transferable) {
DataObject dobj = NodeTransfer.cookie(transferable, NodeTransfer.COPY, DataObject.class);
FileObject fo = (dobj != null && dobj.isValid()) ? dobj.getPrimaryFile() : null;
if (fo == null) {
return null;
}
String clsName = BeanInstaller.findJavaBeanName(fo);
if (clsName == null) {
return null;
}
return BeanInstaller.getProjectClassSource(fo, clsName);
}
示例13: getOpenFileObj
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
private static FileObject getOpenFileObj() {
TopComponent activatedTopComponent = TopComponent.getRegistry()
.getActivated();
if (activatedTopComponent == null) {
return null;
}
DataObject dataObj = activatedTopComponent.getLookup()
.lookup(DataObject.class);
if ((dataObj == null) || !dataObj.isValid()) {
return null;
}
return dataObj.getPrimaryFile();
}
示例14: createNodeForKey
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
@Override protected Node createNodeForKey(DataObject key) {
if (!key.isValid()) {
return null;
}
return key instanceof DataFolder ? new PackageFilterNode((DataFolder) key, folder, filter, g) : key.getNodeDelegate().cloneNode();
}
示例15: createMainClass
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
private static void createMainClass(
final @NonNull String mainClassName,
final @NonNull FileObject srcFolder,
@NullAllowed String mainClassTemplate) throws IOException {
int lastDotIdx = mainClassName.lastIndexOf( '.' );
String mName, pName;
if ( lastDotIdx == -1 ) {
mName = mainClassName.trim();
pName = null;
}
else {
mName = mainClassName.substring( lastDotIdx + 1 ).trim();
pName = mainClassName.substring( 0, lastDotIdx ).trim();
}
if ( mName.length() == 0 ) {
return;
}
if (mainClassTemplate == null) {
mainClassTemplate = "Templates/Classes/Main.java"; //NOI18N
}
final FileObject mainTemplate = FileUtil.getConfigFile(mainClassTemplate);
if ( mainTemplate == null ) {
LOG.log(
Level.WARNING,
"Template {0} not found!", //NOI18N
mainClassTemplate);
return; // Don't know the template
}
DataObject mt = DataObject.find( mainTemplate );
FileObject pkgFolder = srcFolder;
if ( pName != null ) {
String fName = pName.replace( '.', '/' ); // NOI18N
pkgFolder = FileUtil.createFolder( srcFolder, fName );
}
DataFolder pDf = DataFolder.findFolder( pkgFolder );
DataObject res = mt.createFromTemplate( pDf, mName );
if (res == null || !res.isValid()) {
LOG.log(
Level.WARNING,
"Template {0} created an invalid DataObject in folder {1}!", //NOI18N
new Object[] {
mainClassTemplate,
FileUtil.getFileDisplayName(pkgFolder)
});
}
}