Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
package org.apache.cayenne.modeler.dialog;
Used to confirm deleting items in the model.
public class ConfirmRemoveDialog {
    private boolean shouldDelete = true;
If false, no question will be asked no matter what settings are
    private boolean allowAsking;
    public ConfirmRemoveDialog(boolean allowAsking) {
        this. = allowAsking;
    private void showDialog(String name) {
        JCheckBox neverPromptAgainBox = new JCheckBox("Always delete without prompt.");
        Object message[] = {String.format("Are you sure you would like to delete the %s?"name), neverPromptAgainBox};
        JOptionPane pane = new JOptionPane(message..);
        JDialog dialog = pane.createDialog(Application.getFrame(), "Confirm Remove");
        Object selectedValue = pane.getValue();
         = selectedValue.equals(.);
        // If the user clicks "no", we'll just ignore whatever's in the checkbox because it's non-sensical.
        if () {
    public boolean shouldDelete(String typeString name) {
        return shouldDelete(String.format("%s named '%s'?"typename));
    public boolean shouldDelete(String name) {
        if () {
            // See if the user has opted not to showDialog the delete dialog.
            if ((pref == null) || (false == pref.getBooleanProperty(.))) {
        return ;
New to GrepCode? Check out our FAQ X