Data Objects & Editors David Strupl Staff Engineer Sun - - PowerPoint PPT Presentation

data objects editors
SMART_READER_LITE
LIVE PREVIEW

Data Objects & Editors David Strupl Staff Engineer Sun - - PowerPoint PPT Presentation

Data Objects & Editors David Strupl Staff Engineer Sun Microsystems Agenda DataObject Factories Presentation Editor APIs > Schliemann > Lexer > Folding > Highlighting > Code completion > ... Certified


slide-1
SLIDE 1

Data Objects & Editors

David Strupl Staff Engineer Sun Microsystems

slide-2
SLIDE 2

Certified Engineer Course

Agenda

  • DataObject
  • Factories
  • Presentation
  • Editor APIs

> Schliemann > Lexer > Folding > Highlighting > Code completion > ...

slide-3
SLIDE 3

Certified Engineer Course

DataObject

  • Logical object around a FileObject

> Understands the file's content > Copy, move, shadow,

createFromTemplate

> Can represent multiple files (not

recommended)

  • Factories

> A module installs a DataLoader for a

particular file type

> Usually registered by MIME type + file extension > That loader is a factory for DataObjects for that type of file

slide-4
SLIDE 4

Certified Engineer Course

DataObjects provide

> A Lookup – you can query for objects you know about > A Node – to represent it in the UI > A way to have an object that survives file rename/move

slide-5
SLIDE 5

Certified Engineer Course

DataLoader

  • Factory

> by mime type > by extension

  • Context Actions

> String actionsContext();

> Path to a folder in the system filesystem (layer.xml file) > Can be regular javax.swing.Actions

  • Can have persistent state
slide-6
SLIDE 6

Certified Engineer Course

FileSystems vs. Loaders API

  • One type vs. multiple types
  • One file vs. group of files
  • Raw data vs. operations on content

> Think of a DataObject as representing a

(potentially) parsed file

A.java A.class B.properties B_ja.properties

slide-7
SLIDE 7

Certified Engineer Course

Visualizing DataObjects

  • A DataObject has a...

NODE!

DataObject.getNodeDelegate()

slide-8
SLIDE 8

Certified Engineer Course

Diagram of API Layers

slide-9
SLIDE 9

Certified Engineer Course

Files, DataObjects, Nodes, Explorer

  • One set of APIs – but two usages:

> 1. Visualizing and interacting with real files

  • n disk

> 2. Visualizing and interacting with parts of

NetBeans configuration Files on disk are a filesystem. The “system filesystem” is also a filesystem

A registry of configuration information, read/write

Many pieces of UI in NetBeans are just a view

  • f some folder in the System Filesystem

Menus, Toolbars, nodes in the Services tab

slide-10
SLIDE 10

Certified Engineer Course

DataObject Classes

  • DataObject

> base API class, default data object

  • MultiDataObject

> abstract support class – may represent

>1 file

  • DataFolder
  • DataShadow – like a unix symbolic

link

  • InstanceDataObject – represents an
  • bject

> settings management - .instance files

register an object in the system filesystem – different folders have

slide-11
SLIDE 11

Certified Engineer Course

Visual Creation

  • /Templates && TemplateWizard
slide-12
SLIDE 12

Certified Engineer Course

Templating Languges

  • Any scripting language

> javax.script.ScriptEngine > http://scripting.dev.java.net

  • Support for Freemarker

> substitutions > variables > cycles

  • CreateFromTemplateAttributeProvider
  • TemplateWizard.putProperty(xxx) -> $

{wizard.xxx}

slide-13
SLIDE 13

Certified Engineer Course

Visual Representation

  • Represented by Nodes

> DataObjects are the model > Nodes are the presentation of the model

> They add human-friendly attributes – name, icon, etc.

  • DataObject.getNodeDelegate()

> DataNode - premade superclass > FolderNode & FolderChildren

  • Write you own hierarchy

> projects > files > favorites

slide-14
SLIDE 14

Certified Engineer Course

Context of a DataObject

  • DataObject.getLookup()

> added in 6.0 – previously

> DataObject.getCookie(Class type) or DataObject.getNodeDelegate().getLookup()

  • In case of MultiDataObject

> getCookieSet().getLookup()

  • Can be controlled by

> getCookieSet().assign(Data.class, data)

slide-15
SLIDE 15

Certified Engineer Course

Text Editor

  • API for accessing

> EditorCookie > OpenCookie > EditCookie

  • Supporting classes

> CloneableEditorSupport > CloneableEditor > DataEditorSupport

slide-16
SLIDE 16

Certified Engineer Course

Editor APIs

  • Syntax coloring
  • Code folding
  • Navigation
  • Code completion
  • Brace matching
  • Actions
  • Tooltips
  • Hyperlinks
  • Indentation
  • Annotations (e.g. error lines).
slide-17
SLIDE 17

Certified Engineer Course

Schliemann

  • NBS files
  • Simple languages

> LL(k)

  • “Real” languages support by the IDE

use editor APIs directly

slide-18
SLIDE 18

Certified Engineer Course

Conclusion

  • DataObject

> logical view over a file > created by factories

  • Extensible via layers

> actions > templates

  • Visualized by Nodes
  • Content edited by editors
slide-19
SLIDE 19

DEMO

  • File Type Integration