Search in sources :

Example 1 with StandardJavaElementContentProvider

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;
}
Also used : IJavaElement(org.eclipse.jdt.core.IJavaElement) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) IEntity(org.whole.lang.model.IEntity) Viewer(org.eclipse.jface.viewers.Viewer) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) JavaElementLabelProvider(org.eclipse.jdt.ui.JavaElementLabelProvider) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) StandardJavaElementContentProvider(org.eclipse.jdt.ui.StandardJavaElementContentProvider) IBindingManager(org.whole.lang.bindings.IBindingManager) JavaElementLabelProvider(org.eclipse.jdt.ui.JavaElementLabelProvider) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider) IResource(org.eclipse.core.resources.IResource)

Example 2 with StandardJavaElementContentProvider

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();
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) StandardJavaElementContentProvider(org.eclipse.jdt.ui.StandardJavaElementContentProvider) TreeViewer(org.eclipse.jface.viewers.TreeViewer) JavaClassFileFilter(org.whole.lang.ui.controls.JavaClassFileFilter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) JavaElementComparator(org.eclipse.jdt.ui.JavaElementComparator) JavaElementLabelProvider(org.eclipse.jdt.ui.JavaElementLabelProvider)

Example 3 with StandardJavaElementContentProvider

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();
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) StandardJavaElementContentProvider(org.eclipse.jdt.ui.StandardJavaElementContentProvider) TreeViewer(org.eclipse.jface.viewers.TreeViewer) JavaClassFileFilter(org.whole.lang.ui.controls.JavaClassFileFilter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) JavaElementComparator(org.eclipse.jdt.ui.JavaElementComparator) JavaElementLabelProvider(org.eclipse.jdt.ui.JavaElementLabelProvider)

Example 4 with StandardJavaElementContentProvider

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;
}
Also used : ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) StandardJavaElementContentProvider(org.eclipse.jdt.ui.StandardJavaElementContentProvider) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) JavaElementComparator(org.eclipse.jdt.ui.JavaElementComparator) JavaElementLabelProvider(org.eclipse.jdt.ui.JavaElementLabelProvider)

Example 5 with StandardJavaElementContentProvider

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;
}
Also used : ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) StandardJavaElementContentProvider(org.eclipse.jdt.ui.StandardJavaElementContentProvider) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) JavaElementComparator(org.eclipse.jdt.ui.JavaElementComparator) JavaElementLabelProvider(org.eclipse.jdt.ui.JavaElementLabelProvider)

Aggregations

JavaElementLabelProvider (org.eclipse.jdt.ui.JavaElementLabelProvider)5 StandardJavaElementContentProvider (org.eclipse.jdt.ui.StandardJavaElementContentProvider)5 JavaElementComparator (org.eclipse.jdt.ui.JavaElementComparator)4 ElementTreeSelectionDialog (org.eclipse.ui.dialogs.ElementTreeSelectionDialog)3 ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 JavaClassFileFilter (org.whole.lang.ui.controls.JavaClassFileFilter)2 IResource (org.eclipse.core.resources.IResource)1 IJavaElement (org.eclipse.jdt.core.IJavaElement)1 IPackageFragmentRoot (org.eclipse.jdt.core.IPackageFragmentRoot)1 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)1 LabelProvider (org.eclipse.jface.viewers.LabelProvider)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)1 WorkbenchContentProvider (org.eclipse.ui.model.WorkbenchContentProvider)1 WorkbenchLabelProvider (org.eclipse.ui.model.WorkbenchLabelProvider)1