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

The following are Jave code examples for showing how to use getValue() of the org.openide.nodes.Node class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: incubator-netbeans   File: DefaultSettings.java   Source Code and License Vote up 5 votes
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 2
Project: incubator-netbeans   File: DefaultSettings.java   Source Code and License Vote up 5 votes
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 3
Project: incubator-netbeans   File: OptionsAction.java   Source Code and License Vote up 5 votes
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 4
Project: incubator-netbeans   File: JAXBRefreshAction.java   Source Code and License Vote up 4 votes
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);
         } 
    }
}