Java

The Java API

Introduction

You will find here the detailed API of the Atlas toolkit for Java. The API overview contains also useful information about the API.

info.q37.atlas.Atlas class

Static functions

launch

void launch(String newSessionAction, Type type)

Launches the server. newSessionAction is the value returned by below info.q37.atlas.DOM.getAction(...) function when a new session is launched.

type can be:

  • info.q37.atlas.Atlas.Type.DEFAULT to launch the default interface (desktop one),
  • info.q37.atlas.Atlas.Type.DESKTOP to launch the desktop interface,
  • info.q37.atlas.Atlas.Type.WEB to launch the web interface.

NOTA: in some examples, a launch function with extraneous parameters is used. For your own developments, you don't need to give this extraneous parameters.

Abstract functions

handle

public void handle(q37.info.atlas.DOM dom, String action, String id)

This is the function you have to implement. It is called each time the user performs an action. You get :

  • dom, which is an info.q37.atlas.DOM object, detailed below, to manipulate the DOM,
  • action, which is the action tag defined for the corresponding event in the data-xdh-onevent(s) attribute for the element which receives the event,
  • id, the id of this element.

info.q37.atlas.Tree class

Tree constructor

It takes no parameter.

popTag

void popTag()

Closes the tag previously opened by pushTag(...), and the parent one becomes the current one.

pushTag

void pushTag(String name)

Create a new tag of name name as child of the current one, and becomes the current one.

putAttribute

void putAttribute(String name, boolean value)
void putAttribute(String name, int value )
void putAttribute(String name, String value )

Add attribute of name name and value value to the current tag.

putValue

void putValue(String value)

Set value as value for the current tag.

info.q37.atlas.DOM class

This class contains the data for each users' session, and functions to manipulate the DOM displayed by the web browser.

Global

DOM constructor

Takes no parameter.

alert

void alert(String message)

Displays an alert box with the string message as message.

confirm

boolean confirm(String message)

Displays a confirmation dialog box with message as message. The returned value is true when the user clicks the OK button, and false when the user clicks the cancel button.

focus

void focus(String id)

Gives the focus to element of id id.

Attribute

getAttribute

String getAttribute(String id, String name)

Returns the value of the attribute named name of the element of id id.

removeAttribute

void removeAttribute(String id, String name)

Removes attribute named name from element of id id.

setAttribute

void setAttribute(String id, String name, String value)

Set value as value for the attribute named name of the element of id id.

Class

Following methods allows to handle classes (the CSS related class attributes of HTML tags), by respectively add, remove or toggle (i.e. adds if not present, otherwise removes) a class to elements identified by their ids (the content of the id attribute from HTML tags).

idsAndClasses must have following form:

{
    { "id1", "class1" },
    { "id2", "class2" },
    { "id3", "class3" },
    ...
}

addClass

void addClass(String id, String class)

addClasses

void addClasses(String[][] idsAndClasses)

removeClass

void removeClass(String id, String class)

removeClasses

void removeClasses(String[][] idsAndClasses)

toggleClass

void toggleClass(String id, String class)

toggleClasses

void toggleClasses(String[][] idsAndClasses)

Content

getContent

String getContent(String id)

Retrieve the content of the element of id id.

getContents

String[] getContents(String[] ids)

Retrieves the content of the elements of ids ids in the same order.

setContent

void setContent(String id, String content)

Set the content of element of id id to value.

setContents

void setContents(String[][] idsAndContents)

Set the content of all element which id are in idsAndContents to corresponding content.

idsAndContents must have following form:

{
    { "id1", "content1"},
    { "id2", "content2"},
    { "id3", "content3"},
    ...
}

Element

enableElement

void enableElement(String id)

Enable element of id id.

enableElements

void enableElements(String[] ids)

Enable element of ids ids.

disableElement

void disableElements(String[] ids)

Disable element of if id.

disableElements

void disableElements(String[] ids)

Disable element of ids ids (array of strings).

Layout

setLayout

void setLayout(String id, Tree tree, String xslFilename)

Replaces the content of element with string id as id with the result of the transformation of the XSL file with name xslFilename applied to the tree instance of a Tree class (see above).

If id is an empty string, the content of the entire document is replaced by the resulting transformation.

Property

getProperty

String getProperty(String id, String name)

Returns the value of property named name of the element of id id.

setProperty

void setProperty(String id, String name, String value)

Set value as value for the property named name of the element of id id.

Widget

dressWidgets

void dressWidgets(String id)

Create the widget for each elements which are children of the element of id id and which have a data-xdh-widget attribute.

If id is an empty string, the entire document is handled.