Archive

Archive for November, 2011

Marama Code 125 ~ Detect shape updated info

November 23, 2011 Leave a comment

Did you know that you capture or be aware of the changes made in the diagram? For instance when user change a shape name or delete a shape? Yes you can. You just need this codes:

EventPropertyUpdateInfo info = this.propertyUpdated(notification); // get the update info

if (info == null) { return; } // ignore if no update

then,

MaramaDiagram diagram = info.getMaramaDiagram(); // get the diagram

if (diagram == null) { return; } // ignore if diagram doesn’t exist

or

MaramaShape shape = info.getMaramaShape(); // get the shape

if (shape == null) { return; } // ignore if shape doesn’t exist

Once you have captured the diagram/shape, you retrieve the new value that would like to minitor:

String testCategories = mu.getShapeString(sh, “testCategories”); // get the shape value

or, you can filter the shape to make sure you obtain the right shape

if (!sh.getShapeType().equals(“TestInfoShape”)) { return; } // ignore if not info shape

Categories: Java, Life on Marama

Marama Code 124 ~ Hide Your Custome Event Handler

November 21, 2011 Leave a comment

While reading marama WriteEventHandler codes, I found this method that helps to hide the event handlers until a specific icon is selected. Just beware that this method is only applicable for event handlers that were created in working workspace.

public boolean isRunnable() {
  final MaramaShape s = this.getSelectedShape();
    if (s == null) { return false; }

    if (isEventHandlerShapeType(s.getShapeType())) { return true; }
   else { return false; }
}

Categories: Uncategorized

Marama Code 123 ~ Set Custom Properties for Marama Shape

November 15, 2011 Leave a comment

Did you know that you can set the custom properties for each shape in marama, instead using the default properties. The advantages of using this method is you can load a pre-properties attribute rather than having empty space or pre-specified text.

To do this, you need to set a custom method in the event handler to load as soon as the method is invoke. Here is the code that need to be include in the event handler:

@Override
    public void setDiagram(final MaramaDiagram diagram) {
        super.setDiagram(diagram);

        for (final MaramaShapeType st : diagram.getViewType().getShapeTypes()) {
            st.setCustomProperties(new NewCustomProperties());
        }
    }

You need to create a custom properties class, for instance in this example, the NewCustomProperties class.

Categories: Uncategorized
Follow

Get every new post delivered to your Inbox.