Ganttis 1.0.5: validating add/remove operations with custom code

We’ve just released a first Ganttis framework update!

From now on, you’ll be able to easily verify using custom code under the GanttChartContentEditor delegate (and setting the editor property of GanttChartContentController) whether an operation like adding or removing an item or a dependency in the diagram should actually be performed when the end user attempts it.

To validate execution of such an operation, you’ll simply need to define new canAddItem, canRemoveItem, canAddDependency, and canRemoveDependencyfunctions supported by the protocol, as needed in your app.

A common scenario that matches canRemove* use cases is confirming execution of Delete operations (that are available from items’ and dependencies’ contextual menus), like this:

import Cocoa
import Ganttis

class ViewController: NSViewController, GanttChartContentEditor {
    @IBOutlet var ganttChart: GanttChart!
    override func viewDidLoad() {
        contentController.editor = self
        let controller = GanttChartController(headerController: headerController, contentController: contentController)
        ganttChart.controller = controller
    func canRemoveItem(_ item: GanttChartItem) -> Bool {
        let dialog = NSAlert()
        dialog.messageText = "Delete \(item.isMilestone ? "milestone" : "item")"
        dialog.informativeText = "Are you sure you want to perform this operation?"
        dialog.alertStyle = .warning
        dialog.addButton(withTitle: "Yes")
        dialog.addButton(withTitle: "No")
        return dialog.runModal() == .alertFirstButtonReturn

About DlhSoft Team

DlhSoft is a software development company focused on building high quality and innovative solutions using state-of-the-art technologies for customers worldwide. Our activity includes designing and developing general purpose software applications, components and tools, and customized software solutions upon request. DlhSoft team is highly experienced and fully dedicated to software development. Additionally, one of the most important things we rely on is the continuous communication with the customer.
This entry was posted in Development Components and tagged , , , , . Bookmark the permalink.

Add a reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s