use of org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerView in project linuxtools by eclipse.
the class DockerConnectionManagerUtils method configureConnectionManager.
/**
* Configures the {@link DockerConnectionManager} with the given array of
* {@link IDockerConnection} (can be mocked) and refreshes the associated
* {@link DockerExplorerView}.
*
* @param connectionStorageManager
* the {@link IDockerConnectionStorageManager} to use (can be
* mocked)
*/
public static void configureConnectionManager(final IDockerConnectionStorageManager connectionStorageManager) {
DockerConnectionManager.getInstance().setConnectionStorageManager(connectionStorageManager);
final SWTWorkbenchBot bot = new SWTWorkbenchBot();
final SWTBotView dockerExplorerBotView = SWTUtils.getSWTBotView(bot, DockerExplorerView.VIEW_ID);
final SWTBotView dockerContainersBotView = SWTUtils.getSWTBotView(bot, DockerContainersView.VIEW_ID);
SWTUtils.syncExec(() -> {
DockerConnectionManager.getInstance().reloadConnections();
if (dockerExplorerBotView != null) {
final DockerExplorerView dockerExplorerView = (DockerExplorerView) dockerExplorerBotView.getViewReference().getView(false);
if (dockerExplorerView != null) {
dockerExplorerView.getCommonViewer().refresh();
dockerExplorerView.showConnectionsOrExplanations();
}
}
if (dockerContainersBotView != null) {
final DockerContainersView dockerContainersView = (DockerContainersView) dockerContainersBotView.getViewReference().getView(false);
if (dockerContainersView != null) {
dockerContainersView.getViewer().refresh();
}
}
});
}
use of org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerView in project linuxtools by eclipse.
the class RefreshCommandHandler method getRefreshJobs.
private List<Job> getRefreshJobs(final IWorkbenchPart activePart) {
final IDockerConnection connection = getCurrentConnection(activePart);
final ArrayList<Job> jobs = new ArrayList<>();
if (activePart instanceof DockerImagesView) {
jobs.add(getRefreshImagesJob(connection));
} else if (activePart instanceof DockerContainersView) {
jobs.add(getRefreshContainersJob(connection));
} else if (activePart instanceof DockerExplorerView) {
DockerExplorerView dockerExplorerView = (DockerExplorerView) activePart;
final ITreeSelection selection = dockerExplorerView.getCommonViewer().getStructuredSelection();
if (selection.getFirstElement() instanceof DockerContainersCategory) {
jobs.add(getRefreshContainersJob(connection));
} else if (selection.getFirstElement() instanceof DockerImagesCategory) {
jobs.add(getRefreshImagesJob(connection));
} else {
final IDockerConnection[] connections = DockerConnectionManager.getInstance().getConnections();
for (IDockerConnection selectedConnection : connections) {
if (!selectedConnection.isOpen()) {
try {
selectedConnection.open(true);
} catch (DockerException e) {
// do nothing
}
}
if (selectedConnection.isOpen()) {
jobs.add(getRefreshContainersJob(selectedConnection));
jobs.add(getRefreshImagesJob(selectedConnection));
}
}
}
}
return jobs;
}
Aggregations