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();
}
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();
}
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();
}
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();
}
Aggregations