Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed some small bugs found by testing on other platforms:

- the L&F was not always correctly set due to the order
  in which bundles are started. This could lead to half-
  applied L&F;
- the application icon on OSX wasn't set correctly;
- the run batch file for Windows didn't work correctly
  with latest JRE.
  • Loading branch information...
commit 74f96f185c16f6cf04d6f5e50f85322196941cb5 1 parent aa658a0
@jawi authored
View
5 client/src/main/java/nl/lxtreme/ols/client/Activator.java
@@ -259,6 +259,11 @@ public void init( final BundleContext aContext, final DependencyManager aManager
.setCallbacks( "addTool", "removeTool" ) //
.setRequired( false ) //
) //
+ .add( createServiceDependency() //
+ .setService( Exporter.class ) //
+ .setCallbacks( "addExporter", "removeExporter" ) //
+ .setRequired( false ) //
+ ) //
);
}
}
View
149 client/src/main/java/nl/lxtreme/ols/client/ClientController.java
@@ -22,6 +22,7 @@
import java.awt.*;
+import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.util.List;
@@ -73,6 +74,40 @@ protected void run( final List<Void> aArgs )
}
/**
+ * Provides an {@link Action} for closing a {@link JOptionPane}.
+ */
+ static final class CloseOptionPaneAction extends AbstractAction
+ {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ */
+ @Override
+ public void actionPerformed( final ActionEvent aEvent )
+ {
+ final JOptionPane optionPane = ( JOptionPane )aEvent.getSource();
+ optionPane.setValue( Integer.valueOf( JOptionPane.CLOSED_OPTION ) );
+ }
+ }
+
+ /**
+ * Provides a hack to ensure the system class loader is used at all times when
+ * loading UI classes/resources/...
+ */
+ static class CLValue implements UIDefaults.ActiveValue
+ {
+ /**
+ * @see javax.swing.UIDefaults.ActiveValue#createValue(javax.swing.UIDefaults)
+ */
+ public @Override
+ ClassLoader createValue( final UIDefaults aDefaults )
+ {
+ return Activator.class.getClassLoader();
+ }
+ }
+
+ /**
* Provides a default tool context implementation.
*/
static final class DefaultToolContext implements ToolContext
@@ -234,15 +269,6 @@ public ClientController( final BundleContext aBundleContext )
this.progressAccumulatingRunnable = new ProgressUpdatingRunnable();
this.repaintAccumulatingRunnable = new AccumulatingRepaintingRunnable();
-
- SwingComponentUtils.invokeOnEDT( new Runnable()
- {
- @Override
- public void run()
- {
- ClientController.this.mainFrame = new MainFrame( ClientController.this );
- }
- } );
}
// METHODS
@@ -1351,6 +1377,10 @@ public void showPreferencesDialog( final Window aParent )
*/
public void start()
{
+ final HostProperties hostProperties = getHostProperties();
+
+ initOSSpecifics( hostProperties.getShortName() );
+
// Make sure we're running on the EDT to ensure the Swing threading model is
// correctly defined...
SwingUtilities.invokeLater( new Runnable()
@@ -1361,14 +1391,12 @@ public void run()
// Cause exceptions to be shown in a more user-friendly way...
JErrorDialog.installSwingExceptionHandler();
+ ClientController.this.mainFrame = new MainFrame( ClientController.this );
+
final MainFrame mainFrame = getMainFrame();
- HostProperties hostProperties = getHostProperties();
- if ( hostProperties != null )
- {
- mainFrame.setTitle( hostProperties.getFullName() );
- mainFrame.setStatus( "{0} v{1} ready ...", hostProperties.getShortName(), hostProperties.getVersion() );
- }
+ mainFrame.setTitle( hostProperties.getFullName() );
+ mainFrame.setStatus( "{0} v{1} ready ...", hostProperties.getShortName(), hostProperties.getVersion() );
LOG.info( "Client started ..." );
@@ -1881,6 +1909,68 @@ private Exporter getExporter( final String aName ) throws IllegalArgumentExcepti
}
/**
+ * Initializes the OS-specific stuff.
+ *
+ * @param aApplicationName
+ * the name of the application (when this needs to be passed to the
+ * guest OS);
+ * @param aApplicationCallback
+ * the application callback used to report application events on some
+ * platforms (Mac OS), may be <code>null</code>.
+ */
+ private void initOSSpecifics( final String aApplicationName )
+ {
+ final HostInfo hostInfo = HostUtils.getHostInfo();
+ if ( hostInfo.isMacOS() )
+ {
+ // Moves the main menu bar to the screen menu bar location...
+ System.setProperty( "apple.laf.useScreenMenuBar", "true" );
+ System.setProperty( "apple.awt.graphics.EnableQ2DX", "true" );
+ System.setProperty( "com.apple.mrj.application.apple.menu.about.name", aApplicationName );
+ System.setProperty( "com.apple.mrj.application.growbox.intrudes", "false" );
+ System.setProperty( "com.apple.mrj.application.live-resize", "false" );
+ System.setProperty( "com.apple.macos.smallTabs", "true" );
+ System.setProperty( "apple.eawt.quitStrategy", "CLOSE_ALL_WINDOWS" );
+
+ // Install an additional accelerator (Cmd+W) for closing option panes...
+ ActionMap map = ( ActionMap )UIManager.get( "OptionPane.actionMap" );
+ if ( map == null )
+ {
+ map = new ActionMap();
+ UIManager.put( "OptionPane.actionMap", map );
+ }
+ map.put( "close", new CloseOptionPaneAction() );
+
+ UIManager.put( "OptionPane.windowBindings", //
+ new Object[] { SwingComponentUtils.createMenuKeyMask( KeyEvent.VK_W ), "close", "ESCAPE", "close" } );
+ }
+ else if ( hostInfo.isUnix() )
+ {
+ try
+ {
+ UIManager.put( "Application.useSystemFontSettings", Boolean.FALSE );
+ setLookAndFeel( "com.jgoodies.looks.plastic.Plastic3DLookAndFeel" );
+ }
+ catch ( Exception exception )
+ {
+ Logger.getAnonymousLogger().log( Level.WARNING, "Failed to set look and feel!", exception );
+ }
+ }
+ else if ( hostInfo.isWindows() )
+ {
+ try
+ {
+ UIManager.put( "Application.useSystemFontSettings", Boolean.TRUE );
+ setLookAndFeel( "com.jgoodies.looks.plastic.PlasticXPLookAndFeel" );
+ }
+ catch ( Exception exception )
+ {
+ Logger.getAnonymousLogger().log( Level.WARNING, "Failed to set look and feel!", exception );
+ }
+ }
+ }
+
+ /**
* Dispatches a request to repaint the entire main frame.
*/
private void repaintMainFrame()
@@ -1944,4 +2034,33 @@ private void setCursorData( final Long[] aCursorData, final boolean aCursorsEnab
this.dataContainer.setCursorPosition( i, aCursorData[i] );
}
}
+
+ /**
+ * @param aLookAndFeelClass
+ */
+ private void setLookAndFeel( final String aLookAndFeelClassName )
+ {
+ final UIDefaults defaults = UIManager.getDefaults();
+ // to make sure we always use system class loader
+ defaults.put( "ClassLoader", new CLValue() );
+
+ final ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader( Activator.class.getClassLoader() );
+ UIManager.setLookAndFeel( aLookAndFeelClassName );
+ }
+ catch ( Exception exception )
+ {
+ // Make sure to handle IO-interrupted exceptions properly!
+ if ( !HostUtils.handleInterruptedException( exception ) )
+ {
+ Logger.getAnonymousLogger().log( Level.WARNING, "Failed to set look and feel!", exception );
+ }
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader( oldCL );
+ }
+ }
}
View
2  ols.distribution/src/main/assembly/ext/app-bundle.xml
@@ -42,7 +42,7 @@
</target>
<target name="package" depends="init" description="Creates the OSX app bundle" if="isMac">
- <jarbundler dir="${project.targetapp}" bundleid="nl.lxtreme.ols" name="${ols.project.name}" shortname="${ols.project.name}" mainclass="nl.lxtreme.ols.runner.Runner" version="${project.version}" build="1" jvmversion="1.6+" arguments="-Dnl.lxtreme.ols.bundle.dir=$JAVAROOT/plugins" workingdirectory="$APP_PACKAGE/Contents/Resources/Java" vmoptions="-Xmx1024m" icon="${basedir}/../resources/LogicSniffer.icns">
+ <jarbundler dir="${project.targetapp}" bundleid="nl.lxtreme.ols" name="${ols.project.name}" shortname="${ols.project.name}" mainclass="nl.lxtreme.ols.runner.Runner" version="${project.version}" build="1" jvmversion="1.6+" arguments="-Dnl.lxtreme.ols.bundle.dir=$JAVAROOT/plugins" workingdirectory="$APP_PACKAGE/Contents/Resources/Java" vmoptions="-Xmx1024m" icon="${basedir}/../../resources/LogicSniffer.icns">
<!-- put all bin/*.jar files on the class path -->
<jarfileset dir="${project.targetapp-tmp}">
<include name="bin/*.jar" />
View
2  ols.distribution/src/main/resources/run.bat
@@ -8,7 +8,7 @@ rem determine the location this script is run in...
set BASEDIR=%~dp0
rem all paths are used relatively from the base dir...
set PLUGINDIR=%BASEDIR%\plugins
-set CLASSPATH=%BASEDIR%\bin\*
+set CLASSPATH=.;%BASEDIR%\bin\*
set MEMSETTINGS=-Xmx1024m
rem For now, use the "console enabled" java for Windows...
View
131 util/src/main/java/nl/lxtreme/ols/util/internal/Activator.java
@@ -21,11 +21,8 @@
package nl.lxtreme.ols.util.internal;
-import java.awt.event.*;
import java.util.logging.*;
-import javax.swing.*;
-
import nl.lxtreme.ols.util.*;
import nl.lxtreme.ols.util.swing.*;
import nl.lxtreme.ols.util.swing.component.*;
@@ -39,42 +36,6 @@
*/
public class Activator extends DependencyActivatorBase
{
- // INNER TYPES
-
- /**
- * Provides an {@link Action} for closing a {@link JOptionPane}.
- */
- static final class CloseOptionPaneAction extends AbstractAction
- {
- private static final long serialVersionUID = 1L;
-
- /**
- * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
- */
- @Override
- public void actionPerformed( final ActionEvent aEvent )
- {
- final JOptionPane optionPane = ( JOptionPane )aEvent.getSource();
- optionPane.setValue( Integer.valueOf( JOptionPane.CLOSED_OPTION ) );
- }
- }
-
- /**
- * Provides a hack to ensure the system class loader is used at all times when
- * loading UI classes/resources/...
- */
- static class CLValue implements UIDefaults.ActiveValue
- {
- /**
- * @see javax.swing.UIDefaults.ActiveValue#createValue(javax.swing.UIDefaults)
- */
- public @Override
- ClassLoader createValue( final UIDefaults aDefaults )
- {
- return Activator.class.getClassLoader();
- }
- }
-
// METHODS
/**
@@ -94,8 +55,6 @@ public void init( final BundleContext aContext, final DependencyManager aManager
{
final HostProperties hostProperties = new HostResourceProperties( aContext );
- initOSSpecifics( hostProperties.getShortName() );
-
logEnvironment( hostProperties );
aManager.add( createComponent() //
@@ -124,68 +83,6 @@ public void init( final BundleContext aContext, final DependencyManager aManager
}
/**
- * Initializes the OS-specific stuff.
- *
- * @param aApplicationName
- * the name of the application (when this needs to be passed to the
- * guest OS);
- * @param aApplicationCallback
- * the application callback used to report application events on some
- * platforms (Mac OS), may be <code>null</code>.
- */
- private void initOSSpecifics( final String aApplicationName )
- {
- final HostInfo hostInfo = HostUtils.getHostInfo();
- if ( hostInfo.isMacOS() )
- {
- // Moves the main menu bar to the screen menu bar location...
- System.setProperty( "apple.laf.useScreenMenuBar", "true" );
- System.setProperty( "apple.awt.graphics.EnableQ2DX", "true" );
- System.setProperty( "com.apple.mrj.application.apple.menu.about.name", aApplicationName );
- System.setProperty( "com.apple.mrj.application.growbox.intrudes", "false" );
- System.setProperty( "com.apple.mrj.application.live-resize", "false" );
- System.setProperty( "com.apple.macos.smallTabs", "true" );
- System.setProperty( "apple.eawt.quitStrategy", "CLOSE_ALL_WINDOWS" );
-
- // Install an additional accelerator (Cmd+W) for closing option panes...
- ActionMap map = ( ActionMap )UIManager.get( "OptionPane.actionMap" );
- if ( map == null )
- {
- map = new ActionMap();
- UIManager.put( "OptionPane.actionMap", map );
- }
- map.put( "close", new CloseOptionPaneAction() );
-
- UIManager.put( "OptionPane.windowBindings", //
- new Object[] { SwingComponentUtils.createMenuKeyMask( KeyEvent.VK_W ), "close", "ESCAPE", "close" } );
- }
- else if ( hostInfo.isUnix() )
- {
- try
- {
- UIManager.put( "Application.useSystemFontSettings", Boolean.FALSE );
- setLookAndFeel( "com.jgoodies.looks.plastic.Plastic3DLookAndFeel" );
- }
- catch ( Exception exception )
- {
- Logger.getAnonymousLogger().log( Level.WARNING, "Failed to set look and feel!", exception );
- }
- }
- else if ( hostInfo.isWindows() )
- {
- try
- {
- UIManager.put( "Application.useSystemFontSettings", Boolean.TRUE );
- setLookAndFeel( "com.jgoodies.looks.plastic.PlasticXPLookAndFeel" );
- }
- catch ( Exception exception )
- {
- Logger.getAnonymousLogger().log( Level.WARNING, "Failed to set look and feel!", exception );
- }
- }
- }
-
- /**
* @param aContext
*/
private void logEnvironment( final HostProperties aProperties )
@@ -203,32 +100,4 @@ private void logEnvironment( final HostProperties aProperties )
Logger.getLogger( getClass().getName() ).info( sb.toString() );
}
- /**
- * @param aLookAndFeelClass
- */
- private void setLookAndFeel( final String aLookAndFeelClassName )
- {
- final UIDefaults defaults = UIManager.getDefaults();
- // to make sure we always use system class loader
- defaults.put( "ClassLoader", new CLValue() );
-
- final ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
- try
- {
- Thread.currentThread().setContextClassLoader( Activator.class.getClassLoader() );
- UIManager.setLookAndFeel( aLookAndFeelClassName );
- }
- catch ( Exception exception )
- {
- // Make sure to handle IO-interrupted exceptions properly!
- if ( !HostUtils.handleInterruptedException( exception ) )
- {
- Logger.getAnonymousLogger().log( Level.WARNING, "Failed to set look and feel!", exception );
- }
- }
- finally
- {
- Thread.currentThread().setContextClassLoader( oldCL );
- }
- }
}
Please sign in to comment.
Something went wrong with that request. Please try again.