use of org.eclipse.ui.model.WorkbenchContentProvider 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
}
}
}
}
}
use of org.eclipse.ui.model.WorkbenchContentProvider in project jbosstools-openshift by jbosstools.
the class UIUtils method createFileDialog.
/**
* Create a file selection dialog.
*
* @param selectedFile the initial selected file. May be null
* @param title the title of the dialog
* @param message the message of the dialog
* @param extension the extension to filter. If null or empty, all files are accepted
* @param initialSelection the initial selection resource (used if selectedFile is null)
* @return the dialog
*/
public static ElementTreeSelectionDialog createFileDialog(String selectedFile, String title, String message, String extension, IResource initialSelection) {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setTitle(title);
dialog.setMessage(message);
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
dialog.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return element instanceof IContainer || (element instanceof IFile && (StringUtils.isEmpty(extension) || extension.equals(((IFile) element).getFileExtension())));
}
});
dialog.setAllowMultiple(false);
if (StringUtils.isNotBlank(selectedFile)) {
String prefix = "${workspace_loc:";
String path = selectedFile;
if (selectedFile.startsWith(prefix) && selectedFile.endsWith("}")) {
path = path.substring(prefix.length(), path.length() - 1);
}
initialSelection = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
}
if (initialSelection != null) {
dialog.setInitialSelection(initialSelection);
}
return dialog;
}
use of org.eclipse.ui.model.WorkbenchContentProvider in project jbosstools-openshift by jbosstools.
the class ServerSettingsWizardPage method createWorkspaceFolderDialog.
private ElementTreeSelectionDialog createWorkspaceFolderDialog(Shell shell, String selectedFile) {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setTitle("Select a workspace folder");
dialog.setMessage("Select a workspace folder to deploy");
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
dialog.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (!(element instanceof IContainer)) {
return false;
}
IContainer container = (IContainer) element;
return container.isAccessible() && !ProjectUtils.isInternalPde(container.getName()) && !ProjectUtils.isInternalRSE(container.getName());
}
});
dialog.setAllowMultiple(false);
org.eclipse.core.resources.IResource res = model.getDeployProject();
if (org.apache.commons.lang.StringUtils.isNotBlank(selectedFile)) {
String path = VariablesHelper.getWorkspacePath(selectedFile);
org.eclipse.core.resources.IResource member = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
if (member != null) {
res = member;
}
}
if (res != null) {
dialog.setInitialSelection(res);
}
return dialog;
}
use of org.eclipse.ui.model.WorkbenchContentProvider in project tdq-studio-se by Talend.
the class DQRuleSelectPage method createControl.
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
FillLayout layout = new FillLayout();
container.setLayout(layout);
cViewer = new ContainerCheckedTreeViewer(container, SWT.NONE);
cViewer.setLabelProvider(new DQRuleLabelProvider());
cViewer.setContentProvider(new WorkbenchContentProvider());
cViewer.setInput(ResourceManager.getLibrariesFolder());
// ADD mzhao bug TDQ-4188 hide the .svn folders.
cViewer.addFilter(new DQFolderFilter(true));
cViewer.addFilter(new RuleFolderFliter(true));
cViewer.addFilter(AnalysisUtils.createRuleFilter());
setControl(container);
}
use of org.eclipse.ui.model.WorkbenchContentProvider in project whole by wholeplatform.
the class OperationLauncherRegistry method openJavaSourceFoldersDialog.
public static IContainer[] openJavaSourceFoldersDialog(Shell shell, boolean allowMultipleSelection) {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setValidator(new JavaSourceFolderValidator());
dialog.setTitle("Java Source Folder Selection");
dialog.setMessage("Choose a destination folder for generated code");
dialog.addFilter(new JavaSourceFolderFilter());
dialog.setInput(JDTUtils.getWorkspaceRoot());
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
dialog.setAllowMultiple(allowMultipleSelection);
if (dialog.open() == Window.OK) {
Object[] elements = dialog.getResult();
IContainer[] containers = new IContainer[elements.length];
for (int i = 0; i < containers.length; i++) containers[i] = (IContainer) elements[i];
return containers;
}
return new IContainer[0];
}
Aggregations