*/
package org.mxchange.addressbook.application;
+import java.io.IOException;
import java.text.MessageFormat;
-import org.mxchange.addressbook.BaseFrameworkSystem;
-import org.mxchange.addressbook.client.Client;
+import org.mxchange.addressbook.BaseAddressbookSystem;
+import org.mxchange.addressbook.client.AddressbookClient;
import org.mxchange.addressbook.client.console.ConsoleClient;
import org.mxchange.addressbook.client.gui.SwingClient;
-import org.mxchange.addressbook.exceptions.UnhandledUserChoiceException;
-import org.mxchange.addressbook.manager.application.ApplicationManager;
+import org.mxchange.jcore.BaseFrameworkSystem;
+import org.mxchange.jcore.application.Application;
+import org.mxchange.jcore.client.Client;
+import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
+import org.mxchange.jcore.manager.application.ApplicationManager;
/**
- * ============================================ AddressbookApplication
- * management: ============================================
- *
+ * ============================================
+ * AddressbookApplication management:
+ * ============================================
+ *
* Inernet("public" service) and Intranet
- *
- * Version 1.0+: - Single-user local application - Fields: + Gender + Surname +
- * Family name + Company name + Street + number + ZIP code + City + Landline
- * number + Fax number + Cell phone number + Email address + Birth day + Comment
- * (?) - Edit own data - Add new contact - Edit contacts - Delete contacts -
- * Categorization of contacts
- *
- * Version 1.1+: - Permanent storage in database
- *
- * Version 2.0+: - Multi-user web application - Local user registration / login
- * / resend confirmation link / password recovery - User groups (aka. teams) -
- * Administration area (user role) + Create/edit/delete groups +
- * Edit/delete/lock/unlock user + Assign user roles/rights - Allow other users /
- * groups to view addressbook + Full addressbook + Only some categories - VCard
- * export + Allow users/guests (not recommended) - XML export of addressbook and
- * compressable (ZIP) - Form to contact other user/group without need of mail
- * program + User can disabled this - Directory for ussers/groups (who allowed
- * to be listed) + Simple click to add user to own addressbook + Search form?
- *
- * Version 2.1+: - Multi-language support
- *
- * Version 2.2+:("socialized") - "Social login" (OpenID consumer) + Connect user
- * account to social account + Sync own data? - "Social profile" + OpenID
- * provider + RSS/activity feed
- *
- * ============================================ Time esitmation:
- * ============================================ 1.0 (console): + 2 days
- *
- * 1.1 (database): + 2 day + Initial tables: contacts, categories,
- * contact_category
- *
- * 2.0 (web): + 3 days + Additional tables: admins (?), admin_rights, groups,
- * users, user_contacts, user_user_rights, user_category_rights,
- *
- * 2.1 (language) + 1 day + Additional tables: languages (disable, enable
- * language "pack" ?)
- *
- * 2.2 (social): + 3 days + Additional tables: ???
- *
+ *
+ * Version 1.0+:
+ * - Single-user local application
+ * - Fields:
+ * + Gender
+ * + Surname
+ * + Family name
+ * + Company name
+ * + Street + number
+ * + ZIP code
+ * + City
+ * + Landline number
+ * + Fax number
+ * + Cell phone number
+ * + Email address
+ * + Birth day
+ * + Comment (?)
+ * - Edit own data
+ * - Add new contact
+ * - Edit contacts
+ * - Delete contacts
+ * - Categorization of contacts
+ *
+ * Version 1.1+:
+ * - Permanent storage in database
+ *
+ * Version 2.0+:
+ * - Multi-user web application
+ * - Local user registration / login / resend confirmation link / password
+ * recovery
+ * - User groups (aka. teams)
+ * - Administration area (user role)
+ * + Create/edit/delete groups
+ * + Edit/delete/lock/unlock user
+ * + Assign user roles/rights
+ * - Allow other users / groups to view addressbook
+ * + Full addressbook
+ * + Only some categories
+ * - VCard export
+ * + Allow users/guests (not recommended)
+ * - XML export of addressbook and compressable (ZIP)
+ * - Form to contact other user/group without need of mail program
+ * + User can disabled this
+ * - Directory for ussers/groups (who allowed to be listed)
+ * + Simple click to add user to own addressbook
+ * + Search form?
+ *
+ * Version 2.1+:
+ * - Multi-language support
+ *
+ * Version 2.2+:("socialized")
+ * - "Social login" (OpenID consumer)
+ * + Connect user account to social account
+ * + Sync own data?
+ * - "Social profile"
+ * + OpenID provider
+ * + RSS/activity feed
+ *
+ * ============================================
+ * Time esitmation:
+ * ============================================
+ * 1.0 (console):
+ * + 2 days
+ *
+ * 1.1 (database):
+ * + 2 day
+ * + Initial tables: contacts, categories, contact_category
+ *
+ * 2.0 (web):
+ * + 3 days
+ * + Additional tables: admins (?), admin_rights, groups,
+ * users, user_contacts, user_user_rights, user_category_rights,
+ *
+ * 2.1 (language)
+ * + 1 day
+ * + Additional tables: languages (disable, enable language "pack" ?)
+ *
+ * 2.2 (social):
+ * + 3 days
+ * + Additional tables: ???
+*
* @author Roland Haeder
* @version 0.0
- * @since 0.0
*/
-public class AddressbookApplication extends BaseFrameworkSystem implements Application {
+public class AddressbookApplication extends BaseAddressbookSystem implements Application {
/**
* Application title
*/
public static final String APP_VERSION = "0.0"; //NOI18N
- /**
- * Self instance
- */
- private static Application selfInstance;
-
/**
* Console client is enabled by default
*/
/**
* Protected constructor
+ * @throws java.io.IOException If any IO error occurs
*/
- protected AddressbookApplication () {
- // Set own instance
- selfInstance = this;
- }
+ protected AddressbookApplication () throws IOException {
+ // Init properties file
+ this.initProperties();
- /**
- * Getter for printable application name
- *
- * @return A printable name
- */
- public static String printableTitle () {
- return MessageFormat.format("{0} v{1}", APP_TITLE, APP_VERSION); //NOI18N
+ // Init bundle
+ this.initBundle();
}
/**
*/
@Override
public void doMainLoop () {
+ // Get client and cast it
+ AddressbookClient client = (AddressbookClient) this.getClient();
+
// Debug message
this.getLogger().trace("CALLED!"); //NOI18N
this.showIntro();
// Set current menu to main
- this.getClient().setCurrentMenu("main"); //NOI18N
+ client.setCurrentMenu("main"); //NOI18N
// --- Main loop starts here ---
while (this.getClient().isRunning()) {
// The application is still active, show menu selection
- this.getClient().showCurrentMenu();
+ client.showCurrentMenu();
try {
// Ask for user input and run proper method
- this.getClient().doUserMenuChoice();
+ client.doUserMenuChoice();
} catch (final UnhandledUserChoiceException ex) {
this.getLogger().catching(ex);
}
// Ignore it
}
}
- // --- Main loop ends here ---
+ // --- Main loop ends here ---
// Debug message
this.getLogger().debug("Main loop exit - shutting down ..."); //NOI18N
}
+ /**
+ * Shuts down the application.
+ */
+ @Override
+ public void doShutdown () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
+ // Shutdown client
+ this.getClient().doShutdown();
+
+ this.getLogger().info("End of program (last line)"); //NOI18N
+ System.exit(0);
+ }
+
/**
* Enables console client by setting propper flag
*/
* @param args the command line arguments
*/
public static void main (String[] args) {
- // Start application
- new AddressbookApplication().start(args);
- }
-
- /**
- * Shuts down the application.
- */
- @Override
- public void doShutdown () {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- // Shutdown client
- this.getClient().doShutdown();
-
- this.getLogger().info("End of program (last line)"); //NOI18N
- System.exit(0);
+ try {
+ // Start application
+ new AddressbookApplication().start(args);
+ } catch (final IOException ex) {
+ // Get instance
+ BaseFrameworkSystem.getInstance().getLogger().catching(ex);
+ System.exit(1);
+ }
}
/**
- * Getter for this application
+ * Getter for printable application name
*
- * @return Instance from this application
+ * @return A printable name
*/
- public static final Application getInstance () {
- // Return it
- return selfInstance;
+ public static String printableTitle () {
+ return MessageFormat.format("{0} v{1}", APP_TITLE, APP_VERSION); //NOI18N
}
}