Standard label font & fix warnings.
This commit is contained in:
parent
f41cdb8742
commit
6b9e1b8cb8
@ -1,36 +0,0 @@
|
|||||||
package com.lyndir.masterpassword.gui;
|
|
||||||
|
|
||||||
import com.lyndir.lhunath.opal.system.logging.Logger;
|
|
||||||
import com.lyndir.masterpassword.gui.util.Platform;
|
|
||||||
import com.lyndir.masterpassword.gui.util.Res;
|
|
||||||
import com.lyndir.masterpassword.gui.view.MasterPasswordFrame;
|
|
||||||
import com.tulskiy.keymaster.common.Provider;
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author lhunath, 2018-07-28
|
|
||||||
*/
|
|
||||||
public class GUI {
|
|
||||||
|
|
||||||
private static final Logger logger = Logger.get( GUI.class );
|
|
||||||
|
|
||||||
private final MasterPasswordFrame frame = new MasterPasswordFrame();
|
|
||||||
|
|
||||||
public GUI() {
|
|
||||||
Platform.get().installAppForegroundHandler( this::open );
|
|
||||||
Platform.get().installAppReopenHandler( this::open );
|
|
||||||
|
|
||||||
Provider.getCurrentProvider( true ).register( MPGuiConstants.ui_hotkey, hotKey -> open() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void open() {
|
|
||||||
Res.ui( () -> {
|
|
||||||
frame.setAlwaysOnTop( true );
|
|
||||||
frame.setVisible( true );
|
|
||||||
frame.setExtendedState( Frame.NORMAL );
|
|
||||||
frame.setAlwaysOnTop( false );
|
|
||||||
Platform.get().requestForeground();
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
}
|
|
@ -26,11 +26,11 @@ import com.lyndir.masterpassword.model.MPModelConstants;
|
|||||||
* @author lhunath, 2014-08-31
|
* @author lhunath, 2014-08-31
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("CallToSystemGetenv")
|
@SuppressWarnings("CallToSystemGetenv")
|
||||||
public class Config {
|
public class MPConfig {
|
||||||
|
|
||||||
private static final Config instance = new Config();
|
private static final MPConfig instance = new MPConfig();
|
||||||
|
|
||||||
public static Config get() {
|
public static MPConfig get() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
@ -24,8 +24,11 @@ import com.google.common.base.Charsets;
|
|||||||
import com.google.common.io.ByteSource;
|
import com.google.common.io.ByteSource;
|
||||||
import com.lyndir.lhunath.opal.system.logging.Logger;
|
import com.lyndir.lhunath.opal.system.logging.Logger;
|
||||||
import com.lyndir.lhunath.opal.system.util.ObjectUtils;
|
import com.lyndir.lhunath.opal.system.util.ObjectUtils;
|
||||||
import com.lyndir.masterpassword.gui.util.Components;
|
import com.lyndir.masterpassword.gui.util.*;
|
||||||
|
import com.lyndir.masterpassword.gui.view.MasterPasswordFrame;
|
||||||
import com.lyndir.masterpassword.model.MPUser;
|
import com.lyndir.masterpassword.model.MPUser;
|
||||||
|
import com.tulskiy.keymaster.common.Provider;
|
||||||
|
import java.awt.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
@ -48,6 +51,7 @@ public final class MasterPassword {
|
|||||||
private static final MasterPassword instance = new MasterPassword();
|
private static final MasterPassword instance = new MasterPassword();
|
||||||
|
|
||||||
private final Collection<Listener> listeners = new CopyOnWriteArraySet<>();
|
private final Collection<Listener> listeners = new CopyOnWriteArraySet<>();
|
||||||
|
private final MasterPasswordFrame frame = new MasterPasswordFrame();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private MPUser<?> activeUser;
|
private MPUser<?> activeUser;
|
||||||
@ -78,6 +82,16 @@ public final class MasterPassword {
|
|||||||
return MasterPassword.class.getPackage().getImplementationVersion();
|
return MasterPassword.class.getPackage().getImplementationVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void open() {
|
||||||
|
Res.ui( () -> {
|
||||||
|
frame.setAlwaysOnTop( true );
|
||||||
|
frame.setVisible( true );
|
||||||
|
frame.setExtendedState( Frame.NORMAL );
|
||||||
|
Platform.get().requestForeground();
|
||||||
|
frame.setAlwaysOnTop( false );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
public void checkUpdate() {
|
public void checkUpdate() {
|
||||||
try {
|
try {
|
||||||
String implementationVersion = version();
|
String implementationVersion = version();
|
||||||
@ -115,18 +129,22 @@ public final class MasterPassword {
|
|||||||
// Try and set the system look & feel, if available.
|
// Try and set the system look & feel, if available.
|
||||||
try {
|
try {
|
||||||
UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
|
UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
|
||||||
|
Platform.get().installAppForegroundHandler( get()::open );
|
||||||
|
Platform.get().installAppReopenHandler( get()::open );
|
||||||
|
Provider.getCurrentProvider( true ).register( MPGuiConstants.ui_hotkey, hotKey -> get().open() );
|
||||||
}
|
}
|
||||||
catch (final UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException | IllegalAccessException ignored) {
|
catch (final UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException | IllegalAccessException ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a platform-specific GUI and open it.
|
// Create a platform-specific GUI and open it.
|
||||||
new GUI().open();
|
get().open();
|
||||||
|
|
||||||
// Check online to see if this version has been superseded.
|
// Check online to see if this version has been superseded.
|
||||||
if (Config.get().checkForUpdates())
|
if (MPConfig.get().checkForUpdates())
|
||||||
get().checkUpdate();
|
get().checkUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("InterfaceMayBeAnnotatedFunctional")
|
||||||
public interface Listener {
|
public interface Listener {
|
||||||
|
|
||||||
void onUserSelected(@Nullable MPUser<?> user);
|
void onUserSelected(@Nullable MPUser<?> user);
|
||||||
|
@ -306,7 +306,6 @@ public abstract class Components {
|
|||||||
public static JButton button(final Action action) {
|
public static JButton button(final Action action) {
|
||||||
return new JButton( action ) {
|
return new JButton( action ) {
|
||||||
{
|
{
|
||||||
setFont( Res.fonts().controlFont( TEXT_SIZE_CONTROL ) );
|
|
||||||
setAlignmentX( LEFT_ALIGNMENT );
|
setAlignmentX( LEFT_ALIGNMENT );
|
||||||
|
|
||||||
if (getText() == null) {
|
if (getText() == null) {
|
||||||
@ -383,7 +382,7 @@ public abstract class Components {
|
|||||||
public static JLabel heading(@Nullable final String heading, final int horizontalAlignment) {
|
public static JLabel heading(@Nullable final String heading, final int horizontalAlignment) {
|
||||||
return new JLabel( heading, horizontalAlignment ) {
|
return new JLabel( heading, horizontalAlignment ) {
|
||||||
{
|
{
|
||||||
setFont( Res.fonts().controlFont( TEXT_SIZE_HEADING ).deriveFont( Font.BOLD ) );
|
setFont( getFont().deriveFont( Font.BOLD, TEXT_SIZE_HEADING ) );
|
||||||
setAlignmentX( LEFT_ALIGNMENT );
|
setAlignmentX( LEFT_ALIGNMENT );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,7 +417,6 @@ public abstract class Components {
|
|||||||
public static JLabel label(@Nullable final String label, final int horizontalAlignment) {
|
public static JLabel label(@Nullable final String label, final int horizontalAlignment) {
|
||||||
return new JLabel( label, horizontalAlignment ) {
|
return new JLabel( label, horizontalAlignment ) {
|
||||||
{
|
{
|
||||||
//setFont( Res.fonts().controlFont( TEXT_SIZE_CONTROL ) );
|
|
||||||
setAlignmentX( LEFT_ALIGNMENT );
|
setAlignmentX( LEFT_ALIGNMENT );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,7 +430,6 @@ public abstract class Components {
|
|||||||
public static JCheckBox checkBox(final String label) {
|
public static JCheckBox checkBox(final String label) {
|
||||||
return new JCheckBox( label ) {
|
return new JCheckBox( label ) {
|
||||||
{
|
{
|
||||||
setFont( Res.fonts().controlFont( TEXT_SIZE_CONTROL ) );
|
|
||||||
setBackground( null );
|
setBackground( null );
|
||||||
setAlignmentX( LEFT_ALIGNMENT );
|
setAlignmentX( LEFT_ALIGNMENT );
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ import com.google.common.io.Resources;
|
|||||||
import com.google.common.util.concurrent.*;
|
import com.google.common.util.concurrent.*;
|
||||||
import com.lyndir.lhunath.opal.system.logging.Logger;
|
import com.lyndir.lhunath.opal.system.logging.Logger;
|
||||||
import com.lyndir.masterpassword.MPIdenticon;
|
import com.lyndir.masterpassword.MPIdenticon;
|
||||||
import com.lyndir.masterpassword.gui.SwingExecutorService;
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.ref.SoftReference;
|
import java.lang.ref.SoftReference;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.lyndir.masterpassword.gui;
|
package com.lyndir.masterpassword.gui.util;
|
||||||
|
|
||||||
import static com.lyndir.lhunath.opal.system.util.ObjectUtils.*;
|
import static com.lyndir.lhunath.opal.system.util.ObjectUtils.*;
|
||||||
|
|
||||||
@ -29,9 +29,9 @@ public class SwingExecutorService extends AbstractExecutorService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
|
synchronized (pendingCommands) {
|
||||||
shutdown = true;
|
shutdown = true;
|
||||||
|
|
||||||
synchronized (pendingCommands) {
|
|
||||||
if (pendingCommands.isEmpty())
|
if (pendingCommands.isEmpty())
|
||||||
terminated.add( true );
|
terminated.add( true );
|
||||||
}
|
}
|
||||||
@ -49,8 +49,10 @@ public class SwingExecutorService extends AbstractExecutorService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isShutdown() {
|
public boolean isShutdown() {
|
||||||
|
synchronized (pendingCommands) {
|
||||||
return shutdown;
|
return shutdown;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTerminated() {
|
public boolean isTerminated() {
|
||||||
@ -65,10 +67,10 @@ public class SwingExecutorService extends AbstractExecutorService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(@NotNull final Runnable command) {
|
public void execute(@NotNull final Runnable command) {
|
||||||
|
synchronized (pendingCommands) {
|
||||||
if (shutdown)
|
if (shutdown)
|
||||||
throw new RejectedExecutionException( "Executor is shut down." );
|
throw new RejectedExecutionException( "Executor is shut down." );
|
||||||
|
|
||||||
synchronized (pendingCommands) {
|
|
||||||
pendingCommands.add( command );
|
pendingCommands.add( command );
|
||||||
}
|
}
|
||||||
|
|
@ -19,25 +19,24 @@ public class MasterPasswordFrame extends JFrame {
|
|||||||
|
|
||||||
private static final Logger logger = Logger.get( MasterPasswordFrame.class );
|
private static final Logger logger = Logger.get( MasterPasswordFrame.class );
|
||||||
|
|
||||||
@SuppressWarnings("FieldCanBeLocal")
|
private final UserContentPanel userContent;
|
||||||
private final Components.GradientPanel root = Components.borderPanel( Res.colors().frameBg(), BoxLayout.PAGE_AXIS );
|
|
||||||
private final UserContentPanel userContent = new UserContentPanel();
|
|
||||||
|
|
||||||
@SuppressWarnings("MagicNumber")
|
@SuppressWarnings("MagicNumber")
|
||||||
public MasterPasswordFrame() {
|
public MasterPasswordFrame() {
|
||||||
super( "Master Password" );
|
super( "Master Password" );
|
||||||
|
|
||||||
setContentPane( root );
|
JPanel root, userPanel;
|
||||||
|
setContentPane( root = Components.borderPanel( Res.colors().frameBg(), BoxLayout.PAGE_AXIS ) );
|
||||||
|
|
||||||
root.add( new FilesPanel() );
|
root.add( new FilesPanel() );
|
||||||
root.add( Components.strut() );
|
root.add( Components.strut() );
|
||||||
|
root.add( userPanel = Components.panel( new BorderLayout( 0, 0 ) ) );
|
||||||
|
|
||||||
JPanel userPanel = Components.panel( new BorderLayout( 0, 0 ) );
|
|
||||||
userPanel.add( userContent.getUserToolbar(), BorderLayout.LINE_START );
|
|
||||||
userPanel.add( userContent.getSiteToolbar(), BorderLayout.LINE_END );
|
|
||||||
userPanel.add( Components.borderPanel(
|
userPanel.add( Components.borderPanel(
|
||||||
BorderFactory.createBevelBorder( BevelBorder.RAISED, Res.colors().controlBorder(), Res.colors().frameBg() ),
|
BorderFactory.createBevelBorder( BevelBorder.RAISED, Res.colors().controlBorder(), Res.colors().frameBg() ),
|
||||||
Res.colors().controlBg(), BoxLayout.PAGE_AXIS, userContent ), BorderLayout.CENTER );
|
Res.colors().controlBg(), BoxLayout.PAGE_AXIS, userContent = new UserContentPanel() ), BorderLayout.CENTER );
|
||||||
root.add( userPanel );
|
userPanel.add( userContent.getUserToolbar(), BorderLayout.LINE_START );
|
||||||
|
userPanel.add( userContent.getSiteToolbar(), BorderLayout.LINE_END );
|
||||||
|
|
||||||
addComponentListener( new ComponentHandler() );
|
addComponentListener( new ComponentHandler() );
|
||||||
setPreferredSize( new Dimension( 800, 560 ) );
|
setPreferredSize( new Dimension( 800, 560 ) );
|
||||||
|
Loading…
Reference in New Issue
Block a user