use of org.jboss.tools.openshift.common.core.connection.ConnectionsRegistryAdapter in project jbosstools-openshift by jbosstools.
the class OpenShiftCommonUIActivator method start.
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
connectionsRegistryListener = new ConnectionsRegistryAdapter() {
@Override
public void connectionAdded(IConnection connection) {
try {
OpenShiftUIUtils.showOpenShiftExplorer();
} catch (Exception e) {
// Can happen during workbench startup, while the core
// plugins are starting.
// Since mutiple connections would cause multiple errors,
// it's probably better to swallow the exception, else a
// user would see multiple
// errors in the log, every time the workbench starts.
}
}
};
ConnectionsRegistrySingleton.getInstance().addListener(connectionsRegistryListener);
}
use of org.jboss.tools.openshift.common.core.connection.ConnectionsRegistryAdapter in project jbosstools-openshift by jbosstools.
the class OpenShiftCoreActivator method start.
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
registerDebugOptionsListener(PLUGIN_ID, new Trace(this), context);
Collection<Connection> connections = new ConnectionPersistency().load();
ConnectionsRegistrySingleton.getInstance().addAll(connections);
ConnectionsRegistrySingleton.getInstance().addListener(new ConnectionsRegistryAdapter() {
// @TODO I think we need to handle the cleanup case where a connection
// username changes since username is what makes up part of the
// the key that is saved which seems to apply to secure values
// and preference values
@Override
public void connectionRemoved(IConnection connection) {
if (!(connection instanceof Connection)) {
return;
}
((Connection) connection).removeSecureStoreData();
ConnectionURL url = ConnectionURL.safeForConnection(connection);
if (url != null) {
OpenShiftCorePreferences.INSTANCE.removeAuthScheme(url.toString());
}
saveAllConnections();
}
@Override
public void connectionAdded(IConnection connection) {
if (connection instanceof Connection) {
saveAllConnections();
}
}
@Override
public void connectionChanged(IConnection connection, String property, Object oldValue, Object newValue) {
if (connection instanceof Connection && (oldValue instanceof Connection || newValue instanceof Connection)) {
saveAllConnections();
}
}
});
ServerCore.addServerLifecycleListener(getServerListener());
// A clone of the auto-publish thread implementation
resourceChangeListener = new ResourceChangePublisher();
ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_BUILD | IResourceChangeEvent.PRE_CLOSE | IResourceChangeEvent.PRE_DELETE);
}
Aggregations