use of org.eclipse.jface.viewers.ITreeContentProvider in project tdi-studio-se by Talend.
the class JobScriptsExportWizardPage method collectNodes.
private void collectNodes(Map<String, Item> items, RepositoryNode repositoryNode) {
IRepositoryViewObject repositoryObject = repositoryNode.getObject();
if (repositoryObject != null) {
if (repositoryObject.getRepositoryObjectType().isResourceItem()) {
Item item = repositoryObject.getProperty().getItem();
items.put(item.getProperty().getId(), item);
}
} else {
if (repositoryNode.getParent() != null && repositoryNode.getParent().getObject() != null) {
Item item = repositoryNode.getParent().getObject().getProperty().getItem();
items.put(item.getProperty().getId(), item);
}
}
if (this.treeViewer != null) {
IContentProvider contentProvider = this.treeViewer.getFilteredCheckboxTree().getViewer().getContentProvider();
if (contentProvider instanceof ITreeContentProvider) {
Object[] children = ((ITreeContentProvider) contentProvider).getChildren(repositoryNode);
collectNodes(items, children);
}
}
}
use of org.eclipse.jface.viewers.ITreeContentProvider in project tdi-studio-se by Talend.
the class DB2ExplainPlanExecution method displayResults.
private void displayResults(final ExplainNode node) {
Display.getDefault().asyncExec(new Runnable() {
@Override
@SuppressWarnings("deprecation")
public void run() {
clearCanvas();
GridLayout gLayout = new GridLayout();
gLayout.numColumns = 2;
gLayout.marginLeft = 0;
gLayout.horizontalSpacing = 0;
gLayout.verticalSpacing = 0;
gLayout.marginWidth = 0;
gLayout.marginHeight = 0;
composite.setLayout(gLayout);
try {
//$NON-NLS-1$
composite.setData("parenttab", parentTab);
Composite pp = new Composite(composite, SWT.NULL);
pp.setLayout(new FillLayout());
pp.setLayoutData(new GridData(GridData.FILL_BOTH));
TreeViewer tv = new TreeViewer(pp, SWT.BORDER | SWT.FULL_SELECTION);
Tree tree = tv.getTree();
tree.setLinesVisible(true);
tree.setHeaderVisible(true);
TreeColumn tc = new TreeColumn(tree, SWT.NULL);
//$NON-NLS-1$
tc.setText("");
tc = new TreeColumn(tree, SWT.NULL);
//$NON-NLS-1$
tc.setText(Messages.getString("DB2ExplainPlanExecution.tableColumnText1"));
tc = new TreeColumn(tree, SWT.NULL);
//$NON-NLS-1$
tc.setText(Messages.getString("DB2ExplainPlanExecution.tableColumnText2"));
TableLayout tableLayout = new TableLayout();
tableLayout.addColumnData(new ColumnWeightData(6, 150, true));
tableLayout.addColumnData(new ColumnWeightData(1, 50, true));
tableLayout.addColumnData(new ColumnWeightData(1, 50, true));
tree.setLayout(tableLayout);
tv.setContentProvider(new ITreeContentProvider() {
@Override
public void dispose() {
}
@Override
public Object[] getChildren(Object parentElement) {
return ((ExplainNode) parentElement).getChildren();
}
@Override
public Object[] getElements(Object inputElement) {
ExplainNode nd = ((ExplainNode) inputElement);
return nd.getChildren();
}
@Override
public Object getParent(Object element) {
return ((ExplainNode) element).getParent();
}
@Override
public boolean hasChildren(Object element) {
if (((ExplainNode) element).getChildren().length > 0) {
return true;
}
return false;
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
tv.setLabelProvider(new TreeLabelProvider() {
});
tv.setInput(node);
tv.refresh();
tv.expandAll();
// make columns full size
for (int i = 0; i < tree.getColumnCount(); i++) {
tree.getColumn(i).pack();
}
final Composite parent = composite;
tree.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
switch(e.keyCode) {
case SWT.F5:
// refresh SQL Results
try {
//$NON-NLS-1$
Object o = parent.getData("parenttab");
if (o != null) {
AbstractSQLExecution sqlExec = (AbstractSQLExecution) ((TabItem) o).getData();
if (sqlExec != null) {
sqlExec.startExecution();
}
}
} catch (Exception e1) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("DB2ExplainPlanExecution.logMessageError1"), e1);
}
break;
default:
return;
}
}
});
} catch (Exception e) {
// add message
String message = e.getMessage();
Label errorLabel = new Label(composite, SWT.FILL);
errorLabel.setText(message);
errorLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("DB2ExplainPlanExecution.logMessageError2"), e);
}
composite.layout();
composite.redraw();
}
;
});
}
use of org.eclipse.jface.viewers.ITreeContentProvider in project tdi-studio-se by Talend.
the class OracleExplainPlanExecution method displayResults.
private void displayResults(final ExplainNode node) {
Display.getDefault().asyncExec(new Runnable() {
@Override
@SuppressWarnings("deprecation")
public void run() {
clearCanvas();
GridLayout gLayout = new GridLayout();
gLayout.numColumns = 2;
gLayout.marginLeft = 0;
gLayout.horizontalSpacing = 0;
gLayout.verticalSpacing = 0;
gLayout.marginWidth = 0;
gLayout.marginHeight = 0;
composite.setLayout(gLayout);
try {
//$NON-NLS-1$
composite.setData("parenttab", parentTab);
Composite pp = new Composite(composite, SWT.NULL);
pp.setLayout(new FillLayout());
pp.setLayoutData(new GridData(GridData.FILL_BOTH));
TreeViewer tv = new TreeViewer(pp, SWT.BORDER | SWT.FULL_SELECTION);
Tree tree = tv.getTree();
tree.setLinesVisible(true);
tree.setHeaderVisible(true);
TreeColumn tc = new TreeColumn(tree, SWT.NULL);
//$NON-NLS-1$
tc.setText("");
tc = new TreeColumn(tree, SWT.NULL);
//$NON-NLS-1$
tc.setText(Messages.getString("OracleExplainPlanExecution.tableColumnText1"));
tc = new TreeColumn(tree, SWT.NULL);
//$NON-NLS-1$
tc.setText(Messages.getString("OracleExplainPlanExecution.tableColumnText2"));
TableLayout tableLayout = new TableLayout();
tableLayout.addColumnData(new ColumnWeightData(6, 150, true));
tableLayout.addColumnData(new ColumnWeightData(1, 50, true));
tableLayout.addColumnData(new ColumnWeightData(1, 50, true));
tree.setLayout(tableLayout);
tv.setContentProvider(new ITreeContentProvider() {
@Override
public void dispose() {
}
@Override
public Object[] getChildren(Object parentElement) {
return ((ExplainNode) parentElement).getChildren();
}
@Override
public Object[] getElements(Object inputElement) {
ExplainNode nd = ((ExplainNode) inputElement);
return nd.getChildren();
}
@Override
public Object getParent(Object element) {
return ((ExplainNode) element).getParent();
}
@Override
public boolean hasChildren(Object element) {
if (((ExplainNode) element).getChildren().length > 0) {
return true;
}
return false;
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
tv.setLabelProvider(new TreeLabelProvider() {
});
tv.setInput(node);
tv.refresh();
tv.expandAll();
// make columns full size
for (int i = 0; i < tree.getColumnCount(); i++) {
tree.getColumn(i).pack();
}
final Composite parent = composite;
tree.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
switch(e.keyCode) {
case SWT.F5:
// refresh SQL Results
try {
//$NON-NLS-1$
Object o = parent.getData("parenttab");
if (o != null) {
AbstractSQLExecution sqlExec = (AbstractSQLExecution) ((TabItem) o).getData();
if (sqlExec != null) {
sqlExec.startExecution();
}
}
} catch (Exception e1) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanExecution.logMessage1"), e1);
}
break;
default:
return;
}
}
});
} catch (Exception e) {
// add message
String message = e.getMessage();
Label errorLabel = new Label(composite, SWT.FILL);
errorLabel.setText(message);
errorLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanExecution.logMessage2"), e);
}
composite.layout();
composite.redraw();
}
;
});
}
use of org.eclipse.jface.viewers.ITreeContentProvider in project tdi-studio-se by Talend.
the class UseDynamicJobSelectionDialog method setCheckingNodes.
private void setCheckingNodes() {
final IContentProvider contentProvider = getItemsTreeViewer().getContentProvider();
final Object input = getItemsTreeViewer().getInput();
if (contentProvider instanceof ITreeContentProvider && input instanceof ProjectRepositoryNode && getNeedCheckedjobs() != null && getNeedCheckedjobs().length > 0) {
ITreeContentProvider cnfContentProvider = (ITreeContentProvider) contentProvider;
List<IRepositoryNode> checkingNodes = new ArrayList<IRepositoryNode>();
List<String> needCheckedJobIds = new ArrayList(Arrays.asList(getNeedCheckedjobs()));
final ProjectRepositoryNode root = (ProjectRepositoryNode) input;
final RepositoryNode rootRepositoryNode = root.getRootRepositoryNode(getSupportType());
if (rootRepositoryNode == null) {
return;
}
withReferenceProjects(cnfContentProvider, rootRepositoryNode, needCheckedJobIds, checkingNodes);
// set check for node
getItemsTreeViewer().setCheckedElements(checkingNodes.toArray());
// select and will expand the selected node auto
getItemsTreeViewer().setSelection(new StructuredSelection(checkingNodes), true);
// let scroll bar on top
getItemsTreeViewer().setSelection(new StructuredSelection(rootRepositoryNode));
getItemsTreeViewer().setSelection(StructuredSelection.EMPTY);
}
}
use of org.eclipse.jface.viewers.ITreeContentProvider in project archi by archimatetool.
the class ColoursFontsPreferencePage method createColoursTab.
private void createColoursTab() {
// Reset everything
resetColorsCache(false);
fImageRegistry = new ImageRegistry();
Composite client = new Composite(fTabfolder, SWT.NULL);
client.setLayout(new GridLayout(2, false));
TabItem item = new TabItem(fTabfolder, SWT.NONE);
item.setText(Messages.ColoursFontsPreferencePage_23);
item.setControl(client);
Label label = new Label(client, SWT.NULL);
label.setText(Messages.ColoursFontsPreferencePage_0);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
label.setLayoutData(gd);
// Tree
fTreeViewer = new TreeViewer(client);
gd = new GridData(GridData.FILL_BOTH);
// need this to set a smaller height
gd.heightHint = 80;
fTreeViewer.getTree().setLayoutData(gd);
// Tree Double-click listener
fTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
Object[] selected = ((IStructuredSelection) fTreeViewer.getSelection()).toArray();
if (isValidTreeSelection(selected)) {
RGB newRGB = openColorDialog(selected[0]);
if (newRGB != null) {
for (Object object : selected) {
setColor(object, newRGB);
}
}
}
}
});
// Tree Selection Changed Listener
fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
Object[] selected = ((IStructuredSelection) event.getSelection()).toArray();
fEditFillColorButton.setEnabled(isValidTreeSelection(selected));
fResetFillColorButton.setEnabled(isValidTreeSelection(selected));
}
});
// Tree Content Provider
fTreeViewer.setContentProvider(new ITreeContentProvider() {
@Override
public void dispose() {
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
@Override
public Object[] getElements(Object inputElement) {
if (inputElement instanceof String) {
return new Object[] { new TreeGrouping(Messages.ColoursFontsPreferencePage_32, ArchimateModelUtils.getStrategyClasses()), new TreeGrouping(Messages.ColoursFontsPreferencePage_7, ArchimateModelUtils.getBusinessClasses()), new TreeGrouping(Messages.ColoursFontsPreferencePage_8, ArchimateModelUtils.getApplicationClasses()), new TreeGrouping(Messages.ColoursFontsPreferencePage_9, ArchimateModelUtils.getTechnologyClasses()), new TreeGrouping(Messages.ColoursFontsPreferencePage_33, ArchimateModelUtils.getPhysicalClasses()), new TreeGrouping(Messages.ColoursFontsPreferencePage_10, ArchimateModelUtils.getMotivationClasses()), new TreeGrouping(Messages.ColoursFontsPreferencePage_11, ArchimateModelUtils.getImplementationMigrationClasses()), new TreeGrouping(Messages.ColoursFontsPreferencePage_17, ArchimateModelUtils.getOtherClasses()), new TreeGrouping(Messages.ColoursFontsPreferencePage_34, new Object[] { IArchimatePackage.eINSTANCE.getDiagramModelNote(), IArchimatePackage.eINSTANCE.getDiagramModelGroup() }), DEFAULT_ELEMENT_LINE_COLOR, DEFAULT_CONNECTION_LINE_COLOR };
}
return null;
}
@Override
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof TreeGrouping) {
return ((TreeGrouping) parentElement).children;
}
return null;
}
@Override
public Object getParent(Object element) {
return null;
}
@Override
public boolean hasChildren(Object element) {
return element instanceof TreeGrouping;
}
});
// Tree Label Provider
fTreeViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof EClass) {
return ArchiLabelProvider.INSTANCE.getDefaultName((EClass) element);
}
if (element instanceof TreeGrouping) {
return ((TreeGrouping) element).title;
}
if (element instanceof String) {
String s = (String) element;
if (s.equals(DEFAULT_ELEMENT_LINE_COLOR)) {
return Messages.ColoursFontsPreferencePage_12;
}
if (s.equals(DEFAULT_CONNECTION_LINE_COLOR)) {
return Messages.ColoursFontsPreferencePage_18;
}
}
return null;
}
@Override
public Image getImage(Object element) {
if (element instanceof TreeGrouping) {
return IArchiImages.ImageFactory.getImage(IArchiImages.ECLIPSE_IMAGE_FOLDER);
}
return getColorSwatch(element);
}
// Create a coloured image based on colour and add to the image registry
private Image getColorSwatch(Object object) {
String key = getColorKey(object);
Image image = fImageRegistry.get(key);
if (image == null) {
image = new Image(Display.getCurrent(), 16, 16);
GC gc = new GC(image);
SWTGraphics graphics = new SWTGraphics(gc);
graphics.setBackgroundColor(fColorsCache.get(object));
graphics.fillRectangle(0, 0, 15, 15);
graphics.drawRectangle(0, 0, 15, 15);
gc.dispose();
graphics.dispose();
fImageRegistry.put(key, image);
}
return image;
}
});
// fTreeViewer.setAutoExpandLevel(2);
// Set Content in Tree
// $NON-NLS-1$
fTreeViewer.setInput("");
// Buttons
Composite buttonClient = new Composite(client, SWT.NULL);
gd = new GridData(SWT.TOP, SWT.TOP, false, false);
buttonClient.setLayoutData(gd);
buttonClient.setLayout(new GridLayout());
// Edit...
fEditFillColorButton = new Button(buttonClient, SWT.PUSH);
fEditFillColorButton.setText(Messages.ColoursFontsPreferencePage_13);
fEditFillColorButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fEditFillColorButton.setEnabled(false);
fEditFillColorButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
Object[] selected = ((IStructuredSelection) fTreeViewer.getSelection()).toArray();
if (isValidTreeSelection(selected)) {
RGB newRGB = openColorDialog(selected[0]);
if (newRGB != null) {
for (Object object : selected) {
setColor(object, newRGB);
}
}
}
}
});
// Reset
fResetFillColorButton = new Button(buttonClient, SWT.PUSH);
fResetFillColorButton.setText(Messages.ColoursFontsPreferencePage_14);
fResetFillColorButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fResetFillColorButton.setEnabled(false);
fResetFillColorButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
Object[] selected = ((IStructuredSelection) fTreeViewer.getSelection()).toArray();
if (isValidTreeSelection(selected)) {
for (Object object : selected) {
resetColorToInbuiltDefault(object);
}
}
}
});
// Import Scheme
Button importButton = new Button(buttonClient, SWT.PUSH);
importButton.setText(Messages.ColoursFontsPreferencePage_2);
importButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
importButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
try {
importUserColors();
} catch (IOException ex) {
ex.printStackTrace();
}
}
});
// Export Scheme
Button exportButton = new Button(buttonClient, SWT.PUSH);
exportButton.setText(Messages.ColoursFontsPreferencePage_3);
exportButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
exportButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
try {
exportUserColors();
} catch (IOException ex) {
ex.printStackTrace();
}
}
});
Group elementColorGroup = new Group(client, SWT.NULL);
elementColorGroup.setLayout(new GridLayout(2, false));
elementColorGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
elementColorGroup.setText(Messages.ColoursFontsPreferencePage_20);
// Derive element line colours
fDeriveElementLineColorsButton = new Button(elementColorGroup, SWT.CHECK);
fDeriveElementLineColorsButton.setText(Messages.ColoursFontsPreferencePage_19);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
fDeriveElementLineColorsButton.setLayoutData(gd);
fDeriveElementLineColorsButton.setSelection(getPreferenceStore().getBoolean(DERIVE_ELEMENT_LINE_COLOR));
fDeriveElementLineColorsButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fElementLineColorContrastSpinner.setEnabled(fDeriveElementLineColorsButton.getSelection());
fContrastFactorLabel.setEnabled(fDeriveElementLineColorsButton.getSelection());
}
});
fContrastFactorLabel = new Label(elementColorGroup, SWT.NULL);
fContrastFactorLabel.setText(Messages.ColoursFontsPreferencePage_21);
fElementLineColorContrastSpinner = new Spinner(elementColorGroup, SWT.BORDER);
fElementLineColorContrastSpinner.setMinimum(1);
fElementLineColorContrastSpinner.setMaximum(10);
fElementLineColorContrastSpinner.setSelection(getPreferenceStore().getInt(DERIVE_ELEMENT_LINE_COLOR_FACTOR));
label = new Label(elementColorGroup, SWT.NULL);
label.setText(Messages.ColoursFontsPreferencePage_22);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
// Persist user default colours
fPersistUserDefaultColors = new Button(client, SWT.CHECK);
fPersistUserDefaultColors.setText(Messages.ColoursFontsPreferencePage_1);
fPersistUserDefaultColors.setLayoutData(gd);
fPersistUserDefaultColors.setSelection(getPreferenceStore().getBoolean(SAVE_USER_DEFAULT_COLOR));
// Use colours in application
fShowUserDefaultFillColorsInApplication = new Button(client, SWT.CHECK);
fShowUserDefaultFillColorsInApplication.setText(Messages.ColoursFontsPreferencePage_6);
fShowUserDefaultFillColorsInApplication.setLayoutData(gd);
fShowUserDefaultFillColorsInApplication.setSelection(getPreferenceStore().getBoolean(SHOW_FILL_COLORS_IN_GUI));
}
Aggregations