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