use of org.eclipse.ui.model.WorkbenchContentProvider 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);
}
}
use of org.eclipse.ui.model.WorkbenchContentProvider in project n4js by eclipse.
the class CustomElementSelectionDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
CustomElementSelectionForm form = new CustomElementSelectionForm(parent, SWT.FILL);
form.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
TreeViewer v = form.getTreeViewer();
for (ViewerFilter filter : filters) {
v.addFilter(filter);
}
this.treeViewer = v;
WorkbenchContentProvider contentProvider = new WorkbenchContentProvider();
ILabelProvider labelProvider = new WorkbenchLabelProvider();
this.treeViewer.setContentProvider(contentProvider);
this.treeViewer.setLabelProvider(labelProvider);
this.treeViewer.setComparator(new ViewerComparator());
this.treeViewer.setAutoExpandLevel(this.getAutoExpandLevel());
form.setElementLabel(this.elementLabel);
this.elementNameInput = form.getElementInput();
form.getElementInput().addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(SuffixText.TEXT_PROPERTY) || evt.getPropertyName().equals(SuffixText.SUFFIX_PROPERTY)) {
validateElementInput();
elementInputChanged();
}
}
});
return form;
}
use of org.eclipse.ui.model.WorkbenchContentProvider in project n4js by eclipse.
the class AbstractExportToSingleFileWizardPage method getContentProvider.
/**
* Returns a content provider for the list dialog. It will return all projects in the workspace except the given
* project, plus any projects referenced by the given project which do no exist in the workspace.
*
* @return the content provider that shows the project content
*/
private IStructuredContentProvider getContentProvider() {
return new WorkbenchContentProvider() {
@Override
public Object[] getChildren(Object o) {
if (!(o instanceof IWorkspace)) {
return new Object[0];
}
// Collect all the projects in the workspace except the given project
IProject[] projects = ((IWorkspace) o).getRoot().getProjects();
List<IProject> applicableProjects = Lists.newArrayList();
Optional<? extends IN4JSEclipseProject> projectOpt = null;
for (IProject candidate : projects) {
projectOpt = n4jsCore.create(candidate);
if (projectOpt.isPresent() && projectOpt.get().exists()) {
applicableProjects.add(candidate);
}
}
return applicableProjects.toArray(new IProject[applicableProjects.size()]);
}
};
}
use of org.eclipse.ui.model.WorkbenchContentProvider 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;
}
use of org.eclipse.ui.model.WorkbenchContentProvider 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
}
}
}
Aggregations