Issue #1287 Code changes for non-blocking SaveDeleteRefDialog.

Change-Id: I6bf23b8f3d9bac171f9a296e3d47b86851a3e1e0

Former-commit-id: c2def88db1 [formerly c2def88db1 [formerly 085fc755257ed8728a293d59670a79f79293dcbb]]
Former-commit-id: 347ad433ef
Former-commit-id: 56515fc4d6
This commit is contained in:
Roger Ferrel 2012-10-24 12:41:33 -05:00
parent 823e1099e9
commit f0867f4c40
2 changed files with 39 additions and 26 deletions

View file

@ -91,6 +91,7 @@ import com.vividsolutions.jts.geom.MultiPolygon;
* Mar 11, 2008 Eric Babin Initial Creation * Mar 11, 2008 Eric Babin Initial Creation
* Jul 15, 2008 njensen Hooked into backend/fixes * Jul 15, 2008 njensen Hooked into backend/fixes
* Oct 24, 2012 1287 rferrel Code clean up for non-blocking dialog. * Oct 24, 2012 1287 rferrel Code clean up for non-blocking dialog.
* Oct 24, 2012 1287 rferrel Changes for non-blocking SaveDeleteRefDialog.
* *
* </pre> * </pre>
* *
@ -163,6 +164,10 @@ public class DefineRefSetDialog extends CaveJFACEDialog implements
private String[] initialGroups; private String[] initialGroups;
private SaveDeleteRefDialog deleteDlg;
private SaveDeleteRefDialog saveDlg;
public DefineRefSetDialog(Shell parent, DataManager dataManager) { public DefineRefSetDialog(Shell parent, DataManager dataManager) {
super(parent); super(parent);
this.setShellStyle(SWT.DIALOG_TRIM | SWT.MODELESS); this.setShellStyle(SWT.DIALOG_TRIM | SWT.MODELESS);
@ -999,19 +1004,28 @@ public class DefineRefSetDialog extends CaveJFACEDialog implements
private void saveAreaCB() { private void saveAreaCB() {
SaveDeleteRefDialog dialog = new SaveDeleteRefDialog(getShell(), if (saveDlg == null || saveDlg.getShell() == null
this.refSetMgr, "Save"); || saveDlg.isDisposed()) {
saveDlg = new SaveDeleteRefDialog(getShell(), this.refSetMgr,
dialog.open(); "Save");
saveDlg.setBlockOnOpen(false);
saveDlg.open();
} else {
saveDlg.bringToTop();
}
} }
private void deleteAreaCB() { private void deleteAreaCB() {
SaveDeleteRefDialog dialog = new SaveDeleteRefDialog(this.getShell(), if (deleteDlg == null || deleteDlg.getShell() == null
refSetMgr, "Delete"); || deleteDlg.isDisposed()) {
dialog.open(); deleteDlg = new SaveDeleteRefDialog(this.getShell(), refSetMgr,
"Delete");
deleteDlg.setBlockOnOpen(false);
deleteDlg.open();
} else {
deleteDlg.bringToTop();
}
} }
private void saveGroupCB() { private void saveGroupCB() {

View file

@ -42,20 +42,18 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData; import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData;
import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceID;
import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData.RefType; import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData.RefType;
import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceID;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.viz.gfe.Activator;
import com.raytheon.viz.gfe.constants.StatusConstants;
import com.raytheon.viz.gfe.core.IReferenceSetManager; import com.raytheon.viz.gfe.core.IReferenceSetManager;
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
import com.raytheon.viz.ui.widgets.ToggleSelectList; import com.raytheon.viz.ui.widgets.ToggleSelectList;
/** /**
* TODO Add Description * Dialog for performing a save or delete of an Edit Area.
* *
* <pre> * <pre>
* *
@ -63,6 +61,7 @@ import com.raytheon.viz.ui.widgets.ToggleSelectList;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Sep 10, 2010 randerso Initial creation * Sep 10, 2010 randerso Initial creation
* Oct 24, 2012 1287 rferrel Code clean up part of non-blocking dialog.
* *
* </pre> * </pre>
* *
@ -71,11 +70,12 @@ import com.raytheon.viz.ui.widgets.ToggleSelectList;
*/ */
public class SaveDeleteRefDialog extends CaveJFACEDialog { public class SaveDeleteRefDialog extends CaveJFACEDialog {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(SaveDeleteRefDialog.class); private final transient IUFStatusHandler statusHandler = UFStatus
private static final Pattern pythonVariable = Pattern .getHandler(SaveDeleteRefDialog.class);
.compile("\\p{Alpha}\\w*");
private static final int NUM_ITEMS = 10; private final Pattern pythonVariable = Pattern.compile("\\p{Alpha}\\w*");
private final int NUM_ITEMS = 10;
private IReferenceSetManager refSetMgr; private IReferenceSetManager refSetMgr;
@ -156,9 +156,9 @@ public class SaveDeleteRefDialog extends CaveJFACEDialog {
editAreaList = new org.eclipse.swt.widgets.List(areaFrame, SWT.BORDER editAreaList = new org.eclipse.swt.widgets.List(areaFrame, SWT.BORDER
| SWT.V_SCROLL | SWT.SINGLE); | SWT.V_SCROLL | SWT.SINGLE);
Rectangle rect = editAreaList.computeTrim(0, 0, this Rectangle rect = editAreaList.computeTrim(0, 0,
.convertWidthInCharsToPixels(24), editAreaList.getItemHeight() this.convertWidthInCharsToPixels(24),
* NUM_ITEMS); editAreaList.getItemHeight() * NUM_ITEMS);
layoutData = new GridData(GridData.FILL_BOTH); layoutData = new GridData(GridData.FILL_BOTH);
layoutData.minimumWidth = rect.width; layoutData.minimumWidth = rect.width;
layoutData.heightHint = rect.height; layoutData.heightHint = rect.height;
@ -207,10 +207,9 @@ public class SaveDeleteRefDialog extends CaveJFACEDialog {
groupListBox = new ToggleSelectList(groupFrame, SWT.BORDER groupListBox = new ToggleSelectList(groupFrame, SWT.BORDER
| SWT.V_SCROLL | SWT.MULTI); | SWT.V_SCROLL | SWT.MULTI);
rect = groupListBox.computeTrim(0, 0, this rect = groupListBox.computeTrim(0, 0,
.convertWidthInCharsToPixels(24), groupListBox this.convertWidthInCharsToPixels(24),
.getItemHeight() groupListBox.getItemHeight() * NUM_ITEMS);
* NUM_ITEMS);
layoutData = new GridData(GridData.FILL_BOTH); layoutData = new GridData(GridData.FILL_BOTH);
layoutData.minimumWidth = rect.width; layoutData.minimumWidth = rect.width;
layoutData.heightHint = rect.height; layoutData.heightHint = rect.height;
@ -282,8 +281,8 @@ public class SaveDeleteRefDialog extends CaveJFACEDialog {
// Check that name is a legal Python variable so // Check that name is a legal Python variable so
// it can be used subsequently in queries // it can be used subsequently in queries
if (!pythonVariable.matcher(name).matches()) { if (!pythonVariable.matcher(name).matches()) {
statusHandler.handle( statusHandler
Priority.SIGNIFICANT, .handle(Priority.SIGNIFICANT,
"Illegal Name: Must begin with a letter and be alphanumeric or '_'. Please rename."); "Illegal Name: Must begin with a letter and be alphanumeric or '_'. Please rename.");
return false; return false;
} }