~veger/ganttproject/manual-import

« back to all changes in this revision

Viewing changes to ganttproject/src/net/sourceforge/ganttproject/chart/mouse/DrawDependencyInteraction.java

  • Committer: Maarten Bezemer
  • Date: 2012-01-22 12:20:00 UTC
  • Revision ID: maarten.bezemer@gmail.com-20120122122000-qwyec45rjx86wi7o
Updated till 2fe683a778c3 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
GanttProject is an opensource project management tool. License: GPL2
 
2
GanttProject is an opensource project management tool. License: GPL3
3
3
Copyright (C) 2010 Dmitry Barashev
4
4
 
5
5
This program is free software; you can redistribute it and/or
6
6
modify it under the terms of the GNU General Public License
7
 
as published by the Free Software Foundation; either version 2
 
7
as published by the Free Software Foundation; either version 3
8
8
of the License, or (at your option) any later version.
9
9
 
10
10
This program is distributed in the hope that it will be useful,
26
26
import net.sourceforge.ganttproject.chart.item.TaskRegularAreaChartItem;
27
27
import net.sourceforge.ganttproject.gui.UIFacade;
28
28
import net.sourceforge.ganttproject.task.Task;
 
29
import net.sourceforge.ganttproject.task.dependency.TaskDependency;
29
30
import net.sourceforge.ganttproject.task.dependency.TaskDependencyCollection;
30
31
import net.sourceforge.ganttproject.task.dependency.TaskDependencyException;
31
32
import net.sourceforge.ganttproject.task.dependency.constraint.FinishStartConstraintImpl;
51
52
 
52
53
    public static interface ChartModelFacade {
53
54
        Task findTaskUnderMousePointer(int xpos, int ypos);
 
55
        TaskDependency.Hardness getDefaultHardness();
54
56
    }
55
57
 
56
58
    public DrawDependencyInteraction(MouseEvent initiatingEvent,
66
68
            myStartPoint.x, myStartPoint.y, myStartPoint.x, myStartPoint.y);
67
69
    }
68
70
 
 
71
    @Override
69
72
    public void apply(MouseEvent event) {
70
73
        myArrow.changePoint2(event.getX(), event.getY());
71
74
        myLastMouseEvent = event;
72
75
    }
73
76
 
 
77
    @Override
74
78
    public void finish() {
75
79
        if (myLastMouseEvent != null) {
76
80
            myDependant = myChartModelFacade.findTaskUnderMousePointer(
80
84
                if (myDependencyCollection.canCreateDependency(myDependant, dependee)) {
81
85
                    myUiFacade.getUndoManager().undoableEdit("Draw dependency",
82
86
                            new Runnable() {
 
87
                                @Override
83
88
                                public void run() {
84
89
                                    try {
85
 
                                        myDependencyCollection.createDependency(
 
90
                                        TaskDependency dep = myDependencyCollection.createDependency(
86
91
                                            myDependant, dependee, new FinishStartConstraintImpl());
 
92
                                        dep.setHardness(myChartModelFacade.getDefaultHardness());
87
93
 
88
94
                                    } catch (TaskDependencyException e) {
89
95
                                        myUiFacade.showErrorDialog(e);