use of org.eclipse.ui.IWorkbenchPart in project linuxtools by eclipse.
the class RemoveConnectionCommandHandler method execute.
@Override
public Object execute(ExecutionEvent event) {
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart instanceof CommonNavigator) {
final CommonViewer viewer = ((CommonNavigator) activePart).getCommonViewer();
final ITreeSelection selection = (ITreeSelection) viewer.getSelection();
Stream.of(selection.getPaths()).forEach(p -> DockerConnectionManager.getInstance().removeConnection((IDockerConnection) p.getLastSegment()));
}
return null;
}
use of org.eclipse.ui.IWorkbenchPart in project linuxtools by eclipse.
the class RemoveContainerLogCommandHandler method execute.
@Override
public Object execute(final ExecutionEvent event) {
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
List<IDockerContainer> selectedContainers = CommandUtils.getSelectedContainers(activePart);
if (activePart instanceof DockerContainersView) {
connection = ((DockerContainersView) activePart).getConnection();
}
if (selectedContainers.size() != 1 || connection == null)
return null;
container = selectedContainers.get(0);
IDockerContainerInfo info = connection.getContainerInfo(container.id());
if (info.config().tty()) {
Map<String, Object> properties = new HashMap<>();
properties.put(ITerminalsConnectorConstants.PROP_DELEGATE_ID, "org.eclipse.tm.terminal.connector.streams.launcher.streams");
properties.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID, "org.eclipse.tm.terminal.connector.streams.StreamsConnector");
properties.put(ITerminalsConnectorConstants.PROP_TITLE, info.name());
ITerminalService service = TerminalServiceFactory.getService();
service.closeConsole(properties, null);
return null;
}
final RunConsole rc = RunConsole.findConsole(container);
if (rc != null) {
RunConsole.removeConsole(rc);
}
return null;
}
use of org.eclipse.ui.IWorkbenchPart in project linuxtools by eclipse.
the class RemoveTagCommandHandler method execute.
@Override
public Object execute(final ExecutionEvent event) {
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
final List<IDockerImage> selectedImages = CommandUtils.getSelectedImages(activePart);
final IDockerConnection connection = CommandUtils.getCurrentConnection(activePart);
if (selectedImages.size() != 1 || connection == null) {
Activator.log(new DockerException(CommandMessages.getString(// $NON-NLS-1$
"Command.missing.selection.failure")));
return null;
}
final IDockerImage image = selectedImages.get(0);
final ImageRemoveTag wizard = new ImageRemoveTag(image);
final boolean removeTag = CommandUtils.openWizard(wizard, HandlerUtil.getActiveShell(event));
if (removeTag) {
performRemoveTagImage(connection, wizard.getTag());
}
return null;
}
use of org.eclipse.ui.IWorkbenchPart in project linuxtools by eclipse.
the class ShowAllContainersCommandHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
final boolean checked = !HandlerUtil.toggleCommandState(event.getCommand());
if (activePart instanceof DockerContainersView) {
final DockerContainersView containersView = (DockerContainersView) activePart;
containersView.showAllContainers(checked);
}
return null;
}
use of org.eclipse.ui.IWorkbenchPart in project linuxtools by eclipse.
the class ShowInSystemExplorerCommandHandler method execute.
@Override
public Object execute(final ExecutionEvent event) {
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
final List<DockerContainerVolume> volumes = CommandUtils.getSelectedVolumes(activePart);
if (volumes == null || volumes.isEmpty()) {
return null;
}
final DockerContainerVolume selectedVolume = volumes.get(0);
final File hostFile = new File(selectedVolume.getHostPath());
final String launchCmd = getShowInSystemExplorerCommand(hostFile);
if (launchCmd == null) {
return null;
}
final Job job = new Job(CommandMessages.getString("command.showIn.systemExplorer")) {
// $NON-NLS-1$
@Override
protected IStatus run(final IProgressMonitor monitor) {
try {
final Process p = getLaunchProcess(launchCmd, hostFile);
final int retCode = p.waitFor();
if (retCode != 0 && !Util.isWindows()) {
Activator.log(new DockerException(CommandMessages.getFormattedString(// $NON-NLS-1$
"command.showIn.systemExplorer.failure.command.execute", launchCmd, Integer.toString(retCode))));
}
} catch (IOException | InterruptedException e) {
Activator.logErrorMessage(CommandMessages.getFormattedString(// $NON-NLS-1$
"command.showIn.systemExplorer.failure", launchCmd), e);
} finally {
monitor.done();
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
return null;
}
Aggregations