Example usage for javax.swing.event DocumentEvent getDocument

List of usage examples for javax.swing.event DocumentEvent getDocument

Introduction

In this page you can find the example usage for javax.swing.event DocumentEvent getDocument.

Prototype

public Document getDocument();

Source Link

Document

Gets the document that sourced the change event.

Usage

From source file:com.microsoft.azure.hdinsight.spark.ui.SparkSubmissionContentPanel.java

private void addMainClassNameLineItem() {
    JLabel sparkMainClassLabel = new JLabel("Main class name");
    sparkMainClassLabel.setToolTipText("Application's java/spark main class");
    GridBagConstraints c31 = new GridBagConstraints();
    c31.gridx = 0;/*from w  w w .j ava 2  s  .c  o  m*/
    c31.gridy = 2;
    c31.insets = new Insets(margin, margin, margin, margin);
    add(sparkMainClassLabel, new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 1, 0,
            GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, 0), 0, 0));

    mainClassTextField = new TextFieldWithBrowseButton();
    mainClassTextField.setToolTipText("Application's java/spark main class");
    ManifestFileUtil.setupMainClassField(submitModel.getProject(), mainClassTextField);

    add(mainClassTextField,
            new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST,
                    GridBagConstraints.HORIZONTAL, new Insets(margin, margin, 0, margin), 0, 0));

    errorMessageLabels[ErrorMessageLabelTag.MainClass.ordinal()] = new JLabel(
            "Main Class Name should not be null");
    errorMessageLabels[ErrorMessageLabelTag.MainClass.ordinal()]
            .setForeground(DarkThemeManager.getInstance().getErrorMessageColor());
    errorMessageLabels[ErrorMessageLabelTag.MainClass.ordinal()].setVisible(true);

    mainClassTextField.getTextField().getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void insertUpdate(DocumentEvent e) {
            setVisibleForFixedErrorMessageLabel(3, e.getDocument().getLength() == 0);
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            setVisibleForFixedErrorMessageLabel(3, e.getDocument().getLength() == 0);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
        }
    });

    add(errorMessageLabels[ErrorMessageLabelTag.MainClass.ordinal()],
            new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST,
                    GridBagConstraints.HORIZONTAL, new Insets(0, margin, 0, margin), 0, 0));
}

From source file:jeplus.gui.JPanel_EPlusProjectFiles.java

/**
 * Creates new form JPanel_EPlusProjectFiles with parameters
 *///from w w  w. ja  v a2s  . c  o m
public JPanel_EPlusProjectFiles(JEPlusFrameMain frame, JEPlusProject project) {
    initComponents();
    MainGUI = frame;
    Project = project;

    this.txtGroupID.setText(Project.getProjectID());
    this.txtGroupNotes.setText(Project.getProjectNotes());
    txtIdfDir.setText(Project.getIDFDir());
    if (Project.getIDFTemplate() != null) {
        cboTemplateFile.setModel(new DefaultComboBoxModel(Project.getIDFTemplate().split("\\s*;\\s*")));
    } else {
        cboTemplateFile.setModel(new DefaultComboBoxModel(new String[] { "Select files..." }));
    }
    txtWthrDir.setText(Project.getWeatherDir());
    if (Project.getWeatherFile() != null) {
        cboWeatherFile.setModel(new DefaultComboBoxModel(Project.getWeatherFile().split("\\s*;\\s*")));
    } else {
        cboWeatherFile.setModel(new DefaultComboBoxModel(new String[] { "Select files..." }));
    }
    chkReadVar.setSelected(Project.isUseReadVars());
    txtRviDir.setText(Project.getRVIDir());
    if (Project.getRVIFile() != null) {
        cboRviFile.setModel(new DefaultComboBoxModel(new String[] { Project.getRVIFile() }));
    } else {
        cboRviFile.setModel(new DefaultComboBoxModel(new String[] { "Select a file..." }));
    }
    this.chkReadVarActionPerformed(null);

    // Set listeners to text fields
    DL = new DocumentListener() {
        Document DocProjID = txtGroupID.getDocument();
        Document DocProjNotes = txtGroupNotes.getDocument();
        Document DocIdfDir = txtIdfDir.getDocument();
        Document DocWthrDir = txtWthrDir.getDocument();
        Document DocRviDir = txtRviDir.getDocument();

        @Override
        public void insertUpdate(DocumentEvent e) {
            Document src = e.getDocument();
            if (src == DocProjID) {
                Project.setProjectID(txtGroupID.getText());
            } else if (src == DocProjNotes) {
                Project.setProjectNotes(txtGroupNotes.getText());
            } else if (src == DocIdfDir) {
                Project.setIDFDir(txtIdfDir.getText());
            } else if (src == DocWthrDir) {
                Project.setWeatherDir(txtWthrDir.getText());
            } else if (src == DocRviDir) {
                Project.setRVIDir(txtRviDir.getText());
            }
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            insertUpdate(e);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            // not applicable
        }
    };
    txtGroupID.getDocument().addDocumentListener(DL);
    txtGroupNotes.getDocument().addDocumentListener(DL);
    txtIdfDir.getDocument().addDocumentListener(DL);
    txtWthrDir.getDocument().addDocumentListener(DL);
    txtRviDir.getDocument().addDocumentListener(DL);
}

