Button tooltips and improvements.
This commit is contained in:
parent
7455fba55e
commit
38f09021b3
@ -235,7 +235,7 @@ public abstract class Components {
|
||||
} );
|
||||
}
|
||||
|
||||
public static JButton button(final Icon icon, @Nullable final ActionListener actionListener) {
|
||||
public static JButton button(final Icon icon, @Nullable final ActionListener actionListener, @Nullable String toolTip) {
|
||||
JButton iconButton = button( new AbstractAction( null, icon ) {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
@ -248,6 +248,7 @@ public abstract class Components {
|
||||
return actionListener != null;
|
||||
}
|
||||
} );
|
||||
iconButton.setToolTipText( toolTip );
|
||||
iconButton.setFocusable( false );
|
||||
|
||||
return iconButton;
|
||||
|
@ -3,9 +3,7 @@ package com.lyndir.masterpassword.gui.view;
|
||||
import static com.lyndir.masterpassword.util.Utilities.*;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.lyndir.masterpassword.gui.util.Res;
|
||||
import com.lyndir.masterpassword.gui.util.CollectionListModel;
|
||||
import com.lyndir.masterpassword.gui.util.Components;
|
||||
import com.lyndir.masterpassword.gui.util.*;
|
||||
import com.lyndir.masterpassword.model.MPUser;
|
||||
import com.lyndir.masterpassword.model.impl.MPFileUser;
|
||||
import com.lyndir.masterpassword.model.impl.MPFileUserManager;
|
||||
@ -24,7 +22,8 @@ public class FilesPanel extends JPanel implements MPFileUserManager.Listener {
|
||||
|
||||
private final Collection<Listener> listeners = new CopyOnWriteArraySet<>();
|
||||
|
||||
private final JButton avatarButton = Components.button( Res.icons().avatar( 0 ), event -> setAvatar() );
|
||||
private final JButton avatarButton = Components.button( Res.icons().avatar( 0 ), event -> setAvatar(),
|
||||
"Click to change the user's avatar." );
|
||||
|
||||
private final CollectionListModel<MPUser<?>> usersModel =
|
||||
CollectionListModel.<MPUser<?>>copy( MPFileUserManager.get().getFiles() ).selection( this::setUser );
|
||||
@ -43,7 +42,6 @@ public class FilesPanel extends JPanel implements MPFileUserManager.Listener {
|
||||
add( avatarButton );
|
||||
avatarButton.setHorizontalAlignment( SwingConstants.CENTER );
|
||||
avatarButton.setMaximumSize( new Dimension( Integer.MAX_VALUE, 0 ) );
|
||||
avatarButton.setToolTipText( "The avatar for your user. Click to change it." );
|
||||
|
||||
// -
|
||||
add( Components.strut( Components.margin() ) );
|
||||
|
@ -35,7 +35,10 @@ public class UserContentPanel extends JPanel implements FilesPanel.Listener, MPU
|
||||
|
||||
private static final Random random = new Random();
|
||||
private static final Logger logger = Logger.get( UserContentPanel.class );
|
||||
private static final JButton iconButton = Components.button( Res.icons().user(), null );
|
||||
private static final JButton iconButton = Components.button( Res.icons().user(), null, null );
|
||||
|
||||
private final JButton addButton = Components.button( Res.icons().add(), event -> addUser(),
|
||||
"Add a new user to Master Password." );
|
||||
|
||||
private final JPanel userToolbar = Components.panel( BoxLayout.PAGE_AXIS );
|
||||
private final JPanel siteToolbar = Components.panel( BoxLayout.PAGE_AXIS );
|
||||
@ -108,11 +111,23 @@ public class UserContentPanel extends JPanel implements FilesPanel.Listener, MPU
|
||||
} );
|
||||
}
|
||||
|
||||
private void addUser() {
|
||||
Object fullName = JOptionPane.showInputDialog(
|
||||
this, strf( "<html>Enter your full legal name:</html>" ), "Add User",
|
||||
JOptionPane.QUESTION_MESSAGE, null, null, "Robert Lee Mitchell" );
|
||||
if (fullName == null)
|
||||
return;
|
||||
|
||||
setUser( MPFileUserManager.get().add( fullName.toString() ) );
|
||||
}
|
||||
|
||||
private final class NoUserPanel extends JPanel {
|
||||
|
||||
private NoUserPanel() {
|
||||
setLayout( new BoxLayout( this, BoxLayout.PAGE_AXIS ) );
|
||||
|
||||
userToolbar.add( addButton );
|
||||
|
||||
add( Box.createGlue() );
|
||||
add( Components.heading( "Select a user to proceed." ) );
|
||||
add( Box.createGlue() );
|
||||
@ -125,8 +140,8 @@ public class UserContentPanel extends JPanel implements FilesPanel.Listener, MPU
|
||||
@Nonnull
|
||||
private final MPUser<?> user;
|
||||
|
||||
private final JButton addButton = Components.button( Res.icons().add(), event -> addUser() );
|
||||
private final JButton deleteButton = Components.button( Res.icons().delete(), event -> deleteUser() );
|
||||
private final JButton deleteButton = Components.button( Res.icons().delete(), event -> deleteUser(),
|
||||
"Delete this user from Master Password." );
|
||||
|
||||
private final JPasswordField masterPasswordField = Components.passwordField();
|
||||
private final JLabel errorLabel = Components.label();
|
||||
@ -159,16 +174,6 @@ public class UserContentPanel extends JPanel implements FilesPanel.Listener, MPU
|
||||
add( Box.createGlue() );
|
||||
}
|
||||
|
||||
private void addUser() {
|
||||
Object fullName = JOptionPane.showInputDialog(
|
||||
this, strf( "<html>Enter your full legal name:</html>" ), "Add User",
|
||||
JOptionPane.QUESTION_MESSAGE, null, null, "Robert Lee Mitchell" );
|
||||
if (fullName == null)
|
||||
return;
|
||||
|
||||
setUser( MPFileUserManager.get().add( fullName.toString() ) );
|
||||
}
|
||||
|
||||
private void deleteUser() {
|
||||
MPFileUser fileUser = (user instanceof MPFileUser)? (MPFileUser) user: null;
|
||||
if (fileUser == null)
|
||||
@ -248,11 +253,16 @@ public class UserContentPanel extends JPanel implements FilesPanel.Listener, MPU
|
||||
|
||||
public static final int SIZE_RESULT = 48;
|
||||
|
||||
private final JButton userButton = Components.button( Res.icons().user(), event -> showUserPreferences() );
|
||||
private final JButton logoutButton = Components.button( Res.icons().lock(), event -> logoutUser() );
|
||||
private final JButton settingsButton = Components.button( Res.icons().settings(), event -> showSiteSettings() );
|
||||
private final JButton questionsButton = Components.button( Res.icons().question(), null );
|
||||
private final JButton deleteButton = Components.button( Res.icons().delete(), event -> deleteSite() );
|
||||
private final JButton userButton = Components.button( Res.icons().user(), event -> showUserPreferences(),
|
||||
"Show user preferences." );
|
||||
private final JButton logoutButton = Components.button( Res.icons().lock(), event -> logoutUser(),
|
||||
"Sign out and lock user." );
|
||||
private final JButton settingsButton = Components.button( Res.icons().settings(), event -> showSiteSettings(),
|
||||
"Show site settings." );
|
||||
private final JButton questionsButton = Components.button( Res.icons().question(), null,
|
||||
"Show site recovery questions." );
|
||||
private final JButton deleteButton = Components.button( Res.icons().delete(), event -> deleteSite(),
|
||||
"Delete the site from the user." );
|
||||
|
||||
@Nonnull
|
||||
private final MPUser<?> user;
|
||||
@ -272,6 +282,7 @@ public class UserContentPanel extends JPanel implements FilesPanel.Listener, MPU
|
||||
|
||||
this.user = user;
|
||||
|
||||
userToolbar.add( addButton );
|
||||
userToolbar.add( userButton );
|
||||
userToolbar.add( logoutButton );
|
||||
|
||||
@ -279,6 +290,7 @@ public class UserContentPanel extends JPanel implements FilesPanel.Listener, MPU
|
||||
siteToolbar.add( questionsButton );
|
||||
siteToolbar.add( deleteButton );
|
||||
settingsButton.setEnabled( false );
|
||||
deleteButton.setEnabled( false );
|
||||
|
||||
add( Components.heading( user.getFullName(), SwingConstants.CENTER ) );
|
||||
|
||||
@ -366,7 +378,10 @@ public class UserContentPanel extends JPanel implements FilesPanel.Listener, MPU
|
||||
if (site == null)
|
||||
return;
|
||||
|
||||
user.deleteSite( site );
|
||||
if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(
|
||||
this, strf( "<html>Forget the site <strong>%s</strong>?</html>", site.getSiteName() ),
|
||||
"Delete Site", JOptionPane.YES_NO_OPTION ))
|
||||
user.deleteSite( site );
|
||||
}
|
||||
|
||||
private String getSiteDescription(@Nonnull final MPSite<?> site) {
|
||||
@ -434,6 +449,7 @@ public class UserContentPanel extends JPanel implements FilesPanel.Listener, MPU
|
||||
passwordLabel.setText( " " );
|
||||
passwordField.setText( " " );
|
||||
settingsButton.setEnabled( false );
|
||||
deleteButton.setEnabled( false );
|
||||
} );
|
||||
return;
|
||||
}
|
||||
@ -448,6 +464,7 @@ public class UserContentPanel extends JPanel implements FilesPanel.Listener, MPU
|
||||
passwordLabel.setText( strf( "Your password for %s:", site.getSiteName() ) );
|
||||
passwordField.setText( result );
|
||||
settingsButton.setEnabled( true );
|
||||
deleteButton.setEnabled( true );
|
||||
} );
|
||||
}
|
||||
catch (final MPKeyUnavailableException | MPAlgorithmException e) {
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 2.1 KiB |
Loading…
Reference in New Issue
Block a user