Java Reference
In-Depth Information
Before generation, we need to check the other properties and make changes
accordingly. As with the mindmap and other models, we want to generate our
model, edit, and editor code to their own projects, so we can change the Model
Plug-in ID and Model Directory properties to be org.eclipse.require-
ments.model . We generate the three plug-ins and open the org.eclipse.
requirements.provider.RequirementItemProvider class from our Edit
plug-in. Modify the getText() method as seen next. Note that if we wanted to
preserve the generated method to allow the label feature of the generator model
to have an effect, we could use the getTextGen() method approach, as described
in the EMF documentation.
/**
* This returns the label text for the adapted class.
* Modified to show id (major.minor.service) : title
*
* @generated NOT
*/
@Override
public String getText(Object object) {
StringBuilder sb = new StringBuilder();
sb.append(((Requirement)object).getId());
sb.append(" (");
Version version = ((Requirement)object).getVersion();
if (version != null) {
sb.append(((Requirement)object).getVersion().getMajor());
sb.append(".");
sb.append(((Requirement)object).getVersion().getMinor());
sb.append(".");
sb.append(((Requirement)object).getVersion().getService());
} else {
sb.append("0.0.0");
}
sb.append(") : ");
sb.append(((Requirement)object).getTitle());
String label = sb.toString();
return label == null || label.length() == 0 ?
getString("_UI_Requirement_type") : label;
}
We've eliminated the redundant Requirement prefix from our label because
we're using a custom icon to distinguish Requirements from Requirement
Groups , Comments , and so on. For our RequirementGroup element, we can
similarly modify the getText() method to display only the name attribute; we
can modify the Comment element to display created , author , and subject .
Search WWH ::




Custom Search