Java Code Examples for org.openide.nodes.Node#getValue()

The following examples show how to use org.openide.nodes.Node#getValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OptionsAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected Node.Property getPropertyFor(Node node, Node.Property prop) {
    Object value = node.getValue (prop.getName());
    if (value instanceof Node.Property) {
        return (Node.Property)value;
    }
    
    return null;
}
 
Example 2
Source File: DefaultSettings.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static Object get( Node node, String attrName, Object defaultValue ) {
    Object res = null;
    if( null != node ) {
        res = node.getValue( NODE_ATTR_PREFIX+attrName );
        if( null == res || NULL_VALUE.equals( res ) ) {
            res = getNodeDefaultValue( node, attrName );
        }
    }
    if( null == res ) {
        res = defaultValue;
    }
    return res;
}
 
Example 3
Source File: DefaultSettings.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static Object getNodeDefaultValue( Node node, String attrName ) {
    Object res = node.getValue( attrName );
    if( null == res ) {
        DataObject dobj = (DataObject)node.getCookie( DataObject.class );
        if( null != dobj ) {
            res = dobj.getPrimaryFile().getAttribute( attrName );
        }
    }
    return res;
}
 
Example 4
Source File: JAXBRefreshAction.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected void performAction(Node[] nodes) {
    Node node = nodes[ 0 ];
    FileObject fo = node.getLookup().lookup( FileObject.class );
    Project proj = node.getLookup().lookup(Project.class);
    String origLoc = (String) node.getValue(
            JAXBWizModuleConstants.ORIG_LOCATION);
    Boolean origLocIsURL = (Boolean) node.getValue(
            JAXBWizModuleConstants.ORIG_LOCATION_TYPE);
    FileObject locSchemaRoot = (FileObject) node.getValue(
            JAXBWizModuleConstants.LOC_SCHEMA_ROOT);
    
    if ( ( fo != null ) && ( origLoc != null ) ) {
        // XXX TODO run in separate non-awt thread.
         try {
             if (fo.canWrite()){
                 if (origLocIsURL){
                    URL url = new URL(origLoc);
                     ProjectHelper.retrieveResource(locSchemaRoot, 
                             url.toURI());                        
                 } else {
                     File projDir = FileUtil.toFile(
                             proj.getProjectDirectory());
                     //File srcFile = new File(origLoc);
                     File srcFile = FileSysUtil.Relative2AbsolutePath(
                             projDir, origLoc);
                     ProjectHelper.retrieveResource(fo.getParent(), 
                             srcFile.toURI());
                 }
             } else {
                 String msg = NbBundle.getMessage(this.getClass(),
                         "MSG_CanNotRefreshFile"); //NOI18N
                 NotifyDescriptor d = new NotifyDescriptor.Message(
                         msg, NotifyDescriptor.INFORMATION_MESSAGE);
                 d.setTitle(NbBundle.getMessage(this.getClass(), 
                         "LBL_RefreshFile")); //NOI18N
                 DialogDisplayer.getDefault().notify(d);
             }
         } catch (Exception ex){
             log(ex);
         } 
    }
}