use of org.eclipse.jdt.ui.StandardJavaElementContentProvider in project whole by wholeplatform.
the class MergeResourcesAction method performWorkspaceResourceSelection.
protected IEntity performWorkspaceResourceSelection(Shell shell, IEntity entity) {
IResource input;
if (Matcher.matchImpl(ArtifactsEntityDescriptorEnum.Workspace, entity.wGetParent()))
input = ResourcesPlugin.getWorkspace().getRoot();
else {
IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
ArtifactsWorkspaceUtils.bindPath(entity.wGetParent(), bm, false);
input = (IResource) (bm.wIsSet("folder") ? bm.wGetValue("folder") : bm.wGetValue("project"));
}
IJavaElement javaInput = JavaCore.create(input);
LabelProvider labelProvider = javaInput != null ? new JavaElementLabelProvider() : new WorkbenchLabelProvider();
ITreeContentProvider contentProvider = javaInput != null ? new StandardJavaElementContentProvider() : new WorkbenchContentProvider();
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell, labelProvider, contentProvider);
dialog.setInput(javaInput != null ? javaInput : input);
dialog.setTitle(SELECT_RESOURCE_MSG);
dialog.setMessage("Choose a resource");
if (javaInput != null)
dialog.addFilter(new ViewerFilter() {
public boolean select(Viewer viewer, Object parentElement, Object element) {
try {
return !(element instanceof IPackageFragmentRoot) || ((IPackageFragmentRoot) element).getKind() == IPackageFragmentRoot.K_SOURCE;
} catch (Exception e) {
return false;
}
}
});
if (dialog.open() != IDialogConstants.OK_ID)
return NullEntity.instance;
IEntity result = null;
for (Object resource : dialog.getResult()) {
IEntity artifactsPath;
if (resource instanceof IJavaElement) {
IJavaElement toJavaElement = (IJavaElement) resource;
artifactsPath = ArtifactsWorkspaceUtils.toArtifactsPath(javaInput, toJavaElement);
} else {
IResource toResource = (IResource) resource;
IJavaElement parentJavaElement = JavaCore.create(toResource.getParent());
if (javaInput == null || parentJavaElement == null)
artifactsPath = ArtifactsWorkspaceUtils.toArtifactsPath(input, toResource);
else
artifactsPath = ArtifactsWorkspaceUtils.toArtifactsPath(javaInput, toResource);
}
result = result == null ? artifactsPath : EntityUtils.merge(result, artifactsPath, createEntityComparator(), false);
}
int index = Matcher.match(ArtifactsEntityDescriptorEnum.Workspace, result) ? result.wIndexOf(ArtifactsFeatureDescriptorEnum.projects) : result.wIndexOf(ArtifactsFeatureDescriptorEnum.artifacts);
IEntity tree = result.wGet(index);
result.wRemove(index);
return tree;
}
use of org.eclipse.jdt.ui.StandardJavaElementContentProvider in project whole by wholeplatform.
the class WizardPojoModelImportPage1 method createSourceGroup.
@Override
protected void createSourceGroup(Composite parent) {
resourceChooser = new TreeViewer(parent);
GridLayout listAreaLayout = new GridLayout();
listAreaLayout.marginWidth = 0;
parent.setLayout(listAreaLayout);
resourceChooser.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
resourceChooser.setContentProvider(new StandardJavaElementContentProvider());
resourceChooser.setLabelProvider(new JavaElementLabelProvider());
resourceChooser.setComparator(new JavaElementComparator());
resourceChooser.addFilter(new JavaClassFileFilter());
resourceChooser.setInput(JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()));
resourceChooser.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
updatePageCompletion();
}
});
}
use of org.eclipse.jdt.ui.StandardJavaElementContentProvider in project whole by wholeplatform.
the class WizardJavaModelImportPage1 method createSourceGroup.
@Override
protected void createSourceGroup(Composite parent) {
resourceChooser = new TreeViewer(parent, SWT.SINGLE);
GridLayout listAreaLayout = new GridLayout();
listAreaLayout.marginWidth = 0;
parent.setLayout(listAreaLayout);
resourceChooser.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
resourceChooser.setContentProvider(new StandardJavaElementContentProvider());
resourceChooser.setLabelProvider(new JavaElementLabelProvider());
resourceChooser.setComparator(new JavaElementComparator());
resourceChooser.addFilter(new JavaClassFileFilter());
resourceChooser.setInput(JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()));
resourceChooser.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
updatePageCompletion();
}
});
}
use of org.eclipse.jdt.ui.StandardJavaElementContentProvider in project whole by wholeplatform.
the class ClassBrowseChooser method createDialog.
protected Dialog createDialog() {
StandardJavaElementContentProvider provider = new StandardJavaElementContentProvider();
ILabelProvider labelProvider = new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT);
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), labelProvider, provider);
dialog.setTitle("Package selection");
dialog.setMessage("Choose a package fragment");
dialog.setComparator(new JavaElementComparator());
dialog.addFilter(new JavaPackageFragmentFilter());
dialog.setValidator(new JavaPackageFragmentValidator());
dialog.setInput(JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()));
dialog.setHelpAvailable(false);
return dialog;
}
use of org.eclipse.jdt.ui.StandardJavaElementContentProvider in project whole by wholeplatform.
the class PackageFragmentBrowseChooser method createDialog.
protected Dialog createDialog() {
StandardJavaElementContentProvider provider = new StandardJavaElementContentProvider();
ILabelProvider labelProvider = new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT);
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), labelProvider, provider);
dialog.setTitle("Packcage selection");
dialog.setMessage("Choose a package fragment");
dialog.setComparator(new JavaElementComparator());
dialog.addFilter(new JavaPackageFragmentFilter());
dialog.setValidator(new JavaPackageFragmentValidator());
dialog.setInput(JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()));
dialog.setHelpAvailable(false);
return dialog;
}
Aggregations