Merge "Issue #1298 Changes for non-blocking WeatherElementGroupDialog. Changes from reviewer comments." into development
Former-commit-id:cd0a4804c6
[formerly341dc89480
] [formerlycd0a4804c6
[formerly341dc89480
] [formerly7634ea221b
[formerly 3106b10a003ca5985e29c69ee0f02185c88edc12]]] Former-commit-id:7634ea221b
Former-commit-id:23f4face77
[formerly389f9c6a87
] Former-commit-id:5e37d88424
This commit is contained in:
commit
b6ffe0e535
2 changed files with 110 additions and 68 deletions
|
@ -54,6 +54,7 @@ import com.raytheon.viz.core.mode.CAVEMode;
|
||||||
import com.raytheon.viz.gfe.core.DataManager;
|
import com.raytheon.viz.gfe.core.DataManager;
|
||||||
import com.raytheon.viz.gfe.core.parm.Parm;
|
import com.raytheon.viz.gfe.core.parm.Parm;
|
||||||
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
|
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
|
||||||
|
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||||
import com.raytheon.viz.ui.widgets.ToggleSelectList;
|
import com.raytheon.viz.ui.widgets.ToggleSelectList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,6 +74,7 @@ import com.raytheon.viz.ui.widgets.ToggleSelectList;
|
||||||
* database list from ParmManager
|
* database list from ParmManager
|
||||||
* not EDEX.
|
* not EDEX.
|
||||||
* 10/30/2012 1298 rferrel Code clean up non-blocking dialog.
|
* 10/30/2012 1298 rferrel Code clean up non-blocking dialog.
|
||||||
|
* Changes for non-blocking WeatherElementGroupDialog.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author ebabin
|
* @author ebabin
|
||||||
|
@ -198,33 +200,49 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
|
||||||
/**
|
/**
|
||||||
* Show the save weather element dialog.
|
* Show the save weather element dialog.
|
||||||
*/
|
*/
|
||||||
private void showSaveWeatherElementGroup(Menu loadWeatherElementGroupMenu) {
|
private void showSaveWeatherElementGroup(
|
||||||
|
final Menu loadWeatherElementGroupMenu) {
|
||||||
WeatherElementGroupDialog dialog = new WeatherElementGroupDialog(
|
// The dialog being opened is modal to the parent dialog. This will
|
||||||
|
// prevent the launching of another dialog until the modal dialog is
|
||||||
|
// closed.
|
||||||
|
final WeatherElementGroupDialog dialog = new WeatherElementGroupDialog(
|
||||||
getShell(), dataManager, true);
|
getShell(), dataManager, true);
|
||||||
dialog.setBlockOnOpen(true);
|
dialog.setBlockOnOpen(false);
|
||||||
|
dialog.setCloseCallback(new ICloseCallback() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dialogClosed(Object returnValue) {
|
||||||
|
if (returnValue instanceof Integer) {
|
||||||
|
int returnCode = (Integer) returnValue;
|
||||||
|
if (returnCode == Window.OK) {
|
||||||
|
String groupName = dialog.getSelectedItem();
|
||||||
|
doSaveWeatherElementGroup(loadWeatherElementGroupMenu,
|
||||||
|
groupName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
dialog.open();
|
dialog.open();
|
||||||
if (dialog.getReturnCode() == Window.OK) {
|
}
|
||||||
String groupName = dialog.getSelectedItem();
|
|
||||||
if (groupName != null) {
|
private void doSaveWeatherElementGroup(Menu loadWeatherElementGroupMenu,
|
||||||
ParmID[] selectedParmIds = getSelectedParmIDS();
|
String groupName) {
|
||||||
if ((selectedParmIds != null) && (selectedParmIds.length > 0)) {
|
if (groupName != null) {
|
||||||
ParmID[] availIds = selectedType.getPossibleParmIDs();
|
ParmID[] selectedParmIds = getSelectedParmIDS();
|
||||||
if ((availIds != null) && (availIds.length != 0)) {
|
if ((selectedParmIds != null) && (selectedParmIds.length > 0)) {
|
||||||
dataManager.getWEGroupManager().save(groupName,
|
ParmID[] availIds = selectedType.getPossibleParmIDs();
|
||||||
selectedParmIds, availIds);
|
if ((availIds != null) && (availIds.length != 0)) {
|
||||||
boolean alreadyListed = false;
|
dataManager.getWEGroupManager().save(groupName,
|
||||||
for (MenuItem item : loadWeatherElementGroupMenu
|
selectedParmIds, availIds);
|
||||||
.getItems()) {
|
boolean alreadyListed = false;
|
||||||
if (item.getText().equals(groupName)) {
|
for (MenuItem item : loadWeatherElementGroupMenu.getItems()) {
|
||||||
alreadyListed = true;
|
if (item.getText().equals(groupName)) {
|
||||||
}
|
alreadyListed = true;
|
||||||
}
|
|
||||||
if (!alreadyListed) {
|
|
||||||
addWEGroup(loadWeatherElementGroupMenu, groupName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!alreadyListed) {
|
||||||
|
addWEGroup(loadWeatherElementGroupMenu, groupName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -233,22 +251,36 @@ public class WeatherElementBrowserDialog extends CaveJFACEDialog {
|
||||||
/**
|
/**
|
||||||
* Show delete weather element dialog.
|
* Show delete weather element dialog.
|
||||||
*/
|
*/
|
||||||
private void showDeleteWeatherElementGroup(Menu loadWeatherElementGroupMenu) {
|
private void showDeleteWeatherElementGroup(
|
||||||
|
final Menu loadWeatherElementGroupMenu) {
|
||||||
|
// The dialog being opened is modal to the parent dialog. This will
|
||||||
|
// prevent the launching of another dialog until the modal dialog is
|
||||||
|
// closed.
|
||||||
final WeatherElementGroupDialog dialog = new WeatherElementGroupDialog(
|
final WeatherElementGroupDialog dialog = new WeatherElementGroupDialog(
|
||||||
getShell(), this.dataManager, false);
|
getShell(), this.dataManager, false);
|
||||||
dialog.setBlockOnOpen(true);
|
dialog.setBlockOnOpen(false);
|
||||||
dialog.open();
|
dialog.setCloseCallback(new ICloseCallback() {
|
||||||
if ((dialog.getReturnCode() == Window.OK)
|
|
||||||
&& (dialog.getSelectedItem() != null)) {
|
@Override
|
||||||
String groupName = dialog.getSelectedItem();
|
public void dialogClosed(Object returnValue) {
|
||||||
// we may have just overridden a site or base level group, need to
|
if (returnValue instanceof Integer) {
|
||||||
// verify menu item can be deleted
|
int returnCode = (Integer) returnValue;
|
||||||
if (dataManager.getWEGroupManager().remove(groupName)
|
if (returnCode == Window.OK
|
||||||
&& !dataManager.getWEGroupManager().getInventory()
|
&& dialog.getSelectedItem() != null) {
|
||||||
.contains(groupName)) {
|
String groupName = dialog.getSelectedItem();
|
||||||
removeWEGroup(loadWeatherElementGroupMenu, groupName);
|
// we may have just overridden a site or base level
|
||||||
|
// group, need to verify menu item can be deleted
|
||||||
|
if (dataManager.getWEGroupManager().remove(groupName)
|
||||||
|
&& !dataManager.getWEGroupManager()
|
||||||
|
.getInventory().contains(groupName)) {
|
||||||
|
removeWEGroup(loadWeatherElementGroupMenu,
|
||||||
|
groupName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
dialog.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package com.raytheon.viz.gfe.dialogs;
|
package com.raytheon.viz.gfe.dialogs;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
|
@ -29,8 +30,10 @@ import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
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.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Control;
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.List;
|
import org.eclipse.swt.widgets.List;
|
||||||
import org.eclipse.swt.widgets.MessageBox;
|
import org.eclipse.swt.widgets.MessageBox;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
@ -53,6 +56,7 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 02/22/2008 Eric Babin Initial Creation
|
* 02/22/2008 Eric Babin Initial Creation
|
||||||
* 04/17/2009 #2282 rjpeter Added confirmation message on delete.
|
* 04/17/2009 #2282 rjpeter Added confirmation message on delete.
|
||||||
|
* 11/14/2012 #1298 rferrel Changes for non-blocking dialog.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author ebabin
|
* @author ebabin
|
||||||
|
@ -60,7 +64,7 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class WeatherElementGroupDialog extends CaveJFACEDialog {
|
public class WeatherElementGroupDialog extends CaveJFACEDialog {
|
||||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
private final transient IUFStatusHandler statusHandler = UFStatus
|
||||||
.getHandler(WeatherElementGroupDialog.class);
|
.getHandler(WeatherElementGroupDialog.class);
|
||||||
|
|
||||||
private Composite top;
|
private Composite top;
|
||||||
|
@ -75,6 +79,8 @@ public class WeatherElementGroupDialog extends CaveJFACEDialog {
|
||||||
|
|
||||||
private Text groupField;
|
private Text groupField;
|
||||||
|
|
||||||
|
private Button okButton;
|
||||||
|
|
||||||
private String selectedItem;
|
private String selectedItem;
|
||||||
|
|
||||||
private DataManager dataManager;
|
private DataManager dataManager;
|
||||||
|
@ -84,9 +90,11 @@ public class WeatherElementGroupDialog extends CaveJFACEDialog {
|
||||||
public WeatherElementGroupDialog(Shell parent, DataManager dataManager,
|
public WeatherElementGroupDialog(Shell parent, DataManager dataManager,
|
||||||
boolean saveType) {
|
boolean saveType) {
|
||||||
super(parent);
|
super(parent);
|
||||||
|
setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
|
||||||
this.dataManager = dataManager;
|
this.dataManager = dataManager;
|
||||||
this.wegManager = this.dataManager.getWEGroupManager();
|
this.wegManager = this.dataManager.getWEGroupManager();
|
||||||
this.saveType = saveType;
|
this.saveType = saveType;
|
||||||
|
this.selectedItem = "";
|
||||||
|
|
||||||
this.names = new ArrayList<String>();
|
this.names = new ArrayList<String>();
|
||||||
this.protectedNames = new ArrayList<String>();
|
this.protectedNames = new ArrayList<String>();
|
||||||
|
@ -119,6 +127,12 @@ public class WeatherElementGroupDialog extends CaveJFACEDialog {
|
||||||
|
|
||||||
private void initializeComponents() {
|
private void initializeComponents() {
|
||||||
|
|
||||||
|
if (names.size() == 0 && !saveType) {
|
||||||
|
Label label = new Label(top, SWT.CENTER);
|
||||||
|
label.setText("No groups available for deletion.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
GridData data = new GridData(GridData.FILL_BOTH);
|
GridData data = new GridData(GridData.FILL_BOTH);
|
||||||
|
|
||||||
groupList = new List(top, SWT.BORDER | SWT.SINGLE);
|
groupList = new List(top, SWT.BORDER | SWT.SINGLE);
|
||||||
|
@ -135,16 +149,21 @@ public class WeatherElementGroupDialog extends CaveJFACEDialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
groupList.setItems(names.toArray(new String[names.size()]));
|
|
||||||
|
String[] items = names.toArray(new String[names.size()]);
|
||||||
|
Arrays.sort(items);
|
||||||
|
groupList.setItems(items);
|
||||||
groupList.setSelection(0);
|
groupList.setSelection(0);
|
||||||
groupList.deselectAll();
|
groupList.deselectAll();
|
||||||
groupList.setLayoutData(data);
|
groupList.setLayoutData(data);
|
||||||
groupField = new Text(top, SWT.BORDER);
|
groupField = new Text(top, SWT.BORDER);
|
||||||
data = new GridData(GridData.FILL_HORIZONTAL);
|
data = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
groupField.setLayoutData(data);
|
groupField.setLayoutData(data);
|
||||||
|
groupField.setEnabled(saveType);
|
||||||
groupField.addModifyListener(new ModifyListener() {
|
groupField.addModifyListener(new ModifyListener() {
|
||||||
public void modifyText(ModifyEvent arg0) {
|
public void modifyText(ModifyEvent arg0) {
|
||||||
selectedItem = groupField.getText();
|
selectedItem = groupField.getText().trim();
|
||||||
|
okButton.setEnabled(selectedItem.length() > 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -177,7 +196,8 @@ public class WeatherElementGroupDialog extends CaveJFACEDialog {
|
||||||
} else {
|
} else {
|
||||||
label = "Delete";
|
label = "Delete";
|
||||||
}
|
}
|
||||||
createButton(parent, IDialogConstants.OK_ID, label, true);
|
okButton = createButton(parent, IDialogConstants.OK_ID, label, true);
|
||||||
|
okButton.setEnabled(false);
|
||||||
createButton(parent, IDialogConstants.CANCEL_ID,
|
createButton(parent, IDialogConstants.CANCEL_ID,
|
||||||
IDialogConstants.CANCEL_LABEL, false);
|
IDialogConstants.CANCEL_LABEL, false);
|
||||||
}
|
}
|
||||||
|
@ -193,37 +213,27 @@ public class WeatherElementGroupDialog extends CaveJFACEDialog {
|
||||||
@Override
|
@Override
|
||||||
protected void okPressed() {
|
protected void okPressed() {
|
||||||
boolean ok = true;
|
boolean ok = true;
|
||||||
|
String groupName = getSelectedItem();
|
||||||
|
|
||||||
if (!saveType) {
|
if (!FileUtil.isValidFilename(groupName)) {
|
||||||
String groupName = getSelectedItem();
|
MessageBox mb = new MessageBox(super.getShell(), SWT.ICON_ERROR
|
||||||
if (!FileUtil.isValidFilename(groupName)) {
|
| SWT.OK);
|
||||||
MessageBox mb = new MessageBox(super.getShell(), SWT.ICON_ERROR
|
mb.setText("Invalid Group Name");
|
||||||
| SWT.OK);
|
mb.setMessage("Group name may only contain the following characters: "
|
||||||
mb.setText("Invalid Group Name");
|
+ FileUtil.VALID_FILENAME_CHARS);
|
||||||
mb.setMessage("Group name may only contain the following characters: "
|
mb.open();
|
||||||
+ FileUtil.VALID_FILENAME_CHARS);
|
ok = false;
|
||||||
ok = false;
|
} else if (protectedNames.contains(groupName)) {
|
||||||
} else if (!protectedNames.contains(groupName)
|
statusHandler.handle(Priority.SIGNIFICANT, "Weather Element Group "
|
||||||
&& names.contains(groupName)) {
|
+ getSelectedItem() + " is protected or an invalid name.");
|
||||||
MessageBox mb = new MessageBox(super.getShell(),
|
ok = false;
|
||||||
SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
|
} else if (!saveType) {
|
||||||
mb.setText("Item Delete");
|
MessageBox mb = new MessageBox(super.getShell(), SWT.ICON_QUESTION
|
||||||
mb.setMessage(getSelectedItem() + " will be Deleted.");
|
| SWT.OK | SWT.CANCEL);
|
||||||
|
mb.setText("Item Delete");
|
||||||
|
mb.setMessage(getSelectedItem() + " will be Deleted.");
|
||||||
|
|
||||||
if (mb.open() == SWT.CANCEL) {
|
if (mb.open() == SWT.CANCEL) {
|
||||||
ok = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
statusHandler.handle(Priority.SIGNIFICANT,
|
|
||||||
"Weather Element Group " + groupName
|
|
||||||
+ " is protected or an invalid name.");
|
|
||||||
ok = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (protectedNames.contains(getSelectedItem())) {
|
|
||||||
statusHandler.handle(Priority.SIGNIFICANT,
|
|
||||||
"Weather Element Group " + getSelectedItem()
|
|
||||||
+ " is protected or an invalid name.");
|
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue