public override bool doTool() { bool elementDeleted = false; // Delete the block only if it is not the last one lastSelectedResources = parentDataControl.getSelectedResources(); if (resourcesList.Count > 1) { if (resourcesList.Remove((ResourcesUni)dataControl.getContent())) { resourcesIndex = resourcesDataControlList.IndexOf((ResourcesDataControl)dataControl); resourcesDataControlList.Remove((ResourcesDataControl)dataControl); int selectedResources = parentDataControl.getSelectedResources(); // Decrease the selected index if necessary if (selectedResources > 0 && selectedResources >= resourcesIndex) { parentDataControl.setSelectedResources(selectedResources - 1); } //controller.dataModified( ); elementDeleted = true; } } // If it was the last one, show an error message else { Controller.getInstance().showErrorDialog(TC.get("Operation.DeleteResourcesTitle"), TC.get("Operation.DeleteResourcesErrorLastResources")); } return(elementDeleted); }
public override bool redoTool() { resourcesList.Add(newResources); resourcesDataControlList.Add(newResourcesDataControl); parent.setSelectedResources(resourcesList.Count - 1); Controller.getInstance().updatePanel(); return(true); }
public override bool doTool() { if (!(dataControl is ResourcesDataControl)) { return(false); } newElement = (ResourcesUni)(((ResourcesUni)(dataControl.getContent()))); newDataControl = new ResourcesDataControl(newElement, ((ResourcesDataControl)dataControl).getResourcesType()); resourcesList.Add(newElement); resourcesDataControlList.Add(newDataControl); parent.setSelectedResources(resourcesList.Count - 1); return(true); }