use of org.pentaho.metadata.model.concept.types.LocalizedString in project pentaho-kettle by pentaho.
the class StarModelDialog method copyTable.
protected boolean copyTable(Shell shell, LogicalModel logicalModel, String tableName) {
LogicalTable originalTable = findLogicalTable(tableName);
if (originalTable != null) {
// Copy
//
LogicalTable logicalTable = new LogicalTable();
logicalTable.setId(UUID.randomUUID().toString());
logicalTable.setName(new LocalizedString(locale, ConceptUtil.getName(originalTable, locale) + " (Copy)"));
logicalTable.setDescription(new LocalizedString(locale, ConceptUtil.getDescription(originalTable, locale) + " (Copy)"));
logicalTable.setProperty(DefaultIDs.LOGICAL_TABLE_PHYSICAL_TABLE_NAME, originalTable.getProperty(DefaultIDs.LOGICAL_TABLE_PHYSICAL_TABLE_NAME));
logicalTable.setProperty(DefaultPropertyID.TABLE_TYPE.getId(), originalTable.getProperty(DefaultPropertyID.TABLE_TYPE.getId()));
for (LogicalColumn column : originalTable.getLogicalColumns()) {
logicalTable.getLogicalColumns().add((LogicalColumn) column.clone());
}
DimensionTableDialog dialog = new DimensionTableDialog(shell, logicalTable, locale);
if (dialog.open() != null) {
logicalModel.addLogicalTable(logicalTable);
return true;
}
}
return false;
}
use of org.pentaho.metadata.model.concept.types.LocalizedString in project pentaho-kettle by pentaho.
the class StarModelerPerspective method newSharedDimension.
/**
* Create a new shared dimension in the domain
*
* @param domain the domain to create the new model in
*/
private boolean newSharedDimension(Shell shell, StarDomain starDomain) {
LogicalTable dimensionTable = new LogicalTable();
dimensionTable.setName(new LocalizedString(defaultLocale, "Shared dimension"));
DimensionTableDialog dialog = new DimensionTableDialog(shell, dimensionTable, defaultLocale);
if (dialog.open() != null) {
starDomain.getSharedDimensions().add(dimensionTable);
starDomain.setChanged(true);
return true;
}
return false;
}
use of org.pentaho.metadata.model.concept.types.LocalizedString 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;
}
use of org.pentaho.metadata.model.concept.types.LocalizedString in project pentaho-kettle by pentaho.
the class StarModelerPerspective method newModel.
/**
* Create a new model in the domain
*
* @param domain the domain to create the new model in
*/
private boolean newModel(Shell shell, StarDomain starDomain) {
LogicalModel model = new LogicalModel();
model.setName(new LocalizedString(defaultLocale, "Model"));
StarModelDialog dialog = new StarModelDialog(shell, model, defaultLocale);
if (dialog.open() != null) {
starDomain.getDomain().getLogicalModels().add(model);
starDomain.setChanged(true);
return true;
}
return false;
}
use of org.pentaho.metadata.model.concept.types.LocalizedString in project pentaho-kettle by pentaho.
the class MetadataGenerator method extractId.
private String extractId(Concept item) {
LocalizedString localizedName = item.getName();
Set<String> locales = localizedName.getLocales();
if (locales.isEmpty())
return "";
// Just grab the first locale we come across
// This should normally only one for the star modeler
//
String locale = locales.iterator().next();
String id = localizedName.getLocalizedString(locale);
id = id.toUpperCase().replace(" ", "_");
return id;
}
Aggregations