use of org.eclipse.linuxtools.docker.core.IDockerConnection in project linuxtools by eclipse.
the class ShowInWebBrowserCommandHandler method execute.
@Override
public Object execute(final ExecutionEvent event) {
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
final List<IDockerPortMapping> portMappings = getSelectedPortMappings(activePart);
if (portMappings == null || portMappings.isEmpty()) {
return null;
}
final Job job = new Job(// $NON-NLS-1$
CommandMessages.getString("command.showIn.webBrowser")) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
try {
final IDockerConnection currentConnection = getCurrentConnection(activePart);
final IDockerPortMapping selectedPort = portMappings.get(0);
final URI connectionURI = new URI(currentConnection.getUri());
if (// $NON-NLS-1$
"tcp".equalsIgnoreCase(connectionURI.getScheme()) || // $NON-NLS-1$
"unix".equalsIgnoreCase(connectionURI.getScheme()) || // $NON-NLS-1$
"http".equalsIgnoreCase(connectionURI.getScheme()) || // $NON-NLS-1$
"https".equalsIgnoreCase(connectionURI.getScheme())) {
final String host = // $NON-NLS-1$
"unix".equalsIgnoreCase(connectionURI.getScheme()) ? "127.0.0.1" : // $NON-NLS-1$
connectionURI.getHost();
final URL location = new // $NON-NLS-1$
URL(// $NON-NLS-1$
"http", // $NON-NLS-1$
host, selectedPort.getPublicPort(), // $NON-NLS-1$
"/");
openLocationInWebBrowser(location);
}
} catch (URISyntaxException | MalformedURLException e) {
Activator.logErrorMessage(CommandMessages.getString(// $NON-NLS-1$
"command.showIn.webBrowser.failure"), e);
}
monitor.done();
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
return null;
}
use of org.eclipse.linuxtools.docker.core.IDockerConnection in project linuxtools by eclipse.
the class NewDockerConnectionSWTBotTest method configureTCPConnection.
private IDockerConnection configureTCPConnection(final String connectionName, final String host) {
final DockerClient client = MockDockerClientFactory.build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from(connectionName, client).withTCPConnectionSettings(host, null);
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
return dockerConnection;
}
use of org.eclipse.linuxtools.docker.core.IDockerConnection in project jbosstools-openshift by jbosstools.
the class DeployImagePage method createDockerConnectionInfoControl.
private void createDockerConnectionInfoControl(Composite parent, DataBindingContext dbc) {
Label lblConnection = createDockerConnectionLabel(parent);
final Text connectionText = new Text(parent, SWT.READ_ONLY | SWT.NO_FOCUS);
connectionText.setBackground(lblConnection.getBackground());
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(NUM_COLUMS - 1, 1).grab(true, false).applyTo(connectionText);
final IObservableValue<String> connnectionTextObservable = WidgetProperties.text(SWT.None).observe(connectionText);
final IObservableValue<IDockerConnection> connnectionObservable = BeanProperties.value(IDeployImagePageModel.PROPERTY_DOCKER_CONNECTION).observe(model);
ValueBindingBuilder.bind(connnectionTextObservable).notUpdatingParticipant().to(connnectionObservable).converting(new ObjectToStringConverter(IDockerConnection.class) {
ConnectionColumLabelProvider labelProvider = new ConnectionColumLabelProvider();
@Override
public Object convert(Object source) {
return (source instanceof IDockerConnection) ? dockerConnectionToString((IDockerConnection) source) : "";
}
}).in(dbc);
}
use of org.eclipse.linuxtools.docker.core.IDockerConnection in project jbosstools-openshift by jbosstools.
the class DeployImageWizard method getPushImageToRegistryJob.
private static PushImageToRegistryJob getPushImageToRegistryJob(final IDeployImageParameters model) {
final IDockerConnection dockerConnection = model.getDockerConnection();
final String imageName = model.getImageName();
final String deployProjectName = model.getProject().getName();
final IRegistryAccount registryAccount = new IRegistryAccount() {
@Override
public String getServerAddress() {
return model.getTargetRegistryLocation();
}
@Override
public String getUsername() {
return model.getTargetRegistryUsername();
}
@Override
public char[] getPassword() {
return model.getTargetRegistryPassword().toCharArray();
}
@Override
public String getEmail() {
return null;
}
@Override
public List<IRepositoryTag> getTags(String arg0) throws DockerException {
return null;
}
@Override
public boolean isVersion2() {
return false;
}
@Override
public List<IDockerImageSearchResult> getImages(String arg0) throws DockerException {
return null;
}
};
return new PushImageToRegistryJob(dockerConnection, registryAccount, deployProjectName, imageName);
}
use of org.eclipse.linuxtools.docker.core.IDockerConnection in project jbosstools-openshift by jbosstools.
the class DeployImagePage method createDockerConnectionControl.
private void createDockerConnectionControl(Composite parent, DataBindingContext dbc) {
createDockerConnectionLabel(parent);
StructuredViewer connectionViewer = new ComboViewer(parent);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(NUM_COLUMS - 2, 1).applyTo(connectionViewer.getControl());
connectionViewer.setContentProvider(new ObservableListContentProvider());
connectionViewer.setLabelProvider(new ObservableTreeItemLabelProvider() {
@Override
public String getText(Object element) {
return (element instanceof IDockerConnection) ? dockerConnectionToString((IDockerConnection) element) : "";
}
});
connectionViewer.setInput(BeanProperties.list(IDeployImagePageModel.PROPERTY_DOCKER_CONNECTIONS).observe(model));
IObservableValue<IDockerConnection> dockerConnectionObservable = BeanProperties.value(IDeployImagePageModel.PROPERTY_DOCKER_CONNECTION).observe(model);
DockerConnectionStatusProvider validator = new DockerConnectionStatusProvider(dockerConnectionObservable);
IObservableValue<?> selectedConnectionObservable = ViewerProperties.singleSelection().observe(connectionViewer);
Binding selectedConnectionBinding = ValueBindingBuilder.bind(selectedConnectionObservable).converting(new ObservableTreeItem2ModelConverter(IDockerConnection.class)).validatingAfterConvert(validator).to(BeanProperties.value(IDeployImagePageModel.PROPERTY_DOCKER_CONNECTION).observe(model)).in(dbc);
ControlDecorationSupport.create(selectedConnectionBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
Button newDockerConnectionButton = new Button(parent, SWT.PUSH);
newDockerConnectionButton.setText("New...");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(newDockerConnectionButton);
UIUtils.setDefaultButtonWidth(newDockerConnectionButton);
newDockerConnectionButton.addSelectionListener(onNewDockerConnectionClicked());
dbc.addValidationStatusProvider(validator);
}
Aggregations