Skip to content

Commit

Permalink
[JBIDE-21153] allow o.j.t.o.ui to contribute UI to o.j.t.o.core via e…
Browse files Browse the repository at this point in the history
…xtension point
  • Loading branch information
adietish committed Nov 30, 2015
1 parent 8e4f36d commit 8620c1c
Show file tree
Hide file tree
Showing 17 changed files with 343 additions and 66 deletions.
Expand Up @@ -8,7 +8,7 @@
* Contributors:
* Red Hat Incorporated - initial API and implementation
*******************************************************************************/
package org.jboss.tools.openshift.internal.common.ui.utils;
package org.jboss.tools.openshift.common.core.utils;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -18,7 +18,7 @@
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.osgi.util.NLS;
import org.jboss.tools.openshift.internal.common.ui.OpenShiftCommonUIActivator;
import org.jboss.tools.openshift.internal.common.core.OpenShiftCommonCoreActivator;
import org.osgi.framework.Bundle;

/**
Expand All @@ -45,11 +45,20 @@ public static <T> Collection<T> getExtensions(String extensionId, String classAt
return extensions;
}

public static <T> T getFirstExtension(String extensionId, String classAttribute) {
IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionId);
if (config.length == 0) {
return null;
}

return safeCreateExtension(extensionId, classAttribute, config[0]);
}

public static <T> T safeCreateExtension(String extensionId, String classAttribute, IConfigurationElement configurationElement) {
try {
return createExtension(classAttribute, configurationElement);
} catch (IllegalStateException | IllegalArgumentException | ClassNotFoundException e) {
OpenShiftCommonUIActivator.log(NLS.bind("Could not create extension {0} in bundle {1}", configurationElement.getName(), getBundleNameFor(configurationElement)), e);
OpenShiftCommonCoreActivator.log(NLS.bind("Could not create extension {0} in bundle {1}", configurationElement.getName(), getBundleNameFor(configurationElement)), e);
return null;
}
}
Expand Down
Expand Up @@ -11,6 +11,7 @@

package org.jboss.tools.openshift.internal.common.core;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.jboss.tools.foundation.core.plugin.BaseCorePlugin;
import org.jboss.tools.foundation.core.plugin.log.IPluginLog;
Expand Down Expand Up @@ -74,4 +75,16 @@ public static StatusFactory statusFactory() {
return getDefault().statusFactoryInternal();
}

public static void log(Throwable t) {
log(null, t);
}

public static void log(String message, Throwable t) {
log(StatusFactory.errorStatus(PLUGIN_ID, message, t));
}

public static void log(IStatus status) {
getDefault().getLog().log(status);
}

}
Expand Up @@ -25,12 +25,12 @@
import org.jboss.tools.openshift.common.core.connection.ConnectionsRegistrySingleton;
import org.jboss.tools.openshift.common.core.connection.IConnection;
import org.jboss.tools.openshift.common.core.connection.IConnectionFactory;
import org.jboss.tools.openshift.common.core.utils.ExtensionUtils;
import org.jboss.tools.openshift.common.core.utils.StringUtils;
import org.jboss.tools.openshift.internal.common.ui.OpenShiftCommonUIActivator;
import org.jboss.tools.openshift.internal.common.ui.connection.ConnectionWizardModel;
import org.jboss.tools.openshift.internal.common.ui.connection.ConnectionWizardPage;
import org.jboss.tools.openshift.internal.common.ui.utils.DataBindingUtils;
import org.jboss.tools.openshift.internal.common.ui.utils.ExtensionUtils;
import org.jboss.tools.openshift.internal.common.ui.wizard.IConnectionAware;
import org.jboss.tools.openshift.internal.common.ui.wizard.IConnectionAwareWizard;

Expand Down
Expand Up @@ -10,9 +10,6 @@
******************************************************************************/
package org.jboss.tools.openshift.internal.common.ui.connection;

import java.util.Iterator;

import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.observable.value.IObservableValue;
Expand Down
Expand Up @@ -15,8 +15,8 @@
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.swt.widgets.Composite;
import org.jboss.tools.openshift.common.core.utils.ExtensionUtils;
import org.jboss.tools.openshift.internal.common.ui.detailviews.AbstractStackedDetailViews;
import org.jboss.tools.openshift.internal.common.ui.utils.ExtensionUtils;

/**
* @author Andre Dietisheim
Expand Down
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.jboss.tools.openshift.core
Bundle-SymbolicName: org.jboss.tools.openshift.core;singleton:=true
Bundle-Version: 3.1.0.qualifier
Bundle-Activator: org.jboss.tools.openshift.internal.core.OpenShiftCoreActivator
Bundle-Vendor: %Bundle-Vendor
Expand Down
11 changes: 11 additions & 0 deletions plugins/org.jboss.tools.openshift.core/plugin.xml
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension-point id="org.jboss.tools.openshift.core.credentialsPrompterUI"
name="CredentialsPrompterUI"
schema="schema/org.jboss.tools.openshift.core.credentialsPrompterUI.exsd"/>

<extension-point id="org.jboss.tools.openshift.core.sslCertificateCallbackUI"
name="SSLCertificateCallbackUI"
schema="schema/org.jboss.tools.openshift.core.sslCertificateCallbackUI.exsd"/>
</plugin>
@@ -0,0 +1,102 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.jboss.tools.openshift.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="org.jboss.tools.openshift.core" id="org.jboss.tools.openshift.core.credentialsPrompterUI" name="CredentialsPrompterUI"/>
</appinfo>
<documentation>
[Enter description of this extension point.]
</documentation>
</annotation>

<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<sequence>
<element ref="credentialsPrompterUI"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>

</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>

</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>

</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>

<element name="credentialsPrompterUI">
<complexType>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>

</documentation>
<appinfo>
<meta.attribute kind="java" basedOn=":org.jboss.tools.openshift.common.core.ICredentialsPrompter"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>

<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>

<annotation>
<appinfo>
<meta.section type="examples"/>
</appinfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>

<annotation>
<appinfo>
<meta.section type="apiinfo"/>
</appinfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>

<annotation>
<appinfo>
<meta.section type="implementation"/>
</appinfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>


</schema>
@@ -0,0 +1,101 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.jboss.tools.openshift.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="org.jboss.tools.openshift.core" id="org.jboss.tools.openshift.core.sslCertificateCallbackUI" name="SSLCertificateCallbackUI"/>
</appinfo>
<documentation>
[Enter description of this extension point.]
</documentation>
</annotation>

<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<sequence>
<element ref="sslCertificateCallbackUI"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>

</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>

</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>

</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>

<element name="sslCertificateCallbackUI">
<complexType>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>

</documentation>
<appinfo>
<meta.attribute kind="java" basedOn=":com.openshift.client.IHttpClient$ISSLCertificateCallback"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>

<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>

<annotation>
<appinfo>
<meta.section type="examples"/>
</appinfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>

<annotation>
<appinfo>
<meta.section type="apiinfo"/>
</appinfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>

<annotation>
<appinfo>
<meta.section type="implementation"/>
</appinfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>

</schema>
Expand Up @@ -31,9 +31,11 @@ public LazyCredentialsPrompter(ICredentialsPrompter prompter) {
*/
@Override
public final boolean promptAndAuthenticate(IConnection connection, Object context) {
if(prompter == null){
if (prompter == null) {
prompter = OpenShiftCoreUIIntegration.getInstance().getCredentialPrompter();
if(prompter == null) return false;
if (prompter == null) {
return false;
}
}
return prompter.promptAndAuthenticate(connection, context);
}
Expand Down

0 comments on commit 8620c1c

Please sign in to comment.