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

📄 datapanel.java

📁 报表设计软件,很好的
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/**
 * ========================================================================================
 * JFreeReport Designer : a graphical designer for JFreeReport - a free Java report library
 * ===================================
 import org.jfree.designer.db.ResultSetTableModel;
 =====
 *
 * Project Info:  http://www.jfree.org/jfreereport/index.html
 * Project Lead:  Thomas Morgner (taquera@sherito.org);
 *
 * (C) Copyright 2003, by Heiko Evermann (heiko@evermann.de) and Contributors.
 *
 * This library is free software; you can redistribute it and/or modify it under the terms
 * of the GNU Lesser General Public License as published by the Free Software Foundation;
 * either version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with this
 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 */


package org.jfree.designer.db;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Iterator;
import java.util.ResourceBundle;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JMenu;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JToolBar;
import javax.swing.table.TableModel;

import org.jfree.designer.JFreeReportDesigner;
import org.jfree.designer.ReportDefinitionManager;
import org.jfree.designer.RootEditor;
import org.jfree.designer.resources.ResourceBundleUtils;
import org.jfree.designer.util.AbstractDesignerAction;
import org.jfree.report.JFreeReport;
import org.jfree.report.ReportProcessingException;
import org.jfree.report.modules.gui.base.PreviewDialog;
import org.jfree.report.modules.gui.base.components.ActionDowngrade;
import org.jfree.report.util.Log;
import org.jfree.report.util.ReportProperties;
import org.jfree.ui.ExtensionFileFilter;
import org.jfree.ui.RefineryUtilities;


/**
 * @author hev
 *         <p/>
 *         To change this generated comment edit the template variable "typecomment":
 *         Window>Preferences>Java>Templates. To enable and disable the creation of type
 *         comments go to Window>Preferences>Java>Code Generation.
 */
public final class DataPanel
        extends JPanel
        implements RootEditor
{
  private final class ReportQueryAction
          extends AbstractDesignerAction
  {
    /**
     * Defines an <code>Action</code> object with a default description string and default
     * icon.
     */
    public ReportQueryAction ()
    {
      putValue(Action.NAME,
              resources.getString("action.database.report-query.Name"));
    }

    /**
     * Invoked when an action occurs.
     */
    public final void actionPerformed (final ActionEvent e)
    {
      onReportQuery();
    }
  }

  private final class LoadQueryAction
          extends AbstractDesignerAction
  {
    /**
     * Defines an <code>Action</code> object with a default description string and default
     * icon.
     */
    public LoadQueryAction ()
    {
      putValue(Action.NAME,
              resources.getString("action.database.load-query.Name"));
      putValue(Action.SMALL_ICON,
              ResourceBundleUtils.getIcon(resources.getString("action.database.load-query.SmallIcon")));
    }

    /**
     * Invoked when an action occurs.
     */
    public final void actionPerformed (final ActionEvent e)
    {
      onLoadQueryResult();
    }
  }

  private final class SaveQueryAction
          extends AbstractDesignerAction
  {
    /**
     * Defines an <code>Action</code> object with a default description string and default
     * icon.
     */
    public SaveQueryAction ()
    {
      putValue(Action.NAME,
              resources.getString("action.database.save-query.Name"));
      putValue(Action.SMALL_ICON,
              ResourceBundleUtils.getIcon(resources.getString("action.database.save-query.SmallIcon")));
    }

    /**
     * Invoked when an action occurs.
     */
    public final void actionPerformed (final ActionEvent e)
    {
      onSaveQueryResult();
    }
  }

  private final class ReportWizardAction
          extends AbstractDesignerAction
  {
    /**
     * Defines an <code>Action</code> object with a default description string and default
     * icon.
     */
    public ReportWizardAction ()
    {
      putValue(Action.NAME,
              resources.getString("action.database.report-wizzard.Name"));
      putValue(Action.SMALL_ICON,
              ResourceBundleUtils.getIcon(resources.getString("action.database.report-wizzard.SmallIcon")));
      putValue(ActionDowngrade.ACCELERATOR_KEY,
              ResourceBundleUtils.createMenuKeystroke(resources.getString("action.database.report-wizzard.KeyStroke")));
    }

    /**
     * Invoked when an action occurs.
     */
    public final void actionPerformed (final ActionEvent e)
    {
      onReportWizard();
    }
  }

  private final class PreviewReportAction
          extends AbstractDesignerAction
  {
    /**
     * Defines an <code>Action</code> object with a default description string and default
     * icon.
     */
    public PreviewReportAction ()
    {
      putValue(Action.NAME,
              resources.getString("action.database.preview-report.Name"));
    }

    /**
     * Invoked when an action occurs.
     */
    public final void actionPerformed (final ActionEvent e)
    {
      onPreviewReport();
    }
  }

  private final class DBConnectionsAction
          extends AbstractDesignerAction
  {
    /**
     * Defines an <code>Action</code> object with a default description string and default
     * icon.
     */
    public DBConnectionsAction ()
    {
      putValue(Action.NAME,
              resources.getString("action.database.connections.Name"));
    }

    /**
     * Invoked when an action occurs.
     */
    public final void actionPerformed (final ActionEvent e)
    {
      onDBConnections();
    }
  }

  private static final String RESOURCE_BASE_NAME =
          "org.jfree.designer.resources.designer-resources";

  private JTable reportDataTable;
  private ReportDefinitionManager reportDefinitionManager;
  private JFileChooser fileChooser;
  private boolean active;
  private JMenu[] editorMenus;
  private ResourceBundle resources;

  public DataPanel (final ReportDefinitionManager manager)
  {
    this.reportDefinitionManager = manager;
    this.resources = ResourceBundle.getBundle(RESOURCE_BASE_NAME);

    this.fileChooser = new JFileChooser();
    this.fileChooser.setFileFilter(new ExtensionFileFilter("Query Results", ".qry"));
    this.editorMenus = createMenus();
    this.reportDataTable = new JTable();

    add(new JScrollPane(reportDataTable), BorderLayout.CENTER);
    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
  }

  private JMenu[] createMenus ()
  {
    final JMenu[] menus = new JMenu[1];
    menus[0] = createReportMenu();
    return menus;
  }

  private JMenu createReportMenu ()
  {
    final JMenu mReport = new JMenu("Report");
    mReport.setMnemonic(KeyEvent.VK_R);
    mReport.add(new ReportWizardAction());
    mReport.add(new DBConnectionsAction());
    mReport.add(new ReportQueryAction());
    mReport.add(new SaveQueryAction());
    mReport.add(new LoadQueryAction());
    mReport.add(new PreviewReportAction());
    return mReport;
  }

  private void onReportWizard ()
  {
    JFreeReportDesigner.showMessageDialog
            ("This feature is not yet implemented", JOptionPane.ERROR_MESSAGE);

    //            WizardDialog d = new WizardDialog(new ReportWizard());
    //            d.setLocationRelativeTo(this);
    //            d.show();
  }

⌨️ 快捷键说明

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