com.alee.laf.optionpane.WebOptionPane Java Examples

The following examples show how to use com.alee.laf.optionpane.WebOptionPane. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainFrame.java    From desktopclient-java with GNU General Public License v3.0 6 votes vote down vote up
private void showAboutDialog() {
    WebPanel aboutPanel = new WebPanel(new GridLayout(0, 1, View.GAP_SMALL, View.GAP_SMALL));
    aboutPanel.add(new WebLabel("Kontalk Java Client v" + Kontalk.VERSION));
    WebLinkLabel linkLabel = new WebLinkLabel();
    linkLabel.setLink(View.KONTALK_SITE);
    linkLabel.setText(Tr.tr("Visit kontalk.org"));
    aboutPanel.add(linkLabel);
    WebLabel soundLabel = new WebLabel(Tr.tr("Notification sound by")+" FxProSound");
    aboutPanel.add(soundLabel);
    Icon icon = Utils.getIcon("kontalk.png");
    WebOptionPane.showMessageDialog(this,
            aboutPanel,
            Tr.tr("About"),
            WebOptionPane.INFORMATION_MESSAGE,
            icon);
}
 
Example #2
Source File: UISystemProxyConfirmationSupport.java    From weblaf with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean shouldUseSystemProxy ()
{
    // Whether should save the choice or not
    alwaysDoTheSame = new WebCheckBox ();
    alwaysDoTheSame.setLanguage ( "weblaf.proxy.use.system.save" );
    alwaysDoTheSame.setSelected ( false );
    alwaysDoTheSame.setFocusable ( false );

    // Ask for settings replacement with system ones
    final String message = LM.get ( "weblaf.proxy.use.system.text" );
    final String title = LM.get ( "weblaf.proxy.use.system.title" );
    final int options = WebExtendedOptionPane.YES_NO_OPTION;
    final int type = WebExtendedOptionPane.QUESTION_MESSAGE;
    final WebExtendedOptionPane dialog =
            WebExtendedOptionPane.showConfirmDialog ( SwingUtils.getActiveWindow (), message, alwaysDoTheSame, title, options, type );

    return dialog.getResult () == WebOptionPane.YES_OPTION;
}
 
Example #3
Source File: GenerateShortcutAction.java    From lnk2pwn with MIT License 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent event) {
    LOGGER.info("Generate button clicked");
    
    if (directoryChooser == null) {
        directoryChooser = new WebDirectoryChooser(windowController.getRootFrame());
    }
        
    LOGGER.info("Openning the directory chooser");
    directoryChooser.setVisible(true);
    if (directoryChooser.getResult () == DialogOptions.CANCEL_OPTION){
        LOGGER.info("No output path selected, canceling the action");
        return;
    }
            
    File outputPath = directoryChooser.getSelectedDirectory();		
    shortcut.setOutputPath(outputPath.getAbsolutePath());
                
    try {
        
        controller.generateShortcut(shortcut);
        int result = WebOptionPane.showConfirmDialog(
                windowController.getRootFrame(), 
                "Shortcut successfully generated!\nWould you like to open the folder location?", 
                "Shortcut", 
                WebOptionPane.YES_NO_OPTION,
                WebOptionPane.INFORMATION_MESSAGE);
        
        if (WebOptionPane.YES_OPTION == result) {
            LOGGER.info("Openning the output path");
            Desktop.getDesktop().open(outputPath);
        }
        
    } catch (Exception e) {
        LOGGER.error(e);
    }
}
 
Example #4
Source File: ContactDetails.java    From desktopclient-java with GNU General Public License v3.0 5 votes vote down vote up
private void saveJID(JID jid) {
    if (!jid.isValid() || jid.equals(mContact.getJID()))
        // TODO feedback for invalid jid
        return;

    String warningText =
            Tr.tr("Changing the JID is only useful in very rare cases. Are you sure?");
    int selectedOption = WebOptionPane.showConfirmDialog(this,
            warningText,
            Tr.tr("Please Confirm"),
            WebOptionPane.OK_CANCEL_OPTION,
            WebOptionPane.WARNING_MESSAGE);
    if (selectedOption == WebOptionPane.OK_OPTION)
        mView.getControl().changeJID(mContact, jid);
}
 
