use of org.eclipse.jface.viewers.ITreeContentProvider in project eclipse.platform.text by eclipse.
the class AbstractTextSearchViewPage method internalRemoveSelected.
/**
* Note: this is internal API and should not be called from clients outside
* of the search plug-in.
* <p>
* Removes the currently selected match. Does nothing if no match is
* selected.
* </p>
*
* @noreference This method is not intended to be referenced by clients.
*/
public void internalRemoveSelected() {
AbstractTextSearchResult result = getInput();
if (result == null)
return;
StructuredViewer viewer = getViewer();
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
HashSet<Match> set = new HashSet<>();
if (viewer instanceof TreeViewer) {
ITreeContentProvider cp = (ITreeContentProvider) viewer.getContentProvider();
collectAllMatchesBelow(result, set, cp, selection.toArray());
} else {
collectAllMatches(set, selection.toArray());
}
navigateNext(true);
Match[] matches = new Match[set.size()];
set.toArray(matches);
result.removeMatches(matches);
}
use of org.eclipse.jface.viewers.ITreeContentProvider in project knime-core by knime.
the class WorkflowExportPage method createTreeViewer.
private void createTreeViewer(final Composite parent) {
m_treeViewer = new CheckboxTreeViewer(parent);
m_treeViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
m_treeViewer.setContentProvider(new ITreeContentProvider() {
// assume to have IContainers as input
@Override
public Object[] getChildren(final Object parentElement) {
if (parentElement instanceof IContainer) {
IContainer container = (IContainer) parentElement;
try {
// return only workflows and workflow groups
Collection<IContainer> children = new ArrayList<IContainer>();
for (IResource r : container.members(false)) {
if (KnimeResourceUtil.isWorkflow(r) || KnimeResourceUtil.isWorkflowGroup(r)) {
// if it is a workflow or workflow group
// it must be a container
children.add((IContainer) r);
}
}
return children.toArray();
} catch (CoreException e) {
return new Object[0];
}
}
return new Object[0];
}
@Override
public Object getParent(final Object element) {
if (element instanceof IResource) {
return ((IResource) element).getParent();
}
return null;
}
@Override
public boolean hasChildren(final Object element) {
if (element instanceof IWorkspaceRoot) {
return true;
}
if ((element instanceof IContainer) && KnimeResourceUtil.isWorkflowGroup((IContainer) element)) {
return true;
}
return false;
}
@Override
public Object[] getElements(final Object inputElement) {
return getChildren(inputElement);
}
@Override
public void dispose() {
// nothing to do
}
@Override
public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) {
// nothing to do
}
});
m_treeViewer.setLabelProvider(new KnimeResourceLabelProvider());
m_treeViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(final CheckStateChangedEvent event) {
Object o = event.getElement();
boolean isChecked = event.getChecked();
// first expand in order to be able to check children as well
m_treeViewer.expandToLevel(o, AbstractTreeViewer.ALL_LEVELS);
m_treeViewer.setSubtreeChecked(o, isChecked);
if (o instanceof IResource) {
IResource element = (IResource) o;
setParentTreeChecked(m_treeViewer, element, isChecked);
}
dialogChanged();
getWizard().getContainer().updateButtons();
}
});
m_treeViewer.getTree().setVisible(false);
}
use of org.eclipse.jface.viewers.ITreeContentProvider in project knime-core by knime.
the class WorkflowImportSelectionPage method createWorkflowListComposite.
/**
* @param parent parent composite
* @return the lower part of the workflow selection page, the list with
* selected workflows to import
*/
protected Composite createWorkflowListComposite(final Composite parent) {
Group overall = new Group(parent, SWT.FILL);
overall.setText("Workflows:");
overall.setLayoutData(FILL_BOTH);
overall.setLayout(new GridLayout(2, false));
// list with checkboxes....
m_workflowListUI = new CheckboxTreeViewer(overall);
m_workflowListUI.getTree().setLayoutData(FILL_BOTH);
m_workflowListUI.setContentProvider(new ITreeContentProvider() {
@Override
public Object[] getChildren(final Object parentElement) {
if (parentElement instanceof IWorkflowImportElement) {
return ((IWorkflowImportElement) parentElement).getChildren().toArray();
}
return new Object[0];
}
@Override
public Object getParent(final Object element) {
if (element instanceof IWorkflowImportElement) {
return ((IWorkflowImportElement) element).getParent();
}
return null;
}
@Override
public boolean hasChildren(final Object element) {
if (element instanceof IWorkflowImportElement) {
return ((IWorkflowImportElement) element).getChildren().size() > 0;
}
return false;
}
@Override
public Object[] getElements(final Object inputElement) {
return getChildren(inputElement);
}
@Override
public void dispose() {
}
@Override
public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) {
// should never happen
}
});
m_workflowListUI.setLabelProvider(new LabelProvider() {
@Override
public String getText(final Object element) {
if (element instanceof IWorkflowImportElement) {
IWorkflowImportElement wf = (IWorkflowImportElement) element;
return wf.getName();
}
return element.toString();
}
@Override
public Image getImage(final Object element) {
if (element instanceof IWorkflowImportElement) {
IWorkflowImportElement wf = (IWorkflowImportElement) element;
// display invalid ones differently
if (wf.isInvalid()) {
return IMG_WARN;
} else if (wf.isWorkflow()) {
return KnimeResourceLabelProvider.CLOSED_WORKFLOW;
} else if (wf.isWorkflowGroup()) {
return KnimeResourceLabelProvider.WORKFLOW_GROUP;
}
}
return super.getImage(element);
}
});
m_workflowListUI.setInput(m_importRoot);
m_workflowListUI.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(final CheckStateChangedEvent event) {
Object o = event.getElement();
boolean isChecked = event.getChecked();
// first expand in order to be able to check children as well
m_workflowListUI.expandToLevel(o, AbstractTreeViewer.ALL_LEVELS);
m_workflowListUI.setSubtreeChecked(o, isChecked);
if (o instanceof IWorkflowImportElement) {
IWorkflowImportElement element = (IWorkflowImportElement) o;
setParentTreeChecked(m_workflowListUI, element, isChecked);
}
validateWorkflows();
}
});
// and 3 buttons -> panel in second column
GridData rightAlign = new GridData();
rightAlign.horizontalAlignment = SWT.RIGHT;
rightAlign.verticalAlignment = SWT.BEGINNING;
Composite buttonPanel = new Composite(overall, SWT.NONE);
buttonPanel.setLayout(new GridLayout(1, false));
buttonPanel.setLayoutData(rightAlign);
// select all
Button selectAllBtn = new Button(buttonPanel, SWT.PUSH);
selectAllBtn.setText("Select All");
selectAllBtn.setLayoutData(m_btnData);
selectAllBtn.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(final SelectionEvent e) {
if (m_importRoot != null) {
m_workflowListUI.expandAll();
m_workflowListUI.setAllChecked(true);
validateWorkflows();
}
}
});
// deselect all
Button deselectAllBtn = new Button(buttonPanel, SWT.PUSH);
deselectAllBtn.setText("Deselect All");
deselectAllBtn.setLayoutData(m_btnData);
deselectAllBtn.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(final SelectionEvent e) {
if (m_importRoot != null) {
m_workflowListUI.expandAll();
m_workflowListUI.setAllChecked(false);
validateWorkflows();
}
}
});
// below a check box -> copy projects
m_copyProjectsUI = new Button(overall, SWT.CHECK);
m_copyProjectsUI.setText("Copy projects into workspace");
m_copyProjectsUI.setSelection(true);
m_copyProjectsUI.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(final SelectionEvent e) {
validateWorkflows();
}
});
// if from zip this checkbox must be disabled
m_copyProjectsUI.setEnabled(initialFromDir);
return parent;
}
use of org.eclipse.jface.viewers.ITreeContentProvider in project tmdm-studio-se by Talend.
the class DataModelMainPage method activeMarkerItem.
private void activeMarkerItem(TreeViewer v, Element dom) {
ITreeContentProvider provider = (ITreeContentProvider) v.getContentProvider();
for (Object data : provider.getElements(xsdSchema)) {
Object[] foundData = findMarkerData(provider, data, dom, new Object[0]);
if (foundData != null) {
TreePath treePath = new TreePath(foundData);
v.setSelection(new TreeSelection(treePath));
return;
}
}
}
use of org.eclipse.jface.viewers.ITreeContentProvider in project webtools.sourceediting by eclipse.
the class XMLSyntaxColoringPage method createStylesViewer.
/**
* Creates the List viewer where we see the various syntax element display
* names--would it ever be a Tree like JDT's?
*
* @param parent
* @return
*/
private StructuredViewer createStylesViewer(Composite parent) {
StructuredViewer stylesViewer = new ListViewer(parent, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
stylesViewer.setComparator(new ViewerComparator(Collator.getInstance()));
stylesViewer.setLabelProvider(new LabelProvider() {
public String getText(Object element) {
Object description = fStyleToDescriptionMap.get(element);
if (description != null)
return description.toString();
return super.getText(element);
}
});
stylesViewer.setContentProvider(new ITreeContentProvider() {
public void dispose() {
}
public Object[] getChildren(Object parentElement) {
return getStylePreferenceKeys().toArray();
}
public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}
public Object getParent(Object element) {
return getStylePreferenceKeys();
}
public boolean hasChildren(Object element) {
return false;
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
return stylesViewer;
}
Aggregations