3.
ProfileExamplePropertiesEditor
This class manages the properties editor of the
profile.
package com.omondo.uml.profile.example;
import com.omondo.uml.std.external.profile.ProfilePropertiesEditor;
import org.eclipse.swt.widgets.Composite;
public class ProfileExamplePropertiesEditor implements ProfilePropertiesEditor {
This method return a SWT Composite object
that will be displayed when the user selects the associated profile in
the Omondo Profile section of
the project properties.
Note that if the example returns null, a default empty composite will be
used instead.
public Composite createEditorArea(Composite parent) { return null; }
public void dispose() { }
public boolean isDirty() { return false; }
public void save() { } }
|
4.
FragmentExample
The Fragment
class is used at the element level to manage Actions additions to the popup
menu and Tabs additions to
the properties dialog.
A fragment is associated to a stereotype and to some element types.
Thus when this stereotype is applied to an element of the associated
type, the fragment is activated so the declared actions and tabs are
added to the ihms.
Note that the association between fragment classes and
stereotypes / element types is performed by means of the extension point properties.
package com.omondo.uml.profile.example;
import com.omondo.uml.std.external.profile.ExtensionTabItem;
import com.omondo.uml.std.external.profile.AbstractFragment;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
public class FragmentExample extends AbstractFragment
{
public FragmentExample()
{
}
public void init(IProject project)
{
super.init(project);
extensionTabItems = new ExtensionTabItem[] {
new FragmentExampleTabItem(getStereotypeFullName())
};
}
This method is used to declare the additional tabs. See
below for more information.
public ExtensionTabItem[] getExtensionTabItems()
{
return extensionTabItems;
}
This
method is used to select the Actions
that will be added to the element popup menu. The selected actions will
be added into a group
labeled with the name of the profile.
protected void registerDefaultContributionItems()
{
addContributionItem(
new Action("Example action") {
public void run()
{
String buf = "Stereotype properties values: \n\n";
String name = "attr";
buf += "\t" + name + " -> " + getStereotypeValue(name) + "\n";
MessageDialog.openInformation(PluginExample.getShell(), "title", buf);
}
}
);
}
This
method is used to select the Actions
that will be added to the element popup menu. The selected actions will
be added into the New group.
protected void registerNewContributionItems()
{
}
private ExtensionTabItem extensionTabItems[];
}