Java Code Examples for org.openide.nodes.Node.Property

The following are Jave code examples for showing how to use Property 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: FormModelEvent.java   Source Code and License Vote up 6 votes
private void undoEventHandlerRemoval() {
    Event event = getComponentEvent();
    if (event == null)
        return;

    getFormModel().getFormEvents().attachEvent(
        event,
        getEventHandler(),
        getEventHandlerContent(),
        getEventHandlerAnnotation());

    // hack: set the event property to update the property sheet
    Node.Property prop = getComponent().getPropertyByName(event.getId());
    if (prop != null) {
        try {
            prop.setValue(getEventHandler());
        }
        catch (Exception ex) { // should not happen
            Logger.getLogger(getClass().getName()).log(Level.INFO, ex.getMessage(), ex);
        }
    }
}
 
Example 2
Project: incubator-netbeans   File: TreeTableView.java   Source Code and License Vote up 5 votes
void setSortedByProperty(Node.Property prop) {
    if (sortedByProperty == prop) {
        return;
    }

    sortedByProperty = prop;

    if (prop == null) {
        rowComparator = null;
    } else {
        sortedByName = false;
    }

    sortingChanged();
}
 
Example 3
Project: MaxSim   File: PropertiesSheet.java   Source Code and License Vote up 5 votes
public static void initializeSheet(final Properties properties, Sheet s) {

        Sheet.Set set1 = Sheet.createPropertiesSet();
        set1.setDisplayName("Properties");
        for (final Property p : properties) {
            Node.Property<String> prop = new Node.Property<String>(String.class) {

                @Override
                public boolean canRead() {
                    return true;
                }

                @Override
                public String getValue() throws IllegalAccessException, InvocationTargetException {
                    return p.getValue();
                }

                @Override
                public boolean canWrite() {
                    return false;
                }

                @Override
                public void setValue(String arg0) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
                    properties.setProperty(p.getName(), arg0);
                }
            };
            prop.setName(p.getName());
            set1.put(prop);
        }
        s.put(set1);
    }
 
Example 4
Project: incubator-netbeans   File: FormModelEvent.java   Source Code and License Vote up 5 votes
private void undoComponentLayoutChange() {
    if (getComponent() instanceof RADVisualComponent) {
        ((RADVisualComponent)getComponent()).getConstraintsProperties();
        Node.Property prop =
            getComponent().getPropertyByName(getPropertyName());
        if (prop != null)
            try {
                prop.setValue(getOldPropertyValue());
            }
            catch (Exception ex) { // should not happen
                Logger.getLogger(getClass().getName()).log(Level.INFO, ex.getMessage(), ex);
            }
    }
}
 
Example 5
Project: incubator-netbeans   File: FormCodeSupport.java   Source Code and License Vote up 5 votes
public static void readPropertyExpression(CodeExpression expression,
                                          Node.Property property,
                                          boolean allowChangeFiring)
{
    FormProperty fProperty = property instanceof FormProperty ?
                             (FormProperty) property : null;

    if (fProperty != null) {
        if (!allowChangeFiring) {
            if (fProperty.isChangeFiring())
                fProperty.setChangeFiring(false);
            else
                allowChangeFiring = true; // just not to set firing back
        }

        Object metaOrigin = expression.getOrigin().getMetaObject();
        if (metaOrigin instanceof PropertyEditor)
            fProperty.setCurrentEditor((PropertyEditor)metaOrigin);
    }

    try {
        property.setValue(expression.getOrigin().getValue());
    }
    catch (Exception ex) { // ignore
        org.openide.ErrorManager.getDefault().notify(org.openide.ErrorManager.INFORMATIONAL, ex);
    }
    expression.setOrigin(createOrigin(property));

    if (fProperty != null && !allowChangeFiring)
        fProperty.setChangeFiring(true);
}
 
