Commit b2f1b9dc authored by Romain Bioteau's avatar Romain Bioteau
Browse files

code quality

parent b9f9c12d
......@@ -70,11 +70,6 @@ public class FormPaletteLabelProviderTest {
labelProvider.getFormPaletteDescription(ProcessPackage.Literals.FLOW_ELEMENT);
}
@Test(expected = IllegalArgumentException.class)
public void should_getFormPaletteDescription_throw_IllegalArgumentException_for_combo_eClass() throws Exception {
labelProvider.getFormPaletteDescription(FormPackage.Literals.COMBO_FORM_FIELD);
}
@Test(expected = IllegalArgumentException.class)
public void should_getFormPaletteText_throw_IllegalArgumentException_for_combo_eClass() throws Exception {
labelProvider.getFormPaletteText(FormPackage.Literals.COMBO_FORM_FIELD);
......
......@@ -116,22 +116,22 @@ public class FormPaletteLabelProvider {
}
public String getFormPaletteDescription(final EClass eClass) {
Assert.isLegal(eClass != null);
Assert.isLegal(FormPackage.Literals.WIDGET.isSuperTypeOf(eClass), "EClass " + eClass.getName() + " is not supported.");
final int id = eClass.getClassifierID();
final String label = classifierIDToDescription.get(id);
Assert.isLegal(label != null, "EClass " + eClass.getName() + " is not supported.");
return label;
final int id = getEClassifierId(eClass);
return classifierIDToDescription.get(id);
}
public String getFormPaletteText(final EClass eClass) {
Assert.isLegal(eClass != null);
Assert.isLegal(FormPackage.Literals.WIDGET.isSuperTypeOf(eClass), "EClass " + eClass.getName() + " is not supported.");
final int id = eClass.getClassifierID();
final int id = getEClassifierId(eClass);
final String label = classifierIDToTitle.get(id);
Assert.isLegal(label != null, "EClass " + eClass.getName() + " is not supported.");
return label;
}
protected int getEClassifierId(final EClass eClass) {
Assert.isLegal(eClass != null);
Assert.isLegal(FormPackage.Literals.WIDGET.isSuperTypeOf(eClass), "EClass " + eClass.getName() + " is not supported.");
return eClass.getClassifierID();
}
}
......@@ -155,16 +155,12 @@ public class ProcessPaletteLabelProvider {
}
public String getProcessPaletteDescription(final EClass eClass) {
Assert.isLegal(eClass != null);
Assert.isLegal(ProcessPackage.eINSTANCE.equals(eClass.getEPackage()), "EClass " + eClass.getName() + " is not supported.");
final int id = eClass.getClassifierID();
final int id = getEClassifierId(eClass);
return classifierIDToDescription.get(id);
}
public String getProcessPaletteText(final EClass eClass) {
Assert.isLegal(eClass != null);
Assert.isLegal(ProcessPackage.eINSTANCE.equals(eClass.getEPackage()), "EClass " + eClass.getName() + " is not supported.");
final int id = eClass.getClassifierID();
final int id = getEClassifierId(eClass);
final String label = classifierIDToTitle.get(id);
if (label == null) {
return eClass.getName();
......@@ -172,6 +168,12 @@ public class ProcessPaletteLabelProvider {
return label;
}
protected int getEClassifierId(final EClass eClass) {
Assert.isLegal(eClass != null);
Assert.isLegal(ProcessPackage.eINSTANCE.equals(eClass.getEPackage()), "EClass " + eClass.getName() + " is not supported.");
return eClass.getClassifierID();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment