* \r
* @return Resource bundle\r
*/\r
- protected ResourceBundle getBundle () {\r
+ protected final ResourceBundle getBundle () {\r
return this.bundle;\r
}\r
}\r
package org.mxchange.addressbook;
/**
- *
+ * This exception is thrown when initFrame() is called twice.
+ *
* @author Roland Haeder
*/
public class FrameAlreadyInitializedException extends Exception {
import org.mxchange.addressbook.manager.contact.ManageableContact;\r
\r
/**\r
+ * A general interface which should be always expanded\r
*\r
* @author Roland Haeder\r
*/\r
/**\r
* Enables the client\r
*/\r
- public void enableIsRunning () {\r
+ public final void enableIsRunning () {\r
this.isRunning = true;\r
}\r
\r
* \r
* @return the currentMenu\r
*/\r
- public String getCurrentMenu () {\r
+ public final String getCurrentMenu () {\r
return this.currentMenu;\r
}\r
\r
* Current menu choice\r
* @param currentMenu the currentMenu to set\r
*/\r
- public void setCurrentMenu (final String currentMenu) {\r
+ public final void setCurrentMenu (final String currentMenu) {\r
this.currentMenu = currentMenu;\r
}\r
\r
* \r
* @return Whether the application is still active\r
*/\r
- public boolean isRunning () {\r
+ public final boolean isRunning () {\r
// In console client, 0 may have been used\r
return this.isRunning;\r
}\r
/**\r
* Disables running state, so the main loop can abort.\r
*/\r
- protected void disableIsRunning () {\r
+ protected final void disableIsRunning () {\r
this.isRunning = false;\r
}\r
\r
public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException {\r
// Ask the user for editing [name], [a]ddress or [other] data\r
char choice = this.enterChar(new char[]{'n', 'a', 'o', 'x'}, "Welchen Daten möchten Sie ändern? (n=Namensdaten, a=Anschriftsdaten, o=Andere, x=Zurück zur Hauptauswahl) ");\r
- \r
+\r
// @TODO Get rid of this ugly switch block, too\r
switch (choice) {\r
case 'n': // Name data\r
this.getContactManager().doChangeNameData(contact, this);\r
break;\r
- \r
+\r
case 'a': // Address data\r
this.getContactManager().doChangeAddressData(contact, this);\r
break;\r
- \r
+\r
case 'o': // Other data\r
this.getContactManager().doChangeOtherData(contact, this);\r
break;\r
- \r
+\r
case 'x': // Exit this menu\r
// Ignored as it should go back\r
break;\r
- \r
+\r
default:\r
// @TODO throw own exception\r
throw new UnhandledUserChoiceException(MessageFormat.format("Choice '{0}' not handled yet.", choice));\r
*/\r
package org.mxchange.addressbook.client.gui;\r
\r
+import java.text.MessageFormat;\r
import javax.swing.JFrame;\r
import org.mxchange.addressbook.BaseFrameworkSystem;\r
import org.mxchange.addressbook.FrameAlreadyInitializedException;\r
\r
/**\r
* Creates an instance of this frame with a client instance\r
+ * \r
* @param client\r
*/\r
private AddressbookFrame (final Client client) {\r
// Debug line\r
- this.getLogger().debug("Initializing Swing frame ...");\r
+ this.getLogger().trace(MessageFormat.format("client={0}: CALLED!", client));\r
\r
// Set frame instance\r
this.frame = new JFrame(AddressbookApplication.printableTitle());\r
this.setClient(client);\r
}\r
\r
- @Override\r
- public void setVisible (final boolean visible) {\r
- throw new UnsupportedOperationException("Not supported yet.");\r
- }\r
-\r
/**\r
- * Setups the frame\r
+ * Setups the frame, do not set isInitialized here\r
* \r
* @param client Client instance\r
*/\r
@Override\r
public void setupFrame (final Client client) {\r
+ // Debug line\r
+ this.getLogger().trace(MessageFormat.format("client={0}: CALLED!", client));\r
+\r
// Has the user entered own data?\r
if (this.getClient().getContactManager().isOwnContactAdded()) {\r
// Debug message\r
*/\r
@Override\r
public void initFrame () throws FrameAlreadyInitializedException {\r
+ // Debug line\r
+ this.getLogger().trace("CALLED!");\r
+\r
// Has this frame been initialized?\r
- if (this.isInitialized) {\r
+ if (this.isInitialized()) {\r
// Throw exception\r
throw new FrameAlreadyInitializedException();\r
}\r
this.isInitialized = true;\r
}\r
\r
+ /**\r
+ * Returns field isInitialized. This flag indicates whether this frame has been initialized or not.\r
+ * \r
+ * @return Field isInitialized\r
+ */\r
+ @Override\r
+ public final boolean isInitialized () {\r
+ return this.isInitialized;\r
+ }\r
+\r
/**\r
* Initialize components\r
*/\r
private void initComponents () {\r
+ // Debug line\r
+ this.getLogger().trace("CALLED!");\r
}\r
\r
}\r
import org.mxchange.addressbook.client.Client;\r
\r
/**\r
+ * An interface for applications with a frame\r
*\r
* @author Roland Haeder\r
*/\r
public interface ClientFrame extends FrameworkInterface {\r
-\r
- /**\r
- * From JFrame\r
- * \r
- * @param visible Set visibility\r
- */\r
- public void setVisible (boolean visible);\r
-\r
/**\r
* Setups the frame (and starts it). You have to call initFrame() before you\r
* can call this method.\r
* @throws org.mxchange.addressbook.FrameAlreadyInitializedException If this method has been called twice\r
*/\r
public void initFrame () throws FrameAlreadyInitializedException;\r
+\r
+ /**\r
+ * Returns field isInitialized. This flag indicates whether this frame has been initialized or not.\r
+ * \r
+ * @return Field isInitialized\r
+ */\r
+ public boolean isInitialized ();\r
}\r
return this.birthday;\r
}\r
\r
- /**\r
- * Birth day\r
- *\r
- * @param birthday the birthday to set\r
- */\r
- public void setBirthday (final String birthday) {\r
- this.birthday = birthday;\r
- }\r
-\r
/**\r
* Cellphone number\r
*\r
return this.cellphoneNumber;\r
}\r
\r
- /**\r
- * Cellphone number\r
- *\r
- * @param cellphoneNumber the cellphoneNumber to set\r
- */\r
- public void setCellphoneNumber (final String cellphoneNumber) {\r
- this.cellphoneNumber = cellphoneNumber;\r
- }\r
-\r
/**\r
* City\r
*\r
*\r
* @param city the city to set\r
*/\r
- public void setCity (final String city) {\r
+ private void setCity (final String city) {\r
this.city = city;\r
}\r
\r
*\r
* @param comment the comment to set\r
*/\r
- public void setComment (final String comment) {\r
+ private void setComment (final String comment) {\r
this.comment = comment;\r
}\r
\r
*\r
* @param companyName the companyName to set\r
*/\r
- public void setCompanyName (final String companyName) {\r
+ private void setCompanyName (final String companyName) {\r
this.companyName = companyName;\r
}\r
\r
*\r
* @param countryCode the countryCode to set\r
*/\r
- public void setCountryCode (final String countryCode) {\r
+ private void setCountryCode (final String countryCode) {\r
this.countryCode = countryCode;\r
}\r
\r
*\r
* @param emailAddress the emailAddress to set\r
*/\r
- public void setEmailAddress (final String emailAddress) {\r
+ private void setEmailAddress (final String emailAddress) {\r
this.emailAddress = emailAddress;\r
}\r
\r
*\r
* @param familyName the familyName to set\r
*/\r
- public void setFamilyName (final String familyName) {\r
+ private void setFamilyName (final String familyName) {\r
this.familyName = familyName;\r
}\r
\r
*\r
* @param faxNumber the faxNumber to set\r
*/\r
- public void setFaxNumber (final String faxNumber) {\r
+ private void setFaxNumber (final String faxNumber) {\r
this.faxNumber = faxNumber;\r
}\r
\r
*\r
* @param gender the gender to set\r
*/\r
- public void setGender (final char gender) {\r
+ private void setGender (final char gender) {\r
this.gender = gender;\r
}\r
\r
return this.houseNumber;\r
}\r
\r
- /**\r
- * House number\r
- *\r
- * @param houseNumber the houseNumber to set\r
- */\r
- public void setHouseNumber (final int houseNumber) {\r
- this.houseNumber = houseNumber;\r
- }\r
-\r
/**\r
* Phone number\r
*\r
return this.phoneNumber;\r
}\r
\r
- /**\r
- * Phone number\r
- *\r
- * @param phoneNumber the phoneNumber to set\r
- */\r
- public void setPhoneNumber (final String phoneNumber) {\r
- this.phoneNumber = phoneNumber;\r
- }\r
-\r
/**\r
* Street\r
*\r
*\r
* @param street the street to set\r
*/\r
- public void setStreet (final String street) {\r
+ protected final void setStreet (final String street) {\r
this.street = street;\r
}\r
\r
*\r
* @return the surname\r
*/\r
- public String getSurname () {\r
+ public final String getSurname () {\r
return this.surname;\r
}\r
\r
- /**\r
- * Surname\r
- *\r
- * @param surname the surname to set\r
- */\r
- public void setSurname (final String surname) {\r
- this.surname = surname;\r
- }\r
-\r
/**\r
* Some "getter" for a translated/human-readable gender\r
* @return gender Human-readable gender\r
*\r
* @return the zipCode\r
*/\r
- public long getZipCode () {\r
+ public final long getZipCode () {\r
return this.zipCode;\r
}\r
\r
*\r
* @param zipCode the zipCode to set\r
*/\r
- public void setZipCode (final long zipCode) {\r
+ protected final void setZipCode (final long zipCode) {\r
this.zipCode = zipCode;\r
}\r
-\r
+ \r
@Override\r
public int hashCode () {\r
int hash = 7;\r
*\r
* @return Own data?\r
*/\r
- public boolean isOwnContact () {\r
+ public final boolean isOwnContact () {\r
return this.ownContact;\r
}\r
\r
public void show (final Client client) {\r
// Display name "box"\r
client.displayNameBox((Contact) this);\r
-\r
- // Display address "box"\r
+ \r
+ // Display address "box"\r
client.displayAddressBox((Contact) this);\r
-\r
- // Display other data "box"\r
+ \r
+ // Display other data "box"\r
client.displayOtherDataBox((Contact) this);\r
}\r
\r
* Enables the flag "own data" which signals that this contact is the user's\r
* own data.\r
*/\r
- protected void enableFlagOwnContact () {\r
+ protected final void enableFlagOwnContact () {\r
this.ownContact = true;\r
}\r
+\r
+ /**\r
+ * Surname\r
+ *\r
+ * @param surname the surname to set\r
+ */\r
+ protected final void setSurname (final String surname) {\r
+ this.surname = surname;\r
+ }\r
+\r
+ /**\r
+ * Phone number\r
+ *\r
+ * @param phoneNumber the phoneNumber to set\r
+ */\r
+ protected final void setPhoneNumber (final String phoneNumber) {\r
+ this.phoneNumber = phoneNumber;\r
+ }\r
+\r
+ /**\r
+ * House number\r
+ *\r
+ * @param houseNumber the houseNumber to set\r
+ */\r
+ protected final void setHouseNumber (final int houseNumber) {\r
+ this.houseNumber = houseNumber;\r
+ }\r
+\r
+ /**\r
+ * Cellphone number\r
+ *\r
+ * @param cellphoneNumber the cellphoneNumber to set\r
+ */\r
+ protected final void setCellphoneNumber (final String cellphoneNumber) {\r
+ this.cellphoneNumber = cellphoneNumber;\r
+ }\r
+\r
+ /**\r
+ * Birth day\r
+ *\r
+ * @param birthday the birthday to set\r
+ */\r
+ protected final void setBirthday (final String birthday) {\r
+ this.birthday = birthday;\r
+ }\r
}\r
// Make sure all constructors are called\r
this();\r
\r
- this.setGender(gender);\r
- this.setSurname(surname);\r
- this.setFamilyName(familyName);\r
- this.setCompanyName(companyName);\r
+ // Update all data\r
+ this.updateNameData(gender, surname, familyName, companyName);\r
}\r
\r
/**\r
* Gets an iterator for contacts\r
* \r
* @return Iterator for contacts\r
+ * @throws org.mxchange.addressbook.BadTokenException If the CSV token is badly formulated\r
*/\r
public Iterator<Contact> contactIterator () throws BadTokenException;\r
}\r
public void doShutdown () {\r
try {\r
// Close file\r
- this.storageFile.close();\r
+ this.getStorageFile().close();\r
} catch (final IOException ex) {\r
this.getLogger().catching(ex);\r
System.exit(1);\r
long length = 0;\r
\r
try {\r
- length = this.storageFile.length();\r
+ length = this.getStorageFile().length();\r
this.getLogger().debug(MessageFormat.format("length={0}", length));\r
} catch (final IOException ex) {\r
// Length cannot be determined\r
\r
try {\r
// Rewind underlaying database file\r
- this.storageFile.seek(0);\r
+ this.getStorageFile().seek(0);\r
} catch (final IOException ex) {\r
this.getLogger().catching(ex);\r
System.exit(1);\r
this.getLogger().debug(MessageFormat.format("str({0})={1}", str.length(), str));\r
\r
// The string is now a valid CSV string\r
- this.storageFile.writeBytes(str);\r
+ this.getStorageFile().writeBytes(str);\r
}\r
\r
/**\r
}\r
}\r
\r
+ /**\r
+ * Returns storage file\r
+ * \r
+ * @return Storage file instance\r
+ */\r
+ private RandomAccessFile getStorageFile () {\r
+ return this.storageFile;\r
+ }\r
+\r
/**\r
* Checks whether end of file has been reached\r
* \r
boolean isEof = true;\r
\r
try {\r
- isEof = (this.storageFile.getFilePointer() >= this.length());\r
+ isEof = (this.getStorageFile().getFilePointer() >= this.length());\r
} catch (final IOException ex) {\r
// Length cannot be determined\r
this.getLogger().catching(ex);\r
String input = null;\r
\r
try {\r
- input = this.storageFile.readLine();\r
+ input = this.getStorageFile().readLine();\r
} catch (final IOException ex) {\r
this.getLogger().catching(ex);\r
}\r
* \r
* @return the backend\r
*/\r
- protected DatabaseBackend getBackend () {\r
+ protected final DatabaseBackend getBackend () {\r
return this.backend;\r
}\r
\r
* \r
* @param backend the backend to set\r
*/\r
- protected void setBackend (final DatabaseBackend backend) {\r
+ protected final void setBackend (final DatabaseBackend backend) {\r
this.backend = backend;\r
}\r
\r
* @version 0.0\r
* @since 0.0\r
*/\r
-public class BaseManager extends BaseFrameworkSystem {\r
+public class BaseManager extends BaseFrameworkSystem implements Manageable {\r
/**\r
* No instances can be created of this class\r
*/\r
@Override\r
public void doShutdown () {\r
// Shut down the database layer\r
- this.contactDatabase.doShutdown();\r
+ this.getContactDatabase().doShutdown();\r
}\r
\r
/**\r
}\r
\r
@Override\r
- public int getColumnCount () {\r
+ public final int getColumnCount () {\r
return this.columnNames.size();\r
}\r
\r
* @return size of contact "book"\r
*/\r
@Override\r
- public int size () {\r
+ public final int size () {\r
return this.contacts.size();\r
}\r
\r
* Fills the column names array with strings from bundle\r
*/\r
private void fillColumnNamesFromBundle () {\r
+ // Debug message\r
+ this.getLogger().trace("CALLED!");\r
+\r
// First get an iterator from key set to iterate over\r
Iterator<String> iterator = this.getBundle().keySet().iterator();\r
\r
this.columnNames.add(this.getBundle().getString(key));\r
}\r
}\r
+\r
+ // Debug message\r
+ this.getLogger().trace(MessageFormat.format("getColumnCount()={0}: EXIT!", this.getColumnCount()));\r
}\r
\r
/**\r