⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 localeresourcefilesdialog.java

📁 iReport-0.4.1-src是iReport的源代码,iReport是一个开源的报表项目,可以生成PDF等格式报表
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            }        });        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 5;        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;        gridBagConstraints.weightx = 1.0;        gridBagConstraints.insets = new java.awt.Insets(4, 0, 0, 0);        jPanel2.add(jButtonDeleteFile, gridBagConstraints);        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 10;        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;        gridBagConstraints.weightx = 1.0;        gridBagConstraints.weighty = 1.0;        jPanel2.add(jPanel3, gridBagConstraints);        jButtonClose.setFont(new java.awt.Font("Dialog", 0, 11));        jButtonClose.setText("Close");        jButtonClose.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButtonCloseActionPerformed(evt);            }        });        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;        gridBagConstraints.weightx = 1.0;        jPanel2.add(jButtonClose, gridBagConstraints);        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;        gridBagConstraints.insets = new java.awt.Insets(4, 0, 4, 4);        jPanelData.add(jPanel2, gridBagConstraints);        getContentPane().add(jPanelData, java.awt.BorderLayout.CENTER);        pack();    }//GEN-END:initComponents    private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked        if (evt.getClickCount() == 2 && evt.getButton() == evt.BUTTON1)        {            jButtonModifyFileActionPerformed(null);                    }    }//GEN-LAST:event_jTable1MouseClicked    private void jButtonDeleteFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDeleteFileActionPerformed                if (jTable1.getSelectedRow() >= 0)        {            Report report = getJReportFrame().getReport();            File f = new File(report.getFilename());            File dir = f.getParentFile();            File localeFile = new File(dir,""+jTable1.getValueAt( jTable1.getSelectedRow(), 1)  );            try {                localeFile.delete();            } catch (Exception ex) {}            updateFileList();        }            }//GEN-LAST:event_jButtonDeleteFileActionPerformed    private void jButtonModifyFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonModifyFileActionPerformed                if (jTable1.getSelectedRow() >= 0)        {            Report report = getJReportFrame().getReport();            File f = new File(report.getFilename());            File dir = f.getParentFile();            File localeFile = new File(dir,""+jTable1.getValueAt( jTable1.getSelectedRow(), 1)  );            LocaleEditorDialog led = new LocaleEditorDialog(this.getJReportFrame().getMainFrame(), false);            led.setFile( localeFile );            led.setVisible(true);            try {                led.setTitle( localeFile.getName() );            } catch (Exception ex) {}        }    }//GEN-LAST:event_jButtonModifyFileActionPerformed    private void jButtonCreateNewLocaleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCreateNewLocaleActionPerformed                String suffix = "";                Report report = getJReportFrame().getReport();        if (report.getFilename() == null ||            report.getFilename().trim().equals("") )        {            javax.swing.JOptionPane.showMessageDialog(this,"To create a new locale file please save your report first.");            return;        }                File f = new File(report.getFilename());        if (report.getResourceBundleBaseName() == null ||            report.getResourceBundleBaseName().trim().equals("") )        {            String filename =  f.getName();            int index = filename.lastIndexOf(".");            if (index >= 0) {                        filename = filename.substring(0,index);            }            report.setResourceBundleBaseName(filename);        }                NewLocaleFileDialog fd = new NewLocaleFileDialog(this, true);        fd.setVisible(true);        File localeFile = null;        if (fd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION)        {            try   {            suffix = fd.getText();                                    File dir = f.getParentFile();            localeFile = new File(dir, report.getResourceBundleBaseName() + ".properties");            // 1. Try to load default...            String str = "# Locale " + suffix + " for report "  + f.getName() +"\n";            try {                FileInputStream fis = new FileInputStream(localeFile);                byte[] buffer = new byte[1024];                int read = 0;                while ((read = fis.read(buffer)) > 0)                {                    str += new String(buffer,0,read);                }                fis.close();            } catch (Exception ex){}                            localeFile = new File(dir, report.getResourceBundleBaseName() + suffix +".properties");            FileOutputStream fos = new FileOutputStream( localeFile );            fos.write( str.getBytes());            fos.close();                        updateFileList();                        } catch (Exception ex) {              javax.swing.JOptionPane.showMessageDialog(this,"Error creating new locale " + localeFile.getName() +": " + ex.getMessage());            }        }    }//GEN-LAST:event_jButtonCreateNewLocaleActionPerformed    private void jButtonCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCloseActionPerformed               this.setDialogResult( javax.swing.JOptionPane.OK_OPTION);        this.setVisible(false);    }//GEN-LAST:event_jButtonCloseActionPerformed            // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.JButton jButtonClose;    private javax.swing.JButton jButtonCreateNewLocale;    private javax.swing.JButton jButtonDeleteFile;    private javax.swing.JButton jButtonModifyFile;    private javax.swing.JPanel jPanel2;    private javax.swing.JPanel jPanel3;    private javax.swing.JPanel jPanelData;    private javax.swing.JScrollPane jScrollPane3;    private javax.swing.JTable jTable1;    // End of variables declaration//GEN-END:variables    public static String getLocaleName(String baseName, String propertiesName)    {        String language = "";        String country = "";        String variant = "";        Locale locale = Locale.getDefault();                if (!propertiesName.endsWith(".properties")) return "";        if (!propertiesName.startsWith(baseName)) return "";                propertiesName = propertiesName.substring(baseName.length(), propertiesName.length() - ".properties".length());                if (propertiesName.length() == 0) return "Default";        if (propertiesName.startsWith("_")) propertiesName = propertiesName.substring(1);        if (propertiesName.indexOf("_") > 0)         {            language = propertiesName.substring(0,propertiesName.indexOf("_"));            propertiesName = propertiesName.substring(propertiesName.indexOf("_")+1);                        if (propertiesName.indexOf("_") > 0)             {                country = propertiesName.substring(0,propertiesName.indexOf("_"));                propertiesName = propertiesName.substring(propertiesName.indexOf("_")+1);                                if (propertiesName.indexOf("_") > 0)                 {                    variant = propertiesName.substring(0,propertiesName.indexOf("_"));                    propertiesName = propertiesName.substring(propertiesName.indexOf("_")+1);                }                else                {                    variant = propertiesName;                }            }            else            {                country = propertiesName;            }        }        else        {            language = propertiesName;        }                locale = new Locale(language,country,variant);                return locale.getDisplayName();             }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -