private void storeDataFromUserEntry()

in netbeansintegration/tags/4.1.0/src/org/openoffice/extensions/projecttemplates/actions/panel/PropsPanel.java [725:845]


    private void storeDataFromUserEntry(DocumentEvent e) {
        Document doc = e.getDocument();
        if (doc.equals(m_displayNamePanel.getDocument())) {
            GenericDescriptionProperty<String> displayName = m_Handler.getDisplayData();
            String text = m_displayNamePanel.getText();
            if (text.length() > 0) {
                displayName.setPropertyAndLocale(m_CurrentLocale, text);
            } else {
                displayName.deletePropertyAndLocale(m_CurrentLocale);
            }
        }
        else if (doc.equals(jPanelPublisherLink.getDocument())) {
            GenericDescriptionProperty<String[]> publisherData = m_Handler.getPublisherData();
            String link = jPanelPublisherLink.getText();
            String[] prop = publisherData.getPropertyForLocale(m_CurrentLocale);
            if (link.length() > 0) {
                if (prop == null) {
                    prop = new String[2];
                }
                prop[1] = link;
                publisherData.setPropertyAndLocale(m_CurrentLocale, prop);
            } else {
                if (prop == null || prop[0] == null || prop[0].length() == 0) {
                    publisherData.deletePropertyAndLocale(m_CurrentLocale);
                }
            }
        }
        else if (doc.equals(jPanelPublisherName.getDocument())) {
            GenericDescriptionProperty<String[]> publisherData = m_Handler.getPublisherData();
            String text = jPanelPublisherName.getText();
            String[] prop = publisherData.getPropertyForLocale(m_CurrentLocale);
            if (text.length() > 0) {
                if (prop == null) {
                    prop = new String[2];
                }
                prop[0] = text;
                publisherData.setPropertyAndLocale(m_CurrentLocale, prop);
            } else {
                if (prop == null || prop[1] == null || prop[1].length() == 0) {
                    publisherData.deletePropertyAndLocale(m_CurrentLocale);
                }
            }
        }
        else if (doc.equals(m_descriptionPanel.getDocument())) {
            GenericDescriptionProperty<String> description = m_Handler.getDescriptionData();
            String text = m_descriptionPanel.getText();
            if (text.length() > 0) {
                description.setPropertyAndLocale(m_CurrentLocale, text);
            } else {
                description.deletePropertyAndLocale(m_CurrentLocale);
            }
        }
        else if (doc.equals(m_licensePanel.getDocument())){
            GenericDescriptionProperty<String> license = m_Handler.getLicenseFiles();
            String text = m_licensePanel.getText();
            if (text.length() > 0) {
                license.setPropertyAndLocale(m_CurrentLocale, text);
            } else {
                license.deletePropertyAndLocale(m_CurrentLocale);
            }
            if (m_Handler.hasLicenseFiles()) { // first license file entry: enable user/admin buttons
                jRadioButtonAdmin.setEnabled(true);
                jRadioButtonUser.setEnabled(true);
                m_Handler.setLicenseAcceptByUser(jRadioButtonUser.isSelected());
            }
            else {
                jRadioButtonAdmin.setEnabled(false);
                jRadioButtonUser.setEnabled(false);
            }
        }
        else if (doc.equals(m_defaultIconPanel.getDocument())) {
            String file = m_defaultIconPanel.getText();
            File iconFile = new File(file);
            if (!iconFile.canRead()) {
                String imagesDir = (String)ProjectTypeHelper.getObjectFromUnoProperties(m_projDir, "images.dir"); // NOI18N
                if (imagesDir != null) {
                    FileObject imagesFileObject = m_projDir.getFileObject(imagesDir);
                    if (imagesFileObject != null) {
                        FileObject iconFileObject = imagesFileObject.getFileObject(file);
                        if (iconFileObject != null)
                            iconFile = FileUtil.toFile(iconFileObject);
                    }
                }
            }
            if (iconFile.canRead()) {
                m_Handler.setIconFile(iconFile.getPath());
            }
        }
        else if (doc.equals(m_highDefinitionIconPanel.getDocument())) {
            String file = m_highDefinitionIconPanel.getText();
            File iconFile = new File(file);
            if (!iconFile.canRead()) {
                String imagesDir = (String)ProjectTypeHelper.getObjectFromUnoProperties(m_projDir, "images.dir"); // NOI18N
                if (imagesDir != null) {
                    FileObject imagesFileObject = m_projDir.getFileObject(imagesDir);
                    if (imagesFileObject != null) {
                        FileObject iconFileObject = imagesFileObject.getFileObject(file);
                        if (iconFileObject != null)
                            iconFile = FileUtil.toFile(iconFileObject);
                    }
                }
            }
            if (iconFile.canRead()) {
                m_Handler.setHighDefIconFile(iconFile.getPath());
            }
        }
        else {
            // error
            LogWriter.getLogWriter().log(LogWriter.LEVEL_CRITICAL, "No known document on sheet");
        }
        VerifyData verifyer = VerifyData.getVerifyer();
        if (!verifyer.verifyLocalizedData(m_Handler)) {
            String message = verifyer.getErrorMessage();
            jErrorLabel.setText(message);
            jErrorLabel.setIcon(verifyer.getErrorIcon());
        }
        else {
            jErrorLabel.setText("");
            jErrorLabel.setIcon(null);
        }
    }