use of org.eclipse.ui.model.WorkbenchContentProvider in project whole by wholeplatform.
the class ReplaceWithResourceAction method performWorkspaceResourceSelection.
protected boolean performWorkspaceResourceSelection(Shell shell, IEntity entity) {
IPath filePath = Path.fromPortableString(path);
IResource resource = filePath.isAbsolute() ? ResourcesPlugin.getWorkspace().getRoot().findMember(filePath) : null;
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setInput(ResourcesPlugin.getWorkspace());
dialog.setTitle(SELECT_RESOURCE_MSG);
dialog.setMessage("Choose a resource");
dialog.setInitialSelection(resource);
if (dialog.open() != IDialogConstants.OK_ID)
return false;
Object[] selection = dialog.getResult();
path = selection.length == 0 ? "/" : ((IResource) selection[0]).getFullPath().toPortableString();
return true;
}
use of org.eclipse.ui.model.WorkbenchContentProvider in project whole by wholeplatform.
the class WizardArtifactsModelImportPage1 method createSourceGroup.
@Override
protected void createSourceGroup(Composite parent) {
resourceChooser = new TreeViewer(parent);
GridLayout listAreaLayout = new GridLayout();
listAreaLayout.marginWidth = 0;
parent.setLayout(listAreaLayout);
resourceChooser.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
resourceChooser.setContentProvider(new WorkbenchContentProvider());
resourceChooser.setLabelProvider(new WorkbenchLabelProvider());
resourceChooser.setComparator(new WorkbenchViewerComparator());
resourceChooser.setInput(ResourcesPlugin.getWorkspace());
resourceChooser.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
updatePageCompletion();
}
});
}
use of org.eclipse.ui.model.WorkbenchContentProvider in project ecf by eclipse.
the class RemotePeerSynchronizeWizardPage method createResourcesViewer.
private void createResourcesViewer(Composite composite) {
resourcesViewer = new ContainerCheckedTreeViewer(composite);
resourcesViewer.setContentProvider(new WorkbenchContentProvider() {
public Object[] getChildren(Object element) {
if (element instanceof org.eclipse.core.resources.IContainer) {
try {
IResource[] members = ((org.eclipse.core.resources.IContainer) element).members();
List nonDerivedMembers = new ArrayList();
for (int i = 0; i < members.length; i++) {
if (!members[i].isDerived()) {
nonDerivedMembers.add(members[i]);
}
}
return nonDerivedMembers.toArray();
} catch (CoreException e) {
return new IResource[0];
}
}
return new IResource[0];
}
public boolean hasChildren(Object element) {
if (element instanceof org.eclipse.core.resources.IContainer) {
try {
IResource[] members = ((org.eclipse.core.resources.IContainer) element).members();
for (int i = 0; i < members.length; i++) {
if (!members[i].isDerived()) {
return true;
}
}
return false;
} catch (CoreException e) {
return false;
}
}
return false;
}
});
resourcesViewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
resourcesViewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
}
use of org.eclipse.ui.model.WorkbenchContentProvider in project InformationSystem by ObeoNetwork.
the class SpecificWorkspaceResourceDialog method openFileSelection.
public static IFile openFileSelection(Shell parent, String title, String message, IPath suggestedPath, Collection<ViewerFilter> viewerFilters, String newFileExtension) {
final SpecificWorkspaceResourceDialog dialog = new SpecificWorkspaceResourceDialog(parent, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setNewFileExtension(newFileExtension);
dialog.setAllowMultiple(false);
dialog.setTitle(title != null ? title : CommonUIPlugin.INSTANCE.getString("_UI_NewFile_title"));
dialog.setMessage(message);
dialog.setShowNewFolderControl(true);
dialog.setShowFileControl(true);
dialog.addFilter(dialog.createDefaultViewerFilter(true));
if (viewerFilters != null) {
for (ViewerFilter viewerFilter : viewerFilters) {
dialog.addFilter(viewerFilter);
}
}
if (suggestedPath != null) {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IResource resource = root.findMember(suggestedPath);
if (resource != null && resource.isAccessible()) {
if (resource instanceof IContainer) {
dialog.setInitialSelection(resource);
} else {
dialog.setInitialSelection(resource.getParent());
dialog.setFileText(resource.getName());
}
} else {
if (suggestedPath.segmentCount() > 1) {
if (resource == null) {
resource = root.getFile(suggestedPath);
}
if (resource.getProject().isAccessible()) {
IContainer container = resource.getParent();
for (; !container.isAccessible() && container != resource.getProject(); container = container.getParent()) {
// Do nothing
}
dialog.setInitialSelection(container);
suggestedPath = suggestedPath.removeFirstSegments(container.getFullPath().segmentCount());
dialog.setFileText(suggestedPath.toString());
suggestedPath = null;
}
}
if (suggestedPath != null) {
String fileText = suggestedPath.isAbsolute() ? suggestedPath.removeFirstSegments(1).toString() : suggestedPath.toString();
dialog.setFileText(fileText);
}
}
}
dialog.loadContents();
return dialog.open() == Window.OK ? dialog.getFile() : null;
}
use of org.eclipse.ui.model.WorkbenchContentProvider in project webtools.servertools by eclipse.
the class AntBuildFileSelectionEditorSection method createSection.
public void createSection(final Composite parent) {
super.createSection(parent);
FormToolkit formToolkit = getFormToolkit(parent.getDisplay());
Section section = formToolkit.createSection(parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED | ExpandableComposite.TITLE_BAR | Section.DESCRIPTION);
section.setText(GenericServerUIMessages.AntPublisherSectionHeading);
section.setDescription(GenericServerUIMessages.AntPublisherSectionDescription);
section.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
Composite composite = formToolkit.createComposite(section);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
layout.marginHeight = 5;
layout.marginWidth = 10;
layout.verticalSpacing = 5;
layout.horizontalSpacing = 15;
composite.setLayout(layout);
composite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
Label buildFileLabel = formToolkit.createLabel(composite, GenericServerUIMessages.LabelBuildFile);
buildFileLabel.setForeground(formToolkit.getColors().getColor(IFormColors.TITLE));
// $NON-NLS-1$
buildFileText = formToolkit.createText(composite, "");
String oldValue = // $NON-NLS-1$
fServer.getServerInstanceProperties().get(GenericServer.PROP_CUSTOM_BUILD_SCRIPT) == null ? // $NON-NLS-1$
"" : (String) fServer.getServerInstanceProperties().get(GenericServer.PROP_CUSTOM_BUILD_SCRIPT);
buildFileText.setText(oldValue);
buildFileText.addListener(SWT.Modify, new Listener() {
public void handleEvent(Event event) {
executeUpdateOperation(GenericServer.PROP_CUSTOM_BUILD_SCRIPT, buildFileText.getText());
}
});
GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
buildFileText.setLayoutData(gridData);
Button buildFileBtn = formToolkit.createButton(composite, GenericServerUIMessages.ButtonBrowseForBuildFile, SWT.PUSH);
buildFileBtn.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(parent.getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
// dialog.setValidator(new FileValidator());
dialog.setAllowMultiple(false);
dialog.setTitle(GenericServerUIMessages.AntBuildDialogTitle);
dialog.setMessage(GenericServerUIMessages.AntBuildDialogDescription);
dialog.addFilter(new BuildFileFilter());
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
if (dialog.open() == Window.OK) {
IFile file = (IFile) dialog.getFirstResult();
// $NON-NLS-1$
buildFileText.setText(VariablesPlugin.getDefault().getStringVariableManager().generateVariableExpression("workspace_loc", file.getFullPath().toString()));
}
}
});
formToolkit.paintBordersFor(composite);
section.setClient(composite);
}
Aggregations