use of org.drools.workbench.screens.globals.model.Global in project drools-wb by kiegroup.
the class GlobalsPersistenceTest method testMarshalling.
@Test
public void testMarshalling() {
final GlobalsModel model = new GlobalsModel();
final String expected = "global java.lang.String myString;\n";
model.getGlobals().add(new Global("myString", "java.lang.String"));
final String actual = GlobalsPersistence.getInstance().marshal(model);
assertNotNull(actual);
assertEquals(expected, actual);
}
use of org.drools.workbench.screens.globals.model.Global in project drools-wb by kiegroup.
the class GlobalsEditorViewImpl method setup.
private void setup() {
// Setup table
table.setStriped(true);
table.setCondensed(true);
table.setBordered(true);
table.setEmptyTableWidget(new Label(translationService.getTranslation(GlobalsEditorConstants.GlobalsEditorViewImplNoGlobalsDefined)));
// Columns
final TextColumn<Global> aliasColumn = new TextColumn<Global>() {
@Override
public String getValue(final Global global) {
return global.getAlias();
}
};
final TextColumn<Global> classNameColumn = new TextColumn<Global>() {
@Override
public String getValue(final Global global) {
return global.getClassName();
}
};
deleteGlobalButton = new ButtonCell(IconType.MINUS, ButtonType.DANGER, ButtonSize.SMALL);
final Column<Global, String> deleteGlobalColumn = new Column<Global, String>(deleteGlobalButton) {
@Override
public String getValue(final Global global) {
return translationService.getTranslation(GlobalsEditorConstants.GlobalsEditorViewImplRemove);
}
};
deleteGlobalColumn.setFieldUpdater((index, global, value) -> {
if (Window.confirm(translationService.format(GlobalsEditorConstants.GlobalsEditorViewImplPromptForRemovalOfGlobal, global.getAlias()))) {
dataProvider.getList().remove(index);
}
});
table.addColumn(aliasColumn, new TextHeader(translationService.getTranslation(GlobalsEditorConstants.GlobalsEditorViewImplAlias)));
table.addColumn(classNameColumn, new TextHeader(translationService.getTranslation(GlobalsEditorConstants.GlobalsEditorViewImplClassName)));
table.addColumn(deleteGlobalColumn, translationService.getTranslation(GlobalsEditorConstants.GlobalsEditorViewImplRemove));
// Link data
dataProvider.addDataDisplay(table);
dataProvider.setList(globals);
generatedLabel.setText(translationService.getTranslation(GlobalsEditorConstants.GlobalsEditorViewImplAutoGeneratedFile));
addGlobalButton.setText(translationService.getTranslation(GlobalsEditorConstants.GlobalsEditorViewImplAdd));
addGlobalButton.setIcon(IconType.PLUS);
}
use of org.drools.workbench.screens.globals.model.Global in project drools-wb by kiegroup.
the class GlobalsPersistence method unmarshal.
public GlobalsModel unmarshal(final String content) {
// De-serialize model
final List<Pair<String, String>> parsedGlobalsContent = GlobalsParser.parseGlobals(content);
final List<Global> globals = makeGlobals(parsedGlobalsContent);
final GlobalsModel model = new GlobalsModel();
model.setGlobals(globals);
// De-serialize Package name
final String packageName = PackageNameParser.parsePackageName(content);
model.setPackageName(packageName);
return model;
}
use of org.drools.workbench.screens.globals.model.Global in project drools-wb by kiegroup.
the class GlobalsPersistence method marshal.
public String marshal(final GlobalsModel model) {
final StringBuilder sb = new StringBuilder();
PackageNameWriter.write(sb, model);
for (Global global : model.getGlobals()) {
sb.append("global ").append(global.getClassName()).append(" ").append(global.getAlias()).append(";\n");
}
return sb.toString();
}
Aggregations