Classes

Charta contains a lot of basic classes like Text, Integer32, Float64, that you need in any programming language. It also contains some Charta specific classes, like an Output item or a Day of the week.

Manual-GoingDeeper-ChartaClasses.jpg
Klik om te vergroten

And then there are the classes you create yourself. In the demo Person and Project are an example of that.

Manual-GoingDeeper-DemoClasses.jpg
Klik om te vergroten

In order to be able to add informtion to a task we will now show you how to create a new class Note

Creating a custom class

  • Navigate to the explorer and expand the Classes node by pressing Right
  • Press Enter
    This will show you a table with the classes defined for the demo.
  • Select a row and press Ctrl+Insert
    A new class is created at the bottom of the table.
  • Press Enter
    This opens a new tab in the control vault with the fields to define the class.
  • Type "Note" in the name field
  • Select the members field with Windwos+Down and press Insert
    This adds a row to the members table so that you can define what a note consists of.
  • Type "High priority" in the name field of the member and type "boolean" in the type field
    When typing in the type field a suggestion is shown. If you press Enter you select that suggested type. If you press Ctrl+Spacebar you will get more suggestions.
  • Select the row and press Ctrl+Insert
    This adds another member.
  • Type "Backup" in the name field and select Person as the type
    A checkbox appears in the auto-create column. Auto-create means that when an object of your class is created, an object of you member will be created automatically. If the auto-create option is defined by default for the type (like boolean) the checkbox won't appear.
  • Select the auto-create field and press Spacebar
    This will set the auto-create option to true.
    Manual-GoingDeeper-AddClass.jpg
    Klik om te vergroten

    You have now added your first class.
  • As an excercise add a member of type Note to the Weekly task class
    This should result in
    Manual-GoingDeeper-AddMemberToClass.jpg
    Klik om te vergroten

We now have created a new class, and we have used it as a member of another class. But if we create objects of the classes, how do we set the references? The next example will tell you that. We will show you how to reference a Note object from a Weekly task object.

Lessons learned

  • Adding classes to your application
  • Setting the members of a class
  • Using the auto-create option