Example usage for com.jgoodies.looks.plastic PlasticLookAndFeel setPlasticTheme

List of usage examples for com.jgoodies.looks.plastic PlasticLookAndFeel setPlasticTheme

Introduction

In this page you can find the example usage for com.jgoodies.looks.plastic PlasticLookAndFeel setPlasticTheme.

Prototype

public static void setPlasticTheme(PlasticTheme theme) 

Source Link

Document

Sets the theme for colors and fonts used by the Plastic L&F.

After setting the theme, you need to re-install the Look&Feel, as well as update the UI's of any previously created components - just as if you'd change the Look&Feel.

Usage

From source file:edu.ku.brc.specify.Specify.java

License:Open Source License

/**
 *
 *///from ww  w . j  av a2s.  c om
public static void main(String[] args) {

    // Set App Name, MUST be done very first thing!
    UIRegistry.setAppName("Specify"); //$NON-NLS-1$

    //log.debug("********* Current ["+(new File(".").getAbsolutePath())+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    AppBase.processArgs(args);
    AppBase.setupTeeForStdErrStdOut(true, false);

    //UIHelper.attachUnhandledException();

    SwingUtilities.invokeLater(new Runnable() {
        @SuppressWarnings("synthetic-access") //$NON-NLS-1$
        public void run() {
            log.debug("Checking for update....");
            try {
                try {
                    UIHelper.OSTYPE osType = UIHelper.getOSType();
                    if (osType == UIHelper.OSTYPE.Windows) {
                        //UIManager.setLookAndFeel(new WindowsLookAndFeel());
                        UIManager.setLookAndFeel(new PlasticLookAndFeel());
                        PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue());

                    } else if (osType == UIHelper.OSTYPE.Linux) {
                        //UIManager.setLookAndFeel(new GTKLookAndFeel());
                        UIManager.setLookAndFeel(new PlasticLookAndFeel());
                        //PlasticLookAndFeel.setPlasticTheme(new SkyKrupp());
                        //PlasticLookAndFeel.setPlasticTheme(new DesertBlue());
                        //PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue());
                        //PlasticLookAndFeel.setPlasticTheme(new DesertGreen());

                    } else {
                        //PlafOptions.setAsLookAndFeel();
                    }
                } catch (Exception e) {
                    log.error("Can't change L&F: ", e); //$NON-NLS-1$
                }

                // Load Local Prefs
                AppPreferences localPrefs = AppPreferences.getLocalPrefs();
                localPrefs.setDirPath(UIRegistry.getAppDataDir());

                ProxyHelper.setProxySettingsFromPrefs();

                checkDebugLoggerSettings();

                //log.error("LocalPrefs: "+(new File(UIRegistry.getAppDataDir())).getCanonicalPath());

                // Check to see if we should check for a new version
                String VERSION_CHECK = "version_check.auto";
                if (localPrefs.getBoolean(VERSION_CHECK, null) == null) {
                    localPrefs.putBoolean(VERSION_CHECK, true);
                }

                // For Proxies
                boolean isOKToGetSpecialMsgs = AppPreferences.getLocalPrefs().getBoolean("GET_SPECIAL_MSGS",
                        true);
                if (isOKToGetSpecialMsgs) {
                    SpecialMsgNotifier smn = new SpecialMsgNotifier();
                    smn.checkForMessages();
                }

                if (UIRegistry.isEmbedded() && !UIRegistry.isMobile()) {
                    String EZDB_FIRSTTIME = "ezdb.firsttime";
                    if (localPrefs.getBoolean(EZDB_FIRSTTIME, null) == null) {
                        UIRegistry.showLocalizedMsg("EZDB_FIRSTTIME");
                        localPrefs.putBoolean(EZDB_FIRSTTIME, true);
                        localPrefs.flush();
                    }
                }

                String EXTRA_CHECK = "extra.check";
                Boolean isExtraCheck = localPrefs.getBoolean(EXTRA_CHECK, true);
                if (isExtraCheck == null) {
                    isExtraCheck = true;
                    localPrefs.putBoolean(EXTRA_CHECK, isExtraCheck);
                }

                // Managed Releases
                // it's never managed for the Release Manager
                //                  boolean isReleaseManager = localPrefs.getBoolean("RELEASE_MANAGER", false);
                //                  boolean isManagedRelease = localPrefs.getBoolean(MANAGED_RELEASES, false);
                //                  boolean isMgrRel         = !isReleaseManager && isManagedRelease;
                //
                //                  // Never check if it is a managed release
                //                  boolean verChk = localPrefs.getBoolean(VERSION_CHECK, true);
                //                  if (localPrefs.getBoolean(VERSION_CHECK, true) && !isMgrRel)
                //                  {
                //                      if (!isMgrRel)
                //                      {
                //                          localPrefs.getBoolean(MANAGED_RELEASES, false); // remove it in case it was turned on
                //                      }

                //                      try
                //                      {
                //                        com.install4j.api.launcher.SplashScreen.hide();
                //                         ApplicationLauncher.Callback callback = new ApplicationLauncher.Callback()
                //                         {
                //                             @Override
                //                             public void exited(int exitValue)
                //                             {
                //                                 startApp();
                //                             }
                //                             
                //                             @Override
                //                             public void prepareShutdown()
                //                             {
                //                                 
                //                             }
                //                          };
                //                          //ApplicationLauncher.launchApplication("100", getProxySettings(), true, callback);
                //                          
                //                      } catch (Exception ex)
                //                      {
                //                          //ex.printStackTrace();
                //                          log.error(ex);
                //                          startApp();
                //                      }
                //                  } else
                //                  {
                //                      if (!isExtraCheck && StringUtils.isNotEmpty(UIRegistry.getAppVersion()))
                //                      {
                //                          UIRegistry.showLocalizedMsg(null, "SpReg.NOT_REGISTERED");
                //                      }
                startApp();
                //                  }
            } catch (Exception ex) {
                ex.printStackTrace();
                log.error(ex);
            }
        }
    });

}

