Omaha #4300 Minor updates to the Service Backup Dialogs

Change-Id: I409be11a06ff181f184d22dea311c6b0a7e96cca

Former-commit-id: 6833a9db5bc8c0187ce999d8a7f310bcd4892ad2
This commit is contained in:
Ron Anderson 2015-03-24 16:39:34 -05:00
parent 863082515f
commit fdfd52e26c
2 changed files with 70 additions and 74 deletions

View file

@ -25,12 +25,13 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.apache.commons.lang.StringUtils;
import org.eclipse.core.runtime.FileLocator;
@ -185,7 +186,7 @@ public class ServiceBackupDlg extends CaveJFACEDialog implements
private Combo exportConfigCombo;
private Map<String, ServiceBackupStatusDlg> statusDialogs;
private ConcurrentMap<String, ServiceBackupStatusDlg> statusDialogs;
/**
* Constructor
@ -195,7 +196,7 @@ public class ServiceBackupDlg extends CaveJFACEDialog implements
public ServiceBackupDlg() throws GFEException {
super(null);
this.site = LocalizationManager.getInstance().getCurrentSite();
this.statusDialogs = new HashMap<String, ServiceBackupStatusDlg>();
this.statusDialogs = new ConcurrentHashMap<String, ServiceBackupStatusDlg>();
Boolean isAuthorized = checkPermission("serviceBackup");
if (!isAuthorized) {
@ -501,7 +502,7 @@ public class ServiceBackupDlg extends CaveJFACEDialog implements
startGFECheckBox = new Button(startupOptionsComp, SWT.CHECK);
layoutData = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
startGFECheckBox.setLayoutData(layoutData);
startGFECheckBox.setText("Automatically start GFE");
startGFECheckBox.setText("Automatically Start GFE");
startGFECheckBox.setEnabled(false);
importGridsButton = new Button(startupActionsGroup, SWT.PUSH);
@ -773,15 +774,6 @@ public class ServiceBackupDlg extends CaveJFACEDialog implements
Menu helpMenu = new Menu(shell, SWT.DROP_DOWN);
help.setMenu(helpMenu);
MenuItem helpItem = new MenuItem(helpMenu, SWT.PUSH);
helpItem.setText("Help");
helpItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
openHelp("help/GfeServiceBackup/svcbu_help.html");
}
});
MenuItem instructionsItem = new MenuItem(helpMenu, SWT.PUSH);
instructionsItem.setText("Instructions");
instructionsItem.addSelectionListener(new SelectionAdapter() {
@ -790,16 +782,6 @@ public class ServiceBackupDlg extends CaveJFACEDialog implements
openHelp("help/GfeServiceBackup/svcbu_instructions.html");
}
});
MenuItem faqItem = new MenuItem(helpMenu, SWT.PUSH);
faqItem.setText("FAQ");
faqItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
openHelp("help/GfeServiceBackup/svcbu_faq.html");
}
});
}
private void updateDialog() {
@ -1070,4 +1052,25 @@ public class ServiceBackupDlg extends CaveJFACEDialog implements
+ helpPath, e);
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.Dialog#close()
*/
@Override
public boolean close() {
boolean canClose = true;
for (ServiceBackupStatusDlg dlg : this.statusDialogs.values()) {
if (!dlg.close()) {
canClose = false;
}
}
if (canClose) {
return super.close();
}
return false;
}
}

View file

