use of org.eclipse.jface.viewers.ITreeContentProvider in project hale by halestudio.
the class TypeEntityDialog method addToolBarActions.
/**
* @see eu.esdihumboldt.hale.ui.function.common.EntityDialog#addToolBarActions(org.eclipse.jface.action.ToolBarManager)
*/
@Override
protected void addToolBarActions(ToolBarManager manager) {
// filter to only show mapped types
manager.add(new FilterAction("Hide unmapped types", "Show unmapped types", HALEUIPlugin.getImageDescriptor("icons/empty.gif"), getViewer(), new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
Alignment alignment = as.getAlignment();
if (element instanceof TreePath)
element = ((TreePath) element).getLastSegment();
return isMapped((ITreeContentProvider) ((TreeViewer) viewer).getContentProvider(), element, alignment);
}
private boolean isMapped(ITreeContentProvider cp, Object element, Alignment align) {
if (element instanceof EntityDefinition) {
boolean mapped = AlignmentUtil.entityOrChildMapped((EntityDefinition) element, align);
if (mapped)
return true;
}
// recursively check children
Object[] children = cp.getChildren(element);
if (children != null)
for (Object child : children) if (isMapped(cp, child, align))
return true;
return false;
}
}, true, true));
// do not add choice if only mapping relevant types should be selected
if (onlyMappingRelevant)
return;
manager.add(new Separator());
// MappingRelevant types only, flat
manager.add(new ContentProviderAction("Mapping relevant types as list", HALEUIPlugin.getImageDescriptor("icons/flat_relevant.png"), getViewer(), flatRelevantProvider, false));
// MappingRelevant types only, hierarchical
manager.add(new ContentProviderAction("Mapping relevant types hierarchical", HALEUIPlugin.getImageDescriptor("icons/hierarchical_relevant.png"), getViewer(), hierarchicalRelevantProvider, false));
// Mappable types, flat
manager.add(new ContentProviderAction("All types as list", HALEUIPlugin.getImageDescriptor("icons/flat_all.png"), getViewer(), flatAllProvider, true));
// Mappable types, hierarchical
manager.add(new ContentProviderAction("All types hierarchical", HALEUIPlugin.getImageDescriptor("icons/hierarchical_all.png"), getViewer(), hierarchicalAllProvider, false));
}
use of org.eclipse.jface.viewers.ITreeContentProvider in project translationstudio8 by heartsome.
the class ImportProjectWizardPage method createProjectsList.
/**
* Create the checkbox list for the found projects.
*
* @param workArea
*/
private void createProjectsList(Composite workArea) {
Label title = new Label(workArea, SWT.NONE);
title.setText(DataTransferMessages.WizardProjectsImportPage_ProjectsListTitle);
Composite listComposite = new Composite(workArea, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 0;
layout.makeColumnsEqualWidth = false;
listComposite.setLayout(layout);
listComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
projectsList = new CheckboxTreeViewer(listComposite, SWT.BORDER);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.widthHint = new PixelConverter(projectsList.getControl()).convertWidthInCharsToPixels(25);
gridData.heightHint = new PixelConverter(projectsList.getControl()).convertHeightInCharsToPixels(10);
projectsList.getControl().setLayoutData(gridData);
projectsList.setContentProvider(new ITreeContentProvider() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java
* .lang.Object)
*/
public Object[] getChildren(Object parentElement) {
return null;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.IStructuredContentProvider#getElements
* (java.lang.Object)
*/
public Object[] getElements(Object inputElement) {
return getProjectRecords();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java
* .lang.Object)
*/
public boolean hasChildren(Object element) {
return false;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.ITreeContentProvider#getParent(java
* .lang.Object)
*/
public Object getParent(Object element) {
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose() {
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse
* .jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
projectsList.setLabelProvider(new ProjectLabelProvider());
projectsList.addCheckStateListener(new ICheckStateListener() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged
* (org.eclipse.jface.viewers.CheckStateChangedEvent)
*/
public void checkStateChanged(CheckStateChangedEvent event) {
ProjectRecord element = (ProjectRecord) event.getElement();
if (element.hasConflicts) {
projectsList.setChecked(element, false);
}
setPageComplete(projectsList.getCheckedElements().length > 0);
}
});
projectsList.setInput(this);
projectsList.setComparator(new ViewerComparator());
createSelectionButtons(listComposite);
}
use of org.eclipse.jface.viewers.ITreeContentProvider in project tdi-studio-se by Talend.
the class ExportItemWizardPage method collectNodes.
private void collectNodes(Map<String, Item> items, Object[] objects) {
for (Object object : objects) {
if (object instanceof RepositoryNode) {
RepositoryNode repositoryNode = (RepositoryNode) object;
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 (filteredCheckboxTree != null && !isHadoopClusterNode(repositoryNode)) {
IContentProvider contentProvider = filteredCheckboxTree.getViewer().getContentProvider();
if (contentProvider instanceof ITreeContentProvider) {
// only check childrens of allowed items in this viewer
if (selectRepositoryNode(getItemsTreeViewer(), repositoryNode)) {
Object[] children = ((ITreeContentProvider) contentProvider).getChildren(repositoryNode);
List<Object> childrenNodes = getUnTestCaseChildren(children);
collectNodes(items, childrenNodes.toArray());
}
}
}
} else {
for (IExtendedRepositoryNodeHandler nodeHandler : RepositoryContentManager.getExtendedNodeHandler()) {
Property property = nodeHandler.getProperty(object);
if (property != null) {
items.put(property.getId(), property.getItem());
}
}
}
}
}
use of org.eclipse.jface.viewers.ITreeContentProvider in project tdi-studio-se by Talend.
the class ImportItemWizardPage method createTreeViewer.
private TreeViewer createTreeViewer(Composite listComposite) {
filteredCheckboxTree = new FilteredCheckboxTree(listComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
CheckboxTreeViewer viewer = filteredCheckboxTree.getViewer();
viewer.setContentProvider(new ITreeContentProvider() {
@Override
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof IContainerNode) {
return ((IContainerNode) parentElement).getChildren().toArray();
}
return null;
}
@Override
public Object[] getElements(Object inputElement) {
// return getValidItems();
return repositoryUtil.getTreeViewInput().toArray();
}
@Override
public boolean hasChildren(Object element) {
if (element instanceof IContainerNode) {
return ((IContainerNode) element).hasChildren();
}
return false;
}
@Override
public Object getParent(Object element) {
return null;
}
@Override
public void dispose() {
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
viewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof IContainerNode) {
if (element instanceof ProjectNode) {
Project project = ((ProjectNode) element).getProject();
return ProjectManager.getProjectDisplayLabel(project);
}
return ((IContainerNode) element).getLabel();
} else if (element instanceof ItemRecord) {
return ((ItemRecord) element).getLabel();
}
return super.getText(element);
}
@Override
public Image getImage(Object element) {
if (element instanceof IContainerNode) {
return ((IContainerNode) element).getImage();
} else if (element instanceof ItemRecord) {
return ((ItemRecord) element).getImage();
}
return super.getImage(element);
}
});
viewer.setSorter(TreeBuilder.createSorter());
viewer.setInput(this);
viewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
filteredCheckboxTree.calculateCheckedLeafNodes();
updateFinishStatus();
}
});
filteredCheckboxTree.getViewer().addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return selectRepositoryNode(viewer, element);
}
});
return viewer;
}
use of org.eclipse.jface.viewers.ITreeContentProvider in project tdi-studio-se by Talend.
the class AddResourceAction method run.
/**
* Prompts for a jar to add.
*
* @see IAction#run()
*/
@Override
public void run() {
// ViewerFilter filter = new ArchiveFilter(getSelectedJars());
ILabelProvider lp = new WorkbenchLabelProvider();
ITreeContentProvider cp = new WorkbenchContentProvider();
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), lp, cp);
dialog.setValidator(validator);
//$NON-NLS-1$
dialog.setTitle(Messages.getString("AddResourceAction.JARSecection"));
//$NON-NLS-1$
dialog.setMessage(Messages.getString("AddResourceAction.ChooseResource"));
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot().getProject(PluginConstant.COMPONENT_PROJECT));
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (dialog.open() == Window.OK) {
Object[] elements = dialog.getResult();
List<ILibEntry> res = new ArrayList<ILibEntry>();
for (int i = 0; i < elements.length; i++) {
IResource elem = (IResource) elements[i];
String name = elem.getName();
if (name.matches("(?i).*\\.(jar)\\b")) {
//$NON-NLS-1$
res.add(new JarLibEntry(elem));
}
if (name.matches("(?i).*\\.(pm)\\b")) {
//$NON-NLS-1$
res.add(new PmLibEntry(elem));
}
}
if (res.size() > 0) {
ILibEntry[] entries = new ILibEntry[res.size()];
getViewer().addEntries(res.toArray(entries));
}
}
}
Aggregations