Search in sources :

Example 46 with ITreeContentProvider

use of org.eclipse.jface.viewers.ITreeContentProvider in project webtools.sourceediting by eclipse.

the class ADTMultiPageEditor method getContentOutlinePage.

public IContentOutlinePage getContentOutlinePage() {
    if (fOutlinePage == null || fOutlinePage.getControl() == null || fOutlinePage.getControl().isDisposed()) {
        final ProductCustomizationProvider productCustomizationProvider = (ProductCustomizationProvider) getAdapter(ProductCustomizationProvider.class);
        ExtensibleContentOutlinePage outlinePage = null;
        if (productCustomizationProvider != null) {
            outlinePage = productCustomizationProvider.getProductContentOutlinePage();
        }
        if (outlinePage == null) {
            outlinePage = new ADTContentOutlinePage();
        }
        outlinePage.setEditor(this);
        ITreeContentProvider provider = (ITreeContentProvider) getEditorModeManager().getCurrentMode().getOutlineProvider();
        outlinePage.setContentProvider(provider);
        ADTLabelProvider adtLabelProvider = new ADTLabelProvider();
        outlinePage.setLabelProvider(adtLabelProvider);
        outlinePage.setModel(getModel());
        fOutlinePage = outlinePage;
    }
    return fOutlinePage;
}
Also used : ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) ExtensibleContentOutlinePage(org.eclipse.wst.xsd.ui.internal.adt.outline.ExtensibleContentOutlinePage) ADTLabelProvider(org.eclipse.wst.xsd.ui.internal.adt.outline.ADTLabelProvider) ADTContentOutlinePage(org.eclipse.wst.xsd.ui.internal.adt.outline.ADTContentOutlinePage)

Example 47 with ITreeContentProvider

use of org.eclipse.jface.viewers.ITreeContentProvider in project webtools.sourceediting by eclipse.

the class CSSSyntaxColoringPage 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;
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) ListViewer(org.eclipse.jface.viewers.ListViewer) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) Viewer(org.eclipse.jface.viewers.Viewer) SourceViewer(org.eclipse.jface.text.source.SourceViewer) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 48 with ITreeContentProvider

use of org.eclipse.jface.viewers.ITreeContentProvider in project webtools.sourceediting by eclipse.

the class AddWorkspaceFileAction method run.

@Override
public void run() {
    // ViewerFilter filter= new StylesheetFilter(getSelectedJars());
    ILabelProvider lp = new WorkbenchLabelProvider();
    ITreeContentProvider cp = new WorkbenchContentProvider();
    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), lp, cp);
    dialog.setValidator(validator);
    dialog.setTitle(Messages.AddWorkspaceFileAction_DialogTitle);
    dialog.setMessage(Messages.AddWorkspaceFileAction_DialogMessage);
    dialog.addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (!(element instanceof IResource))
                return false;
            IResource resource = (IResource) element;
            if (resource.getType() == IResource.FILE) {
                if (!XSLCore.isXSLFile((IFile) resource))
                    return false;
            }
            return true;
        }
    });
    dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
    if (dialog.open() == Window.OK) {
        Object[] elements = dialog.getResult();
        LaunchTransform[] res = new LaunchTransform[elements.length];
        for (int i = 0; i < res.length; i++) {
            IResource elem = (IResource) elements[i];
            res[i] = new LaunchTransform(elem.getFullPath().toPortableString(), LaunchTransform.RESOURCE_TYPE);
        }
        addTransforms(res);
    }
}
Also used : ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) ResourceComparator(org.eclipse.ui.views.navigator.ResourceComparator) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) LaunchTransform(org.eclipse.wst.xsl.launching.config.LaunchTransform) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Viewer(org.eclipse.jface.viewers.Viewer) StylesheetViewer(org.eclipse.wst.xsl.internal.debug.ui.tabs.main.StylesheetViewer) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) IResource(org.eclipse.core.resources.IResource)

Example 49 with ITreeContentProvider

use of org.eclipse.jface.viewers.ITreeContentProvider in project liferay-ide by liferay.

the class UploadNewWorkflowDefinitionAction method promptForWorkspaceFile.

