Java Code Examples for com.alee.laf.optionpane.WebOptionPane#showConfirmDialog()

The following examples show how to use com.alee.laf.optionpane.WebOptionPane#showConfirmDialog() . 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: 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 2
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 3
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 4
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 5
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 6
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 ();
    }
}