use of org.eclipse.linuxtools.docker.core.DockerException in project linuxtools by eclipse.
the class ShowInSystemExplorerCommandHandler method getShowInSystemExplorerCommand.
/**
* Prepare command for launching system explorer to show a path
*
* @param path
* the path to show
* @return the command that shows the path
* @see ShowInSystemExplorerHandler#getDefaultCommand()
*/
private String getShowInSystemExplorerCommand(final File path) {
String command = ShowInSystemExplorerHandler.getDefaultCommand();
if ("".equals(command)) {
// $NON-NLS-1$
Activator.log(new DockerException(CommandMessages.getString(// $NON-NLS-1$
"command.showIn.systemExplorer.failure.command_unavailable")));
return null;
}
try {
command = Util.replaceAll(command, VARIABLE_RESOURCE, quotePath(path.getCanonicalPath()));
command = Util.replaceAll(command, VARIABLE_RESOURCE_URI, path.getCanonicalFile().toURI().toString());
File parent = path.getParentFile();
if (parent != null) {
command = Util.replaceAll(command, VARIABLE_FOLDER, quotePath(parent.getCanonicalPath()));
}
return command;
} catch (IOException e) {
Activator.logErrorMessage(CommandMessages.getString("command.showIn.systemExplorer.failure"), e);
return null;
}
}
use of org.eclipse.linuxtools.docker.core.DockerException in project linuxtools by eclipse.
the class TagImageCommandHandler method performTagImage.
private void performTagImage(final IDockerConnection connection, final IDockerImage image, final String tag) {
final Job tagImageJob = new Job(DVMessages.getString(TAG_IMAGE_JOB_TITLE)) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
monitor.beginTask(DVMessages.getFormattedString(TAG_IMAGE_MSG, tag), 2);
// handler refresh the images when done
try {
((DockerConnection) connection).tagImage(image.id(), tag);
monitor.worked(1);
((DockerConnection) connection).getImages(true);
monitor.worked(1);
} catch (final DockerException e) {
Display.getDefault().syncExec(() -> MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DVMessages.getFormattedString(ERROR_TAGGING_IMAGE, tag), e.getMessage()));
// for now
} catch (InterruptedException e) {
// do nothing
} finally {
monitor.done();
}
return Status.OK_STATUS;
}
};
tagImageJob.schedule();
}
use of org.eclipse.linuxtools.docker.core.DockerException in project linuxtools by eclipse.
the class TagImageCommandHandler 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);
// TODO: remove the cast to DockerImage once the 'shortId' method has
// been added in the API
final ImageTag wizard = new ImageTag(((DockerImage) image).shortId());
final boolean tagImage = CommandUtils.openWizard(wizard, HandlerUtil.getActiveShell(event));
if (tagImage) {
performTagImage(connection, image, wizard.getTag());
}
return null;
}
Aggregations