From source file:edu.ku.brc.specify.tests.PickListTestApp.java

License:Open Source License

/**
* Create the GUI and show it.  For thread safety,
* this method should be invoked from the
* event-dispatching thread.// w ww .j  av  a  2  s.  c om
*/
private void initialize() {
    SpecifyAppPrefs.initialPrefs(); // Must be done first thing!

    try {
        //System.out.println(System.getProperty("os.name"));

        if (!System.getProperty("os.name").equals("Mac OS X")) {
            UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
            PlasticLookAndFeel.setPlasticTheme(new DesertBlue());
        }

        //UIManager.setLookAndFeel(new PlasticLookAndFeel()); 
        //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
        //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
    } catch (Exception e) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(PickListTestApp.class, e);
        log.error("Can't change L&F: ", e);
    }

    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);

    // Create and set up the window.
    mainFrame = new JFrame("Specify Form Editor");
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    UIRegistry.setTopWindow(mainFrame);

    // Create and set up the content pane.
    contentPane = buildContentPane();
    contentPane.setOpaque(true); //content panes must be opaque
    mainFrame.setContentPane(contentPane);

    JMenuBar menuBar = createMenus();
    if (menuBar != null) {
        mainFrame.setJMenuBar(menuBar);
    }

    mainFrame.pack();
    //mainFrame.setSize(new Dimension(1024, 764));
    //frame.pack();
    UIHelper.centerAndShow(mainFrame);

}

From source file:edu.ku.brc.specify.tools.ireportspecify.MainFrameSpecify.java

License:Open Source License

/**
 * @param args/* w ww.j av a2  s  . c  o  m*/
 */
public static void main(String[] args) {
    log.debug("********* Current [" + (new File(".").getAbsolutePath()) + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    // This is for Windows and Exe4J, turn the args into System Properties

    // Set App Name, MUST be done very first thing!
    //UIRegistry.setAppName("iReports4Specify");  //$NON-NLS-1$
    UIRegistry.setAppName("Specify"); //$NON-NLS-1$
    UIRegistry.setEmbeddedDBPath(UIRegistry.getDefaultEmbeddedDBPath()); // on the local machine

    AppBase.processArgs(args);
    AppBase.setupTeeForStdErrStdOut(true, false);

    // Then set this
    IconManager.setApplicationClass(Specify.class);
    IconManager.loadIcons(XMLHelper.getConfigDir("icons_datamodel.xml")); //$NON-NLS-1$
    IconManager.loadIcons(XMLHelper.getConfigDir("icons_plugins.xml")); //$NON-NLS-1$
    IconManager.loadIcons(XMLHelper.getConfigDir("icons_disciplines.xml")); //$NON-NLS-1$

    Specify.setUpSystemProperties();

    AppPreferences localPrefs = AppPreferences.getLocalPrefs();
    localPrefs.setDirPath(UIRegistry.getAppDataDir());
    adjustLocaleFromPrefs();
    HibernateUtil.setListener("post-commit-update", new edu.ku.brc.specify.dbsupport.PostUpdateEventListener()); //$NON-NLS-1$
    HibernateUtil.setListener("post-commit-insert", new edu.ku.brc.specify.dbsupport.PostInsertEventListener()); //$NON-NLS-1$
    HibernateUtil.setListener("post-commit-delete", new edu.ku.brc.specify.dbsupport.PostDeleteEventListener()); //$NON-NLS-1$

    ImageIcon helpIcon = IconManager.getIcon(IconManager.makeIconName("AppIcon"), IconSize.Std16); //$NON-NLS-1$
    HelpMgr.initializeHelp("SpecifyHelp", helpIcon.getImage()); //$NON-NLS-1$

    try {
        UIHelper.OSTYPE osType = UIHelper.getOSType();
        if (osType == UIHelper.OSTYPE.Windows) {
            UIManager.setLookAndFeel(new PlasticLookAndFeel());
            PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue());

        } else if (osType == UIHelper.OSTYPE.Linux) {
            UIManager.setLookAndFeel(new PlasticLookAndFeel());
        }
    } catch (Exception e) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(MainFrameSpecify.class, e);
        log.error("Can't change L&F: ", e); //$NON-NLS-1$
    }

    if (UIHelper.isLinux()) {
        Specify.checkForSpecifyAppsRunning();
    }

    if (UIRegistry.isEmbedded()) {
        ProcessListUtil.checkForMySQLProcesses(new ProcessListener() {
            @Override
            public void done(PROC_STATUS status) // called on the UI thread
            {
                if (status == PROC_STATUS.eOK || status == PROC_STATUS.eFoundAndKilled) {
                    startupContinuing(); // On UI Thread
                }
            }
        });
    } else {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                startupContinuing();
            }
        });
    }
}

From source file:edu.ku.brc.specify.tools.l10nios.StrLocalizerAppForiOS.java

License:Open Source License

/**
  * @param args//www. j  av  a2 s.  c o m
  */
public static void main(String[] args) {
    setAppName("Specify"); //$NON-NLS-1$
    System.setProperty(AppPreferences.factoryName, "edu.ku.brc.specify.config.AppPrefsDBIOIImpl"); // Needed by AppReferences //$NON-NLS-1$

    for (String s : args) {
        String[] pairs = s.split("="); //$NON-NLS-1$
        if (pairs.length == 2) {
            if (pairs[0].startsWith("-D")) //$NON-NLS-1$
            {
                //System.err.println("["+pairs[0].substring(2, pairs[0].length())+"]["+pairs[1]+"]");
                System.setProperty(pairs[0].substring(2, pairs[0].length()), pairs[1]);
            }
        } else {
            String symbol = pairs[0].substring(2, pairs[0].length());
            //System.err.println("["+symbol+"]");
            System.setProperty(symbol, symbol);
        }
    }

    // Now check the System Properties
    String appDir = System.getProperty("appdir");
    if (StringUtils.isNotEmpty(appDir)) {
        UIRegistry.setDefaultWorkingPath(appDir);
    }

    String appdatadir = System.getProperty("appdatadir");
    if (StringUtils.isNotEmpty(appdatadir)) {
        UIRegistry.setBaseAppDataDir(appdatadir);
    }

    // Then set this
    IconManager.setApplicationClass(Specify.class);
    IconManager.loadIcons(XMLHelper.getConfigDir("icons.xml")); //$NON-NLS-1$
    //ImageIcon icon = IconManager.getIcon("AppIcon", IconManager.IconSize.Std16);

    try {
        ResourceBundle.getBundle("resources", Locale.getDefault()); //$NON-NLS-1$

    } catch (MissingResourceException ex) {
        Locale.setDefault(Locale.ENGLISH);
        UIRegistry.setResourceLocale(Locale.ENGLISH);
    }

    try {
        if (!System.getProperty("os.name").equals("Mac OS X")) {
            UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
            PlasticLookAndFeel.setPlasticTheme(new DesertBlue());
        }
    } catch (Exception e) {
        //whatever
    }
    AppPreferences localPrefs = AppPreferences.getLocalPrefs();
    localPrefs.setDirPath(UIRegistry.getAppDataDir());

    boolean doIt = false;
    if (doIt)

    {
        Charset utf8charset = Charset.forName("UTF-8");
        Charset iso88591charset = Charset.forName("ISO-8859-1");

        ByteBuffer inputBuffer = ByteBuffer.wrap(new byte[] { (byte) 0xC3, (byte) 0xA2 });

        // decode UTF-8
        CharBuffer data = utf8charset.decode(inputBuffer);

        // encode ISO-8559-1
        ByteBuffer outputBuffer = iso88591charset.encode(data);
        byte[] outputData = outputBuffer.array();
        System.out.println(new String(outputData));
        return;
    }

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            try {
                UIHelper.OSTYPE osType = UIHelper.getOSType();
                if (osType == UIHelper.OSTYPE.Windows) {
                    UIManager.setLookAndFeel(new PlasticLookAndFeel());
                    PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue());

                } else if (osType == UIHelper.OSTYPE.Linux) {
                    UIManager.setLookAndFeel(new PlasticLookAndFeel());
                }
            } catch (Exception e) {
                log.error("Can't change L&F: ", e); //$NON-NLS-1$
            }

            JFrame frame = new JFrame(getResourceString("StrLocalizerApp.AppTitle"));
            frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
            final StrLocalizerAppForiOS sl = new StrLocalizerAppForiOS();
            sl.addMenuBar(frame);
            frame.setContentPane(sl);
            frame.setSize(768, 1024);

            //Dimension size = frame.getPreferredSize();
            //size.height = 500;
            //frame.setSize(size);
            frame.addWindowListener(sl);
            IconManager.setApplicationClass(Specify.class);
            frame.setIconImage(IconManager.getImage(IconManager.makeIconName("SpecifyWhite32")).getImage());

            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    sl.startUp();
                }
            });
        }
    });
}

From source file:edu.ku.brc.specify.tools.schemalocale.SchemaLocalizerFrame.java

License:Open Source License

/**
 * @param args//w w w  .j a v  a 2 s  .  c om
 */
