| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | |
| | | * It proposes the user to save the changes, do not save them or cancel the |
| | | * action that make the dialog appear (for instance when the user is editing |
| | | * an entry and clicks on another node, this dialog appears). |
| | | * |
| | | */ |
| | | public class UnsavedChangesDialog extends GenericDialog |
| | | { |
| | | /** |
| | | * The different input that the user can provide. |
| | | * |
| | | */ |
| | | /** The different input that the user can provide. */ |
| | | public enum Result |
| | | { |
| | | /** |
| | | * The user asks to save the changes. |
| | | */ |
| | | /** The user asks to save the changes. */ |
| | | SAVE, |
| | | /** |
| | | * The user asks to not to save the changes. |
| | | */ |
| | | /** The user asks to not to save the changes. */ |
| | | DO_NOT_SAVE, |
| | | /** |
| | | * The user asks to cancel the operation that made this dialog to appear. |
| | | */ |
| | | /** The user asks to cancel the operation that made this dialog to appear. */ |
| | | CANCEL |
| | | } |
| | | private static final long serialVersionUID = -4436794801035162388L; |
| | |
| | | pack(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setVisible(boolean visible) |
| | | { |
| | | if (visible) |
| | |
| | | return panel; |
| | | } |
| | | |
| | | /** |
| | | * The panel to be displayed inside the dialog. |
| | | * |
| | | */ |
| | | /** The panel to be displayed inside the dialog. */ |
| | | private static class UnsavedChangesPanel extends StatusGenericPanel |
| | | { |
| | | private static final long serialVersionUID = -1528939816762604059L; |
| | |
| | | |
| | | private Result result; |
| | | |
| | | /** |
| | | * Default constructor. |
| | | * |
| | | */ |
| | | /** Default constructor. */ |
| | | public UnsavedChangesPanel() |
| | | { |
| | | super(); |
| | |
| | | add(createButtonsPanel(), gbc); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean requiresBorder() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean requiresScroll() |
| | | { |
| | | return false; |
| | |
| | | buttonsPanel.add(doNotSaveButton, gbc); |
| | | doNotSaveButton.addActionListener(new ActionListener() |
| | | { |
| | | @Override |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | result = Result.DO_NOT_SAVE; |
| | |
| | | buttonsPanel.add(cancelButton, gbc); |
| | | cancelButton.addActionListener(new ActionListener() |
| | | { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | result = Result.CANCEL; |
| | |
| | | buttonsPanel.add(saveButton, gbc); |
| | | saveButton.addActionListener(new ActionListener() |
| | | { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | result = Result.SAVE; |
| | |
| | | return buttonsPanel; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Component getPreferredFocusComponent() |
| | | { |
| | | return doNotSaveButton; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void okClicked() |
| | | { |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage getTitle() |
| | | { |
| | | return INFO_CTRL_PANEL_UNSAVED_CHANGES_DIALOG_TITLE.get(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void configurationChanged(ConfigurationChangeEvent ev) |
| | | { |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public GenericDialog.ButtonType getButtonType() |
| | | { |
| | | return GenericDialog.ButtonType.NO_BUTTON; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isDisposeOnClose() |
| | | { |
| | | return true; |