diff options
author | mkersten | 2005-11-07 20:43:08 +0000 |
---|---|---|
committer | mkersten | 2005-11-07 20:43:08 +0000 |
commit | 5863a0e5bb8b4443a2fdcf6102d50aae66ef1287 (patch) | |
tree | da27a92a1ede8934a860fdffd571b464d1deb4c9 | |
parent | 1f96adc4a0d0327ef422713b5a28220fdd61b331 (diff) | |
download | org.eclipse.mylyn.tasks-5863a0e5bb8b4443a2fdcf6102d50aae66ef1287.tar.gz org.eclipse.mylyn.tasks-5863a0e5bb8b4443a2fdcf6102d50aae66ef1287.tar.xz org.eclipse.mylyn.tasks-5863a0e5bb8b4443a2fdcf6102d50aae66ef1287.zip |
Removed automatic wrap for Bugzilla 2.20 compatability.
2 files changed, 456 insertions, 549 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/AbstractBugEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/AbstractBugEditor.java index c764da702..f73dfdfc1 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/AbstractBugEditor.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/AbstractBugEditor.java @@ -99,9 +99,10 @@ import org.eclipse.ui.part.EditorPart; import org.eclipse.ui.views.contentoutline.ContentOutline; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; - /** * Abstract base implementation for an editor to view a bugzilla report. + * + * @author Mik Kersten (some hardening of prototype) */ public abstract class AbstractBugEditor extends EditorPart implements Listener { @@ -109,48 +110,50 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { protected Display display; - public static final Font TITLE_FONT = JFaceResources.getHeaderFont(); - + public static final Font TITLE_FONT = JFaceResources.getHeaderFont(); + // TODO: don't use hard-coded font - public static final Font TEXT_FONT = JFaceResources.getDefaultFont(); - public static final Font COMMENT_FONT = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT); -// new Font(null, "Courier New", 9, SWT.NORMAL); - - public static final Font HEADER_FONT = JFaceResources.getDefaultFont(); - + public static final Font TEXT_FONT = JFaceResources.getDefaultFont(); + + public static final Font COMMENT_FONT = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT); + + // new Font(null, "Courier New", 9, SWT.NORMAL); + + public static final Font HEADER_FONT = JFaceResources.getDefaultFont(); + public static final int DESCRIPTION_WIDTH = 79 * 7; - + public static final int DESCRIPTION_HEIGHT = 10 * 14; - + protected Color background; protected Color foreground; protected AbstractBugEditorInput bugzillaInput; - + private BugzillaTaskEditor parentEditor = null; /** * Style option for function <code>newLayout</code>. This will create a * plain-styled, selectable text label. - */ + */ protected final String VALUE = "VALUE"; /** * Style option for function <code>newLayout</code>. This will create a * bolded, selectable header. It will also have an arrow image before the * text (simply for decoration). - */ + */ protected final String HEADER = "HEADER"; /** * Style option for function <code>newLayout</code>. This will create a * bolded, unselectable label. - */ + */ protected final String PROPERTY = "PROPERTY"; protected final int HORZ_INDENT = 0; - + protected Combo oSCombo; protected Combo versionCombo; @@ -168,26 +171,26 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { protected Text urlText; protected Text summaryText; - + protected Text assignedTo; protected Button submitButton; - -// protected Button saveButton; - + + // protected Button saveButton; + protected int scrollIncrement; protected int scrollVertPageIncrement; protected int scrollHorzPageIncrement; - + public boolean isDirty = false; - + /** Manager controlling the context menu */ protected MenuManager contextMenuManager; - + protected StyledText currentSelectedText; - + protected static final String cutActionDefId = "org.eclipse.ui.edit.cut"; //$NON-NLS-1$ protected static final String copyActionDefId = "org.eclipse.ui.edit.copy"; //$NON-NLS-1$ @@ -199,7 +202,7 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { protected BugzillaEditorCopyAction copyAction; protected RetargetAction pasteAction; - + protected Composite editorComposite; protected CLabel titleLabel; @@ -209,11 +212,11 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { protected Composite infoArea; protected Hyperlink linkToBug; - + protected StyledText generalTitleText; - + private List<IBugzillaAttributeListener> attributesListeners = new ArrayList<IBugzillaAttributeListener>(); - + protected final ISelectionProvider selectionProvider = new ISelectionProvider() { public void addSelectionChangedListener(ISelectionChangedListener listener) { selectionChangedListeners.add(listener); @@ -224,46 +227,46 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { } public void removeSelectionChangedListener(ISelectionChangedListener listener) { - selectionChangedListeners.remove(listener); + selectionChangedListeners.remove(listener); } public void setSelection(ISelection selection) { // No implementation. } }; - + protected ListenerList selectionChangedListeners = new ListenerList(); - + protected HashMap<Combo, String> comboListenerMap = new HashMap<Combo, String>(); - + private IBugzillaReportSelection lastSelected = null; - + protected final ISelectionListener selectionListener = new ISelectionListener() { public void selectionChanged(IWorkbenchPart part, ISelection selection) { if ((part instanceof ContentOutline) && (selection instanceof StructuredSelection)) { - Object select = ((StructuredSelection)selection).getFirstElement(); - if(select instanceof BugzillaOutlineNode){ - BugzillaOutlineNode n = (BugzillaOutlineNode) select; - - if (n != null && lastSelected != null && BugzillaTools.getHandle(n).equals(BugzillaTools.getHandle(lastSelected))){ - // we don't need to set the selection if it is alredy set - return; - } - lastSelected = n; - - Object data = n.getData(); - boolean highlight = true; - if(n.getKey().toLowerCase().equals("comments")){ - highlight = false; - } - if(n.getKey().toLowerCase().equals("new comment")){ - selectNewComment(); - } else if(n.getKey().toLowerCase().equals("new description")){ - selectNewDescription(); - } else if (data != null){ - select(data, highlight); - } - } + Object select = ((StructuredSelection) selection).getFirstElement(); + if (select instanceof BugzillaOutlineNode) { + BugzillaOutlineNode n = (BugzillaOutlineNode) select; + + if (n != null && lastSelected != null && BugzillaTools.getHandle(n).equals(BugzillaTools.getHandle(lastSelected))) { + // we don't need to set the selection if it is alredy set + return; + } + lastSelected = n; + + Object data = n.getData(); + boolean highlight = true; + if (n.getKey().toLowerCase().equals("comments")) { + highlight = false; + } + if (n.getKey().toLowerCase().equals("new comment")) { + selectNewComment(); + } else if (n.getKey().toLowerCase().equals("new description")) { + selectNewDescription(); + } else if (data != null) { + select(data, highlight); + } + } } } }; @@ -273,55 +276,46 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { * cut/copy/paste actions. */ public AbstractBugEditor() { - - // set the scroll increments so the editor scrolls normally with the scroll wheel - FontData[] fd = TEXT_FONT.getFontData(); - int cushion = 4; - scrollIncrement = fd[0].getHeight() + cushion; - scrollVertPageIncrement = 0; - scrollHorzPageIncrement = 0; - - // set up actions for the context menu - cutAction = new RetargetAction(ActionFactory.CUT.getId(), WorkbenchMessages.Workbench_cut); - cutAction.setToolTipText(WorkbenchMessages.Workbench_cutToolTip);//WorkbenchMessages.getString("Workbench.cutToolTip")); //$NON-NLS-1$ - 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);//WorkbenchMessages.getString("Workbench.pasteToolTip")); //$NON-NLS-1$ - 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 BugzillaEditorCopyAction(this); - copyAction.setText(WorkbenchMessages.Workbench_copy);//WorkbenchMessages.getString("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); - } + + // set the scroll increments so the editor scrolls normally with the scroll wheel + FontData[] fd = TEXT_FONT.getFontData(); + int cushion = 4; + scrollIncrement = fd[0].getHeight() + cushion; + scrollVertPageIncrement = 0; + scrollHorzPageIncrement = 0; + + // set up actions for the context menu + cutAction = new RetargetAction(ActionFactory.CUT.getId(), WorkbenchMessages.Workbench_cut); + cutAction.setToolTipText(WorkbenchMessages.Workbench_cutToolTip);//WorkbenchMessages.getString("Workbench.cutToolTip")); //$NON-NLS-1$ + 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);//WorkbenchMessages.getString("Workbench.pasteToolTip")); //$NON-NLS-1$ + 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 BugzillaEditorCopyAction(this); + copyAction.setText(WorkbenchMessages.Workbench_copy);//WorkbenchMessages.getString("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); + } /** * @return The bug this editor is displaying. */ public abstract IBugzillaBug getBug(); - + /** * @return Any currently selected text. */ @@ -347,21 +341,20 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { editorComposite.setLayout(layout); // Create the title for the editor createTitleArea(editorComposite); - Label titleBarSeparator = - new Label(editorComposite, SWT.HORIZONTAL | SWT.SEPARATOR); - + Label titleBarSeparator = new Label(editorComposite, SWT.HORIZONTAL | SWT.SEPARATOR); + background = JFaceColors.getBannerBackground(display); foreground = JFaceColors.getBannerForeground(display); GridData gd = new GridData(GridData.FILL_HORIZONTAL); titleBarSeparator.setLayoutData(gd); - + // Put the bug info onto the editor createInfoArea(editorComposite); - + WorkbenchHelpSystem.getInstance().setHelp(editorComposite, IBugzillaConstants.EDITOR_PAGE_CONTEXT); - + infoArea.setMenu(contextMenuManager.createContextMenu(infoArea)); - + getSite().getPage().addSelectionListener(selectionListener); getSite().setSelectionProvider(selectionProvider); } @@ -378,7 +371,7 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { display = parent.getDisplay(); background = JFaceColors.getBannerBackground(display); foreground = JFaceColors.getBannerForeground(display); - + // Create the title area which will contain // a title, message, and image. Composite titleArea = new Composite(parent, SWT.NO_FOCUS); @@ -391,7 +384,7 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { 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); @@ -412,13 +405,11 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { 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)); + titleImage.setImage(WorkbenchImages.getImage(IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_BANNER)); gd = new GridData(); gd.horizontalAlignment = GridData.END; titleImage.setLayoutData(gd); @@ -436,13 +427,11 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { protected Composite createInfoArea(Composite parent) { createContextMenu(); - - scrolledComposite = - new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL); + + 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)); + scrolledComposite.setMinSize(infoArea.computeSize(SWT.DEFAULT, SWT.DEFAULT)); GridLayout infoLayout = new GridLayout(); infoLayout.numColumns = 1; infoLayout.verticalSpacing = 0; @@ -451,10 +440,8 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { infoArea.setLayout(infoLayout); infoArea.setBackground(background); if (getBug() == null) { -// close(); - MessageDialog.openError( - Display.getDefault().getActiveShell(), - "Bugzilla Client Errror", + // close(); + MessageDialog.openError(Display.getDefault().getActiveShell(), "Bugzilla Client Errror", "Could not resolve the requested bug, check Bugzilla server and version."); Composite composite = new Composite(parent, SWT.NULL); @@ -470,7 +457,7 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { this.scrolledComposite.setMinWidth(p.x); this.scrolledComposite.setExpandHorizontal(true); this.scrolledComposite.setExpandVertical(true); - + // make the editor scroll properly with a scroll editor scrolledComposite.addControlListener(new ControlListener() { public void controlMoved(ControlEvent e) { @@ -478,16 +465,12 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { } public void controlResized(ControlEvent e) { - scrolledComposite.getVerticalBar() - .setIncrement(scrollIncrement); - scrolledComposite.getHorizontalBar().setIncrement( - scrollIncrement); + scrolledComposite.getVerticalBar().setIncrement(scrollIncrement); + scrolledComposite.getHorizontalBar().setIncrement(scrollIncrement); scrollVertPageIncrement = scrolledComposite.getClientArea().height; scrollHorzPageIncrement = scrolledComposite.getClientArea().width; - scrolledComposite.getVerticalBar().setPageIncrement( - scrollVertPageIncrement); - scrolledComposite.getHorizontalBar().setPageIncrement( - scrollHorzPageIncrement); + scrolledComposite.getVerticalBar().setPageIncrement(scrollVertPageIncrement); + scrolledComposite.getHorizontalBar().setPageIncrement(scrollHorzPageIncrement); } }); @@ -507,18 +490,15 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { manager.add(pasteAction); manager.add(new Separator()); manager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); - if (currentSelectedText == null || - currentSelectedText.getSelectionText().length() == 0) { - + if (currentSelectedText == null || currentSelectedText.getSelectionText().length() == 0) { + copyAction.setEnabled(false); - } - else { + } else { copyAction.setEnabled(true); } } }); - getSite().registerContextMenu("#BugEditor", contextMenuManager, - getSite().getSelectionProvider()); + getSite().registerContextMenu("#BugEditor", contextMenuManager, getSite().getSelectionProvider()); } /** @@ -537,11 +517,11 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { * of the bug (some of which are editable). */ protected void createAttributeLayout() { - + String title = getTitleString(); String keywords = ""; String url = ""; - + // Attributes Composite- this holds all the combo fiels and text // fields Composite attributesComposite = new Composite(infoArea, SWT.NONE); @@ -556,30 +536,28 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { attributesComposite.setLayoutData(attributesData); attributesComposite.setBackground(background); // End Attributes Composite - + // Attributes Title Area - Composite attributesTitleComposite = - new Composite(attributesComposite, SWT.NONE); + Composite attributesTitleComposite = new Composite(attributesComposite, SWT.NONE); GridLayout attributesTitleLayout = new GridLayout(); attributesTitleLayout.horizontalSpacing = 0; attributesTitleLayout.marginWidth = 0; attributesTitleComposite.setLayout(attributesTitleLayout); attributesTitleComposite.setBackground(background); - GridData attributesTitleData = - new GridData(GridData.HORIZONTAL_ALIGN_FILL); + GridData attributesTitleData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); attributesTitleData.horizontalSpan = 4; attributesTitleData.grabExcessVerticalSpace = false; attributesTitleComposite.setLayoutData(attributesTitleData); // End Attributes Title - + // Set the Attributes Title newAttributesLayout(attributesTitleComposite); titleLabel.setText(title); bugzillaInput.setToolTipText(title); int currentCol = 1; - + String ccValue = null; - + // Populate Attributes for (Iterator<Attribute> it = getBug().getAttributes().iterator(); it.hasNext();) { Attribute attribute = it.next(); @@ -587,7 +565,7 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { String name = attribute.getName(); String value = checkText(attribute.getValue()); Map<String, String> values = attribute.getOptionValues(); - + // make sure we don't try to display a hidden field if (attribute.isHidden() || (key != null && key.equals("status_whiteboard"))) continue; @@ -597,26 +575,22 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { if (key == null) key = ""; - + GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); data.horizontalSpan = 1; data.horizontalIndent = HORZ_INDENT; if (key.equals("short_desc") || key.equals("keywords")) { keywords = value; - } - else if (key.equals("newcc")) { + } else if (key.equals("newcc")) { ccValue = value; - if(value == null) + if (value == null) ccValue = ""; - } - else if (key.equals("bug_file_loc")) { + } else if (key.equals("bug_file_loc")) { url = value; - } - else if (key.equals("op_sys")) { + } else if (key.equals("op_sys")) { newLayout(attributesComposite, 1, name, PROPERTY); - oSCombo = new Combo(attributesComposite, SWT.NO_BACKGROUND - | SWT.MULTI | SWT.V_SCROLL | SWT.READ_ONLY); + oSCombo = new Combo(attributesComposite, SWT.NO_BACKGROUND | SWT.MULTI | SWT.V_SCROLL | SWT.READ_ONLY); oSCombo.setFont(TEXT_FONT); oSCombo.setLayoutData(data); oSCombo.setBackground(background); @@ -631,12 +605,10 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { comboListenerMap.put(oSCombo, name); oSCombo.addListener(SWT.FocusIn, new GenericListener()); currentCol += 2; - } - else if (key.equals("version")) { + } else if (key.equals("version")) { newLayout(attributesComposite, 1, name, PROPERTY); - versionCombo = new Combo(attributesComposite, SWT.NO_BACKGROUND - | SWT.MULTI | SWT.V_SCROLL | SWT.READ_ONLY); + versionCombo = new Combo(attributesComposite, SWT.NO_BACKGROUND | SWT.MULTI | SWT.V_SCROLL | SWT.READ_ONLY); versionCombo.setFont(TEXT_FONT); versionCombo.setLayoutData(data); versionCombo.setBackground(background); @@ -651,13 +623,10 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { versionCombo.addListener(SWT.FocusIn, new GenericListener()); comboListenerMap.put(versionCombo, name); currentCol += 2; - } - else if (key.equals("priority")) { + } else if (key.equals("priority")) { newLayout(attributesComposite, 1, name, PROPERTY); - priorityCombo = new Combo(attributesComposite, - SWT.NO_BACKGROUND | SWT.MULTI | SWT.V_SCROLL - | SWT.READ_ONLY); + priorityCombo = new Combo(attributesComposite, SWT.NO_BACKGROUND | SWT.MULTI | SWT.V_SCROLL | SWT.READ_ONLY); priorityCombo.setFont(TEXT_FONT); priorityCombo.setLayoutData(data); priorityCombo.setBackground(background); @@ -672,16 +641,9 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { priorityCombo.addListener(SWT.FocusIn, new GenericListener()); comboListenerMap.put(priorityCombo, name); currentCol += 2; - } - else if (key.equals("bug_severity")) { + } else if (key.equals("bug_severity")) { newLayout(attributesComposite, 1, name, PROPERTY); - severityCombo = - new Combo( - attributesComposite, - SWT.NO_BACKGROUND - | SWT.MULTI - | SWT.V_SCROLL - | SWT.READ_ONLY); + severityCombo = new Combo(attributesComposite, SWT.NO_BACKGROUND | SWT.MULTI | SWT.V_SCROLL | SWT.READ_ONLY); severityCombo.setFont(TEXT_FONT); severityCombo.setLayoutData(data); @@ -697,16 +659,9 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { severityCombo.addListener(SWT.FocusIn, new GenericListener()); comboListenerMap.put(severityCombo, name); currentCol += 2; - } - else if (key.equals("target_milestone")) { + } else if (key.equals("target_milestone")) { newLayout(attributesComposite, 1, name, PROPERTY); - milestoneCombo = - new Combo( - attributesComposite, - SWT.NO_BACKGROUND - | SWT.MULTI - | SWT.V_SCROLL - | SWT.READ_ONLY); + milestoneCombo = new Combo(attributesComposite, SWT.NO_BACKGROUND | SWT.MULTI | SWT.V_SCROLL | SWT.READ_ONLY); milestoneCombo.setFont(TEXT_FONT); milestoneCombo.setLayoutData(data); @@ -722,16 +677,9 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { milestoneCombo.addListener(SWT.FocusIn, new GenericListener()); comboListenerMap.put(milestoneCombo, name); currentCol += 2; - } - else if (key.equals("rep_platform")) { + } else if (key.equals("rep_platform")) { newLayout(attributesComposite, 1, name, PROPERTY); - platformCombo = - new Combo( - attributesComposite, - SWT.NO_BACKGROUND - | SWT.MULTI - | SWT.V_SCROLL - | SWT.READ_ONLY); + platformCombo = new Combo(attributesComposite, SWT.NO_BACKGROUND | SWT.MULTI | SWT.V_SCROLL | SWT.READ_ONLY); platformCombo.setFont(TEXT_FONT); platformCombo.setLayoutData(data); @@ -747,12 +695,11 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { platformCombo.addListener(SWT.FocusIn, new GenericListener()); comboListenerMap.put(platformCombo, name); currentCol += 2; - } - else if (key.equals("product")) { + } else if (key.equals("product")) { newLayout(attributesComposite, 1, name, PROPERTY); newLayout(attributesComposite, 1, value, VALUE).addListener(SWT.FocusIn, new GenericListener()); currentCol += 2; - } else if(key.equals("assigned_to")){ + } else if (key.equals("assigned_to")) { newLayout(attributesComposite, 1, name, PROPERTY); assignedTo = new Text(attributesComposite, SWT.BORDER | SWT.SINGLE | SWT.WRAP); assignedTo.setFont(TEXT_FONT); @@ -772,18 +719,11 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { } }); assignedTo.addListener(SWT.FocusIn, new GenericListener()); - + currentCol += 2; - } - else if (key.equals("component")) { + } else if (key.equals("component")) { newLayout(attributesComposite, 1, name, PROPERTY); - componentCombo = - new Combo( - attributesComposite, - SWT.NO_BACKGROUND - | SWT.MULTI - | SWT.V_SCROLL - | SWT.READ_ONLY); + componentCombo = new Combo(attributesComposite, SWT.NO_BACKGROUND | SWT.MULTI | SWT.V_SCROLL | SWT.READ_ONLY); componentCombo.setFont(TEXT_FONT); componentCombo.setLayoutData(data); @@ -799,12 +739,10 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { componentCombo.addListener(SWT.FocusIn, new GenericListener()); comboListenerMap.put(componentCombo, name); currentCol += 2; - } - else if (name.equals("Summary")) { + } else if (name.equals("Summary")) { // Don't show the summary here. continue; - } - else if (values.isEmpty()) { + } else if (values.isEmpty()) { newLayout(attributesComposite, 1, name, PROPERTY); newLayout(attributesComposite, 1, value, VALUE).addListener(SWT.FocusIn, new GenericListener()); currentCol += 2; @@ -814,7 +752,7 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { } } // End Populate Attributes - + // make sure that we are in the first column if (currentCol > 1) { while (currentCol <= attributesLayout.numColumns) { @@ -822,13 +760,13 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { currentCol++; } } - + // URL, Keywords, Summary Text Fields addUrlText(url, attributesComposite); - + // keywords text field (not editable) addKeywordsList(keywords, attributesComposite); - if(ccValue != null){ + if (ccValue != null) { addCCList(ccValue, attributesComposite); } addSummaryText(attributesComposite); @@ -845,8 +783,7 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { */ protected void addUrlText(String url, Composite attributesComposite) { newLayout(attributesComposite, 1, "URL:", PROPERTY); - urlText = - new Text(attributesComposite, SWT.BORDER | SWT.SINGLE | SWT.WRAP); + urlText = new Text(attributesComposite, SWT.BORDER | SWT.SINGLE | SWT.WRAP); urlText.setFont(TEXT_FONT); GridData urlTextData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); urlTextData.horizontalSpan = 3; @@ -878,7 +815,7 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { protected abstract void addKeywordsList(String keywords, Composite attributesComposite); protected abstract void addCCList(String value, Composite attributesComposite); - + /** * Adds a text field to display and edit the bug's summary. * @@ -887,8 +824,7 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { */ protected void addSummaryText(Composite attributesComposite) { newLayout(attributesComposite, 1, "Summary:", PROPERTY); - summaryText = - new Text(attributesComposite, SWT.BORDER | SWT.SINGLE | SWT.WRAP); + summaryText = new Text(attributesComposite, SWT.BORDER | SWT.SINGLE | SWT.WRAP); summaryText.setFont(TEXT_FONT); GridData summaryTextData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); summaryTextData.horizontalSpan = 3; @@ -957,21 +893,21 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { }); submitButton.addListener(SWT.FocusIn, new GenericListener()); -// This is not needed anymore since we have the save working properly with ctrl-s and file->save -// saveButton = new Button(buttonComposite, SWT.NONE); -// saveButton.setFont(TEXT_FONT); -// GridData saveButtonData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); -// saveButtonData.widthHint = 100; -// saveButtonData.heightHint = 20; -// saveButton.setText("Save Offline"); -// saveButton.setLayoutData(saveButtonData); -// saveButton.addListener(SWT.Selection, new Listener() { -// public void handleEvent(Event e) { -// saveBug(); -// updateEditor(); -// } -// }); -// saveButton.addListener(SWT.FocusIn, new GenericListener()); + // This is not needed anymore since we have the save working properly with ctrl-s and file->save + // saveButton = new Button(buttonComposite, SWT.NONE); + // saveButton.setFont(TEXT_FONT); + // GridData saveButtonData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + // saveButtonData.widthHint = 100; + // saveButtonData.heightHint = 20; + // saveButton.setText("Save Offline"); + // saveButton.setLayoutData(saveButtonData); + // saveButton.addListener(SWT.Selection, new Listener() { + // public void handleEvent(Event e) { + // saveBug(); + // updateEditor(); + // } + // }); + // saveButton.addListener(SWT.FocusIn, new GenericListener()); } /** @@ -989,7 +925,7 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { else return text; } - + /** * @return A string to use as a title for this editor. */ @@ -1013,15 +949,13 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { * @see PROPERTY * @see HEADER */ - protected StyledText newLayout(Composite composite, int colSpan, String text, - String style) { + protected StyledText newLayout(Composite composite, int colSpan, String text, String style) { GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); data.horizontalSpan = colSpan; - - StyledText stext; + + StyledText stext; if (style.equalsIgnoreCase(VALUE)) { - StyledText styledText = - new StyledText(composite, SWT.MULTI | SWT.READ_ONLY); + StyledText styledText = new StyledText(composite, SWT.MULTI | SWT.READ_ONLY); styledText.setFont(TEXT_FONT); styledText.setText(checkText(text)); styledText.setBackground(background); @@ -1029,9 +963,9 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { styledText.setLayoutData(data); styledText.setEditable(false); styledText.getCaret().setVisible(false); - + styledText.addSelectionListener(new SelectionAdapter() { - + @Override public void widgetSelected(SelectionEvent e) { StyledText c = (StyledText) e.widget; @@ -1045,38 +979,26 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { currentSelectedText = c; } }); - - styledText.setMenu( - contextMenuManager.createContextMenu(styledText)); - stext = styledText; - } - else if (style.equalsIgnoreCase(PROPERTY)) { - StyledText styledText = - new StyledText(composite, SWT.MULTI | SWT.READ_ONLY); + + styledText.setMenu(contextMenuManager.createContextMenu(styledText)); + stext = styledText; + } else if (style.equalsIgnoreCase(PROPERTY)) { + StyledText styledText = new StyledText(composite, SWT.MULTI | SWT.READ_ONLY); styledText.setFont(TEXT_FONT); 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); + StyleRange sr = new StyleRange(styledText.getOffsetAtLine(0), text.length(), foreground, background, SWT.BOLD); styledText.setStyleRange(sr); styledText.getCaret().setVisible(false); styledText.setEnabled(false); - styledText.setMenu(contextMenuManager.createContextMenu(styledText)); - stext = styledText; - } - else { + stext = styledText; + } else { Composite generalTitleGroup = new Composite(composite, SWT.NONE); - generalTitleGroup.setLayoutData( - new GridData(GridData.FILL_HORIZONTAL)); + generalTitleGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); generalTitleGroup.setLayoutData(data); GridLayout generalTitleLayout = new GridLayout(); generalTitleLayout.numColumns = 2; @@ -1084,32 +1006,24 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { 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)); + image.setImage(WorkbenchImages.getImage(IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_ITEM)); GridData gd = new GridData(GridData.FILL_BOTH); gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING; image.setLayoutData(gd); - StyledText titleText = - new StyledText(generalTitleGroup, SWT.MULTI | SWT.READ_ONLY); + StyledText titleText = new StyledText(generalTitleGroup, SWT.MULTI | SWT.READ_ONLY); titleText.setText(checkText(text)); titleText.setFont(HEADER_FONT); titleText.setBackground(background); - StyleRange sr = new StyleRange( - titleText.getOffsetAtLine(0), - text.length(), - foreground, - background, - SWT.BOLD); + StyleRange sr = new StyleRange(titleText.getOffsetAtLine(0), text.length(), foreground, background, SWT.BOLD); titleText.setStyleRange(sr); titleText.getCaret().setVisible(false); titleText.setEditable(false); titleText.addSelectionListener(new SelectionAdapter() { - + @Override public void widgetSelected(SelectionEvent e) { StyledText c = (StyledText) e.widget; @@ -1124,16 +1038,13 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { } }); // create context menu - generalTitleGroup.setMenu( - contextMenuManager.createContextMenu(generalTitleGroup)); - titleText.setMenu( - contextMenuManager.createContextMenu(titleText)); - image.setMenu( - contextMenuManager.createContextMenu(image)); - stext = titleText; + generalTitleGroup.setMenu(contextMenuManager.createContextMenu(generalTitleGroup)); + titleText.setMenu(contextMenuManager.createContextMenu(titleText)); + image.setMenu(contextMenuManager.createContextMenu(image)); + stext = titleText; } composite.setMenu(contextMenuManager.createContextMenu(composite)); - return stext; + return stext; } /** @@ -1149,8 +1060,7 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); data.horizontalSpan = 4; Composite generalTitleGroup = new Composite(composite, SWT.NONE); - generalTitleGroup.setLayoutData( - new GridData(GridData.FILL_HORIZONTAL)); + generalTitleGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); generalTitleGroup.setLayoutData(data); GridLayout generalTitleLayout = new GridLayout(); generalTitleLayout.numColumns = 3; @@ -1158,24 +1068,21 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { 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)); - + image.setImage(WorkbenchImages.getImage(IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_ITEM)); + GridData gd = new GridData(GridData.FILL_BOTH); gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING; image.setLayoutData(gd); - generalTitleText = - new StyledText(generalTitleGroup, SWT.MULTI | SWT.READ_ONLY); + generalTitleText = new StyledText(generalTitleGroup, SWT.MULTI | SWT.READ_ONLY); generalTitleText.setBackground(background); generalTitleText.getCaret().setVisible(false); generalTitleText.setEditable(false); generalTitleText.addSelectionListener(new SelectionAdapter() { - + @Override public void widgetSelected(SelectionEvent e) { StyledText c = (StyledText) e.widget; @@ -1190,22 +1097,18 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { } }); // create context menu - generalTitleGroup.setMenu( - contextMenuManager.createContextMenu(generalTitleGroup)); - generalTitleText.setMenu( - contextMenuManager.createContextMenu(generalTitleText)); - - linkToBug = - new Hyperlink(generalTitleGroup, SWT.MULTI | SWT.READ_ONLY); + generalTitleGroup.setMenu(contextMenuManager.createContextMenu(generalTitleGroup)); + generalTitleText.setMenu(contextMenuManager.createContextMenu(generalTitleText)); + + linkToBug = new Hyperlink(generalTitleGroup, SWT.MULTI | SWT.READ_ONLY); linkToBug.setBackground(background); setGeneralTitleText(); - image.setMenu( - contextMenuManager.createContextMenu(image)); + image.setMenu(contextMenuManager.createContextMenu(image)); composite.setMenu(contextMenuManager.createContextMenu(composite)); } - + /** * This refreshes the text in the title label of the info area (it contains * elements which can change). @@ -1214,45 +1117,43 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { String text = "[Open in Browser]"; linkToBug.setText(text); linkToBug.setFont(TEXT_FONT); - if(this instanceof ExistingBugEditor){ + if (this instanceof ExistingBugEditor) { linkToBug.setUnderlined(true); linkToBug.setForeground(JFaceColors.getHyperlinkText(Display.getCurrent())); - linkToBug.addMouseListener(new MouseListener(){ - - public void mouseDoubleClick(MouseEvent e) {} - public void mouseUp(MouseEvent e) {} - + linkToBug.addMouseListener(new MouseListener() { + + public void mouseDoubleClick(MouseEvent e) { + } + + public void mouseUp(MouseEvent e) { + } + public void mouseDown(MouseEvent e) { BugzillaUITools.openUrl(getTitle(), getTitleToolTip(), BugzillaRepository.getBugUrlWithoutLogin(bugzillaInput.getBug().getId())); - if(e.stateMask == SWT.MOD3){ + if (e.stateMask == SWT.MOD3) { // XXX come back to look at this ui close(); } - + } }); - } else{ + } else { linkToBug.setEnabled(false); } linkToBug.addListener(SWT.FocusIn, new GenericListener()); - + // Resize the composite, in case the new summary is longer than the // previous one. // Then redraw it to show the changes. linkToBug.getParent().pack(true); linkToBug.redraw(); - + text = getTitleString(); generalTitleText.setText(text); - StyleRange sr = new StyleRange( - generalTitleText.getOffsetAtLine(0), - text.length(), - foreground, - background, - SWT.BOLD); + StyleRange sr = new StyleRange(generalTitleText.getOffsetAtLine(0), text.length(), foreground, background, SWT.BOLD); generalTitleText.setStyleRange(sr); generalTitleText.addListener(SWT.FocusIn, new GenericListener()); - + // Resize the composite, in case the new summary is longer than the // previous one. // Then redraw it to show the changes. @@ -1285,7 +1186,7 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { * Submit the changes to the bug to the bugzilla server. */ protected abstract void submitBug(); - + /** * If there is no locally saved copy of the current bug, then it saved * offline. Otherwise, any changes are updated in the file. @@ -1294,34 +1195,34 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { try { updateBug(); IBugzillaBug bug = getBug(); - - if(bug.hasChanges()){ + + if (bug.hasChanges()) { BugzillaPlugin.getDefault().fireOfflineStatusChanged(bug, BugzillaOfflineStaus.SAVED_WITH_OUTGOING_CHANGES); } else { BugzillaPlugin.getDefault().fireOfflineStatusChanged(bug, BugzillaOfflineStaus.SAVED); } - + changeDirtyStatus(false); OfflineView.saveOffline(getBug(), true); } catch (Exception e) { MylarPlugin.fail(e, "bug save offline failed", true); } -// OfflineView.checkWindow(); -// OfflineView.refreshView(); + // OfflineView.checkWindow(); + // OfflineView.refreshView(); } - + /** * Updates the <code>IBugzillaBug</code> object to contain the latest data * entered in the data fields. */ protected abstract void updateBug(); - + /** * Resets the data fields to contain the data currently in the * <code>IBugzillaBug</code> object. */ protected abstract void restoreBug(); - + /** * Refreshes any text labels in the editor that contain information that * might change. @@ -1331,23 +1232,27 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { // been edited. String title = getTitleString(); titleLabel.setText(title); - setGeneralTitleText(); + setGeneralTitleText(); } - + /** - * Break text up into lines of about 80 characters so that it - * is displayed properly in bugzilla + * Break text up into lines of about 80 characters so that it is displayed + * properly in bugzilla + * * @param origText The string to be formatted * @return The formatted text */ - protected String formatText(String origText) - { - String [] textArray = new String[(origText.length()/WRAP_LENGTH + 1) *2]; - for(int i = 0; i < textArray.length; i++) + protected String formatText(String origText) { + if (BugzillaPlugin.getDefault().isServerCompatability220()) { + return origText; + } + + String[] textArray = new String[(origText.length() / WRAP_LENGTH + 1) * 2]; + for (int i = 0; i < textArray.length; i++) textArray[i] = null; int j = 0; - while(true) { - int spaceIndex = origText.indexOf(" ", WRAP_LENGTH-5); + while (true) { + int spaceIndex = origText.indexOf(" ", WRAP_LENGTH - 5); if (spaceIndex == origText.length() || spaceIndex == -1) { textArray[j] = origText; break; @@ -1356,17 +1261,17 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { origText = origText.substring(spaceIndex + 1, origText.length()); j++; } - + String newText = ""; - + for (int i = 0; i < textArray.length; i++) { - if(textArray[i] == null) + if (textArray[i] == null) break; newText += textArray[i] + "\n"; } return newText; } - + /** * function to set the url to post the bug to * @param form A reference to a BugPost that the bug is going to be posted to @@ -1378,8 +1283,7 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { baseURL += "/"; try { form.setURL(baseURL + formName); - } - catch (MalformedURLException e){ + } catch (MalformedURLException e) { // we should be ok here } @@ -1387,12 +1291,12 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { form.add("Bugzilla_login", BugzillaPreferencePage.getUserName()); form.add("Bugzilla_password", BugzillaPreferencePage.getPassword()); } - + @Override public void setFocus() { scrolledComposite.setFocus(); } - + @Override public boolean isDirty() { return isDirty; @@ -1413,10 +1317,9 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { } else { parentEditor.updatePartName(); } - + } - - + /** * Updates the title of the editor to reflect dirty status. * If the bug report has been modified but not saved, then @@ -1425,34 +1328,34 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { protected void updateEditorTitle() { setPartName(bugzillaInput.getName()); } - + @Override public boolean isSaveAsAllowed() { return false; } - + @Override public void doSave(IProgressMonitor monitor) { saveBug(); updateEditor(); - + // XXX notify that saved ofline? } - + @Override public void doSaveAs() { // we don't save, so no need to implement } - + /** * @return The composite for the whole editor. */ public Composite getEditorComposite() { return editorComposite; } - + @Override - public void dispose() { + public void dispose() { super.dispose(); isDisposed = true; getSite().getPage().removeSelectionListener(selectionListener); @@ -1460,13 +1363,13 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { public void handleEvent(Event event) { if (event.widget instanceof Combo) { - Combo combo = (Combo)event.widget; + Combo combo = (Combo) event.widget; if (comboListenerMap.containsKey(combo)) { String sel = combo.getItem(combo.getSelectionIndex()); Attribute a = getBug().getAttribute(comboListenerMap.get(combo)); if (!(a.getNewValue().equals(sel))) { - a.setNewValue(sel); - for(IBugzillaAttributeListener client : attributesListeners) { + a.setNewValue(sel); + for (IBugzillaAttributeListener client : attributesListeners) { client.attributeChanged(a.getName(), sel); } changeDirtyStatus(true); @@ -1483,15 +1386,15 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { * The selection event. */ protected void fireSelectionChanged(final SelectionChangedEvent event) { - Object[] listeners = selectionChangedListeners.getListeners(); - for (int i = 0; i < listeners.length; i++) { - final ISelectionChangedListener l = (ISelectionChangedListener) listeners[i]; - SafeRunnable.run(new SafeRunnable() { - public void run() { - l.selectionChanged(event); - } - }); - } + Object[] listeners = selectionChangedListeners.getListeners(); + for (int i = 0; i < listeners.length; i++) { + final ISelectionChangedListener l = (ISelectionChangedListener) listeners[i]; + SafeRunnable.run(new SafeRunnable() { + public void run() { + l.selectionChanged(event); + } + }); + } } /** @@ -1501,7 +1404,8 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { protected class GenericListener implements Listener { public void handleEvent(Event event) { IBugzillaBug bug = getBug(); - fireSelectionChanged(new SelectionChangedEvent(selectionProvider, new StructuredSelection(new BugzillaReportSelection(bug.getId(), bug.getServer(), bug.getLabel(), false, bug.getSummary())))); + fireSelectionChanged(new SelectionChangedEvent(selectionProvider, new StructuredSelection(new BugzillaReportSelection(bug.getId(), bug.getServer(), + bug.getLabel(), false, bug.getSummary())))); } } @@ -1519,44 +1423,44 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { */ public abstract void handleSummaryEvent(); - /*----------------------------------------------------------* - * CODE TO SCROLL TO A COMMENT OR OTHER PIECE OF TEXT - *----------------------------------------------------------*/ - + /*----------------------------------------------------------* + * CODE TO SCROLL TO A COMMENT OR OTHER PIECE OF TEXT + *----------------------------------------------------------*/ + /** List of the StyledText's so that we can get the previous and the next */ - protected ArrayList<StyledText> texts = new ArrayList<StyledText>(); - - protected HashMap<Object, StyledText> textHash = new HashMap<Object, StyledText>(); - - /** Index into the styled texts*/ - protected int textsindex = 0; - - protected Text addCommentsTextBox = null; - - protected Text descriptionTextBox = null; - - private StyledText previousText = null; - - /** - * Selects the given object in the editor. - * - * @param commentNumber - * The comment number to be selected - */ - public void select(int commentNumber){ - if(commentNumber == -1) - return; - - for(Object o: textHash.keySet()){ - if(o instanceof Comment){ - if(((Comment)o).getNumber() == commentNumber){ - select(o, true); - } - } - } - } - - /** + protected ArrayList<StyledText> texts = new ArrayList<StyledText>(); + + protected HashMap<Object, StyledText> textHash = new HashMap<Object, StyledText>(); + + /** Index into the styled texts*/ + protected int textsindex = 0; + + protected Text addCommentsTextBox = null; + + protected Text descriptionTextBox = null; + + private StyledText previousText = null; + + /** + * Selects the given object in the editor. + * + * @param commentNumber + * The comment number to be selected + */ + public void select(int commentNumber) { + if (commentNumber == -1) + return; + + for (Object o : textHash.keySet()) { + if (o instanceof Comment) { + if (((Comment) o).getNumber() == commentNumber) { + select(o, true); + } + } + } + } + + /** * Selects the given object in the editor. * * @param o @@ -1564,122 +1468,121 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener { * @param highlight * Whether or not the object should be highlighted. */ - public void select(Object o, boolean highlight){ - if(textHash.containsKey(o)){ - StyledText t = textHash.get(o); - if(t != null){ - focusOn(t, highlight); - } - } else if(o instanceof IBugzillaBug){ - focusOn(null, highlight); - } - } - - public void selectDescription(){ - for(Object o: textHash.keySet()){ - if(o.equals(bugzillaInput.getBug().getDescription())){ + public void select(Object o, boolean highlight) { + if (textHash.containsKey(o)) { + StyledText t = textHash.get(o); + if (t != null) { + focusOn(t, highlight); + } + } else if (o instanceof IBugzillaBug) { + focusOn(null, highlight); + } + } + + public void selectDescription() { + for (Object o : textHash.keySet()) { + if (o.equals(bugzillaInput.getBug().getDescription())) { select(o, true); - } - } - } - - - public void selectNewComment(){ - focusOn(addCommentsTextBox, false); - } - - public void selectNewDescription(){ - focusOn(descriptionTextBox, false); - } - - /** - * Scroll to a specified piece of text - * @param selectionComposite The StyledText to scroll to - */ - private void focusOn(Control selectionComposite, boolean highlight) { - - int pos = 0; - if(previousText != null && !previousText.isDisposed()) { - previousText.setSelection(0); - } - - if(selectionComposite instanceof StyledText) - previousText = (StyledText) selectionComposite; - - if (selectionComposite != null) { - - if(highlight && selectionComposite instanceof StyledText && !selectionComposite.isDisposed()) - ((StyledText)selectionComposite).setSelection(0, ((StyledText)selectionComposite).getText().length()); - - // get the position of the text in the composite - pos = 0; - Control s = selectionComposite; - if(s.isDisposed()) - return; - s.setEnabled(true); - s.setFocus(); - s.forceFocus(); - while(s != null && s != getEditorComposite()) { - if(!s.isDisposed()){ - pos += s.getLocation().y; - s = s.getParent(); - } - } - - pos = scrolledComposite.getOrigin().y + pos - 60; - } - if(!scrolledComposite.isDisposed()) - scrolledComposite.setOrigin(0, pos); - } - - private BugzillaOutlinePage outlinePage = null; - - @Override - public Object getAdapter(Class adapter) { - if (IContentOutlinePage.class.equals(adapter)) { - if (outlinePage == null && bugzillaInput != null) { + } + } + } + + public void selectNewComment() { + focusOn(addCommentsTextBox, false); + } + + public void selectNewDescription() { + focusOn(descriptionTextBox, false); + } + + /** + * Scroll to a specified piece of text + * @param selectionComposite The StyledText to scroll to + */ + private void focusOn(Control selectionComposite, boolean highlight) { + + int pos = 0; + if (previousText != null && !previousText.isDisposed()) { + previousText.setSelection(0); + } + + if (selectionComposite instanceof StyledText) + previousText = (StyledText) selectionComposite; + + if (selectionComposite != null) { + + if (highlight && selectionComposite instanceof StyledText && !selectionComposite.isDisposed()) + ((StyledText) selectionComposite).setSelection(0, ((StyledText) selectionComposite).getText().length()); + + // get the position of the text in the composite + pos = 0; + Control s = selectionComposite; + if (s.isDisposed()) + return; + s.setEnabled(true); + s.setFocus(); + s.forceFocus(); + while (s != null && s != getEditorComposite()) { + if (!s.isDisposed()) { + pos += s.getLocation().y; + s = s.getParent(); + } + } + + pos = scrolledComposite.getOrigin().y + pos - 60; + } + if (!scrolledComposite.isDisposed()) + scrolledComposite.setOrigin(0, pos); + } + + private BugzillaOutlinePage outlinePage = null; + + @Override + public Object getAdapter(Class adapter) { + if (IContentOutlinePage.class.equals(adapter)) { + if (outlinePage == null && bugzillaInput != null) { outlinePage = new BugzillaOutlinePage(model); - } - return outlinePage; - } - return super.getAdapter(adapter); - } - - protected BugzillaOutlineNode model = null; - - public BugzillaOutlineNode getModel(){ - return model; - } - - public BugzillaOutlinePage getOutline(){ - return outlinePage; - } - - private boolean isDisposed = false; - - public boolean isDisposed(){ - return isDisposed; - } - - public void close() { - Display activeDisplay= getSite().getShell().getDisplay(); - activeDisplay.asyncExec(new Runnable() { - public void run() { - if(getSite() != null && getSite().getPage() != null && !AbstractBugEditor.this.isDisposed()) - getSite().getPage().closeEditor(AbstractBugEditor.this, false); - } - }); - } - - public void addAttributeListener(IBugzillaAttributeListener listener) { - attributesListeners.add(listener); - } - - public void removeAttributeListener(IBugzillaAttributeListener listener) { - attributesListeners.remove(listener); - } - - public void setParentEditor(BugzillaTaskEditor editor) { - parentEditor = editor; - } + } + return outlinePage; + } + return super.getAdapter(adapter); + } + + protected BugzillaOutlineNode model = null; + + public BugzillaOutlineNode getModel() { + return model; + } + + public BugzillaOutlinePage getOutline() { + return outlinePage; + } + + private boolean isDisposed = false; + + public boolean isDisposed() { + return isDisposed; + } + + public void close() { + Display activeDisplay = getSite().getShell().getDisplay(); + activeDisplay.asyncExec(new Runnable() { + public void run() { + if (getSite() != null && getSite().getPage() != null && !AbstractBugEditor.this.isDisposed()) + getSite().getPage().closeEditor(AbstractBugEditor.this, false); + } + }); + } + + public void addAttributeListener(IBugzillaAttributeListener listener) { + attributesListeners.add(listener); + } + + public void removeAttributeListener(IBugzillaAttributeListener listener) { + attributesListeners.remove(listener); + } + + public void setParentEditor(BugzillaTaskEditor editor) { + parentEditor = editor; + } } diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/AbstractBugWizard.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/AbstractBugWizard.java index 8ce6dab6d..bf35f20c9 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/AbstractBugWizard.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/AbstractBugWizard.java @@ -50,6 +50,7 @@ import org.eclipse.ui.progress.IProgressService; * Class that contains shared functions for the wizards that submit bug reports. * * @author Eric Booth + * @author Mik Kersten (some hardening of prototype) */ public abstract class AbstractBugWizard extends Wizard implements INewWizard { @@ -355,34 +356,37 @@ public abstract class AbstractBugWizard extends Wizard implements INewWizard { /** * Format the description into lines of about 80 characters so that it is - * displayed properly in bugzilla + * displayed properly in bugzilla, done automatically by Bugzilla 2.20 */ protected void formatDescription() { String origDesc = model.getDescription(); - String[] descArray = new String[(origDesc.length() / AbstractBugEditor.WRAP_LENGTH + 1) * 2]; - for (int i = 0; i < descArray.length; i++) - descArray[i] = null; - int j = 0; - while (true) { - int spaceIndex = origDesc.indexOf(" ", AbstractBugEditor.WRAP_LENGTH-5); - if (spaceIndex == origDesc.length() || spaceIndex == -1) { - descArray[j] = origDesc; - break; + if (BugzillaPlugin.getDefault().isServerCompatability220()) { + model.setDescription(origDesc); + } else { + String[] descArray = new String[(origDesc.length() / AbstractBugEditor.WRAP_LENGTH + 1) * 2]; + for (int i = 0; i < descArray.length; i++) + descArray[i] = null; + int j = 0; + while (true) { + int spaceIndex = origDesc.indexOf(" ", AbstractBugEditor.WRAP_LENGTH - 5); + if (spaceIndex == origDesc.length() || spaceIndex == -1) { + descArray[j] = origDesc; + break; + } + descArray[j] = origDesc.substring(0, spaceIndex); + origDesc = origDesc.substring(spaceIndex + 1, origDesc.length()); + j++; } - descArray[j] = origDesc.substring(0, spaceIndex); - origDesc = origDesc.substring(spaceIndex + 1, origDesc.length()); - j++; - } - String newDesc = ""; + String newDesc = ""; - for (int i = 0; i < descArray.length; i++) { - if (descArray[i] == null) - break; - newDesc += descArray[i] + "\n"; + for (int i = 0; i < descArray.length; i++) { + if (descArray[i] == null) + break; + newDesc += descArray[i] + "\n"; + } + model.setDescription(newDesc); } - model.setDescription(newDesc); - } public String getId() { |