From 0a34446c636fa87c31ea1f4f021e011933f8cafd Mon Sep 17 00:00:00 2001 From: tza Date: Thu, 24 Dec 2020 00:45:17 +0100 Subject: [PATCH] add new button to refresh all known tasks via repair action --- .../plugin/ui/TaskSelectionDialog.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/plugin/ui/TaskSelectionDialog.java b/parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/plugin/ui/TaskSelectionDialog.java index 57f9492..284467f 100644 --- a/parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/plugin/ui/TaskSelectionDialog.java +++ b/parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/plugin/ui/TaskSelectionDialog.java @@ -9,8 +9,9 @@ package com.google.eclipse.mechanic.plugin.ui; -import com.google.eclipse.mechanic.Task; +import java.util.Collection; +import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.CellLabelProvider; import org.eclipse.jface.viewers.ColumnViewerToolTipSupport; @@ -28,7 +29,9 @@ import org.eclipse.swt.widgets.TableColumn; import org.eclipse.ui.dialogs.ListDialog; -import java.util.Collection; +import com.google.eclipse.mechanic.MechanicService; +import com.google.eclipse.mechanic.Task; +import com.google.eclipse.mechanic.plugin.core.MechanicLog; /** * Allows the user to pick a single Task from a list of Tasks. @@ -105,6 +108,24 @@ public String getColumnText(Task item, int columnIndex) { } } + @Override + protected void createButtonsForButtonBar(final Composite parent) { + createButton(parent, IDialogConstants.PROCEED_ID, "Repair all tasks", true); + super.createButtonsForButtonBar(parent); + } + + @Override + protected void buttonPressed(final int buttonId) { + super.buttonPressed(buttonId); + if (buttonId == IDialogConstants.PROCEED_ID) { + MechanicLog.getDefault().logInfo("Repairing all tasks"); + for (final Task task : MechanicService.getInstance().getAllKnownTasks()) { + task.getRepairAction().run(); + } + okPressed(); + } + } + /** * Serializes Tasks for use in user facing dialogs. */