diff options
author | Yana Stamcheva <yana@jitsi.org> | 2011-02-24 13:48:24 +0000 |
---|---|---|
committer | Yana Stamcheva <yana@jitsi.org> | 2011-02-24 13:48:24 +0000 |
commit | bf3fd3dcdaa47ef8a5e246c5af9915e052d7aa74 (patch) | |
tree | 80ee644b2be8a865f2c73f77dc42e21a7166d3fd /src/net/java/sip/communicator/plugin | |
parent | 4269c5ff7d9253622fadea90ae5e4bb1f7c154b7 (diff) | |
download | jitsi-bf3fd3dcdaa47ef8a5e246c5af9915e052d7aa74.zip jitsi-bf3fd3dcdaa47ef8a5e246c5af9915e052d7aa74.tar.gz jitsi-bf3fd3dcdaa47ef8a5e246c5af9915e052d7aa74.tar.bz2 |
Allow to enable provisioning when you start jitsi for the first time. As part of the solution proposed by Conrad Beckert on dev (subject: "Re: Updates to the Provisioning Plugin").
Diffstat (limited to 'src/net/java/sip/communicator/plugin')
5 files changed, 285 insertions, 10 deletions
diff --git a/src/net/java/sip/communicator/plugin/advancedconfig/AdvancedConfigActivator.java b/src/net/java/sip/communicator/plugin/advancedconfig/AdvancedConfigActivator.java index abf9b26..5dfc8e4 100644 --- a/src/net/java/sip/communicator/plugin/advancedconfig/AdvancedConfigActivator.java +++ b/src/net/java/sip/communicator/plugin/advancedconfig/AdvancedConfigActivator.java @@ -47,12 +47,7 @@ public class AdvancedConfigActivator bundleContext .registerService( ConfigurationForm.class.getName(), - new LazyConfigurationForm( - "net.java.sip.communicator.plugin.advancedconfig.AdvancedConfigurationPanel", - getClass().getClassLoader(), - "plugin.advancedconfig.PLUGIN_ICON", - "service.gui.ADVANCED", - 300), + new AdvancedConfigurationPanel(), properties); if (logger.isInfoEnabled()) diff --git a/src/net/java/sip/communicator/plugin/advancedconfig/AdvancedConfigurationPanel.java b/src/net/java/sip/communicator/plugin/advancedconfig/AdvancedConfigurationPanel.java index ef07e3b..aad5dd9 100644 --- a/src/net/java/sip/communicator/plugin/advancedconfig/AdvancedConfigurationPanel.java +++ b/src/net/java/sip/communicator/plugin/advancedconfig/AdvancedConfigurationPanel.java @@ -24,7 +24,9 @@ import org.osgi.framework.*; */ public class AdvancedConfigurationPanel extends TransparentPanel - implements ServiceListener, + implements ConfigurationForm, + ConfigurationContainer, + ServiceListener, ListSelectionListener { /** @@ -181,8 +183,20 @@ public class AdvancedConfigurationPanel break; } listModel.add(i, configForm); + } - configList.setSelectedIndex(0); + /** + * Implements <code>ApplicationWindow.show</code> method. + * + * @param isVisible specifies whether the frame is to be visible or not. + */ + public void setVisible(boolean isVisible) + { + if (isVisible && configList.getSelectedIndex() < 0) + { + this.configList.setSelectedIndex(0); + } + super.setVisible(isVisible); } /** @@ -306,4 +320,62 @@ public class AdvancedConfigurationPanel showFormContent(configForm); } } + + /** + * Selects the given <tt>ConfigurationForm</tt>. + * + * @param configForm the <tt>ConfigurationForm</tt> to select + */ + public void setSelected(ConfigurationForm configForm) + { + configList.setSelectedValue(configForm, true); + } + + /** + * Returns the title of the form. + * @return the title of the form + */ + public String getTitle() + { + return AdvancedConfigActivator.getResources() + .getI18NString("service.gui.ADVANCED"); + } + + /** + * Returns the icon of the form. + * @return a byte array containing the icon of the form + */ + public byte[] getIcon() + { + return AdvancedConfigActivator.getResources() + .getImageInBytes("plugin.advancedconfig.PLUGIN_ICON"); + } + + /** + * Returns the form component. + * @return the form component + */ + public Object getForm() + { + return this; + } + + /** + * Returns the index of the form in its parent container. + * @return the index of the form in its parent container + */ + public int getIndex() + { + return 300; + } + + /** + * Indicates if the form is an advanced form. + * @return <tt>true</tt> to indicate that this is an advanced form, + * otherwise returns <tt>false</tt> + */ + public boolean isAdvanced() + { + return true; + } } diff --git a/src/net/java/sip/communicator/plugin/provisioning/ProvisioningForm.java b/src/net/java/sip/communicator/plugin/provisioning/ProvisioningForm.java index 39f429f..e91bc5a 100644 --- a/src/net/java/sip/communicator/plugin/provisioning/ProvisioningForm.java +++ b/src/net/java/sip/communicator/plugin/provisioning/ProvisioningForm.java @@ -142,6 +142,20 @@ public class ProvisioningForm c.gridy = 3; mainPanel.add(uriField, c); + JTextPane pane = new JTextPane(); + pane.setForeground(Color.RED); + pane.setEditable(false); + pane.setOpaque(false); + pane.setText(ProvisioningActivator.getResourceService().getI18NString( + "plugin.provisioning.RESTART_WARNING")); + + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1.0; + c.insets = new Insets(30, 10, 0, 0); + c.gridx = 0; + c.gridy = 4; + mainPanel.add(pane, c); + initButtonStates(); initListeners(); } diff --git a/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java b/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java index f02fd64..9ce5a7c 100644 --- a/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java +++ b/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java @@ -68,8 +68,6 @@ public class InitialAccountRegistrationFrame = new TransparentPanel(new BorderLayout());
mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-
-
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
JButton cancelButton
= new JButton(Resources.getString("service.gui.CANCEL"));
@@ -94,6 +92,8 @@ public class InitialAccountRegistrationFrame mainAccountsPanel.add(accountsPanel, BorderLayout.CENTER);
+ initProvisioningPanel();
+
mainAccountsPanel.setOpaque(false);
accountsPanel.setOpaque(false);
buttonPanel.setOpaque(false);
@@ -137,6 +137,62 @@ public class InitialAccountRegistrationFrame }
}
+ /**
+ * Initializes the provisioning panel.
+ */
+ private void initProvisioningPanel()
+ {
+ JPanel provisioningPanel = new TransparentPanel();
+
+ final JLabel provisioningLabel =
+ new JLabel("<html><a href=''>"
+ + SimpleAccountRegistrationActivator
+ .getResources().getI18NString("service.gui.USE_PROVISIONING")
+ + "</a></html>");
+
+ provisioningLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
+ provisioningLabel.setToolTipText(
+ SimpleAccountRegistrationActivator
+ .getResources().getI18NString("service.gui.USE_PROVISIONING"));
+
+ provisioningLabel.addMouseListener(new MouseAdapter()
+ {
+ public void mousePressed(MouseEvent e)
+ {
+ ConfigurationContainer configContainer
+ = SimpleAccountRegistrationActivator.getUIService()
+ .getConfigurationContainer();
+
+ ConfigurationForm advancedConfigForm
+ = SimpleAccountRegistrationActivator.getAdvancedConfigForm();
+
+ if (advancedConfigForm != null)
+ {
+ configContainer.setSelected(advancedConfigForm);
+
+ if (advancedConfigForm instanceof ConfigurationContainer)
+ {
+ ConfigurationForm provisioningForm
+ = SimpleAccountRegistrationActivator
+ .getProvisioningConfigForm();
+
+ if (provisioningForm != null)
+ {
+ ((ConfigurationContainer) advancedConfigForm)
+ .setSelected(provisioningForm);
+ }
+ }
+ }
+
+ configContainer.setVisible(true);
+ }
+ });
+
+ provisioningPanel.add(provisioningLabel);
+
+ mainAccountsPanel.add(provisioningPanel, BorderLayout.SOUTH);
+ }
+
private void initAccountWizards()
{
String simpleWizards
diff --git a/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java b/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java index b5e8f3a..3c35917 100644 --- a/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java +++ b/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java @@ -12,18 +12,38 @@ import java.util.*; import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; +import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; import org.osgi.framework.*; +/** + * + * @author Yana Stamcheva + */ public class SimpleAccountRegistrationActivator implements BundleActivator { private static final Logger logger = Logger.getLogger(SimpleAccountRegistrationActivator.class); + /** + * Advanced config form class name. + */ + private static final String advancedConfigFormClassName + = "net.java.sip.communicator.plugin" + + ".advancedconfig.AdvancedConfigurationPanel"; + + /** + * Provisioning form class name. + */ + private static final String provisioningFormClassName + = "net.java.sip.communicator.plugin.provisioning.ProvisioningForm"; + public static BundleContext bundleContext; + private static ResourceManagementService resourcesService; + public void start(BundleContext bc) throws Exception { bundleContext = bc; @@ -172,4 +192,122 @@ public class SimpleAccountRegistrationActivator return (UIService) bundleContext .getService(serviceReference); } + + /** + * Returns the <tt>ResourceManagementService</tt>, through which we will + * access all resources. + * + * @return the <tt>ResourceManagementService</tt>, through which we will + * access all resources. + */ + public static ResourceManagementService getResources() + { + if (resourcesService == null) + { + resourcesService + = ServiceUtils.getService( + bundleContext, + ResourceManagementService.class); + } + return resourcesService; + } + + /** + * Returns the first available advanced configuration form. + * + * @return the first available advanced configuration form + */ + public static ConfigurationForm getAdvancedConfigForm() + { + // General configuration forms only. + String osgiFilter = "(" + + ConfigurationForm.FORM_TYPE + + "="+ConfigurationForm.GENERAL_TYPE+")"; + + ServiceReference[] confFormsRefs = null; + try + { + confFormsRefs = bundleContext + .getServiceReferences( + ConfigurationForm.class.getName(), + osgiFilter); + } + catch (InvalidSyntaxException ex) + {} + + if(confFormsRefs != null) + { + for (int i = 0; i < confFormsRefs.length; i++) + { + ConfigurationForm form + = (ConfigurationForm) bundleContext + .getService(confFormsRefs[i]); + + if (form instanceof LazyConfigurationForm) + { + LazyConfigurationForm lazyConfigForm + = (LazyConfigurationForm) form; + + if (lazyConfigForm.getFormClassName().equals( + advancedConfigFormClassName)) + return form; + } + else if (form.getClass().getName().equals( + advancedConfigFormClassName)) + { + return form; + } + } + } + + return null; + } + + /** + * Returns the first available provisioning configuration form. + * + * @return the first available provisioning configuration form + */ + public static ConfigurationForm getProvisioningConfigForm() + { + // General configuration forms only. + String osgiFilter = "(" + + ConfigurationForm.FORM_TYPE + + "="+ConfigurationForm.ADVANCED_TYPE+")"; + + ServiceReference[] confFormsRefs = null; + try + { + confFormsRefs = bundleContext + .getServiceReferences( + ConfigurationForm.class.getName(), + osgiFilter); + } + catch (InvalidSyntaxException ex) + {} + + if(confFormsRefs != null) + { + for (int i = 0; i < confFormsRefs.length; i++) + { + ConfigurationForm form + = (ConfigurationForm) bundleContext + .getService(confFormsRefs[i]); + + if (form instanceof LazyConfigurationForm) + { + LazyConfigurationForm lazyConfigForm + = (LazyConfigurationForm) form; + + if (lazyConfigForm.getFormClassName().equals( + provisioningFormClassName)) + { + return form; + } + } + } + } + + return null; + } } |