Search in sources :

Example 1 with MinimizedFileSystemElement

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);
    }
}
Also used : WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) ContainerFileProxy(org.eclipse.linuxtools.internal.docker.core.ContainerFileProxy) BusyIndicator(org.eclipse.swt.custom.BusyIndicator) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) ContainerDirectorySelectionDialog(org.eclipse.linuxtools.internal.docker.ui.ContainerDirectorySelectionDialog) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) ContainerFileSystemProvider(org.eclipse.linuxtools.internal.docker.ui.ContainerFileSystemProvider) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) FocusListener(org.eclipse.swt.events.FocusListener) Event(org.eclipse.swt.widgets.Event) ArrayList(java.util.ArrayList) IStatus(org.eclipse.core.runtime.IStatus) IPath(org.eclipse.core.runtime.IPath) Composite(org.eclipse.swt.widgets.Composite) Map(java.util.Map) BidiUtils(org.eclipse.jface.util.BidiUtils) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) GridData(org.eclipse.swt.layout.GridData) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) Hashtable(java.util.Hashtable) MinimizedFileSystemElement(org.eclipse.linuxtools.internal.docker.ui.MinimizedFileSystemElement) Text(org.eclipse.swt.widgets.Text) WizardResourceImportPage(org.eclipse.ui.dialogs.WizardResourceImportPage) Combo(org.eclipse.swt.widgets.Combo) Shell(org.eclipse.swt.widgets.Shell) Iterator(java.util.Iterator) IDEFileSystemStructureProvider(org.eclipse.linuxtools.internal.docker.ui.IDEFileSystemStructureProvider) Button(org.eclipse.swt.widgets.Button) NLS(org.eclipse.osgi.util.NLS) PlatformUI(org.eclipse.ui.PlatformUI) FileSystemElement(org.eclipse.ui.dialogs.FileSystemElement) Collection(java.util.Collection) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IImportStructureProvider(org.eclipse.ui.wizards.datatransfer.IImportStructureProvider) File(java.io.File) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) List(java.util.List) SWTImagesFactory(org.eclipse.linuxtools.internal.docker.ui.SWTImagesFactory) Path(org.eclipse.core.runtime.Path) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) SWT(org.eclipse.swt.SWT) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog) KeyListener(org.eclipse.swt.events.KeyListener) Label(org.eclipse.swt.widgets.Label) IElementFilter(org.eclipse.ui.ide.dialogs.IElementFilter) SelectionListener(org.eclipse.swt.events.SelectionListener) GridLayout(org.eclipse.swt.layout.GridLayout) Hashtable(java.util.Hashtable) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ArrayList(java.util.ArrayList) IElementFilter(org.eclipse.ui.ide.dialogs.IElementFilter) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MinimizedFileSystemElement(org.eclipse.linuxtools.internal.docker.ui.MinimizedFileSystemElement) Iterator(java.util.Iterator) MinimizedFileSystemElement(org.eclipse.linuxtools.internal.docker.ui.MinimizedFileSystemElement) FileSystemElement(org.eclipse.ui.dialogs.FileSystemElement) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map)

Example 2 with MinimizedFileSystemElement

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);
}
Also used : MinimizedFileSystemElement(org.eclipse.linuxtools.internal.docker.ui.MinimizedFileSystemElement)

Example 3 with MinimizedFileSystemElement

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;
}
Also used : ContainerFileProxy(org.eclipse.linuxtools.internal.docker.core.ContainerFileProxy) MinimizedFileSystemElement(org.eclipse.linuxtools.internal.docker.ui.MinimizedFileSystemElement) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList)

Example 4 with MinimizedFileSystemElement

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();
    }
}
Also used : ContainerFileProxy(org.eclipse.linuxtools.internal.docker.core.ContainerFileProxy) MinimizedFileSystemElement(org.eclipse.linuxtools.internal.docker.ui.MinimizedFileSystemElement) ArrayList(java.util.ArrayList)

Example 5 with MinimizedFileSystemElement

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;
}
Also used : MinimizedFileSystemElement(org.eclipse.linuxtools.internal.docker.ui.MinimizedFileSystemElement)

Aggregations

MinimizedFileSystemElement (org.eclipse.linuxtools.internal.docker.ui.MinimizedFileSystemElement)5 ArrayList (java.util.ArrayList)3 ContainerFileProxy (org.eclipse.linuxtools.internal.docker.core.ContainerFileProxy)3 Iterator (java.util.Iterator)2 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Collection (java.util.Collection)1 Hashtable (java.util.Hashtable)1 List (java.util.List)1 Map (java.util.Map)1 IPath (org.eclipse.core.runtime.IPath)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 Path (org.eclipse.core.runtime.Path)1 IDialogConstants (org.eclipse.jface.dialogs.IDialogConstants)1 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 BidiUtils (org.eclipse.jface.util.BidiUtils)1