From source file:coreferenceresolver.gui.MainGUI.java

/**
 * Creates new form MainGUI/*  w ww.j ava  2s.c o  m*/
 */
public MainGUI() throws IOException {
    initComponents();
    defaulPath = FileUtils.readFileToString(new File(".\\src\\coreferenceresolver\\gui\\defaultpath"));
    markupBtn.setEnabled(false);
    testBtn.setEnabled(false);
    trainingBtn.setEnabled(false);
    applyClassifierBtn.setEnabled(false);
    inputFilePathTF.getDocument().addDocumentListener(new DocumentListener() {
        // implement the methods
        public void changedUpdate(DocumentEvent e) {

        }

        public void removeUpdate(DocumentEvent e) {
            if (e.getDocument().getLength() == 0) {
                markupBtn.setEnabled(false);
                testBtn.setEnabled(false);
                trainingBtn.setEnabled(false);
                applyClassifierBtn.setEnabled(false);
            }
        }

        public void insertUpdate(DocumentEvent e) {
            markupBtn.setEnabled(true);
            if (markupFilePathTF.getText() != null && !markupFilePathTF.getText().equals("")) {
                testBtn.setEnabled(true);
                trainingBtn.setEnabled(true);
            }
            if (testingFilePathTF.getText() != null && !testingFilePathTF.getText().equals("")
                    && trainingFilePathTF.getText() != null && !trainingFilePathTF.getText().equals("")) {
                applyClassifierBtn.setEnabled(true);
            }
        }
    });

    markupFilePathTF.getDocument().addDocumentListener(new DocumentListener() {
        // implement the methods
        public void changedUpdate(DocumentEvent e) {

        }

        public void removeUpdate(DocumentEvent e) {
            if (e.getDocument().getLength() == 0) {
                testBtn.setEnabled(false);
                trainingBtn.setEnabled(false);
            }
        }

        public void insertUpdate(DocumentEvent e) {
            if (inputFilePathTF.getText() != null && !inputFilePathTF.getText().equals("")) {
                testBtn.setEnabled(true);
                trainingBtn.setEnabled(true);
            }
        }
    });

    testingFilePathTF.getDocument().addDocumentListener(new DocumentListener() {
        // implement the methods
        public void changedUpdate(DocumentEvent e) {

        }

        public void removeUpdate(DocumentEvent e) {
            if (e.getDocument().getLength() == 0) {
                applyClassifierBtn.setEnabled(false);
            }
        }

        public void insertUpdate(DocumentEvent e) {
            if (trainingFilePathTF.getText() != null && !trainingFilePathTF.getText().equals("")
                    && inputFilePathTF.getText() != null && !inputFilePathTF.getText().equals("")) {
                applyClassifierBtn.setEnabled(true);
            }
        }
    });

    trainingFilePathTF.getDocument().addDocumentListener(new DocumentListener() {
        // implement the methods
        public void changedUpdate(DocumentEvent e) {

        }

        public void removeUpdate(DocumentEvent e) {
            if (e.getDocument().getLength() == 0) {
                applyClassifierBtn.setEnabled(false);
            }
        }

        public void insertUpdate(DocumentEvent e) {
            if (testingFilePathTF.getText() != null && !testingFilePathTF.getText().equals("")
                    && inputFilePathTF.getText() != null && !inputFilePathTF.getText().equals("")) {
                applyClassifierBtn.setEnabled(true);
            }
        }
    });

    inputFilePathTF.setText(defaulPath + File.separatorChar + "input_test.txt");
    markupFilePathTF.setText(defaulPath + File.separatorChar + "input_test.txt.markup");
    trainingFilePathTF.setText(defaulPath + File.separatorChar + "train.arff");
    testingFilePathTF.setText(defaulPath + File.separatorChar + "test.arff");

}

From source file:com.stonelion.zooviewer.ui.JZVNodePanel.java

private void initListeners() {
    taUpdate.getDocument().addDocumentListener(new DocumentListener() {
        @Override//  w  w  w .j  a v a2  s  .co m
        public void removeUpdate(DocumentEvent e) {
            enableAction(e);
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            enableAction(e);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            enableAction(e);
        }

        private void enableAction(DocumentEvent e) {
            boolean enabled = e.getDocument().getLength() > 0;
            getUpdateAction().setEnabled(enabled);
        }
    });
}

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java

/**
 * Updates write panel size and adjusts sms properties if the sms menu
 * is visible.// w ww.j  a  v  a  2 s.c  om
 *
 * @param event the <tt>DocumentEvent</tt> that notified us
 */
public void insertUpdate(DocumentEvent event) {
    // If we're in sms mode count the chars typed.
    if (smsButton.isVisible()) {
        updateSmsCounters(event.getDocument().getLength());
    }
}

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java

/**
 * Updates write panel size and adjusts sms properties if the sms menu
 * is visible.//from  w  w  w .j a  v a2s .c  om
 *
 * @param event the <tt>DocumentEvent</tt> that notified us
 */
public void removeUpdate(DocumentEvent event) {
    // If we're in sms mode count the chars typed.
    if (smsButton.isVisible()) {
        updateSmsCounters(event.getDocument().getLength());
    }
}

From source file:src.gui.ItTabbedPane.java

public void openPDDLTab(Element diagram, String id, String title, Element project, Element projectHeader,
        File file) {//from  ww w. j a v  a  2 s .  c o m

    String nodeType = diagram.getName();

    // Checks whether the diagram is already open
    String xpath = "openTab[@language='PDDL' and @projectID='" + projectHeader.getAttributeValue("id")
            + "' and @diagramID='" + id + "' and type='" + nodeType + "']";

    //Checks if it is already opened
    Element openingDiagram = null;
    try {
        XPath path = new JDOMXPath(xpath);
        openingDiagram = (Element) path.selectSingleNode(openTabs);
    } catch (JaxenException e2) {
        e2.printStackTrace();
    }

    if (openingDiagram != null) {
        // select the tab if it is already open
        setSelectedIndex(openingDiagram.getParent().indexOf(openingDiagram));

    } else {

        //New Tab
        Document newDoc = null;
        try {
            newDoc = XMLUtilities.readFromFile("resources/settings/commonData.xml");
        } catch (JDOMException e) {

            e.printStackTrace();
        } catch (IOException e) {

            e.printStackTrace();
        }
        Element openTab = ((Element) newDoc.getRootElement().getChild("internalUse").getChild("openTab")
                .clone());

        Icon icon = null;
        JRootPane panel = null;

        ItToolBar toolBar = new ItToolBar(diagram.getName(), "PDDL");
        toolBar.setName(title);

        ItHilightedDocument pddlDocument = new ItHilightedDocument();
        pddlDocument.setHighlightStyle(ItHilightedDocument.PDDL_STYLE);

        JTextPane pddlTextPane = new JTextPane(pddlDocument);
        pddlTextPane.setFont(new Font("Courier", 0, 12));
        pddlDocument.setTextPane(pddlTextPane);
        pddlDocument.setData(diagram);
        pddlDocument.addDocumentListener(new DocumentListener() {

            public void insertUpdate(DocumentEvent de) {
                //throw new UnsupportedOperationException("Not supported yet.");                                            
                //System.out.println("insert");
                storechange(de);
            }

            public void removeUpdate(DocumentEvent de) {
                //throw new UnsupportedOperationException("Not supported yet.");
                //System.out.println("remove");
                storechange(de);
            }

            public void changedUpdate(DocumentEvent de) {
                //throw new UnsupportedOperationException("Not supported yet.");
                //System.out.println("changed");
            }

            public void storechange(DocumentEvent de) {
                //When a document is open it is also calling this method
                ItHilightedDocument document = (ItHilightedDocument) de.getDocument();
                String text = document.getTextPane().getText();
                Element diagram = document.getData();
                Element content = diagram.getChild("content");
                if (content != null) {
                    content.setText(text);
                } else {
                    content = new Element("content");
                    content.setText(text);
                    diagram.addContent(content);
                }
            }

        });

        //ROSI pddlDocument
        UndoManager undo = new UndoManager();
        toolBar.setUndoManager(undo);
        pddlDocument.addUndoableEditListener(new MyUndoableEditListener(undo));

        toolBar.setTextPane(pddlTextPane);

        JScrollPane pddlScrollPane = new JScrollPane(pddlTextPane);
        panel = new JRootPane();
        panel.setLayout(new BorderLayout());
        panel.add(toolBar, BorderLayout.NORTH);
        panel.add(pddlScrollPane, BorderLayout.CENTER);

        icon = new ImageIcon("resources/images/" + diagram.getName() + ".png");

        String fileContentText = "";

        fileContentText = getContentsAsString(file);

        pddlTextPane.setText(fileContentText);

        //Set Tab properties
        openTab.setAttribute("language", "PDDL");
        openTab.setAttribute("diagramID", id);
        openTab.setAttribute("projectID", projectHeader.getAttributeValue("id"));
        openTab.getChild("type").setText(diagram.getName());

        //if (diagram.getName().equals("pddlproblem")){
        //                                                                                        // planningProblems  domains
        //        openTab.getChild("domain").setText(diagram.getParentElement().getParentElement().getAttributeValue("id"));
        //}

        if (icon != null && panel != null) {
            // add the tab
            openTabs.addContent(openTab);
            addTab(title, icon, panel);
            if (getTabCount() > 1) {
                setSelectedIndex(getTabCount() - 1);
            }
        }

    }

}

From source file:jeplus.JEPlusFrameMain.java

/**
 * Fill in the batch execution options section in the Exec tab
 *///from www .  j av a  2 s.  com
private void initBatchOptions() {
    this.txtJobListFile.setText(Project.ExecSettings.getJobListFile());
    this.txtTestRandomN.setText(Integer.toString(Project.ExecSettings.getNumberOfJobs()));
    this.txtRandomSeed.setText(Long.toString(Project.ExecSettings.getRandomSeed()));
    this.chkLHS.setSelected(Project.ExecSettings.isUseLHS());
    this.cboSampleOpt.setSelectedItem(Project.ExecSettings.getSampleOpt());
    switch (Project.ExecSettings.getSubSet()) {
    case ExecutionOptions.CHAINS:
        this.rdoTestChains.setSelected(true);
        this.rdoTestChainsActionPerformed(null);
        break;
    case ExecutionOptions.RANDOM:
        this.rdoTestRandomN.setSelected(true);
        this.rdoTestRandomNActionPerformed(null);
        break;
    case ExecutionOptions.FILE:
        this.rdoJobListFile.setSelected(true);
        this.rdoJobListFileActionPerformed(null);
        break;
    case ExecutionOptions.ALL:
        this.rdoAllJobs.setSelected(true);
        this.rdoAllJobsActionPerformed(null);
    }

    // Set listeners to text fields
    DL = new DocumentListener() {
        Document DocJobListFile = txtJobListFile.getDocument();
        Document DocTestRandomN = txtTestRandomN.getDocument();
        Document DocRandomSeed = txtRandomSeed.getDocument();

        @Override
        public void insertUpdate(DocumentEvent e) {
            Document src = e.getDocument();
            if (src == DocJobListFile) {
                Project.ExecSettings.setJobListFile(txtJobListFile.getText());
                if (!new File(Project.ExecSettings.getJobListFile()).exists()) {
                    txtJobListFile.setForeground(Color.red);
                } else {
                    txtJobListFile.setForeground(Color.black);
                }
            } else if (src == DocTestRandomN) {
                try {
                    Project.ExecSettings.setNumberOfJobs(Integer.parseInt(txtTestRandomN.getText()));
                    txtTestRandomN.setForeground(Color.black);
                } catch (NumberFormatException nfx) {
                    txtTestRandomN.setForeground(Color.red);
                    Project.ExecSettings.setNumberOfJobs(1); // one job by default
                }
            } else if (src == DocRandomSeed) {
                long seed;
                try {
                    seed = Long.parseLong(txtRandomSeed.getText());
                    if (seed < 0)
                        seed = new Date().getTime();
                    txtRandomSeed.setForeground(Color.black);
                } catch (NumberFormatException nfx) {
                    seed = new Date().getTime();
                    txtRandomSeed.setForeground(Color.red);
                }
                Project.ExecSettings.setRandomSeed(seed);
            }
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            insertUpdate(e);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            // not applicable
        }

    };
    txtJobListFile.getDocument().addDocumentListener(DL);
    txtTestRandomN.getDocument().addDocumentListener(DL);
    txtRandomSeed.getDocument().addDocumentListener(DL);
}

From source file:org.nuclos.client.wizard.steps.NuclosEntityAttributeValueListShipStep.java

