|
Lines 12-21
Link Here
|
| 12 |
import java.util.ArrayList; |
12 |
import java.util.ArrayList; |
| 13 |
import java.util.Calendar; |
13 |
import java.util.Calendar; |
| 14 |
import java.util.Date; |
14 |
import java.util.Date; |
| 15 |
import java.util.Iterator; |
15 |
import java.util.List; |
| 16 |
import java.util.Set; |
16 |
import java.util.Set; |
| 17 |
import java.util.StringTokenizer; |
|
|
| 18 |
|
17 |
|
|
|
18 |
import org.eclipse.jface.dialogs.Dialog; |
| 19 |
import org.eclipse.jface.dialogs.MessageDialog; |
19 |
import org.eclipse.jface.dialogs.MessageDialog; |
| 20 |
import org.eclipse.jface.layout.GridDataFactory; |
20 |
import org.eclipse.jface.layout.GridDataFactory; |
| 21 |
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin; |
21 |
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin; |
|
Lines 48-55
Link Here
|
| 48 |
import org.eclipse.swt.widgets.Button; |
48 |
import org.eclipse.swt.widgets.Button; |
| 49 |
import org.eclipse.swt.widgets.Composite; |
49 |
import org.eclipse.swt.widgets.Composite; |
| 50 |
import org.eclipse.swt.widgets.Label; |
50 |
import org.eclipse.swt.widgets.Label; |
| 51 |
import org.eclipse.swt.widgets.List; |
51 |
import org.eclipse.swt.widgets.Shell; |
| 52 |
import org.eclipse.swt.widgets.Text; |
52 |
import org.eclipse.swt.widgets.Text; |
|
|
53 |
import org.eclipse.ui.PlatformUI; |
| 53 |
import org.eclipse.ui.forms.IFormColors; |
54 |
import org.eclipse.ui.forms.IFormColors; |
| 54 |
import org.eclipse.ui.forms.editor.FormEditor; |
55 |
import org.eclipse.ui.forms.editor.FormEditor; |
| 55 |
import org.eclipse.ui.forms.events.HyperlinkAdapter; |
56 |
import org.eclipse.ui.forms.events.HyperlinkAdapter; |
|
Lines 61-66
Link Here
|
| 61 |
import org.eclipse.ui.forms.widgets.Section; |
62 |
import org.eclipse.ui.forms.widgets.Section; |
| 62 |
import org.eclipse.ui.themes.IThemeManager; |
63 |
import org.eclipse.ui.themes.IThemeManager; |
| 63 |
|
64 |
|
|
|
65 |
|
| 64 |
/** |
66 |
/** |
| 65 |
* An editor used to view a bug report that exists on a server. It uses a <code>BugReport</code> object to store the |
67 |
* An editor used to view a bug report that exists on a server. It uses a <code>BugReport</code> object to store the |
| 66 |
* data. |
68 |
* data. |
|
Lines 73-84
Link Here
|
| 73 |
|
75 |
|
| 74 |
private static final String LABEL_TIME_TRACKING = "Bugzilla Time Tracking"; |
76 |
private static final String LABEL_TIME_TRACKING = "Bugzilla Time Tracking"; |
| 75 |
|
77 |
|
| 76 |
// protected BugzillaCompareInput compareInput; |
|
|
| 77 |
|
| 78 |
// protected Button compareButton; |
| 79 |
|
| 80 |
protected List keyWordsList; |
| 81 |
|
| 82 |
protected Text keywordsText; |
78 |
protected Text keywordsText; |
| 83 |
|
79 |
|
| 84 |
protected Text estimateText; |
80 |
protected Text estimateText; |
|
Lines 521-530
Link Here
|
| 521 |
|
517 |
|
| 522 |
protected void addKeywordsList(Composite attributesComposite) throws IOException { |
518 |
protected void addKeywordsList(Composite attributesComposite) throws IOException { |
| 523 |
// newLayout(attributesComposite, 1, "Keywords:", PROPERTY); |
519 |
// newLayout(attributesComposite, 1, "Keywords:", PROPERTY); |
| 524 |
RepositoryTaskAttribute attribute = taskData.getAttribute(RepositoryTaskAttribute.KEYWORDS); |
520 |
final RepositoryTaskAttribute attribute = taskData.getAttribute(RepositoryTaskAttribute.KEYWORDS); |
| 525 |
if (attribute == null) |
521 |
if (attribute == null) |
| 526 |
return; |
522 |
return; |
| 527 |
String keywords = attribute.getValue(); |
|
|
| 528 |
Label label = createLabel(attributesComposite, attribute); |
523 |
Label label = createLabel(attributesComposite, attribute); |
| 529 |
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label); |
524 |
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label); |
| 530 |
|
525 |
|
|
Lines 538-588
Link Here
|
| 538 |
keywordsData.horizontalSpan = 2; |
533 |
keywordsData.horizontalSpan = 2; |
| 539 |
keywordsData.widthHint = 200; |
534 |
keywordsData.widthHint = 200; |
| 540 |
keywordsText.setLayoutData(keywordsData); |
535 |
keywordsText.setLayoutData(keywordsData); |
| 541 |
// keywordsText.setText(keywords); |
536 |
|
| 542 |
keyWordsList = new List(attributesComposite, SWT.MULTI | SWT.V_SCROLL); |
537 |
|
| 543 |
keyWordsList.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); |
538 |
Button changeKeywordsButton = getManagedForm().getToolkit().createButton(attributesComposite, "Edit...", SWT.FLAT); |
| 544 |
keyWordsList.setFont(TEXT_FONT); |
539 |
GridData keyWordsButtonData = new GridData(); |
| 545 |
GridData keyWordsTextData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); |
540 |
changeKeywordsButton.setLayoutData(keyWordsButtonData); |
| 546 |
keyWordsTextData.horizontalSpan = 1; |
541 |
changeKeywordsButton.addSelectionListener(new SelectionListener(){ |
| 547 |
keyWordsTextData.widthHint = 125; |
542 |
|
| 548 |
keyWordsTextData.heightHint = 40; |
543 |
public void widgetDefaultSelected(SelectionEvent e) {} |
| 549 |
keyWordsList.setLayoutData(keyWordsTextData); |
544 |
|
| 550 |
|
545 |
public void widgetSelected(SelectionEvent e) { |
| 551 |
// initialize the keywords list with valid values |
546 |
|
| 552 |
|
547 |
String keywords = attribute.getValue(); |
| 553 |
java.util.List<String> validKeywords = new ArrayList<String>(); |
548 |
|
| 554 |
try { |
549 |
Shell shell = null; |
| 555 |
validKeywords = BugzillaCorePlugin.getRepositoryConfiguration(repository, false).getKeywords(); |
550 |
if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) { |
| 556 |
} catch (Exception e) { |
551 |
shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); |
| 557 |
// ignore |
552 |
} else { |
| 558 |
} |
553 |
shell = new Shell(PlatformUI.getWorkbench().getDisplay()); |
| 559 |
|
554 |
} |
| 560 |
if (validKeywords != null) { |
555 |
|
| 561 |
for (Iterator<String> it = validKeywords.iterator(); it.hasNext();) { |
556 |
List<String> validKeywords = new ArrayList<String>(); |
| 562 |
String keyword = it.next(); |
557 |
try { |
| 563 |
keyWordsList.add(keyword); |
558 |
validKeywords = BugzillaCorePlugin.getRepositoryConfiguration(repository, false).getKeywords(); |
| 564 |
} |
559 |
} catch (Exception ex) { |
| 565 |
|
560 |
// ignore |
| 566 |
// get the selected keywords for the bug |
561 |
} |
| 567 |
StringTokenizer st = new StringTokenizer(keywords, ",", false); |
562 |
|
| 568 |
ArrayList<Integer> indicies = new ArrayList<Integer>(); |
563 |
KeywordsDialog keywordsDialog = new KeywordsDialog(shell, keywords, validKeywords); |
| 569 |
while (st.hasMoreTokens()) { |
564 |
int responseCode = keywordsDialog.open(); |
| 570 |
String s = st.nextToken().trim(); |
565 |
|
| 571 |
int index = keyWordsList.indexOf(s); |
566 |
String newKeywords = keywordsDialog.getSelectedKeywordsString(); |
| 572 |
if (index != -1) |
567 |
if (responseCode == Dialog.OK && keywords != null) { |
| 573 |
indicies.add(new Integer(index)); |
568 |
keywordsText.setText(newKeywords); |
| 574 |
} |
569 |
attribute.setValue(newKeywords); |
| 575 |
|
570 |
attributeChanged(attribute); |
| 576 |
// select the keywords that were selected for the bug |
571 |
} else { |
| 577 |
int length = indicies.size(); |
572 |
return; |
| 578 |
int[] sel = new int[length]; |
573 |
} |
| 579 |
for (int i = 0; i < length; i++) { |
574 |
|
| 580 |
sel[i] = indicies.get(i).intValue(); |
|
|
| 581 |
} |
575 |
} |
| 582 |
keyWordsList.select(sel); |
576 |
|
| 583 |
} |
577 |
}); |
| 584 |
|
|
|
| 585 |
keyWordsList.addSelectionListener(new KeywordListener()); |
| 586 |
} |
578 |
} |
| 587 |
|
579 |
|
| 588 |
protected void addVoting(Composite attributesComposite) { |
580 |
protected void addVoting(Composite attributesComposite) { |
|
Lines 632-681
Link Here
|
| 632 |
}); |
624 |
}); |
| 633 |
} |
625 |
} |
| 634 |
|
626 |
|
| 635 |
/** |
|
|
| 636 |
* Class to handle the selection change of the keywords. |
| 637 |
*/ |
| 638 |
protected class KeywordListener implements SelectionListener { |
| 639 |
|
| 640 |
/* |
| 641 |
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) |
| 642 |
*/ |
| 643 |
public void widgetSelected(SelectionEvent arg0) { |
| 644 |
markDirty(true); |
| 645 |
|
| 646 |
// get the selected keywords and create a string to submit |
| 647 |
StringBuffer keywords = new StringBuffer(); |
| 648 |
String[] sel = keyWordsList.getSelection(); |
| 649 |
|
| 650 |
// allow unselecting 1 keyword when it is the only one selected |
| 651 |
if (keyWordsList.getSelectionCount() == 1) { |
| 652 |
int index = keyWordsList.getSelectionIndex(); |
| 653 |
String keyword = keyWordsList.getItem(index); |
| 654 |
if (taskData.getAttributeValue(BugzillaReportElement.KEYWORDS.getKeyString()).equals(keyword)) |
| 655 |
keyWordsList.deselectAll(); |
| 656 |
} |
| 657 |
|
| 658 |
for (int i = 0; i < keyWordsList.getSelectionCount(); i++) { |
| 659 |
keywords.append(sel[i]); |
| 660 |
if (i != keyWordsList.getSelectionCount() - 1) { |
| 661 |
keywords.append(","); |
| 662 |
} |
| 663 |
} |
| 664 |
|
| 665 |
taskData.setAttributeValue(BugzillaReportElement.KEYWORDS.getKeyString(), keywords.toString()); |
| 666 |
|
| 667 |
// update the keywords text field |
| 668 |
keywordsText.setText(keywords.toString()); |
| 669 |
} |
| 670 |
|
| 671 |
/* |
| 672 |
* @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) |
| 673 |
*/ |
| 674 |
public void widgetDefaultSelected(SelectionEvent arg0) { |
| 675 |
// no need to listen to this |
| 676 |
} |
| 677 |
|
| 678 |
} |
| 679 |
|
627 |
|
| 680 |
@Override |
628 |
@Override |
| 681 |
protected void validateInput() { |
629 |
protected void validateInput() { |