Example 6
Project: incubator-netbeans   File: PropUtilsTest.java   Source Code and License Vote up 5 votes
public void testRestoreDefaultValueBehaviour() {
    System.out.println("testRestoreDefaultValueBehaviour");
    
    Node.Property trueProp = new OldModulePropertyWithSDVReturningTrue();
    assertTrue("OldModuleProperty doesn't know about Node.Property.isDefaultValue()" +
            " therefore it should be enabled in every case.",
            PropUtils.shallBeRDVEnabled(trueProp));
    
    Node.Property falseProp = new PropertyWithSDVReturningFalse();
    assertFalse("Property doesn't support default value. It should be " +
            "disabled", PropUtils.shallBeRDVEnabled(falseProp));
    
    Node.Property newIDVFalseProp = new BothMethodsOverridedPropertyWithIDSReturningFalse();
    assertTrue("Correctly implemented property with isDefaultValue() " +
            "returning false should be enable.",
            PropUtils.shallBeRDVEnabled(newIDVFalseProp));
    
    Node.Property newIDVTrueProp = new BothMethodsOverridedPropertyWithIDSReturningTrue();
    assertFalse("Correctly implemented property with isDefaultValue() " +
            "returning true should be disabled.",
            PropUtils.shallBeRDVEnabled(newIDVTrueProp));
    
    Node.Property noneOverrided = new DefaultTestProperty();
    assertFalse("Correctly implemented property which doesn't override any " +
            "of the two method should be disabled",
            PropUtils.shallBeRDVEnabled(noneOverrided));
}
 
Example 7
Project: incubator-netbeans   File: CustomCodeEditor.java   Source Code and License Vote up 5 votes
/** Creates new form CustomCodeEditor */
public CustomCodeEditor(Node.Property property, DataObject dataObject) {
    initComponents();

    codeEditorPane.setContentType("text/x-java");  // NOI18N
    try {
        codeEditorPane.setText((String) property.getValue()); 
    }
    catch (Exception ex) { // ignore - should not happen
        ex.printStackTrace();
    }

    java.util.ResourceBundle bundle =
        org.openide.util.NbBundle.getBundle(CustomCodeEditor.class);

    jLabel1.setText(bundle.getString("CustomCodeEditor.label1")); // NOI18N
    jLabel1.setDisplayedMnemonic(
        bundle.getString("CustomCodeEditor.label1.mnemonic").charAt(0)); // NOI18N
    jLabel1.setLabelFor(codeEditorPane);
    codeEditorPane.getDocument().putProperty(Document.StreamDescriptionProperty, dataObject);
    codeEditorPane.setPreferredSize(new java.awt.Dimension(440, 200));
    codeEditorPane.requestFocus();
    codeEditorPane.getCaret().setVisible(codeEditorPane.hasFocus());
    
    codeEditorPane.getAccessibleContext().setAccessibleDescription(
        bundle.getString("ACSD_CustomCodeEditor.label1")); // NOI18N
    getAccessibleContext().setAccessibleDescription(
        bundle.getString("ACSD_CustomCodeEditor")); // NOI18N
}
 
Example 8
Project: incubator-netbeans   File: DataShadowTest.java   Source Code and License Vote up 5 votes
public void testCreateTheShadow () throws Exception {
    DataShadow shade = original.createShadow (folder);
    
    Node node = shade.createNodeDelegate();
    
    final AtomicBoolean modified = new AtomicBoolean();
    shade.getPrimaryFile().addFileChangeListener(new FileChangeAdapter() {

        @Override
        public void fileChanged (FileEvent fe) {
            modified.set(true);
        }
        
    });
    
    String originName = node.getName();
    PropertySet[] props = node.getPropertySets();
    Node.Property p = null;
    for (PropertySet propSet : props) {
        for (Node.Property prop : propSet.getProperties()) {
            if ("OriginalName".equals(prop.getName())) {
                p = prop;
                break;
            }
        }
    }
    assertNotNull(p);
    // set name to the same value
    p.setValue(originName);
    // nothing should happen
    assertFalse(modified.get());
    assertEquals(originName, original.getName());
    // set name to the same value
    p.setValue(originName + ".txt");
    // link should be changed
    assertTrue(modified.get());
    assertEquals(originName + ".txt", original.getName());
}
 
