提交 08cdcba7 编写于 作者: S serge-rider

Panels contents reset confirmation

上级 4b64152a
......@@ -66,6 +66,7 @@ public final class DBeaverPreferences
public static final String CONFIRM_ORDER_RESULTSET = "order_resultset"; //$NON-NLS-1$
public static final String CONFIRM_RS_FETCH_ALL = "fetch_all_rows"; //$NON-NLS-1$
public static final String CONFIRM_RS_EDIT_CLOSE = "close_resultset_edit"; //$NON-NLS-1$
public static final String CONFIRM_RS_PANEL_RESET = "reset_panels_content"; //$NON-NLS-1$
public static final String CONFIRM_TXN_DISCONNECT = "disconnect_txn"; //$NON-NLS-1$
public static final String CONFIRM_ENTITY_EDIT_CLOSE = "close_entity_edit"; //$NON-NLS-1$
public static final String CONFIRM_ENTITY_DELETE = "entity_delete"; //$NON-NLS-1$
......
......@@ -119,6 +119,10 @@ public class CoreMessages extends NLS {
public static String confirm_close_resultset_edit_message;
public static String confirm_close_resultset_edit_toggleMessage;
public static String confirm_reset_panels_content_title;
public static String confirm_reset_panels_content_message;
public static String confirm_reset_panels_content_toggleMessage;
public static String confirm_disconnect_txn_title;
public static String confirm_disconnect_txn_message;
public static String confirm_disconnect_txn_toggleMessage;
......
......@@ -90,6 +90,10 @@ confirm_close_resultset_edit_message = Result set was edited. Do you want to sav
confirm_close_resultset_edit_title = Save result set edit
confirm_close_resultset_edit_toggleMessage = Remember choice
confirm_reset_panels_content_title = Panels content will be lost. Are you sure you want to continue?
confirm_reset_panels_content_message = Proceed and reset panels content
confirm_reset_panels_content_toggleMessage = Remember choice
confirm_close_editor_edit_message = "{0}" was changed. Do you want to save these changes?
confirm_close_editor_edit_title = Save editor changes
confirm_close_editor_edit_toggleMessage = Remember choice
......
......@@ -30,6 +30,8 @@ public interface IResultSetPanel {
Control createContents(IResultSetPresentation presentation, Composite parent);
boolean isDirty();
void activatePanel();
void deactivatePanel();
......
......@@ -2217,6 +2217,9 @@ public class ResultSetViewer extends Viewer
if (!confirmProceed()) {
return;
}
if (!newWindow && !confirmPanelsReset()) {
return;
}
if (getExecutionContext() == null) {
throw new DBException("Not connected");
......@@ -2355,6 +2358,30 @@ public class ResultSetViewer extends Viewer
return new UIConfirmation() { @Override public Boolean runTask() { return checkForChanges(); } }.confirm();
}
private boolean confirmPanelsReset() {
return new UIConfirmation() {
@Override public Boolean runTask() {
boolean panelsDirty = false;
for (IResultSetPanel panel : getActivePanels()) {
if (panel.isDirty()) {
panelsDirty = true;
break;
}
}
if (panelsDirty) {
int result = ConfirmationDialog.showConfirmDialog(
viewerPanel.getShell(),
DBeaverPreferences.CONFIRM_RS_PANEL_RESET,
ConfirmationDialog.CONFIRM);
if (result == IDialogConstants.CANCEL_ID) {
return false;
}
}
return true;
}
}.confirm();
}
private void openResultsInNewWindow(DBRProgressMonitor monitor, DBSEntity targetEntity, final DBDDataFilter newFilter) {
if (targetEntity instanceof DBSDataContainer) {
getContainer().openNewContainer(monitor, (DBSDataContainer) targetEntity, newFilter);
......
......@@ -114,6 +114,11 @@ public class AggregateColumnsPanel implements IResultSetPanel {
return this.aggregateTable;
}
@Override
public boolean isDirty() {
return false;
}
private void loadSettings() {
groupByColumns = panelSettings.getBoolean(PARAM_GROUP_BY_COLUMNS);
IDialogSettings functionsSection = panelSettings.getSection("functions");
......
......@@ -78,7 +78,7 @@ public class GroupingPanel implements IResultSetPanel {
// Or just clear it (if brand new query was executed)
String queryText = presentation.getController().getDataContainer().getName();
if (prevQueryText != null && !CommonUtils.equalObjects(prevQueryText, queryText)) {
resultsContainer.getResultSetController().setEmptyPresentation();
resultsContainer.clearGrouping();
} else {
try {
resultsContainer.rebuildGrouping();
......@@ -109,6 +109,11 @@ public class GroupingPanel implements IResultSetPanel {
return groupingViewer.getControl();
}
@Override
public boolean isDirty() {
return !resultsContainer.getGroupAttributes().isEmpty();
}
private void updateControls() {
// Update panel toolbar
this.presentation.getController().updatePanelActions();
......
......@@ -104,6 +104,12 @@ public class MetaDataPanel implements IResultSetPanel {
return this.attributeList;
}
@Override
public boolean isDirty() {
return false;
}
private DBDAttributeBinding getSelectedAttribute() {
IStructuredSelection selection = attributeList.getItemsViewer().getStructuredSelection();
if (!selection.isEmpty()) {
......
......@@ -125,6 +125,11 @@ public class ValueViewerPanel implements IResultSetPanel, IAdaptable {
return viewPlaceholder;
}
@Override
public boolean isDirty() {
return valueEditor != null && valueEditor.isDirty();
}
@Override
public void activatePanel() {
refreshValue(false);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册