001: /*******************************************************************************
002: * Copyright (c) 2000, 2007 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.views.markers.internal;
011:
012: import java.util.ArrayList;
013: import java.util.Collection;
014: import java.util.Hashtable;
015:
016: import org.eclipse.core.resources.IMarker;
017: import org.eclipse.core.runtime.SubProgressMonitor;
018: import org.eclipse.jface.dialogs.Dialog;
019: import org.eclipse.jface.dialogs.IDialogConstants;
020: import org.eclipse.jface.dialogs.TitleAreaDialog;
021: import org.eclipse.jface.resource.JFaceResources;
022: import org.eclipse.jface.viewers.CheckStateChangedEvent;
023: import org.eclipse.jface.viewers.CheckboxTableViewer;
024: import org.eclipse.jface.viewers.ColumnWeightData;
025: import org.eclipse.jface.viewers.ICheckStateListener;
026: import org.eclipse.jface.viewers.ILabelProviderListener;
027: import org.eclipse.jface.viewers.ISelection;
028: import org.eclipse.jface.viewers.ISelectionChangedListener;
029: import org.eclipse.jface.viewers.IStructuredContentProvider;
030: import org.eclipse.jface.viewers.IStructuredSelection;
031: import org.eclipse.jface.viewers.ITableLabelProvider;
032: import org.eclipse.jface.viewers.LabelProvider;
033: import org.eclipse.jface.viewers.ListViewer;
034: import org.eclipse.jface.viewers.SelectionChangedEvent;
035: import org.eclipse.jface.viewers.TableLayout;
036: import org.eclipse.jface.viewers.Viewer;
037: import org.eclipse.jface.viewers.ViewerComparator;
038: import org.eclipse.jface.wizard.ProgressMonitorPart;
039: import org.eclipse.osgi.util.NLS;
040: import org.eclipse.swt.SWT;
041: import org.eclipse.swt.custom.BusyIndicator;
042: import org.eclipse.swt.events.SelectionAdapter;
043: import org.eclipse.swt.events.SelectionEvent;
044: import org.eclipse.swt.graphics.Image;
045: import org.eclipse.swt.layout.FormAttachment;
046: import org.eclipse.swt.layout.FormData;
047: import org.eclipse.swt.layout.FormLayout;
048: import org.eclipse.swt.layout.GridData;
049: import org.eclipse.swt.layout.GridLayout;
050: import org.eclipse.swt.widgets.Button;
051: import org.eclipse.swt.widgets.Composite;
052: import org.eclipse.swt.widgets.Control;
053: import org.eclipse.swt.widgets.Label;
054: import org.eclipse.swt.widgets.Shell;
055: import org.eclipse.swt.widgets.Table;
056: import org.eclipse.swt.widgets.TableColumn;
057: import org.eclipse.ui.IMarkerResolution;
058: import org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages;
059: import org.eclipse.ui.views.markers.WorkbenchMarkerResolution;
060:
061: /**
062: * The MarkerResolutionDialog is the dialog used to select a marker resolution.
063: *
064: * @since 3.2
065: *
066: */
067: public class MarkerResolutionDialog extends TitleAreaDialog {
068:
069: private IMarker originalMarker;
070:
071: private IMarkerResolution[] resolutions;
072:
073: private CheckboxTableViewer markersTable;
074:
075: private ListViewer resolutionsList;
076:
077: private ProgressMonitorPart progressPart;
078:
079: private MarkerView markerView;
080:
081: private ViewerComparator resolutionsComparator;
082:
083: private boolean calculatingResolutions;
084:
085: private boolean progressCancelled = false;
086:
087: private Button addMatching;
088:
089: private Hashtable markerMap = new Hashtable(0);
090:
091: /**
092: * Create a new instance of the receiver with the given resolutions.
093: *
094: * @param shell
095: * @param marker
096: * the marker to show
097: * @param newResolutions
098: * @param view
099: * the viewer that is showing these errors
100: */
101: public MarkerResolutionDialog(Shell shell, IMarker marker,
102: IMarkerResolution[] newResolutions, MarkerView view) {
103: super (shell);
104: initializeResolutionsSorter();
105: resolutionsComparator.sort(view.getViewer(), newResolutions);
106: resolutions = newResolutions;
107: originalMarker = marker;
108: markerView = view;
109: }
110:
111: /*
112: * (non-Javadoc)
113: *
114: * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
115: */
116: protected void configureShell(Shell newShell) {
117: super .configureShell(newShell);
118: newShell
119: .setText(MarkerMessages.resolveMarkerAction_dialogTitle);
120: }
121:
122: /*
123: * (non-Javadoc)
124: *
125: * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
126: */
127: protected Control createDialogArea(Composite parent) {
128:
129: initializeDialogUnits(parent);
130:
131: setTitleImage(JFaceResources
132: .getResources()
133: .createImageWithDefault(
134: IDEInternalWorkbenchImages
135: .getImageDescriptor(IDEInternalWorkbenchImages.IMG_DLGBAN_QUICKFIX_DLG)));
136:
137: Composite mainArea = (Composite) super .createDialogArea(parent);
138:
139: // Create a new composite as there is the title bar seperator
140: // to deal with
141: Composite control = new Composite(mainArea, SWT.NONE);
142: control.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
143: true));
144:
145: FormLayout layout = new FormLayout();
146: layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
147: layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
148: layout.spacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
149: control.setLayout(layout);
150:
151: Label resolutionsLabel = new Label(control, SWT.NONE);
152: resolutionsLabel
153: .setText(MarkerMessages.MarkerResolutionDialog_Resolutions_List_Title);
154:
155: resolutionsLabel.setLayoutData(new FormData());
156:
157: resolutionsList = new ListViewer(control, SWT.BORDER
158: | SWT.SINGLE | SWT.V_SCROLL);
159: resolutionsList
160: .setContentProvider(new IStructuredContentProvider() {
161: public Object[] getElements(Object inputElement) {
162: return resolutions;
163: }
164:
165: /*
166: * (non-Javadoc)
167: *
168: * @see org.eclipse.jface.viewers.IContentProvider#dispose()
169: */
170: public void dispose() {
171:
172: }
173:
174: /*
175: * (non-Javadoc)
176: *
177: * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
178: * java.lang.Object, java.lang.Object)
179: */
180: public void inputChanged(Viewer viewer,
181: Object oldInput, Object newInput) {
182:
183: }
184: });
185:
186: resolutionsList.setLabelProvider(new LabelProvider() {
187: public String getText(Object element) {
188: return ((IMarkerResolution) element).getLabel();
189: }
190: });
191:
192: resolutionsList
193: .addSelectionChangedListener(new ISelectionChangedListener() {
194: /*
195: * (non-Javadoc)
196: *
197: * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
198: */
199: public void selectionChanged(
200: SelectionChangedEvent event) {
201:
202: WorkbenchMarkerResolution resolution = getSelectedWorkbenchResolution();
203: if (resolution == null
204: || markerMap.containsKey(resolution))
205: addMatching.setEnabled(false);
206: else
207: addMatching.setEnabled(true);
208: markersTable.refresh();
209: }
210: });
211:
212: resolutionsList.setInput(this );
213:
214: resolutionsList.setComparator(resolutionsComparator);
215:
216: FormData listData = new FormData();
217: listData.top = new FormAttachment(resolutionsLabel, 0);
218: listData.left = new FormAttachment(0);
219: listData.right = new FormAttachment(100, 0);
220: listData.height = convertHeightInCharsToPixels(10);
221: resolutionsList.getControl().setLayoutData(listData);
222:
223: Label title = new Label(control, SWT.NONE);
224: title
225: .setText(MarkerMessages.MarkerResolutionDialog_Problems_List_Title);
226: FormData labelData = new FormData();
227: labelData.top = new FormAttachment(
228: resolutionsList.getControl(), 0);
229: labelData.left = new FormAttachment(0);
230: title.setLayoutData(labelData);
231:
232: Composite buttons = createTableButtons(control);
233: FormData buttonData = new FormData();
234: buttonData.top = new FormAttachment(title, 0);
235: buttonData.right = new FormAttachment(100);
236: buttonData.height = convertHeightInCharsToPixels(10);
237: buttons.setLayoutData(buttonData);
238:
239: createMarkerTable(control);
240:
241: FormData tableData = new FormData();
242: tableData.top = new FormAttachment(buttons, 0, SWT.TOP);
243: tableData.left = new FormAttachment(0);
244: tableData.right = new FormAttachment(buttons, 0);
245: tableData.height = convertHeightInCharsToPixels(10);
246: markersTable.getControl().setLayoutData(tableData);
247:
248: progressPart = new ProgressMonitorPart(control,
249: new GridLayout());
250:
251: FormData progressData = new FormData();
252: progressData.top = new FormAttachment(
253: markersTable.getControl(), 0);
254: progressData.left = new FormAttachment(0);
255: progressData.right = new FormAttachment(100, 0);
256: progressPart.setLayoutData(progressData);
257:
258: Dialog.applyDialogFont(control);
259:
260: String message = NLS.bind(
261: MarkerMessages.MarkerResolutionDialog_Description, Util
262: .getProperty(IMarker.MESSAGE, originalMarker));
263: if (message.length() > 50) {
264: // Add a carriage return in the middle if we can
265: int insertionIndex = chooseWhitespace(message);
266: if (insertionIndex > 0) {
267: StringBuffer buffer = new StringBuffer();
268: buffer.append(message.substring(0, insertionIndex));
269: buffer.append("\n"); //$NON-NLS-1$
270: buffer.append(message.substring(insertionIndex, message
271: .length()));
272: message = buffer.toString();
273: }
274: }
275:
276: setMessage(message);
277: return mainArea;
278:
279: }
280:
281: /**
282: * Choose a good whitespace position for a page break. Start in the middle
283: * of the message.
284: *
285: * @param message
286: * @return int -1 if there is no whitespace to choose.
287: */
288: private int chooseWhitespace(String message) {
289:
290: for (int i = message.length() / 2; i < message.length(); i++) {
291: if (Character.isWhitespace(message.charAt(i)))
292: return i;
293: }
294: return -1;
295: }
296:
297: /**
298: * Create the resolutions sorter.
299: */
300: private void initializeResolutionsSorter() {
301: resolutionsComparator = new ViewerComparator() {
302: /*
303: * (non-Javadoc)
304: *
305: * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer,
306: * java.lang.Object, java.lang.Object)
307: */
308: public int compare(Viewer viewer, Object e1, Object e2) {
309: return ((IMarkerResolution) e1).getLabel().compareTo(
310: ((IMarkerResolution) e1).getLabel());
311: }
312: };
313: }
314:
315: /**
316: * Create the buttons for the table.
317: *
318: * @param control
319: * @return Composite
320: */
321: private Composite createTableButtons(Composite control) {
322:
323: Composite buttonComposite = new Composite(control, SWT.NONE);
324: GridLayout layout = new GridLayout();
325: layout.marginWidth = 0;
326: layout.marginHeight = 0;
327: layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
328: layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
329: buttonComposite.setLayout(layout);
330:
331: Button selectAll = new Button(buttonComposite, SWT.PUSH);
332: selectAll.setText(MarkerMessages.selectAllAction_title);
333: selectAll.setLayoutData(new GridData(SWT.FILL, SWT.NONE, false,
334: false));
335:
336: selectAll.addSelectionListener(new SelectionAdapter() {
337: /*
338: * (non-Javadoc)
339: *
340: * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
341: */
342: public void widgetSelected(SelectionEvent arg0) {
343: markersTable.setAllChecked(true);
344: setComplete(!resolutionsList.getSelection().isEmpty());
345: }
346: });
347:
348: Button deselectAll = new Button(buttonComposite, SWT.PUSH);
349: deselectAll.setText(MarkerMessages.filtersDialog_deselectAll);
350: deselectAll.setLayoutData(new GridData(SWT.FILL, SWT.NONE,
351: false, false));
352:
353: deselectAll.addSelectionListener(new SelectionAdapter() {
354: /*
355: * (non-Javadoc)
356: *
357: * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
358: */
359: public void widgetSelected(SelectionEvent arg0) {
360: markersTable.setAllChecked(false);
361: setComplete(false);
362: }
363: });
364:
365: addMatching = new Button(buttonComposite, SWT.PUSH);
366: addMatching
367: .setText(MarkerMessages.MarkerResolutionDialog_AddOthers);
368: addMatching.setLayoutData(new GridData(SWT.FILL, SWT.NONE,
369: false, false));
370: addMatching.setEnabled(true);
371: addMatching.addSelectionListener(new SelectionAdapter() {
372: /*
373: * (non-Javadoc)
374: *
375: * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
376: */
377: public void widgetSelected(SelectionEvent arg0) {
378:
379: WorkbenchMarkerResolution selected = getSelectedWorkbenchResolution();
380: if (selected == null) {
381: return;
382: }
383:
384: if (addMatchingMarkers(selected)) {
385: addMatching.setEnabled(false);
386: }
387: }
388: });
389:
390: return buttonComposite;
391: }
392:
393: /**
394: * Return the single selected WorkbenchMarkerResolution if there is one.
395: *
396: * @return WorkbenchMarkerResolution or <code>null</code> if there is no
397: * selection or the selection is not a WorkbenchMarkerResolution.
398: */
399: private WorkbenchMarkerResolution getSelectedWorkbenchResolution() {
400: Object selection = getSelectedResolution();
401: if (selection == null
402: || !(selection instanceof WorkbenchMarkerResolution)) {
403: return null;
404: }
405: return (WorkbenchMarkerResolution) selection;
406:
407: }
408:
409: /**
410: * Return the marker resolution that is currenly selected/
411: *
412: * @return IMarkerResolution or <code>null</code> if there is no
413: * selection.
414: */
415: private IMarkerResolution getSelectedResolution() {
416: ISelection selection = resolutionsList.getSelection();
417: if (!(selection instanceof IStructuredSelection)) {
418: return null;
419: }
420:
421: Object first = ((IStructuredSelection) selection)
422: .getFirstElement();
423:
424: return (IMarkerResolution) first;
425:
426: }
427:
428: /**
429: * Add all of the markers that have resolutions compatible with the
430: * receiver.
431: *
432: * @return boolean <code>true</code> if the operation completed.
433: */
434: protected boolean addMatchingMarkers(
435: final WorkbenchMarkerResolution resolution) {
436:
437: calculatingResolutions = true;
438: progressPart.beginTask(
439: MarkerMessages.MarkerResolutionDialog_CalculatingTask,
440: 100);
441:
442: progressPart.worked(10);
443: if (progressCancelled()) {
444: calculatingResolutions = false;
445: return false;
446: }
447:
448: progressPart.subTask(NLS.bind(
449: MarkerMessages.MarkerResolutionDialog_WorkingSubTask,
450: resolution.getLabel()));
451:
452: BusyIndicator.showWhile(getShell().getDisplay(),
453: new Runnable() {
454: /*
455: * (non-Javadoc)
456: *
457: * @see java.lang.Runnable#run()
458: */
459: public void run() {
460: IMarker[] others = resolution
461: .findOtherMarkers(markerView
462: .getCurrentMarkers()
463: .getIMarkers());
464:
465: Collection currentMarkers = new ArrayList();
466: currentMarkers.add(originalMarker);
467:
468: for (int i = 0; i < others.length; i++) {
469: currentMarkers.add(others[i]);
470: }
471:
472: markerMap.put(resolution, currentMarkers);
473:
474: progressPart.worked(90);
475: progressPart.done();
476: progressCancelled = false;
477: calculatingResolutions = false;
478: markersTable.refresh();
479:
480: }
481: });
482:
483: return true;
484: }
485:
486: /**
487: * Spin the event loop and see if the cancel button was pressed. If it was
488: * then clear the flags and return <code>true</code>.
489: *
490: * @return boolean
491: */
492: private boolean progressCancelled() {
493: getShell().getDisplay().readAndDispatch();
494: if (progressCancelled) {
495: progressCancelled = false;
496: calculatingResolutions = false;
497: progressPart.done();
498: return true;
499: }
500: return false;
501: }
502:
503: /**
504: * Create the table for the markers/
505: *
506: * @param control
507: */
508: private void createMarkerTable(Composite control) {
509: markersTable = CheckboxTableViewer.newCheckList(control,
510: SWT.BORDER | SWT.V_SCROLL);
511:
512: createTableColumns();
513:
514: markersTable
515: .setContentProvider(new IStructuredContentProvider() {
516: /*
517: * (non-Javadoc)
518: *
519: * @see org.eclipse.jface.viewers.IContentProvider#dispose()
520: */
521: public void dispose() {
522:
523: }
524:
525: /*
526: * (non-Javadoc)
527: *
528: * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
529: */
530: public Object[] getElements(Object inputElement) {
531: IMarkerResolution selected = getSelectedResolution();
532: if (selected == null) {
533: return new Object[0];
534: }
535:
536: if (markerMap.containsKey(selected)) {
537: return ((Collection) markerMap
538: .get(selected)).toArray();
539: }
540: return new IMarker[] { originalMarker };
541: }
542:
543: /*
544: * (non-Javadoc)
545: *
546: * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
547: * java.lang.Object, java.lang.Object)
548: */
549: public void inputChanged(Viewer viewer,
550: Object oldInput, Object newInput) {
551:
552: }
553: });
554:
555: markersTable.setLabelProvider(new ITableLabelProvider() {
556:
557: /*
558: * (non-Javadoc)
559: *
560: * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object,
561: * int)
562: */
563: public Image getColumnImage(Object element, int columnIndex) {
564: if (columnIndex == 0)
565: return Util.getImage(((IMarker) element)
566: .getAttribute(IMarker.SEVERITY, -1));
567: return null;
568: }
569:
570: /*
571: * (non-Javadoc)
572: *
573: * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object,
574: * int)
575: */
576: public String getColumnText(Object element, int columnIndex) {
577: if (columnIndex == 0)
578: return Util.getResourceName((IMarker) element);
579: int line = ((IMarker) element).getAttribute(
580: IMarker.LINE_NUMBER, -1);
581: if (line < 0) {
582: return MarkerMessages.Unknown;
583: }
584: return NLS.bind(MarkerMessages.label_lineNumber,
585: Integer.toString(line));
586: }
587:
588: /*
589: * (non-Javadoc)
590: *
591: * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
592: */
593: public void addListener(ILabelProviderListener listener) {
594: // do nothing
595:
596: }
597:
598: /*
599: * (non-Javadoc)
600: *
601: * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
602: */
603: public void dispose() {
604: // do nothing
605:
606: }
607:
608: /*
609: * (non-Javadoc)
610: *
611: * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object,
612: * java.lang.String)
613: */
614: public boolean isLabelProperty(Object element,
615: String property) {
616: return false;
617: }
618:
619: /*
620: * (non-Javadoc)
621: *
622: * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
623: */
624: public void removeListener(ILabelProviderListener listener) {
625: // do nothing
626:
627: }
628: });
629:
630: markersTable.addCheckStateListener(new ICheckStateListener() {
631: /*
632: * (non-Javadoc)
633: *
634: * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
635: */
636: public void checkStateChanged(CheckStateChangedEvent event) {
637: if (event.getChecked() == true) {
638: setComplete(true);
639: } else {
640: setComplete(markersTable.getCheckedElements().length > 0);
641: }
642:
643: }
644: });
645:
646: markersTable.setInput(this );
647: markersTable.setAllChecked(true);
648: }
649:
650: /**
651: * Create the table columns for the receiver.
652: */
653: private void createTableColumns() {
654: TableLayout layout = new TableLayout();
655:
656: Table table = markersTable.getTable();
657: table.setLayout(layout);
658: table.setLinesVisible(true);
659: table.setHeaderVisible(true);
660:
661: layout.addColumnData(new ColumnWeightData(70, true));
662: TableColumn tc = new TableColumn(table, SWT.NONE, 0);
663: tc
664: .setText(MarkerMessages.MarkerResolutionDialog_Problems_List_Location);
665: layout.addColumnData(new ColumnWeightData(30, true));
666: tc = new TableColumn(table, SWT.NONE, 0);
667: tc
668: .setText(MarkerMessages.MarkerResolutionDialog_Problems_List_Resource);
669:
670: }
671:
672: /**
673: * Set the dialog to be complete.
674: *
675: * @param complete
676: */
677: protected void setComplete(boolean complete) {
678: getButton(IDialogConstants.OK_ID).setEnabled(complete);
679:
680: }
681:
682: /**
683: * Return all of the resolutions to choose from in the receiver.
684: *
685: * @return IMarkerResolution[]
686: */
687: public IMarkerResolution[] getResolutions() {
688: return resolutions;
689: }
690:
691: /*
692: * (non-Javadoc)
693: *
694: * @see org.eclipse.jface.dialogs.Dialog#create()
695: */
696: public void create() {
697: super .create();
698: setTitle(MarkerMessages.MarkerResolutionDialog_Title);
699: resolutionsList.getList().select(0);
700: markersTable.refresh();
701: markersTable.setAllChecked(true);
702: setComplete(true);
703: }
704:
705: /*
706: * (non-Javadoc)
707: *
708: * @see org.eclipse.jface.dialogs.Dialog#okPressed()
709: */
710: protected void okPressed() {
711: IMarkerResolution resolution = getSelectedResolution();
712: if (resolution == null) {
713: return;
714: }
715:
716: Object[] checked = markersTable.getCheckedElements();
717:
718: progressPart.beginTask(
719: MarkerMessages.MarkerResolutionDialog_Fixing,
720: checked.length + 1);
721: progressPart.worked(1);
722:
723: calculatingResolutions = true;
724:
725: if (resolution instanceof WorkbenchMarkerResolution) {
726:
727: IMarker[] markers = new IMarker[checked.length];
728: System.arraycopy(checked, 0, markers, 0, checked.length);
729: ((WorkbenchMarkerResolution) resolution)
730: .run(markers, new SubProgressMonitor(progressPart,
731: checked.length));
732: } else {
733:
734: // Allow paint events and wake up the button
735: getShell().getDisplay().readAndDispatch();
736: if (!progressCancelled() && checked.length == 1) {
737:
738: // There will only be one
739: IMarker marker = (IMarker) checked[0];
740:
741: progressPart.subTask(Util.getProperty(IMarker.MESSAGE,
742: marker));
743: resolution.run(marker);
744: progressPart.worked(1);
745: }
746:
747: }
748:
749: calculatingResolutions = false;
750: progressPart.done();
751: progressCancelled = false;
752: super .okPressed();
753: }
754:
755: /*
756: * (non-Javadoc)
757: *
758: * @see org.eclipse.jface.dialogs.Dialog#cancelPressed()
759: */
760: protected void cancelPressed() {
761: if (calculatingResolutions) {
762: progressCancelled = true;
763: progressPart.setCanceled(true);
764: return;
765: }
766: super .cancelPressed();
767: }
768:
769: /*
770: * (non-Javadoc)
771: * @see org.eclipse.jface.dialogs.Dialog#isResizable()
772: */
773: protected boolean isResizable() {
774: return true;
775: }
776: }
|