protected IFile promptForWorkspaceFile() {
    ISelectionStatusValidator validator = getContainerDialogSelectionValidator();
    ViewerFilter filter = getContainerDialogViewerFilter();
    ITreeContentProvider contentProvider = new WorkbenchContentProvider();
    IWorkbench workBench = PlatformUI.getWorkbench();
    ILabelProvider labelProvider = new DecoratingLabelProvider(new WorkbenchLabelProvider(), workBench.getDecoratorManager().getLabelDecorator());
    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), labelProvider, contentProvider);
    dialog.setValidator(validator);
    dialog.setTitle("workspace file");
    dialog.setMessage("workspace file");
    dialog.addFilter(filter);
    dialog.setInput(ResourcesPlugin.getWorkspace());
    if (dialog.open() == Window.OK) {
        Object element = dialog.getFirstResult();
        try {
            if (element instanceof IFile) {
                IFile file = (IFile) element;
                return file;
            }
        } catch (Exception ex) {
        // Do nothing
        }
    }
    return null;
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) IFile(org.eclipse.core.resources.IFile) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) ISelectionStatusValidator(org.eclipse.ui.dialogs.ISelectionStatusValidator) DecoratingLabelProvider(org.eclipse.jface.viewers.DecoratingLabelProvider) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider)

Example 50 with ITreeContentProvider

use of org.eclipse.jface.viewers.ITreeContentProvider in project liferay-ide by liferay.

the class NewPortletClassWizardPage method handleFolderButtonPressed.

/**
 * Browse for a new Destination Folder
 */
protected void handleFolderButtonPressed() {
    ISelectionStatusValidator validator = getContainerDialogSelectionValidator();
    ViewerFilter filter = getContainerDialogViewerFilter();
    ITreeContentProvider contentProvider = new WorkbenchContentProvider();
    IWorkbench workbench = PlatformUI.getWorkbench();
    ILabelProvider labelProvider = new DecoratingLabelProvider(new WorkbenchLabelProvider(), workbench.getDecoratorManager().getLabelDecorator());
    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), labelProvider, contentProvider);
    dialog.setValidator(validator);
    dialog.setTitle(J2EEUIMessages.CONTAINER_SELECTION_DIALOG_TITLE);
    dialog.setMessage(J2EEUIMessages.CONTAINER_SELECTION_DIALOG_DESC);
    dialog.addFilter(filter);
    String projectName = model.getStringProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME);
    if ((projectName == null) || (projectName.length() == 0)) {
        return;
    }
    IProject project = ProjectUtilities.getProject(projectName);
    dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
    if (project != null) {
        dialog.setInitialSelection(project);
    }
    if (dialog.open() == Window.OK) {
        Object element = dialog.getFirstResult();
        try {
            if (element instanceof IContainer) {
                IContainer container = (IContainer) element;
                folderText.setText(container.getFullPath().toString());
            // dealWithSelectedContainerResource(container);
            }
        } catch (Exception ex) {
        // Do nothing
        }
    }
}
Also used : ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) DecoratingLabelProvider(org.eclipse.jface.viewers.DecoratingLabelProvider) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) JavaModelException(org.eclipse.jdt.core.JavaModelException) IWorkbench(org.eclipse.ui.IWorkbench) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) ISelectionStatusValidator(org.eclipse.ui.dialogs.ISelectionStatusValidator) EObject(org.eclipse.emf.ecore.EObject) IContainer(org.eclipse.core.resources.IContainer)

Aggregations

ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)67 Viewer (org.eclipse.jface.viewers.Viewer)31 LabelProvider (org.eclipse.jface.viewers.LabelProvider)18 GridData (org.eclipse.swt.layout.GridData)18 Composite (org.eclipse.swt.widgets.Composite)16 TreeViewer (org.eclipse.jface.viewers.TreeViewer)15 GridLayout (org.eclipse.swt.layout.GridLayout)14 ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)12 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)12 Label (org.eclipse.swt.widgets.Label)12 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)11 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)11 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)11 WorkbenchContentProvider (org.eclipse.ui.model.WorkbenchContentProvider)11 WorkbenchLabelProvider (org.eclipse.ui.model.WorkbenchLabelProvider)11 ArrayList (java.util.ArrayList)10 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)9 ElementTreeSelectionDialog (org.eclipse.ui.dialogs.ElementTreeSelectionDialog)9 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)8 SourceViewer (org.eclipse.jface.text.source.SourceViewer)7