Example 9
Project: incubator-netbeans   File: SchemaImportGUI.java   Source Code and License Vote up 5 votes
/** Creates new form SchemaPanel */
    public SchemaImportGUI(TemplateWizard tw) {
        initComponents();
        initAccessibility();
        this.templateWizard = tw;
        registeredNodes = new HashMap();
        decorator = new ExternalReferenceDecorator(this);            
         // View for selecting an external reference.
        TreeTableView locationView = new LocationView();
        locationView.setDefaultActionAllowed(false);
        locationView.setPopupAllowed(false);
        locationView.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        locationView.setRootVisible(false);
        locationView.getAccessibleContext().setAccessibleName(locationLabel.getToolTipText());
        locationView.getAccessibleContext().setAccessibleDescription(locationLabel.getToolTipText());
        Node.Property[] columns = new Node.Property[] {
            new Column(ExternalReferenceDataNode.PROP_NAME, String.class, true),
            new ImportColumn(referenceTypeName()),
            //new Column(ExternalReferenceDataNode.PROP_PREFIX, String.class, false),
        };
        locationView.setProperties(columns);
        locationView.setTreePreferredWidth(200);
        locationView.setTableColumnPreferredWidth(0, 25);
//        locationView.setTableColumnPreferredWidth(1, 25);
        locationPanel.add(locationView, BorderLayout.CENTER);
        explorerManager = new ExplorerManager();
        explorerManager.addPropertyChangeListener(this);
        explorerManager.setRootContext(createRootNode());        
    }
 
Example 10
Project: incubator-netbeans   File: NodePropertyModel.java   Source Code and License Vote up 5 votes
String getBeanName() {
    if (beans != null) {
        if ((beans.length == 1) && beans[0] instanceof Node.Property) {
            return ((Node.Property) beans[0]).getDisplayName();
        }
    }

    return null;
}
 
Example 11
Project: incubator-netbeans   File: ProjectsView.java   Source Code and License Vote up 5 votes
private void setupColumns() {
    Node.Property[] columns = new Node.Property[1];
    String columnName = NbBundle.getMessage(ProjectsView.class, "LBL_Path");
    String columnDesc = NbBundle.getMessage(ProjectsView.class, "LBL_PathDesc");
    columns[0] = new ColumnDescriptor<String>(ProjectNode.PROPERTY_NAME_PATH, String.class, columnName, columnDesc);  // NOI18N

    setProperties(columns);
}
 
Example 12
Project: incubator-netbeans   File: PropertiesRowModel.java   Source Code and License Vote up 5 votes
/**
 * Of the parameter is of type Node.Property this methods
 * calls getValue on the property and returns the value.
 * If the parameter is something else <code>null</code>
 * is returned.
 */
public static Object getValueFromProperty(Object property) {
    if (property instanceof Node.Property) {
        Node.Property prop = (Node.Property)property;
        try {
            return prop.getValue();
        } catch (Exception x) {
            ErrorManager.getDefault().getInstance(
                PropertiesRowModel.class.getName()).notify(
                    ErrorManager.INFORMATIONAL, x);
        }
    }
    return null;
}
 
Example 13
Project: incubator-netbeans   File: FormUtils.java   Source Code and License Vote up 5 votes
private static void copyPropertyAttrs(Node.Property sourceProp, Node.Property targetProp, String[] attrs) {
    for (String attr : attrs) {
        Object value = sourceProp.getValue(attr);
        if (value != null) {
            targetProp.setValue(attr, value);
        }
    }
}
 
Example 14
Project: incubator-netbeans   File: IndexedEditorPanel.java   Source Code and License Vote up 4 votes
private void updateDetailsPanel() {
    detailsPanel.removeAll();

    if (!showingDetails) {
        remove(detailsPanel);
        revalidateDetailsPanel();

        return;
    }

    Node[] selN = getExplorerManager().getSelectedNodes();

    if ((selN == null) || (selN.length == 0)) {
        revalidateDetailsPanel();

        return;
    }

    Node n = selN[0];

    if (n == rootNode) {
        revalidateDetailsPanel();

        return;
    }

    if (selN.length > 1) {
        n = new ProxyNode(selN);
    }

    // beware - this will function only if the DisplayIndexedNode has
    // one property on the first sheet and the property is of type
    // ValueProp
    Node.Property prop = n.getPropertySets()[0].getProperties()[0];
    PropertyPanel p = new PropertyPanel(prop);
    p.setPreferences(PropertyPanel.PREF_CUSTOM_EDITOR);

    if (isEditorScrollable(p)) {
        detailsPanel.add(p, java.awt.BorderLayout.CENTER);
    } else {
        jScrollPane1.setViewportView(p);
        detailsPanel.add(jScrollPane1, java.awt.BorderLayout.CENTER);
    }

    revalidateDetailsPanel();
}
 
Example 15
Project: incubator-netbeans   File: FileEditor.java   Source Code and License Vote up 4 votes
/**
 * This method is called by the IDE to pass
 * the environment to the property editor.
 * @param env Environment passed by the ide.
 */
