wiki:GritsTutorial_SampleMetaDataManager

Sample Meta Data Manager

Introduction

It consists of four pages, each page meant to manage a different type of meta data that is stored in the ontology. The four types of meta information that are managed are

  • Descriptor
  • Descriptor Group
  • Template
  • Category

The first page manages Descriptor in the ontology. Here is a screenshot of it:

Working

Each page extends ""AbstractManagementPage"" which extends FormPage. The AbstractManagementPage lays the basic layout creating two sections. One of the section lists the objects and the other section displays the information related to the selected object in the first section. Since the first three pages required a generic container giving information related to label, description, editing ability etc. the container classes for each of the three objects (Descriptor, Descriptor Group, Template) were created from same abstract class "ClassesWithFeatures". This abstract class has a getter and setter for editable flag. It forces its children class to return label, description and URI.

As shown in the diagram, the AbstractManagementPage leftSection as its protected field which is modified by the concrete class setting its title, action bars, and content provider for the tableviewer and listener etc. An example code is shown for the DescriptorManagementPage

    @Override
    public void createRestOftheContent()
    {
        leftSectionOfPage.setText(this.getTitle());
        SetupLeftSideSection leftSectionSetup = new SetupLeftSideSection(this, this.inputDescriptors);
        TableViewer tableViewer = leftSectionSetup.setUp();
        super.createToolBar(tableViewer, OntologyManager.DESCRIPTOR_CLASS_URI);
        tableViewer.addSelectionChangedListener(new DescriptorSelectionListener(this));
    }

For each of the pages a different SelectionChangedListener Class is added to the tableViewer which decides the right section of the page. In the SetupLeftSideSection which is common for all the pages, the tableViewer is setup with content and label provider. These content and label provider are generic as they all get input as List of objects of class "ClassWithFeatures". Any child class inheriting this class has a label, uri, and has a field indicating whether it is editable or not.

    public TableViewer setUp()
    {
        TableViewer tableViewer = this.generalizedTableWithActions.createTableViewer(300, 730);
        tableViewer.setLabelProvider(new ListLabelProvider());
        tableViewer.setContentProvider(new GenericListContentProvider());
        tableViewer.setInput(this.inputList);
        return tableViewer;
    }

The class "ClassesWithFeatures" just has an editable field setter and getter but for rest of the fields, the getter and setters are abstract which are implemented by the concrete classes. The DescriptorTypeClassesWithFeatures has abstract methods for updating the maximum occurrence and categories. The heirarchy is shown as below:

Corresponding to this class hierrarchy, the right side section which displays the information related to the objects of this class also has a similar hierarchy. The most generic class RightSideSection creates the part for displaying label and description in the "createGeneralPart" for all the objects of type "ClassesWithFeatures" while resetting in "setGeneralPart". It leaves the method "createSpecificPart" and "setSpecificPart" abstract to be implemented by its child depending on what type of object's information is to be displayed. A TemplateWithFeatures object would have mandatory and optional descriptor/group tables while an object of type "DescriptorWithFeatures" would have namespace and units table to display. The "RightSideDescriptorTypeSection" displays information like maxOccurrence spinner and mandatory checkbox which are common to both Descriptor and DecriptorGroup objects an is contained in DescriptorTypeClassesWithFeatures. It implements the method "createSpecificPart" and "setSpecificPart" but leaves the method "createMoreSpecificPart" and "setMoreSpecificPart" abstract. It is hsown below:

Last modified 7 years ago Last modified on 09/20/2014 12:42:30 AM

Attachments (7)

Download all attachments as: .zip