Skip to content

Commit 849c1fa

Browse files
committed
Provide user feedback when updating versions
One current issue is that users are confused about the meaning of buttons, especially as pressing them gives no immediate feedback. This now do the following: - disable the update button while update is running (or user selects another location) - after completion gives a message to the user what was the outcome of the most recent operation
1 parent 9a772d2 commit 849c1fa

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/Messages.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ public class Messages extends NLS {
149149
public static String TargetLocationsGroup_1;
150150

151151
public static String TargetLocationsGroup_TargetUpdateErrorDialog;
152+
public static String TargetLocationsGroup_TargetUpdateNoChange;
152153
public static String TargetStatus_NoActiveTargetPlatformStatus;
153154
public static String TargetStatus_TargetStatusDefaultString;
154155
public static String TargetStatus_UnresolvedTarget;

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationHandlerAdapter.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ public IStatus update(ITargetDefinition target, TreePath[] treePath, IProgressMo
100100
for (Entry<ITargetLocationHandler, List<TreePath>> entry : handlerMap.entrySet()) {
101101
status.add(entry.getKey().update(target, entry.getValue().toArray(TreePath[]::new), subMonitor.split(100)));
102102
}
103+
IStatus[] children = status.getChildren();
104+
if (children.length == 1) {
105+
return children[0];
106+
}
103107
return status;
104108
}
105109

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.eclipse.jface.action.Action;
3434
import org.eclipse.jface.action.MenuManager;
3535
import org.eclipse.jface.dialogs.ErrorDialog;
36+
import org.eclipse.jface.dialogs.MessageDialog;
3637
import org.eclipse.jface.viewers.AbstractTreeViewer;
3738
import org.eclipse.jface.viewers.ITreeSelection;
3839
import org.eclipse.jface.viewers.TreePath;
@@ -82,6 +83,7 @@
8283
*/
8384
public class TargetLocationsGroup {
8485

86+
private static final String LOCATION_ID_KEY = "target.location.id"; //$NON-NLS-1$
8587
private static final String BUTTON_STATE = "ButtonState"; //$NON-NLS-1$
8688

8789
private enum DeleteButtonState {
@@ -121,6 +123,7 @@ static DeleteButtonState computeState(boolean canRemove, boolean canEnable, bool
121123
private final ListenerList<ITargetChangedListener> fChangeListeners = new ListenerList<>();
122124
private final ListenerList<ITargetChangedListener> fReloadListeners = new ListenerList<>();
123125
private static final TargetLocationHandlerAdapter ADAPTER = new TargetLocationHandlerAdapter();
126+
private int counter;
124127

125128
/**
126129
* Creates this part using the form toolkit and adds it to the given
@@ -478,24 +481,41 @@ private void handleRemove() {
478481
}
479482

480483
private void handleUpdate() {
484+
fUpdateButton.setEnabled(false);
481485
ITreeSelection selection = fTreeViewer.getStructuredSelection();
482486
if (selection.isEmpty()) {
483-
fUpdateButton.setEnabled(false);
484487
return;
485488
}
489+
Integer id = counter++;
490+
fUpdateButton.setCursor(fUpdateButton.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
491+
fUpdateButton.setData(LOCATION_ID_KEY, id);
486492
List<IJobFunction> updateActions = Collections
487493
.singletonList(monitor -> log(ADAPTER.update(fTarget, selection.getPaths(), monitor)));
488494
JobChangeAdapter listener = new JobChangeAdapter() {
489495
@Override
490496
public void done(final IJobChangeEvent event) {
491497
UIJob job = UIJob.create(Messages.UpdateTargetJob_UpdateJobName, monitor -> {
498+
boolean showMessage = !fUpdateButton.isDisposed() && id == fUpdateButton.getData(LOCATION_ID_KEY);
499+
if (showMessage) {
500+
// we are the current owner so need to reset
501+
// state...
502+
fUpdateButton.setEnabled(!fTreeViewer.getStructuredSelection().isEmpty());
503+
fUpdateButton.setCursor(null);
504+
showMessage = true;
505+
}
492506
IStatus result = event.getJob().getResult();
493507
if (!result.isOK()) {
494-
if (!fTreeViewer.getControl().isDisposed()) {
495-
ErrorDialog.openError(fTreeViewer.getTree().getShell(),
508+
if (showMessage) {
509+
ErrorDialog.openError(fUpdateButton.getShell(),
496510
Messages.TargetLocationsGroup_TargetUpdateErrorDialog, result.getMessage(), result);
497511
}
498-
} else if (result.getCode() != ITargetLocationHandler.STATUS_CODE_NO_CHANGE) {
512+
} else if (result.getCode() == ITargetLocationHandler.STATUS_CODE_NO_CHANGE) {
513+
if (showMessage) {
514+
MessageDialog.openInformation(fUpdateButton.getShell(),
515+
Messages.UpdateTargetJob_UpdateJobName,
516+
Messages.TargetLocationsGroup_TargetUpdateNoChange);
517+
}
518+
} else {
499519
// Update was successful and changed the target, if
500520
// dialog/editor still open, update it
501521
if (!fTreeViewer.getControl().isDisposed()) {
@@ -518,6 +538,11 @@ public void done(final IJobChangeEvent event) {
518538
// do nothing if we could not set the current
519539
// target.
520540
}
541+
if (showMessage) {
542+
MessageDialog.openInformation(fUpdateButton.getShell(),
543+
Messages.UpdateTargetJob_UpdateJobName,
544+
result.getMessage());
545+
}
521546
}
522547
});
523548
job.schedule();

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ TargetLocationsGroup_update=Looks for newer versions of the target contents and
139139
TargetLocationsGroup_refresh=Clears the cached target data and resolves the target, looking for newer versions of any artifacts
140140
TargetLocationsGroup_1=&Show location content
141141
TargetLocationsGroup_TargetUpdateErrorDialog=Problems Updating Target Definition
142+
TargetLocationsGroup_TargetUpdateNoChange=All versions are up-to-date
142143
TargetStatus_NoActiveTargetPlatformStatus=No active target platform
143144
TargetStatus_TargetStatusDefaultString=Target Platform
144145
TargetStatus_UnresolvedTarget=Unresolved ''{0}''

0 commit comments

Comments
 (0)