📄 elementeditordialog.java
字号:
/**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://www.jfree.org/jfreereport/index.html
* Project Lead: Thomas Morgner (taquera@sherito.org);
*
* (C) Copyright 2000-2003, by Simba Management Limited 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.
*
* ------------------------------
* StyleSheetPropertyEditorDialog.java
* ------------------------------
* (C)opyright 2003, by Thomas Morgner and Contributors.
*
* Original Author: Thomas Morgner;
* Contributor(s): David Gilbert (for Simba Management Limited);
*
* $Id: ElementEditorDialog.java,v 1.3 2004/04/20 18:55:00 taqua Exp $
*
* Changes
* -------------------------
* 25.10.2003 : Initial version
*
*/
package org.jfree.designer.visualeditor.elementeditor;
import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.AbstractAction;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.jfree.designer.visualeditor.VisualEditPanel;
import org.jfree.designer.visualeditor.bandeditor.ReportBandEditor;
import org.jfree.report.Band;
import org.jfree.report.Element;
import org.jfree.report.filter.DataSource;
import org.jfree.report.filter.templates.Template;
import org.jfree.report.util.Log;
public final class ElementEditorDialog
extends JDialog
implements PropertyChangeListener, ChangeListener
{
private final class ElementNameAction
extends AbstractAction
{
/**
* Invoked when an action occurs.
*/
public final void actionPerformed (final ActionEvent e)
{
if (element != null)
{
element.setName(elementName.getText());
}
}
}
//private static final int TEMPLATE_INDEX = 0;
private static final int ELEMENT_INDEX = 1;
private static final int BAND_INDEX = 2;
private StyleSheetPropertyEditorPane elementStylePane;
private StyleSheetPropertyEditorPane bandDefaultStylePane;
private TemplateEditorPane templateEditorPane;
private Element element;
private ReportBandEditor bandEditor;
private JTabbedPane tabbedPane;
private VisualEditPanel editPanel;
private JTextField elementName;
public ElementEditorDialog (final VisualEditPanel editPanel)
{
setTitle("Element Detail Editor");
this.editPanel = editPanel;
tabbedPane = new JTabbedPane();
elementStylePane = new StyleSheetPropertyEditorPane();
elementStylePane.setChangeListener(this);
bandDefaultStylePane = new StyleSheetPropertyEditorPane();
bandDefaultStylePane.setChangeListener(this);
templateEditorPane = new TemplateEditorPane();
templateEditorPane.addPropertyChangeListener(this);
final JLabel elementNameLabel = new JLabel("Element-Name");
elementName = new JTextField();
elementName.addActionListener(new ElementNameAction());
final JPanel elementPanel = new JPanel();
elementPanel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.WEST;
elementPanel.add(elementNameLabel, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 1;
gbc.anchor = GridBagConstraints.WEST;
elementPanel.add(elementName, gbc);
final Box templateBox = new Box(BoxLayout.Y_AXIS);
final JScrollPane templateScrolling = new JScrollPane(templateEditorPane);
templateBox.add(elementPanel);
templateBox.add(templateScrolling);
templateBox.add(Box.createVerticalGlue());
tabbedPane.add("Template", templateBox);
final Box elementBox = new Box(BoxLayout.Y_AXIS);
final JScrollPane elementScrolling = new JScrollPane(elementStylePane);
elementBox.add(elementScrolling);
tabbedPane.add("Element Style", elementBox);
final Box bandBox = new Box(BoxLayout.Y_AXIS);
bandBox.add(new JScrollPane(bandDefaultStylePane));
tabbedPane.add("Band Default Style", bandBox);
final JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(tabbedPane);
setContentPane(panel);
//tabbedPane.setEnabledAt(TEMPLATE_INDEX, false);
tabbedPane.setEnabledAt(ELEMENT_INDEX, false);
tabbedPane.setEnabledAt(BAND_INDEX, false);
}
/**
* Invoked when the target of the listener has changed its state.
*
* @param e a ChangeEvent object
*/
public final void stateChanged (final ChangeEvent e)
{
Log.info("Fire Change ...");
if (bandEditor != null)
{
bandEditor.revalidate();
//el
}
}
/**
* This method gets called when a bound property is changed.
*
* @param evt A PropertyChangeEvent object describing the event source and the property
* that has changed.
*/
public final void propertyChange (final PropertyChangeEvent evt)
{
if (this.element != null && templateEditorPane.getTemplate() != null)
{
this.element.setDataSource(templateEditorPane.getTemplate());
}
}
public final void setElement (final Element e)
{
if (this.element != null)
{
templateEditorPane.setTemplate(null);
elementStylePane.setStyleSheet(null);
bandDefaultStylePane.setStyleSheet(null);
//tabbedPane.setEnabledAt(TEMPLATE_INDEX, false);
tabbedPane.setEnabledAt(ELEMENT_INDEX, false);
tabbedPane.setEnabledAt(BAND_INDEX, false);
elementName.setText("");
bandEditor = null;
}
this.element = e;
if (this.element != null)
{
elementName.setText(element.getName());
bandEditor = editPanel.findEditorForElement(element);
elementStylePane.setStyleSheet(e.getStyle());
tabbedPane.setEnabledAt(ELEMENT_INDEX, true);
if (this.element instanceof Band)
{
final Band band = (Band) element;
bandDefaultStylePane.setStyleSheet(band.getBandDefaults());
tabbedPane.setEnabledAt(BAND_INDEX, true);
}
final DataSource ds = element.getDataSource();
if (ds instanceof Template)
{
templateEditorPane.setTemplate((Template) ds);
//tabbedPane.setEnabledAt(TEMPLATE_INDEX, true);
}
// else
// {
// //tabbedPane.setEnabledAt(TEMPLATE_INDEX, false);
// }
}
}
public final Element getElement ()
{
return element;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -