diff options
author | relves | 2007-01-16 21:43:00 +0000 |
---|---|---|
committer | relves | 2007-01-16 21:43:00 +0000 |
commit | 9ed4a4ecd0aeb771903158cbe69677174cde995e (patch) | |
tree | d35135b69af6943c4c562bc8cbecf8cd62baa271 | |
parent | 233992048e6e0676ebb6ff9feb08b770181d1a50 (diff) | |
download | org.eclipse.mylyn.tasks-9ed4a4ecd0aeb771903158cbe69677174cde995e.tar.gz org.eclipse.mylyn.tasks-9ed4a4ecd0aeb771903158cbe69677174cde995e.tar.xz org.eclipse.mylyn.tasks-9ed4a4ecd0aeb771903158cbe69677174cde995e.zip |
REOPENED - bug 170684: Attributes section not expanding in some cases
https://bugs.eclipse.org/bugs/show_bug.cgi?id=170684
2 files changed, 121 insertions, 80 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java index e03e03f20..f197f26f8 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java @@ -112,29 +112,31 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor { // compareInput = new BugzillaCompareInput(config); } -// @Override -// public void init(IEditorSite site, IEditorInput input) { -// super.init(site, input); -// -// if (!(input instanceof RepositoryTaskEditorInput)) { -// return; -// } -// super.init(site, input); -// -// editorInput = (AbstractTaskEditorInput) input; -// taskData = editorInput.getTaskData(); -// repository = editorInput.getRepository(); -// connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getKind()); -// -// setSite(site); -// setInput(input); -// -// taskOutlineModel = RepositoryTaskOutlineNode.parseBugReport(editorInput.getTaskData()); -// -// // restoreBug(); -// isDirty = false; -// updateEditorTitle(); -// } + // @Override + // public void init(IEditorSite site, IEditorInput input) { + // super.init(site, input); + // + // if (!(input instanceof RepositoryTaskEditorInput)) { + // return; + // } + // super.init(site, input); + // + // editorInput = (AbstractTaskEditorInput) input; + // taskData = editorInput.getTaskData(); + // repository = editorInput.getRepository(); + // connector = + // TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getKind()); + // + // setSite(site); + // setInput(input); + // + // taskOutlineModel = + // RepositoryTaskOutlineNode.parseBugReport(editorInput.getTaskData()); + // + // // restoreBug(); + // isDirty = false; + // updateEditorTitle(); + // } @Override protected void createCustomAttributeLayout(Composite composite) { @@ -151,23 +153,11 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor { GridData textData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); textData.horizontalSpan = 1; textData.widthHint = 135; - RepositoryTaskAttribute attribute = this.taskData.getAttribute( - BugzillaReportElement.DEPENDSON.getKeyString()); + RepositoryTaskAttribute attribute = this.taskData.getAttribute(BugzillaReportElement.DEPENDSON.getKeyString()); if (!attribute.isReadOnly()) { final Text text = createTextField(textFieldComposite, attribute, SWT.FLAT); text.setLayoutData(textData); toolkit.paintBordersFor(textFieldComposite); - text.setData(attribute); - text.addListener(SWT.KeyUp, new Listener() { - public void handleEvent(Event event) { - String sel = text.getText(); - RepositoryTaskAttribute a = (RepositoryTaskAttribute) text.getData(); - if (!(a.getValue().equals(sel))) { - a.setValue(sel); - markDirty(true); - } - } - }); text.addListener(SWT.FocusIn, new GenericListener()); } @@ -184,23 +174,9 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor { textData.widthHint = 135; attribute = this.taskData.getAttribute(BugzillaReportElement.BLOCKED.getKeyString()); if (!attribute.isReadOnly()) { - final Text text = toolkit.createText(textFieldComposite, attribute.getValue(), SWT.FLAT); - // if(attribute.hasChanged()) { - // text.setBackground(TaskListColorsAndFonts.COLOR_ATTRIBUTE_CHANGED); - // } + final Text text = createTextField(textFieldComposite, attribute, SWT.FLAT); text.setLayoutData(textData); toolkit.paintBordersFor(textFieldComposite); - text.setData(attribute); - text.addListener(SWT.KeyUp, new Listener() { - public void handleEvent(Event event) { - String sel = text.getText(); - RepositoryTaskAttribute a = (RepositoryTaskAttribute) text.getData(); - if (!(a.getValue().equals(sel))) { - a.setValue(sel); - markDirty(true); - } - } - }); text.addListener(SWT.FocusIn, new GenericListener()); } @@ -251,8 +227,8 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor { addKeywordsList(composite); } catch (IOException e) { MessageDialog.openInformation(null, "Attribute Display Error", - "Could not retrieve keyword list, ensure proper configuration in " + TasksUiPlugin.LABEL_VIEW_REPOSITORIES - + "\n\nError reported: " + e.getMessage()); + "Could not retrieve keyword list, ensure proper configuration in " + + TasksUiPlugin.LABEL_VIEW_REPOSITORIES + "\n\nError reported: " + e.getMessage()); } label = toolkit.createLabel(composite, BugzillaReportElement.BUG_FILE_LOC.toString()); @@ -260,14 +236,16 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor { attribute = this.taskData.getAttribute(BugzillaReportElement.BUG_FILE_LOC.getKeyString()); Text urlField = createTextField(composite, attribute, SWT.FLAT); GridDataFactory.fillDefaults().hint(135, SWT.DEFAULT).applyTo(urlField); -// TextViewer viewer = addTextEditor(repository, composite, attribute.getValue(), false, SWT.SINGLE); -// viewer.setEditable(true); -// GridDataFactory.fillDefaults().hint(DESCRIPTION_WIDTH, SWT.DEFAULT).applyTo(viewer.getTextWidget()); - + // TextViewer viewer = addTextEditor(repository, composite, + // attribute.getValue(), false, SWT.SINGLE); + // viewer.setEditable(true); + // GridDataFactory.fillDefaults().hint(DESCRIPTION_WIDTH, + // SWT.DEFAULT).applyTo(viewer.getTextWidget()); addVoting(composite); label = toolkit.createLabel(composite, ""); + Hyperlink viewActivity = toolkit.createHyperlink(composite, "Show Bug Activity", SWT.NONE); viewActivity.addHyperlinkListener(new HyperlinkAdapter() { @Override @@ -285,6 +263,48 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor { } + // @Override + // protected Control createActionsTextClient(Section section) { + // Hyperlink hyperlink = + // super.getManagedForm().getToolkit().createHyperlink(section, "Past + // activity", SWT.NONE); + // hyperlink.setBackground(section.getBackground()); + // hyperlink.addHyperlinkListener(new HyperlinkAdapter() { + // @Override + // public void linkActivated(HyperlinkEvent e) { + // if (BugzillaTaskEditor.this.getEditor() instanceof TaskEditor) { + // TaskEditor mylarTaskEditor = (TaskEditor) + // BugzillaTaskEditor.this.getEditor(); + // mylarTaskEditor.displayInBrowser(repository.getUrl() + + // IBugzillaConstants.URL_BUG_ACTIVITY + // + taskData.getId()); + // } + // } + // }); + // return hyperlink; + // } + + private boolean hasCustomAttributeChanges() { + if (taskData == null) + return false; + String customAttributeKeys[] = { BugzillaReportElement.BUG_FILE_LOC.getKeyString(), + BugzillaReportElement.DEPENDSON.getKeyString(), BugzillaReportElement.BLOCKED.getKeyString(), + BugzillaReportElement.KEYWORDS.getKeyString(), BugzillaReportElement.VOTES.getKeyString() }; + for (String key : customAttributeKeys) { + RepositoryTaskAttribute attribute = taskData.getAttribute(key); + if (hasChanged(attribute)) { + return true; + } + } + return false; + } + + @Override + protected boolean hasVisibleAttributeChanges() { + return super.hasChanges || this.hasCustomAttributeChanges(); + + } + // protected void createDependencyLayout(Composite composite) { // FormToolkit toolkit = getManagedForm().getToolkit(); // final Section section = createSection(composite, "Dependencies"); @@ -433,8 +453,8 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor { timeComposite.setLayoutData(gd); toolkit.createLabel(timeComposite, BugzillaReportElement.ESTIMATED_TIME.toString()); - estimateText = toolkit.createText(timeComposite, taskData.getAttributeValue(BugzillaReportElement.ESTIMATED_TIME - .getKeyString()), SWT.BORDER); + estimateText = toolkit.createText(timeComposite, taskData + .getAttributeValue(BugzillaReportElement.ESTIMATED_TIME.getKeyString()), SWT.BORDER); estimateText.setFont(TEXT_FONT); estimateText.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); estimateText.addModifyListener(new ModifyListener() { @@ -445,9 +465,12 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor { }); toolkit.createLabel(timeComposite, "Current Estimate:"); - Text currentEstimate = toolkit.createText(timeComposite, "" - + (Float.parseFloat(taskData.getAttributeValue(BugzillaReportElement.ACTUAL_TIME.getKeyString())) + Float - .parseFloat(taskData.getAttributeValue(BugzillaReportElement.REMAINING_TIME.getKeyString())))); + Text currentEstimate = toolkit.createText(timeComposite, + "" + + (Float.parseFloat(taskData + .getAttributeValue(BugzillaReportElement.ACTUAL_TIME.getKeyString())) + Float + .parseFloat(taskData.getAttributeValue(BugzillaReportElement.REMAINING_TIME + .getKeyString())))); currentEstimate.setFont(TEXT_FONT); currentEstimate.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); currentEstimate.setEditable(false); @@ -473,8 +496,8 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor { }); toolkit.createLabel(timeComposite, BugzillaReportElement.REMAINING_TIME.toString()); - remainingText = toolkit.createText(timeComposite, taskData.getAttributeValue(BugzillaReportElement.REMAINING_TIME - .getKeyString()), SWT.BORDER); + remainingText = toolkit.createText(timeComposite, taskData + .getAttributeValue(BugzillaReportElement.REMAINING_TIME.getKeyString()), SWT.BORDER); remainingText.setFont(TEXT_FONT); remainingText.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); remainingText.addModifyListener(new ModifyListener() { @@ -594,8 +617,9 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor { votingComposite.setLayout(layout); // GridDataFactory.fillDefaults().span(2, 1).applyTo(votingComposite); RepositoryTaskAttribute votesAttribute = taskData.getAttribute(BugzillaReportElement.VOTES.getKeyString()); - String voteValue = votesAttribute != null ? votesAttribute.getValue() : "0"; - votesText = toolkit.createText(votingComposite, voteValue); + // String voteValue = votesAttribute != null ? votesAttribute.getValue() + // : "0"; + votesText = createTextField(votingComposite, votesAttribute, SWT.FLAT); votesText.setFont(TEXT_FONT); if (votesAttribute != null && hasChanged(votesAttribute)) { @@ -631,7 +655,6 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor { }); } - // @Override // protected void restoreBug() { // @@ -721,8 +744,7 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor { if (keyWordsList.getSelectionCount() == 1) { int index = keyWordsList.getSelectionIndex(); String keyword = keyWordsList.getItem(index); - if (taskData.getAttributeValue(BugzillaReportElement.KEYWORDS.getKeyString()).equals( - keyword)) + if (taskData.getAttributeValue(BugzillaReportElement.KEYWORDS.getKeyString()).equals(keyword)) keyWordsList.deselectAll(); } @@ -808,8 +830,7 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor { urlText.addListener(SWT.KeyUp, new Listener() { public void handleEvent(Event event) { String sel = urlText.getText(); - RepositoryTaskAttribute a = taskData.getAttribute( - BugzillaReportElement.BUG_FILE_LOC.getKeyString()); + RepositoryTaskAttribute a = taskData.getAttribute(BugzillaReportElement.BUG_FILE_LOC.getKeyString()); if (!(a.getValue().equals(sel))) { a.setValue(sel); markDirty(true); @@ -819,7 +840,6 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor { urlText.addListener(SWT.FocusIn, new GenericListener()); } - // protected void createDescriptionLayout(Composite composite) { // // This is migration code from 0.6.1 -> 0.6.2 // // Changes to the abstract editor causes the description diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java index 915a2459e..1768ef0be 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java @@ -487,12 +487,11 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { repository = editorInput.getRepository(); taskData = editorInput.getTaskData(); connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getKind()); - setSite(site); setInput(input); taskOutlineModel = RepositoryTaskOutlineNode.parseBugReport(taskData); - + hasChanges = hasVisibleAttributeChanges(); isDirty = false; updateEditorTitle(); } @@ -533,6 +532,8 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { private Color backgroundIncoming; + protected boolean hasChanges = false; + /** * Creates a new <code>AbstractRepositoryTaskEditor</code>. Sets up the * default fonts and cut/copy/paste actions. @@ -706,9 +707,17 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { */ protected Composite createAttributeLayout(Composite composite) { String title = getTitleString(); - Section section = createSection(composite, LABEL_SECTION_ATTRIBUTES); - section.setExpanded(expandedStateAttributes || hasAttributeChanges()); + section.setExpanded(expandedStateAttributes || hasChanges); + if (hasChanges) { + IThemeManager themeManager = getSite().getWorkbenchWindow().getWorkbench().getThemeManager(); + backgroundIncoming = themeManager.getCurrentTheme().getColorRegistry().get( + TaskListColorsAndFonts.THEME_COLOR_TASKS_INCOMING_BACKGROUND); + // TODO: Use darker color (this color isn't different enough from + // regular header color) + section.setTitleBarBackground(backgroundIncoming); + } + // Attributes Composite- this holds all the combo fields and text fields Composite attributesComposite = toolkit.createComposite(section); GridLayout attributesLayout = new GridLayout(); @@ -1714,6 +1723,7 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { protected void createActionsLayout(Composite composite) { Section section = createSection(composite, LABEL_SECTION_ACTIONS); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, true).applyTo(section); + section.setTextClient(createActionsTextClient(section)); Composite buttonComposite = toolkit.createComposite(section); GridLayout buttonLayout = new GridLayout(); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).applyTo(buttonComposite); @@ -1724,6 +1734,13 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { section.setClient(buttonComposite); } + /** + * Override to contribute controls to Action section's title area + */ + protected Control createActionsTextClient(Section section) { + return null; + } + protected Section createSection(Composite composite, String title) { Section section = toolkit.createSection(composite, ExpandableComposite.TITLE_BAR | Section.TWISTIE); section.setText(title); @@ -2339,11 +2356,15 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { toolkit.paintBordersFor(buttonComposite); } - protected boolean hasAttributeChanges() { - RepositoryTaskData newTaskData = editorInput.getTaskData(); - if (newTaskData == null) + /** + * If implementing custom attributes you may need to override this method + * + * @return true if one or more attributes exposed in the editor have changed + */ + protected boolean hasVisibleAttributeChanges() { + if (taskData == null) return false; - for (RepositoryTaskAttribute attribute : newTaskData.getAttributes()) { + for (RepositoryTaskAttribute attribute : taskData.getAttributes()) { if (!attribute.isHidden()) { if (hasChanged(attribute)) { return true; |