PageRenderTime 536ms CodeModel.GetById 141ms app.highlight 282ms RepoModel.GetById 100ms app.codeStats 1ms

/src/mpv5/ui/panels/ConversationPanel.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 1227 lines | 1023 code | 108 blank | 96 comment | 104 complexity | 1b5eacaa90c82913ee2e48e342d518d4 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1/*
   2 * To change this template, choose Tools | Templates
   3 * and open the template in the editor.
   4 */
   5
   6/*
   7 * ConversationUI.java
   8 *
   9 * Created on 06.04.2011, 20:17:07
  10 */
  11package mpv5.ui.panels;
  12
  13import enoa.handler.TemplateHandler;
  14import java.awt.BorderLayout;
  15import java.awt.Color;
  16import java.awt.GraphicsEnvironment;
  17import java.awt.event.ActionEvent;
  18import java.awt.event.ActionListener;
  19import java.io.ByteArrayInputStream;
  20import java.io.ByteArrayOutputStream;
  21import java.io.IOException;
  22import java.util.Date;
  23import java.util.HashMap;
  24import java.util.Iterator;
  25import java.util.List;
  26import javax.swing.JComboBox;
  27import javax.swing.JFrame;
  28import javax.swing.JTabbedPane;
  29import javax.swing.JTextPane;
  30import javax.swing.JToggleButton;
  31import javax.swing.JViewport;
  32import javax.swing.SwingUtilities;
  33import javax.swing.text.AttributeSet;
  34import javax.swing.text.BadLocationException;
  35import javax.swing.text.DefaultStyledDocument;
  36import javax.swing.text.MutableAttributeSet;
  37import javax.swing.text.SimpleAttributeSet;
  38import javax.swing.text.StyleConstants;
  39import javax.swing.text.StyledDocument;
  40import javax.swing.text.StyledEditorKit;
  41import javax.swing.text.rtf.RTFEditorKit;
  42import mpv5.db.common.Context;
  43import mpv5.db.common.DatabaseObject;
  44import mpv5.db.common.DatabaseSearch;
  45import mpv5.db.common.NodataFoundException;
  46import mpv5.db.objects.Address;
  47import mpv5.db.objects.Contact;
  48import mpv5.db.objects.Favourite;
  49import mpv5.db.objects.User;
  50import mpv5.globals.Messages;
  51import mpv5.logging.Log;
  52import mpv5.ui.dialogs.DialogForFile;
  53import mpv5.ui.dialogs.Popup;
  54import mpv5.ui.panels.ChangeNotApprovedException;
  55import mpv5.ui.panels.DataPanel;
  56import mpv5.ui.panels.ExportablePanel;
  57import mpv5.ui.toolbars.DataPanelTB;
  58import mpv5.utils.export.Export;
  59import mpv5.utils.jobs.Job;
  60import mpv5.db.objects.Conversation;
  61import mpv5.globals.Constants;
  62import mpv5.ui.dialogs.Search2;
  63import mpv5.utils.models.MPComboBoxModelItem;
  64import mpv5.utils.ui.TextFieldUtils;
  65
  66/**
  67 *
  68 * @author Jan Hahnisch 
  69 */
  70public class ConversationPanel
  71        extends javax.swing.JPanel
  72        implements DataPanel,
  73        ExportablePanel {
  74
  75    private static final long serialVersionUID = -7873021087487613697L;
  76    private static ConversationPanel me;
  77
  78    /**
  79     * Singleton
  80     * @return
  81     */
  82    public static ConversationPanel instanceOf() {
  83        if (me == null) {
  84            me = new ConversationPanel();
  85        } else {
  86            me.refresh_internal();
  87        }
  88        return me;
  89    }
  90    private int Type = Constants.TYPE_CONVERSATION;
  91    private DataPanelTB tb;
  92    private SearchPanel sp;
  93    private Conversation dataOwner;
  94    public Integer groupsids_ = 1;
  95    public String cnumber_ = "";
  96    public String content_ = "";
  97    public String cname_ = "";
  98    public String adress_ = "";
  99    public Date date_ = null;
 100    public Date dateadded_;
 101    Contact contact = null;
 102    List data = null;
 103    Thread t = null;
 104    public Integer intaddedby_;
 105    public int contactsids_;
 106
 107    /** Creates new form ConversationUI */
 108    public ConversationPanel() {
 109        initComponents();
 110        Log.Debug(ConversationPanel.class,
 111                "Erstellung gestartet ...");
 112
 113        sp = new SearchPanel(Context.getConversation(), this);
 114        sp.setVisible(true);
 115        tb = new DataPanelTB(this);
 116        tb.getMailButton().setEnabled(false);
 117        SearchBarPane.add(sp,
 118                BorderLayout.CENTER);
 119        Log.Debug(ConversationPanel.class,
 120                "Suchbar eingebaut ...");
 121        ToolBarPane.add(tb,
 122                BorderLayout.CENTER);
 123        Log.Debug(ConversationPanel.class,
 124                "Toolbar eingebaut ...");
 125        dataOwner = new Conversation();
 126        RTFEditorKit kit = (RTFEditorKit) RTF_Text.getEditorKitForContentType(
 127                "text/rtf");
 128        DefaultStyledDocument doc = (DefaultStyledDocument) kit.createDefaultDocument();
 129        RTF_Text.setEditorKit(kit);
 130        RTF_Text.setDocument(doc);
 131
 132        addedby.setText(mpv5.db.objects.User.getCurrentUser().getName());
 133        contactname.setSearchEnabled(true);
 134        contactname.setContext(Context.getCustomer());
 135        contactname.getComboBox().addActionListener(new ActionListener() {
 136
 137            @Override
 138            public void actionPerformed(ActionEvent e) {
 139                Log.Debug(this, e.getActionCommand());
 140                final MPComboBoxModelItem item = contactname.getSelectedItem();
 141                if (item != null && item.isValid()) {
 142                    t = new Thread() {
 143
 144                        @Override
 145                        public void run() {
 146                            Address adr;
 147                            try {
 148                                contact = (Contact) DatabaseObject.getObject(Context.getContact(), Integer.valueOf(item.getId()));
 149
 150                                data = DatabaseObject.getReferencedObjects(contact,
 151                                        Context.getAddress());
 152                                if (data.isEmpty()) {
 153                                    contactcity.setText(contact.__getCity());
 154                                    contactcompany.setText(contact.__getCompany());
 155                                    contactzip.setText(contact.__getZip());
 156                                    contactstreet.setText(contact.__getStreet());
 157                                } else {
 158                                    contactcity.setText("");
 159                                    contactcompany.setText("");
 160                                    contactzip.setText("");
 161                                    contactstreet.setText("");
 162                                }
 163                                contactid.setText(contact.__getCNumber());
 164                                Object[][] data1 = new Object[data.size() + 1][2];
 165                                data1[0][0] = 0;
 166                                data1[0][1] = Messages.Conversation_MainAddress.toString();
 167                                for (int o = 0; o < data.size(); o++) {
 168                                    adr = (Address) data.get(o);
 169                                    data1[o + 1][0] = adr.__getIDS();
 170                                    data1[o + 1][1] = adr.__getCname();
 171                                }
 172                                adressList.setModel(data1);
 173                            } catch (NodataFoundException ex) {
 174                                Log.Debug(this, ex);
 175                            }
 176                        }
 177                    };
 178                    t.start();
 179                }
 180            }
 181        });
 182
 183        adressList.getComboBox().addActionListener(new ActionListener() {
 184
 185            @Override
 186            public void actionPerformed(ActionEvent e) {
 187                final MPComboBoxModelItem item = adressList.getSelectedItem();
 188                if (item != null) {
 189                    Runnable runnable = new Runnable() {
 190
 191                        @Override
 192                        public void run() {
 193                            Log.Debug(this, "AdressListe");
 194                            if (item.getId().equals("0")) {
 195                                contactcity.setText(contact.__getCity());
 196                                contactcompany.setText(contact.__getCompany());
 197                                contactzip.setText(contact.__getZip());
 198                                contactstreet.setText(contact.__getStreet());
 199                                contactid.setText(contact.__getCNumber());
 200                            } else {
 201                                for (int i = 0; i < data.size(); i++) {
 202                                    Address adr = (Address) data.get(i);
 203                                    if (item.getId() == null ? adr.__getIDS().toString() == null : item.getId().equals(adr.__getIDS().toString())) {
 204                                        contactcity.setText(adr.__getCity());
 205                                        contactcompany.setText(adr.__getCompany());
 206                                        contactzip.setText(adr.__getZip());
 207                                        contactstreet.setText(adr.__getStreet());
 208                                    }
 209                                }
 210                            }
 211                        }
 212                    };
 213                    SwingUtilities.invokeLater(runnable);
 214                }
 215            }
 216        });
 217    }
 218
 219    private HashMap<String, Object> getAddData() {
 220        HashMap<String, Object> hm1 = null;
 221        HashMap<String, Object> hm2 = new HashMap<String, Object>();
 222        if (contact != null) {
 223            String AdressName = adressList.getSelectedItem().getId();
 224            int adressID = Integer.parseInt(AdressName);
 225            Log.Debug(this,
 226                    "Kontakt zum drucken geladen ...");
 227            if (adressID == 0) {
 228                hm1 = contact.getValues4();
 229                Log.Debug(this,
 230                        "Hauptkontakt ausgegeben ...");
 231            } else {
 232                for (int i = 0; i < data.size(); i++) {
 233                    Address adr = (Address) data.get(i);
 234                    if (adressID == adr.__getIDS()) {
 235                        hm1 = adr.getValues4();
 236                    }
 237                }
 238                Log.Debug(this,
 239                        "gezielte Addresse geladen ...");
 240            }
 241            Iterator<String> iterator = hm1.keySet().iterator();
 242            Object e;
 243            while (iterator.hasNext()) {
 244                e = iterator.next();
 245                hm2.put(dataOwner.getType() + "." + contact.getType() + "." + e.toString(),
 246                        hm1.get(e));
 247                if (e.equals("ismale")) {
 248                    if (hm1.get(e).
 249                            equals(true)) {
 250                        hm2.put(dataOwner.getType() + "." + contact.getType() + ".gender",
 251                                Messages.CONTACT_TYPE_MALE.toString());
 252                        hm2.put(dataOwner.getType() + ".intro",
 253                                Messages.CONTACT_INTRO_MALE.toString());
 254                    } else {
 255                        hm2.put(dataOwner.getType() + "." + contact.getType() + ".gender",
 256                                Messages.CONTACT_TYPE_FEMALE.toString());
 257                        hm2.put(dataOwner.getType() + ".intro",
 258                                Messages.CONTACT_INTRO_FEMALE.toString());
 259                    }
 260                }
 261            }
 262        }
 263        return hm2;
 264    }
 265
 266    /** This method is called from within the constructor to
 267     * initialize the form.
 268     * WARNING: Do NOT modify this code. The content of this method is
 269     * always regenerated by the Form Editor.
 270     */
 271    @SuppressWarnings("unchecked")
 272    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
 273    private void initComponents() {
 274
 275        ToolBarPane = new javax.swing.JPanel();
 276        jPanel1 = new javax.swing.JPanel();
 277        street = new javax.swing.JPanel();
 278        contactname = new mpv5.ui.beans.LabeledCombobox();
 279        contactcity = new javax.swing.JTextField();
 280        contactcompany = new javax.swing.JTextField();
 281        contactid = new javax.swing.JTextField();
 282        jButton3 = new javax.swing.JButton();
 283        jButton4 = new javax.swing.JButton();
 284        adressList = new mpv5.ui.beans.LabeledCombobox();
 285        contactzip = new javax.swing.JTextField();
 286        contactstreet = new javax.swing.JTextField();
 287        jPanel3 = new javax.swing.JPanel();
 288        jComboBox2 = new javax.swing.JComboBox();
 289        String fontSizes[] = {"8", "10", "11", "12", "14", "16", "18",
 290            "20", "24", "30", "36", "40", "48", "60", "72"};
 291        for (int index = 0; index < fontSizes.length; index++) {
 292            jComboBox2.addItem(fontSizes[index]);
 293        }
 294        jComboBox1 = new javax.swing.JComboBox();
 295        try {
 296            String[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
 297            Log.Debug(this, "Ermittelte Fonts: " + fonts.length);
 298
 299            for (int index = 0; index < fonts.length; index++) {
 300                jComboBox1.addItem(fonts[index]);
 301            }
 302        } catch (Exception e) {
 303
 304            Log.Debug(ConversationPanel.class, e);
 305        }
 306        jToggleButton3 = new javax.swing.JToggleButton();
 307        jToggleButton1 = new javax.swing.JToggleButton();
 308        jToggleButton2 = new javax.swing.JToggleButton();
 309        jLabel3 = new javax.swing.JLabel();
 310        jSeparator1 = new javax.swing.JSeparator();
 311        jScrollPane1 = new javax.swing.JScrollPane();
 312        RTF_Text = new javax.swing.JTextPane();
 313        jLabel7 = new javax.swing.JLabel();
 314        dateTo = new mpv5.ui.beans.DateChooser();
 315        cname = new javax.swing.JTextField();
 316        jPanel4 = new javax.swing.JPanel();
 317        jLabel6 = new javax.swing.JLabel();
 318        ids = new javax.swing.JTextField();
 319        jLabel4 = new javax.swing.JLabel();
 320        addedby = new javax.swing.JTextField();
 321        jLabel5 = new javax.swing.JLabel();
 322        dateadded = new mpv5.ui.beans.DateChooser();
 323        dateadded.setEnabled(false);
 324        SearchBarPane = new javax.swing.JPanel();
 325
 326        setName("Form"); // NOI18N
 327        setLayout(new java.awt.BorderLayout());
 328
 329        ToolBarPane.setName("ToolBarPane"); // NOI18N
 330        ToolBarPane.setLayout(new java.awt.BorderLayout());
 331        add(ToolBarPane, java.awt.BorderLayout.NORTH);
 332
 333        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
 334        jPanel1.setName("jPanel1"); // NOI18N
 335
 336        street.setBackground(new java.awt.Color(255, 255, 255));
 337        java.util.ResourceBundle bundle = mpv5.i18n.LanguageManager.getBundle(); // NOI18N
 338        street.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("ConversationPanel.street.border.title"))); // NOI18N
 339        street.setName("street"); // NOI18N
 340        street.setOpaque(false);
 341
 342        contactname.set_Label(bundle.getString("ConversationPanel.contactname._Label")); // NOI18N
 343        contactname.setName("contactname"); // NOI18N
 344
 345        contactcity.setEditable(false);
 346        contactcity.setText(bundle.getString("ConversationPanel.contactcity.text")); // NOI18N
 347        contactcity.setName("contactcity"); // NOI18N
 348
 349        contactcompany.setEditable(false);
 350        contactcompany.setText(bundle.getString("ConversationPanel.contactcompany.text")); // NOI18N
 351        contactcompany.setName("contactcompany"); // NOI18N
 352
 353        contactid.setEditable(false);
 354        contactid.setText(bundle.getString("ConversationPanel.contactid.text")); // NOI18N
 355        contactid.setName("contactid"); // NOI18N
 356
 357        jButton3.setText(bundle.getString("ConversationPanel.jButton3.text")); // NOI18N
 358        jButton3.setName("jButton3"); // NOI18N
 359        jButton3.addActionListener(new java.awt.event.ActionListener() {
 360            public void actionPerformed(java.awt.event.ActionEvent evt) {
 361                actionShowContact(evt);
 362            }
 363        });
 364
 365        jButton4.setText(bundle.getString("ConversationPanel.jButton4.text")); // NOI18N
 366        jButton4.setName("jButton4"); // NOI18N
 367        jButton4.addActionListener(new java.awt.event.ActionListener() {
 368            public void actionPerformed(java.awt.event.ActionEvent evt) {
 369                actionLookupContact(evt);
 370            }
 371        });
 372
 373        adressList.set_Label(bundle.getString("ConversationPanel.adressList._Label")); // NOI18N
 374        adressList.setName("adressList"); // NOI18N
 375
 376        contactzip.setEditable(false);
 377        contactzip.setText(bundle.getString("ConversationPanel.contactzip.text")); // NOI18N
 378        contactzip.setName("contactzip"); // NOI18N
 379
 380        contactstreet.setEditable(false);
 381        contactstreet.setText(bundle.getString("ConversationPanel.contactstreet.text")); // NOI18N
 382        contactstreet.setName("contactstreet"); // NOI18N
 383
 384        javax.swing.GroupLayout streetLayout = new javax.swing.GroupLayout(street);
 385        street.setLayout(streetLayout);
 386        streetLayout.setHorizontalGroup(
 387            streetLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 388            .addGroup(streetLayout.createSequentialGroup()
 389                .addGroup(streetLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 390                    .addGroup(streetLayout.createSequentialGroup()
 391                        .addComponent(contactcompany, javax.swing.GroupLayout.DEFAULT_SIZE, 206, Short.MAX_VALUE)
 392                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 393                        .addComponent(contactcity, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE))
 394                    .addComponent(contactname, javax.swing.GroupLayout.PREFERRED_SIZE, 338, javax.swing.GroupLayout.PREFERRED_SIZE))
 395                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 396                .addGroup(streetLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
 397                    .addGroup(streetLayout.createSequentialGroup()
 398                        .addComponent(adressList, javax.swing.GroupLayout.PREFERRED_SIZE, 269, javax.swing.GroupLayout.PREFERRED_SIZE)
 399                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 400                        .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
 401                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 402                        .addComponent(jButton4))
 403                    .addGroup(streetLayout.createSequentialGroup()
 404                        .addComponent(contactzip, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
 405                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 406                        .addComponent(contactstreet, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
 407                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 408                        .addComponent(contactid)))
 409                .addGap(28, 28, 28))
 410        );
 411        streetLayout.setVerticalGroup(
 412            streetLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 413            .addGroup(streetLayout.createSequentialGroup()
 414                .addGroup(streetLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
 415                    .addComponent(adressList, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 416                    .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
 417                    .addComponent(jButton4)
 418                    .addComponent(contactname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
 419                .addGap(6, 6, 6)
 420                .addGroup(streetLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
 421                    .addComponent(contactcompany, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 422                    .addComponent(contactcity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 423                    .addComponent(contactzip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 424                    .addComponent(contactstreet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 425                    .addComponent(contactid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
 426        );
 427
 428        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("ConversationPanel.jPanel3.border.title"))); // NOI18N
 429        jPanel3.setName("jPanel3"); // NOI18N
 430
 431        jComboBox2.setName("jComboBox2"); // NOI18N
 432        jComboBox2.addActionListener(new java.awt.event.ActionListener() {
 433            public void actionPerformed(java.awt.event.ActionEvent evt) {
 434                jComboBox2ActionPerformed(evt);
 435            }
 436        });
 437
 438        jComboBox1.setName("jComboBox1"); // NOI18N
 439        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
 440            public void actionPerformed(java.awt.event.ActionEvent evt) {
 441                jComboBox1ActionPerformed(evt);
 442            }
 443        });
 444
 445        jToggleButton3.setFont(jToggleButton3.getFont());
 446        jToggleButton3.setText(bundle.getString("ConversationPanel.jToggleButton3.text")); // NOI18N
 447        jToggleButton3.setName("jToggleButton3"); // NOI18N
 448        jToggleButton3.addActionListener(new java.awt.event.ActionListener() {
 449            public void actionPerformed(java.awt.event.ActionEvent evt) {
 450                jToggleButton3ActionPerformed(evt);
 451            }
 452        });
 453
 454        jToggleButton1.setFont(new java.awt.Font("Tahoma", 1, 11));
 455        jToggleButton1.setText(bundle.getString("ConversationPanel.jToggleButton1.text")); // NOI18N
 456        jToggleButton1.setName("jToggleButton1"); // NOI18N
 457        jToggleButton1.addActionListener(new java.awt.event.ActionListener() {
 458            public void actionPerformed(java.awt.event.ActionEvent evt) {
 459                jToggleButton1ActionPerformed(evt);
 460            }
 461        });
 462
 463        jToggleButton2.setFont(new java.awt.Font("Tahoma", 2, 11));
 464        jToggleButton2.setText(bundle.getString("ConversationPanel.jToggleButton2.text")); // NOI18N
 465        jToggleButton2.setName("jToggleButton2"); // NOI18N
 466        jToggleButton2.addActionListener(new java.awt.event.ActionListener() {
 467            public void actionPerformed(java.awt.event.ActionEvent evt) {
 468                jToggleButton2ActionPerformed(evt);
 469            }
 470        });
 471
 472        jLabel3.setLabelFor(dateTo);
 473        jLabel3.setText(bundle.getString("ConversationPanel.jLabel3.text")); // NOI18N
 474        jLabel3.setName("jLabel3"); // NOI18N
 475
 476        jSeparator1.setName("jSeparator1"); // NOI18N
 477
 478        jScrollPane1.setName("jScrollPane1"); // NOI18N
 479
 480        RTF_Text.setEditorKit(new javax.swing.text.rtf.RTFEditorKit());
 481        RTF_Text.setName("RTF_Text"); // NOI18N
 482        RTF_Text.addCaretListener(new javax.swing.event.CaretListener() {
 483            public void caretUpdate(javax.swing.event.CaretEvent evt) {
 484                RTF_TextCaretUpdate(evt);
 485            }
 486        });
 487        jScrollPane1.setViewportView(RTF_Text);
 488
 489        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
 490        jLabel7.setLabelFor(cname);
 491        jLabel7.setText(bundle.getString("ConversationPanel.jLabel7.text")); // NOI18N
 492        jLabel7.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
 493        jLabel7.setMaximumSize(new java.awt.Dimension(65, 20));
 494        jLabel7.setMinimumSize(new java.awt.Dimension(65, 20));
 495        jLabel7.setName("jLabel7"); // NOI18N
 496        jLabel7.setPreferredSize(new java.awt.Dimension(65, 20));
 497
 498        dateTo.setMaximumSize(new java.awt.Dimension(32767, 20));
 499        dateTo.setMinimumSize(new java.awt.Dimension(120, 20));
 500        dateTo.setName("dateTo"); // NOI18N
 501        dateTo.setPreferredSize(new java.awt.Dimension(150, 20));
 502
 503        cname.setText(bundle.getString("ConversationPanel.cname.text")); // NOI18N
 504        cname.setName("cname"); // NOI18N
 505
 506        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
 507        jPanel3.setLayout(jPanel3Layout);
 508        jPanel3Layout.setHorizontalGroup(
 509            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 510            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 910, Short.MAX_VALUE)
 511            .addGroup(jPanel3Layout.createSequentialGroup()
 512                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 513                    .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 900, Short.MAX_VALUE)
 514                    .addGroup(jPanel3Layout.createSequentialGroup()
 515                        .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE)
 516                        .addGap(15, 15, 15)
 517                        .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
 518                        .addGap(7, 7, 7)
 519                        .addComponent(jToggleButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
 520                        .addGap(2, 2, 2)
 521                        .addComponent(jToggleButton2)
 522                        .addGap(5, 5, 5)
 523                        .addComponent(jToggleButton3)
 524                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 525                        .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)
 526                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 527                        .addComponent(dateTo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
 528                    .addGroup(jPanel3Layout.createSequentialGroup()
 529                        .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 530                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 531                        .addComponent(cname, javax.swing.GroupLayout.DEFAULT_SIZE, 831, Short.MAX_VALUE)))
 532                .addContainerGap())
 533        );
 534        jPanel3Layout.setVerticalGroup(
 535            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 536            .addGroup(jPanel3Layout.createSequentialGroup()
 537                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 538                    .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 539                    .addComponent(cname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
 540                .addGap(10, 10, 10)
 541                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
 542                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 543                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 544                    .addComponent(jToggleButton1)
 545                    .addComponent(jToggleButton2)
 546                    .addComponent(jToggleButton3)
 547                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
 548                    .addComponent(dateTo, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
 549                .addGap(5, 5, 5)
 550                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 551                .addGap(10, 10, 10)
 552                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE))
 553        );
 554
 555        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("ConversationPanel.jPanel4.border.title"))); // NOI18N
 556        jPanel4.setName("jPanel4"); // NOI18N
 557        jPanel4.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
 558
 559        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
 560        jLabel6.setLabelFor(ids);
 561        jLabel6.setText(bundle.getString("ConversationPanel.jLabel6.text")); // NOI18N
 562        jLabel6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
 563        jLabel6.setMaximumSize(new java.awt.Dimension(333, 20));
 564        jLabel6.setMinimumSize(new java.awt.Dimension(65, 20));
 565        jLabel6.setName("jLabel6"); // NOI18N
 566        jLabel6.setOpaque(true);
 567        jLabel6.setPreferredSize(new java.awt.Dimension(120, 20));
 568        jPanel4.add(jLabel6);
 569
 570        ids.setMaximumSize(new java.awt.Dimension(333, 20));
 571        ids.setMinimumSize(new java.awt.Dimension(65, 20));
 572        ids.setName("ids"); // NOI18N
 573        ids.setPreferredSize(new java.awt.Dimension(120, 20));
 574        jPanel4.add(ids);
 575
 576        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
 577        jLabel4.setLabelFor(addedby);
 578        jLabel4.setText(bundle.getString("ConversationPanel.jLabel4.text")); // NOI18N
 579        jLabel4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
 580        jLabel4.setMaximumSize(new java.awt.Dimension(333, 20));
 581        jLabel4.setMinimumSize(new java.awt.Dimension(65, 20));
 582        jLabel4.setName("jLabel4"); // NOI18N
 583        jLabel4.setOpaque(true);
 584        jLabel4.setPreferredSize(new java.awt.Dimension(120, 20));
 585        jPanel4.add(jLabel4);
 586
 587        addedby.setEditable(false);
 588        addedby.setMaximumSize(new java.awt.Dimension(333, 20));
 589        addedby.setMinimumSize(new java.awt.Dimension(65, 20));
 590        addedby.setName("addedby"); // NOI18N
 591        addedby.setPreferredSize(new java.awt.Dimension(120, 20));
 592        jPanel4.add(addedby);
 593
 594        jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
 595        jLabel5.setLabelFor(ids);
 596        jLabel5.setText(bundle.getString("ConversationPanel.jLabel5.text")); // NOI18N
 597        jLabel5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
 598        jLabel5.setMaximumSize(new java.awt.Dimension(333, 20));
 599        jLabel5.setMinimumSize(new java.awt.Dimension(65, 20));
 600        jLabel5.setName("jLabel5"); // NOI18N
 601        jLabel5.setOpaque(true);
 602        jLabel5.setPreferredSize(new java.awt.Dimension(120, 20));
 603        jPanel4.add(jLabel5);
 604
 605        dateadded.setMaximumSize(new java.awt.Dimension(333, 20));
 606        dateadded.setMinimumSize(new java.awt.Dimension(65, 20));
 607        dateadded.setName("dateadded"); // NOI18N
 608        dateadded.setOpaque(true);
 609        dateadded.setPreferredSize(new java.awt.Dimension(120, 20));
 610        jPanel4.add(dateadded);
 611
 612        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
 613        jPanel1.setLayout(jPanel1Layout);
 614        jPanel1Layout.setHorizontalGroup(
 615            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 616            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 617            .addGroup(jPanel1Layout.createSequentialGroup()
 618                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
 619                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 620                    .addComponent(street, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
 621                .addContainerGap())
 622        );
 623        jPanel1Layout.setVerticalGroup(
 624            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 625            .addGroup(jPanel1Layout.createSequentialGroup()
 626                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
 627                .addGap(0, 0, 0)
 628                .addComponent(street, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 629                .addGap(0, 0, 0)
 630                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
 631        );
 632
 633        add(jPanel1, java.awt.BorderLayout.CENTER);
 634
 635        SearchBarPane.setName("SearchBarPane"); // NOI18N
 636        SearchBarPane.setLayout(new java.awt.BorderLayout());
 637        add(SearchBarPane, java.awt.BorderLayout.WEST);
 638    }// </editor-fold>//GEN-END:initComponents
 639
 640    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
 641        JComboBox comboBox = (JComboBox) evt.getSource();
 642        javax.swing.text.StyledEditorKit.FontFamilyAction action =
 643                new StyledEditorKit.FontFamilyAction("xxx",
 644                comboBox.getSelectedItem().
 645                toString());
 646        action.actionPerformed(new ActionEvent(comboBox,
 647                ActionEvent.ACTION_PERFORMED,
 648                "xxx"));
 649    }//GEN-LAST:event_jComboBox1ActionPerformed
 650
 651    private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton1ActionPerformed
 652        JToggleButton btn = (JToggleButton) evt.getSource();
 653        RTFEditorKit kit = (RTFEditorKit) RTF_Text.getEditorKit();
 654        MutableAttributeSet attr = kit.getInputAttributes();
 655        boolean bold =
 656                (StyleConstants.isBold(attr)) ? false : true;
 657        btn.setSelected(bold);
 658        SimpleAttributeSet sas = new SimpleAttributeSet();
 659        StyleConstants.setBold(sas,
 660                bold);
 661        RTF_Text.setCharacterAttributes(sas,
 662                false);
 663    }//GEN-LAST:event_jToggleButton1ActionPerformed
 664
 665    private void jToggleButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton2ActionPerformed
 666        JToggleButton btn = (JToggleButton) evt.getSource();
 667        RTFEditorKit kit = (RTFEditorKit) RTF_Text.getEditorKit();
 668        MutableAttributeSet attr = kit.getInputAttributes();
 669        boolean italic =
 670                (StyleConstants.isItalic(attr)) ? false : true;
 671        btn.setSelected(italic);
 672        SimpleAttributeSet sas = new SimpleAttributeSet();
 673        StyleConstants.setItalic(sas,
 674                italic);
 675        RTF_Text.setCharacterAttributes(sas,
 676                false);
 677    }//GEN-LAST:event_jToggleButton2ActionPerformed
 678
 679    private void jToggleButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton3ActionPerformed
 680        JToggleButton btn = (JToggleButton) evt.getSource();
 681        RTFEditorKit kit = (RTFEditorKit) RTF_Text.getEditorKit();
 682        MutableAttributeSet attr = kit.getInputAttributes();
 683        boolean under =
 684                (StyleConstants.isUnderline(attr)) ? false : true;
 685        btn.setSelected(under);
 686        SimpleAttributeSet sas = new SimpleAttributeSet();
 687        StyleConstants.setUnderline(sas,
 688                under);
 689        RTF_Text.setCharacterAttributes(sas,
 690                false);
 691    }//GEN-LAST:event_jToggleButton3ActionPerformed
 692
 693    private void RTF_TextCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_RTF_TextCaretUpdate
 694        JTextPane text = (JTextPane) evt.getSource();
 695        StyledDocument doc = text.getStyledDocument();
 696
 697        if (doc.getLength() > 0) {
 698            Boolean isBold = null;
 699            Boolean isItalic = null;
 700            Boolean isUnderline = null;
 701            Boolean tmp = null;
 702            String fontFamily = null;
 703            int fontSize = 8;
 704
 705            for (int i = evt.getMark(); i < evt.getDot(); i++) {
 706                AttributeSet atts = doc.getCharacterElement(i).
 707                        getAttributes();
 708
 709                tmp = StyleConstants.isBold(atts);
 710                if (isBold == null) {
 711                    isBold = tmp;
 712                } else if (tmp.equals(isBold) == false) {
 713                    isBold = false;
 714                }
 715
 716                tmp = StyleConstants.isItalic(atts);
 717                if (isItalic == null) {
 718                    isItalic = tmp;
 719                } else if (tmp.equals(isItalic) == false) {
 720                    isItalic = false;
 721                }
 722
 723                tmp = StyleConstants.isUnderline(atts);
 724                if (isUnderline == null) {
 725                    isUnderline = tmp;
 726                } else if (tmp.equals(isUnderline) == false) {
 727                    isUnderline = false;
 728                }
 729
 730                fontFamily = StyleConstants.getFontFamily(atts);
 731                fontSize = StyleConstants.getFontSize(atts);
 732            }
 733
 734            if (isBold == null && isItalic == null && isUnderline == null) {
 735                AttributeSet atts = doc.getCharacterElement(evt.getDot() - 1).
 736                        getAttributes();
 737                isBold = StyleConstants.isBold(atts);
 738                isItalic = StyleConstants.isItalic(atts);
 739                isUnderline = StyleConstants.isUnderline(atts);
 740            }
 741
 742            if (fontFamily == null || fontSize == 8) {
 743                AttributeSet atts = doc.getCharacterElement(evt.getDot() - 1).
 744                        getAttributes();
 745                fontFamily = StyleConstants.getFontFamily(atts);
 746                fontSize = StyleConstants.getFontSize(atts);
 747            }
 748
 749            jToggleButton1.setSelected(isBold);
 750            jToggleButton2.setSelected(isItalic);
 751            jToggleButton3.setSelected(isUnderline);
 752            jComboBox1.setSelectedItem(fontFamily);
 753            jComboBox2.setSelectedItem(String.valueOf(fontSize));
 754        }
 755}//GEN-LAST:event_RTF_TextCaretUpdate
 756
 757    private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox2ActionPerformed
 758        JComboBox comboBox = (JComboBox) evt.getSource();
 759        javax.swing.text.StyledEditorKit.FontSizeAction action =
 760                new StyledEditorKit.FontSizeAction("xxx",
 761                Integer.parseInt(comboBox.getSelectedItem().
 762                toString()));
 763        action.actionPerformed(new ActionEvent(comboBox,
 764                ActionEvent.ACTION_PERFORMED,
 765                "xxx"));
 766    }//GEN-LAST:event_jComboBox2ActionPerformed
 767
 768    private void actionShowContact(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_actionShowContact
 769        try {
 770            int cid = Integer.valueOf(contactname.getSelectedItem().getId());
 771            Contact c = (Contact) DatabaseObject.getObject(Context.getContact(), cid);
 772            ContactPanel cp = new ContactPanel(Context.getContact());
 773            mpv5.YabsViewProxy.instance().getIdentifierView().addOrShowTab(cp, Messages.TYPE_CONTACT.toString());
 774            cp.setDataOwner(c, true);
 775        } catch (Exception e) {
 776            Log.Debug(this, e);
 777        }
 778    }//GEN-LAST:event_actionShowContact
 779
 780    private void actionLookupContact(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_actionLookupContact
 781        Contact dbo = (Contact) Search2.showSearchFor(Context.getContact());
 782        if (dbo != null) {
 783            contact = dbo;
 784            contactname.setModel(dbo);
 785            contactcity.setText(dbo.__getCity());
 786            contactzip.setText(dbo.__getZip());
 787            contactstreet.setText(dbo.__getStreet());
 788            contactcompany.setText(dbo.__getCompany());
 789            contactid.setText(dbo.__getCNumber());
 790        }
 791    }//GEN-LAST:event_actionLookupContact
 792    // Variables declaration - do not modify//GEN-BEGIN:variables
 793    private javax.swing.JTextPane RTF_Text;
 794    private javax.swing.JPanel SearchBarPane;
 795    private javax.swing.JPanel ToolBarPane;
 796    private javax.swing.JTextField addedby;
 797    private mpv5.ui.beans.LabeledCombobox adressList;
 798    private javax.swing.JTextField cname;
 799    private javax.swing.JTextField contactcity;
 800    private javax.swing.JTextField contactcompany;
 801    private javax.swing.JTextField contactid;
 802    private mpv5.ui.beans.LabeledCombobox contactname;
 803    private javax.swing.JTextField contactstreet;
 804    private javax.swing.JTextField contactzip;
 805    private mpv5.ui.beans.DateChooser dateTo;
 806    private mpv5.ui.beans.DateChooser dateadded;
 807    private javax.swing.JTextField ids;
 808    private javax.swing.JButton jButton3;
 809    private javax.swing.JButton jButton4;
 810    private javax.swing.JComboBox jComboBox1;
 811    private javax.swing.JComboBox jComboBox2;
 812    private javax.swing.JLabel jLabel3;
 813    private javax.swing.JLabel jLabel4;
 814    private javax.swing.JLabel jLabel5;
 815    private javax.swing.JLabel jLabel6;
 816    private javax.swing.JLabel jLabel7;
 817    private javax.swing.JPanel jPanel1;
 818    private javax.swing.JPanel jPanel3;
 819    private javax.swing.JPanel jPanel4;
 820    private javax.swing.JScrollPane jScrollPane1;
 821    private javax.swing.JSeparator jSeparator1;
 822    private javax.swing.JToggleButton jToggleButton1;
 823    private javax.swing.JToggleButton jToggleButton2;
 824    private javax.swing.JToggleButton jToggleButton3;
 825    private javax.swing.JPanel street;
 826    // End of variables declaration//GEN-END:variables
 827
 828    /**
 829     *  Give the DatabaseObject back
 830     * @return The DatabaseObject
 831     */
 832    public DatabaseObject getDataOwner() {
 833        return dataOwner;
 834    }
 835
 836    /**
 837     * Sets the DatabaseObject
 838     * @param DatabaseObject
 839     * @param populate 
 840     */
 841    public void setDataOwner(DatabaseObject object,
 842            boolean populate) {
 843        dataOwner = (Conversation) object;
 844        if (populate) {
 845            dataOwner.setPanelData(this);
 846            Runnable runnable = new Runnable() {
 847
 848                @Override
 849                public void run() {
 850                    try {
 851                        me.exposeData();
 852                    } catch (Exception e) {
 853                        Log.Debug(this,
 854                                e);
 855                    }
 856                }
 857            };
 858
 859            SwingUtilities.invokeLater(runnable);
 860
 861            if (dataOwner.isExisting() && populate) {
 862                setTitle(dataOwner.__getCname());
 863            }
 864            tb.setFavourite(Favourite.isFavourite(object));
 865            tb.setEditable(!object.isReadOnly());
 866
 867            if (object.isReadOnly()) {
 868                Popup.notice(Messages.LOCKED_BY);
 869            }
 870
 871            validate();
 872        }
 873    }
 874
 875    private void refresh_internal() {
 876        contact = null;
 877        sp.refresh();
 878        cname.setText("");
 879        contactcity.setText("");
 880        contactcompany.setText("");
 881        contactzip.setText("");
 882        contactstreet.setText("");
 883        contactid.setText("");
 884        dateTo.setDate(new Date());
 885        dateadded.setDate(new Date());
 886        addedby.setText(String.valueOf(User.getUserId(User.getCurrentUser().
 887                toString())));
 888        ids.setText("");
 889        try {
 890            RTF_Text.getStyledDocument().
 891                    remove(0,
 892                    RTF_Text.getStyledDocument().
 893                    getLength());
 894        } catch (BadLocationException ex) {
 895            Log.Debug(this,
 896                    "Fehler löschen Textfeld!!");
 897        }
 898        Log.Debug(this,
 899                "UI zurückgesetzt!!");
 900    }
 901
 902    /**
 903     * Pastestub of the Copy&Paste-function 
 904     * @param arg0 
 905     */
 906    public void paste(DatabaseObject... arg0) {
 907        mpv5.YabsViewProxy.instance().
 908                addMessage(Messages.NOT_POSSIBLE.toString() + Messages.ACTION_PASTE.toString(), Color.RED);
 909    }
 910
 911    /**
 912     * Checks the fullfillment of all requierements
 913     */
 914    public void showRequiredFields() {
 915        TextFieldUtils.blink(contactid,
 916                Color.RED);
 917        TextFieldUtils.blink(adressList,
 918                Color.RED);
 919        TextFieldUtils.blink(contactname,
 920                Color.RED);
 921        TextFieldUtils.blinkerRed(cname);
 922        cname.requestFocus();
 923    }
 924
 925    /**
 926     * enables / disables the Searchbar
 927     * @param show 
 928     */
 929    public void showSearchBar(boolean show) {
 930
 931        SearchBarPane.removeAll();
 932
 933        if (show) {
 934            SearchBarPane.add(sp,
 935                    BorderLayout.CENTER);
 936            Log.Debug(ConversationPanel.class,
 937                    "Suchfenster eingeblendet");
 938            sp.search();
 939        } else {
 940            Log.Debug(ConversationPanel.class,
 941                    "Suchfenster ausgeblendet");
 942        }
 943
 944        validate();
 945    }
 946
 947    /**
 948     * empty Function
 949     */
 950    public void actionAfterSave() {
 951    }
 952
 953    /**
 954     * empty Function
 955     */
 956    public void actionAfterCreate() {
 957        sp.refresh();
 958    }
 959
 960    /**
 961     * empty Function
 962     */
 963    public void actionBeforeCreate() {
 964    }
 965
 966    /**
 967     * Do an action bevor the System saves
 968     * @throws ChangeNotApprovedException 
 969     */
 970    public void actionBeforeSave() throws ChangeNotApprovedException {
 971        if (dataOwner.isExisting()) {
 972            if (!mpv5.db.objects.User.getCurrentUser().
 973                    getProperties().
 974                    getProperty("org.openyabs.uiproperty",
 975                    "nowarnings")) {
 976
 977                if (!Popup.Y_N_dialog(Messages.REALLY_CHANGE)) {
 978                    throw new ChangeNotApprovedException(dataOwner);
 979                }
 980            }
 981        }
 982    }
 983
 984    /**
 985     * Sends the DataObject as Mail 
 986     */
 987    public void mail() {
 988//        if (dataOwner != null && dataOwner.isExisting()) {
 989//            if (TemplateHandler.isLoaded(dataOwner.templateGroupIds(), dataOwner.__getInttype())) {
 990//
 991//                try {
 992//                    Contact cont = (Contact) (Contact.getObject(Context.getContact(), dataOwner.__getContactsids()));
 993//                    Export.mail(TemplateHandler.loadTemplate(dataOwner.templateGroupIds(), dataOwner.__getInttype()), dataOwner, cont);
 994//                } catch (NodataFoundException ex) {
 995//                    Log.Debug(ex);
 996//                }
 997//            } else {
 998//                Popup.notice(Messages.NO_TEMPLATE_LOADED + " (" + mpv5.db.objects.User.getCurrentUser() + ")");
 999//            }
1000//        } else {
1001//            Popup.notice(Messages.NOT_POSSIBLE + "\n" + Messages.NOT_SAVED_YET);
1002//        }
1003    }
1004
1005    /**
1006     * prints the DataObject
1007     */
1008    public void print() {
1009        if (dataOwner != null && dataOwner.isExisting()) {
1010            if (TemplateHandler.isLoaded(Long.valueOf(dataOwner.templateGroupIds()),
1011                    Type)) {
1012                Export.print(TemplateHandler.loadTemplate(dataOwner.templateGroupIds(),
1013                        Type),
1014                        dataOwner);
1015            } else {
1016                Popup.notice(Messages.NO_TEMPLATE_LOADED + " (" + mpv5.db.objects.User.getCurrentUser() + ")");
1017                Export.print(this);
1018            }
1019        } else {
1020            Popup.notice(Messages.FILE_NOT_SAVED);
1021        }
1022    }
1023
1024    /**
1025     * Sends the DataObject as PDF
1026     */
1027    public void pdf() {
1028        if (dataOwner != null && dataOwner.isExisting()) {
1029            if (TemplateHandler.isLoaded(Long.valueOf(dataOwner.templateGroupIds()),
1030                    Type)) {
1031                new Job(Export.createFile(cname_,
1032                        TemplateHandler.loadTemplate(dataOwner.templateGroupIds(),
1033                        Type),
1034                        dataOwner,
1035                        getAddData()),
1036                        new DialogForFile(User.getSaveDir(dataOwner))).execute();
1037            } else {
1038                Popup.notice(Messages.NO_TEMPLATE_LOADED + " (" + mpv5.db.objects.User.getCurrentUser() + ")");
1039            }
1040        } else {
1041            Popup.notice(Messages.FILE_NOT_SAVED);
1042        }
1043    }
1044
1045    /**
1046     * Sends the DataObject as odt 
1047     */
1048    public void odt() {
1049        if (dataOwner != null && dataOwner.isExisting()) {
1050            if (TemplateHandler.isLoaded(Long.valueOf(dataOwner.templateGroupIds()),
1051                    Type)) {
1052                new Job(Export.sourceFile(cname_,
1053                        TemplateHandler.loadTemplate(dataOwner.templateGroupIds(),
1054                        Type),
1055                        dataOwner),
1056                        new DialogForFile(User.getSaveDir(dataOwner))).execute();
1057            } else {
1058                Popup.notice(Messages.NO_TEMPLATE_LOADED + " (" + mpv5.db.objects.User.getCurrentUser() + ")");
1059            }
1060        } else {
1061            Popup.notice(Messages.FILE_NOT_SAVED);
1062        }
1063    }
1064
1065    /**
1066     * Collects the Data from the Userscreen 
1067     */
1068    public boolean collectData() {
1069        if (contactname.getSelectedItem() == null) {
1070            showRequiredFields();
1071            return false;
1072        } else {
1073            groupsids_ = 1;
1074            cname_ = cname.getText();
1075            cnumber_ = contactid.getText();
1076            contactsids_ = Integer.parseI

Large files files are truncated, but you can click here to view the full file