Example #5
Source File: ChatDetails.java    From desktopclient-java with GNU General Public License v3.0 5 votes vote down vote up
private boolean leave(GroupChat chat) {
    String warningText =
            Tr.tr("You won't be able to enter this group again after you leave.");
    int selectedOption = WebOptionPane.showConfirmDialog(this,
            warningText,
            Tr.tr("Please Confirm"),
            WebOptionPane.OK_CANCEL_OPTION,
            WebOptionPane.WARNING_MESSAGE);

    if (selectedOption == WebOptionPane.OK_OPTION) {
        mView.getControl().leaveGroupChat(chat);
        return true;
    }
    return false;
}
 
Example #6
Source File: View.java    From desktopclient-java with GNU General Public License v3.0 5 votes vote down vote up
void showPasswordDialog(boolean wasWrong) {
    WebPanel passPanel = new WebPanel();
    WebLabel passLabel = new WebLabel(Tr.tr("Please enter your key password:"));
    passPanel.add(passLabel, BorderLayout.NORTH);
    final WebPasswordField passField = new WebPasswordField();
    passPanel.add(passField, BorderLayout.CENTER);
    if (wasWrong) {
        WebLabel wrongLabel = new WebLabel(Tr.tr("Wrong password"));
        wrongLabel.setForeground(Color.RED);
        passPanel.add(wrongLabel, BorderLayout.SOUTH);
    }
    WebOptionPane passPane = new WebOptionPane(passPanel,
            WebOptionPane.QUESTION_MESSAGE,
            WebOptionPane.OK_CANCEL_OPTION);
    JDialog dialog = passPane.createDialog(mMainFrame, Tr.tr("Enter password"));
    dialog.setModal(true);
    dialog.addWindowFocusListener(new WindowAdapter() {
        @Override
        public void windowGainedFocus(WindowEvent e) {
            passField.requestFocusInWindow();
        }
    });
    // blocking
    LOGGER.info("asking for password…");
    dialog.setVisible(true);

    Object value = passPane.getValue();
    if (value != null && value.equals(WebOptionPane.OK_OPTION))
        mControl.connect(passField.getPassword());
}
 
Example #7
Source File: View.java    From desktopclient-java with GNU General Public License v3.0 5 votes vote down vote up
public static void showWrongJavaVersionDialog() {
    String jVersion = System.getProperty("java.version");
    if (jVersion.length() >= 3)
        jVersion = jVersion.substring(2, 3);
    String errorText = Tr.tr("The installed Java version is too old")+": " + jVersion;
    errorText += EncodingUtils.EOL;
    errorText += Tr.tr("Please install Java 8.");
    WebOptionPane.showMessageDialog(null,
            errorText,
            Tr.tr("Unsupported Java Version"),
            WebOptionPane.ERROR_MESSAGE);
}
 
Example #8
Source File: Utils.java    From desktopclient-java with GNU General Public License v3.0 5 votes vote down vote up
static boolean confirmDeletion(Component parent, String text) {
    int selectedOption = WebOptionPane.showConfirmDialog(parent,
            text,
            Tr.tr("Please Confirm"),
            WebOptionPane.OK_CANCEL_OPTION,
            WebOptionPane.WARNING_MESSAGE);
    return selectedOption == WebOptionPane.OK_OPTION;
}
 
Example #9
Source File: WebExtendedOptionPane.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setVisible ( final boolean b )
{
    if ( b )
    {
        // Default result
        result = WebOptionPane.CLOSED_OPTION;

        // Default focus
        buttons.getComponents ()[ 0 ].requestFocusInWindow ();
    }
    super.setVisible ( b );
}
 
Example #10
Source File: NinePatchEditorPanel.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
public boolean continueAfterSave ()
{
    if ( ninePatchEditor.isChanged () )
    {
        final String message = LM.get ( "weblaf.ex.npeditor.saveChanges.text" );
        final String title = LM.get ( "weblaf.ex.npeditor.saveChanges.title" );
        final int option = WebOptionPane.YES_NO_CANCEL_OPTION;
        final int messageType = WebOptionPane.QUESTION_MESSAGE;
        final int confirm = WebOptionPane.showConfirmDialog ( this, message, title, option, messageType );

        if ( confirm == WebOptionPane.YES_OPTION )
        {
            // Save changes before open
            if ( save.isEnabled () )
            {
                save.doClick ();
            }
            else
            {
                saveAs.doClick ();
            }

            // Save operation cancelled or failed
            if ( ninePatchEditor.isChanged () )
            {
                return false;
            }
        }
        else if ( confirm == WebOptionPane.CANCEL_OPTION )
        {
            // Cancel open
            return false;
        }
    }
    return true;
}
 
