Merge "Issue #1353 Changes for non-blocking RetrieveMergeDlg and LoadSaveDelteSelectDlg close callbacks added to FFFGDlg." into development
Former-commit-id:a0ba84d5e0
[formerly6a187c705a
[formerly e433fbe19e51138c78f69b8a3a89decffbb75f13]] Former-commit-id:6a187c705a
Former-commit-id:696fb95b92
This commit is contained in:
commit
840ed57de0
2 changed files with 225 additions and 190 deletions
|
@ -60,6 +60,9 @@ import com.raytheon.uf.common.monitor.config.FFFGDataMgr;
|
||||||
import com.raytheon.uf.common.monitor.config.SourceCompData;
|
import com.raytheon.uf.common.monitor.config.SourceCompData;
|
||||||
import com.raytheon.uf.common.monitor.config.ValueNameIdData;
|
import com.raytheon.uf.common.monitor.config.ValueNameIdData;
|
||||||
import com.raytheon.uf.common.monitor.xml.FFFGBasinIdXML;
|
import com.raytheon.uf.common.monitor.xml.FFFGBasinIdXML;
|
||||||
|
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
|
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||||
import com.raytheon.uf.common.time.SimulatedTime;
|
import com.raytheon.uf.common.time.SimulatedTime;
|
||||||
import com.raytheon.uf.viz.core.VizApp;
|
import com.raytheon.uf.viz.core.VizApp;
|
||||||
import com.raytheon.uf.viz.monitor.ffmp.FFMPMonitor;
|
import com.raytheon.uf.viz.monitor.ffmp.FFMPMonitor;
|
||||||
|
@ -67,6 +70,7 @@ import com.raytheon.uf.viz.monitor.ffmp.fffg.RetrieveMergeDlg.RetrieveMergeActio
|
||||||
import com.raytheon.uf.viz.monitor.ui.dialogs.LoadSaveDeleteSelectDlg;
|
import com.raytheon.uf.viz.monitor.ui.dialogs.LoadSaveDeleteSelectDlg;
|
||||||
import com.raytheon.uf.viz.monitor.ui.dialogs.LoadSaveDeleteSelectDlg.DialogType;
|
import com.raytheon.uf.viz.monitor.ui.dialogs.LoadSaveDeleteSelectDlg.DialogType;
|
||||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
|
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -83,6 +87,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
* Changes for non-blocking AboutDlg.
|
* Changes for non-blocking AboutDlg.
|
||||||
* Changes for non-blocking AcknowledgmentsDlg.
|
* Changes for non-blocking AcknowledgmentsDlg.
|
||||||
* Changes for non-blocking HelpDlg.
|
* Changes for non-blocking HelpDlg.
|
||||||
|
* Changes for non-blocking RetrieveMergeDlg.
|
||||||
|
* Changes for non-blocking LoadSaveDeleteSelectDlg.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -91,6 +97,9 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
*/
|
*/
|
||||||
public class FFFGDlg extends CaveSWTDialog implements ISourceCompAction,
|
public class FFFGDlg extends CaveSWTDialog implements ISourceCompAction,
|
||||||
IFFFGData {
|
IFFFGData {
|
||||||
|
private final IUFStatusHandler statusHandler = UFStatus
|
||||||
|
.getHandler(FFFGDlg.class);
|
||||||
|
|
||||||
private final String MODIFIED = "Modified";
|
private final String MODIFIED = "Modified";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -218,6 +227,21 @@ public class FFFGDlg extends CaveSWTDialog implements ISourceCompAction,
|
||||||
*/
|
*/
|
||||||
private RetrieveMergeDlg retMergeDlg;
|
private RetrieveMergeDlg retMergeDlg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dialog prompting the user for save file.
|
||||||
|
*/
|
||||||
|
private LoadSaveDeleteSelectDlg saveDlg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dialog prompting the user for delete file.
|
||||||
|
*/
|
||||||
|
private LoadSaveDeleteSelectDlg deleteDlg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dialog for getting file to retrieve.
|
||||||
|
*/
|
||||||
|
private LoadSaveDeleteSelectDlg loadDlg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Popup for Help menu item
|
* Popup for Help menu item
|
||||||
*/
|
*/
|
||||||
|
@ -1575,32 +1599,73 @@ public class FFFGDlg extends CaveSWTDialog implements ISourceCompAction,
|
||||||
* Retrieve saved data.
|
* Retrieve saved data.
|
||||||
*/
|
*/
|
||||||
private void retrieveSavedData() {
|
private void retrieveSavedData() {
|
||||||
RetrieveMergeAction action = RetrieveMergeDlg.RetrieveMergeAction.CANCEL;
|
if (loadDlg != null) {
|
||||||
|
// The RetriveMergeDlg has done its work but still waiting for the
|
||||||
if (isDialogClear() && (fileNameLbl.getText().trim().length() == 0)) {
|
// user to pick file to retrive.
|
||||||
action = RetrieveMergeAction.RETRIEVE;
|
loadDlg.open();
|
||||||
} else {
|
|
||||||
if (retMergeDlg == null) {
|
|
||||||
retMergeDlg = new RetrieveMergeDlg(shell);
|
|
||||||
action = retMergeDlg.open();
|
|
||||||
retMergeDlg = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (action == RetrieveMergeAction.CANCEL) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isDialogClear() && (fileNameLbl.getText().trim().length() == 0)) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
if (retMergeDlg == null) {
|
||||||
|
retMergeDlg = new RetrieveMergeDlg(shell);
|
||||||
|
retMergeDlg.setCloseCallback(new ICloseCallback() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dialogClosed(Object returnValue) {
|
||||||
|
if (returnValue instanceof RetrieveMergeAction) {
|
||||||
|
RetrieveMergeAction action = (RetrieveMergeAction) returnValue;
|
||||||
|
getRetrieveFilename(action);
|
||||||
|
}
|
||||||
|
retMergeDlg = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
retMergeDlg.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get file to retrieve and then perform the action.
|
||||||
|
*
|
||||||
|
* @param action
|
||||||
|
*/
|
||||||
|
private void getRetrieveFilename(final RetrieveMergeAction action) {
|
||||||
|
|
||||||
FFFGDataMgr fdm = FFFGDataMgr.getInstance();
|
FFFGDataMgr fdm = FFFGDataMgr.getInstance();
|
||||||
|
|
||||||
LoadSaveDeleteSelectDlg loadDlg = new LoadSaveDeleteSelectDlg(shell,
|
loadDlg = new LoadSaveDeleteSelectDlg(shell, DialogType.OPEN,
|
||||||
DialogType.OPEN, fdm.getFFFGDataFilePath(),
|
fdm.getFFFGDataFilePath(), fdm.getFFFGMasterFileName());
|
||||||
fdm.getFFFGMasterFileName());
|
|
||||||
LocalizationFile fileName = (LocalizationFile) loadDlg.open();
|
loadDlg.setCloseCallback(new ICloseCallback() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dialogClosed(Object returnValue) {
|
||||||
|
if (returnValue instanceof LocalizationFile) {
|
||||||
|
LocalizationFile fileName = (LocalizationFile) returnValue;
|
||||||
|
doRetrieveSavedData(action, fileName);
|
||||||
|
}
|
||||||
|
loadDlg = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
loadDlg.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform the desired and and update the display.
|
||||||
|
*
|
||||||
|
* @param action
|
||||||
|
* @param fileName
|
||||||
|
*/
|
||||||
|
private void doRetrieveSavedData(RetrieveMergeAction action,
|
||||||
|
LocalizationFile fileName) {
|
||||||
|
|
||||||
if (fileName == null) {
|
if (fileName == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
FFFGDataMgr fdm = FFFGDataMgr.getInstance();
|
||||||
|
|
||||||
fdm.loadUserFFFGData(fileName.getFile().getName());
|
fdm.loadUserFFFGData(fileName.getFile().getName());
|
||||||
|
|
||||||
|
@ -1812,16 +1877,28 @@ public class FFFGDlg extends CaveSWTDialog implements ISourceCompAction,
|
||||||
* Save the file to a user selected file name.
|
* Save the file to a user selected file name.
|
||||||
*/
|
*/
|
||||||
private void saveFileAs() {
|
private void saveFileAs() {
|
||||||
FFFGDataMgr fdm = FFFGDataMgr.getInstance();
|
if (saveDlg == null) {
|
||||||
|
FFFGDataMgr fdm = FFFGDataMgr.getInstance();
|
||||||
|
|
||||||
LoadSaveDeleteSelectDlg loadDlg = new LoadSaveDeleteSelectDlg(shell,
|
saveDlg = new LoadSaveDeleteSelectDlg(shell, DialogType.SAVE_AS,
|
||||||
DialogType.SAVE_AS, fdm.getFFFGDataFilePath(),
|
fdm.getFFFGDataFilePath(), fdm.getFFFGMasterFileName());
|
||||||
fdm.getFFFGMasterFileName());
|
saveDlg.setCloseCallback(new ICloseCallback() {
|
||||||
LocalizationFile fileName = (LocalizationFile) loadDlg.open();
|
|
||||||
|
|
||||||
if (fileName == null) {
|
@Override
|
||||||
return;
|
public void dialogClosed(Object returnValue) {
|
||||||
|
if (returnValue instanceof LocalizationFile) {
|
||||||
|
LocalizationFile fileName = (LocalizationFile) returnValue;
|
||||||
|
doSaveFileAs(fileName);
|
||||||
|
}
|
||||||
|
saveDlg = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
saveDlg.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doSaveFileAs(LocalizationFile fileName) {
|
||||||
|
FFFGDataMgr fdm = FFFGDataMgr.getInstance();
|
||||||
|
|
||||||
ArrayList<SourceCompData> srcCompData = getSourceCompData();
|
ArrayList<SourceCompData> srcCompData = getSourceCompData();
|
||||||
|
|
||||||
|
@ -1861,20 +1938,32 @@ public class FFFGDlg extends CaveSWTDialog implements ISourceCompAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete that user selected file.
|
* Delete the user selected file.
|
||||||
*/
|
*/
|
||||||
private void deleteFile() {
|
private void deleteFile() {
|
||||||
FFFGDataMgr fdm = FFFGDataMgr.getInstance();
|
if (deleteDlg == null) {
|
||||||
|
FFFGDataMgr fdm = FFFGDataMgr.getInstance();
|
||||||
|
|
||||||
LoadSaveDeleteSelectDlg lsDlg = new LoadSaveDeleteSelectDlg(shell,
|
deleteDlg = new LoadSaveDeleteSelectDlg(shell, DialogType.DELETE,
|
||||||
DialogType.DELETE, fdm.getFFFGDataFilePath(),
|
fdm.getFFFGDataFilePath(), fdm.getFFFGMasterFileName());
|
||||||
fdm.getFFFGMasterFileName());
|
deleteDlg.setCloseCallback(new ICloseCallback() {
|
||||||
LocalizationFile fileName = (LocalizationFile) lsDlg.open();
|
|
||||||
|
|
||||||
if (fileName == null) {
|
@Override
|
||||||
setStatusMsg("FileName is null...");
|
public void dialogClosed(Object returnValue) {
|
||||||
return;
|
if (returnValue instanceof LocalizationFile) {
|
||||||
|
LocalizationFile fileName = (LocalizationFile) returnValue;
|
||||||
|
doDeleteFile(fileName);
|
||||||
|
}
|
||||||
|
deleteDlg = null;
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
deleteDlg.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doDeleteFile(LocalizationFile fileName) {
|
||||||
|
FFFGDataMgr fdm = FFFGDataMgr.getInstance();
|
||||||
|
String name = fileName.getFile().getName();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (fileName.getFile().getName().compareTo(fdm.getUserFileName()) == 0) {
|
if (fileName.getFile().getName().compareTo(fdm.getUserFileName()) == 0) {
|
||||||
|
@ -1882,12 +1971,13 @@ public class FFFGDlg extends CaveSWTDialog implements ISourceCompAction,
|
||||||
fileNameLbl.setText("");
|
fileNameLbl.setText("");
|
||||||
updateFileStatusLabel(false);
|
updateFileStatusLabel(false);
|
||||||
}
|
}
|
||||||
String name = fileName.getFile().getName();
|
|
||||||
fileName.delete();
|
fileName.delete();
|
||||||
setStatusMsg("Deleted " + name + " successfully. ");
|
setStatusMsg("Deleted " + name + " successfully. ");
|
||||||
fileName = null;
|
fileName = null;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
statusHandler.handle(Priority.PROBLEM, "Unable to delete file \""
|
||||||
|
+ fileName.toString() + "\"", e);
|
||||||
|
setStatusMsg("Problem deleting file: " + name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,273 +20,218 @@
|
||||||
package com.raytheon.uf.viz.monitor.ffmp.fffg;
|
package com.raytheon.uf.viz.monitor.ffmp.fffg;
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.DisposeEvent;
|
|
||||||
import org.eclipse.swt.events.DisposeListener;
|
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.events.SelectionListener;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Button;
|
import org.eclipse.swt.widgets.Button;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Dialog;
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
import org.eclipse.swt.widgets.Group;
|
import org.eclipse.swt.widgets.Group;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog used to bring data in for the FFFG dialog. There are
|
* Dialog used to bring data in for the FFFG dialog. There are 3 options:
|
||||||
* 3 options:
|
|
||||||
*
|
*
|
||||||
* Retrieve - Clear current data entirely and load data from the selected file.
|
* Retrieve - Clear current data entirely and load data from the selected file.
|
||||||
*
|
*
|
||||||
* Merge - Retain current data and load data from the selected file. Current
|
* Merge - Retain current data and load data from the selected file. Current
|
||||||
* data will NOT be overwritten by incoming data when the two conflict.
|
* data will NOT be overwritten by incoming data when the two conflict.
|
||||||
*
|
*
|
||||||
* Merge/Overwrite - Retain current data and load data from the selected file.
|
* Merge/Overwrite - Retain current data and load data from the selected file.
|
||||||
* Incoming data will overwrite current data when the two
|
* Incoming data will overwrite current data when the two conflict.
|
||||||
* conflict.
|
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
*
|
||||||
* SOFTWARE HISTORY
|
* SOFTWARE HISTORY
|
||||||
*
|
*
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Oct 13, 2010 lvenable Initial creation
|
* Oct 13, 2010 lvenable Initial creation
|
||||||
*
|
* Nov 29, 2012 1353 rferrel Convert to CavSWTDialog
|
||||||
|
* and make non-blocking
|
||||||
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author lvenable
|
* @author lvenable
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public class RetrieveMergeDlg extends Dialog
|
public class RetrieveMergeDlg extends CaveSWTDialog {
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Dialog shell.
|
|
||||||
*/
|
|
||||||
private Shell shell;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The display control.
|
|
||||||
*/
|
|
||||||
private Display display;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enumeration of the retrieve options.
|
* Enumeration of the retrieve options.
|
||||||
*/
|
*/
|
||||||
public static enum RetrieveMergeAction
|
public static enum RetrieveMergeAction {
|
||||||
{
|
RETRIEVE("Retrieve"), MERGE_OVERWRITE("Merge/Overwrite"), MERGE("Merge"), CANCEL(
|
||||||
RETRIEVE("Retrieve"),
|
"Cancel");
|
||||||
MERGE_OVERWRITE("Merge/Overwrite"),
|
|
||||||
MERGE("Merge"),
|
|
||||||
CANCEL("Cancel");
|
|
||||||
|
|
||||||
private String actionName;
|
private String actionName;
|
||||||
|
|
||||||
RetrieveMergeAction(String name)
|
RetrieveMergeAction(String name) {
|
||||||
{
|
|
||||||
actionName = name;
|
actionName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getActionName()
|
public String getActionName() {
|
||||||
{
|
|
||||||
return actionName;
|
return actionName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve choice.
|
|
||||||
*/
|
|
||||||
private RetrieveMergeAction choice = RetrieveMergeAction.CANCEL;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve radio button.
|
* Retrieve radio button.
|
||||||
*/
|
*/
|
||||||
private Button retrieveRdo;
|
private Button retrieveRdo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge/Overwrite button.
|
* Merge/Overwrite button.
|
||||||
*/
|
*/
|
||||||
private Button mergeOvrWriteRdo;
|
private Button mergeOvrWriteRdo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge button.
|
* Merge button.
|
||||||
*/
|
*/
|
||||||
private Button mergeRdo;
|
private Button mergeRdo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The selected button.
|
||||||
|
*/
|
||||||
|
private Button selectedRdo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
* @param parent Parent control.
|
*
|
||||||
|
* @param parent
|
||||||
|
* Parent control.
|
||||||
*/
|
*/
|
||||||
public RetrieveMergeDlg(Shell parent)
|
public RetrieveMergeDlg(Shell parent) {
|
||||||
{
|
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||||
super(parent, 0);
|
setText("Retrieve/Merge FFG File");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Open/Display the dialog.
|
protected void initializeComponents(Shell shell) {
|
||||||
* @return The choice made by the operator.
|
|
||||||
*/
|
|
||||||
public RetrieveMergeAction open()
|
|
||||||
{
|
|
||||||
Shell parent = getParent();
|
|
||||||
display = parent.getDisplay();
|
|
||||||
shell = new Shell(parent, SWT.DIALOG_TRIM);
|
|
||||||
shell.setText("Retrieve/Merge FFG File");
|
|
||||||
|
|
||||||
// Create the main layout for the shell.
|
// Create the main layout for the shell.
|
||||||
GridLayout mainLayout = new GridLayout(1, false);
|
GridLayout mainLayout = new GridLayout(1, false);
|
||||||
mainLayout.marginHeight = 3;
|
mainLayout.marginHeight = 3;
|
||||||
mainLayout.marginWidth = 3;
|
mainLayout.marginWidth = 3;
|
||||||
shell.setLayout(mainLayout);
|
shell.setLayout(mainLayout);
|
||||||
|
|
||||||
// Initialize all of the controls and layouts
|
// Initialize all of the controls and layouts
|
||||||
initializeComponents();
|
initializeComponents();
|
||||||
|
|
||||||
parent.addDisposeListener(new DisposeListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void widgetDisposed(DisposeEvent e)
|
|
||||||
{
|
|
||||||
shell.dispose();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
shell.pack();
|
|
||||||
|
|
||||||
shell.open();
|
|
||||||
while (!shell.isDisposed())
|
|
||||||
{
|
|
||||||
if (!display.readAndDispatch())
|
|
||||||
{
|
|
||||||
display.sleep();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return choice;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the controls on the dialog.
|
* Initialize the controls on the dialog.
|
||||||
*/
|
*/
|
||||||
private void initializeComponents()
|
private void initializeComponents() {
|
||||||
{
|
|
||||||
createRetrieveMergeControls();
|
createRetrieveMergeControls();
|
||||||
createBottomButtons();
|
createBottomButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the Retrieve, Merge/Overwrite, and Merge controls.
|
* Create the Retrieve, Merge/Overwrite, and Merge controls.
|
||||||
*/
|
*/
|
||||||
private void createRetrieveMergeControls()
|
private void createRetrieveMergeControls() {
|
||||||
{
|
|
||||||
Group controlGrp = new Group(shell, SWT.BORDER);
|
Group controlGrp = new Group(shell, SWT.BORDER);
|
||||||
GridLayout gl = new GridLayout(2, false);
|
GridLayout gl = new GridLayout(2, false);
|
||||||
gl.verticalSpacing = 20;
|
gl.verticalSpacing = 20;
|
||||||
controlGrp.setLayout(gl);
|
controlGrp.setLayout(gl);
|
||||||
controlGrp.setText(" Please choose your selection: ");
|
controlGrp.setText(" Please choose your selection: ");
|
||||||
|
|
||||||
|
SelectionListener listener = new SelectionAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
Button button = (Button) e.widget;
|
||||||
|
if (button.getSelection()) {
|
||||||
|
selectedRdo = button;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
GridData gd = new GridData(SWT.DEFAULT, SWT.TOP, false, true);
|
GridData gd = new GridData(SWT.DEFAULT, SWT.TOP, false, true);
|
||||||
retrieveRdo = new Button(controlGrp, SWT.RADIO);
|
retrieveRdo = new Button(controlGrp, SWT.RADIO);
|
||||||
retrieveRdo.setText("Retrieve: ");
|
retrieveRdo.setText("Retrieve: ");
|
||||||
retrieveRdo.setSelection(true);
|
retrieveRdo.setSelection(true);
|
||||||
|
selectedRdo = retrieveRdo;
|
||||||
|
selectedRdo.addSelectionListener(listener);
|
||||||
|
selectedRdo.setData(RetrieveMergeAction.RETRIEVE);
|
||||||
retrieveRdo.setLayoutData(gd);
|
retrieveRdo.setLayoutData(gd);
|
||||||
|
|
||||||
Label retrieveLbl = new Label(controlGrp, SWT.NONE);
|
Label retrieveLbl = new Label(controlGrp, SWT.NONE);
|
||||||
retrieveLbl.setText("Clear current data entirely and load data\nfrom the selected file.");
|
retrieveLbl
|
||||||
|
.setText("Clear current data entirely and load data\nfrom the selected file.");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ** NOTE:
|
* ** NOTE: The merge features are disabled due to the limitations of
|
||||||
* The merge features are disabled due to the limitations
|
* having 4 sources to edit. If 3 unique sources are to be merged with 3
|
||||||
* of having 4 sources to edit. If 3 unique sources are to
|
* other unique sources on the display there would be 6 sources trying
|
||||||
* be merged with 3 other unique sources on the display there
|
* to fit into 4 available areas. I have ideas for a more elegant
|
||||||
* would be 6 sources trying to fit into 4 available areas.
|
* solution that will allow more than just 4 sources.
|
||||||
* I have ideas for a more elegant solution that will allow
|
|
||||||
* more than just 4 sources.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
gd = new GridData(SWT.DEFAULT, SWT.TOP, false, true);
|
gd = new GridData(SWT.DEFAULT, SWT.TOP, false, true);
|
||||||
mergeOvrWriteRdo = new Button(controlGrp, SWT.RADIO);
|
mergeOvrWriteRdo = new Button(controlGrp, SWT.RADIO);
|
||||||
mergeOvrWriteRdo.setText("Merge Overwrite: ");
|
mergeOvrWriteRdo.setText("Merge Overwrite: ");
|
||||||
|
mergeOvrWriteRdo.addSelectionListener(listener);
|
||||||
|
mergeOvrWriteRdo.setData(RetrieveMergeAction.MERGE_OVERWRITE);
|
||||||
mergeOvrWriteRdo.setLayoutData(gd);
|
mergeOvrWriteRdo.setLayoutData(gd);
|
||||||
|
|
||||||
Label mergeOvrWriteLbl = new Label(controlGrp, SWT.NONE);
|
Label mergeOvrWriteLbl = new Label(controlGrp, SWT.NONE);
|
||||||
mergeOvrWriteLbl.setText("Retain current data and load data from the\n" +
|
mergeOvrWriteLbl.setText("Retain current data and load data from the\n"
|
||||||
"selected file. Incoming data will overwrite\n" +
|
+ "selected file. Incoming data will overwrite\n"
|
||||||
"current data when the two conflict.");
|
+ "current data when the two conflict.");
|
||||||
|
|
||||||
gd = new GridData(SWT.DEFAULT, SWT.TOP, false, true);
|
gd = new GridData(SWT.DEFAULT, SWT.TOP, false, true);
|
||||||
mergeRdo = new Button(controlGrp, SWT.RADIO);
|
mergeRdo = new Button(controlGrp, SWT.RADIO);
|
||||||
mergeRdo.setText("Merge: ");
|
mergeRdo.setText("Merge: ");
|
||||||
|
mergeRdo.addSelectionListener(listener);
|
||||||
|
mergeRdo.setData(RetrieveMergeAction.MERGE);
|
||||||
mergeRdo.setLayoutData(gd);
|
mergeRdo.setLayoutData(gd);
|
||||||
|
|
||||||
Label mergeLbl = new Label(controlGrp, SWT.NONE);
|
Label mergeLbl = new Label(controlGrp, SWT.NONE);
|
||||||
mergeLbl.setText("Retain current data and load data from the\n" +
|
mergeLbl.setText("Retain current data and load data from the\n"
|
||||||
"selected file. Current data will NOT be\n" +
|
+ "selected file. Current data will NOT be\n"
|
||||||
"overwritten by incoming data when the two\n" +
|
+ "overwritten by incoming data when the two\n" + "conflict.");
|
||||||
"conflict.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the buttons on the bottom of the display.
|
* Create the buttons on the bottom of the display.
|
||||||
*/
|
*/
|
||||||
private void createBottomButtons()
|
private void createBottomButtons() {
|
||||||
{
|
|
||||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
Composite buttonComp = new Composite(shell, SWT.NONE);
|
Composite buttonComp = new Composite(shell, SWT.NONE);
|
||||||
buttonComp.setLayout(new GridLayout(2, false));
|
buttonComp.setLayout(new GridLayout(2, false));
|
||||||
buttonComp.setLayoutData(gd);
|
buttonComp.setLayoutData(gd);
|
||||||
|
|
||||||
int buttonWidth = 100;
|
int buttonWidth = 100;
|
||||||
|
|
||||||
gd = new GridData(SWT.RIGHT, SWT.DEFAULT, true, false);
|
gd = new GridData(SWT.RIGHT, SWT.DEFAULT, true, false);
|
||||||
gd.widthHint = buttonWidth;
|
gd.widthHint = buttonWidth;
|
||||||
Button okBtn = new Button(buttonComp, SWT.PUSH);
|
Button okBtn = new Button(buttonComp, SWT.PUSH);
|
||||||
okBtn.setText("OK");
|
okBtn.setText("OK");
|
||||||
okBtn.setLayoutData(gd);
|
okBtn.setLayoutData(gd);
|
||||||
okBtn.addSelectionListener(new SelectionAdapter()
|
okBtn.addSelectionListener(new SelectionAdapter() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e)
|
public void widgetSelected(SelectionEvent e) {
|
||||||
{
|
setReturnValue(selectedRdo.getData());
|
||||||
updateChoice();
|
close();
|
||||||
shell.dispose();
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
gd = new GridData(SWT.LEFT, SWT.DEFAULT, true, false);
|
gd = new GridData(SWT.LEFT, SWT.DEFAULT, true, false);
|
||||||
gd.widthHint = buttonWidth;
|
gd.widthHint = buttonWidth;
|
||||||
Button cancelBtn = new Button(buttonComp, SWT.PUSH);
|
Button cancelBtn = new Button(buttonComp, SWT.PUSH);
|
||||||
cancelBtn.setText("Cancel");
|
cancelBtn.setText("Cancel");
|
||||||
cancelBtn.setLayoutData(gd);
|
cancelBtn.setLayoutData(gd);
|
||||||
cancelBtn.addSelectionListener(new SelectionAdapter()
|
cancelBtn.addSelectionListener(new SelectionAdapter() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e)
|
public void widgetSelected(SelectionEvent e) {
|
||||||
{
|
close();
|
||||||
choice = RetrieveMergeAction.CANCEL;
|
}
|
||||||
shell.dispose();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the choice selected by the operator.
|
|
||||||
*/
|
|
||||||
private void updateChoice()
|
|
||||||
{
|
|
||||||
if (retrieveRdo.getSelection() == true)
|
|
||||||
{
|
|
||||||
choice = RetrieveMergeAction.RETRIEVE;
|
|
||||||
}
|
|
||||||
else if (mergeOvrWriteRdo.getSelection() == true)
|
|
||||||
{
|
|
||||||
choice = RetrieveMergeAction.MERGE_OVERWRITE;
|
|
||||||
}
|
|
||||||
else if (mergeRdo.getSelection() == true)
|
|
||||||
{
|
|
||||||
choice = RetrieveMergeAction.MERGE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue