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

The following are Jave code examples for showing how to use getHelpCtx() 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: HelpTest.java   Source Code and License Vote up 6 votes
public void testItemHelp() throws Exception {
    FileObject item1 = getItemFile( categoryNames[0], itemNames[0][0] );
    FileObject item2 = getItemFile( categoryNames[0], itemNames[0][1] );
    
    item1.setAttribute( PaletteController.ATTR_HELP_ID, "DummyHelpId" );
    
    PaletteController pc = PaletteFactory.createPalette( getRootFolderName(), new DummyActions() );
    Model model = pc.getModel();
    Category[] categories = model.getCategories();
    Item[] items = categories[0].getItems();
    
    Node node1 = items[0].getLookup().lookup( Node.class );
    Node node2 = items[1].getLookup().lookup( Node.class );
    
    HelpCtx help1 = node1.getHelpCtx();
    HelpCtx help2 = node2.getHelpCtx();

    assertEquals( "Custom help", "DummyHelpId", help1.getHelpID() );
    assertEquals( "Default help", HelpCtx.DEFAULT_HELP, help2 );
}
 
Example 2
Project: incubator-netbeans   File: HelpTest.java   Source Code and License Vote up 6 votes
public void testCategoryHelp() throws Exception {
    FileObject cat1 = getCategoryFile( categoryNames[0] );
    FileObject cat2 = getCategoryFile( categoryNames[1] );
    
    cat1.setAttribute( PaletteController.ATTR_HELP_ID, "DummyHelpId" );
    
    PaletteController pc = PaletteFactory.createPalette( getRootFolderName(), new DummyActions() );
    Model model = pc.getModel();
    Category[] categories = model.getCategories();
    
    Node node1 = categories[0].getLookup().lookup( Node.class );
    Node node2 = categories[1].getLookup().lookup( Node.class );
    
    HelpCtx help1 = node1.getHelpCtx();
    HelpCtx help2 = node2.getHelpCtx();

    assertEquals( "Custom help", "DummyHelpId", help1.getHelpID() );
    assertNull( "Default help", help2 );
}
 
Example 3
Project: incubator-netbeans   File: LookupNode.java   Source Code and License Vote up 6 votes
public HelpCtx getHelpCtx () {
    Object o = getDataObject().getPrimaryFile().getAttribute(EA_HELPCTX);
    if (o != null) {
        return new HelpCtx(o.toString());
    }
    // now try the original DataObject (assume it is a folder-thing)
    HelpCtx ctx = getDataObject().getHelpCtx();
    if (ctx != null &&
        ctx != HelpCtx.DEFAULT_HELP &&
        !FOLDER_DEFAULT_HELP.equals(ctx)) {
        return ctx;
    }
    // try the parent node:
    Node n = getParentNode();
    if (n != null)
        ctx = n.getHelpCtx();
    return ctx;
}
 
Example 4
Project: incubator-netbeans   File: LookupNode.java   Source Code and License Vote up 6 votes
public HelpCtx getHelpCtx() {
    Object o = data.getPrimaryFile().getAttribute(EA_HELPCTX);
    if (o != null) {
        return new HelpCtx(o.toString());
    }
    // now try the original DataObject (assume it is a folder-thing)
    HelpCtx ctx = getOriginal().getHelpCtx();
    if (ctx != null &&
        ctx != HelpCtx.DEFAULT_HELP &&
        !INSTANCE_DEFAULT_HELP.equals(ctx)) {
        return ctx;
    }
    // try the parent node:
    Node n = getParentNode();
    if (n == null)
        n = parent;
    if (n != null)
        ctx = n.getHelpCtx();
    return ctx;
}
 
Example 5
Project: incubator-netbeans   File: HelpTest.java   Source Code and License Vote up 5 votes
public void testRootHelpCustom() throws Exception {
    paletteRootFolder.setAttribute( PaletteController.ATTR_HELP_ID, "DummyHelpId" );
    
    PaletteController pc = PaletteFactory.createPalette( getRootFolderName(), new DummyActions() );
    Model model = pc.getModel();
    Node node = model.getRoot().lookup( Node.class );
    
    HelpCtx help = node.getHelpCtx();

    assertEquals( "Custom help", "DummyHelpId", help.getHelpID() );
}
 
Example 6
Project: incubator-netbeans   File: HelpTest.java   Source Code and License Vote up 5 votes
public void testRootHelpDefault() throws Exception {
    PaletteController pc = PaletteFactory.createPalette( getRootFolderName(), new DummyActions() );
    Model model = pc.getModel();
    Node node = model.getRoot().lookup( Node.class );
    
    HelpCtx help = node.getHelpCtx();

    assertNull( "Custom help", help );
}