com.openindex.openestate.tool
Class ImmoToolUtils

java.lang.Object
  extended by com.openindex.openestate.tool.ImmoToolUtils

public class ImmoToolUtils
extends Object

Hilfsfunktionen.
$Id: ImmoToolUtils.java 1845 2012-10-18 16:34:47Z andy $

Author:
Andreas Rudolph

Field Summary
static Color BG_COLOR_1
           
static Color BG_COLOR_2
           
static Color TABLE_HIGHLIGHT_COLOR
           
static eu.medsea.mimeutil.MimeType UNKNOWN_MIME_TYPE
           
 
Method Summary
static JPanel buildButtonBar(JButton... buttons)
           
static JPanel buildButtonBar(org.jdesktop.swingx.JXTitledSeparator title, JButton... buttons)
           
static void configureDialog(JDialog dlg)
           
static void configureDialog(JDialog dlg, org.jdesktop.swingx.JXPanel bgPanel)
           
static void configureFrame(JFrame frame, String title)
           
static void configureTable(org.jdesktop.swingx.JXTable table)
           
static JMenuItem createDefaultMenuItem(Action action)
          Hilfsfunktion zur Erzeugung eines Menü-Eintrages.
static JMenuItem createDefaultMenuItem(String title)
          Hilfsfunktion zur Erzeugung eines Menü-Eintrages.
static org.apache.commons.net.ftp.FTPClient createFtpClient()
           
static org.jdesktop.swingx.JXTitledSeparator createHead1Separator(String title)
           
static org.jdesktop.swingx.JXTitledSeparator createHead2Separator(String title)
           
static org.apache.http.client.HttpClient createHttpClient()
           
static org.apache.http.client.HttpClient createHttpClient(String login, String password)
           
static org.apache.http.client.HttpClient createHttpClient(String login, String password, int timeout)
           
static ProxySelector createHttpProxySelector(String host, int port)
           
static ModificationHandler createModificationHandler()
           
static ValidationHandler createValidationHandler()
           
static BufferedImage cropImageToRatio(BufferedImage image, int ratioWidth, int ratioHeight)
           
static void deleteRecursively(org.apache.commons.net.ftp.FTPClient client, String path)
           
static void deleteRecursively(org.apache.commons.net.ftp.FTPClient client, String path, org.apache.commons.net.ftp.FTPFile file)
           
static void executeTask(org.jdesktop.application.Task task)
           
static BufferedImage flipImageHorizontal(BufferedImage image, int type)
           
static BufferedImage flipImageVertical(BufferedImage image, int type)
           
static Action getAction(Class actionClass, Object actionContainer, String actionName)
           
static Action getAction(Object actionContainer, String actionName)
           
static ActionMap getActionMap(Class actionClass, Object actionContainer)
           
static ActionMap getActionMap(Object actionContainer)
           
static org.jdesktop.swingx.painter.Painter getBackgroundPainter(int height)
           
static Object getComponentValue(JComponent c)
           
static String getCountryCodeFromText(String country)
           
static List<String> getCountryCodes()
          Liefert die ID's der verfügbaren Länder
static String getCountryName(String code)
           
static List<String> getCurrencyCodes()
           
static String getCurrencySymbol(String code)
           
static Color getHexColor(String s)
          Erzeugt ein Color-Objekt aus einem RGB-Hex-String.
static String getHumanReadableByteCount(long size)
           
static String getHumanReadableByteCount(long size, NumberFormat numberFormat)
           
static URL getIdnaUrl(String url)
           
static URL getIdnaUrl(URL url)
           
static double getImageScaleFactor(int sourceWidth, int sourceHeight, int targetWidth, int targetHeight)
           
static eu.medsea.mimeutil.MimeType getMimeType(File file)
           
static eu.medsea.mimeutil.MimeType getMimeType(InputStream in)
           
static ImmoToolPlugin getPlugin(String name)
           
static Set<String> getPluginNames()
           
static Boolean getPropertyAsBoolean(String key, Boolean defaultValue, Properties props)
           
static Color getPropertyAsColor(String key, Color defaultValue, Properties props)
           
static Date getPropertyAsDate(String key, Date defaultValue, Properties props)
           
static Float getPropertyAsFloat(String key, Float defaultValue, Properties props)
           
static Integer getPropertyAsInteger(String key, Integer defaultValue, Properties props)
           
static Long getPropertyAsLong(String key, Long defaultValue, Properties props)
           
static ResourceBundle getResourceBundle(Class containerClass, Locale locale)
           
static org.jdesktop.application.ResourceMap getResourceMap(Class containerClass)
           
static String getResourcePath(Class containerClass)
           
static String getResourcePath(Class containerClass, Locale locale)
           
static String getStringResource(Class actionContainerClass, String key)
           
static boolean hasPanel(String title)
           
static byte[] loadFileContent(File file)
           
static void loadFileIntoZipStream(File f, ZipOutputStream output)
           
static void loadFileIntoZipStream(File f, ZipOutputStream output, String baseDir)
           
static org.apache.commons.net.ftp.FTPClient openFtpClient(String host, int port, boolean passive)
           
static void openPDF(File pdf)
          PDF-Datei in externer Anwendung öffnen.
static void openPDF(String path)
          PDF-Datei in externer Anwendung öffnen.
static void openURL(String url)
          URL in externer Anwendung öffnen.
static void openURL(URL url)
          URL in externer Anwendung öffnen.
static void print(Printable printable)
           
static String readApplicationResource(String name)
           
static String readFile(File f)
           
static boolean removePanel(String title)
           
static boolean removePanel(String title, boolean force)
           
static String replaceTags(String txt)
           
static BufferedImage rotateImageToLeft(BufferedImage image, int type)
           
static BufferedImage rotateImageToRight(BufferedImage image, int type)
           
static BufferedImage scaleImageAndKeepRatio(BufferedImage image, int maxWidth, int maxHeight)
           
static BufferedImage scaleImageAndKeepRatio(BufferedImage image, int maxWidth, int maxHeight, int imageType)
           
static BufferedImage scaleImageToResolution(BufferedImage image, int screenWidth, int screenHeight, int resolution)
           
static boolean selectPanel(String title)
           
static void setLocale(Locale locale)
           
static void showHelpDialog()
           
static void showHelpDialog(String id)
           
static void showHelpDialog(String id, boolean modal)
           
static String showInputDialog(String msg)
          Darstellung eines Dialog-Fensters mit einem Eingabefeld.
static String showInputDialog(String msg, String defaultValue)
          Darstellung eines Dialog-Fensters mit einem Eingabefeld.
static void showMessageDialog(String msg, String title, int type)
          Meldungsdialog anzeigen.
static void showMessageDialog(String msg, String title, int type, Component parent)
          Meldungsdialog anzeigen.
static void showMessageErrorDialog(String msg)
          Dialog mit Fehlermeldung anzeigen.
static void showMessageErrorDialog(String msg, Component parent)
           
static void showMessageErrorDialog(String msg, List<String> errors)
          Dialog mit Fehlermeldung anzeigen.
static void showMessageErrorDialog(String msg, Map<String,List<String>> errors)
          Dialog mit Fehlermeldung anzeigen.
static void showMessageErrorDialog(String msg, String title)
          Dialog mit Fehlermeldung anzeigen.
static void showMessageErrorDialog(String msg, Throwable t)
           
static void showMessageInfoDialog(String msg)
          Dialog mit Fehlermeldung anzeigen.
static void showMessageInfoDialog(String msg, Component c)
           
static void showMessageInfoDialog(String msg, String title)
          Dialog mit Fehlermeldung anzeigen.
static void showMessageInfoDialog(String msg, String title, Component c)
           
static void showMessageWarningDialog(String msg)
          Dialog mit Fehlermeldung anzeigen.
static void showMessageWarningDialog(String msg, String title)
          Dialog mit Fehlermeldung anzeigen.
static void showPanel(TabComponent component)
           
static void showPanel(TabComponent component, boolean select)
           
static boolean showQuestionDialog(String msg)
          Darstellung eines Dialog-Fensters mit einer Frage.
static boolean showQuestionDialog(String msg, Component c)
           
static Boolean showQuestionWithCancelDialog(String msg)
          Darstellung eines Dialog-Fensters mit einer Frage.
static Boolean showQuestionWithCancelDialog(String msg, Component c)
          Darstellung eines Dialog-Fensters mit einer Frage.
static Image toGray(Image image)
           
static ImageIcon toGray(ImageIcon icon)
           
static void updateProgram(ImmoToolProject project, ImmoToolDb db, String oldVersion, String newVersion)
           
static void updateProgramPlugin(ImmoToolProject project, ImmoToolPlugin plugin, ImmoToolDb db, String oldVersion, String newVersion)
           
static void updateTabs()
           
static String wrapAndIndentString(String original, String indent, int width)
          Indent and wrap multi-line strings.
static List<String> wrapStringToArray(String original, int width, BreakIterator breakIterator, boolean removeNewLines)
          Wrap multi-line strings (and get the individual lines).
static String writeException(Throwable ex)
           
static void writeFileToStream(File file, OutputStream out)
           
static String writeHexColor(Color color)
           
static void writeStreamToFile(InputStream in, File file)
           
static void writeURLToStream(URL url, OutputStream out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BG_COLOR_1

public static final Color BG_COLOR_1

BG_COLOR_2

public static final Color BG_COLOR_2

TABLE_HIGHLIGHT_COLOR

public static final Color TABLE_HIGHLIGHT_COLOR

UNKNOWN_MIME_TYPE

public static final eu.medsea.mimeutil.MimeType UNKNOWN_MIME_TYPE
Method Detail

buildButtonBar

public static JPanel buildButtonBar(JButton... buttons)

buildButtonBar

public static JPanel buildButtonBar(org.jdesktop.swingx.JXTitledSeparator title,
                                    JButton... buttons)

configureDialog

public static void configureDialog(JDialog dlg)

configureDialog

public static void configureDialog(JDialog dlg,
                                   org.jdesktop.swingx.JXPanel bgPanel)

configureFrame

public static void configureFrame(JFrame frame,
                                  String title)

configureTable

public static void configureTable(org.jdesktop.swingx.JXTable table)

createDefaultMenuItem

public static JMenuItem createDefaultMenuItem(Action action)
Hilfsfunktion zur Erzeugung eines Menü-Eintrages.

Parameters:
action -
Returns:

createDefaultMenuItem

public static JMenuItem createDefaultMenuItem(String title)
Hilfsfunktion zur Erzeugung eines Menü-Eintrages.

Parameters:
title -
Returns:

createFtpClient

public static org.apache.commons.net.ftp.FTPClient createFtpClient()
                                                            throws IOException,
                                                                   IllegalStateException
Throws:
IOException
IllegalStateException

createHead1Separator

public static org.jdesktop.swingx.JXTitledSeparator createHead1Separator(String title)

createHead2Separator

public static org.jdesktop.swingx.JXTitledSeparator createHead2Separator(String title)

createHttpClient

public static org.apache.http.client.HttpClient createHttpClient()

createHttpClient

public static org.apache.http.client.HttpClient createHttpClient(String login,
                                                                 String password)

createHttpClient

public static org.apache.http.client.HttpClient createHttpClient(String login,
                                                                 String password,
                                                                 int timeout)

createHttpProxySelector

public static ProxySelector createHttpProxySelector(String host,
                                                    int port)

createModificationHandler

public static ModificationHandler createModificationHandler()

createValidationHandler

public static ValidationHandler createValidationHandler()

cropImageToRatio

public static BufferedImage cropImageToRatio(BufferedImage image,
                                             int ratioWidth,
                                             int ratioHeight)

deleteRecursively

public static void deleteRecursively(org.apache.commons.net.ftp.FTPClient client,
                                     String path)
                              throws IOException
Throws:
IOException

deleteRecursively

public static void deleteRecursively(org.apache.commons.net.ftp.FTPClient client,
                                     String path,
                                     org.apache.commons.net.ftp.FTPFile file)
                              throws IOException
Throws:
IOException

executeTask

public static void executeTask(org.jdesktop.application.Task task)

flipImageHorizontal

public static BufferedImage flipImageHorizontal(BufferedImage image,
                                                int type)

flipImageVertical

public static BufferedImage flipImageVertical(BufferedImage image,
                                              int type)

getAction

public static Action getAction(Object actionContainer,
                               String actionName)

getAction

public static Action getAction(Class actionClass,
                               Object actionContainer,
                               String actionName)

getActionMap

public static ActionMap getActionMap(Object actionContainer)

getActionMap

public static ActionMap getActionMap(Class actionClass,
                                     Object actionContainer)

getBackgroundPainter

public static org.jdesktop.swingx.painter.Painter getBackgroundPainter(int height)

getComponentValue

public static Object getComponentValue(JComponent c)

getCountryCodes

public static List<String> getCountryCodes()
Liefert die ID's der verfügbaren Länder

Returns:
ISO-Codes

getCountryCodeFromText

public static String getCountryCodeFromText(String country)

getCountryName

public static String getCountryName(String code)

getCurrencyCodes

public static List<String> getCurrencyCodes()

getCurrencySymbol

public static String getCurrencySymbol(String code)

getHexColor

public static Color getHexColor(String s)
Erzeugt ein Color-Objekt aus einem RGB-Hex-String.

Parameters:
s - RGB-Hex-String
Returns:
Color-Objekt

getHumanReadableByteCount

public static String getHumanReadableByteCount(long size)

getHumanReadableByteCount

public static String getHumanReadableByteCount(long size,
                                               NumberFormat numberFormat)

getIdnaUrl

public static URL getIdnaUrl(String url)
                      throws gnu.inet.encoding.IDNAException,
                             MalformedURLException
Throws:
gnu.inet.encoding.IDNAException
MalformedURLException

getIdnaUrl

public static URL getIdnaUrl(URL url)
                      throws gnu.inet.encoding.IDNAException,
                             MalformedURLException
Throws:
gnu.inet.encoding.IDNAException
MalformedURLException

getImageScaleFactor

public static double getImageScaleFactor(int sourceWidth,
                                         int sourceHeight,
                                         int targetWidth,
                                         int targetHeight)

getMimeType

public static eu.medsea.mimeutil.MimeType getMimeType(File file)

getMimeType

public static eu.medsea.mimeutil.MimeType getMimeType(InputStream in)

getPlugin

public static ImmoToolPlugin getPlugin(String name)

getPluginNames

public static Set<String> getPluginNames()

getPropertyAsBoolean

public static Boolean getPropertyAsBoolean(String key,
                                           Boolean defaultValue,
                                           Properties props)

getPropertyAsColor

public static Color getPropertyAsColor(String key,
                                       Color defaultValue,
                                       Properties props)

getPropertyAsDate

public static Date getPropertyAsDate(String key,
                                     Date defaultValue,
                                     Properties props)

getPropertyAsFloat

public static Float getPropertyAsFloat(String key,
                                       Float defaultValue,
                                       Properties props)

getPropertyAsInteger

public static Integer getPropertyAsInteger(String key,
                                           Integer defaultValue,
                                           Properties props)

getPropertyAsLong

public static Long getPropertyAsLong(String key,
                                     Long defaultValue,
                                     Properties props)

getResourceBundle

public static ResourceBundle getResourceBundle(Class containerClass,
                                               Locale locale)

getResourceMap

public static org.jdesktop.application.ResourceMap getResourceMap(Class containerClass)

getResourcePath

public static String getResourcePath(Class containerClass)

getResourcePath

public static String getResourcePath(Class containerClass,
                                     Locale locale)

getStringResource

public static String getStringResource(Class actionContainerClass,
                                       String key)

hasPanel

public static boolean hasPanel(String title)

loadFileContent

public static byte[] loadFileContent(File file)
                              throws IOException
Throws:
IOException

loadFileIntoZipStream

public static void loadFileIntoZipStream(File f,
                                         ZipOutputStream output)
                                  throws IOException
Throws:
IOException

loadFileIntoZipStream

public static void loadFileIntoZipStream(File f,
                                         ZipOutputStream output,
                                         String baseDir)
                                  throws IOException
Throws:
IOException

openFtpClient

public static org.apache.commons.net.ftp.FTPClient openFtpClient(String host,
                                                                 int port,
                                                                 boolean passive)
                                                          throws IOException,
                                                                 IllegalStateException
Throws:
IOException
IllegalStateException

openPDF

public static void openPDF(File pdf)
PDF-Datei in externer Anwendung öffnen.

Parameters:
pdf - zu öffnende PDF

openPDF

public static void openPDF(String path)
PDF-Datei in externer Anwendung öffnen.

Parameters:
path - zu öffnende PDF

openURL

public static void openURL(URL url)
URL in externer Anwendung öffnen.

Parameters:
url - zu öffnende URL

openURL

public static void openURL(String url)
URL in externer Anwendung öffnen.

Parameters:
url - zu öffnende URL

print

public static void print(Printable printable)
                  throws PrinterException
Throws:
PrinterException

readApplicationResource

public static String readApplicationResource(String name)
                                      throws IOException
Throws:
IOException

readFile

public static String readFile(File f)
                       throws IOException
Throws:
IOException

removePanel

public static boolean removePanel(String title)

removePanel

public static boolean removePanel(String title,
                                  boolean force)

replaceTags

public static String replaceTags(String txt)

rotateImageToLeft

public static BufferedImage rotateImageToLeft(BufferedImage image,
                                              int type)

rotateImageToRight

public static BufferedImage rotateImageToRight(BufferedImage image,
                                               int type)

scaleImageAndKeepRatio

public static BufferedImage scaleImageAndKeepRatio(BufferedImage image,
                                                   int maxWidth,
                                                   int maxHeight)

scaleImageAndKeepRatio

public static BufferedImage scaleImageAndKeepRatio(BufferedImage image,
                                                   int maxWidth,
                                                   int maxHeight,
                                                   int imageType)

scaleImageToResolution

public static BufferedImage scaleImageToResolution(BufferedImage image,
                                                   int screenWidth,
                                                   int screenHeight,
                                                   int resolution)

selectPanel

public static boolean selectPanel(String title)

setLocale

public static void setLocale(Locale locale)

showHelpDialog

public static void showHelpDialog()

showHelpDialog

public static void showHelpDialog(String id)

showHelpDialog

public static void showHelpDialog(String id,
                                  boolean modal)

showInputDialog

public static String showInputDialog(String msg)
Darstellung eines Dialog-Fensters mit einem Eingabefeld.

Parameters:
msg - dargestellter Text
Returns:
eingegebener Text, oder null bei einem Abbruch

showInputDialog

public static String showInputDialog(String msg,
                                     String defaultValue)
Darstellung eines Dialog-Fensters mit einem Eingabefeld.

Parameters:
msg - dargestellter Text
defaultValue - Standard-Wert im Eingabefeld
Returns:
eingegebener Text, oder null bei einem Abbruch

showMessageDialog

public static void showMessageDialog(String msg,
                                     String title,
                                     int type)
Meldungsdialog anzeigen.

Parameters:
title - Mitteilungstitel
msg - Mitteilungstext
type - Mitteilungsart

showMessageDialog

public static void showMessageDialog(String msg,
                                     String title,
                                     int type,
                                     Component parent)
Meldungsdialog anzeigen.

Parameters:
title - Mitteilungstitel
msg - Mitteilungstext
type - Mitteilungsart
parent - Parent-Komponente

showMessageErrorDialog

public static void showMessageErrorDialog(String msg)
Dialog mit Fehlermeldung anzeigen.

Parameters:
msg - Mitteilungstext

showMessageErrorDialog

public static void showMessageErrorDialog(String msg,
                                          Component parent)

showMessageErrorDialog

public static void showMessageErrorDialog(String msg,
                                          Throwable t)

showMessageErrorDialog

public static void showMessageErrorDialog(String msg,
                                          List<String> errors)
Dialog mit Fehlermeldung anzeigen.

Parameters:
msg - Mitteilungstext
errors - Fehler-Liste

showMessageErrorDialog

public static void showMessageErrorDialog(String msg,
                                          Map<String,List<String>> errors)
Dialog mit Fehlermeldung anzeigen.

Parameters:
msg - Mitteilungstext
errors - Fehler-Liste

showMessageErrorDialog

public static void showMessageErrorDialog(String msg,
                                          String title)
Dialog mit Fehlermeldung anzeigen.

Parameters:
title - Mitteilungstitel
msg - Mitteilungstext

showMessageInfoDialog

public static void showMessageInfoDialog(String msg)
Dialog mit Fehlermeldung anzeigen.

Parameters:
msg - Mitteilungstext

showMessageInfoDialog

public static void showMessageInfoDialog(String msg,
                                         Component c)

showMessageInfoDialog

public static void showMessageInfoDialog(String msg,
                                         String title)
Dialog mit Fehlermeldung anzeigen.

Parameters:
title - Mitteilungstitel
msg - Mitteilungstext

showMessageInfoDialog

public static void showMessageInfoDialog(String msg,
                                         String title,
                                         Component c)

showMessageWarningDialog

public static void showMessageWarningDialog(String msg)
Dialog mit Fehlermeldung anzeigen.

Parameters:
msg - Mitteilungstext

showMessageWarningDialog

public static void showMessageWarningDialog(String msg,
                                            String title)
Dialog mit Fehlermeldung anzeigen.

Parameters:
title - Mitteilungstitel
msg - Mitteilungstext

showPanel

public static void showPanel(TabComponent component)

showPanel

public static void showPanel(TabComponent component,
                             boolean select)

showQuestionDialog

public static boolean showQuestionDialog(String msg)
Darstellung eines Dialog-Fensters mit einer Frage.

Parameters:
msg - Text der Frage
Returns:
true, wenn die Frage mit ja beantwortet wurde

showQuestionDialog

public static boolean showQuestionDialog(String msg,
                                         Component c)

showQuestionWithCancelDialog

public static Boolean showQuestionWithCancelDialog(String msg)
Darstellung eines Dialog-Fensters mit einer Frage.

Parameters:
msg - Text der Frage
Returns:
true, wenn die Frage mit ja beantwortet wurde

showQuestionWithCancelDialog

public static Boolean showQuestionWithCancelDialog(String msg,
                                                   Component c)
Darstellung eines Dialog-Fensters mit einer Frage.

Parameters:
msg - Text der Frage
c - aufrufende Komponente
Returns:
true, wenn die Frage mit ja beantwortet wurde

toGray

public static ImageIcon toGray(ImageIcon icon)

toGray

public static Image toGray(Image image)

updateProgram

public static void updateProgram(ImmoToolProject project,
                                 ImmoToolDb db,
                                 String oldVersion,
                                 String newVersion)
                          throws ImmoToolException
Throws:
ImmoToolException

updateProgramPlugin

public static void updateProgramPlugin(ImmoToolProject project,
                                       ImmoToolPlugin plugin,
                                       ImmoToolDb db,
                                       String oldVersion,
                                       String newVersion)
                                throws ImmoToolException
Throws:
ImmoToolException

updateTabs

public static void updateTabs()

wrapAndIndentString

public static String wrapAndIndentString(String original,
                                         String indent,
                                         int width)
Indent and wrap multi-line strings.

Parameters:
original - the original string to wrap
indent - indentation
width - the maximum width of lines
Returns:
the whole string with embedded newlines

wrapStringToArray

public static List<String> wrapStringToArray(String original,
                                             int width,
                                             BreakIterator breakIterator,
                                             boolean removeNewLines)
Wrap multi-line strings (and get the individual lines).

Parameters:
original - the original string to wrap
width - the maximum width of lines
breakIterator - breaks original to chars, words, sentences, depending on what instance you provide.
removeNewLines - if true, any newlines in the original string are ignored
Returns:
the lines after wrapping

writeException

public static String writeException(Throwable ex)

writeHexColor

public static String writeHexColor(Color color)

writeFileToStream

public static void writeFileToStream(File file,
                                     OutputStream out)
                              throws FileNotFoundException,
                                     IOException
Throws:
FileNotFoundException
IOException

writeURLToStream

public static void writeURLToStream(URL url,
                                    OutputStream out)
                             throws FileNotFoundException,
                                    IOException
Throws:
FileNotFoundException
IOException

writeStreamToFile

public static void writeStreamToFile(InputStream in,
                                     File file)
                              throws FileNotFoundException,
                                     IOException
Throws:
FileNotFoundException
IOException


Copyright © 2012 OpenEstate. All Rights Reserved.