Skip to main content
summaryrefslogtreecommitdiffstats
blob: 2ddd6cd38800075a4811ba80f4675d5c70b63929 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
/*******************************************************************************
 * Copyright (c) 2004 - 2005 University Of British Columbia and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     University Of British Columbia - initial API and implementation
 *******************************************************************************/
/*
 * Created on 19-Jan-2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package org.eclipse.mylar.tasks.ui;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ICellModifier;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.mylar.tasks.ITask;
import org.eclipse.mylar.tasks.ITaskActivityListener;
import org.eclipse.mylar.tasks.TaskListImages;
import org.eclipse.mylar.tasks.MylarTasksPlugin;
import org.eclipse.mylar.tasks.RelatedLinks;
import org.eclipse.mylar.tasks.ui.views.TaskListView;
import org.eclipse.mylar.tasks.util.RelativePathUtil;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.RetargetAction;
import org.eclipse.ui.browser.IWebBrowser;
import org.eclipse.ui.forms.FormColors;
import org.eclipse.ui.forms.events.ExpansionEvent;
import org.eclipse.ui.forms.events.IExpansionListener;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
import org.eclipse.ui.internal.WorkbenchImages;
import org.eclipse.ui.internal.WorkbenchMessages;
import org.eclipse.ui.internal.browser.WorkbenchBrowserSupport;
import org.eclipse.ui.part.EditorPart;

/**
 * For details on forms, go to:
 * 	http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/pde-ui-home/working/EclipseForms/EclipseForms.html
 * @author Ken Sueda
 */
public class TaskSummaryEditor extends EditorPart {
	
	/**
	 * TODO: use workbench theme
	 */
	public static final Color HYPERLINK  = new Color(Display.getDefault(), 0, 0, 255);
	
	private ITask task;
	private TaskEditorInput editorInput;
	private Composite editorComposite;
	private TaskEditorCopyAction copyAction;
	private RetargetAction pasteAction;
	private RetargetAction cutAction;
	private static final String cutActionDefId = "org.eclipse.ui.edit.cut";
	private static final String pasteActionDefId = "org.eclipse.ui.edit.paste";
	private Table table;
	private TableViewer tableViewer;
	private RelatedLinks links;
	private RelatedLinksContentProvider contentProvider;
		
	private Button browse;
	private Text pathText;
	private ScrolledForm sform;
	private Action add;
    private Action delete;
    private Text description;

    private ITaskActivityListener TASK_LIST_LISTENER = new ITaskActivityListener() {
        public void taskActivated(ITask activeTask) {    
        	if (task != null && !browse.isDisposed() && activeTask.getHandle().equals(task.getHandle())) {
        		browse.setEnabled(false);
        	}
        }

        public void tasksActivated(List<ITask> tasks) {
            for (ITask t : tasks) {
            	taskActivated(t);
            }
        }

        public void taskDeactivated(ITask deactiveTask) {
        	if (task != null && !browse.isDisposed() && deactiveTask.getHandle().equals(task.getHandle())) {
        		browse.setEnabled(true);
        	}
        }

		public void taskPropertyChanged(ITask updatedTask, String property) {
			if (task != null && updatedTask.getHandle().equals(task.getHandle())) {
        		if (property.equals("Description") && !description.isDisposed()) {
        			description.setText(task.getLabel());
        		} else if (property.equals("Path") && !pathText.isDisposed()) {
        			pathText.setText("<Mylar_Dir>/" + task.getPath());
        		}
        	}
		}        
    };    
	/**
	 * 
	 */
	public TaskSummaryEditor() {
		super();

		cutAction = new RetargetAction(ActionFactory.CUT.getId(),
                WorkbenchMessages.Workbench_cut);
		cutAction.setToolTipText(
                WorkbenchMessages.Workbench_cutToolTip);
		cutAction.setImageDescriptor(WorkbenchImages.getImageDescriptor(
			ISharedImages.IMG_TOOL_CUT));
		cutAction.setHoverImageDescriptor(WorkbenchImages.getImageDescriptor(
			ISharedImages.IMG_TOOL_CUT));
		cutAction.setDisabledImageDescriptor(WorkbenchImages.getImageDescriptor(
			ISharedImages.IMG_TOOL_CUT_DISABLED));
		cutAction.setAccelerator(SWT.CTRL | 'x');
		cutAction.setActionDefinitionId(cutActionDefId);

		pasteAction = new RetargetAction(ActionFactory.PASTE.getId(),
                WorkbenchMessages.Workbench_paste);
		pasteAction.setToolTipText(
                WorkbenchMessages.Workbench_pasteToolTip);
		pasteAction.setImageDescriptor(WorkbenchImages.getImageDescriptor(
			ISharedImages.IMG_TOOL_PASTE));
		pasteAction.setHoverImageDescriptor(WorkbenchImages.getImageDescriptor(
			ISharedImages.IMG_TOOL_PASTE));
		pasteAction.setDisabledImageDescriptor(WorkbenchImages.getImageDescriptor(
			ISharedImages.IMG_TOOL_PASTE_DISABLED));
		pasteAction.setAccelerator(SWT.CTRL | 'v');
		pasteAction.setActionDefinitionId(pasteActionDefId);

		copyAction = new TaskEditorCopyAction();
		copyAction.setText(
                WorkbenchMessages.Workbench_copy);
		copyAction.setImageDescriptor(WorkbenchImages.getImageDescriptor(
			ISharedImages.IMG_TOOL_COPY));
		copyAction.setHoverImageDescriptor(WorkbenchImages.getImageDescriptor(
			ISharedImages.IMG_TOOL_COPY));
		copyAction.setDisabledImageDescriptor(WorkbenchImages.getImageDescriptor(
			ISharedImages.IMG_TOOL_COPY_DISABLED));
		copyAction.setAccelerator(SWT.CTRL | 'c');

		copyAction.setEnabled(false);
		MylarTasksPlugin.getTaskListManager().addListener(TASK_LIST_LISTENER);
	}
	@Override
	public void doSave(IProgressMonitor monitor) {
		// don't support saving
	}
	@Override
	public void doSaveAs() {
		// don't support saving
	}
	@Override
	public void init(IEditorSite site, IEditorInput input) throws PartInitException {
		if (!(input instanceof TaskEditorInput)) {
			throw new PartInitException("Invalid Input: Must be TaskEditorInput");
		}
		setSite(site);
		setInput(input);
		editorInput = (TaskEditorInput)input;
		setPartName(editorInput.getLabel());
	}
	@Override
	public boolean isDirty() {
		return false;
	}
	@Override
	public boolean isSaveAsAllowed() {
		return false;
	}
	
	@Override
	public void createPartControl(Composite parent) {
//		ManagedForm form = new ManagedForm(parent);
//		FormToolkit toolkit = form.getToolkit();
//		editorComposite = form.getForm();
		FormToolkit toolkit = new FormToolkit(parent.getDisplay());
		sform = toolkit.createScrolledForm(parent);
		sform.getBody().setLayout(new TableWrapLayout());
		editorComposite = sform.getBody();
		
		
		TableWrapLayout layout = new TableWrapLayout();
		layout.bottomMargin = 10;
		layout.topMargin = 10;
		layout.leftMargin = 10;
		layout.rightMargin = 10;
		layout.numColumns = 1;
		layout.makeColumnsEqualWidth = true;
		layout.verticalSpacing = 20;
		layout.horizontalSpacing = 10;
		editorComposite.setLayout(layout);
		//editorComposite.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));				
		
		// Put the info onto the editor
		createContent(editorComposite, toolkit);
	}

	@Override
	public void setFocus() {
		// don't care when the focus is set
	}

	/**
	 * @return Returns the editorComposite.
	 */
	public Composite getEditorComposite() {
		return editorComposite;
	}

	public Control getControl() {
		return sform;
	}
	
	public void setTask(ITask task) throws Exception {
		if (task == null)
			throw new Exception("ITask object is null.");
		this.task = task;
	}
	
	private Composite createContent(Composite parent, FormToolkit toolkit) {				
		TaskEditorInput taskEditorInput = (TaskEditorInput)getEditorInput();
		
		task = taskEditorInput.getTask();
		if (task == null) {
			MessageDialog.openError(parent.getShell(), "No such task", "No task exists with this id");
			return null;
		}		
        
		try {
			createTaskSection(parent, toolkit);		
			createNotesSection(parent, toolkit);
			createPlanningGameSection(parent, toolkit);
	        createRelatedLinksSection(parent, toolkit);
	        createDetailsSection(parent, toolkit);
        } catch (SWTException e) {
        	MylarPlugin.log(e, "content failed");
        }	       
		return null;
	}
	
	private void createTaskSection(Composite parent, FormToolkit toolkit) {
		Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR);
		section.setText("Mylar Task Description");
		section.setLayout(new TableWrapLayout());
		section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
		section.addExpansionListener(new IExpansionListener() {
			public void expansionStateChanging(ExpansionEvent e) {
				sform.reflow(true);
			}
			public void expansionStateChanged(ExpansionEvent e) {
				sform.reflow(true);
			}			
		});
		
		Composite container = toolkit.createComposite(section);
		section.setClient(container);		
		TableWrapLayout layout = new TableWrapLayout();
		layout.numColumns = 3;						
		container.setLayout(layout);
		
        Label l = toolkit.createLabel(container, "Description:");
        l.setForeground(toolkit.getColors().getColor(FormColors.TITLE));	        
        description = toolkit.createText(container,task.getLabel(), SWT.BORDER);
        TableWrapData td = new TableWrapData(TableWrapData.FILL_GRAB);
        td.colspan = 2;
        description.setLayoutData(td);
        if (task.canEditDescription()) {
        	description.setEnabled(false);
        } else {
        	description.addFocusListener(new FocusListener() {
    			public void focusGained(FocusEvent e) {
    				// don't care about focus gained
    			}

    			public void focusLost(FocusEvent e) {
    				String label = description.getText();
    				task.setLabel(label);
    				refreshTaskListView(task);
    			}			
    		});
        }        
	}	
	
//	private String formatPath(String path) {
//		if (path == null) return "";
//		StringBuffer result = new StringBuffer(path.length() + 10);		
//		for (int i = 0; i < path.length(); i++) {
//			if (path.charAt(i) == '\\'){
//				result.append('/');
//			} else {
//				result.append(path.charAt(i));
//			}
//		}
//		
//		return result.toString();
//	}	
	
	private void createNotesSection(Composite parent, FormToolkit toolkit) {
		Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR);
		section.setText("Notes");			
		section.setLayout(new TableWrapLayout());
		section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
		section.addExpansionListener(new IExpansionListener() {
			public void expansionStateChanging(ExpansionEvent e) {
				sform.reflow(true);
			}

			public void expansionStateChanged(ExpansionEvent e) {
				sform.reflow(true);
			}			
		});
		Composite container = toolkit.createComposite(section);			
		section.setClient(container);		
		TableWrapLayout layout = new TableWrapLayout();
		layout.numColumns = 2;					
		container.setLayout(layout);
		
		final Text text = toolkit.createText(container, task.getNotes(), SWT.BORDER | SWT.MULTI);
		TableWrapData tablewrap = new TableWrapData(TableWrapData.FILL_GRAB);
		tablewrap.heightHint = 100;
		text.setLayoutData(tablewrap);
		text.addFocusListener(new FocusListener() {
			public void focusGained(FocusEvent e) {
				// don't care about focus gained
			}

			public void focusLost(FocusEvent e) {
				String notes = text.getText();
				task.setNotes(notes);
			}			
		});
	}
	
	private void createPlanningGameSection(Composite parent, FormToolkit toolkit) {
		Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR | Section.TWISTIE);
		section.setText("Planning Game");			
		section.setLayout(new TableWrapLayout());
		section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
		section.addExpansionListener(new IExpansionListener() {
			public void expansionStateChanging(ExpansionEvent e) {
				sform.reflow(true);
			}

			public void expansionStateChanged(ExpansionEvent e) {
				sform.reflow(true);
			}			
		});
		Composite container = toolkit.createComposite(section);			
		section.setClient(container);		
		TableWrapLayout layout = new TableWrapLayout();
		layout.numColumns = 2;					
		container.setLayout(layout);
		
		Label l = toolkit.createLabel(container, "Estimated Time:");		
		l.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
		final Text text = toolkit.createText(container,task.getEstimatedTime(), SWT.BORDER);	        
        text.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
        
        text.addFocusListener(new FocusListener() {
			public void focusGained(FocusEvent e) {
				// don't care about focus gained
			}

			public void focusLost(FocusEvent e) {
				String estimate = text.getText();
				task.setEstimatedTime(estimate);
			}			
		});
		
		l = toolkit.createLabel(container, "Elapsed Time:");		
		l.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
		Text text2 = toolkit.createText(container,task.getElapsedTimeForDisplay(), SWT.BORDER);	        
        text2.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
        text2.setEditable(false);
        text2.setEnabled(false);
        //text2.setForeground(background);
	}
	
	private void createRelatedLinksSection(Composite parent, FormToolkit toolkit) {
		Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR | Section.TWISTIE);
		section.setText("Related Links");			
		section.setLayout(new TableWrapLayout());
		section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
		section.addExpansionListener(new IExpansionListener() {
			public void expansionStateChanging(ExpansionEvent e) {
				sform.reflow(true);
			}

			public void expansionStateChanged(ExpansionEvent e) {
				sform.reflow(true);
			}			
		});
		Composite container = toolkit.createComposite(section);			
		section.setClient(container);		
		TableWrapLayout layout = new TableWrapLayout();
		layout.numColumns = 2;					
		container.setLayout(layout);			
		
		Label l = toolkit.createLabel(container, "Related Links:");
		l.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
		toolkit.createLabel(container, "");
		
		createTable(container, toolkit);
		createTableViewer(container, toolkit);		
		toolkit.paintBordersFor(container);
		createAddDeleteButtons(container, toolkit);
	}

	private void createTable(Composite parent, FormToolkit toolkit) {	
		table = toolkit.createTable(parent, SWT.NONE );		
		TableColumn col1 = new TableColumn(table, SWT.NULL);
		TableLayout tlayout = new TableLayout();
		tlayout.addColumnData(new ColumnWeightData(0,0,false));
		table.setLayout(tlayout);
		TableWrapData wd = new TableWrapData(TableWrapData.FILL_GRAB);
		wd.heightHint = 100;
		wd.grabVertical = true;
		table.setLayoutData(wd);
		table.setHeaderVisible(false);
		col1.addSelectionListener(new SelectionAdapter() {			
			@Override
			public void widgetSelected(SelectionEvent e) {
				tableViewer.setSorter(new RelatedLinksTableSorter(
						RelatedLinksTableSorter.LABEL));
			}
		});			
		table.addMouseTrackListener(new MouseTrackListener() {
			public void mouseEnter(MouseEvent e) {
				if(!((RelatedLinksContentProvider)tableViewer.getContentProvider()).isEmpty()) {
					Cursor hyperlinkCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
					Display.getCurrent().getCursorControl().setCursor(hyperlinkCursor);
				}				
			}

			public void mouseExit(MouseEvent e) {
				Cursor pointer = new Cursor(Display.getCurrent(), SWT.CURSOR_ARROW);
				Display.getCurrent().getCursorControl().setCursor(pointer);
			}

			public void mouseHover(MouseEvent e){
				if(!((RelatedLinksContentProvider)tableViewer.getContentProvider()).isEmpty()) {
					Cursor hyperlinkCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
					Display.getCurrent().getCursorControl().setCursor(hyperlinkCursor);
				}
			}
		});		
	}
	
	private void createTableViewer(Composite parent, FormToolkit toolkit) {
		String[] columnNames = {"Links"};	
		tableViewer = new TableViewer(table);
		tableViewer.setColumnProperties(columnNames);
		
		CellEditor[] editors = new CellEditor[columnNames.length];
		
		TextCellEditor textEditor = new TextCellEditor(table);
		((Text) textEditor.getControl()).setTextLimit(50);
		((Text) textEditor.getControl()).setOrientation(SWT.LEFT_TO_RIGHT);
		editors[0] = textEditor;		
		
		tableViewer.setCellEditors(editors);
		tableViewer.setCellModifier(new RelatedLinksCellModifier());
		contentProvider = new RelatedLinksContentProvider();
		tableViewer.setContentProvider(contentProvider);
		tableViewer.setLabelProvider(new RelatedLinksLabelProvider());
		links = task.getRelatedLinks();
		tableViewer.setInput(links);
		defineActions();
		hookContextMenu();
	}	
	private void createAddDeleteButtons(Composite parent, FormToolkit toolkit) {
		Composite container = toolkit.createComposite(parent);
		container.setLayout(new GridLayout(1, true));
		Button addButton = toolkit.createButton(container, "  Add  ", SWT.PUSH | SWT.CENTER);
		//add.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
		addButton.addSelectionListener(new SelectionAdapter() {			
			@Override
			public void widgetSelected(SelectionEvent e) {
				addLink();	
			}
		});

		Button deleteButton = toolkit.createButton(container, "Delete", SWT.PUSH | SWT.CENTER);
		deleteButton.setText("Delete");
		//delete.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
		deleteButton.addSelectionListener(new SelectionAdapter() {
			
			@Override
			public void widgetSelected(SelectionEvent e) {
				removeLink();
			}
		});
	}	
	
	private void createDetailsSection(Composite parent, FormToolkit toolkit) {
		Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR | Section.TWISTIE);
		section.setText("Details");
		section.setLayout(new TableWrapLayout());
		section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
		section.addExpansionListener(new IExpansionListener() {
			public void expansionStateChanging(ExpansionEvent e) {
				sform.reflow(true);
			}
			public void expansionStateChanged(ExpansionEvent e) {
				sform.reflow(true);
			}			
		});
		
		Composite container = toolkit.createComposite(section);
		section.setClient(container);
		TableWrapLayout layout = new TableWrapLayout();
		layout.numColumns = 3;						
		container.setLayout(layout);
		
		Label l = toolkit.createLabel(container, "Task Handle:");
        l.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
        Text handle = toolkit.createText(container, task.getHandle(), SWT.BORDER);
        TableWrapData td = new TableWrapData(TableWrapData.FILL_GRAB);
        td.colspan = 2;
        handle.setLayoutData(td);
        handle.setEditable(false);
        handle.setEnabled(false);
              		
		
        Label l2 = toolkit.createLabel(container, "Task context path:");
        l2.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
        pathText = toolkit.createText(container, "<Mylar_Dir>/"+task.getPath()+".xml", SWT.BORDER);
        pathText.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
        pathText.setEditable(false);        
        pathText.setEnabled(false);
        
        browse = toolkit.createButton(container, "Change", SWT.PUSH | SWT.CENTER);
        if (task.isActive()) {
        	browse.setEnabled(false);
        } else {
        	browse.setEnabled(true);
        }		
		browse.addSelectionListener(new SelectionAdapter() {			
			@Override
			public void widgetSelected(SelectionEvent e) {
				
				if (task.isActive()) {
					MessageDialog.openInformation(
							Display.getDefault().getActiveShell(),
				            "Task Message",
				            "Task can not be active when changing taskscape");
				} else {
					FileDialog dialog = new FileDialog(Display.getDefault()
							.getActiveShell(), SWT.OPEN);
					String[] ext = { "*.xml" };
					dialog.setFilterExtensions(ext);

					String mylarDir = MylarPlugin.getTaskscapeManager()
							.getMylarDir()
							+ "/";
					mylarDir = mylarDir.replaceAll("\\\\", "/");
					// mylarDir = formatPath(mylarDir);
					dialog.setFilterPath(mylarDir);

					String res = dialog.open();
					if (res != null) {
						res = res.replaceAll("\\\\", "/");
						res = RelativePathUtil.findRelativePath(mylarDir, res);
						pathText.setText("<MylarDir>/" + res + ".xml");
						task.setPath(res);
					}
				}
			}
		});
		toolkit.createLabel(container, "");
		l = toolkit.createLabel(container, "Go to Mylar Preferences to change <Mylar_Dir>");
        l.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
	}
	
	private void refreshTaskListView(ITask task) {
		if (TaskListView.getDefault() != null) TaskListView.getDefault().notifyTaskDataChanged(task);
	}
	private class RelatedLinksCellModifier implements ICellModifier, IColorProvider {
		RelatedLinksCellModifier() {
			super();

		}
		public boolean canModify(Object element, String property) {
			return true;
		}
		public Object getValue(Object element, String property) {			
			Object res = null;
			if (element instanceof String) {								
				String url = (String) element;
				try {					
					IWebBrowser b = null;
					int flags = 0;
					if (WorkbenchBrowserSupport.getInstance()
							.isInternalWebBrowserAvailable()) {
						flags = WorkbenchBrowserSupport.AS_EDITOR
								| WorkbenchBrowserSupport.LOCATION_BAR
								| WorkbenchBrowserSupport.NAVIGATION_BAR;

					} else {
						flags = WorkbenchBrowserSupport.AS_EXTERNAL
								| WorkbenchBrowserSupport.LOCATION_BAR
								| WorkbenchBrowserSupport.NAVIGATION_BAR;
					}
					b = WorkbenchBrowserSupport.getInstance().createBrowser(
							flags, "org.eclipse.mylar.tasks", "Task", "tasktooltip");
					b.openURL(new URL((String) element));					
				} catch (PartInitException e) {
					MessageDialog.openError( Display.getDefault().getActiveShell(), 
							"URL not found", url + " could not be opened");
				} catch (MalformedURLException e) {
					MessageDialog.openError( Display.getDefault().getActiveShell(), 
							"URL not found", url + " could not be opened");
				}
				res = (String) element;
			}			
			return res;
		}
		public void modify(Object element, String property, Object value) {			
			return;
		}
		
		public Color getForeground(Object element) {
			return HYPERLINK;
		}
		
		public Color getBackground(Object element) {
			return null;
		}
	}
	
	private class RelatedLinksLabelProvider extends LabelProvider implements
			ITableLabelProvider, IColorProvider {
		
		public RelatedLinksLabelProvider() {
			// don't have any initialization to do
		}
		public String getColumnText(Object obj, int columnIndex) {
			String result = "";
			if (obj instanceof String) {
				switch (columnIndex) {
				case 0:
					result = (String) obj;
					break;
				default:
					break;
				}
			}
			return result;
		}
		public Image getColumnImage(Object obj, int columnIndex) {			
			return null;
		}
		public Color getForeground(Object element) {
			return HYPERLINK;
		}
		
		public Color getBackground(Object element) {
			return null;
		}
	}

	private class RelatedLinksContentProvider implements
			IStructuredContentProvider {

		public Object[] getElements(Object inputElement) {
			return links.getLinks().toArray();
		}
		public void dispose() {
			// don't care if we are disposed
		}
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
			// don't care if the input chages
		}
		public boolean isEmpty() {
			return links.getLinks().isEmpty();
		}
	}
	
	private class RelatedLinksTableSorter extends ViewerSorter {

		public final static int LABEL = 1;
		private int criteria;

		public RelatedLinksTableSorter(int criteria) {
			super();
			this.criteria = criteria;
		}
		
		@Override
		public int compare(Viewer viewer, Object o1, Object o2) {
			String s1 = (String) o1;
			String s2 = (String) o2;			
			switch (criteria) {
				case LABEL:
					return compareLabel(s1, s2);
				default:
					return 0;
			}
		}
		protected int compareLabel(String s1, String s2) {
			return s1.compareTo(s2);
		}				
		public int getCriteria() {
			return criteria;
		}
	}
	
	private void addLink() {
		InputDialog dialog = new InputDialog(Display.getDefault().getActiveShell(), "New related link", 
				"Enter new related link for this task", "", null);
		dialog.open();
		String url = null;
		String link = dialog.getValue();
		if (!(link.startsWith("http://") || link.startsWith("https://"))) {
			url = "http://" + link;					
		} else {
			url = link;
		}
		links.add(url);
		tableViewer.add(url);	
	}
	
	private void removeLink() {
		String url = (String) ((IStructuredSelection) tableViewer
				.getSelection()).getFirstElement();
		if (url != null) {
			links.remove(url);
			tableViewer.remove(url);
		}
	}
	private void defineActions() {		  
        delete = new Action() {
			@Override
			public void run() {
				removeLink();
			}
		};
        delete.setText("Delete");
        delete.setToolTipText("Delete");
        delete.setImageDescriptor(TaskListImages.REMOVE);
        
        add = new Action() {
			@Override
			public void run() {
				addLink();
			}
		};
		add.setText("Add");
		add.setToolTipText("Add");
		//add.setImageDescriptor(MylarImages.REMOVE);
	}
	
	private void hookContextMenu() {
        MenuManager menuMgr = new MenuManager("#PopupMenu");
        menuMgr.setRemoveAllWhenShown(true);
        menuMgr.addMenuListener(new IMenuListener() {
            public void menuAboutToShow(IMenuManager manager) {
            	manager.add(add);
                manager.add(delete);
            }
        });
        Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
        tableViewer.getControl().setMenu(menu);
        //getSite().registerContextMenu(menuMgr, tableViewer);
    }
	
	

	

	
	// Eric's Old Code...
	//
	
	//private StringBuffer sb;
	//private MenuManager contextMenuManager;
	//private final String VALUE = "VALUE";
	//private final String PROPERTY = "PROPERTY";
	//private final String HEADER = "HEADER";
	//private Color foreground;
	//private StringBuffer commentBuffer;
	//private int index;
	//private ArrayList<StyledText> texts = new ArrayList<StyledText>();
	//private StyledText currentSelectedText;
	//private Font titleFont;
	//private Font textFont;
	//private int scrollIncrement;
	//private int scrollVertPageIncrement;
	//private int scrollHorzPageIncrement;
	//private ScrolledComposite scrolledComposite;
	//private Display display;
	//private CLabel titleLabel;
	//private Composite infoArea;
	//private final int HORZ_INDENT = 0;
	//private final int HORZ_TABLE_SPACING = 10;
	
//	
//	private void focusOn(StyledText newText, int caretOffset) {
//		if (newText == null)
//			return;
//		newText.setFocus();
//		newText.setCaretOffset(caretOffset);
//		scrolledComposite.setOrigin(0, newText.getLocation().y);
//	}
//	
//	/**
//	 * Find the next text
//	 */
//	private StyledText nextText(StyledText text) {
//		int index = 0;
//		if (text == null)
//			return texts.get(0);
//		else
//			index = texts.indexOf(text);
//
//		//If we are not at the end....
//		if (index < texts.size() - 1)
//			return texts.get(index + 1);
//		else
//			return texts.get(index);
//	}
//
//	/**
//	 * Find the previous text
//	 */
//	private StyledText previousText(StyledText text) {
//		int index = 0;
//		if (text == null)
//			return texts.get(0);
//		else
//			index = texts.indexOf(text);
//
//		//If we are not at the end....
//		if (index == 0)
//			return texts.get(0);
//		else
//			return texts.get(index - 1);
//	}
//
//	protected StyledText getCurrentText() {
//		return currentSelectedText;
//	}
//
//	protected TaskEditorCopyAction getCopyAction() {
//		return copyAction;
//	}
//
//	private void addTextListeners(StyledText styledText) {
//		styledText.addTraverseListener(new TraverseListener() {
//			public void keyTraversed(TraverseEvent e) {
//				StyledText text = (StyledText) e.widget;
//
//				switch (e.detail) {
//					case SWT.TRAVERSE_ESCAPE :
//						e.doit = true;
//						break;
//					case SWT.TRAVERSE_TAB_NEXT :
//
//						text.setSelection(0);
//						StyledText nextText = nextText(text);
//						focusOn(nextText, 0);
//
//						e.detail = SWT.TRAVERSE_NONE;
//						e.doit = true;
//						break;
//
//					case SWT.TRAVERSE_TAB_PREVIOUS :
//
//						text.setSelection(text.getSelection());
//						StyledText previousText = previousText(text);
//						focusOn(previousText, 0);
//
//						e.detail = SWT.TRAVERSE_NONE;
//						e.doit = true;
//						break;
//
//					default:
//						break;
//				}
//			}
//		});
//
//		styledText.addKeyListener(new KeyListener() {
//			public void keyReleased(KeyEvent e) {
//				//Ignore a key release
//			}
//
//			public void keyPressed(KeyEvent event) {
//				StyledText text = (StyledText) event.widget;
//				if (event.character == ' ' || event.character == SWT.CR) {
//					return;
//				}
//
//				if (event.keyCode == SWT.PAGE_DOWN) {
//
//					scrolledComposite.setOrigin(0,
//						scrolledComposite.getOrigin().y
//							+ scrollVertPageIncrement);
//					return;
//				}
//				if (event.keyCode == SWT.ARROW_DOWN) {
//					scrolledComposite.setOrigin(0,
//						scrolledComposite.getOrigin().y + scrollIncrement);
//				}
//				if (event.keyCode == SWT.PAGE_UP) {
//					int origin = scrolledComposite.getOrigin().y;
//					int scrollAmount = origin - scrollVertPageIncrement;
//					if (scrollAmount <= 0) {
//						scrolledComposite.setOrigin(0, 0);
//					} else {
//						scrolledComposite.setOrigin(0, scrollAmount);
//					}
//					return;
//				}
//				if (event.keyCode == SWT.ARROW_UP) {
//					scrolledComposite.setOrigin(0,
//						scrolledComposite.getOrigin().y - scrollIncrement);
//				}
//			}
//		});
//
//		styledText.addFocusListener(new FocusAdapter() {
//			
//			@Override
//			public void focusLost(FocusEvent e) {
//				StyledText text = (StyledText) e.widget;
//				text.setSelection(text.getSelection().x);
//			}
//		});
//	}
	
//	public void createLayouts(Composite composite, ITask task) {
//		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
//		String title = "Task #" + task.getId();
//		newLayout(composite, 4, title, HEADER);
//		titleLabel.setText(title);
//	}
//
//	public void displayArtifact(Composite composite) {
//		TaskEditorInput editorInput = (TaskEditorInput) getEditorInput();
//		background = JFaceColors.getBannerBackground(composite.getParent()
//				.getParent().getDisplay());
//		composite.setBackground(background);
//
//		// Get the background color for the info area
//		composite.setBackground(background);
//
//		// The entire info area is 4 columns in width
//		// all headers take up all 4, values take up 1
//		GridLayout infoLayout = new GridLayout();
//		infoLayout.numColumns = 4;
//		infoLayout.marginHeight = 10;
//		infoLayout.verticalSpacing = 6;
//
//		infoLayout.marginWidth = 5;
//		infoLayout.horizontalSpacing = HORZ_TABLE_SPACING;
//		composite.setLayout(infoLayout);
//		GridData infoData = new GridData(GridData.FILL_BOTH);
//		composite.setLayoutData(infoData);
//
//		// Create the page with the task's contents
//		task = editorInput.getTask();
//		if (task != null) {
//			createLayouts(composite, task);
//		} else {
//			MessageDialog.openError(composite.getShell(), "No such task",
//					"No task exists with this id");
//			return;
//		}
//	}
//
//	/**
//	 * Make sure that a String that is <code>null</code> is changed to a null
//	 * string
//	 * 
//	 * @param text
//	 *            The text to check if it is null or not
//	 * @return
//	 */
//	public String checkText(String text) {
//		if (text == null)
//			return "";
//		else
//			return text;
//	}
//
//	
//	//
////	public void newLayout(Composite composite, int colSpan, String text, String style) {
////		GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
////		data.horizontalSpan = colSpan;
////		if (style.equalsIgnoreCase(VALUE)) {
////			StyledText styledText = new StyledText(composite, SWT.MULTI | SWT.READ_ONLY);
////			styledText.setFont(textFont);
////			styledText.setText(checkText(text));
////			styledText.setBackground(background);
////			data.horizontalIndent = HORZ_INDENT;
////
////			styledText.setLayoutData(data);
////			styledText.addSelectionListener(new SelectionAdapter() {
////				
////				@Override
////				public void widgetSelected(SelectionEvent e) {
////					StyledText c = (StyledText) e.widget;
////					if (c != null && c.getSelectionCount() > 0) {
////						if (currentSelectedText != null) {
////							if (!c.equals(currentSelectedText)) {
////								currentSelectedText.setSelectionRange(0, 0);
////							}
////						}
////					}
////					currentSelectedText = c;
////				}
////			});
////
////			styledText.setMenu(contextMenuManager.createContextMenu(styledText));
////
////			styledText.setEditable(false);
////
////			if (styledText.getText().trim().length() > 0) {
////				texts.add(index, styledText);
////				index++;
////				addTextListeners(styledText);
////			}
////		} else if (style.equalsIgnoreCase(PROPERTY)) {
////			StyledText styledText = new StyledText(composite, SWT.MULTI | SWT.READ_ONLY);
////			styledText.setFont(textFont);
////			styledText.setText(checkText(text));
////			styledText.setBackground(background);
////			data.horizontalIndent = HORZ_INDENT;
////			styledText.setLayoutData(data);
////			StyleRange sr = new StyleRange(
////					styledText.getOffsetAtLine(0),
////					text.length(),
////					foreground,
////					background,
////					SWT.BOLD);
////			styledText.setStyleRange(sr);
////			styledText.setEnabled(false);
////			styledText.setMenu(contextMenuManager.createContextMenu(styledText));
////		} else {
////			Composite generalTitleGroup = new Composite(composite, SWT.NONE);
////			generalTitleGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
//			generalTitleGroup.setLayoutData(data);
//			GridLayout generalTitleLayout = new GridLayout();
//			generalTitleLayout.numColumns = 2;
//			generalTitleLayout.marginWidth = 0;
//			generalTitleLayout.marginHeight = 9;
//			generalTitleGroup.setLayout(generalTitleLayout);
//			generalTitleGroup.setBackground(background);
//
//			Label image = new Label(generalTitleGroup, SWT.NONE);
//			image.setBackground(background);
//			image.setImage(
//				WorkbenchImages.getImage(IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_ITEM));
//			GridData gd = new GridData(GridData.FILL_VERTICAL);
//			gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
//			image.setLayoutData(gd);
//			StyledText generalTitleText = new StyledText(generalTitleGroup, SWT.MULTI | SWT.READ_ONLY);
//			generalTitleText.setText(checkText(text));
//			generalTitleText.setBackground(background);
//			StyleRange sr =	new StyleRange(
//					generalTitleText.getOffsetAtLine(0),
//					text.length(),
//					foreground,
//					background,
//					SWT.BOLD);
//			generalTitleText.setStyleRange(sr);
//			generalTitleText.setEditable(false);
//			
//			generalTitleText.addSelectionListener(new SelectionAdapter() {
//				
//				@Override
//				public void widgetSelected(SelectionEvent e) {
//					StyledText c = (StyledText) e.widget;
//					if (c != null && c.getSelectionCount() > 0) {
//						if (currentSelectedText != null) {
//							if (!c.equals(currentSelectedText)) {
//								currentSelectedText.setSelectionRange(0, 0);
//							}
//						}
//					}
//					currentSelectedText = c;
//				}
//			});
//			
//			// create context menu
//			generalTitleGroup.setMenu(contextMenuManager.createContextMenu(generalTitleGroup));
//			generalTitleText.setMenu(contextMenuManager.createContextMenu(generalTitleText));
//			image.setMenu(contextMenuManager.createContextMenu(image));
//		}
//	}
	
//	private Composite createTitleArea(Composite parent) {
	//
//			// Get the background color for the title area
//			display = parent.getDisplay();
//			Color background = JFaceColors.getBannerBackground(display);
//			Color foreground = JFaceColors.getBannerForeground(display);
//			
//			// Create the title area which will contain
//			// a title, message, and image.
//			Composite titleArea = new Composite(parent, SWT.NO_FOCUS);
//			GridLayout layout = new GridLayout();
//			layout.marginHeight = 0;
//			layout.marginWidth = 0;
//			layout.verticalSpacing = 0;
//			layout.horizontalSpacing = 0;
//			layout.numColumns = 2;
//			titleArea.setLayout(layout);
//			titleArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
//			titleArea.setBackground(background);
//			
//			// Message label
//			titleLabel = new CLabel(titleArea, SWT.LEFT);
//			JFaceColors.setColors(titleLabel, foreground, background);
//			titleLabel.setFont(titleFont);
//			final IPropertyChangeListener fontListener = new IPropertyChangeListener() {
//				public void propertyChange(PropertyChangeEvent event) {
//					if (JFaceResources.HEADER_FONT.equals(event.getProperty())) {
//						titleLabel.setFont(titleFont);
//					}
//				}
//			};
//			titleLabel.addDisposeListener(new DisposeListener() {
//				public void widgetDisposed(DisposeEvent event) {
//					JFaceResources.getFontRegistry().removeListener(fontListener);
//				}
//			});
//			JFaceResources.getFontRegistry().addListener(fontListener);
//			GridData gd = new GridData(GridData.FILL_BOTH);
//			titleLabel.setLayoutData(gd);
	//
//			// Title image
//			Label titleImage = new Label(titleArea, SWT.LEFT);
//			titleImage.setBackground(background);
//			titleImage.setImage(
//				WorkbenchImages.getImage(
//						IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_BANNER));
//			gd = new GridData();
//			gd.horizontalAlignment = GridData.END;
//			titleImage.setLayoutData(gd);
//			return titleArea;
//		}
	//
//		private Composite createInfoArea(Composite parent) {
//			// Create the title area which will contain a title, message, and image.
//			scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
//			scrolledComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
//			infoArea = new Composite(this.scrolledComposite, SWT.NONE);
//			scrolledComposite.setMinSize(infoArea.computeSize(SWT.DEFAULT, SWT.DEFAULT));
	//
//			contextMenuManager = new MenuManager("#TaskSummaryEditor");
//			contextMenuManager.setRemoveAllWhenShown(true);
//			contextMenuManager.addMenuListener(new IMenuListener() {
//				public void menuAboutToShow(IMenuManager manager) {
//					manager.add(cutAction);
//					manager.add(copyAction);
//					manager.add(pasteAction);
//					manager.add(new Separator());
//					manager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
//					if (currentSelectedText == null || 
//							currentSelectedText.getSelectionText().length() == 0) {
//						copyAction.setEnabled(false);
//					}
//					else {
//						copyAction.setEnabled(true);
//					}
//				}
//			});
//			getSite().registerContextMenu(
//				"#TaskSummaryEditor",
//				contextMenuManager,
//				getSite().getSelectionProvider());
	//