public void attachEnv(PropertyEnv env) {
    this.env = env;

    // clearing to defaults
    directories = true;
    files = true;
    fileFilter = null;
    fileHiding = false;

    Object dirs = env.getFeatureDescriptor().getValue(PROPERTY_SHOW_DIRECTORIES);
    if (dirs instanceof Boolean) {
        directories = ((Boolean)dirs).booleanValue();
    } // XXX else if != null, warn
    Object fil = env.getFeatureDescriptor().getValue(PROPERTY_SHOW_FILES);
    if (fil instanceof Boolean) {
        files = ((Boolean)fil).booleanValue();
    } // XXX else if != null, warn
    Object filter = env.getFeatureDescriptor().getValue(PROPERTY_FILTER);
    if (filter instanceof FilenameFilter) {
        fileFilter = new DelegatingFilenameFilter((FilenameFilter)filter);
    } else if (filter instanceof javax.swing.filechooser.FileFilter) {
        fileFilter = (javax.swing.filechooser.FileFilter)filter;
    } else if (filter instanceof java.io.FileFilter) {
        fileFilter = new DelegatingFileFilter((java.io.FileFilter)filter);
    } // XXX else if != null, warn

    Object curDir = env.getFeatureDescriptor().getValue(PROPERTY_CURRENT_DIR);
    if (curDir instanceof File) {
        currentDirectory = (File)curDir;
        if(! currentDirectory.isDirectory()) {
            Logger.getAnonymousLogger().warning("java.io.File will not accept currentDir=" + currentDirectory); // NOI18N
            currentDirectory = null;
        }
    } // XXX else if != null, warn

    Object baseDir = env.getFeatureDescriptor().getValue(PROPERTY_BASE_DIR);
    if(baseDir instanceof File) {
        baseDirectory = (File)baseDir;
        // As baseDir accept only directories in their absolute form.
        if(!baseDirectory.isDirectory() || !baseDirectory.isAbsolute()) {
            Logger.getAnonymousLogger().warning("java.io.File will not accept baseDir=" + baseDirectory); // NOI18N
            baseDirectory = null;
        }
    } // XXX else if != null, warn
    if (files) {
        mode = directories ? JFileChooser.FILES_AND_DIRECTORIES : 
            JFileChooser.FILES_ONLY;
    } else {
        mode = directories ? JFileChooser.DIRECTORIES_ONLY :
            JFileChooser.FILES_AND_DIRECTORIES; // both false, what now? XXX warn
    }
    
    Object fileHide = env.getFeatureDescriptor().getValue(PROPERTY_FILE_HIDING);
    if (fileHide instanceof Boolean) {
        fileHiding = ((Boolean)fileHide).booleanValue();
    }
    
    if (env.getFeatureDescriptor() instanceof Node.Property){
        Node.Property prop = (Node.Property)env.getFeatureDescriptor();
        editable = prop.canWrite();
    }
}
 
Example 16
Project: incubator-netbeans   File: AbstractLayoutSupport.java   Source Code and License Vote up 4 votes
/** Method to obtain just one propetry of given name.
 * @return layout property of given name
 */
protected Node.Property getProperty(String propName) {
    return metaLayout == null ? null :
                                metaLayout.getPropertyByName(propName);
}
 
Example 17
Project: incubator-netbeans   File: PropertiesRowModel.java   Source Code and License Vote up 4 votes
@Override
public Class getColumnClass(int column) {
    return Node.Property.class;
}
 
Example 18
Project: incubator-netbeans   File: FocusAfterBadEditTest.java   Source Code and License Vote up 4 votes
public void addProp(Node.Property p) {
    props.put(p);
    this.firePropertyChange(PROP_PROPERTY_SETS, null, null);
    this.firePropertySetsChange(null, null);
}
 
Example 19
Project: incubator-netbeans   File: PropertyPanel.java   Source Code and License Vote up 2 votes
/**
 * Create a new property panel for the specified property with the
 * specified preferences.
 * @param p
 * @param preferences
 */
public PropertyPanel(Node.Property p, int preferences) {
    this(p, preferences, null);
}
 
Example 20
Project: incubator-netbeans   File: BoxLayoutSupport.java   Source Code and License Vote up 2 votes
/** Method to obtain just one propetry of given name. Must be override
 * AbstractLayoutSupport because alternative properties are used for
 * BoxLayout (see getProperties method)
 * @return layout property of given name
 */
@Override
protected Node.Property getProperty(String propName) {
    return PROP_AXIS.equals(propName) ? getProperties()[0] : null;
}