use of com.amalto.workbench.models.Line in project tmdm-studio-se by Talend.
the class FKFilterDialog method resetFilter.
private String resetFilter() {
List<Line> lines = new ArrayList<Line>();
TableItem[] items = viewer.getViewer().getTable().getItems();
if (items.length > 0) {
for (TableItem item : items) {
Line line = (Line) item.getData();
lines.add(line);
}
}
filter = FKFilterParser.getDeParseredFilter(lines);
return filter;
}
use of com.amalto.workbench.models.Line in project tmdm-studio-se by Talend.
the class SetupTransformerInputVariablesDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Group comp = new Group(parent, SWT.NONE);
comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
((GridLayout) parent.getLayout()).marginTop = 5;
((GridLayout) parent.getLayout()).marginLeft = 5;
((GridLayout) parent.getLayout()).marginRight = 5;
((GridLayout) parent.getLayout()).marginBottom = 5;
parent.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
comp.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
comp.setLayout(new GridLayout(1, false));
comp.setText(Messages.bind(Messages.SetupTransformerInputVariablesDialog_CompText, transformer.getName()));
// Get the input variable names
Set<String> inputVariables = new HashSet<String>();
for (WSTransformerProcessStep step : transformer.getProcessSteps()) {
for (WSTransformerVariablesMapping mapping : step.getInputMappings()) {
inputVariables.add(mapping.getPipelineVariable() == null ? TransformerMainPage.DEFAULT_VAR : mapping.getPipelineVariable());
}
}
ComplexTableViewerColumn[] columns = new ComplexTableViewerColumn[] { new // name
ComplexTableViewerColumn(// name
Messages.SetupTransformerInputVariablesDialog_InputVariables, // is Nillable ?
true, // Nill value//$NON-NLS-1$
"_DEFAULT_", // Nill display//$NON-NLS-1$
"_DEFAULT_", // Default Value//$NON-NLS-1$
"", // is Combo ?
ComplexTableViewerColumn.COMBO_STYLE, // Combo Values
inputVariables.toArray(new String[inputVariables.size()]), // Text Lines
0), new // name
ComplexTableViewerColumn(// name
Messages.SetupTransformerInputVariablesDialog_ContentType, // is Nillable ?
false, // Nill value//$NON-NLS-1$
"", // Nill display//$NON-NLS-1$
"", // Default Value//$NON-NLS-1$
"text/xml", // is Combo ?
ComplexTableViewerColumn.COMBO_STYLE, // Combo Values
EContentType.allTypes().toArray(new String[EContentType.allTypes().size()]), // Text Lines
0), new // name
ComplexTableViewerColumn(// name
Messages.SetupTransformerInputVariablesDialog_Value, // is Nillable ?
true, // Nill value//$NON-NLS-1$
"", // Nill display//$NON-NLS-1$
"", // Default Value//$NON-NLS-1$
"", // is Combo ?
ComplexTableViewerColumn.TEXT_STYLE, // Combo Values
null, // Text Lines
10) };
objectViewer = new ComplexTableViewerR(Arrays.asList(columns), toolkit, comp, page.getSite());
objectViewer.create();
Table table = objectViewer.getViewer().getTable();
table.getColumns()[2].setWidth(500);
// GridData gd=(GridData)objectViewer.getTxtLists().get(0).getLayoutData();
// gd.minimumHeight=200;
// gd.minimumWidth=300;
table.setHeaderVisible(true);
table.setLinesVisible(true);
// ((GridData)table.getLayoutData()).minimumWidth = 600;
if (page.getCacheList() != null) {
objectViewer.getViewer().setInput(page.getCacheList());
} else {
List<Line> list = new ArrayList<Line>();
objectViewer.getViewer().setInput(list);
}
final CCombo combo = (CCombo) objectViewer.getColumns().get(1).getControl();
combo.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
if (combo.getText().equals(EInputTemplate.APPLICATION_ITEMPK.getName())) {
Text t = (Text) objectViewer.getColumns().get(2).getControl();
t.setText(EInputTemplate.APPLICATION_ITEMPK.getContent());
}
}
});
return comp;
}
use of com.amalto.workbench.models.Line in project tmdm-studio-se by Talend.
the class ValidationRuleDialog method parseRules.
private List<Line> parseRules() {
List<Line> lines = new ArrayList<Line>();
// $NON-NLS-1$//$NON-NLS-2$
pattern = pattern.replaceAll("\\r\\n|\\n", "");
// $NON-NLS-1$
String context = "";
// $NON-NLS-1$
String type = "";
// $NON-NLS-1$
String express = "";
// $NON-NLS-1$
String msg = "";
Element e = null;
try {
e = Util.parse(pattern).getDocumentElement();
} catch (Exception e1) {
log.error(e1.getMessage(), e1);
}
if (e.getAttributes().getNamedItem("name") != null) {
// $NON-NLS-1$
// $NON-NLS-1$
name = e.getAttributes().getNamedItem("name").getTextContent();
}
// $NON-NLS-1$//$NON-NLS-2$
text.setText("Product Type".equals(name) ? "" : name);
ckName = name;
// $NON-NLS-1$
NodeList rulelist = e.getElementsByTagName("rule");
for (int i = 0; i < rulelist.getLength(); i++) {
Node r = rulelist.item(i);
// $NON-NLS-1$
context = r.getAttributes().getNamedItem("context").getTextContent();
for (int j = 0; j < r.getChildNodes().getLength(); j++) {
if (r.getChildNodes().item(j).getNodeType() == Node.ELEMENT_NODE) {
type = r.getChildNodes().item(j).getNodeName();
// $NON-NLS-1$
express = r.getChildNodes().item(j).getAttributes().getNamedItem("test").getTextContent();
msg = r.getChildNodes().item(j).getTextContent();
break;
}
}
Line l = new Line(columns, new String[] { type, context, express, msg });
lines.add(l);
}
return lines;
}
use of com.amalto.workbench.models.Line in project tmdm-studio-se by Talend.
the class ValidationRuleDialog method getValidationRules.
private String getValidationRules() {
TableItem[] items = viewer.getViewer().getTable().getItems();
// List<String> rules=new ArrayList<String>();
StringBuffer sb = new StringBuffer();
// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
sb = sb.append("<pattern " + "name=\"" + text.getText() + "\" >\n");
if (items.length > 0) {
for (TableItem item : items) {
Line line = (Line) item.getData();
// $NON-NLS-1$
sb = sb.append("<rule context=\"");
String type = line.keyValues.get(0).value;
String context = line.keyValues.get(1).value;
String express = line.keyValues.get(2).value;
// $NON-NLS-1$//$NON-NLS-2$
express = express.replaceAll("<", "<");
// $NON-NLS-1$//$NON-NLS-2$
express = express.replaceAll("\"", """);
// $NON-NLS-1$//$NON-NLS-2$
express = express.replaceAll("\'", "'");
String msg = line.keyValues.get(3).value;
if (conceptName != null) {
if (context.equals(conceptName)) {
// $NON-NLS-1$
context = context.replace(conceptName, "/");
} else if (context.startsWith(conceptName + "/")) {
// $NON-NLS-1$
// $NON-NLS-1$
context = context.substring((conceptName + "/").length());
}
}
// $NON-NLS-1$
sb = sb.append(context).append("\">");
// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
sb = sb.append("<" + type.toLowerCase() + " test=\"" + express + "\">");
// $NON-NLS-1$//$NON-NLS-2$
sb = sb.append("<![CDATA[" + msg + "]]>");
// $NON-NLS-1$//$NON-NLS-2$
sb = sb.append("</" + type.toLowerCase() + ">");
// $NON-NLS-1$
sb = sb.append("</rule>\n");
}
// rules.add(sb.toString());
}
// $NON-NLS-1$
sb = sb.append("</pattern>\n");
return pattern = sb.toString();
}
use of com.amalto.workbench.models.Line in project tmdm-studio-se by Talend.
the class ComplexTableViewer method createRightmostPortion.
protected void createRightmostPortion(Composite parent) {
// $NON-NLS-1$
addButton = toolkit.createButton(parent, "", SWT.PUSH | SWT.CENTER);
addButton.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false, 1, 1));
addButton.setImage(ImageCache.getCreatedImage(EImage.ADD_OBJ.getPath()));
addButton.setToolTipText(Messages.ComplexTableViewer_Add);
addButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
@SuppressWarnings("unchecked")
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
// $NON-NLS-1$
String uniqueVal = "";
// $NON-NLS-1$
String keyVal = "";
// Make sure texts are not nill (empty) where not authorized
for (ComplexTableViewerColumn column : columns) {
// $NON-NLS-1$
String text = "";
if (column.isCombo()) {
text = ((CCombo) column.getControl()).getText();
} else if (column.isText()) {
text = ((Text) column.getControl()).getText();
} else if (column.isXPATH()) {
Control text1 = ((Composite) column.getControl()).getChildren()[0];
if (text1 instanceof Text) {
text = ((Text) text1).getText();
}
}
if (text.length() == 0) {
if (column.isNillable()) {
text = column.getNillValue();
if (column.isCombo()) {
((CCombo) column.getControl()).setText(text);
} else {
((Text) column.getControl()).setText(text);
}
} else {
MessageDialog.openError(ComplexTableViewer.this.getViewer().getControl().getShell(), Messages.ComplexTableViewer_InputError, Messages.ComplexTableViewer_ErrorMsg + column.getName() + Messages.ComplexTableViewer_ErrorMsgA);
return;
}
}
if (keyColumns != null && Arrays.asList(keyColumns).indexOf(column) >= 0) {
keyVal += text;
}
// $NON-NLS-1$
uniqueVal += "." + text;
}
// check uniqueness by concatenating all the values
List<Line> list = (List<Line>) getViewer().getInput();
for (Line line : list) {
// $NON-NLS-1$
String thisLineVal = "";
for (KeyValue keyvalue : line.keyValues) {
// $NON-NLS-1$
thisLineVal += "." + keyvalue.value;
}
if (thisLineVal.equals(uniqueVal) || (keyVal.length() > 0 && thisLineVal.indexOf(keyVal) >= 0)) {
MessageDialog.openInformation(null, ERROR_ITEMALREADYEXISTS_TITLE, ERROR_ITEMALREADYEXISTS_CONTENT);
return;
}
}
// Update the model
Line line = new Line(columns.toArray(new ComplexTableViewerColumn[columns.size()]), getTextValues());
list.add(line);
// update the instances viewer
markDirty();
viewer.setSelection(null);
viewer.refresh();
viewer.getTable().select(viewer.getTable().getItemCount() - 1);
}
});
}
Aggregations