Search in sources :

Example 11 with DecoratingLabelProvider

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

the class LiferayDataModelWizardPage method handleFileBrowseButton.

protected void handleFileBrowseButton(final Text text, String title, String message) {
    ISelectionStatusValidator validator = getContainerDialogSelectionValidator();
    ViewerFilter filter = getContainerDialogViewerFilter();
    ITreeContentProvider contentProvider = new WorkbenchContentProvider();
    IDecoratorManager decoratorManager = PlatformUI.getWorkbench().getDecoratorManager();
    ILabelProvider labelProvider = new DecoratingLabelProvider(new WorkbenchLabelProvider(), decoratorManager.getLabelDecorator());
    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), labelProvider, contentProvider);
    dialog.setValidator(validator);
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.addFilter(filter);
    final IWebProject lrproject = LiferayCore.create(IWebProject.class, CoreUtil.getProject(getDataModel().getStringProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME)));
    if (lrproject != null) {
        final IFolder defaultDocroot = lrproject.getDefaultDocrootFolder();
        if (defaultDocroot != null) {
            dialog.setInput(defaultDocroot);
            if (dialog.open() == Window.OK) {
                Object element = dialog.getFirstResult();
                try {
                    if (element instanceof IFile) {
                        IFile file = (IFile) element;
                        final IPath relativePath = file.getFullPath().makeRelativeTo(defaultDocroot.getFullPath());
                        text.setText("/" + relativePath.toPortableString());
                    // dealWithSelectedContainerResource(container);
                    }
                } catch (Exception ex) {
                // Do nothing
                }
            }
        }
    }
}
Also used : ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) IFile(org.eclipse.core.resources.IFile) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) IPath(org.eclipse.core.runtime.IPath) IWebProject(com.liferay.ide.core.IWebProject) IDecoratorManager(org.eclipse.ui.IDecoratorManager) DecoratingLabelProvider(org.eclipse.jface.viewers.DecoratingLabelProvider) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) CoreException(org.eclipse.core.runtime.CoreException) JavaModelException(org.eclipse.jdt.core.JavaModelException) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) ISelectionStatusValidator(org.eclipse.ui.dialogs.ISelectionStatusValidator) EObject(org.eclipse.emf.ecore.EObject) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

DecoratingLabelProvider (org.eclipse.jface.viewers.DecoratingLabelProvider)11 WorkbenchLabelProvider (org.eclipse.ui.model.WorkbenchLabelProvider)10 IProject (org.eclipse.core.resources.IProject)7 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)7 ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)6 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)6 ElementTreeSelectionDialog (org.eclipse.ui.dialogs.ElementTreeSelectionDialog)6 ISelectionStatusValidator (org.eclipse.ui.dialogs.ISelectionStatusValidator)6 WorkbenchContentProvider (org.eclipse.ui.model.WorkbenchContentProvider)6 Composite (org.eclipse.swt.widgets.Composite)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 IFolder (org.eclipse.core.resources.IFolder)4 IWorkspace (org.eclipse.core.resources.IWorkspace)4 IStructuredContentProvider (org.eclipse.jface.viewers.IStructuredContentProvider)4 Viewer (org.eclipse.jface.viewers.Viewer)4 Control (org.eclipse.swt.widgets.Control)4 IDecoratorManager (org.eclipse.ui.IDecoratorManager)4 ListDialog (org.eclipse.ui.dialogs.ListDialog)4 ResourceSorter (org.eclipse.ui.views.navigator.ResourceSorter)4