use of org.eclipse.jface.viewers.IStructuredSelection in project tdi-studio-se by Talend.
the class GefEditorLabelProvider method getImage.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
*/
public Image getImage(Object objects) {
Node node = null;
if (objects == null || objects.equals(StructuredSelection.EMPTY)) {
return null;
}
if (!(objects instanceof IStructuredSelection)) {
return null;
}
final boolean[] multiple = { false };
Object object = getObject(objects, multiple);
if (object == null) {
return null;
}
if ((object instanceof NodeTreeEditPart)) {
node = (Node) ((NodeTreeEditPart) object).getModel();
} else {
if (object instanceof NodeReturnsTreeEditPart) {
node = lastNode;
} else {
if (object instanceof ProcessPart) {
return ImageProvider.getImage(ECoreImage.PROCESS_ICON);
}
if (object instanceof ConnectionPart) {
return ImageProvider.getImage(EImage.RIGHT_ICON);
}
if (object instanceof NoteEditPart) {
return ImageProvider.getImage(ECoreImage.CODE_ICON);
}
if (object instanceof ConnLabelEditPart) {
return ImageProvider.getImage(EImage.RIGHT_ICON);
}
if ((object instanceof NodeLabelEditPart)) {
node = ((NodeContainer) ((NodeLabelEditPart) object).getParent().getModel()).getNode();
}
if (!(object instanceof NodePart)) {
return null;
}
if (node == null) {
node = (Node) ((NodePart) object).getModel();
}
}
}
if (lastNode != node) {
lastNode = node;
}
return CoreImageProvider.getComponentIcon(node.getComponent(), ICON_SIZE.ICON_24);
}
use of org.eclipse.jface.viewers.IStructuredSelection in project tdi-studio-se by Talend.
the class GefEditorLabelProvider method getText.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
*/
public String getText(Object objects) {
Node node = null;
if (objects == null || objects.equals(StructuredSelection.EMPTY)) {
//$NON-NLS-1$
return "No items selected";
}
if (!(objects instanceof IStructuredSelection)) {
return null;
}
final boolean[] multiple = { false };
Object object = getObject(objects, multiple);
if (object == null) /* || ((IStructuredSelection) objects).size() > 1 */
{
//$NON-NLS-1$
return "No items selected";
} else {
if (object instanceof NodeContainerPart) {
NodeContainerPart nContainer = (NodeContainerPart) object;
Process process = (Process) nContainer.getParent().getModel();
return process.getName();
} else if (object instanceof ProcessPart) {
Process process = (Process) ((ProcessPart) object).getModel();
return process.getLabel();
} else if (object instanceof ProcessTreeEditPart) {
Process process = (Process) ((ProcessTreeEditPart) object).getModel();
return process.getName();
}
if (object instanceof ConnectionPart) {
Connection conn = (Connection) ((ConnectionPart) object).getModel();
return conn.getName();
}
if (object instanceof NoteEditPart) {
return Note.class.getSimpleName();
}
if (object instanceof ConnLabelEditPart) {
Connection conn = (Connection) ((ConnectionLabel) ((ConnLabelEditPart) object).getModel()).getConnection();
return conn.getName();
}
if (object instanceof NodeTreeEditPart) {
node = (Node) ((NodeTreeEditPart) object).getModel();
} else {
if (object instanceof NodeReturnsTreeEditPart) {
node = lastNode;
} else {
if (object instanceof NodeLabelEditPart) {
node = ((NodeContainer) ((NodeLabelEditPart) object).getParent().getModel()).getNode();
}
if (!(object instanceof NodePart)) {
return null;
}
if (node == null) {
node = (Node) ((NodePart) object).getModel();
}
}
}
if (lastNode != node) {
lastNode = node;
}
String name = node.getUniqueName();
// }
return name;
}
}
use of org.eclipse.jface.viewers.IStructuredSelection in project tdi-studio-se by Talend.
the class HL7MultiSchemaUI method updateCurrentMetadataTable.
private void updateCurrentMetadataTable() {
IStructuredSelection selection = (IStructuredSelection) metaTableViewer.getSelection();
Object selectedObj = selection.getFirstElement();
if (selectedObj != null) {
String key = ((IModel) selectedObj).getDisplayName();
Map m = hl7Manager.getSchemaRelationMap();
List<MetadataColumn> beans = (List<MetadataColumn>) m.get(key);
MetadataTable currentTable = getCurrentTable(key, beans);
if (currentTable != null) {
metadataEditor.setMetadataTable(currentTable);
hl7SchemaEditorView.setExtendedTableModel(metadataEditor);
} else {
currentTable = ConnectionFactory.eINSTANCE.createMetadataTable();
metadataEditor.setMetadataTable(currentTable);
}
}
}
use of org.eclipse.jface.viewers.IStructuredSelection in project tdi-studio-se by Talend.
the class HotSpotsTabPage method createHotSpotsViewer.
/**
* Creates the hot spots viewer.
*
* @param composite The parent composite
* @param propertySheet The property sheet
*/
private void createHotSpotsViewer(Composite composite, PropertySheet propertySheet) {
filteredTree = new HotSpotsFilteredTree(composite, propertySheet.getViewSite().getActionBars()) {
@Override
protected void addMenus(IMenuManager manager) {
manager.add(new Separator());
manager.add(new ConfigureCpuProfilerAction(cpuSection));
}
};
TreeViewer hotSpotsViewer = filteredTree.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(filteredTree));
hotSpotsViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
filteredTree.updateStatusLine((IStructuredSelection) event.getSelection());
}
});
filteredTree.sortColumn(hotSpotsViewer.getTree().getColumn(1));
}
use of org.eclipse.jface.viewers.IStructuredSelection in project tdi-studio-se by Talend.
the class CallerCalleeTabPage method createCalleeViewer.
/**
* Creates the callee viewer.
*
* @param parent The parent composite
* @param propertySheet The property sheet
*/
private void createCalleeViewer(Composite parent, PropertySheet propertySheet) {
calleeFilteredTree = new HotSpotsFilteredTree(parent, propertySheet.getViewSite().getActionBars()) {
@Override
protected void addMenus(IMenuManager manager) {
manager.add(new Separator());
manager.add(new ConfigureCpuProfilerAction(cpuSection));
}
@Override
public ViewerType getViewerType() {
return ViewerType.Callee;
}
@Override
protected String getMethodColumnName() {
return Messages.calleeColumnLabel;
}
@Override
protected String getMethodColumnToolTip() {
return Messages.calleeColumnToolTip;
}
};
TreeViewer calleeViewer = calleeFilteredTree.getViewer();
calleeViewer.setContentProvider(new AbstractContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
if (inputElement instanceof ICpuModel) {
return ((ICpuModel) inputElement).getCallees();
}
return new Object[0];
}
});
calleeViewer.setLabelProvider(new HotSpotsLabelProvider(calleeFilteredTree));
calleeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
calleeFilteredTree.updateStatusLine((IStructuredSelection) event.getSelection());
}
});
calleeFilteredTree.sortColumn(calleeViewer.getTree().getColumn(1));
}
Aggregations