Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement confirmation dialogs and string overrides
This implements two APIs: * An API for requiring the confirmation of selections of existing files when the chooser is in CREATE mode. * An API for providing overrides of button strings. Affects: #17 Affects: #7
- Loading branch information
Showing
12 changed files
with
634 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
...heaf.api/src/main/java/com/io7m/jwheatsheaf/api/JWFileChooserStringOverridesAbstract.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright © 2021 Mark Raynsford <code@io7m.com> http://io7m.com | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
package com.io7m.jwheatsheaf.api; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* An abstract set of string overrides that override nothing. | ||
*/ | ||
|
||
public abstract class JWFileChooserStringOverridesAbstract | ||
implements JWFileChooserStringOverridesType | ||
{ | ||
protected JWFileChooserStringOverridesAbstract() | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* Overrides of this method are NOT required to call this method via {@code super}. | ||
*/ | ||
|
||
@Override | ||
public Optional<String> buttonOpen() | ||
{ | ||
return Optional.empty(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* Overrides of this method are NOT required to call this method via {@code super}. | ||
*/ | ||
|
||
@Override | ||
public Optional<String> buttonSave() | ||
{ | ||
return Optional.empty(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* Overrides of this method are NOT required to call this method via {@code super}. | ||
*/ | ||
|
||
@Override | ||
public Optional<String> confirmReplaceMessage( | ||
final String file) | ||
{ | ||
return Optional.empty(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* Overrides of this method are NOT required to call this method via {@code super}. | ||
*/ | ||
|
||
@Override | ||
public Optional<String> confirmReplaceButton() | ||
{ | ||
return Optional.empty(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* Overrides of this method are NOT required to call this method via {@code super}. | ||
*/ | ||
|
||
@Override | ||
public Optional<String> confirmTitleMessage() | ||
{ | ||
return Optional.empty(); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...atsheaf.api/src/main/java/com/io7m/jwheatsheaf/api/JWFileChooserStringOverridesEmpty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright © 2021 Mark Raynsford <code@io7m.com> http://io7m.com | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
package com.io7m.jwheatsheaf.api; | ||
|
||
/** | ||
* A set of string overrides that override nothing. | ||
*/ | ||
|
||
public final class JWFileChooserStringOverridesEmpty | ||
extends JWFileChooserStringOverridesAbstract | ||
{ | ||
private static final JWFileChooserStringOverridesType INSTANCE = | ||
new JWFileChooserStringOverridesEmpty(); | ||
|
||
private JWFileChooserStringOverridesEmpty() | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* @return The empty set of overrides | ||
*/ | ||
|
||
public static JWFileChooserStringOverridesType get() | ||
{ | ||
return INSTANCE; | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...eatsheaf.api/src/main/java/com/io7m/jwheatsheaf/api/JWFileChooserStringOverridesType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright © 2021 Mark Raynsford <code@io7m.com> http://io7m.com | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
package com.io7m.jwheatsheaf.api; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* The set of string overrides. For any of the methods in this class, if | ||
* {@link Optional#empty()} is returned, a default string will be used. | ||
* | ||
* @since 3.0.0 | ||
*/ | ||
|
||
public interface JWFileChooserStringOverridesType | ||
{ | ||
/** | ||
* A message override for the "Open" button. | ||
* | ||
* @return A message override | ||
*/ | ||
|
||
Optional<String> buttonOpen(); | ||
|
||
/** | ||
* A message override for the "Save" button. | ||
* | ||
* @return A message override | ||
*/ | ||
|
||
Optional<String> buttonSave(); | ||
|
||
/** | ||
* A message override for the "Do you want to replace this file?" message. | ||
* | ||
* @param file The file | ||
* | ||
* @return A message override | ||
*/ | ||
|
||
Optional<String> confirmReplaceMessage(String file); | ||
|
||
/** | ||
* A message override for the "Replace" confirmation button. | ||
* | ||
* @return A message override | ||
*/ | ||
|
||
Optional<String> confirmReplaceButton(); | ||
|
||
/** | ||
* A message override for the "Replace?" confirmation dialog header. | ||
* | ||
* @return A message override | ||
*/ | ||
|
||
Optional<String> confirmTitleMessage(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...jwheatsheaf.examples/src/main/java/com/io7m/jwheatsheaf/examples/ExampleWeirdStrings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright © 2021 Mark Raynsford <code@io7m.com> http://io7m.com | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
package com.io7m.jwheatsheaf.examples; | ||
|
||
import com.io7m.jwheatsheaf.api.JWFileChooserStringOverridesAbstract; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* A set of weird strings. | ||
*/ | ||
|
||
public final class ExampleWeirdStrings | ||
extends JWFileChooserStringOverridesAbstract | ||
{ | ||
public ExampleWeirdStrings() | ||
{ | ||
|
||
} | ||
|
||
@Override | ||
public Optional<String> buttonOpen() | ||
{ | ||
return Optional.of("Vigilate"); | ||
} | ||
|
||
@Override | ||
public Optional<String> buttonSave() | ||
{ | ||
return Optional.of("Manticulate"); | ||
} | ||
|
||
@Override | ||
public Optional<String> confirmReplaceMessage( | ||
final String file) | ||
{ | ||
return Optional.of(String.format("Defloccate velleity '%s'?", file)); | ||
} | ||
|
||
@Override | ||
public Optional<String> confirmReplaceButton() | ||
{ | ||
return Optional.of("Defloccate"); | ||
} | ||
|
||
@Override | ||
public Optional<String> confirmTitleMessage() | ||
{ | ||
return Optional.of("Defloccate velleity?"); | ||
} | ||
} |
Oops, something went wrong.