use of org.eclipse.ui.model.WorkbenchContentProvider in project tdi-studio-se by Talend.
the class SelectDeleteProjectDialog method getResourceProvider.
private ITreeContentProvider getResourceProvider(final int resourceType) {
return new WorkbenchContentProvider() {
@Override
public Object[] getChildren(Object o) {
if (o instanceof IContainer) {
IResource[] members = null;
try {
members = ((IContainer) o).members();
} catch (CoreException e) {
// just return an empty set of children
return new Object[0];
}
// filter out the desired resource types
ArrayList results = new ArrayList();
for (IResource member : members) {
// And the test bits with the resource types to see if they are what we want
if ((member.getType() & resourceType) > 0) {
results.add(member);
}
}
return results.toArray();
}
// input element case
if (o instanceof ArrayList) {
return ((ArrayList) o).toArray();
}
return new Object[0];
}
};
}
use of org.eclipse.ui.model.WorkbenchContentProvider in project tdi-studio-se by Talend.
the class TalendWizardArchiveFileResourceExportPage1 method getResourceProvider.
private ITreeContentProvider getResourceProvider(final int resourceType) {
return new WorkbenchContentProvider() {
@Override
public Object[] getChildren(Object o) {
if (o instanceof IContainer) {
IResource[] members = null;
try {
members = ((IContainer) o).members();
} catch (CoreException e) {
// just return an empty set of children
return new Object[0];
}
// filter out the desired resource types
ArrayList results = new ArrayList();
for (IResource member : members) {
// And the test bits with the resource types to see if they are what we want
if ((member.getType() & resourceType) > 0) {
results.add(member);
}
}
return results.toArray();
}
// input element case
if (o instanceof ArrayList) {
return ((ArrayList) o).toArray();
}
return new Object[0];
}
};
}
use of org.eclipse.ui.model.WorkbenchContentProvider in project tdi-studio-se by Talend.
the class AddResourceAction method run.
/**
* Prompts for a jar to add.
*
* @see IAction#run()
*/
@Override
public void run() {
// ViewerFilter filter = new ArchiveFilter(getSelectedJars());
ILabelProvider lp = new WorkbenchLabelProvider();
ITreeContentProvider cp = new WorkbenchContentProvider();
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), lp, cp);
dialog.setValidator(validator);
//$NON-NLS-1$
dialog.setTitle(Messages.getString("AddResourceAction.JARSecection"));
//$NON-NLS-1$
dialog.setMessage(Messages.getString("AddResourceAction.ChooseResource"));
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot().getProject(PluginConstant.COMPONENT_PROJECT));
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (dialog.open() == Window.OK) {
Object[] elements = dialog.getResult();
List<ILibEntry> res = new ArrayList<ILibEntry>();
for (int i = 0; i < elements.length; i++) {
IResource elem = (IResource) elements[i];
String name = elem.getName();
if (name.matches("(?i).*\\.(jar)\\b")) {
//$NON-NLS-1$
res.add(new JarLibEntry(elem));
}
if (name.matches("(?i).*\\.(pm)\\b")) {
//$NON-NLS-1$
res.add(new PmLibEntry(elem));
}
}
if (res.size() > 0) {
ILibEntry[] entries = new ILibEntry[res.size()];
getViewer().addEntries(res.toArray(entries));
}
}
}
use of org.eclipse.ui.model.WorkbenchContentProvider in project eclipse.platform.text by eclipse.
the class SelectResourcesDialog method getResourceProvider.
private ITreeContentProvider getResourceProvider(final int resourceType) {
return new WorkbenchContentProvider() {
@Override
public Object[] getChildren(Object o) {
if (o instanceof IWorkspaceRoot) {
HashSet<IResource> projects = new HashSet<>();
for (int i = 0; i < fInput.length; i++) {
IResource project = fInput[i].getProject();
if ((project.getType() & resourceType) > 0)
projects.add(project);
}
return projects.toArray();
}
if (o instanceof IContainer) {
IResource[] members = null;
try {
members = ((IContainer) o).members();
} catch (CoreException e) {
// just return an empty set of children
return new Object[0];
}
// filter out the desired resource types
ArrayList<IResource> results = new ArrayList<>();
for (int i = 0; i < members.length; i++) {
// And the test bits with the resource types to see if they are what we want
if ((members[i].getType() & resourceType) > 0 && (resourceType != IResource.FILE || fAcceptableLocationsFilter == null || fAcceptableLocationsFilter.accept(members[i]))) {
results.add(members[i]);
}
}
return results.toArray();
}
// input element case
if (o instanceof ArrayList)
return ((ArrayList<?>) o).toArray();
return new Object[0];
}
};
}
use of org.eclipse.ui.model.WorkbenchContentProvider in project linuxtools by eclipse.
the class SystemTapOptionsTab method createFileOption.
private void createFileOption(Composite top) {
Composite browseTop = new Composite(top, SWT.NONE);
browseTop.setLayout(new GridLayout(4, false));
browseTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label suppFileLabel = new Label(browseTop, SWT.NONE);
// $NON-NLS-1$
suppFileLabel.setText(Messages.getString("SystemTapOptionsTab.ScriptSelector"));
scriptFile = new Text(browseTop, SWT.BORDER);
scriptFile.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
scriptFile.addModifyListener(modifyListener);
// $NON-NLS-1$
workspaceBrowseButton = createPushButton(browseTop, Messages.getString("SystemTapOptionsTab.WorkspaceButton"), null);
workspaceBrowseButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
// $NON-NLS-1$
dialog.setTitle(Messages.getString("SystemTapOptionsTab.ResourceButton"));
// $NON-NLS-1$
dialog.setMessage(Messages.getString("SystemTapOptionsTab.SuppresionsFile"));
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (dialog.open() == IDialogConstants.OK_ID) {
IResource resource = (IResource) dialog.getFirstResult();
String arg = resource.getFullPath().toString();
scriptFile.setText(workspacePath + arg);
}
}));
// $NON-NLS-1$
fileBrowseButton = createPushButton(browseTop, Messages.getString("SystemTapOptionsTab.FileSystem"), null);
fileBrowseButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
String filePath = scriptFile.getText();
FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
filePath = dialog.open();
if (filePath != null) {
scriptFile.setText(filePath);
}
}));
Label binaryFileLabel = new Label(browseTop, SWT.NONE);
// $NON-NLS-1$
binaryFileLabel.setText(Messages.getString("SystemTapOptionsTab.SelectBinary"));
binaryFile = new Text(browseTop, SWT.BORDER);
binaryFile.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
binaryFile.addModifyListener(modifyListener);
// $NON-NLS-1$
Button workspaceBrowseButton2 = createPushButton(browseTop, Messages.getString("SystemTapOptionsTab.WorkspaceButton2"), null);
workspaceBrowseButton2.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
// $NON-NLS-1$
dialog.setTitle(Messages.getString("SystemTapOptionsTab.SelectResource"));
// $NON-NLS-1$
dialog.setMessage(Messages.getString("SystemTapOptionsTab.SelectSuppressions"));
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (dialog.open() == IDialogConstants.OK_ID) {
IResource resource = (IResource) dialog.getFirstResult();
String arg = resource.getFullPath().toString();
binaryFile.setText(workspacePath + arg);
}
}));
// $NON-NLS-1$
Button fileBrowseButton2 = createPushButton(browseTop, Messages.getString("SystemTapOptionsTab.BrowseFiles"), null);
fileBrowseButton2.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
String filePath = binaryFile.getText();
FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
filePath = dialog.open();
if (filePath != null) {
File file = new File(filePath);
if (file.exists())
binaryFile.setText(filePath);
}
}));
Label outputFileLabel = new Label(browseTop, SWT.NONE);
// $NON-NLS-1$
outputFileLabel.setText(Messages.getString("SystemTapOptionsTab.SelectOutput"));
outputFile = new Text(browseTop, SWT.BORDER);
outputFile.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
outputFile.addModifyListener(modifyListenerOutput);
outputFile.addFocusListener(focusListener);
// $NON-NLS-1$
Button workspaceBrowseButton3 = createPushButton(browseTop, Messages.getString("SystemTapOptionsTab.WorkspaceButton2"), null);
workspaceBrowseButton3.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
// $NON-NLS-1$
dialog.setTitle(Messages.getString("SystemTapOptionsTab.SelectResource"));
// $NON-NLS-1$
dialog.setMessage(Messages.getString("SystemTapOptionsTab.SelectSuppressions"));
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
if (dialog.open() == IDialogConstants.OK_ID) {
IResource resource = (IResource) dialog.getFirstResult();
String arg = resource.getFullPath().toString();
outputFile.setText(workspacePath + arg);
checkOverwrite();
updateLaunchConfigurationDialog();
}
}));
// $NON-NLS-1$
Button fileBrowseButton3 = createPushButton(browseTop, Messages.getString("SystemTapOptionsTab.BrowseFiles"), null);
fileBrowseButton3.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
String filePath = outputFile.getText();
FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
filePath = dialog.open();
if (filePath != null) {
outputFile.setText(filePath);
checkOverwrite();
updateLaunchConfigurationDialog();
}
}));
useColourButton = new Button(browseTop, SWT.CHECK);
// $NON-NLS-1$
useColourButton.setText(Messages.getString("SystemTapOptionsTab.ColourCodes"));
useColourButton.addSelectionListener(selectListener);
useColourButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
Aggregations