//			displayArtifact(infoArea);
//			this.scrolledComposite.setContent(infoArea);
//			Point p = infoArea.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
//			this.scrolledComposite.setMinHeight(p.y);
//			this.scrolledComposite.setMinWidth(p.x);
//			this.scrolledComposite.setExpandHorizontal(true);
//			this.scrolledComposite.setExpandVertical(true);
	//
//			// Add the focus listener to the scrolled composite
//			scrolledComposite.addMouseListener(new MouseAdapter() {
//				
//				@Override
//				public void mouseUp(MouseEvent e) {
//					if (!texts.isEmpty()) {
//						StyledText target = texts.get(0);
//						target.setFocus();
//					} else {
//						scrolledComposite.setFocus();
//					}
//				}
//			});
	//
//			scrolledComposite.addControlListener(new ControlListener() {
//				public void controlMoved(ControlEvent e) {
//					// don't care if a control is moved
//				}
//				public void controlResized(ControlEvent e) {
//					scrolledComposite.getVerticalBar().setIncrement(scrollIncrement);
//					scrolledComposite.getHorizontalBar().setIncrement(scrollIncrement);
//					scrollVertPageIncrement = scrolledComposite.getClientArea().height;
//					scrollHorzPageIncrement = scrolledComposite.getClientArea().width;
//					scrolledComposite.getVerticalBar().setPageIncrement(scrollVertPageIncrement);
//					scrolledComposite.getHorizontalBar().setPageIncrement(scrollHorzPageIncrement);
//				}
//			});
//			return infoArea;
//		}
}

Back to the top