use of org.eclipse.ui.model.WorkbenchContentProvider in project webtools.sourceediting by eclipse.
the class ProcessorLibraryBlock method addWorkspace.
private void addWorkspace(IStructuredSelection selection) {
IDialogSettings dialogSettings = XSLDebugUIPlugin.getDefault().getDialogSettings();
String lastUsedPath = dialogSettings.get(LAST_WORKSPACE_PATH_SETTING);
IPath lastPath = null;
if (lastUsedPath != null) {
lastPath = Path.fromPortableString(lastUsedPath);
}
// IResource currentResource = getResource();
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(tableViewer.getControl().getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setTitle(Messages.ProcessorLibraryBlock_WorkspaceFileDialog_Title);
dialog.setMessage(Messages.ProcessorLibraryBlock_WorkspaceFileDialog_Message);
dialog.setValidator(validator);
dialog.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IContainer)
return true;
else if (element instanceof IFile) {
IFile file = (IFile) element;
String extension = file.getFileExtension();
if (extension == null)
return false;
// $NON-NLS-1$
return extension.equals("jar");
}
return false;
}
});
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
if (lastPath != null)
dialog.setInitialSelection(lastPath);
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
dialog.setAllowMultiple(true);
if (dialog.open() == Window.OK) {
Object[] elements = dialog.getResult();
if (elements.length > 0) {
IProcessorJar[] libs = new IProcessorJar[elements.length];
for (int i = 0; i < elements.length; i++) {
IFile jar = (IFile) elements[i];
libs[i] = JAXPRuntime.createProcessorJar(jar.getFullPath());
}
IProcessorJar[] currentJars = install.getProcessorJars();
IProcessorJar[] newJars = new IProcessorJar[currentJars.length + libs.length];
System.arraycopy(currentJars, 0, newJars, 0, currentJars.length);
System.arraycopy(libs, 0, newJars, currentJars.length, libs.length);
install.setProcessorJars(newJars);
tableViewer.add(libs);
lastPath = libs[0].getPath();
lastPath = lastPath.uptoSegment(lastPath.segmentCount());
dialogSettings.put(LAST_WORKSPACE_PATH_SETTING, lastPath.toPortableString());
}
}
}
use of org.eclipse.ui.model.WorkbenchContentProvider in project bndtools by bndtools.
the class ProjectLaunchTabPiece method doBrowseBndrun.
void doBrowseBndrun() {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(launchTargetTxt.getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setValidator(new ISelectionStatusValidator() {
@Override
public IStatus validate(Object[] selection) {
if (selection.length > 0 && selection[0] instanceof IFile) {
// $NON-NLS-1$
return new Status(IStatus.OK, Plugin.PLUGIN_ID, IStatus.OK, "", null);
}
// $NON-NLS-1$
return new Status(IStatus.ERROR, Plugin.PLUGIN_ID, IStatus.ERROR, "", null);
}
});
dialog.setAllowMultiple(false);
dialog.setTitle("Run File Selection");
dialog.setMessage("Select the Run File to launch.");
dialog.addFilter(new FileExtensionFilter(LaunchConstants.EXT_BNDRUN));
dialog.setInput(ResourcesPlugin.getWorkspace());
if (dialog.open() == Window.OK) {
Object[] files = dialog.getResult();
if (files != null && files.length == 1) {
IPath path = ((IResource) files[0]).getFullPath().makeRelative();
launchTargetTxt.setText(path.toString());
} else {
launchTargetTxt.setText("");
}
}
}
use of org.eclipse.ui.model.WorkbenchContentProvider in project bndtools by bndtools.
the class RunDescriptorTargetLocationPage method createRunDescriptorSelectionArea.
private TreeViewer createRunDescriptorSelectionArea(Composite composite) {
final TreeViewer projectTree = new TreeViewer(new Tree(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER));
projectTree.getTree().setLayoutData(fillGridData(1));
projectTree.setContentProvider(new WorkbenchContentProvider());
projectTree.setLabelProvider(new WorkbenchLabelProvider());
projectTree.setInput(ResourcesPlugin.getWorkspace());
projectTree.setFilters(getProjectTreeFilters());
projectTree.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
Object selection = ((ITreeSelection) event.getSelection()).getFirstElement();
if (selection != null && selection instanceof IFile) {
runDescriptorFile = (IFile) selection;
} else {
runDescriptorFile = null;
}
updateTarget();
}
});
projectTree.expandAll();
return projectTree;
}
use of org.eclipse.ui.model.WorkbenchContentProvider in project bndtools by bndtools.
the class AddFilesToRepositoryWizardPage method doAdd.
void doAdd() {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setValidator(new ISelectionStatusValidator() {
@Override
public IStatus validate(Object[] selection) {
if (selection.length > 0 && selection[0] instanceof IFile) {
// $NON-NLS-1$
return new Status(IStatus.OK, Plugin.PLUGIN_ID, IStatus.OK, "", null);
}
// $NON-NLS-1$
return new Status(IStatus.ERROR, Plugin.PLUGIN_ID, IStatus.ERROR, "", null);
}
});
dialog.setAllowMultiple(true);
dialog.setTitle("JAR File Selection");
// $NON-NLS-1$
dialog.addFilter(new FileExtensionFilter("jar"));
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
if (dialog.open() == Window.OK) {
Object[] result = dialog.getResult();
List<File> added = new ArrayList<File>(result.length);
for (Object fileObj : result) {
IFile ifile = (IFile) fileObj;
File file = ifile.getLocation().toFile();
analyseFile(file);
files.add(file);
added.add(file);
}
if (!added.isEmpty()) {
viewer.add(added.toArray());
validate();
}
}
}
use of org.eclipse.ui.model.WorkbenchContentProvider in project mechanoid by robotoworks.
the class PackageBrowserField method onBrowseButtonPressed.
@Override
protected void onBrowseButtonPressed() {
Shell shell = PlatformUI.getWorkbench().getModalDialogShellProvider().getShell();
ListDialog dialog = new ListDialog(shell);
dialog.setContentProvider(new WorkbenchContentProvider());
dialog.setInput("hi");
dialog.setLabelProvider(new WorkbenchLabelProvider());
dialog.setBlockOnOpen(true);
if (dialog.open() == Window.OK) {
// TODO
}
}
Aggregations