From fd8ad43f7c8cf511778f704f92a1d726fad09059 Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Fri, 6 Jun 2008 15:00:29 +0000 Subject: [PATCH] Creating of a default group if one is set in application properties. --- build.xml | 4 ++- resources/application.properties | 3 +- .../InitialAccountRegistrationFrame.java | 17 ++++++++++ .../plugin/simpleaccreg/Resources.java | 33 +++++++++++++++++++ .../SimpleAccountRegistrationActivator.java | 22 +++++++++++++ 5 files changed, 77 insertions(+), 2 deletions(-) diff --git a/build.xml b/build.xml index 234b1f90c..38b55090d 100644 --- a/build.xml +++ b/build.xml @@ -1677,7 +1677,7 @@ javax.swing.event, javax.swing.border"/> - + @@ -1689,6 +1689,8 @@ javax.swing.event, javax.swing.border"/> prefix="resources"/> + diff --git a/resources/application.properties b/resources/application.properties index 8aa7a6d64..7f9a60823 100644 --- a/resources/application.properties +++ b/resources/application.properties @@ -5,4 +5,5 @@ fontSize=12 titleFontSize=14 isLookAndFeelDecorated=false isToolBarExteneded=false -aboutLogoFontSize=14 \ No newline at end of file +aboutLogoFontSize=14 +defaultGroupName= diff --git a/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java b/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java index 6946c474a..59a6f6490 100644 --- a/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java +++ b/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java @@ -92,6 +92,23 @@ public InitialAccountRegistrationFrame() this.getRootPane().setDefaultButton(signinButton); this.initAccountWizards(); + + // Create the default group + String groupName = Resources.getString("defaultGroupName"); + + if(groupName != null && groupName.length() > 0) + { + SimpleAccountRegistrationActivator.getContactList(). + createMetaContactGroup( + SimpleAccountRegistrationActivator.getContactList().getRoot(), + groupName); + + SimpleAccountRegistrationActivator.getConfigurationService(). + setProperty( + "net.java.sip.communicator.impl.gui.addcontact.lastContactParent", + groupName + ); + } } private void initAccountWizards() diff --git a/src/net/java/sip/communicator/plugin/simpleaccreg/Resources.java b/src/net/java/sip/communicator/plugin/simpleaccreg/Resources.java index e9d06e47f..b382c8675 100644 --- a/src/net/java/sip/communicator/plugin/simpleaccreg/Resources.java +++ b/src/net/java/sip/communicator/plugin/simpleaccreg/Resources.java @@ -61,7 +61,19 @@ public class Resources */ private static final ResourceBundle LOGIN_PROPERTIES_BUNDLE = ResourceBundle .getBundle(LOGIN_BUNDLE_NAME); + + /** + * Name of the bundle where we will search for application resources. + */ + private static final String APPLICATION_RESUORCE_LOCATION + = "resources.application"; + /** + * Bundle which handle access to application resources. + */ + private static final ResourceBundle applicationBundle + = ResourceBundle.getBundle(APPLICATION_RESUORCE_LOCATION); + /** * Returns an internationalized string corresponding to the given key. * @@ -121,4 +133,25 @@ public static String getLoginProperty(String key) return ""; } } + + /** + * Returns the application property corresponding to the given key. + * + * @param key The key of the string. + * + * @return the application property corresponding to the given key + */ + public static String getApplicationProperty(String key) + { + try + { + return applicationBundle.getString(key); + } + catch (MissingResourceException e) + { + log.error("Missing property.", e); + + return ""; + } + } } diff --git a/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java b/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java index 0946f724e..69ce58479 100644 --- a/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java +++ b/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java @@ -10,6 +10,7 @@ import java.util.*; import net.java.sip.communicator.service.configuration.*; +import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; @@ -24,6 +25,8 @@ public class SimpleAccountRegistrationActivator public static BundleContext bundleContext; private static ConfigurationService configService; + + private static MetaContactListService contactListService; public void start(BundleContext bc) throws Exception { @@ -124,4 +127,23 @@ private static boolean hasRegisteredAccounts() return hasRegisteredAccounts; } + + /** + * Returns the MetaContactListService obtained from the bundle + * context. + * @return the MetaContactListService obtained from the bundle + * context + */ + public static MetaContactListService getContactList() + { + if (contactListService == null) { + ServiceReference serviceReference = bundleContext + .getServiceReference(MetaContactListService.class.getName()); + + contactListService = (MetaContactListService) bundleContext + .getService(serviceReference); + } + + return contactListService; + } }