Example #11
Source File: UIProxyAuthenticator.java    From weblaf with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns new custom password authentication.
 * This method might also pop authentication dialog if needed.
 *
 * @return new custom password authentication
 */
protected PasswordAuthentication getProxyAuthentification ()
{
    // This method cannot wait for auth dialog since it is mostly called from EDT
    final ProxySettings proxySettings = ProxyManager.getProxySettings ().clone ();
    final PasswordAuthentication auth;
    if ( authDialog != null )
    {
        // Ignore while auth dialog is showing
        auth = null;
    }
    else if ( proxySettings.isUseProxyAuthentification () )
    {
        // Creating auth from settings
        auth = createAuthentification ( proxySettings );
    }
    else
    {
        // Ask user for login/pass
        authDialog = new AuthDialog ( proxySettings );
        authDialog.setVisible ( true );

        if ( authDialog.getResult () == WebOptionPane.OK_OPTION )
        {
            // Update settings
            proxySettings.setUseProxyAuthentification ( true );
            proxySettings.setProxyLogin ( authDialog.getLogin () );
            proxySettings.setProxyPassword ( new String ( authDialog.getPassword () ) );

            // Setup updated settings
            ProxyManager.setProxySettings ( proxySettings, authDialog.isSaveSettings () );

            // Determined authentification
            auth = createAuthentification ( proxySettings );
        }
        else
        {
            final ProxySettings updatedSettings = ProxyManager.getProxySettings ();
            if ( updatedSettings.isUseProxyAuthentification () )
            {
                // Settings came from somewhere else
                auth = createAuthentification ( updatedSettings );
            }
            else
            {
                // Null authentification
                auth = null;
            }
        }

        authDialog = null;
    }
    return auth;
}
 
Example #12
Source File: WebFileChooserPanel.java    From weblaf with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Delete all selected in view files.
 */
public void deleteSelectedFiles ()
{
    final List<File> files = getAllSelectedFiles ();
    if ( files.isEmpty () )
    {
        return;
    }

    final WebPanel all = new WebPanel ( new BorderLayout ( 0, 5 ) );
    all.add ( new WebLabel ( "weblaf.filechooser.delete.confirm.text" ), BorderLayout.NORTH );

    final VerticalFlowLayout removalListLayout = new VerticalFlowLayout ( VerticalFlowLayout.TOP, 0, 5, true, false );
    final WebPanel deleteFilesPanel = new WebPanel ( StyleId.filechooserRemovalListPanel.at ( this ), removalListLayout );
    for ( final File file : files )
    {
        deleteFilesPanel.add ( new WebLabel ( file.getName (), FileUtils.getFileIcon ( file ), WebLabel.LEFT ) );
    }
    final WebScrollPane scroll = new WebScrollPane ( deleteFilesPanel )
    {
        @NotNull
        @Override
        public Dimension getPreferredSize ()
        {
            final Dimension ps = super.getPreferredSize ();

            final JScrollBar vsb = getVerticalScrollBar ();
            if ( vsb != null && vsb.isShowing () )
            {
                ps.width = ps.width + vsb.getPreferredSize ().width;
            }

            ps.height = Math.min ( ps.height, 100 );

            return ps;
        }
    };
    all.add ( scroll, BorderLayout.CENTER );

    final int confirm = WebOptionPane.showConfirmDialog ( WebFileChooserPanel.this,
            all, LM.get ( "weblaf.filechooser.delete.confirm.title" ),
            WebOptionPane.YES_NO_OPTION, WebOptionPane.QUESTION_MESSAGE );

    if ( confirm == WebOptionPane.YES_OPTION )
    {
        FileUtils.deleteFiles ( files );
        reloadCurrentFolder ();
    }
}