@ -53,7 +53,6 @@ import org.eclipse.ui.progress.UIJob;
import com.raytheon.uf.common.dataplugin.gfe.svcbu.JobProgress;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.viz.gfe.dialogs.sbu.jobs.AbstractSbuTask;
import com.raytheon.viz.gfe.dialogs.sbu.jobs.ServiceBackupTaskExecutor;
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
@ -140,7 +139,8 @@ public class ServiceBackupStatusDlg extends CaveJFACEDialog {
public IStatus runInUIThread(IProgressMonitor monitor) {
if (!getShell().isDisposed()) {
doRefresh();
if (executor.getJobStatus().equals(JobProgress.IN_PROGRESS)) {
if (executor.isAlive()) {
this.schedule(1000);
} else {
getButton(IDialogConstants.CANCEL_ID).setEnabled(false);
@ -235,7 +235,6 @@ public class ServiceBackupStatusDlg extends CaveJFACEDialog {
Rectangle clientArea = child.getClientArea();
int delta = childBounds.height - clientArea.height;
y += delta;
// x += delta;
}
}
}
@ -314,7 +313,7 @@ public class ServiceBackupStatusDlg extends CaveJFACEDialog {
Label time = new Label(statusGroup, SWT.HORIZONTAL);
time.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
time.setText("00:00:00");
time.setText("00:00:00 ");
Label label = new Label(statusGroup, SWT.HORIZONTAL);
label.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
@ -375,7 +374,7 @@ public class ServiceBackupStatusDlg extends CaveJFACEDialog {
*/
@Override
public boolean close() {
if (executor.getJobStatus().equals(JobProgress.IN_PROGRESS)) {
if (executor.isAlive()) {
MessageDialog
.openWarning(getShell(), this.site
+ " Service Backup Status",
@ -406,58 +405,52 @@ public class ServiceBackupStatusDlg extends CaveJFACEDialog {
}
private void updateStatus(final AbstractSbuTask task) {
VizApp.runAsync(new Runnable() {
@Override
public void run() {
String key = task.getStatusFileName();
JobProgress jobProgress = task.getStatus();
String key = task.getStatusFileName();
JobProgress jobProgress = task.getStatus();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
Date statusTime = task.getStatusTime();
Label[] labels = controls.get(key);
if (labels != null) {
Label statusIcon = labels[0];
Label timeLabel = labels[1];
Date statusTime = task.getStatusTime();
Label[] labels = controls.get(key);
if (labels != null) {
Label statusIcon = labels[0];
Label timeLabel = labels[1];
StatusIcons icon;
switch (jobProgress) {
case IN_PROGRESS:
icon = StatusIcons.IN_PROGRESS;
statusTime = new Date(System.currentTimeMillis()
- statusTime.getTime());
break;
case SUCCESS:
icon = StatusIcons.SUCCESS;
break;
case FAILED:
icon = StatusIcons.FAILED;
break;
StatusIcons icon;
switch (jobProgress) {
case IN_PROGRESS:
icon = StatusIcons.IN_PROGRESS;
statusTime = new Date(System.currentTimeMillis()
- statusTime.getTime());
break;
case SUCCESS:
icon = StatusIcons.SUCCESS;
break;
case FAILED:
icon = StatusIcons.FAILED;
break;
case UNKNOWN:
icon = StatusIcons.NOT_STARTED;
break;
case UNKNOWN:
icon = StatusIcons.NOT_STARTED;
break;
default:
statusHandler
.error("Unknown JobProgress value received: "
+ jobProgress.name());
icon = StatusIcons.IN_PROGRESS;
}
if (!statusIcon.isDisposed()) {
statusIcon.setForeground(statusIcon.getDisplay()
.getSystemColor(icon.getColor()));
statusIcon.setText(Character.toString(icon.getSymbol()));
statusIcon.setToolTipText(icon.getToolTip());
}
if (!timeLabel.isDisposed()) {
timeLabel.setText(sdf.format(statusTime));
}
}
default:
statusHandler.error("Unknown JobProgress value received: "
+ jobProgress.name());
icon = StatusIcons.IN_PROGRESS;
}
});
if (!statusIcon.isDisposed()) {
statusIcon.setForeground(statusIcon.getDisplay()
.getSystemColor(icon.getColor()));
statusIcon.setText(Character.toString(icon.getSymbol()));
statusIcon.setToolTipText(icon.getToolTip());
}
if (!timeLabel.isDisposed()) {
timeLabel.setText(sdf.format(statusTime));
}
}
}
private void doRefresh() {