use of org.eclipse.jface.viewers.IStructuredSelection in project tdi-studio-se by Talend.
the class UIManager method moveRecord.
public void moveRecord(TreeViewer schemaTreeViewer, boolean left) {
if (schemaTreeViewer == null) {
return;
}
ISelection selection = schemaTreeViewer.getSelection();
if (selection instanceof IStructuredSelection) {
Object element = ((IStructuredSelection) selection).getFirstElement();
if (element instanceof SchemasKeyData) {
SchemasKeyData data = (SchemasKeyData) element;
SchemasKeyData parent = data.getParent();
if (left) {
SchemasKeyData grandfather = parent.getParent();
if (grandfather != null) {
// not in root.
List<SchemasKeyData> children = grandfather.getChildren();
int index = -1;
for (int i = 0; i < children.size(); i++) {
if (children.get(i) == parent) {
index = i;
break;
}
}
if (index > -1) {
int index2 = index + 1;
if (index2 > children.size()) {
grandfather.addChild(data);
} else {
grandfather.addChild(index2, data);
}
}
}
} else {
SchemasKeyData sibling = null;
for (SchemasKeyData skd : parent.getChildren()) {
if (skd == data) {
break;
} else {
sibling = skd;
}
}
if (sibling != null) {
sibling.addChild(data);
}
}
schemaTreeViewer.refresh();
}
}
}
use of org.eclipse.jface.viewers.IStructuredSelection in project tdi-studio-se by Talend.
the class HL7UI method initTableViewer.
private void initTableViewer() {
List<IMetadataTable> tables = externalNode.getMetadataList();
for (IMetadataTable table : tables) {
MetadataTable loaded = ConvertionHelper.convert(table);
List<MetadataColumn> columns = loaded.getColumns();
String trueTableName = table.getLabel();
if (trueTableName.split("_").length > 2) {
// get true table name from node draged from repository
//$NON-NLS-N$
trueTableName = trueTableName.split("_")[1];
}
if (hl7Manager.getSchemaRelationMap().get(trueTableName) != null) {
hl7Manager.getSchemaRelationMap().remove(trueTableName);
hl7Manager.getSchemaRelationMap().put(trueTableName, columns);
} else {
hl7Manager.getSchemaRelationMap().put(trueTableName, columns);
}
MetadataColumn[] array = new MetadataColumn[columns.size()];
int i = 0;
for (MetadataColumn column : columns) {
MetadataColumn newColumn = copyColumn(column);
array[i] = newColumn;
i++;
}
if (this.getMetaTableViewer().getSelection() instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) this.getMetaTableViewer().getSelection();
if (selection.getFirstElement() != null) {
String name = ((IModel) selection.getFirstElement()).getDisplayName();
if (name.equals(trueTableName)) {
for (int j = 0; j < array.length; j++) {
hl7SchemaEditorView.getMetadataEditor().add(array[j]);
}
// hl7SchemaEditorView.getMetadataEditor().addAll(columns);
}
}
}
}
}
use of org.eclipse.jface.viewers.IStructuredSelection in project tdi-studio-se by Talend.
the class HL7MetadataEmfTableEditorView method getDbColumnNameAccessor.
@Override
protected IBeanPropertyAccessors<MetadataColumn, String> getDbColumnNameAccessor() {
return new IBeanPropertyAccessors<MetadataColumn, String>() {
public String get(MetadataColumn bean) {
return bean.getOriginalField();
}
public void set(MetadataColumn bean, String value) {
bean.setOriginalField(value);
IStructuredSelection selection = (IStructuredSelection) ((HL7MultiSchemaUI) linker.getMainui()).getMetaTableViewer().getSelection();
Object selectedObj = selection.getFirstElement();
if (selectedObj != null) {
String key = ((IModel) selectedObj).getDisplayName();
linker.getManager().updateRelationMapping(key, bean, false);
// if (columns.indexOf(bean) > 0) {
// columns.get(columns.indexOf(bean)).setOriginalField(value);
// }
}
}
};
}
use of org.eclipse.jface.viewers.IStructuredSelection in project tdi-studio-se by Talend.
the class CpuDumpEditor method createHotSpotsPage.
/**
* Creates the hot spots page.
*/
private void createHotSpotsPage() {
Composite panel = new Composite(getContainer(), SWT.NONE);
panel.setLayout(new FillLayout());
final HotSpotsFilteredTree hotSpotsFilteredTree = new HotSpotsFilteredTree(panel, getEditorSite().getActionBars());
TreeViewer hotSpotsViewer = hotSpotsFilteredTree.getViewer();
hotSpotsViewer.setContentProvider(new AbstractContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
if (inputElement instanceof ICpuModel) {
return ((ICpuModel) inputElement).getHotSpotRoots();
}
return new Object[0];
}
});
hotSpotsViewer.setLabelProvider(new HotSpotsLabelProvider(hotSpotsFilteredTree));
hotSpotsViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
hotSpotsFilteredTree.updateStatusLine((IStructuredSelection) event.getSelection());
}
});
hotSpotsViewer.setUseHashlookup(true);
hotSpotsViewer.setInput(cpuModel);
hotSpotsFilteredTree.sortColumn(hotSpotsViewer.getTree().getColumn(1));
int page = addPage(panel);
trees.put(hotSpotsFilteredTree, page);
setPageText(page, Messages.hotSpotsPageLabel);
setPageImage(page, getHotSpotsImage());
}
use of org.eclipse.jface.viewers.IStructuredSelection in project tdi-studio-se by Talend.
the class EditJSONPropertiesAction method init.
public void init(TreeViewer viewer, IStructuredSelection selection) {
boolean canWork = selection.size() == 1;
if (canWork) {
Object o = ((IStructuredSelection) selection).getFirstElement();
if (o instanceof RepositoryNode) {
RepositoryNode node = (RepositoryNode) o;
switch(node.getType()) {
case REPOSITORY_ELEMENT:
if (node.getObjectType() == JSONRepositoryNodeType.JSON) {
canWork = true;
} else {
canWork = false;
}
break;
default:
canWork = false;
break;
}
if (canWork) {
canWork = (node.getObject().getRepositoryStatus() != ERepositoryStatus.DELETED);
}
if (canWork) {
canWork = isLastVersion(node);
}
}
}
setEnabled(canWork);
}
Aggregations