public static void main(String[] args) {
    log.debug("********* Current [" + (new File(".").getAbsolutePath()) + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    // This is for Windows and Exe4J, turn the args into System Properties
    for (String s : args) {
        String[] pairs = s.split("="); //$NON-NLS-1$
        if (pairs.length == 2) {
            log.debug("[" + pairs[0] + "][" + pairs[1] + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            if (pairs[0].startsWith("-D")) //$NON-NLS-1$
            {
                System.setProperty(pairs[0].substring(2, pairs[0].length()), pairs[1]);
            }
        }
    }

    // Now check the System Properties
    String appDir = System.getProperty("appdir"); //$NON-NLS-1$
    if (StringUtils.isNotEmpty(appDir)) {
        UIRegistry.setDefaultWorkingPath(appDir);
    }

    String appdatadir = System.getProperty("appdatadir"); //$NON-NLS-1$
    if (StringUtils.isNotEmpty(appdatadir)) {
        UIRegistry.setBaseAppDataDir(appdatadir);
    }

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {

            //              Set App Name, MUST be done very first thing!
            UIRegistry.setAppName("Specify"); //$NON-NLS-1$

            // Then set this
            IconManager.setApplicationClass(Specify.class);
            IconManager.loadIcons(XMLHelper.getConfigDir("icons_datamodel.xml")); //$NON-NLS-1$
            IconManager.loadIcons(XMLHelper.getConfigDir("icons_plugins.xml")); //$NON-NLS-1$
            IconManager.loadIcons(XMLHelper.getConfigDir("icons_disciplines.xml")); //$NON-NLS-1$

            try {
                UIHelper.OSTYPE osType = UIHelper.getOSType();
                if (osType == UIHelper.OSTYPE.Windows) {
                    //UIManager.setLookAndFeel(new WindowsLookAndFeel());
                    UIManager.setLookAndFeel(new PlasticLookAndFeel());
                    PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue());

                } else if (osType == UIHelper.OSTYPE.Linux) {
                    //UIManager.setLookAndFeel(new GTKLookAndFeel());
                    PlasticLookAndFeel.setPlasticTheme(new SkyKrupp());
                    //PlasticLookAndFeel.setPlasticTheme(new DesertBlue());
                    //PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue());
                    //PlasticLookAndFeel.setPlasticTheme(new ExperienceRoyale());
                    UIManager.setLookAndFeel(new PlasticLookAndFeel());
                }
            } catch (Exception e) {
                edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SchemaLocalizerFrame.class, e);
                e.printStackTrace();
            }

            AppPreferences localPrefs = AppPreferences.getLocalPrefs();
            localPrefs.setDirPath(UIRegistry.getAppDataDir());

            //Specify.adjustLocaleFromPrefs();

            System.setProperty(AppContextMgr.factoryName, "edu.ku.brc.specify.config.SpecifyAppContextMgr"); // Needed by AppContextMgr //$NON-NLS-1$
            System.setProperty(SchemaI18NService.factoryName,
                    "edu.ku.brc.specify.config.SpecifySchemaI18NService"); // Needed for Localization and Schema //$NON-NLS-1$
            System.setProperty(UIFieldFormatterMgr.factoryName,
                    "edu.ku.brc.specify.ui.SpecifyUIFieldFormatterMgr"); // Needed for CatalogNumbering //$NON-NLS-1$
            System.setProperty(WebLinkMgr.factoryName, "edu.ku.brc.specify.config.SpecifyWebLinkMgr"); // Needed for WebLnkButton //$NON-NLS-1$
            System.setProperty(DataObjFieldFormatMgr.factoryName,
                    "edu.ku.brc.specify.config.SpecifyDataObjFieldFormatMgr"); // Needed for WebLnkButton //$NON-NLS-1$

            SpecifyDataObjFieldFormatMgr.setDoingLocal(true);
            SpecifyUIFieldFormatterMgr.setDoingLocal(true);
            SpecifyWebLinkMgr.setDoingLocal(true);

            Object[] options = { getResourceString("SchemaLocalizerFrame.FULL_SCHEMA"), //$NON-NLS-1$ 
                    getResourceString("SchemaLocalizerFrame.WB_SCHEMA") }; //$NON-NLS-1$
            int retVal = JOptionPane.showOptionDialog(null,
                    getResourceString("SchemaLocalizerFrame.WHICH_SCHEMA"), //$NON-NLS-1$
                    getResourceString("SchemaLocalizerFrame.CHOOSE_SCHEMA"), JOptionPane.YES_NO_CANCEL_OPTION, //$NON-NLS-1$
                    JOptionPane.QUESTION_MESSAGE, null, options, options[0]);

            SchemaLocalizerFrame sla;
            if (retVal == JOptionPane.NO_OPTION) {
                DBTableIdMgr schema = new DBTableIdMgr(false);
                schema.initialize(new File(XMLHelper.getConfigDirPath("specify_workbench_datamodel.xml"))); //$NON-NLS-1$
                sla = new SchemaLocalizerFrame(SpLocaleContainer.WORKBENCH_SCHEMA, schema);

            } else {
                sla = new SchemaLocalizerFrame(SpLocaleContainer.CORE_SCHEMA, DBTableIdMgr.getInstance());
            }

            AppContextMgr.getInstance().setHasContext(true);

            sla.createDisplay();
            sla.pack();
            Dimension size = sla.getSize();
            size.width += 250;
            sla.setSize(size);
            UIHelper.centerAndShow(sla);

            final SchemaLocalizerFrame slaf = sla;
            slaf.setDefaultCloseOperation(EXIT_ON_CLOSE);
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    slaf.chooseCurrentLocale();
                }
            });
        }
    });

}

From source file:edu.ku.brc.specify.tools.StrLocalizerApp.java

License:Open Source License

/**
  * @param args/*  w  w  w. j a  v a2  s.  c  om*/
  */
public static void main(String[] args) {
    setAppName("Specify"); //$NON-NLS-1$
    System.setProperty(AppPreferences.factoryName, "edu.ku.brc.specify.config.AppPrefsDBIOIImpl"); // Needed by AppReferences //$NON-NLS-1$

    for (String s : args) {
        String[] pairs = s.split("="); //$NON-NLS-1$
        if (pairs.length == 2) {
            if (pairs[0].startsWith("-D")) //$NON-NLS-1$
            {
                //System.err.println("["+pairs[0].substring(2, pairs[0].length())+"]["+pairs[1]+"]");
                System.setProperty(pairs[0].substring(2, pairs[0].length()), pairs[1]);
            }
        } else {
            String symbol = pairs[0].substring(2, pairs[0].length());
            //System.err.println("["+symbol+"]");
            System.setProperty(symbol, symbol);
        }
    }

    // Now check the System Properties
    String appDir = System.getProperty("appdir");
    if (StringUtils.isNotEmpty(appDir)) {
        UIRegistry.setDefaultWorkingPath(appDir);
    }

    String appdatadir = System.getProperty("appdatadir");
    if (StringUtils.isNotEmpty(appdatadir)) {
        UIRegistry.setBaseAppDataDir(appdatadir);
    }

    // Then set this
    IconManager.setApplicationClass(Specify.class);
    IconManager.loadIcons(XMLHelper.getConfigDir("icons.xml")); //$NON-NLS-1$
    //ImageIcon icon = IconManager.getIcon("AppIcon", IconManager.IconSize.Std16);

    try {
        ResourceBundle.getBundle("resources", Locale.getDefault()); //$NON-NLS-1$

    } catch (MissingResourceException ex) {
        Locale.setDefault(Locale.ENGLISH);
        UIRegistry.setResourceLocale(Locale.ENGLISH);
    }

    try {
        if (!System.getProperty("os.name").equals("Mac OS X")) {
            UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
            PlasticLookAndFeel.setPlasticTheme(new DesertBlue());
        }
    } catch (Exception e) {
        //whatever
    }
    AppPreferences localPrefs = AppPreferences.getLocalPrefs();
    localPrefs.setDirPath(UIRegistry.getAppDataDir());

    boolean doIt = false;
    if (doIt)

    {
        Charset utf8charset = Charset.forName("UTF-8");
        Charset iso88591charset = Charset.forName("ISO-8859-1");

        ByteBuffer inputBuffer = ByteBuffer.wrap(new byte[] { (byte) 0xC3, (byte) 0xA2 });

        // decode UTF-8
        CharBuffer data = utf8charset.decode(inputBuffer);

        // encode ISO-8559-1
        ByteBuffer outputBuffer = iso88591charset.encode(data);
        byte[] outputData = outputBuffer.array();
        System.out.println(new String(outputData));
        return;
    }

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            try {
                UIHelper.OSTYPE osType = UIHelper.getOSType();
                if (osType == UIHelper.OSTYPE.Windows) {
                    UIManager.setLookAndFeel(new PlasticLookAndFeel());
                    PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue());

                } else if (osType == UIHelper.OSTYPE.Linux) {
                    UIManager.setLookAndFeel(new PlasticLookAndFeel());
                }
            } catch (Exception e) {
                log.error("Can't change L&F: ", e); //$NON-NLS-1$
            }

            JFrame frame = new JFrame(getResourceString("StrLocalizerApp.AppTitle"));
            frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
            final StrLocalizerApp sl = new StrLocalizerApp();
            sl.addMenuBar(frame);
            frame.setContentPane(sl);
            frame.setSize(768, 1024);

            //Dimension size = frame.getPreferredSize();
            //size.height = 500;
            //frame.setSize(size);
            frame.addWindowListener(sl);
            IconManager.setApplicationClass(Specify.class);
            frame.setIconImage(IconManager.getImage(IconManager.makeIconName("SpecifyWhite32")).getImage());
            UIHelper.centerAndShow(frame);

            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    sl.startUp();
                }
            });
        }
    });
}

From source file:edu.ku.brc.specify.toycode.BasicHibernateMain.java

License:Open Source License

/**
 *
 *
 * @param args/*from w  ww.  ja v  a2s  . c om*/
 */
