Nodes & Explorer Views Geertjan Wielenga Sun Microsystems.

Slides:



Advertisements
Similar presentations
June, 2007 Petr Hamernik Extending Instant JChem 2.0 Architecture & API.
Advertisements

March Ron McFadyen1 Composite Used to compose objects into tree structures to represent part-whole hierarchies Composite lets clients treat.
Java Review Structure of a graphics program. Computer Graphics and User Interfaces Java is Object-Oriented A program uses objects to model the solution.
Contructing GUI’s in Java Implemented in the Swing API Imported into your programs by: import javax.swing.*; Most Swing programs also need the AWT packages.
Java Swing Joon Ho Cho. What is Java Swing? Part of the Java Foundation Classes (JFC) Provides a rich set of GUI components Used to create a Java program.
Creating of Rich Client Applications using NetBeans 6 and Java Swing Miroslav Nachev.
GUI Basics: Introduction. Creating GUI Objects // Create a button with text OK JButton jbtOK = new JButton("OK"); // Create a label with text "Enter your.
Java Beans.
Intro to Java 2 By Geb Thomas Based on the Java TutorialJava Tutorial.
Java GUI CSCE 190 – Java Instructor: Joel Gompert Mon, July 26, 2004.
tiled Map Case Study: Rendering with JPanel © Allan C. Milne v
Swing, part 2 Tutorial 07 1 / 31 Leonid Barenboim 25/4/2010.
Session 27 Swing vs. AWT. AWT (Abstract Window ToolKit) It is a portable GUI library for stand-alone applications and/or applets. The Abstract Window.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
CSC 205 – Java Programming II Applet. Types of Java Programs Applets Applications Console applications Graphics applications Applications are stand-alone.
Object-Oriented Programming (Java), Unit 18 Kirk Scott 1.
Reporting – Sort Orders, Selections, and Related Data TEC02 Brian Ciccolo.
Trees CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
SWING 101. IF YOU GET LOST - IMPORTANT LINKS  Swing articles:
1.  At the end of this slide, student able to:  Object-Oriented Programming  Research on OOP features.  Do a code walkthrough to examine the implementation.
1 Java Swing - Lecture 2 Components and Containment Boriana Koleva
JTree javax.swing.tree javax.swing.event. Components JTree and JTable COMPONENT – Model – Selection Model – Editor – Renderer.
1 / 67 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 14 Programming Fundamentals using Java 1.
 GUI – Graphic User Interface  Up to now in the programs we have written all output has been sent to the standard output device i.e.: the DOS console.
