use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class OpenShiftExplorerContentProvider method getConnectionChildren.
protected Object[] getConnectionChildren(IConnectionWrapper connection) {
switch(connection.getState()) {
case LOADED:
removeStub(connection);
Object[] result = connection.getResources().toArray();
if (result == null || result.length == 0) {
result = new Object[] { new NewProjectLinkNode((Connection) connection.getWrapped()) };
}
return result;
case LOAD_STOPPED:
LoadingStub stub = removeStub(connection);
if (stub != null) {
return stub.getChildren();
}
default:
connection.load(e -> handleLoadingException(connection, e));
return new Object[] { makeStub(connection) };
}
}
use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class DeployImageHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Connection connection = null;
IProject project = null;
ISelection selection = HandlerUtil.getCurrentSelection(event);
final IDockerImage image = UIUtils.getFirstElement(selection, IDockerImage.class);
if (image == null || OpenShiftUIUtils.hasOpenShiftExplorerSelection()) {
selection = OpenShiftUIUtils.getOpenShiftExplorerSelection();
project = ResourceUtils.getProject(UIUtils.getFirstElement(selection, IResource.class));
if (project != null) {
connection = ConnectionsRegistryUtil.getConnectionFor(project);
} else {
connection = UIUtils.getFirstElement(selection, Connection.class);
}
}
if (connection == null) {
connection = OpenShiftUIUtils.getExplorerDefaultConnection(Connection.class);
}
IDockerConnection dockerConnection = null;
if (image != null) {
dockerConnection = image.getConnection();
} else if (OpenShiftUIUtils.hasDockerExplorerSelection()) {
ISelection dockerSelection = OpenShiftUIUtils.getDockerExplorerSelection();
dockerConnection = UIUtils.getFirstElement(dockerSelection, IDockerConnection.class);
if (dockerConnection == null) {
// Action is originated from OpenShift Explorer, do the best to pick up Docker connection from the current selection in Docker Explorer.
IDockerImage selectedImage = UIUtils.getFirstElement(dockerSelection, IDockerImage.class);
if (selectedImage != null) {
dockerConnection = selectedImage.getConnection();
}
}
}
runWizard(HandlerUtil.getActiveWorkbenchWindow(event).getShell(), dockerConnection, image, project, connection);
return null;
}
use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class OpenShiftServerEditorModel method setConnection.
public void setConnection(Connection connection, boolean executeCommand) {
Connection previous = getConnection();
String newUrl = connection == null ? null : getConnectionUrl(connection);
super.setConnection(connection);
// fire server command
if (executeCommand)
section.execute(new SetConnectionCommand(getServer(), previous, connection, newUrl));
}
use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class ImportApplicationWizard method setConnection.
private void setConnection(IProject project) {
Connection connection = ConnectionsRegistryUtil.safeGetConnectionFor(project);
setModelConnection(connection);
}
use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class ConnectionTest method shouldReplaceExtendedProperty.
@SuppressWarnings("serial")
@Test
public void shouldReplaceExtendedProperty() throws Exception {
// given
Connection connection = new Connection("http://localhost", null, null);
connection.setExtendedProperty("kung", "foo");
connection.setExtendedProperty("foo", "bar");
assertThat(connection.getExtendedProperties()).containsEntry("kung", "foo").containsEntry("foo", "bar");
// when
connection.setExtendedProperties(new HashMap<String, Object>() {
{
put("foo", "bar");
}
});
// then
assertThat(connection.getExtendedProperties()).hasSize(1);
assertThat(connection.getExtendedProperties()).containsExactly(MapEntry.entry("foo", "bar"));
}
Aggregations