PageRenderTime 35ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/src/mpv5/ui/panels/AddressPanel.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 506 lines | 401 code | 59 blank | 46 comment | 25 complexity | 1155e2b2dc823727bb78e334a4ec92b3 MD5 | raw file
Possible License(s): LGPL-3.0, Apache-2.0, GPL-3.0, GPL-2.0, AGPL-3.0, JSON, BSD-3-Clause
  1. /*
  2. * This file is part of YaBS.
  3. *
  4. * YaBS is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * YaBS is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with YaBS. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /*
  18. * AddressPanel.java
  19. *
  20. * Created on 26.02.2009, 11:33:08
  21. */
  22. package mpv5.ui.panels;
  23. import java.awt.Color;
  24. import javax.swing.JTabbedPane;
  25. import javax.swing.SwingUtilities;
  26. import mpv5.db.common.Context;
  27. import mpv5.db.common.DatabaseObject;
  28. import mpv5.db.common.NodataFoundException;
  29. import mpv5.globals.Messages;
  30. import mpv5.db.objects.Address;
  31. import mpv5.db.objects.Contact;
  32. import mpv5.logging.Log;
  33. import mpv5.i18n.LanguageManager;
  34. import mpv5.ui.frames.MPView;
  35. import mpv5.utils.models.MPComboBoxModelItem;
  36. import mpv5.utils.ui.TextFieldUtils;
  37. /**
  38. *
  39. *
  40. */
  41. public class AddressPanel extends javax.swing.JPanel implements DataPanel {
  42. private static final long serialVersionUID = 8513278191283931211L;
  43. private Address dataOwner = new Address();
  44. private Contact dataParent = new Contact();
  45. private java.util.ResourceBundle bundle = mpv5.i18n.LanguageManager.getBundle();
  46. /** Creates new form AddressPanel */
  47. public AddressPanel() {
  48. initComponents();
  49. dataOwner.setCountry(mpv5.db.objects.User.getCurrentUser().__getDefcountry());
  50. refresh();
  51. }
  52. /** This method is called from within the constructor to
  53. * initialize the form.
  54. * WARNING: Do NOT modify this code. The content of this method is
  55. * always regenerated by the Form Editor.
  56. */
  57. @SuppressWarnings("unchecked")
  58. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  59. private void initComponents() {
  60. buttonGroup1 = new javax.swing.ButtonGroup();
  61. jPanel2 = new javax.swing.JPanel();
  62. mainaddress = new javax.swing.JPanel();
  63. title = new mpv5.ui.beans.LabeledTextField();
  64. street = new mpv5.ui.beans.LabeledTextField();
  65. cname = new mpv5.ui.beans.LabeledTextField();
  66. prename = new mpv5.ui.beans.LabeledTextField();
  67. zip = new mpv5.ui.beans.LabeledTextField();
  68. male = new javax.swing.JRadioButton();
  69. female = new javax.swing.JRadioButton();
  70. department = new mpv5.ui.beans.LabeledTextField();
  71. jLabel5 = new javax.swing.JLabel();
  72. countryselect = new javax.swing.JComboBox();
  73. city = new mpv5.ui.beans.LabeledTextField();
  74. jButton2 = new javax.swing.JButton();
  75. jButton1 = new javax.swing.JButton();
  76. badress = new javax.swing.JCheckBox();
  77. dadress = new javax.swing.JCheckBox();
  78. setBackground(new java.awt.Color(204, 204, 204));
  79. setName("Address#"); // NOI18N
  80. jPanel2.setBackground(new java.awt.Color(204, 204, 204));
  81. jPanel2.setBorder(null);
  82. jPanel2.setName("jPanel2"); // NOI18N
  83. jPanel2.setLayout(new java.awt.BorderLayout());
  84. mainaddress.setBackground(new java.awt.Color(204, 204, 204));
  85. mainaddress.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
  86. mainaddress.setName("mainaddress"); // NOI18N
  87. java.util.ResourceBundle bundle = mpv5.i18n.LanguageManager.getBundle(); // NOI18N
  88. title.set_Label(bundle.getString("AddressPanel.title._Label")); // NOI18N
  89. title.setMaximumSize(new java.awt.Dimension(120, 21));
  90. title.setMinimumSize(new java.awt.Dimension(120, 21));
  91. title.setName("title"); // NOI18N
  92. title.setPreferredSize(new java.awt.Dimension(120, 21));
  93. street.set_Label(bundle.getString("AddressPanel.street._Label")); // NOI18N
  94. street.setMaximumSize(new java.awt.Dimension(120, 21));
  95. street.setMinimumSize(new java.awt.Dimension(120, 21));
  96. street.setName("street"); // NOI18N
  97. street.setPreferredSize(new java.awt.Dimension(120, 21));
  98. cname.set_Label(bundle.getString("AddressPanel.cname._Label")); // NOI18N
  99. cname.setMaximumSize(new java.awt.Dimension(120, 21));
  100. cname.setMinimumSize(new java.awt.Dimension(120, 21));
  101. cname.setName("cname"); // NOI18N
  102. cname.setPreferredSize(new java.awt.Dimension(120, 21));
  103. prename.set_Label(bundle.getString("AddressPanel.prename._Label")); // NOI18N
  104. prename.setMaximumSize(new java.awt.Dimension(120, 21));
  105. prename.setMinimumSize(new java.awt.Dimension(120, 21));
  106. prename.setName("prename"); // NOI18N
  107. prename.setPreferredSize(new java.awt.Dimension(120, 21));
  108. zip.set_Label(bundle.getString("AddressPanel.zip._Label")); // NOI18N
  109. zip.setMaximumSize(new java.awt.Dimension(120, 21));
  110. zip.setMinimumSize(new java.awt.Dimension(120, 21));
  111. zip.setName("zip"); // NOI18N
  112. zip.setPreferredSize(new java.awt.Dimension(120, 21));
  113. male.setBackground(new java.awt.Color(204, 204, 204));
  114. male.setFont(male.getFont().deriveFont(male.getFont().getStyle() & ~java.awt.Font.BOLD));
  115. male.setSelected(true);
  116. male.setText(bundle.getString("AddressPanel.male.text")); // NOI18N
  117. male.setName("male"); // NOI18N
  118. female.setBackground(new java.awt.Color(204, 204, 204));
  119. female.setFont(female.getFont().deriveFont(female.getFont().getStyle() & ~java.awt.Font.BOLD));
  120. female.setText(bundle.getString("AddressPanel.female.text")); // NOI18N
  121. female.setName("female"); // NOI18N
  122. department.set_Label(bundle.getString("AddressPanel.department._Label")); // NOI18N
  123. department.setFont(department.getFont().deriveFont(department.getFont().getStyle() | java.awt.Font.BOLD));
  124. department.setMaximumSize(new java.awt.Dimension(120, 21));
  125. department.setMinimumSize(new java.awt.Dimension(120, 21));
  126. department.setName("department"); // NOI18N
  127. department.setPreferredSize(new java.awt.Dimension(120, 21));
  128. jLabel5.setFont(jLabel5.getFont());
  129. jLabel5.setText(bundle.getString("AddressPanel.jLabel5.text")); // NOI18N
  130. jLabel5.setName("jLabel5"); // NOI18N
  131. countryselect.setMaximumSize(new java.awt.Dimension(120, 21));
  132. countryselect.setMinimumSize(new java.awt.Dimension(120, 21));
  133. countryselect.setName("countryselect"); // NOI18N
  134. countryselect.setPreferredSize(new java.awt.Dimension(120, 21));
  135. countryselect.addActionListener(new java.awt.event.ActionListener() {
  136. public void actionPerformed(java.awt.event.ActionEvent evt) {
  137. countryselectActionPerformed(evt);
  138. }
  139. });
  140. city.set_Label(bundle.getString("AddressPanel.city._Label")); // NOI18N
  141. city.setMaximumSize(new java.awt.Dimension(120, 21));
  142. city.setMinimumSize(new java.awt.Dimension(120, 21));
  143. city.setName("city"); // NOI18N
  144. city.setPreferredSize(new java.awt.Dimension(120, 21));
  145. jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/16/filesave.png"))); // NOI18N
  146. jButton2.setText(bundle.getString("AddressPanel.jButton2.text")); // NOI18N
  147. jButton2.setToolTipText(bundle.getString("AddressPanel.jButton2.toolTipText")); // NOI18N
  148. jButton2.setName("jButton2"); // NOI18N
  149. jButton2.addActionListener(new java.awt.event.ActionListener() {
  150. public void actionPerformed(java.awt.event.ActionEvent evt) {
  151. jButton2ActionPerformed(evt);
  152. }
  153. });
  154. jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/16/remove.png"))); // NOI18N
  155. jButton1.setText(bundle.getString("AddressPanel.jButton1.text")); // NOI18N
  156. jButton1.setToolTipText(bundle.getString("AddressPanel.jButton1.toolTipText")); // NOI18N
  157. jButton1.setName("jButton1"); // NOI18N
  158. jButton1.addActionListener(new java.awt.event.ActionListener() {
  159. public void actionPerformed(java.awt.event.ActionEvent evt) {
  160. jButton1ActionPerformed(evt);
  161. }
  162. });
  163. badress.setBackground(new java.awt.Color(204, 204, 204));
  164. badress.setFont(badress.getFont());
  165. badress.setText(bundle.getString("AddressPanel.badress.text")); // NOI18N
  166. badress.setName("badress"); // NOI18N
  167. dadress.setBackground(new java.awt.Color(204, 204, 204));
  168. dadress.setFont(dadress.getFont());
  169. dadress.setText(bundle.getString("AddressPanel.dadress.text")); // NOI18N
  170. dadress.setName("dadress"); // NOI18N
  171. javax.swing.GroupLayout mainaddressLayout = new javax.swing.GroupLayout(mainaddress);
  172. mainaddress.setLayout(mainaddressLayout);
  173. mainaddressLayout.setHorizontalGroup(
  174. mainaddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  175. .addGroup(mainaddressLayout.createSequentialGroup()
  176. .addContainerGap()
  177. .addGroup(mainaddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  178. .addGroup(mainaddressLayout.createSequentialGroup()
  179. .addGroup(mainaddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  180. .addComponent(department, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE)
  181. .addComponent(title, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  182. .addComponent(street, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  183. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  184. .addGroup(mainaddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  185. .addGroup(mainaddressLayout.createSequentialGroup()
  186. .addGroup(mainaddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  187. .addComponent(zip, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  188. .addComponent(prename, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE))
  189. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  190. .addGroup(mainaddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  191. .addComponent(city, javax.swing.GroupLayout.PREFERRED_SIZE, 312, javax.swing.GroupLayout.PREFERRED_SIZE)
  192. .addComponent(cname, javax.swing.GroupLayout.PREFERRED_SIZE, 312, javax.swing.GroupLayout.PREFERRED_SIZE)))
  193. .addGroup(mainaddressLayout.createSequentialGroup()
  194. .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
  195. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  196. .addComponent(countryselect, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE)
  197. .addGap(18, 18, 18)
  198. .addComponent(male, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  199. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  200. .addComponent(female, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE))))
  201. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainaddressLayout.createSequentialGroup()
  202. .addComponent(badress, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
  203. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  204. .addComponent(dadress, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE)
  205. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 297, Short.MAX_VALUE)
  206. .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
  207. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  208. .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)))
  209. .addContainerGap())
  210. );
  211. mainaddressLayout.setVerticalGroup(
  212. mainaddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  213. .addGroup(mainaddressLayout.createSequentialGroup()
  214. .addGap(12, 12, 12)
  215. .addGroup(mainaddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
  216. .addComponent(department, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  217. .addComponent(countryselect, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  218. .addComponent(jLabel5)
  219. .addComponent(male)
  220. .addComponent(female))
  221. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  222. .addGroup(mainaddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
  223. .addComponent(title, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  224. .addComponent(prename, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  225. .addComponent(cname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  226. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  227. .addGroup(mainaddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
  228. .addComponent(street, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  229. .addComponent(zip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  230. .addComponent(city, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  231. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  232. .addGroup(mainaddressLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
  233. .addComponent(jButton2)
  234. .addComponent(jButton1)
  235. .addComponent(badress)
  236. .addComponent(dadress))
  237. .addContainerGap(23, Short.MAX_VALUE))
  238. );
  239. jPanel2.add(mainaddress, java.awt.BorderLayout.CENTER);
  240. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
  241. this.setLayout(layout);
  242. layout.setHorizontalGroup(
  243. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  244. .addGroup(layout.createSequentialGroup()
  245. .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  246. .addContainerGap(25, Short.MAX_VALUE))
  247. );
  248. layout.setVerticalGroup(
  249. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  250. .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  251. );
  252. }// </editor-fold>//GEN-END:initComponents
  253. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
  254. removeAddress();
  255. }//GEN-LAST:event_jButton1ActionPerformed
  256. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
  257. addAddress();
  258. }//GEN-LAST:event_jButton2ActionPerformed
  259. private void countryselectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_countryselectActionPerformed
  260. }//GEN-LAST:event_countryselectActionPerformed
  261. // Variables declaration - do not modify//GEN-BEGIN:variables
  262. private javax.swing.JCheckBox badress;
  263. private javax.swing.ButtonGroup buttonGroup1;
  264. private mpv5.ui.beans.LabeledTextField city;
  265. private mpv5.ui.beans.LabeledTextField cname;
  266. private javax.swing.JComboBox countryselect;
  267. private javax.swing.JCheckBox dadress;
  268. private mpv5.ui.beans.LabeledTextField department;
  269. private javax.swing.JRadioButton female;
  270. private javax.swing.JButton jButton1;
  271. private javax.swing.JButton jButton2;
  272. private javax.swing.JLabel jLabel5;
  273. private javax.swing.JPanel jPanel2;
  274. private javax.swing.JPanel mainaddress;
  275. private javax.swing.JRadioButton male;
  276. private mpv5.ui.beans.LabeledTextField prename;
  277. private mpv5.ui.beans.LabeledTextField street;
  278. private mpv5.ui.beans.LabeledTextField title;
  279. private mpv5.ui.beans.LabeledTextField zip;
  280. // End of variables declaration//GEN-END:variables
  281. public String city_;
  282. public String cname_;
  283. public String taxnumber_;
  284. public String department_;
  285. public boolean ismale_;
  286. public String prename_;
  287. public String street_;
  288. public String title_;
  289. public String zip_;
  290. public String company_;
  291. public String country_;
  292. public int ids_;
  293. public int contactsids_;
  294. public int groupsids_ = 1;
  295. public java.util.Date dateadded_ = new java.util.Date();
  296. public int intaddedby_ = 4343;
  297. public int inttype_;
  298. public boolean collectData() {
  299. if (cname.getText().length() == 0) {
  300. return false;
  301. }
  302. ids_ = dataOwner.__getIDS();
  303. city_ = city.get_Text();
  304. cname_ = cname.get_Text();
  305. taxnumber_ = dataParent.__getTaxnumber();
  306. company_ = dataParent.__getCompany();
  307. country_ = dataParent.__getCountry();
  308. ismale_ = male.isSelected();
  309. prename_ = prename.get_Text();
  310. street_ = street.get_Text();
  311. title_ = title.get_Text();
  312. zip_ = zip.get_Text();
  313. department_ = department.get_Text();
  314. contactsids_ = dataParent.__getIDS();
  315. if (badress.isSelected() && dadress.isSelected()) {
  316. inttype_ = 2;
  317. } else if (badress.isSelected()) {
  318. inttype_ = 0;
  319. } else if (dadress.isSelected()) {
  320. inttype_ = 1;
  321. }
  322. if (countryselect.getSelectedItem() != null) {
  323. country_ = String.valueOf(((MPComboBoxModelItem) countryselect.getSelectedItem()).getValue());
  324. } else {
  325. country_ = "";
  326. }
  327. return true;
  328. }
  329. public void exposeData() {
  330. city.set_Text(city_);
  331. male.setSelected(ismale_);
  332. female.setSelected(!ismale_);
  333. prename.set_Text(prename_);
  334. street.set_Text(street_);
  335. cname.setText(cname_);
  336. title.set_Text(title_);
  337. zip.set_Text(zip_);
  338. department.set_Text(department_);
  339. try {
  340. dataParent = (Contact) DatabaseObject.getObject(Context.getContact(), contactsids_);
  341. } catch (NodataFoundException ex) {
  342. Log.Debug(this, ex.getMessage());
  343. }
  344. try {
  345. countryselect.setSelectedIndex(MPComboBoxModelItem.getItemIDfromValue(country_, countryselect.getModel()));
  346. } catch (Exception e) {
  347. try {
  348. countryselect.setSelectedIndex(MPComboBoxModelItem.getItemIDfromValue(dataParent.__getCountry(), countryselect.getModel()));
  349. } catch (Exception ex) {
  350. }
  351. }
  352. badress.setSelected(inttype_ == 0 || inttype_ == 2);
  353. dadress.setSelected(inttype_ == 1 || inttype_ == 2);
  354. }
  355. public DatabaseObject getDataOwner() {
  356. return dataOwner;
  357. }
  358. public void setDataOwner(DatabaseObject object, boolean populate) {
  359. dataOwner = (Address) object;
  360. if (populate) {
  361. dataOwner.setPanelData(this);
  362. this.exposeData();
  363. if (this.getParent() instanceof JTabbedPane) {
  364. JTabbedPane jTabbedPane = (JTabbedPane) this.getParent();
  365. jTabbedPane.setTitleAt(jTabbedPane.getSelectedIndex(), Messages.CONTACT + cname_);
  366. }
  367. }
  368. }
  369. public void refresh() {
  370. try {
  371. countryselect.setModel(LanguageManager.getCountriesAsComboBoxModel());
  372. Runnable runnable = new Runnable() {
  373. public void run() {
  374. countryselect.setSelectedIndex(MPComboBoxModelItem.getItemID(mpv5.db.objects.User.getCurrentUser().__getDefcountry(), countryselect.getModel()));
  375. }
  376. };
  377. SwingUtilities.invokeLater(runnable);
  378. } catch (Exception e) {
  379. }
  380. }
  381. public void paste(DatabaseObject... dbos) {
  382. for (DatabaseObject dbo : dbos) {
  383. if (dbo.getDbIdentity().equals(Context.getAddress().getDbIdentity())) {
  384. setDataOwner(dbo, true);
  385. } else {
  386. mpv5.YabsViewProxy.instance().addMessage(Messages.NOT_POSSIBLE.toString() + Messages.ACTION_PASTE.toString(), Color.RED);
  387. }
  388. }
  389. }
  390. public void showRequiredFields() {
  391. TextFieldUtils.blinkerRed(cname);
  392. }
  393. /**
  394. * Removes this adress from the current user
  395. */
  396. public void removeAddress() {
  397. this.getParent().remove(this);
  398. dataOwner.delete();
  399. }
  400. /**
  401. * Associates this adress with the current user
  402. */
  403. public void addAddress() {
  404. if (dataParent.isExisting()) {
  405. dataOwner.setContactsids(dataParent.__getIDS());
  406. dataOwner.getPanelData(this);
  407. if (!dataOwner.save()) {
  408. showRequiredFields();
  409. } else {
  410. ((JTabbedPane) getParent()).setTitleAt(
  411. ((JTabbedPane) getParent()).getSelectedIndex(),
  412. dataOwner.__getCname());
  413. }
  414. }
  415. }
  416. /**
  417. * @return the dataParent
  418. */
  419. public Contact getDataParent() {
  420. return dataParent;
  421. }
  422. /**
  423. * @param dataParent the dataParent to set
  424. */
  425. public void setDataParent(Contact dataParent) {
  426. this.dataParent = dataParent;
  427. }
  428. public void showSearchBar(boolean show) {
  429. throw new UnsupportedOperationException("Not supported yet.");
  430. }
  431. @Override
  432. public void actionAfterSave() {
  433. }
  434. @Override
  435. public void actionAfterCreate() {
  436. }
  437. public void actionBeforeCreate() {
  438. }
  439. public void actionBeforeSave() {
  440. }
  441. public void mail() {
  442. throw new UnsupportedOperationException("Not supported yet.");
  443. }
  444. public void print() {
  445. mpv5.utils.export.Export.print(this);
  446. }
  447. }