Add localization.
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@891 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -111,7 +111,7 @@ class AboutPMD extends JDialog
|
||||
JPanel aboutPanel = new JPanel(new BorderLayout());
|
||||
|
||||
// PMD Image
|
||||
ImageIcon imageIcon = Utilities.getImageIcon("icons/pmdLogo.jpg");
|
||||
ImageIcon imageIcon = (ImageIcon) UIManager.get("pmdLogoImage");
|
||||
JLabel imageLabel = new JLabel(imageIcon);
|
||||
aboutPanel.add(imageLabel, BorderLayout.CENTER);
|
||||
|
||||
@ -121,13 +121,17 @@ class AboutPMD extends JDialog
|
||||
aboutPanel.add(bottomPanel, BorderLayout.SOUTH);
|
||||
|
||||
// Version Label
|
||||
JLabel versionLabel = new JLabel("Version 1.0RC2");
|
||||
String versionText = Resources.getString("RESOURCEVersion")
|
||||
+ " "
|
||||
+ Resources.getString("RESOURCEpmdVersion");
|
||||
JLabel versionLabel = new JLabel(versionText);
|
||||
versionLabel.setFont(UIManager.getFont("labelFont"));
|
||||
versionLabel.setHorizontalAlignment(JLabel.CENTER);
|
||||
bottomPanel.add(versionLabel);
|
||||
|
||||
// SourceForge PMD Project
|
||||
JLabel sourceForgeLabel = new JLabel("Developed by the SourceForge PMD Project Team");
|
||||
String sourceForgeText = Resources.getString("RESOURCEDevelopedBySourceForgePMDTeam");
|
||||
JLabel sourceForgeLabel = new JLabel(sourceForgeText);
|
||||
sourceForgeLabel.setFont(UIManager.getFont("labelFont"));
|
||||
sourceForgeLabel.setHorizontalAlignment(JLabel.CENTER);
|
||||
bottomPanel.add(sourceForgeLabel);
|
||||
|
@ -2,6 +2,12 @@ package net.sourceforge.pmd.swingui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.LookAndFeel;
|
||||
import javax.swing.UIDefaults;
|
||||
@ -79,8 +85,6 @@ public class PMDLookAndFeel extends WindowsLookAndFeel
|
||||
String pkgName = "net.sourceforge.pmd.swingui";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
****************************************************************************
|
||||
*
|
||||
@ -113,8 +117,6 @@ public class PMDLookAndFeel extends WindowsLookAndFeel
|
||||
loadSystemColors(table, defaultSystemColors, isNativeLookAndFeel());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
****************************************************************************
|
||||
*
|
||||
@ -137,6 +139,7 @@ public class PMDLookAndFeel extends WindowsLookAndFeel
|
||||
"view", LookAndFeel.makeIcon(plafClass, "icons/view.gif"),
|
||||
"help", LookAndFeel.makeIcon(plafClass, "icons/help.gif"),
|
||||
"pmdLogo", LookAndFeel.makeIcon(plafClass, "icons/pmdLogo.gif"),
|
||||
"pmdLogoImage", getImageIcon("icons/pmdLogo.jpg"),
|
||||
"labelFont", new Font("Dialog", Font.BOLD, 12),
|
||||
"label14Font", new Font("Dialog", Font.BOLD, 14),
|
||||
"label16Font", new Font("Dialog", Font.BOLD, 16),
|
||||
@ -148,6 +151,7 @@ public class PMDLookAndFeel extends WindowsLookAndFeel
|
||||
"messageFont", new Font("Dialog", Font.PLAIN, 12),
|
||||
"serif12Font", new Font("Serif", Font.PLAIN, 12),
|
||||
"serif14Font", new Font("Serif", Font.PLAIN, 14),
|
||||
"viewerProperties", loadViewerProperties(),
|
||||
|
||||
// These are all the icons defined in the WindowsLookAndFeel. We redefine them
|
||||
// here because of the way they are defined in that class: in terms of the return
|
||||
@ -176,4 +180,81 @@ public class PMDLookAndFeel extends WindowsLookAndFeel
|
||||
|
||||
table.putDefaults(defaults);
|
||||
}
|
||||
|
||||
/**
|
||||
****************************************************************************
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private Properties loadViewerProperties()
|
||||
{
|
||||
Properties properties = new Properties();
|
||||
|
||||
try
|
||||
{
|
||||
InputStream inputStream = getClass().getResourceAsStream("pmdViewer.properties");
|
||||
properties.load(inputStream);
|
||||
}
|
||||
catch (IOException exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
*
|
||||
* @param fileName
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected static final ImageIcon getImageIcon(String fileName)
|
||||
{
|
||||
final byte[][] buffer = new byte[1][];
|
||||
|
||||
try
|
||||
{
|
||||
InputStream resource = PMDLookAndFeel.class.getResourceAsStream(fileName);
|
||||
|
||||
if (resource == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
BufferedInputStream in;
|
||||
ByteArrayOutputStream out;
|
||||
int n;
|
||||
|
||||
in = new BufferedInputStream(resource);
|
||||
out = new ByteArrayOutputStream(1024);
|
||||
buffer[0] = new byte[1024];
|
||||
|
||||
while ((n = in.read(buffer[0])) > 0)
|
||||
{
|
||||
out.write(buffer[0], 0, n);
|
||||
}
|
||||
|
||||
in.close();
|
||||
out.flush();
|
||||
buffer[0] = out.toByteArray();
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (buffer[0] == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (buffer[0].length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ImageIcon(buffer[0]);
|
||||
}
|
||||
}
|
@ -12,6 +12,9 @@ import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.Font;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.swing.border.CompoundBorder;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.border.EtchedBorder;
|
||||
@ -52,7 +55,7 @@ public class PMDViewer extends JFrame
|
||||
private ResultsViewer m_resultsViewer;
|
||||
private JScrollPane m_resultsViewerScrollPane;
|
||||
private JSplitPane m_mainSplitPane;
|
||||
private PMDClipboard m_clipboardOwner = new PMDClipboard();
|
||||
private PMDClipboard m_clipboardOwner;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
@ -62,6 +65,8 @@ public class PMDViewer extends JFrame
|
||||
{
|
||||
super("PMD Viewer");
|
||||
|
||||
m_clipboardOwner = new PMDClipboard();
|
||||
|
||||
int windowWidth = 1200;
|
||||
int windowHeight = 1000;
|
||||
int windowMargin = 10;
|
||||
@ -94,7 +99,7 @@ public class PMDViewer extends JFrame
|
||||
createMainSplitPane();
|
||||
getContentPane().add(createContentPanel(windowMargin));
|
||||
|
||||
ImageIcon image = Utilities.getImageIcon("icons/pmdLogo.jpg");
|
||||
ImageIcon image = (ImageIcon) UIManager.get("pmdLogoImage");
|
||||
setIconImage(image.getImage());
|
||||
}
|
||||
|
||||
@ -244,6 +249,7 @@ public class PMDViewer extends JFrame
|
||||
/**
|
||||
*********************************************************************************
|
||||
*
|
||||
* @param rootDirectories
|
||||
*/
|
||||
private void setupFiles(File[] rootDirectories)
|
||||
{
|
||||
@ -265,9 +271,9 @@ public class PMDViewer extends JFrame
|
||||
|
||||
UIManager.setLookAndFeel(useLookAndFeel);
|
||||
|
||||
PMDViewer pmdViewer = new PMDViewer();
|
||||
LoadRootDirectories loadRootDirectories = new LoadRootDirectories();
|
||||
loadRootDirectories.start();
|
||||
PMDViewer pmdViewer = new PMDViewer();
|
||||
pmdViewer.setVisible(true);
|
||||
pmdViewer.setupFiles(loadRootDirectories.getDirectories());
|
||||
}
|
||||
|
44
pmd/src/net/sourceforge/pmd/swingui/Resources.java
Normal file
44
pmd/src/net/sourceforge/pmd/swingui/Resources.java
Normal file
@ -0,0 +1,44 @@
|
||||
package net.sourceforge.pmd.swingui;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.swing.UIManager;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Donald A. Leckie
|
||||
* @since September 9, 2002
|
||||
* @version $Revision$, $Date$
|
||||
*/
|
||||
class Resources
|
||||
{
|
||||
private static ResourceBundle RESOURCES = ResourceBundle.getBundle("net.sourceforge.pmd.swingui.pmdViewer");
|
||||
|
||||
/**
|
||||
*********************************************************************************
|
||||
*
|
||||
* @param name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected static final String getString(String name)
|
||||
{
|
||||
return RESOURCES.getString(name);
|
||||
}
|
||||
|
||||
/**
|
||||
*********************************************************************************
|
||||
*
|
||||
* @param name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected static final String getString(String name, String[] parameters)
|
||||
{
|
||||
String template = RESOURCES.getString(name);
|
||||
String message = MessageFormat.format(template, parameters);
|
||||
|
||||
return message;
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
package net.sourceforge.pmd.swingui;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Donald A. Leckie
|
||||
* @since September 5, 2002
|
||||
* @version $Revision$, $Date$
|
||||
*/
|
||||
class Utilities
|
||||
{
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
*
|
||||
* @param fileName
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected static final ImageIcon getImageIcon(String fileName)
|
||||
{
|
||||
final byte[][] buffer = new byte[1][];
|
||||
|
||||
try
|
||||
{
|
||||
InputStream resource = PMDLookAndFeel.class.getResourceAsStream(fileName);
|
||||
|
||||
if (resource == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
BufferedInputStream in;
|
||||
ByteArrayOutputStream out;
|
||||
int n;
|
||||
|
||||
in = new BufferedInputStream(resource);
|
||||
out = new ByteArrayOutputStream(1024);
|
||||
buffer[0] = new byte[1024];
|
||||
|
||||
while ((n = in.read(buffer[0])) > 0)
|
||||
{
|
||||
out.write(buffer[0], 0, n);
|
||||
}
|
||||
|
||||
in.close();
|
||||
out.flush();
|
||||
buffer[0] = out.toByteArray();
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (buffer[0] == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (buffer[0].length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ImageIcon(buffer[0]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user