public static void main(String[] args) throws UnsupportedLookAndFeelException {
    if (!System.getProperty("os.name").equals("Mac OS X")) {
        UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
        PlasticLookAndFeel.setPlasticTheme(new DesertBlue());
    }

    // Name factories
    System.setProperty(AppContextMgr.factoryName, "edu.ku.brc.specify.config.SpecifyAppContextMgr"); // Needed by AppContextMgr
    System.setProperty(AppPreferences.factoryName, "edu.ku.brc.specify.config.AppPrefsDBIOIImpl"); // Needed by AppReferences
    System.setProperty("edu.ku.brc.ui.ViewBasedDialogFactoryIFace", "edu.ku.brc.specify.ui.DBObjDialogFactory"); // Needed By UIRegistry
    System.setProperty("edu.ku.brc.ui.forms.DraggableRecordIdentifierFactory",
            "edu.ku.brc.specify.ui.SpecifyDraggableRecordIdentiferFactory"); // Needed By the Form System
    System.setProperty("edu.ku.brc.dbsupport.AuditInterceptor",
            "edu.ku.brc.specify.dbsupport.AuditInterceptor"); // Needed By the Form System for updating Lucene and loggin transactions
    System.setProperty("edu.ku.brc.dbsupport.DataProvider",
            "edu.ku.brc.specify.dbsupport.HibernateDataProvider"); // Needed By the Form System and any Data Get/Set
    System.setProperty("edu.ku.brc.ui.db.PickListDBAdapterFactory",
            "edu.ku.brc.specify.ui.db.PickListDBAdapterFactory"); // Needed By the Auto Cosmplete UI

    IconManager.setApplicationClass(Specify.class);
    IconManager.loadIcons(XMLHelper.getConfigDir("icons_datamodel.xml"));
    IconManager.loadIcons(XMLHelper.getConfigDir("icons_plugins.xml"));

    UIRegistry.getInstance(); // initializes it first thing
    UIRegistry.setAppName("Specify");

    // Load Local Prefs
    AppPreferences localPrefs = AppPreferences.getLocalPrefs();
    localPrefs.setDirPath(UIRegistry.getAppDataDir());
    localPrefs.load();

    Pair<String, String> usernamePassword = UserAndMasterPasswordMgr.getInstance().getUserNamePasswordForDB();
    BasicHibernateMain tester = new BasicHibernateMain();
    UIHelper.doLogin(usernamePassword.first, usernamePassword.second, true, true, false, tester, null,
            "SpecifyWhite32", "login");
}

From source file:edu.ku.brc.specify.toycode.mexconabio.FileMakerToMySQL.java

License:Open Source License

/**
 * @param args//  ww  w .  ja va2s.co  m
 */
public static void main(String[] args) {
    if (!System.getProperty("os.name").equals("Mac OS X")) {
        try {
            UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
        } catch (UnsupportedLookAndFeelException e) {
            e.printStackTrace();
        }
        PlasticLookAndFeel.setPlasticTheme(new DesertBlue());
    }

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            //FileDialog dlg = new FileDialog((Frame)null, "Choose a FileMaker XML File");
            //dlg.setVisible(true);
            String fileName = "xxx.xml";//dlg.getFile();

            if (StringUtils.isNotEmpty(fileName)) {
                //String path = dlg.getDirectory() + File.separator + fileName;

                //String name = "AgentsBryo_Vasc";
                String tableName = "Conabio";
                //String name = "TaxonomicBryo_Vasc";
                boolean addKey = true;

                FileMakerToMySQL fm2mysql = new FileMakerToMySQL(tableName, null, addKey);
                //fm2mysql.cleanFile("/Users/rods/Documents/"+name+".xml");
                fm2mysql.process(true);
                fm2mysql.process(false);

                fm2mysql.shutdown();

            } else {
                System.exit(0);
            }

        }
    });

}

From source file:edu.ku.brc.specify.toycode.mexconabio.GBIFFullTextSearchFrame.java

License:Open Source License