@Override
protected void initComponents() {

    lstValues = new ArrayList<ValueList>();

    this.setLayout(new BorderLayout(5, 5));
    pnlName = new JPanel();
    pnlName.setLayout(new BorderLayout(5, 5));

    lbName = new JLabel(
            SpringLocaleDelegate.getInstance().getMessage("wizard.step.attributevaluelist.7", "Name"));
    tfName = new JTextField();

    tfName.setDocument(new LimitSpecialCharacterDocument(25));

    pnlName.add(lbName, BorderLayout.WEST);
    pnlName.add(tfName, BorderLayout.CENTER);

    lbInfo = new JLabel(SpringLocaleDelegate.getInstance().getMessage("wizard.step.attributevaluelist.1",
            "Entitt ist schon vorhanden. Bitte anderen Namen vergeben!"));
    lbInfo.setForeground(Color.RED);
    lbInfo.setVisible(false);//from   w  ww . j ava  2 s. co  m

    this.add(pnlName, BorderLayout.NORTH);
    this.add(subform, BorderLayout.CENTER);
    this.add(lbInfo, BorderLayout.SOUTH);
    subform.getSubformTable().setModel(new ValuelistTableModel());

    JTextField textField = new JTextField();
    textField.addFocusListener(NuclosWizardUtils.createWizardFocusAdapter());
    DefaultCellEditor editor = new DefaultCellEditor(textField);
    editor.setClickCountToStart(1);
    subform.getSubformTable().setDefaultEditor(String.class, editor);
    subform.getSubformTable().setDefaultEditor(Date.class, new DateEditor());

    ListenerUtil.registerSubFormToolListener(subform, this, new SubForm.SubFormToolListener() {
        @Override
        public void toolbarAction(String actionCommand) {
            if (SubForm.ToolbarFunction.fromCommandString(actionCommand) == SubForm.ToolbarFunction.NEW) {
                ValuelistTableModel model = (ValuelistTableModel) subform.getSubformTable().getModel();
                lstValues.add(new ValueList());
                model.fireTableDataChanged();
            }
        }
    });

    tfName.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent e) {
            doSomeWork(e);
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            doSomeWork(e);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            doSomeWork(e);
        }

        private void doSomeWork(DocumentEvent e) {
            try {
                String s = e.getDocument().getText(0, e.getDocument().getLength());

                model.getAttribute().setValueListName(s);
                if (s.length() == 0)
                    NuclosEntityAttributeValueListShipStep.this.setComplete(false);
                else
                    NuclosEntityAttributeValueListShipStep.this.setComplete(true);

                if (model.getAttribute().isValueListNew()) {
                    for (EntityMetaDataVO voEntity : MetaDataClientProvider.getInstance().getAllEntities()) {
                        if (s.equals(voEntity.getEntity())
                                || ("V_EO_" + s).equalsIgnoreCase(voEntity.getDbEntity())) {
                            NuclosEntityAttributeValueListShipStep.this.setComplete(false);
                            lbInfo.setVisible(true);
                            break;
                        }
                        NuclosEntityAttributeValueListShipStep.this.setComplete(true);
                        lbInfo.setVisible(false);
                    }
                }
            } catch (BadLocationException e1) {
                LOG.info("doSomeWork failed: " + e1, e1);
            }
        }
    });

}

From source file:org.nuclos.client.wizard.steps.NuclosEntityNameStep.java

