1 package tim.prune.function.compress;
3 import javax.swing.JOptionPane;
6 import tim.prune.FunctionLibrary;
7 import tim.prune.GenericFunction;
8 import tim.prune.I18nManager;
11 * Superclass of those functions which mark points for deletion
12 * (and optionally delete them automatically)
14 public abstract class MarkAndDeleteFunction extends GenericFunction
16 /** flag to remember whether the automatic deletion has been set to always */
17 private boolean _automaticallyDelete = false;
22 * @param inApp App object
24 public MarkAndDeleteFunction(App inApp)
30 * optionally delete the marked points
32 protected void optionallyDeleteMarkedPoints(int inNumMarked)
34 // Allow calling of delete function with one click
35 final String[] buttonTexts = {I18nManager.getText("button.yes"), I18nManager.getText("button.no"),
36 I18nManager.getText("button.always")};
37 int answer = _automaticallyDelete ? JOptionPane.YES_OPTION :
38 JOptionPane.showOptionDialog(_parentFrame,
39 I18nManager.getTextWithNumber("dialog.compress.confirm", inNumMarked),
40 I18nManager.getText(getNameKey()), JOptionPane.YES_NO_CANCEL_OPTION,
41 JOptionPane.WARNING_MESSAGE, null, buttonTexts, buttonTexts[1]);
42 if (answer == JOptionPane.CANCEL_OPTION) {_automaticallyDelete = true;} // "always" is third option
44 // Make sure function knows what to do, whether we'll call it now or later
45 FunctionLibrary.FUNCTION_DELETE_MARKED_POINTS.setParentFunction(
46 getNameKey(), getShouldSplitSegments());
47 if (_automaticallyDelete || answer == JOptionPane.YES_OPTION)
49 new Thread(new Runnable() {
52 FunctionLibrary.FUNCTION_DELETE_MARKED_POINTS.begin();
58 /** by default, segments are not split at deleted points */
59 protected boolean getShouldSplitSegments() {