/**
 * @param args/*from w  w w. jav a  2s . c  om*/
 */
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {

            //              Set App Name, MUST be done very first thing!
            UIRegistry.setAppName("Specify"); //$NON-NLS-1$

            // Then set this
            IconManager.setApplicationClass(Specify.class);
            IconManager.loadIcons(XMLHelper.getConfigDir("icons_datamodel.xml")); //$NON-NLS-1$
            IconManager.loadIcons(XMLHelper.getConfigDir("icons_plugins.xml")); //$NON-NLS-1$
            IconManager.loadIcons(XMLHelper.getConfigDir("icons_disciplines.xml")); //$NON-NLS-1$

            try {
                UIHelper.OSTYPE osType = UIHelper.getOSType();
                if (osType == UIHelper.OSTYPE.Windows) {
                    //UIManager.setLookAndFeel(new WindowsLookAndFeel());
                    UIManager.setLookAndFeel(new PlasticLookAndFeel());
                    PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue());

                } else if (osType == UIHelper.OSTYPE.Linux) {
                    //UIManager.setLookAndFeel(new GTKLookAndFeel());
                    PlasticLookAndFeel.setPlasticTheme(new SkyKrupp());
                    //PlasticLookAndFeel.setPlasticTheme(new DesertBlue());
                    //PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue());
                    //PlasticLookAndFeel.setPlasticTheme(new ExperienceRoyale());
                    UIManager.setLookAndFeel(new PlasticLookAndFeel());
                }
            } catch (Exception e) {
                edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SchemaLocalizerFrame.class, e);
                e.printStackTrace();
            }

            System.setProperty(AppContextMgr.factoryName, "edu.ku.brc.specify.config.SpecifyAppContextMgr"); // Needed by AppContextMgr //$NON-NLS-1$
            System.setProperty(SchemaI18NService.factoryName,
                    "edu.ku.brc.specify.config.SpecifySchemaI18NService"); // Needed for Localization and Schema //$NON-NLS-1$
            System.setProperty(UIFieldFormatterMgr.factoryName,
                    "edu.ku.brc.specify.ui.SpecifyUIFieldFormatterMgr"); // Needed for CatalogNumbering //$NON-NLS-1$
            System.setProperty(WebLinkMgr.factoryName, "edu.ku.brc.specify.config.SpecifyWebLinkMgr"); // Needed for WebLnkButton //$NON-NLS-1$
            System.setProperty(DataObjFieldFormatMgr.factoryName,
                    "edu.ku.brc.specify.config.SpecifyDataObjFieldFormatMgr"); // Needed for WebLnkButton //$NON-NLS-1$

            SpecifyDataObjFieldFormatMgr.setDoingLocal(true);
            SpecifyUIFieldFormatterMgr.setDoingLocal(true);
            SpecifyWebLinkMgr.setDoingLocal(true);

            GBIFFullTextSearchFrame dlg = new GBIFFullTextSearchFrame();
            dlg.createDBConnection("localhost", "3306", "gbif", "root", "root");
            dlg.setCancelLabel("Close");
            dlg.setSize(900, 700);
            UIHelper.centerAndShow(dlg);
            dlg.cleanup();
            System.exit(0);

        }
    });

}

From source file:edu.ku.brc.specify.toycode.UpdatesApp.java

License:Open Source License

/**
 * @param args//w w w  . ja v a2 s.  c o  m
 */
public static void main(String[] args) {
    if (args.length == 9) {
        for (int i = 0; i < args.length; i++) {
            System.out.println(i + "=" + args[i]);
        }
        doingCmdLine = true;
        UpdatesApp updateApp = new UpdatesApp();
        try {
            updateApp.merge(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
        } catch (java.lang.NullPointerException ex) {
            System.err.println("****The merge process failed:  check for errors above.");
        }

    } else {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {

                try {
                    UIHelper.OSTYPE osType = UIHelper.getOSType();
                    if (osType == UIHelper.OSTYPE.Windows) {
                        //UIManager.setLookAndFeel(new WindowsLookAndFeel());
                        UIManager.setLookAndFeel(new PlasticLookAndFeel());
                        PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue());

                    } else if (osType == UIHelper.OSTYPE.Linux) {
                        //UIManager.setLookAndFeel(new GTKLookAndFeel());
                        UIManager.setLookAndFeel(new PlasticLookAndFeel());
                        //PlasticLookAndFeel.setPlasticTheme(new SkyKrupp());
                        //PlasticLookAndFeel.setPlasticTheme(new DesertBlue());
                        //PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue());
                        //PlasticLookAndFeel.setPlasticTheme(new DesertGreen());

                    }
                } catch (Exception e) {
                    edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                    edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(UpdatesApp.class, e);
                    System.err.println("Can't change L&F: " + e); //$NON-NLS-1$
                }

                UpdatesApp panel = new UpdatesApp();
                JFrame frame = new JFrame();
                frame.setTitle("Install4J XML Updater");
                frame.setContentPane(panel);

                JMenuBar menuBar = panel.createMenus();
                if (menuBar != null) {
                    //top.add(menuBar, BorderLayout.NORTH);
                    frame.setJMenuBar(menuBar);
                }

                frame.pack();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
            }
        });
    }
}