Search in sources :

Example 1 with ContainerFileProxy

use of org.eclipse.linuxtools.internal.docker.core.ContainerFileProxy in project linuxtools by eclipse.

the class ContainerCopyFrom method addPages.

@Override
public void addPages() {
    ProgressMonitorDialog pd = new ProgressMonitorDialog(Activator.getActiveWorkbenchShell());
    ContainerFileSystemProvider provider = new ContainerFileSystemProvider(connection, container.id());
    PopulateContainerFilesOperation sfo = new PopulateContainerFilesOperation(// $NON-NLS-1$ //$NON-NLS-2$
    new ContainerFileProxy("", "", true), null, provider);
    try {
        pd.run(true, true, sfo);
    } catch (InvocationTargetException | InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    boolean isRunning = EnumDockerStatus.fromStatusMessage(container.status()) == EnumDockerStatus.RUNNING;
    // we only want to browse a Container's file system if
    // it is running and it has specified to use a tty
    boolean usingTTY = false;
    if (isRunning) {
        IDockerContainerInfo info = connection.getContainerInfo(container.id());
        if (info != null) {
            usingTTY = info.config().tty();
        }
    }
    mainPage = new ContainerCopyFromPage(sfo.getResult(), provider, container.name(), isRunning && usingTTY);
    addPage(mainPage);
}
Also used : ContainerFileProxy(org.eclipse.linuxtools.internal.docker.core.ContainerFileProxy) ContainerFileSystemProvider(org.eclipse.linuxtools.internal.docker.ui.ContainerFileSystemProvider) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IDockerContainerInfo(org.eclipse.linuxtools.docker.core.IDockerContainerInfo) InvocationTargetException(java.lang.reflect.InvocationTargetException) PopulateContainerFilesOperation(org.eclipse.linuxtools.internal.docker.ui.PopulateContainerFilesOperation)

Example 2 with ContainerFileProxy

use of org.eclipse.linuxtools.internal.docker.core.ContainerFileProxy in project linuxtools by eclipse.

the class ContainerCopyTo method addPages.

@Override
public void addPages() {
    ProgressMonitorDialog pd = new ProgressMonitorDialog(Activator.getActiveWorkbenchShell());
    ContainerFileSystemProvider provider = new ContainerFileSystemProvider(connection, container.id());
    PopulateContainerFilesOperation sfo = new PopulateContainerFilesOperation(// $NON-NLS-1$ //$NON-NLS-2$
    new ContainerFileProxy("", "", true), null, provider);
    try {
        pd.run(true, true, sfo);
    } catch (InvocationTargetException | InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    boolean isRunning = EnumDockerStatus.fromStatusMessage(container.status()) == EnumDockerStatus.RUNNING;
    // we only want to browse a Container's file system if
    // it is running and it has specified to use a tty
    boolean usingTTY = false;
    if (isRunning) {
        IDockerContainerInfo info = connection.getContainerInfo(container.id());
        if (info != null) {
            usingTTY = info.config().tty();
        }
    }
    mainPage = new ContainerCopyToPage(sfo.getResult(), provider, container.name(), isRunning && usingTTY);
    addPage(mainPage);
}
Also used : ContainerFileProxy(org.eclipse.linuxtools.internal.docker.core.ContainerFileProxy) ContainerFileSystemProvider(org.eclipse.linuxtools.internal.docker.ui.ContainerFileSystemProvider) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IDockerContainerInfo(org.eclipse.linuxtools.docker.core.IDockerContainerInfo) InvocationTargetException(java.lang.reflect.InvocationTargetException) PopulateContainerFilesOperation(org.eclipse.linuxtools.internal.docker.ui.PopulateContainerFilesOperation)

Example 3 with ContainerFileProxy

use of org.eclipse.linuxtools.internal.docker.core.ContainerFileProxy 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 ContainerFileProxy

use of org.eclipse.linuxtools.internal.docker.core.ContainerFileProxy 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 ContainerFileProxy

use of org.eclipse.linuxtools.internal.docker.core.ContainerFileProxy in project linuxtools by eclipse.

the class ContainerCopyToPage method handleContainerBrowseButtonPressed.

@Override
protected void handleContainerBrowseButtonPressed() {
    ContainerDirectorySelectionDialog dialog = new ContainerDirectorySelectionDialog(sourceNameField.getShell(), this.root, this.provider, NLS.bind(CONTAINER_DIRECTORY_MSG, containerName));
    if (dialog.open() == IStatus.OK) {
        Object[] result = dialog.getResult();
        ContainerFileProxy proxy = (ContainerFileProxy) result[0];
        // If it is valid then proceed to populate
        setErrorMessage(null);
        setContainerFieldValue(proxy.getFullPath());
        selectionGroup.setFocus();
    }
    updateWidgetEnablements();
}
Also used : ContainerFileProxy(org.eclipse.linuxtools.internal.docker.core.ContainerFileProxy) ContainerDirectorySelectionDialog(org.eclipse.linuxtools.internal.docker.ui.ContainerDirectorySelectionDialog)

Aggregations

ContainerFileProxy (org.eclipse.linuxtools.internal.docker.core.ContainerFileProxy)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ArrayList (java.util.ArrayList)2 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)2 IDockerContainerInfo (org.eclipse.linuxtools.docker.core.IDockerContainerInfo)2 ContainerFileSystemProvider (org.eclipse.linuxtools.internal.docker.ui.ContainerFileSystemProvider)2 MinimizedFileSystemElement (org.eclipse.linuxtools.internal.docker.ui.MinimizedFileSystemElement)2 PopulateContainerFilesOperation (org.eclipse.linuxtools.internal.docker.ui.PopulateContainerFilesOperation)2 Closeable (java.io.Closeable)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Iterator (java.util.Iterator)1 TarArchiveEntry (org.apache.commons.compress.archivers.tar.TarArchiveEntry)1 TarArchiveInputStream (org.apache.commons.compress.archivers.tar.TarArchiveInputStream)1 IPath (org.eclipse.core.runtime.IPath)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Path (org.eclipse.core.runtime.Path)1 Job (org.eclipse.core.runtime.jobs.Job)1