use of org.eclipse.linuxtools.internal.docker.ui.MinimizedFileSystemElement in project linuxtools by eclipse.
the class ContainerCopyToPage method setupSelectionsBasedOnSelectedTypes.
/**
* Update the tree to only select those elements that match the selected
* types
*/
@SuppressWarnings("rawtypes")
@Override
protected void setupSelectionsBasedOnSelectedTypes() {
ProgressMonitorDialog dialog = new ProgressMonitorDialog(getContainer().getShell());
final Map selectionMap = new Hashtable();
final IElementFilter filter = new IElementFilter() {
@Override
public void filterElements(Collection files, IProgressMonitor monitor) throws InterruptedException {
if (files == null) {
throw new InterruptedException();
}
Iterator filesList = files.iterator();
while (filesList.hasNext()) {
if (monitor.isCanceled()) {
throw new InterruptedException();
}
checkFile(filesList.next());
}
}
@Override
public void filterElements(Object[] files, IProgressMonitor monitor) throws InterruptedException {
if (files == null) {
throw new InterruptedException();
}
for (int i = 0; i < files.length; i++) {
if (monitor.isCanceled()) {
throw new InterruptedException();
}
checkFile(files[i]);
}
}
@SuppressWarnings("unchecked")
private void checkFile(Object fileElement) {
MinimizedFileSystemElement file = (MinimizedFileSystemElement) fileElement;
if (isExportableExtension(file.getFileNameExtension())) {
List elements = new ArrayList();
FileSystemElement parent = file.getParent();
if (selectionMap.containsKey(parent)) {
elements = (List) selectionMap.get(parent);
}
elements.add(file);
selectionMap.put(parent, elements);
}
}
};
IRunnableWithProgress runnable = monitor -> {
monitor.beginTask(CopyToContainerMessages.ImportPage_filterSelections, IProgressMonitor.UNKNOWN);
getSelectedResources(filter, monitor);
};
try {
dialog.run(true, true, runnable);
} catch (InvocationTargetException exception) {
// Couldn't start. Do nothing.
return;
} catch (InterruptedException exception) {
// Got interrupted. Do nothing.
return;
}
// make sure that all paint operations caused by closing the progress
// dialog get flushed, otherwise extra pixels will remain on the screen
// until
// updateSelections is completed
getShell().update();
// a new process.
if (selectionMap != null) {
updateSelections(selectionMap);
}
}
use of org.eclipse.linuxtools.internal.docker.ui.MinimizedFileSystemElement in project linuxtools by eclipse.
the class ContainerCopyToPage method resetSelection.
/**
* Repopulate the view based on the currently entered directory.
*/
protected void resetSelection() {
MinimizedFileSystemElement currentRoot = getFileSystemTree();
this.selectionGroup.setRoot(currentRoot);
}
use of org.eclipse.linuxtools.internal.docker.ui.MinimizedFileSystemElement in project linuxtools by eclipse.
the class ContainerCopyFrom method performFinish.
@Override
public boolean performFinish() {
target = mainPage.getTarget();
@SuppressWarnings("rawtypes") Iterator iterator = mainPage.getValueIterator();
ArrayList<ContainerFileProxy> copyList = new ArrayList<>();
while (iterator.hasNext()) {
MinimizedFileSystemElement e = (MinimizedFileSystemElement) iterator.next();
ContainerFileProxy p = (ContainerFileProxy) e.getFileSystemObject();
copyList.add(p);
}
sources = copyList;
return true;
}
use of org.eclipse.linuxtools.internal.docker.ui.MinimizedFileSystemElement in project linuxtools by eclipse.
the class ContainerCopyFromPage method getValueIterator.
/*
* Get an iterator for the selected items to copy
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public Iterator getValueIterator() {
if (canBrowseContainer) {
return selectionGroup.getAllWhiteCheckedItems();
} else {
// We need to fake a collection of MinimizedFileSystemElement with
// one element.
ArrayList out = new ArrayList();
String sourceName = sourceText.getText();
MinimizedFileSystemElement element = new MinimizedFileSystemElement(sourceName, null, false);
element.setFileSystemObject(// $NON-NLS-1$
new ContainerFileProxy(sourceName, "", false));
out.add(element);
return out.iterator();
}
}
use of org.eclipse.linuxtools.internal.docker.ui.MinimizedFileSystemElement in project linuxtools by eclipse.
the class ContainerCopyToPage method createRootElement.
/**
* Creates and returns a <code>FileSystemElement</code> if the specified
* file system object merits one. The criteria for this are: Also create the
* children.
*/
protected MinimizedFileSystemElement createRootElement(Object fileSystemObject, IImportStructureProvider provider) {
boolean isContainer = provider.isFolder(fileSystemObject);
String elementLabel = provider.getLabel(fileSystemObject);
// Use an empty label so that display of the element's full name
// doesn't include a confusing label
MinimizedFileSystemElement dummyParent = new MinimizedFileSystemElement("", null, // $NON-NLS-1$
true);
dummyParent.setPopulated();
MinimizedFileSystemElement result = new MinimizedFileSystemElement(elementLabel, dummyParent, isContainer);
result.setFileSystemObject(fileSystemObject);
// Get the files for the element so as to build the first level
result.getFiles(provider);
return dummyParent;
}
Aggregations