Search in sources :

Example 1 with RemoveNodeCommandVector

use of facetmodeller.commands.RemoveNodeCommandVector in project facetmodeller by pglelievre.

the class ClearPLCMenuTask method execute.

@Override
public void execute() {
    // Check for the required information:
    if (!check()) {
        return;
    }
    // Get user confirmation:
    int response = Dialogs.confirm(controller, "Are you sure?", title());
    if (response != Dialogs.OK_OPTION) {
        return;
    }
    // Remove all plc components:
    ModelManager model = controller.getModelManager();
    CommandVector commands = new CommandVector(title());
    commands.add(new RemoveFacetCommandVector(model, model.getFacets(), ""));
    commands.add(new RemoveNodeCommandVector(model, model.getNodes(), ""));
    commands.add(new RemoveRegionCommandVector(model, model.getRegions()));
    commands.execute();
    controller.undoVectorAdd(commands);
    // Enable or disable menu items:
    controller.checkItemsEnabled();
    // Repaint:
    controller.redraw();
}
Also used : RemoveFacetCommandVector(facetmodeller.commands.RemoveFacetCommandVector) RemoveRegionCommandVector(facetmodeller.commands.RemoveRegionCommandVector) ModelManager(facetmodeller.ModelManager) RemoveNodeCommandVector(facetmodeller.commands.RemoveNodeCommandVector) RemoveRegionCommandVector(facetmodeller.commands.RemoveRegionCommandVector) RemoveFacetCommandVector(facetmodeller.commands.RemoveFacetCommandVector) RemoveNodeCommandVector(facetmodeller.commands.RemoveNodeCommandVector) CommandVector(facetmodeller.commands.CommandVector)

Example 2 with RemoveNodeCommandVector

use of facetmodeller.commands.RemoveNodeCommandVector in project facetmodeller by pglelievre.

the class DeleteDisplayedNodesMenuTask method execute.

@Override
public void execute() {
    // Check for the required information:
    if (!check()) {
        return;
    }
    // Check for no nodes painted:
    NodeVector nodes = controller.getPaintedNodes();
    if (nodes.isEmpty()) {
        return;
    }
    // Ask user for confirmation:
    int response = Dialogs.confirm(controller, "Are you sure you want to remove all the currently displayed nodes?", title());
    // user cancelled
    if (response != Dialogs.OK_OPTION) {
        return;
    }
    // Delete the displayed nodes:
    RemoveNodeCommandVector com = new RemoveNodeCommandVector(controller.getModelManager(), nodes, title());
    com.execute();
    controller.undoVectorAdd(com);
    // Enable or disable menu items:
    controller.checkItemsEnabled();
    // Repaint:
    controller.redraw();
}
Also used : NodeVector(facetmodeller.plc.NodeVector) RemoveNodeCommandVector(facetmodeller.commands.RemoveNodeCommandVector)

Example 3 with RemoveNodeCommandVector

use of facetmodeller.commands.RemoveNodeCommandVector in project facetmodeller by pglelievre.

the class DeleteDuplicateNodesMenuTask method execute.

@Override
public void execute() {
    // Check for the required information:
    if (!check()) {
        return;
    }
    // Find the duplicates:
    DuplicateNodeInfo dupInfo = controller.findDuplicateNodes();
    int n = dupInfo.size();
    // Check number of nodes to remove:
    if (n == 0) {
        // Inform user:
        Dialogs.inform(controller, "There are no duplicate nodes.", title());
        return;
    } else {
        // Get user confirmation:
        String message;
        if (n == 1) {
            message = "1 node will be removed.";
        } else {
            message = n + " nodes will be removed.";
        }
        int resp = Dialogs.confirm(controller, message, title());
        if (resp != Dialogs.OK_OPTION) {
            return;
        }
    }
    // Remove the marked nodes:
    RemoveNodeCommandVector com = new RemoveNodeCommandVector(controller.getModelManager(), dupInfo.getNodesToRemove(), title());
    com.execute();
    // removes any reference to the removed nodes so they can be removed from memory by the garbage collector
    dupInfo.clear();
    controller.undoVectorAdd(com);
    // Enable or disable menu items:
    controller.checkItemsEnabled();
    // Repaint:
    controller.redraw();
}
Also used : DuplicateNodeInfo(facetmodeller.commands.DuplicateNodeInfo) RemoveNodeCommandVector(facetmodeller.commands.RemoveNodeCommandVector)

Example 4 with RemoveNodeCommandVector

use of facetmodeller.commands.RemoveNodeCommandVector in project facetmodeller by pglelievre.

the class DeleteNodeGroupMenuTask method execute.

@Override
public void execute() {
    // Check for the required information:
    if (!check()) {
        return;
    }
    // Ask user for confirmation:
    int response = Dialogs.confirm(controller, "Are you sure you want to remove all the nodes for the selected group?", title());
    // user cancelled
    if (response != Dialogs.OK_OPTION) {
        return;
    }
    // Delete the group of nodes:
    NodeVector nodes = controller.getSelectedCurrentGroup().getNodes();
    RemoveNodeCommandVector com = new RemoveNodeCommandVector(controller.getModelManager(), nodes, title());
    com.execute();
    controller.undoVectorAdd(com);
    // Enable or disable menu items:
    controller.checkItemsEnabled();
    // Repaint:
    controller.redraw();
}
Also used : NodeVector(facetmodeller.plc.NodeVector) RemoveNodeCommandVector(facetmodeller.commands.RemoveNodeCommandVector)

Aggregations

RemoveNodeCommandVector (facetmodeller.commands.RemoveNodeCommandVector)4 NodeVector (facetmodeller.plc.NodeVector)2 ModelManager (facetmodeller.ModelManager)1 CommandVector (facetmodeller.commands.CommandVector)1 DuplicateNodeInfo (facetmodeller.commands.DuplicateNodeInfo)1 RemoveFacetCommandVector (facetmodeller.commands.RemoveFacetCommandVector)1 RemoveRegionCommandVector (facetmodeller.commands.RemoveRegionCommandVector)1