📄 mainframe.java
字号:
/*
* MainFrame.java
*
* iReport -- Visual designer for generating JasperReports Documents
* Copyright (C) 2002-2003 Giulio Toffoli gt@businesslogic.it
*
* This program is free software; you can redistribute and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Giulio Toffoli
* Via T.Aspetti, 233
* 35100 Padova ITALY
* gt@businesslogic.it
*
* Created on 5 febbraio 2003, 12.45
*
*/
package it.businesslogic.ireport.gui;
import it.businesslogic.ireport.gui.event.*;
import it.businesslogic.ireport.gui.library.*;
import it.businesslogic.ireport.gui.locale.*;
import it.businesslogic.ireport.*;
import it.businesslogic.ireport.util.*;
import javax.swing.tree.*;
import java.util.*;
import java.io.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.Point;
import java.beans.PropertyVetoException;
import jcmdline.*;
import org.apache.xerces.parsers.DOMParser;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.NamedNodeMap;
import org.xml.sax.SAXException;
/**
* This class is the core of the GUI of iReport. From this class we control all
* events related to the open and close files, handling of properties files,
* handling JMDIDestopPane, Menus....
*
* @author Administrator
*/
public class MainFrame extends javax.swing.JFrame implements ReportListener, Runnable, LanguageChangedListener {
public int docCounter=0;
private Thread checkModifiedFielsThread = null;
public static String constTitle = "iReport 0.4.1 ";
private String homeDirectory = ".";
private java.util.Vector toolBarControls;
private java.util.HashMap pluginEntries;
private ElementPropertiesDialog elementPropertiesDialog;
private EventsForm eventsForm;
private ValuesDialog valuesDialog;
private GroupsDialog groupsDialog;
private BandsDialog bandsDialog;
private FontsDialog fontsDialog;
private LocaleResourceFilesDialog localeFilesDialog;
private ReportQueryDialog reportQueryDialog;
private PluginConfigurationDialog pluginConfigurationDialog = null;
private Vector ttfFonts;
private Vector connections;
private Properties properties;
private Vector recentFilesList;
private Vector favoriteFilesList;
private Vector recentProjectsList;
private Vector clipboards[];
private it.businesslogic.ireport.ReportElement styleClipboards[];
private int activeClipboard = 0;
private int activeStyleClipboard = 0;
private boolean catchFormActivated = true;
private boolean embeddedIreport = false;
private LibraryPanel libraryPanel = null;
public static ReportClassLoader reportClassLoader = null;
private static MainFrame mainInstance = null;
private boolean dontHandleEvent;
private StringBuffer outputBuffer;
/**
* Variable currentZoomFactor is used to remember the zoomFactor
* while reloading a file after changing it from outside or
* via the option Edit XML source.
*/
private double currentZoomFactor = 1.0;
public static String IREPORT_HOME_DIR;
public static String IREPORT_USER_HOME_DIR;
public static String IREPORT_TMP_DIR;
public static String IREPORT_RECENT_FILES_FILE;
public static String IREPORT_FAVORITE_FILES_FILE;
public static String IREPORT_RECENT_PROJECTS_FILE;
public static String IREPORT_CONFIG_FILE;
public static String IREPORT_DEFAULT_HOME_DIR;
public static final int IREPORT_JAVA_VIEWER = 1;
public static final int IREPORT_PDF_VIEWER = 2;
public static final int IREPORT_HTML_VIEWER = 4;
public static final int IREPORT_XLS_VIEWER = 8;
public static final int IREPORT_CSV_VIEWER = 16;
public static final int IREPORT_JASPER_VIEWER = 32;
public static final int IREPORT_TXT_VIEWER = 64;
/**
* Return the main instance of the MainFrame. This method assume that there is only
* one iReport instanced per JVM, so the first istance of MainFrame is the only possible.
*/
public static MainFrame getMainInstance() {
return mainInstance;
}
static {
reportClassLoader = new ReportClassLoader();
} //end static section for simple init
/*
* You can override ireport home setting ireport.home variable or using line command options.
*
*/
public void setiReportPaths(String ireport_home, String ireport_user_home, String ireport_tmp_dir) {
// Setting User home directory
if ( ireport_user_home == null) {
ireport_user_home = System.getProperty("user.home") + File.separator + ".ireport";
IREPORT_USER_HOME_DIR = ireport_user_home;
//setHomeDirectory(Misc.nvl(System.getProperty("ireport.home"), IREPORT_DEFAULT_HOME_DIR));
}
else {
if (ireport_user_home.endsWith(File.separator)) {
ireport_user_home = ireport_user_home.substring(0, ireport_user_home.length()-1);
}
IREPORT_USER_HOME_DIR = ireport_user_home;
}
// Setting iReport directory
if ( ireport_home == null) {
ireport_home = System.getProperty("ireport.home",".");
IREPORT_HOME_DIR = ireport_home;
setHomeDirectory(IREPORT_HOME_DIR);
}
else {
if (ireport_home.endsWith(File.separator)) {
ireport_home = ireport_home.substring(0, ireport_home.length()-1);
}
IREPORT_HOME_DIR = ireport_home;
}
// Setting temp dir...
if (IREPORT_TMP_DIR == null || IREPORT_TMP_DIR.trim().length() == 0) {
if ( ireport_tmp_dir == null) {
ireport_user_home = System.getProperty("user.home") + File.separator + ".ireport";
IREPORT_TMP_DIR = ireport_home;
//setHomeDirectory(Misc.nvl(System.getProperty("ireport.home"), IREPORT_DEFAULT_HOME_DIR));
}
else {
if (ireport_tmp_dir.endsWith(File.separator)) {
ireport_tmp_dir = ireport_tmp_dir.substring(0, ireport_tmp_dir.length()-1);
}
IREPORT_TMP_DIR = ireport_tmp_dir;
}
}
IREPORT_DEFAULT_HOME_DIR = IREPORT_HOME_DIR;
setHomeDirectory(IREPORT_HOME_DIR);
IREPORT_RECENT_FILES_FILE = IREPORT_USER_HOME_DIR + File.separator + "recentFiles.xml";
IREPORT_RECENT_PROJECTS_FILE = IREPORT_USER_HOME_DIR + File.separator + "recentProjects.xml";
IREPORT_FAVORITE_FILES_FILE = IREPORT_USER_HOME_DIR + File.separator + "favoriteFiles.xml";
IREPORT_CONFIG_FILE = IREPORT_USER_HOME_DIR + File.separator + "config.xml";
//System.out.println(IREPORT_DEFAULT_HOME_DIR);
//System.out.println(IREPORT_HOME_DIR);
try {
//nothing in here yet.
}
catch(Throwable e) {
e.printStackTrace(System.err);
}
}
public MainFrame() {
this(new HashMap());
}
/** Creates new form MainFrame */
public MainFrame(Map args) {
if (mainInstance==null) {
mainInstance = this;
}
SplashDialog sp = null;
if (args.get("splash") != null)
{
sp = (SplashDialog)args.get("splash");
}
properties = new Properties();
outputBuffer = new StringBuffer();
connections = new Vector();
recentFilesList = new Vector();
favoriteFilesList = new Vector();
recentProjectsList = new Vector();
pluginEntries = new java.util.HashMap();
setiReportPaths((String)args.get("ireport-home"),
(String)args.get("user-home"),
(String)args.get("tmp-dir"));
// Set the classloader...
//Thread.currentThread().setContextClassLoader( reportClassLoader );
if (sp!=null) sp.updateLoadingStatus(10,"Loading iReport configuration");
if (args.containsKey("config-file")) {
loadiReportConfiguration((String)args.get("config-file"));
}
else {
loadiReportConfiguration();
}
if (args.get("beanClass") != null)
{
getProperties().put("beanClass",(String)args.get("beanClass"));
}
Misc.setPLAF( properties.getProperty("LookAndFeel") );
if (sp!=null) sp.updateLoadingStatus(20,"Setting locale");
it.businesslogic.ireport.util.I18n.setCurrentLocale( properties.getProperty("Language"), properties.getProperty("Country") );
if (sp!=null) sp.updateLoadingStatus(30,"Init main frame components");
initComponents();
this.jListThreads.setModel(new javax.swing.DefaultListModel());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -