| Methods from java.awt.Component: |
|---|
|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, dispatchEvent, doLayout, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFocusable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFocusable, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate |
| Method from org.jfree.report.modules.gui.converter.ReportConverterGUI Detail: |
public boolean convert() {
if (performSourceValidate(getSourceFile()) == false)
{
setStatusText("Validating the source file failed. Please check your inputs.");
return false;
}
if (performTargetValidate(getTargetFile()) == false)
{
setStatusText("Validating the target file failed. Please check your inputs.");
return false;
}
try
{
final ConverterParserFrontend frontend = new ConverterParserFrontend();
final File sourceFile = new File (getSourceFile());
final File targetFile = new File (getTargetFile());
final String encoding = encodingModel.getSelectedEncoding();
final JFreeReport report = (JFreeReport)
frontend.parse(sourceFile.toURL(), sourceFile.toURL());
final DefaultConfiguration config = new DefaultConfiguration();
config.setProperty(Parser.CONTENTBASE_KEY, targetFile.toURL().toExternalForm());
// adding all factories will make sure that all stylekeys are found,
// even if the report was parsed from a simple report definition
final ReportWriter writer = new ReportWriter(report, encoding, config);
writer.addClassFactoryFactory(new URLClassFactory());
writer.addClassFactoryFactory(new DefaultClassFactory());
writer.addClassFactoryFactory(new BandLayoutClassFactory());
writer.addClassFactoryFactory(new ArrayClassFactory());
writer.addStyleKeyFactory(new DefaultStyleKeyFactory());
writer.addStyleKeyFactory(new PageableLayoutStyleKeyFactory());
writer.addTemplateCollection(new DefaultTemplateCollection());
writer.addElementFactory(new DefaultElementFactory());
writer.addDataSourceFactory(new DefaultDataSourceFactory());
final OutputStream base = new FileOutputStream(targetFile);
final Writer w = new BufferedWriter(new OutputStreamWriter(base, encoding));
writer.write(w);
w.close();
setStatusText("Conversion done.");
return true;
}
catch (Exception e)
{
Log.warn ("Failed to convert the report. ", e);
setStatusText("Failed to convert the report:" + e.getMessage());
return false;
}
}
Performs the conversion, returning true if the conversion is successful, and
false otherwise. |
protected JPanel createStatusBar() {
final JPanel statusPane = new JPanel();
statusPane.setLayout(new BorderLayout());
statusPane.setBorder(
BorderFactory.createLineBorder(UIManager.getDefaults().getColor("controlShadow")));
statusHolder = new JLabel(" ");
statusPane.setMinimumSize(statusHolder.getPreferredSize());
statusPane.add(statusHolder, BorderLayout.WEST);
return statusPane;
}
Creates the statusbar for this frame. Use setStatus() to display text on the status bar. |
protected ResourceBundle getResources() {
if (resources == null)
{
resources = ResourceBundle.getBundle(BASE_RESOURCE_CLASS);
}
return resources;
}
Retrieves the resources for the frame. If the resources are not initialized,
they get loaded on the first call to this method. |
protected String getSourceFile() {
return sourceField.getText();
}
Returns the source file name. |
public String getStatusText() {
return statusHolder.getText();
}
Returns the text from the status bar. |
protected String getTargetFile() {
return targetField.getText();
}
Returns the name of the target file. |
public static void main(String[] args) {
final ReportConverterGUI gui = new ReportConverterGUI();
gui.addWindowListener(new WindowAdapter()
{
public void windowClosing(final WindowEvent e)
{
System.exit(0);
}
});
gui.pack();
gui.setVisible(true);
}
Starting point for the utility application. |
protected String performSelectFile(String filename,
boolean appendExt) {
final File file = new File(filename);
fileChooser.setCurrentDirectory(file);
fileChooser.setSelectedFile(file);
final int option = fileChooser.showSaveDialog(this);
if (option == JFileChooser.APPROVE_OPTION)
{
final File selFile = fileChooser.getSelectedFile();
String selFileName = selFile.getAbsolutePath();
if (appendExt)
{
if ((StringUtil.endsWithIgnoreCase(selFileName, ".xml") == false))
{
selFileName = selFileName + ".xml";
}
}
return selFileName;
}
return filename;
}
|
public boolean performSourceValidate(String filename) {
if (filename.trim().length() == 0)
{
JOptionPane.showMessageDialog(this,
getResources().getString("convertdialog.sourceIsEmpty"),
getResources().getString("convertdialog.errorTitle"),
JOptionPane.ERROR_MESSAGE);
return false;
}
final File f = new File(filename);
if (f.exists() == false)
{
return false;
}
if (f.isFile() == false)
{
JOptionPane.showMessageDialog(this,
getResources().getString("convertdialog.sourceIsNoFile"),
getResources().getString("convertdialog.errorTitle"),
JOptionPane.ERROR_MESSAGE);
return false;
}
if (f.canRead() == false)
{
JOptionPane.showMessageDialog(this,
getResources().getString("convertdialog.sourceIsNotReadable"),
getResources().getString("convertdialog.errorTitle"),
JOptionPane.ERROR_MESSAGE);
return false;
}
return true;
}
Validates the contents of the dialogs input fields. If the selected file exists, it is also
checked for validity. |
public boolean performTargetValidate(String filename) {
if (filename.trim().length() == 0)
{
JOptionPane.showMessageDialog(this,
getResources().getString("convertdialog.targetIsEmpty"),
getResources().getString("convertdialog.errorTitle"),
JOptionPane.ERROR_MESSAGE);
return false;
}
final File f = new File(filename);
if (f.exists())
{
if (f.isFile() == false)
{
JOptionPane.showMessageDialog(this,
getResources().getString("convertdialog.targetIsNoFile"),
getResources().getString("convertdialog.errorTitle"),
JOptionPane.ERROR_MESSAGE);
return false;
}
if (f.canWrite() == false)
{
JOptionPane.showMessageDialog(this,
getResources().getString("convertdialog.targetIsNotWritable"),
getResources().getString("convertdialog.errorTitle"),
JOptionPane.ERROR_MESSAGE);
return false;
}
final String key1 = "convertdialog.targetOverwriteConfirmation";
final String key2 = "convertdialog.targetOverwriteTitle";
if (JOptionPane.showConfirmDialog(this,
MessageFormat.format(getResources().getString(key1),
new Object[]{filename}
),
getResources().getString(key2),
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)
== JOptionPane.NO_OPTION)
{
return false;
}
}
return true;
}
Validates the contents of the dialogs input fields. If the selected file exists, it is also
checked for validity. |
protected void setSourceFile(String file) {
sourceField.setText(file);
}
|
public void setStatusText(String text) {
statusHolder.setText(text);
}
Sets the text of the status line. |
protected void setTargetFile(String file) {
targetField.setText(file);
}
|