Search in sources :

Example 1 with IDecoratorManager

use of org.eclipse.ui.IDecoratorManager in project liferay-ide by liferay.

the class NewCustomJSPsHookWizardPage method handleFileBrowseButton.

protected void handleFileBrowseButton(Text text) {
    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(J2EEUIMessages.CONTAINER_SELECTION_DIALOG_TITLE);
    dialog.setMessage(J2EEUIMessages.CONTAINER_SELECTION_DIALOG_DESC);
    dialog.addFilter(filter);
    dialog.setInput(CoreUtil.getWorkspaceRoot());
    if (dialog.open() == Window.OK) {
        Object element = dialog.getFirstResult();
        try {
            if (element instanceof IFolder) {
                IFolder folder = (IFolder) element;
                IProject project = CoreUtil.getProject(getDataModel().getStringProperty(PROJECT_NAME));
                IWebProject webproject = LiferayCore.create(IWebProject.class, project);
                if (webproject != null) {
                    IFolder defaultWebappRootFolder = webproject.getDefaultDocrootFolder();
                    if (folder.equals(defaultWebappRootFolder)) {
                        folder = folder.getFolder("custom_jsps");
                    }
                    String defaultWebappRootFolderFullPath = defaultWebappRootFolder.getFullPath().toPortableString();
                    String folderFullPath = folder.getFullPath().toPortableString();
                    int index = folderFullPath.indexOf(defaultWebappRootFolderFullPath);
                    if (index != -1) {
                        folderFullPath = folderFullPath.substring(index + defaultWebappRootFolderFullPath.length());
                    }
                    text.setText(folderFullPath);
                }
            }
        } 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) 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) IProject(org.eclipse.core.resources.IProject) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) ISelectionStatusValidator(org.eclipse.ui.dialogs.ISelectionStatusValidator) IFolder(org.eclipse.core.resources.IFolder)

Example 2 with IDecoratorManager

use of org.eclipse.ui.IDecoratorManager in project liferay-ide by liferay.

the class NewLanguagePropertiesHookWizardPage method handleFileBrowseButton.

protected void handleFileBrowseButton(Text text) {
    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(J2EEUIMessages.CONTAINER_SELECTION_DIALOG_TITLE);
    dialog.setMessage(J2EEUIMessages.CONTAINER_SELECTION_DIALOG_DESC);
    dialog.addFilter(filter);
    dialog.setInput(CoreUtil.getWorkspaceRoot());
    if (dialog.open() == Window.OK) {
        Object element = dialog.getFirstResult();
        try {
            if (element instanceof IFolder) {
                IFolder folder = (IFolder) element;
                IProject project = CoreUtil.getProject(getDataModel().getStringProperty(PROJECT_NAME));
                List<IFolder> sources = CoreUtil.getSourceFolders(JavaCore.create(project));
                if (ListUtil.isNotEmpty(sources) && folder.equals(sources.get(0))) {
                    folder = folder.getFolder("content");
                }
                text.setText(folder.getFullPath().toPortableString());
            }
        } 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) IDecoratorManager(org.eclipse.ui.IDecoratorManager) DecoratingLabelProvider(org.eclipse.jface.viewers.DecoratingLabelProvider) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) IProject(org.eclipse.core.resources.IProject) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) ISelectionStatusValidator(org.eclipse.ui.dialogs.ISelectionStatusValidator) IFolder(org.eclipse.core.resources.IFolder)

Example 3 with IDecoratorManager

use of org.eclipse.ui.IDecoratorManager in project liferay-ide by liferay.

the class NewPortalPropertiesHookWizardPage method handleBrowseButton.

protected void handleBrowseButton(Text text) {
    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(Msgs.portalPropertiesFile);
    dialog.setMessage(Msgs.portalPropertiesFile);
    dialog.addFilter(filter);
    dialog.setInput(CoreUtil.getWorkspaceRoot());
    if (dialog.open() == Window.OK) {
        Object element = dialog.getFirstResult();
        try {
            if (element instanceof IFile) {
                IFile file = (IFile) element;
                text.setText(file.getFullPath().toPortableString());
            } else if (element instanceof IFolder) {
                IFolder folder = (IFolder) element;
                IPath portalPropertiesPath = folder.getFullPath().append("portal.properties");
                text.setText(portalPropertiesPath.toPortableString());
            }
        } 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) IDecoratorManager(org.eclipse.ui.IDecoratorManager) DecoratingLabelProvider(org.eclipse.jface.viewers.DecoratingLabelProvider) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) ISelectionStatusValidator(org.eclipse.ui.dialogs.ISelectionStatusValidator) IFolder(org.eclipse.core.resources.IFolder)

Example 4 with IDecoratorManager

use of org.eclipse.ui.IDecoratorManager in project derby by apache.

the class DerbyIsRunningDecorator method performUpdateDecor.

public static void performUpdateDecor(IProject proj) {
    IDecoratorManager dm = DerbyPlugin.getDefault().getWorkbench().getDecoratorManager();
    DerbyIsRunningDecorator decorator = (DerbyIsRunningDecorator) dm.getBaseLabelProvider(CommonNames.RUNDECORATOR);
    decorator.startUpdateDecor(proj);
}
Also used : IDecoratorManager(org.eclipse.ui.IDecoratorManager)

Example 5 with IDecoratorManager

use of org.eclipse.ui.IDecoratorManager 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

IDecoratorManager (org.eclipse.ui.IDecoratorManager)7 IFolder (org.eclipse.core.resources.IFolder)4 DecoratingLabelProvider (org.eclipse.jface.viewers.DecoratingLabelProvider)4 ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)4 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)4 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)4 ElementTreeSelectionDialog (org.eclipse.ui.dialogs.ElementTreeSelectionDialog)4 ISelectionStatusValidator (org.eclipse.ui.dialogs.ISelectionStatusValidator)4 WorkbenchContentProvider (org.eclipse.ui.model.WorkbenchContentProvider)4 WorkbenchLabelProvider (org.eclipse.ui.model.WorkbenchLabelProvider)4 IWebProject (com.liferay.ide.core.IWebProject)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 IPath (org.eclipse.core.runtime.IPath)2 CoreException (org.eclipse.core.runtime.CoreException)1 EObject (org.eclipse.emf.ecore.EObject)1 NotificationFilter (org.eclipse.emf.transaction.NotificationFilter)1 ResourceSetChangeEvent (org.eclipse.emf.transaction.ResourceSetChangeEvent)1 ResourceSetListenerImpl (org.eclipse.emf.transaction.ResourceSetListenerImpl)1 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)1