Inheritance and Design CSIS 3701: Advanced Object Oriented Programming.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 31 JTable and JTree.
Swinging in Your Java Playground. Background Swing is a part of the Java Foundation Classes (JFC). The JFC is made up of features intended to give a programmer.
Swing - 2 Session 13. Swing - 2 / 2 of 38 Objectives (1) Discuss trees and tables Discuss progress bars Discuss MVC architecture Describe menus.
Swing. Introduction to Swing What is Swing? “ Swing is a diverse collection of lightweight components that can be used to build sophisticated user interfaces.”
More Swing utilities: JTree COMP204, Bernhard Pfahringer Code snippets taken from Sun’s JTree demo example.
עקרונות תכנות מונחה עצמים תרגול 8: MVC. Outline  MVC  Using the default models  Example- File Browser.
Java Swing One of the most important features of Java is its ability to draw graphics.
Creating Modular CRUD Desktop Applications Jiri Rechtacek Geertjan Wielenga.
Presented By:. What is JavaHelp: Most software developers do not look forward to spending time documenting and explaining their product. JavaSoft has.
Using NetBeans IDE for Desktop Development Geertjan Wielenga
Introduction to the NetBeans Platform Certified Training Course Geertjan Wielenga Sun Microsystems.
Beans Binding Framework & Swing Application Framework Geertjan Wielenga http//netbeans.dzone.com.
Getting Started with the NetBeans Platform. Extending NetBeans Possibilities > single module > suite of modules > standalone application > like a suite.
Porting a Swing Application to the NetBeans Platform Anton Epple
NetBeans Rich Client Platform Alex Kotchnev Software Developer Commerce Technologies Inc. Alex Kotchnev Software Developer Commerce Technologies Inc.
An Introduction to the Window System. Agenda ● Problem statement ● Solution ● Demos: ● Creating a TopComponent ● Porting a Swing Application ● API Overview.
Consumer IDE Jiri Rechtacek Geertjan Wielenga Sun Microsystems.
System FileSystem Everything is a Stream. What is it? General registry of configuration data.
Hello NetBeans Platform
Recap Modules: dependency management, revisioning, information hiding
Data Structures and Design in Java © Rick Mercer
Nodes and Explorer David Strupl Staff Engineer Sun Microsystems.
using System; namespace Demo01 { class Program
Geertjan Wielenga
Basic Controls and Plugins
Nodes and Explorer NetBeans ~ JavaBeans Tim Boudreau
Advanced Swing Lists.
Architectural Patterns for Interactive Software
Contributing to Open Source Projects
New Features in NetBeans Platform 6.5.
Geertjan Wielenga This presentation introduces Swing Application Framework and Beans Binding JSRs. These are two new JSRs.
NetBeans ~ JavaBeans Jaroslav Tulach Sun Microsystems.
Productivity Tools Extensions to NetBeans IDE that make life easier
Using the Hierarchy Workbench
CNT 4007C Project 2 Good morning, everyone. In this class, we will have a brief look at the project 2. Project 2 is basically the same with project 1.
עקרונות תכנות מונחה עצמים תרגול 8: MVC
Chapter 8 Objects and Classes Part 1
class PrintOnetoTen { public static void main(String args[]) {
Steps to Creating a GUI Interface
Week 8 Swing NetBeans GUI Builder
Constructors, GUI’s(Using Swing) and ActionListner
Chapter 17 Creating User Interfaces
Methods/Functions.
Chapter 17 Creating User Interfaces
Windows Forms in Visual Studio 2005: An in-depth look at key features
Presentation transcript:

Nodes & Explorer Views Geertjan Wielenga Sun Microsystems

Agenda Problem Statement & Solution Nodes Explorer Views Q/A

Problem Statement public class JListDemo extends JFrame { public static void main(String args[]) { final JList jList1 = new JList(); jList1.setModel(new AbstractListModel() { String[] strings = {"Tom", "Dick", "Harry "}; @Override public int getSize() { return strings.length; } public Object getElementAt(int i) { return strings[i]; }); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JListDemo list = new JListDemo(); list.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); list.setTitle("JList Demo"); list.setSize(new Dimension(200, 200)); list.add(jList1); list.setVisible(true);

Problem Statement public class JTreeDemo extends JFrame { public static void main(String args[]) { final JTree jTree1 = new JTree(); DefaultMutableTreeNode treeNode1 = new DefaultMutableTreeNode("Names"); DefaultMutableTreeNode treeNode2 = new DefaultMutableTreeNode("Tom"); treeNode1.add(treeNode2); treeNode2 = new DefaultMutableTreeNode("Dick"); treeNode2 = new DefaultMutableTreeNode("Harry"); jTree1.setModel(new DefaultTreeModel(treeNode1)); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JTreeDemo list = new JTreeDemo(); list.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); list.setTitle("JTree Demo"); list.setSize(new Dimension(200, 200)); list.add(jTree1); list.setVisible(true); } });

Problem Statement When presenting data models to user... Need to program many low level details (e.g., cell renderers) Switching from one control (e.g., Jlist) to another control (JTree) is hard Context sensitivity A lot of plumbing code is needed!

Solution Nodes API: Easy to create a tree-like model Explorer API: Many UI components that can render the model

Solution class NamesNode extends Children.Keys<String> { @Override protected void addNotify() { String[] strings = {"Tom", "Dick", "Harry "}; setKeys(strings); } protected Node[] createNodes(String key) { return new Node[]{new PropNode(key)}; private class PropNode extends AbstractNode { private PropNode(String key) { super(Children.LEAF, Lookups.fixed()); setDisplayName(key);

What is a Node? Nodes are a presentation layer Nodes are hierarchical They have child nodes that can have their own child nodes.

DEMO How to Create a Node

Presentation Layer Nodes take a random object and provide human-friendly features Actions Display name Description Icon Properties (can be shown/edited in property sheet) Clipboard operations

Nodes API import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; class MyNode extends AbstractNode { public MyNode() { super(new MyChildren()); }} class MyChildren extends Children.Keys<String> { protected void addNotify() { String[] names = {"Tom", "Dick", "Harry "}; setKeys(names); } protected Node[] createNodes(String key) { MyNode n = new MyNode(); n.setName(key); return new Node[] { n };

What is an Explorer View? An “explorer” component is a Swing component It can show a Node and its children Many different components Trees, Lists, Combo Boxes, Tree Tables, Property Sheet all in org.openide.explorer.view Nodes provide a universal tree-model for presenting data Explorer views are components to show that data to the user

How to Add Explorer Views to the Palette DEMO How to Add Explorer Views to the Palette

Views ExplorerManager root context explored context selected nodes (vetoable) General Model behind Swing BeanTreeView, ContextTreeView ListView PropertySheet TableTreeView

Using Explorer Views class MyPanel extends JPanel implements ExplorerManager.Provider { public MyPanel() { myManager = new ExplorerManager(); add(new BeanTreeView()); add(new PropertySheetView()); myManager.setRootContext(myNode); } public ExplorerManager getExplorerManager() { return myManager;

How to Use Explorer Views DEMO How to Use Explorer Views

How to Port to the NetBeans Platform DEMO How to Port to the NetBeans Platform

Nodes and Selection Each window component has a Lookup Nodes have Lookups You can easily have the window component's Lookup proxy whatever the Lookup(s) of the selected Node(s) in an explorer view

Conclusion Nodes are typed JavaBeans Hierarchy Extensible Rich Set of Views Standalone

Q&A http://bits.netbeans.org/dev/javadoc/org-openide-nodes/ http://bits.netbeans.org/dev/javadoc/org-openide-explorer/