use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.
the class TextFileInputDialogTest method testMinimalWidth_PDI_14253.
@Test
public void testMinimalWidth_PDI_14253() throws Exception {
final String virtualFile = "ram://pdi-14253.txt";
KettleVFS.getFileObject(virtualFile).createFile();
final String content = "r1c1, r1c2\nr2c1 , r2c2 ";
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bos.write(content.getBytes());
OutputStream os = KettleVFS.getFileObject(virtualFile).getContent().getOutputStream();
IOUtils.copy(new ByteArrayInputStream(bos.toByteArray()), os);
os.close();
TextFileInputMeta meta = new TextFileInputMeta();
meta.content.lineWrapped = false;
meta.inputFields = new BaseFileField[] { new BaseFileField("col1", -1, -1), new BaseFileField("col2", -1, -1) };
meta.content.fileCompression = "None";
meta.content.fileType = "CSV";
meta.content.header = false;
meta.content.nrHeaderLines = -1;
meta.content.footer = false;
meta.content.nrFooterLines = -1;
TextFileInputData data = new TextFileInputData();
data.files = new FileInputList();
data.files.addFile(KettleVFS.getFileObject(virtualFile));
data.outputRowMeta = new RowMeta();
data.outputRowMeta.addValueMeta(new ValueMetaString("col1"));
data.outputRowMeta.addValueMeta(new ValueMetaString("col2"));
data.dataErrorLineHandler = mock(FileErrorHandler.class);
data.fileFormatType = TextFileInputMeta.FILE_FORMAT_UNIX;
data.separator = ",";
data.filterProcessor = new TextFileFilterProcessor(new TextFileFilter[0], new Variables() {
});
data.filePlayList = new FilePlayListAll();
TextFileInputDialog dialog = new TextFileInputDialog(mock(Shell.class), meta, mock(TransMeta.class), "TFIMinimalWidthTest");
TableView tv = mock(TableView.class);
when(tv.nrNonEmpty()).thenReturn(0);
// click the Minimal width button
dialog.setMinimalWidth(tv);
RowSet output = new BlockingRowSet(5);
TextFileInput input = StepMockUtil.getStep(TextFileInput.class, TextFileInputMeta.class, "test");
input.setOutputRowSets(Collections.singletonList(output));
while (input.processRow(meta, data)) {
// wait until the step completes executing
}
Object[] row1 = output.getRowImmediate();
assertRow(row1, "r1c1", "r1c2");
Object[] row2 = output.getRowImmediate();
assertRow(row2, "r2c1", "r2c2");
KettleVFS.getFileObject(virtualFile).delete();
}
use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.
the class DimensionTableDialog method addAttributesTab.
private void addAttributesTab() {
wTablesTab = new CTabItem(wTabFolder, SWT.NONE);
wTablesTab.setText(BaseMessages.getString(PKG, "DimensionTableDialog.AttributesTab.Label"));
FormLayout paramLayout = new FormLayout();
paramLayout.marginWidth = Const.MARGIN;
paramLayout.marginHeight = Const.MARGIN;
Composite wTablesComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wTablesComp);
wTablesComp.setLayout(paramLayout);
Button wAddDefaultFields = new Button(wTablesComp, SWT.PUSH);
wAddDefaultFields.setText(BaseMessages.getString(PKG, "DimensionTableDialog.AddDefaultFieldsButton.Label"));
BaseStepDialog.positionBottomButtons(wTablesComp, new Button[] { wAddDefaultFields }, margin, null);
wAddDefaultFields.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
addDefaultAttributes();
}
});
Label wlAtrributes = new Label(wTablesComp, SWT.RIGHT);
wlAtrributes.setText(BaseMessages.getString(PKG, "DimensionTableDialog.Attributes.Label"));
props.setLook(wlAtrributes);
FormData fdlAttributes = new FormData();
fdlAttributes.left = new FormAttachment(0, 0);
fdlAttributes.top = new FormAttachment(0, 0);
wlAtrributes.setLayoutData(fdlAttributes);
final int FieldsRows = logicalTable.getLogicalColumns().size();
List<DatabaseMeta> sharedDatabases = SharedDatabaseUtil.loadSharedDatabases();
String[] databaseNames = SharedDatabaseUtil.getSortedDatabaseNames(sharedDatabases);
// data types
//
String[] dataTypes = new String[DataType.values().length];
for (int i = 0; i < dataTypes.length; i++) {
dataTypes[i] = DataType.values()[i].name();
}
// field types
//
String[] attributeTypes = new String[AttributeType.values().length];
for (int i = 0; i < AttributeType.values().length; i++) {
attributeTypes[i] = AttributeType.values()[i].name();
}
// name, description, field type, physical column name, data type, length, precision, source db, source table, source column, conversion remarks
//
ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "DimensionTableDialog.ColumnInfo.Name.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "DimensionTableDialog.ColumnInfo.Description.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "DimensionTableDialog.ColumnInfo.FieldType.Label"), ColumnInfo.COLUMN_TYPE_CCOMBO, attributeTypes), new ColumnInfo(BaseMessages.getString(PKG, "DimensionTableDialog.ColumnInfo.PhysicalName.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "DimensionTableDialog.ColumnInfo.DataType.Label"), ColumnInfo.COLUMN_TYPE_CCOMBO, dataTypes), new ColumnInfo(BaseMessages.getString(PKG, "DimensionTableDialog.ColumnInfo.DataLength.Label"), ColumnInfo.COLUMN_TYPE_TEXT, true), new ColumnInfo(BaseMessages.getString(PKG, "DimensionTableDialog.ColumnInfo.DataPrecision.Label"), ColumnInfo.COLUMN_TYPE_TEXT, true), new ColumnInfo(BaseMessages.getString(PKG, "DimensionTableDialog.ColumnInfo.SourceDatabase.Label"), ColumnInfo.COLUMN_TYPE_CCOMBO, databaseNames), new ColumnInfo(BaseMessages.getString(PKG, "DimensionTableDialog.ColumnInfo.SourceTable.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "DimensionTableDialog.ColumnInfo.SourceColumn.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "DimensionTableDialog.ColumnInfo.ConversionLogicRemarks.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false) };
wAttributes = new TableView(new Variables(), wTablesComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, null, props);
FormData fdTables = new FormData();
fdTables.left = new FormAttachment(0, 0);
fdTables.top = new FormAttachment(wlAtrributes, margin);
fdTables.right = new FormAttachment(100, 0);
fdTables.bottom = new FormAttachment(wAddDefaultFields, -margin * 2);
wAttributes.setLayoutData(fdTables);
FormData fdTablesComp = new FormData();
fdTablesComp.left = new FormAttachment(0, 0);
fdTablesComp.top = new FormAttachment(0, 0);
fdTablesComp.right = new FormAttachment(100, 0);
fdTablesComp.bottom = new FormAttachment(100, 0);
wTablesComp.setLayoutData(fdTablesComp);
wTablesComp.layout();
wTablesTab.setControl(wTablesComp);
}
use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.
the class StarModelDialog method addDimensionsTab.
private void addDimensionsTab() {
wDimensionsTab = new CTabItem(wTabFolder, SWT.NONE);
wDimensionsTab.setText(BaseMessages.getString(PKG, "StarModelDialog.DimensionsTab.Label"));
FormLayout dimensionsLayout = new FormLayout();
dimensionsLayout.marginWidth = Const.MARGIN;
dimensionsLayout.marginHeight = Const.MARGIN;
Composite wDimensionsComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wDimensionsComp);
wDimensionsComp.setLayout(dimensionsLayout);
Label wlTables = new Label(wDimensionsComp, SWT.RIGHT);
wlTables.setText(BaseMessages.getString(PKG, "StarModelDialog.Tables.Label"));
props.setLook(wlTables);
FormData fdlAttributes = new FormData();
fdlAttributes.left = new FormAttachment(0, 0);
fdlAttributes.top = new FormAttachment(0, 0);
wlTables.setLayoutData(fdlAttributes);
// A few buttons to edit the list
//
Button newTableButton = new Button(wDimensionsComp, SWT.PUSH);
newTableButton.setText(BaseMessages.getString(PKG, "StarModelDialog.Button.NewTable"));
newTableButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (newTable(shell, logicalModel)) {
refreshTablesList();
}
}
});
Button copyTableButton = new Button(wDimensionsComp, SWT.PUSH);
copyTableButton.setText(BaseMessages.getString(PKG, "StarModelDialog.Button.CopyTable"));
copyTableButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (wTablesList.getSelectionIndex() < 0)
return;
TableItem item = wTablesList.table.getSelection()[0];
String tableName = item.getText(1);
if (copyTable(shell, logicalModel, tableName)) {
refreshTablesList();
}
}
});
Button editTableButton = new Button(wDimensionsComp, SWT.PUSH);
editTableButton.setText(BaseMessages.getString(PKG, "StarModelDialog.Button.EditTable"));
editTableButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (wTablesList.getSelectionIndex() < 0)
return;
TableItem item = wTablesList.table.getSelection()[0];
String tableName = item.getText(1);
if (editTable(tableName)) {
refreshTablesList();
}
}
});
Button delTableButton = new Button(wDimensionsComp, SWT.PUSH);
delTableButton.setText(BaseMessages.getString(PKG, "StarModelDialog.Button.DeleteTable"));
delTableButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (wTablesList.getSelectionIndex() < 0)
return;
TableItem item = wTablesList.table.getSelection()[0];
String tableName = item.getText(1);
if (deleteTable(tableName)) {
refreshTablesList();
}
}
});
BaseStepDialog.positionBottomButtons(wDimensionsComp, new Button[] { newTableButton, copyTableButton, editTableButton, delTableButton }, margin, null);
final int FieldsRows = logicalModel.getLogicalTables().size();
List<DatabaseMeta> sharedDatabases = new ArrayList<DatabaseMeta>();
try {
SharedObjects sharedObjects = new SharedObjects();
for (SharedObjectInterface sharedObject : sharedObjects.getObjectsMap().values()) {
if (sharedObject instanceof DatabaseMeta) {
sharedDatabases.add((DatabaseMeta) sharedObject);
}
}
} catch (Exception e) {
LogChannel.GENERAL.logError("Unable to load shared objects", e);
}
// The dimensions and fact of the model
//
ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "StarModelDialog.ColumnInfo.Name.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "StarModelDialog.ColumnInfo.Description.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "StarModelDialog.ColumnInfo.TableType.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false, true) };
wTablesList = new TableView(new Variables(), wDimensionsComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, null, props);
FormData fdTablesList = new FormData();
fdTablesList.left = new FormAttachment(0, 0);
fdTablesList.top = new FormAttachment(wlTables, margin);
fdTablesList.right = new FormAttachment(100, 0);
fdTablesList.bottom = new FormAttachment(newTableButton, -margin);
wTablesList.setLayoutData(fdTablesList);
wTablesList.setReadonly(true);
wTablesList.table.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
if (wTablesList.getSelectionIndex() < 0)
return;
TableItem item = wTablesList.table.getSelection()[0];
String tableName = item.getText(1);
if (editTable(tableName)) {
refreshTablesList();
// refreshRelationshipsList();
}
}
});
FormData fdTablesComp = new FormData();
fdTablesComp.left = new FormAttachment(0, 0);
fdTablesComp.top = new FormAttachment(0, 0);
fdTablesComp.right = new FormAttachment(100, 0);
fdTablesComp.bottom = new FormAttachment(100, 0);
wDimensionsComp.setLayoutData(fdTablesComp);
wDimensionsComp.layout();
wDimensionsTab.setControl(wDimensionsComp);
}
use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.
the class StarModelDialog method addFactTab.
private void addFactTab() {
wFactTab = new CTabItem(wTabFolder, SWT.NONE);
wFactTab.setText(BaseMessages.getString(PKG, "StarModelDialog.FactTab.Label"));
FormLayout factLayout = new FormLayout();
factLayout.marginWidth = Const.MARGIN;
factLayout.marginHeight = Const.MARGIN;
Composite wFactComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wFactComp);
wFactComp.setLayout(factLayout);
Button wAddDimensionKeys = new Button(wFactComp, SWT.PUSH);
wAddDimensionKeys.setText(BaseMessages.getString(PKG, "StarModelDialog.AddDimensionKeys.Label"));
BaseStepDialog.positionBottomButtons(wFactComp, new Button[] { wAddDimensionKeys }, margin, null);
wAddDimensionKeys.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
addDimensionKeys();
}
});
// Table name:
//
Label wlFactTableName = new Label(wFactComp, SWT.RIGHT);
wlFactTableName.setText(BaseMessages.getString(PKG, "StarModelDialog.FactTableName.Label"));
props.setLook(wlFactTableName);
FormData fdlFactTableName = new FormData();
fdlFactTableName.left = new FormAttachment(0, 0);
fdlFactTableName.right = new FormAttachment(middle, -margin);
fdlFactTableName.top = new FormAttachment(0, margin);
wlFactTableName.setLayoutData(fdlFactTableName);
wFactTableName = new Text(wFactComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wFactTableName);
FormData fdFactTableName = new FormData();
fdFactTableName.left = new FormAttachment(middle, 0);
fdFactTableName.top = new FormAttachment(0, margin);
fdFactTableName.right = new FormAttachment(100, 0);
wFactTableName.setLayoutData(fdFactTableName);
Control lastControl = wFactTableName;
// Table description
//
Label wlFactTableDescription = new Label(wFactComp, SWT.RIGHT);
wlFactTableDescription.setText(BaseMessages.getString(PKG, "StarModelDialog.FactTableDescription.Label"));
props.setLook(wlFactTableDescription);
FormData fdlFactTableDescription = new FormData();
fdlFactTableDescription.left = new FormAttachment(0, 0);
fdlFactTableDescription.right = new FormAttachment(middle, -margin);
fdlFactTableDescription.top = new FormAttachment(lastControl, margin);
wlFactTableDescription.setLayoutData(fdlFactTableDescription);
wFactTableDescription = new Text(wFactComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wFactTableDescription);
FormData fdFactTableDescription = new FormData();
fdFactTableDescription.left = new FormAttachment(middle, 0);
fdFactTableDescription.top = new FormAttachment(lastControl, margin);
fdFactTableDescription.right = new FormAttachment(100, 0);
wFactTableDescription.setLayoutData(fdFactTableDescription);
lastControl = wFactTableDescription;
// Table description
//
Label wlPhysicalFactName = new Label(wFactComp, SWT.RIGHT);
wlPhysicalFactName.setText(BaseMessages.getString(PKG, "StarModelDialog.PhysicalFactName.Label"));
props.setLook(wlPhysicalFactName);
FormData fdlPhysicalName = new FormData();
fdlPhysicalName.left = new FormAttachment(0, 0);
fdlPhysicalName.right = new FormAttachment(middle, -margin);
fdlPhysicalName.top = new FormAttachment(lastControl, margin);
wlPhysicalFactName.setLayoutData(fdlPhysicalName);
wPhysicalFactName = new Text(wFactComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wPhysicalFactName);
FormData fdPhysicalFactName = new FormData();
fdPhysicalFactName.left = new FormAttachment(middle, 0);
fdPhysicalFactName.top = new FormAttachment(lastControl, margin);
fdPhysicalFactName.right = new FormAttachment(100, 0);
wPhysicalFactName.setLayoutData(fdPhysicalFactName);
lastControl = wPhysicalFactName;
Label wlAtrributes = new Label(wFactComp, SWT.RIGHT);
wlAtrributes.setText(BaseMessages.getString(PKG, "DimensionTableDialog.Attributes.Label"));
props.setLook(wlAtrributes);
FormData fdlAttributes = new FormData();
fdlAttributes.left = new FormAttachment(0, 0);
fdlAttributes.top = new FormAttachment(lastControl, margin);
wlAtrributes.setLayoutData(fdlAttributes);
final int FieldsRows = factTable.getLogicalColumns().size();
List<DatabaseMeta> sharedDatabases = SharedDatabaseUtil.loadSharedDatabases();
String[] databaseNames = SharedDatabaseUtil.getSortedDatabaseNames(sharedDatabases);
// data types
//
String[] dataTypes = new String[DataType.values().length];
for (int i = 0; i < dataTypes.length; i++) {
dataTypes[i] = DataType.values()[i].name();
}
// field types
//
String[] attributeTypes = new String[AttributeType.values().length];
for (int i = 0; i < AttributeType.values().length; i++) {
attributeTypes[i] = AttributeType.values()[i].name();
}
String[] dimensionNames = getDimensionTableNames();
// name, description, field type, physical column name, data type, length, precision, source db, source table, source column, conversion remarks
//
factColumns = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "StarModelDialog.ColumnInfo.Name.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "StarModelDialog.ColumnInfo.Description.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "StarModelDialog.ColumnInfo.FieldType.Label"), ColumnInfo.COLUMN_TYPE_CCOMBO, attributeTypes), new ColumnInfo(BaseMessages.getString(PKG, "StarModelDialog.ColumnInfo.PhysicalName.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "StarModelDialog.ColumnInfo.DataType.Label"), ColumnInfo.COLUMN_TYPE_CCOMBO, dataTypes), new ColumnInfo(BaseMessages.getString(PKG, "StarModelDialog.ColumnInfo.Dimension.Label"), ColumnInfo.COLUMN_TYPE_CCOMBO, dimensionNames), new ColumnInfo(BaseMessages.getString(PKG, "StarModelDialog.ColumnInfo.DataLength.Label"), ColumnInfo.COLUMN_TYPE_TEXT, true), new ColumnInfo(BaseMessages.getString(PKG, "StarModelDialog.ColumnInfo.DataPrecision.Label"), ColumnInfo.COLUMN_TYPE_TEXT, true), new ColumnInfo(BaseMessages.getString(PKG, "StarModelDialog.ColumnInfo.SourceDatabase.Label"), ColumnInfo.COLUMN_TYPE_CCOMBO, databaseNames), new ColumnInfo(BaseMessages.getString(PKG, "StarModelDialog.ColumnInfo.SourceTable.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "StarModelDialog.ColumnInfo.SourceColumn.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "StarModelDialog.ColumnInfo.ConversionLogicRemarks.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false) };
wFactAttributes = new TableView(new Variables(), wFactComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, factColumns, FieldsRows, null, props);
FormData fdFactAttributes = new FormData();
fdFactAttributes.left = new FormAttachment(0, 0);
fdFactAttributes.top = new FormAttachment(wlAtrributes, margin);
fdFactAttributes.right = new FormAttachment(100, 0);
fdFactAttributes.bottom = new FormAttachment(wAddDimensionKeys, -margin * 2);
wFactAttributes.setLayoutData(fdFactAttributes);
FormData fdFactComp = new FormData();
fdFactComp.left = new FormAttachment(0, 0);
fdFactComp.top = new FormAttachment(0, 0);
fdFactComp.right = new FormAttachment(100, 0);
fdFactComp.bottom = new FormAttachment(100, 0);
wFactComp.setLayoutData(fdFactComp);
wFactComp.layout();
wFactTab.setControl(wFactComp);
}
use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.
the class StarModelerPerspective method addModelsGroupToDomainTab.
private Control addModelsGroupToDomainTab(final StarDomain starDomain, final XulTabAndPanel tabAndPanel, Composite parentComposite) {
PropsUI props = PropsUI.getInstance();
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Add a group for the logical stars
//
final Group logicalGroup = new Group(parentComposite, SWT.SHADOW_NONE);
props.setLook(logicalGroup);
logicalGroup.setText(BaseMessages.getString(PKG, "StarModelerPerspective.LogicalGroup.Label"));
FormLayout groupLayout = new FormLayout();
groupLayout.marginLeft = 10;
groupLayout.marginRight = 10;
groupLayout.marginTop = 10;
groupLayout.marginBottom = 10;
groupLayout.spacing = margin;
logicalGroup.setLayout(groupLayout);
FormData fdLogicalGroup = new FormData();
fdLogicalGroup.top = new FormAttachment(0, 0);
fdLogicalGroup.left = new FormAttachment(0, 0);
fdLogicalGroup.right = new FormAttachment(100, 0);
logicalGroup.setLayoutData(fdLogicalGroup);
// Add a line to edit the name of the logical domain
//
Label nameLabel = new Label(logicalGroup, SWT.RIGHT);
props.setLook(nameLabel);
nameLabel.setText(BaseMessages.getString(PKG, "StarModelerPerspective.DomainName.Label"));
FormData fdNameLabel = new FormData();
fdNameLabel.left = new FormAttachment(0, 0);
fdNameLabel.right = new FormAttachment(middle, 0);
fdNameLabel.top = new FormAttachment(0, 0);
nameLabel.setLayoutData(fdNameLabel);
final Text nameText = new Text(logicalGroup, SWT.BORDER | SWT.SINGLE);
props.setLook(nameText);
nameText.setText(Const.NVL(starDomain.getDomain().getName(defaultLocale), ""));
FormData fdNameText = new FormData();
fdNameText.left = new FormAttachment(middle, margin);
fdNameText.right = new FormAttachment(100, 0);
fdNameText.top = new FormAttachment(0, 0);
nameText.setLayoutData(fdNameText);
nameText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
starDomain.getDomain().setName(new LocalizedString(defaultLocale, nameText.getText()));
setNameForTab(tabAndPanel.tab, starDomain.getDomain().getName(defaultLocale));
}
});
Control lastControl = nameText;
// Add a line to edit the name of the logical domain
//
Label descriptionLabel = new Label(logicalGroup, SWT.RIGHT);
props.setLook(descriptionLabel);
descriptionLabel.setText(BaseMessages.getString(PKG, "StarModelerPerspective.DomainDescription.Label"));
FormData fdDescriptionLabel = new FormData();
fdDescriptionLabel.left = new FormAttachment(0, 0);
fdDescriptionLabel.right = new FormAttachment(middle, 0);
fdDescriptionLabel.top = new FormAttachment(lastControl, margin);
descriptionLabel.setLayoutData(fdDescriptionLabel);
final Text descriptionText = new Text(logicalGroup, SWT.BORDER | SWT.SINGLE);
props.setLook(descriptionText);
descriptionText.setText(Const.NVL(starDomain.getDomain().getDescription(defaultLocale), ""));
FormData fdDescriptionText = new FormData();
fdDescriptionText.left = new FormAttachment(middle, 5);
fdDescriptionText.right = new FormAttachment(100, 0);
fdDescriptionText.top = new FormAttachment(lastControl, margin);
descriptionText.setLayoutData(fdDescriptionText);
descriptionText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
starDomain.getDomain().setDescription(new LocalizedString(defaultLocale, descriptionText.getText()));
}
});
lastControl = descriptionText;
// Then we'll add a table view of all the models and their descriptions
//
Label modelsLabel = new Label(logicalGroup, SWT.RIGHT);
props.setLook(modelsLabel);
modelsLabel.setText(BaseMessages.getString(PKG, "StarModelerPerspective.DomainModels.Label"));
FormData fdModelsLabel = new FormData();
fdModelsLabel.left = new FormAttachment(0, 0);
fdModelsLabel.right = new FormAttachment(middle, 0);
fdModelsLabel.top = new FormAttachment(lastControl, margin);
modelsLabel.setLayoutData(fdModelsLabel);
ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "StarModelerPerspective.ModelName.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "StarModelerPerspective.ModelDescription.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false, true) };
final TableView modelsList = new TableView(new Variables(), logicalGroup, SWT.BORDER, colinf, 1, null, props);
modelsList.setReadonly(true);
modelsList.table.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
if (modelsList.getSelectionIndex() < 0)
return;
TableItem item = modelsList.table.getSelection()[0];
String name = item.getText(1);
if (editModel(logicalGroup.getShell(), starDomain, defaultLocale, name)) {
refreshModelsList(starDomain, modelsList);
}
}
});
refreshModelsList(starDomain, modelsList);
FormData fdModelsList = new FormData();
fdModelsList.top = new FormAttachment(lastControl, margin);
fdModelsList.bottom = new FormAttachment(lastControl, 250);
fdModelsList.left = new FormAttachment(middle, margin);
fdModelsList.right = new FormAttachment(100, 0);
modelsList.setLayoutData(fdModelsList);
lastControl = modelsList;
// A few buttons to edit the list
//
Button newModelButton = new Button(logicalGroup, SWT.PUSH);
newModelButton.setText(BaseMessages.getString(PKG, "StarModelerPerspective.Button.NewModel"));
FormData fdNewModelButton = new FormData();
fdNewModelButton.top = new FormAttachment(lastControl, margin);
fdNewModelButton.left = new FormAttachment(middle, margin);
newModelButton.setLayoutData(fdNewModelButton);
newModelButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (newModel(logicalGroup.getShell(), starDomain)) {
refreshModelsList(starDomain, modelsList);
}
}
});
Button editModelButton = new Button(logicalGroup, SWT.PUSH);
editModelButton.setText(BaseMessages.getString(PKG, "StarModelerPerspective.Button.EditModel"));
FormData fdEditModelButton = new FormData();
fdEditModelButton.top = new FormAttachment(lastControl, margin);
fdEditModelButton.left = new FormAttachment(newModelButton, margin);
editModelButton.setLayoutData(fdEditModelButton);
editModelButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (modelsList.getSelectionIndex() < 0)
return;
TableItem item = modelsList.table.getSelection()[0];
String name = item.getText(1);
if (editModel(logicalGroup.getShell(), starDomain, defaultLocale, name)) {
refreshModelsList(starDomain, modelsList);
}
}
});
Button delModelButton = new Button(logicalGroup, SWT.PUSH);
delModelButton.setText(BaseMessages.getString(PKG, "StarModelerPerspective.Button.DeleteModel"));
FormData fdDelModelButton = new FormData();
fdDelModelButton.top = new FormAttachment(lastControl, margin);
fdDelModelButton.left = new FormAttachment(editModelButton, margin);
delModelButton.setLayoutData(fdDelModelButton);
delModelButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (modelsList.getSelectionIndex() < 0)
return;
TableItem item = modelsList.table.getSelection()[0];
String name = item.getText(1);
if (deleteModel(logicalGroup.getShell(), starDomain, defaultLocale, name)) {
refreshModelsList(starDomain, modelsList);
}
}
});
return logicalGroup;
}
Aggregations