use of org.eclipse.jface.viewers.TreeViewer 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.TreeViewer 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));
}
use of org.eclipse.jface.viewers.TreeViewer in project tdi-studio-se by Talend.
the class JSONFileStep1Form method initialize.
/**
*
* Initialize value, forceFocus first field.
*/
@Override
protected void initialize() {
getConnection().setInputModel(true);
availableJSONTreeViewer = new TreeViewer(availableJSONTree);
this.xmlTreePopulator = new TreePopulator(availableJSONTreeViewer);
// this.xmlTreePopulator.configureDefaultTreeViewer();
this.jsonTreePopulator = new JsonTreePopulator(availableJSONTreeViewer);
// this.jsonTreePopulator.configureDefaultTreeViewer();
this.availableJSONTreeViewer.setUseHashlookup(true);
// add init of CheckBoxIsGuess and Determine the Initialize checkFileXsdorJSON
// if (getConnection().getXsdFilePath() != null) {
// fileFieldXsd.setText(getConnection().getXsdFilePath().replace("\\\\", "\\"));
// // init the fileViewer
// this.treePopulator.populateTree(fileFieldXsd.getText(), treeNode);
// checkFieldsValue();
// }
EJsonReadbyMode eJsonReadbyMode = null;
if (getConnection().getReadbyMode() != null) {
eJsonReadbyMode = EJsonReadbyMode.getEJsonReadbyModeByValue(getConnection().getReadbyMode());
}
if (eJsonReadbyMode == null) {
eJsonReadbyMode = getDefaultJsonReadbyMode();
}
// JSONFileStep1Form.this.wizard.setReadbyMode(readbyCombo.getText());
readbyCombo.setText(eJsonReadbyMode.getDisplayName());
getConnection().setReadbyMode(eJsonReadbyMode.getValue());
JSONFileStep1Form.this.wizard.setReadbyMode(eJsonReadbyMode.getValue());
if (getConnection().getJSONFilePath() != null) {
//$NON-NLS-1$ //$NON-NLS-2$
fileFieldJSON.setText(getConnection().getJSONFilePath().replace("\\\\", "\\"));
// init the fileViewer
checkFieldsValue();
String jsonFilePath = fileFieldJSON.getText();
if (isContextMode()) {
ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection());
jsonFilePath = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType, fileFieldJSON.getText()));
}
File file = new File(jsonFilePath);
if (!file.exists() && getConnection().getFileContent() != null && getConnection().getFileContent().length > 0) {
initFileContent();
jsonFilePath = tempJSONXsdPath;
}
String tempxml = null;
tempxml = getFilePath4Populate(jsonFilePath);
switchPopulator(JSONFileStep1Form.this.wizard.getReadbyMode(), tempxml);
}
// Fields to the Group Delimited File Settings
if (getConnection().getEncoding() != null && !getConnection().getEncoding().equals("")) {
//$NON-NLS-1$
encodingCombo.setText(getConnection().getEncoding());
} else {
encodingCombo.select(0);
}
encodingCombo.clearSelection();
// if (getConnection().getMaskXPattern() != null) {
// fieldMaskXPattern.setText(getConnection().getMaskXPattern().replace("\\\\", "\\"));
// }
adaptFormToEditable();
}
use of org.eclipse.jface.viewers.TreeViewer in project tdi-studio-se by Talend.
the class ErrorDetailDialog method createTreeTableViewer.
/**
* DOC chuang Comment method "createTreeTableView".
*
* @param parent
*/
private void createTreeTableViewer(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
viewer = new TreeViewer(composite, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
// init tree
final Tree tree = viewer.getTree();
tree.setHeaderVisible(true);
tree.setLinesVisible(true);
tree.setLayoutData(new GridData(GridData.FILL_BOTH));
// create tree column
TreeColumn column = new TreeColumn(tree, SWT.NONE);
//$NON-NLS-1$
column.setText("Resource");
column.setWidth(150);
column = new TreeColumn(tree, SWT.NONE);
//$NON-NLS-1$
column.setText("Description");
column.setWidth(300);
viewer.setContentProvider(new ErrorDetailContentProvider());
viewer.setLabelProvider(new ErrorDetailLabelProvider());
viewer.setInput(errors);
viewer.expandAll();
}
use of org.eclipse.jface.viewers.TreeViewer in project tdi-studio-se by Talend.
the class JSONFileOutputStep2Form method addJSONFileViewer.
private void addJSONFileViewer(final Composite mainComposite, final int width, final int height) {
final Group group = Form.createGroup(mainComposite, 1, "Linker Target", height);
GridData data = new GridData(GridData.FILL_BOTH);
Composite composite = new Composite(group, SWT.BORDER);
composite.setLayout(new GridLayout());
composite.setLayoutData(data);
JSONViewer = new TreeViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
data = new GridData(GridData.FILL_BOTH);
JSONViewer.getControl().setLayoutData(data);
JSONViewer.setUseHashlookup(true);
Tree tree = JSONViewer.getTree();
if (isReadOnly()) {
tree.setEnabled(false);
}
tree.setLinesVisible(true);
tree.setBackground(tree.getDisplay().getSystemColor(SWT.COLOR_WHITE));
TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
column1.setText("JSON Tree");
column1.setWidth(120);
TreeColumn column2 = new TreeColumn(tree, SWT.CENTER);
column2.setText("Related Column");
column2.setWidth(100);
TreeColumn column3 = new TreeColumn(tree, SWT.CENTER);
column3.setText("Node Status");
column3.setWidth(100);
TreeColumn column4 = new TreeColumn(tree, SWT.CENTER);
column4.setText("Default Value");
column4.setWidth(100);
tree.setHeaderVisible(true);
JSONFileTreeViewerProvider provider = new JSONFileTreeViewerProvider();
JSONViewer.setLabelProvider(provider);
JSONViewer.setCellModifier(new ICellModifier() {
public void modify(Object element, String property, Object value) {
TreeItem treeItem = (TreeItem) element;
FOXTreeNode node = (FOXTreeNode) treeItem.getData();
if (property.equals("C1")) {
node.setLabel((String) value);
}
if (property.equals("C4")) {
node.setDefaultValue((String) value);
}
JSONViewer.refresh(node);
}
public Object getValue(Object element, String property) {
FOXTreeNode node = (FOXTreeNode) element;
if (property.equals("C1")) {
//$NON-NLS-1$
return node.getLabel();
}
if (property.equals("C4")) {
//$NON-NLS-1$
return node.getDefaultValue();
}
return null;
}
public boolean canModify(Object element, String property) {
FOXTreeNode node = (FOXTreeNode) element;
if (property.equals("C1")) {
if (node.getLabel() != null && node.getLabel().length() > 0) {
return true;
}
}
if (property.equals("C4")) {
if (node.getDefaultValue() != null && node.getDefaultValue().length() > 0) {
return true;
}
}
return false;
}
});
JSONViewer.setColumnProperties(new String[] { "C1", "C2", "C3", "C4" });
CellEditor editor = new TextCellEditor(JSONViewer.getTree());
editor.addListener(new DialogErrorJSONLabelCellEditor(editor, "C1"));
CellEditor editorDefault = new TextCellEditor(JSONViewer.getTree());
editorDefault.addListener(new DialogErrorJSONLabelCellEditor(editorDefault, "C4"));
JSONViewer.setCellEditors(new CellEditor[] { editor, null, null, editorDefault });
JSONViewer.setContentProvider(provider);
// JSONViewer.setInput(treeData);
JSONViewer.expandAll();
createAction();
MenuManager menuMgr = new MenuManager("#PopupMenu");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
fillContextMenu(manager);
}
});
Menu menu = menuMgr.createContextMenu(JSONViewer.getControl());
JSONViewer.getControl().setMenu(menu);
JSONViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
}
});
initToolBar(composite);
}
Aggregations