@Override
protected void initComponents() {

    colMasterdata = MetaDataClientProvider.getInstance().getAllEntities();

    double size[][] = { { TableLayout.PREFERRED, 200, TableLayout.FILL },
            { 20, 20, 20, 20, 20, TableLayout.FILL } };

    TableLayout layout = new TableLayout(size);
    layout.setVGap(3);/*from w  w  w  .  j av  a2  s .  c  o  m*/
    layout.setHGap(5);
    this.setLayout(layout);
    lbName = new JLabel(SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.1",
            "Bitte geben Sie den Namen der neuen Entit\u00e4t ein") + ": ");
    tfName = new JTextField();
    tfName.setToolTipText(SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.tooltip.1",
            "Namen der neuen Entit\u00e4t"));
    tfName.addFocusListener(NuclosWizardUtils.createWizardFocusAdapter());
    lbChoice = new JLabel(SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.2",
            "oder w\u00e4hlen Sie eine Entit\u00e4t die Sie ver\u00e4ndern m\u00f6chten") + ": ");
    cmbEntity = new JComboBox();
    cmbEntity.setToolTipText(SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.tooltip.2",
            "Namen der Entit\u00e4t die Sie ver\u00e4ndern m\u00f6chten"));
    this.fillEntityCombobox();
    cmbEntity.setEditable(true);
    AutoCompleteDecorator.decorate(cmbEntity);

    lbInfo = new JLabel();
    lbInfo.setVisible(false);
    lbInfo.setForeground(Color.RED);

    btnRemove = new JButton(SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.8",
            "Entit\u00e4t entfernen"));
    btnRemove.setVisible(false);

    this.add(lbName, "0,0");
    this.add(tfName, "1,0");
    this.add(lbChoice, "0,1");
    this.add(cmbEntity, "1,1");
    this.add(lbInfo, "0,2,1,2");
    this.add(btnRemove, "0,3");

    tfName.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent e) {
            doSomeWork(e);
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            doSomeWork(e);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            doSomeWork(e);
        }

        protected void doSomeWork(DocumentEvent e) {
            int size = e.getDocument().getLength();
            try {
                for (EntityMetaDataVO metaVO : colMasterdata) {
                    if (e.getDocument().getLength() == 0) {
                        lbInfo.setVisible(false);
                        break;
                    }
                    if (e.getDocument().getLength() > 250) {
                        lbInfo.setText(SpringLocaleDelegate.getInstance().getMessage(
                                "wizard.step.entityname.12", "Der Name ist zu lang. Bitte k\u00fcrzen!"));
                        lbInfo.setVisible(true);
                        NuclosEntityNameStep.this.setComplete(false);
                        return;
                    }

                    if (e.getDocument().getText(0, size).equals(metaVO.getEntity())
                            || e.getDocument().getText(0, size).equals(SpringLocaleDelegate.getInstance()
                                    .getResource(metaVO.getLocaleResourceIdForLabel(), ""))) {
                        NuclosEntityNameStep.this.setComplete(false);
                        lbInfo.setText(SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.4",
                                "Entit\u00e4t ist schon vorhanden"));
                        lbInfo.setVisible(true);
                        return;
                    } else {
                        lbInfo.setVisible(false);
                    }
                    if (e.getDocument().getLength() > 25) {
                        lbInfo.setText(
                                SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.13",
                                        "Der Tabellenname wird fr interne Zwecke gekrzt!"));
                        lbInfo.setVisible(true);
                    } else {
                        lbInfo.setVisible(false);
                    }
                }
                if (size > 0) {
                    if (cmbEntity.getSelectedIndex() > 0) {
                        NuclosEntityNameStep.this.model.resetModel();
                    }
                    NuclosEntityNameStep.this.setComplete(true);
                    cmbEntity.setSelectedIndex(0);
                    cmbEntity.setEnabled(false);
                } else {
                    //NuclosEntityNameStep.this.model.resetModel();
                    NuclosEntityNameStep.this.setComplete(false);
                    model.setTableOrViewName(null);
                    cmbEntity.setEnabled(true);
                }

                NuclosEntityNameStep.this.model
                        .setEntityName(e.getDocument().getText(0, e.getDocument().getLength()));
                if (!NuclosEntityNameStep.this.model.isEditMode()) {
                    NuclosEntityNameStep.this.model
                            .setLabelSingular(e.getDocument().getText(0, e.getDocument().getLength()));
                }
            } catch (BadLocationException ex) {
                Errors.getInstance().showExceptionDialog(NuclosEntityNameStep.this, ex);
            }
        }
    });

    cmbEntity.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                final Object obj = e.getItem();
                if (obj instanceof EntityWrapper) {
                    EntityMetaDataVO vo = ((EntityWrapper) obj).getWrappedEntity();
                    NuclosEntityNameStep.this.model.setEditMode(true);
                    NuclosEntityNameStep.this.model.resetModel();
                    NuclosEntityNameStep.this.setComplete(true);
                    btnRemove.setVisible(true);
                } else if (obj instanceof String) {
                    NuclosEntityNameStep.this.model.setEditMode(false);
                    NuclosEntityNameStep.this.model.resetModel();
                    tfName.setEnabled(true);
                    btnRemove.setVisible(false);
                    NuclosEntityNameStep.this.setComplete(false);
                }
            }
        }
    });
    ListenerUtil.registerActionListener(btnRemove, this, new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                StringBuffer sbMessage = new StringBuffer();
                if (!dropEntityAllowed(((EntityWrapper) cmbEntity.getSelectedItem()).getWrappedEntity(),
                        sbMessage)) {
                    JOptionPane.showMessageDialog(
                            NuclosEntityNameStep.this, sbMessage, SpringLocaleDelegate.getInstance()
                                    .getMessage("wizard.step.inputattribute.12", "Entfernen nicht mglich!"),
                            JOptionPane.OK_OPTION);
                    return;
                }

                boolean blnImportStructure = MetaDataDelegate.getInstance().hasEntityImportStructure(
                        ((EntityWrapper) cmbEntity.getSelectedItem()).getWrappedEntity().getId());
                if (blnImportStructure) {
                    String sMessage = SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.14",
                            "Diese Entitt besitzt Strukturdefinitionen fr Objektimporte. Diese wird gelscht! Sie knnen den Vorgang abbrechen!");
                    int abort = JOptionPane
                            .showConfirmDialog(
                                    NuclosEntityNameStep.this, sMessage, SpringLocaleDelegate.getInstance()
                                            .getMessage("wizard.step.entityname.16", "Achtung!"),
                                    JOptionPane.OK_CANCEL_OPTION);
                    if (abort != JOptionPane.OK_OPTION)
                        return;
                }

                boolean blnWorkflow = MetaDataDelegate.getInstance().hasEntityWorkflow(
                        ((EntityWrapper) cmbEntity.getSelectedItem()).getWrappedEntity().getId());
                if (blnWorkflow) {
                    String sMessage = SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.15",
                            "Diese Entitt ist in einem Arbeitsschritt integriert! Dieser wird gelscht!");
                    int abort = JOptionPane
                            .showConfirmDialog(
                                    NuclosEntityNameStep.this, sMessage, SpringLocaleDelegate.getInstance()
                                            .getMessage("wizard.step.entityname.16", "Achtung!"),
                                    JOptionPane.OK_CANCEL_OPTION);
                    if (abort != JOptionPane.OK_OPTION)
                        return;
                }

                final String sMessage = SpringLocaleDelegate.getInstance().getMessage(
                        "wizard.step.entityname.9",
                        "Sind Sie sicher, dass Sie die Entit\u00e4t l\u00f6schen m\u00f6chten?");
                final String sTitle = SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.10",
                        "L\u00f6schen");

                int dropEntity = JOptionPane.showConfirmDialog(NuclosEntityNameStep.this, sMessage, sTitle,
                        JOptionPane.YES_NO_OPTION);
                switch (dropEntity) {
                case JOptionPane.YES_OPTION:
                    boolean bDropLayout = false;
                    if (MetaDataDelegate.getInstance().hasEntityLayout(
                            ((EntityWrapper) cmbEntity.getSelectedItem()).getWrappedEntity().getId())) {
                        int dropLayout = JOptionPane.showConfirmDialog(NuclosEntityNameStep.this,
                                SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.11",
                                        "Soll das Layout der Entitt gelscht werden?"),
                                sTitle, JOptionPane.YES_NO_OPTION);
                        bDropLayout = (dropLayout == JOptionPane.YES_OPTION);
                    }

                    final boolean bDropLayoutfinal = bDropLayout;
                    UIUtils.runCommandLater(getParent(), new Runnable() {

                        @Override
                        public void run() {
                            try {
                                MetaDataDelegate.getInstance().removeEntity(
                                        ((EntityWrapper) cmbEntity.getSelectedItem()).getWrappedEntity(),
                                        bDropLayoutfinal);
                                NuclosWizardUtils.flushCaches();
                                NuclosConsole.getInstance().invalidateAllCaches();
                                NuclosEntityNameStep.this.model.cancelWizard();
                            } catch (Exception ex) {
                                Errors.getInstance().showExceptionDialog(NuclosEntityNameStep.this, ex);
                                return;
                            } finally {
                                MasterDataDelegate.getInstance().invalidateLayoutCache();
                            }
                        }
                    });
                    break;
                case JOptionPane.NO_OPTION:
                default:
                    return;
                }
            } catch (Exception ex) {
                Errors.getInstance().showExceptionDialog(NuclosEntityNameStep.this, ex);
                return;
            }
        }
    });

}