"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java" between
dbeaver-6.1.5.tar.gz and dbeaver-6.2.0.tar.gz

About: DBeaver is a multi-platform database tool (for developers and database administrators) that supports all popular databases. Java sources.

ResultSetViewer.java  (dbeaver-6.1.5):ResultSetViewer.java  (dbeaver-6.2.0)
skipping to change at line 58 skipping to change at line 58
import org.eclipse.ui.menus.CommandContributionItem; import org.eclipse.ui.menus.CommandContributionItem;
import org.eclipse.ui.menus.CommandContributionItemParameter; import org.eclipse.ui.menus.CommandContributionItemParameter;
import org.eclipse.ui.menus.IMenuService; import org.eclipse.ui.menus.IMenuService;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
import org.jkiss.code.NotNull; import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable; import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException; import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log; import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.ModelPreferences; import org.jkiss.dbeaver.ModelPreferences;
import org.jkiss.dbeaver.model.*; import org.jkiss.dbeaver.model.*;
import org.jkiss.dbeaver.model.app.DBPProject;
import org.jkiss.dbeaver.model.data.*; import org.jkiss.dbeaver.model.data.*;
import org.jkiss.dbeaver.model.edit.DBEPersistAction; import org.jkiss.dbeaver.model.edit.DBEPersistAction;
import org.jkiss.dbeaver.model.exec.*; import org.jkiss.dbeaver.model.exec.*;
import org.jkiss.dbeaver.model.impl.AbstractExecutionSource; import org.jkiss.dbeaver.model.impl.AbstractExecutionSource;
import org.jkiss.dbeaver.model.impl.local.StatResultSet; import org.jkiss.dbeaver.model.impl.local.StatResultSet;
import org.jkiss.dbeaver.model.messages.ModelMessages; import org.jkiss.dbeaver.model.messages.ModelMessages;
import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore; import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore;
import org.jkiss.dbeaver.model.runtime.AbstractJob; import org.jkiss.dbeaver.model.runtime.AbstractJob;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor; import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress; import org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor; import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
import org.jkiss.dbeaver.model.runtime.load.DatabaseLoadService; import org.jkiss.dbeaver.model.runtime.load.DatabaseLoadService;
import org.jkiss.dbeaver.model.runtime.load.ILoadService; import org.jkiss.dbeaver.model.runtime.load.ILoadService;
import org.jkiss.dbeaver.model.sql.DBSQLException; import org.jkiss.dbeaver.model.sql.DBSQLException;
import org.jkiss.dbeaver.model.sql.SQLQueryContainer; import org.jkiss.dbeaver.model.sql.SQLQueryContainer;
import org.jkiss.dbeaver.model.sql.SQLScriptElement; import org.jkiss.dbeaver.model.sql.SQLScriptElement;
import org.jkiss.dbeaver.model.sql.SQLUtils; import org.jkiss.dbeaver.model.sql.SQLUtils;
import org.jkiss.dbeaver.model.struct.*; import org.jkiss.dbeaver.model.struct.*;
import org.jkiss.dbeaver.model.virtual.DBVEntity; import org.jkiss.dbeaver.model.virtual.*;
import org.jkiss.dbeaver.model.virtual.DBVEntityConstraint;
import org.jkiss.dbeaver.model.virtual.DBVTransformSettings;
import org.jkiss.dbeaver.model.virtual.DBVUtils;
import org.jkiss.dbeaver.runtime.DBWorkbench; import org.jkiss.dbeaver.runtime.DBWorkbench;
import org.jkiss.dbeaver.runtime.DBeaverNotifications; import org.jkiss.dbeaver.runtime.DBeaverNotifications;
import org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor; import org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor;
import org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor ; import org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor ;
import org.jkiss.dbeaver.tools.transfer.registry.DataTransferRegistry; import org.jkiss.dbeaver.tools.transfer.registry.DataTransferRegistry;
import org.jkiss.dbeaver.ui.*; import org.jkiss.dbeaver.ui.*;
import org.jkiss.dbeaver.ui.controls.ToolbarSeparatorContribution; import org.jkiss.dbeaver.ui.controls.ToolbarSeparatorContribution;
import org.jkiss.dbeaver.ui.controls.VerticalButton; import org.jkiss.dbeaver.ui.controls.VerticalButton;
import org.jkiss.dbeaver.ui.controls.VerticalFolder; import org.jkiss.dbeaver.ui.controls.VerticalFolder;
import org.jkiss.dbeaver.ui.controls.autorefresh.AutoRefreshControl; import org.jkiss.dbeaver.ui.controls.autorefresh.AutoRefreshControl;
skipping to change at line 129 skipping to change at line 127
* ResultSetViewer * ResultSetViewer
* *
* TODO: not-editable cells (struct owners in record mode) * TODO: not-editable cells (struct owners in record mode)
* TODO: PROBLEM. Multiple occurrences of the same struct type in a single table . * TODO: PROBLEM. Multiple occurrences of the same struct type in a single table .
* Need to make wrapper over DBSAttributeBase or something. Or maybe it is not a problem * Need to make wrapper over DBSAttributeBase or something. Or maybe it is not a problem
* because we search for binding by attribute only in constraints and for unique key columns which are unique? * because we search for binding by attribute only in constraints and for unique key columns which are unique?
* But what PK has struct type? * But what PK has struct type?
* *
*/ */
public class ResultSetViewer extends Viewer public class ResultSetViewer extends Viewer
implements DBPContextProvider, IResultSetController, ISaveablePart2, IAdapta ble implements DBPContextProvider, IResultSetController, ISaveablePart2, IAdapta ble, DBPEventListener
{ {
private static final Log log = Log.getLog(ResultSetViewer.class); private static final Log log = Log.getLog(ResultSetViewer.class);
private static final String TOOLBAR_GROUP_NAVIGATION = "navigation"; private static final String TOOLBAR_GROUP_NAVIGATION = "navigation";
private static final String TOOLBAR_GROUP_PRESENTATIONS = "presentations"; private static final String TOOLBAR_GROUP_PRESENTATIONS = "presentations";
private static final String TOOLBAR_GROUP_ADDITIONS = IWorkbenchActionConsta nts.MB_ADDITIONS; private static final String TOOLBAR_GROUP_ADDITIONS = IWorkbenchActionConsta nts.MB_ADDITIONS;
private static final String SETTINGS_SECTION_PRESENTATIONS = "presentations" ; private static final String SETTINGS_SECTION_PRESENTATIONS = "presentations" ;
private static final String TOOLBAR_CONTRIBUTION_ID = "toolbar:org.jkiss.dbe aver.ui.controls.resultset.status"; private static final String TOOLBAR_CONTRIBUTION_ID = "toolbar:org.jkiss.dbe aver.ui.controls.resultset.status";
skipping to change at line 358 skipping to change at line 356
} }
this.viewerPanel.addDisposeListener(e -> dispose()); this.viewerPanel.addDisposeListener(e -> dispose());
changeMode(false); changeMode(false);
} finally { } finally {
this.viewerPanel.setRedraw(true); this.viewerPanel.setRedraw(true);
} }
updateFiltersText(); updateFiltersText();
DBPProject project = container.getProject();
if (project != null) {
project.getDataSourceRegistry().addDataSourceListener(this);
}
} }
@Override @Override
@NotNull @NotNull
public IResultSetContainer getContainer() { public IResultSetContainer getContainer() {
return container; return container;
} }
@NotNull @NotNull
@Override @Override
skipping to change at line 420 skipping to change at line 423
} }
void saveDataFilter() { void saveDataFilter() {
DBCExecutionContext context = getExecutionContext(); DBCExecutionContext context = getExecutionContext();
if (context == null) { if (context == null) {
log.error("Can't save data filter with null context"); log.error("Can't save data filter with null context");
return; return;
} }
DataFilterRegistry.getInstance().saveDataFilter(getDataContainer(), mode l.getDataFilter()); DataFilterRegistry.getInstance().saveDataFilter(getDataContainer(), mode l.getDataFilter());
DBeaverNotifications.showNotification(DBeaverNotifications.NT_GENERAL, if (filtersPanel != null) {
"Data filter was saved", DBeaverNotifications.showNotification(DBeaverNotifications.NT_GENERA
filtersPanel.getFilterText(), L,
DBPMessageType.INFORMATION, null); "Data filter was saved",
filtersPanel.getFilterText(),
DBPMessageType.INFORMATION, null);
}
} }
void switchFilterFocus() { void switchFilterFocus() {
if (filtersPanel == null) {
return;
}
boolean filterFocused = filtersPanel.getEditControl().isFocusControl(); boolean filterFocused = filtersPanel.getEditControl().isFocusControl();
if (filterFocused) { if (filterFocused) {
if (activePresentation != null) { if (activePresentation != null) {
activePresentation.getControl().setFocus(); activePresentation.getControl().setFocus();
} }
} else { } else {
filtersPanel.getEditControl().setFocus(); filtersPanel.getEditControl().setFocus();
} }
} }
private void updateFiltersText() private void updateFiltersText()
{ {
updateFiltersText(true); updateFiltersText(true);
} }
public void updateFiltersText(boolean resetFilterValue) public void updateFiltersText(boolean resetFilterValue)
{ {
if (filtersPanel == null || this.viewerPanel.isDisposed()) { if (filtersPanel == null || this.viewerPanel.isDisposed()) {
return; return;
} }
if (resultSetSize != null && !resultSetSize.isDisposed()) {
resultSetSize.setEnabled(!model.getVisibleAttributes().isEmpty());
}
this.viewerPanel.setRedraw(false); this.viewerPanel.setRedraw(false);
try { try {
boolean enableFilters = false; boolean enableFilters = false;
DBCExecutionContext context = getExecutionContext(); DBCExecutionContext context = getExecutionContext();
if (context != null) { if (context != null) {
if (activePresentation instanceof StatisticsPresentation) { if (activePresentation instanceof StatisticsPresentation) {
enableFilters = false; enableFilters = false;
} else { } else {
StringBuilder where = new StringBuilder(); StringBuilder where = new StringBuilder();
SQLUtils.appendConditionString(model.getDataFilter(), contex t.getDataSource(), null, where, true); SQLUtils.appendConditionString(model.getDataFilter(), contex t.getDataSource(), null, where, true);
String whereCondition = where.toString().trim(); String whereCondition = where.toString().trim();
if (resetFilterValue) { if (resetFilterValue) {
filtersPanel.setFilterValue(whereCondition); filtersPanel.setFilterValue(whereCondition);
skipping to change at line 671 skipping to change at line 683
} finally { } finally {
// Enable redraw // Enable redraw
viewerPanel.setRedraw(true); viewerPanel.setRedraw(true);
} }
} }
private void setActivePresentation(@NotNull IResultSetPresentation presentat ion) { private void setActivePresentation(@NotNull IResultSetPresentation presentat ion) {
boolean focusInPresentation = UIUtils.isParent(presentationPanel, viewer Panel.getDisplay().getFocusControl()); boolean focusInPresentation = UIUtils.isParent(presentationPanel, viewer Panel.getDisplay().getFocusControl());
// Dispose previous presentation and panels // Dispose previous presentation and panels
if (activePresentation != null) {
activePresentation.dispose();
}
UIUtils.disposeChildControls(presentationPanel); UIUtils.disposeChildControls(presentationPanel);
if (panelFolder != null) { if (panelFolder != null) {
CTabItem curItem = panelFolder.getSelection(); CTabItem curItem = panelFolder.getSelection();
for (CTabItem panelItem : panelFolder.getItems()) { for (CTabItem panelItem : panelFolder.getItems()) {
if (panelItem != curItem) { if (panelItem != curItem) {
panelItem.dispose(); panelItem.dispose();
} }
} }
if (curItem != null) { if (curItem != null) {
curItem.dispose(); curItem.dispose();
skipping to change at line 771 skipping to change at line 786
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
boolean isPanelVisible = isPanelsVisible() && isPane lVisible(panel.getId()); boolean isPanelVisible = isPanelsVisible() && isPane lVisible(panel.getId());
if (isPanelVisible) { if (isPanelVisible) {
closePanel(panel.getId()); closePanel(panel.getId());
} else { } else {
activatePanel(panel.getId(), true, true); activatePanel(panel.getId(), true, true);
} }
panelButton.setChecked(!isPanelVisible); panelButton.setChecked(!isPanelVisible);
panelsButton.setChecked(isPanelsVisible()); panelsButton.setChecked(isPanelsVisible());
panelSwitchFolder.redraw(); if (panelSwitchFolder != null) {
panelSwitchFolder.redraw();
}
} }
}); });
panelButton.setChecked(panelsVisible && isPanelVisible(panel .getId())); panelButton.setChecked(panelsVisible && isPanelVisible(panel .getId()));
} }
UIUtils.createEmptyLabel(panelSwitchFolder, 1, 1).setLayoutData( new GridData(GridData.FILL_VERTICAL)); UIUtils.createEmptyLabel(panelSwitchFolder, 1, 1).setLayoutData( new GridData(GridData.FILL_VERTICAL));
VerticalButton.create(panelSwitchFolder, SWT.RIGHT | SWT.CHECK, getSite(), ResultSetHandlerMain.CMD_TOGGLE_LAYOUT, false); VerticalButton.create(panelSwitchFolder, SWT.RIGHT | SWT.CHECK, getSite(), ResultSetHandlerMain.CMD_TOGGLE_LAYOUT, false);
} }
} else { } else {
skipping to change at line 1209 skipping to change at line 1226
} }
items.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain .CMD_TOGGLE_MAXIMIZE)); items.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain .CMD_TOGGLE_MAXIMIZE));
items.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain .CMD_TOGGLE_PANELS)); items.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain .CMD_TOGGLE_PANELS));
items.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain .CMD_ACTIVATE_PANELS)); items.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain .CMD_ACTIVATE_PANELS));
return items; return items;
} }
void fillOpenWithMenu(IContributionManager openWithMenu) { void fillOpenWithMenu(IContributionManager openWithMenu) {
ResultSetDataContainerOptions options = new ResultSetDataContainerOption s(); ResultSetDataContainerOptions options = new ResultSetDataContainerOption s();
ResultSetDataContainer dataContainer = new ResultSetDataContainer(getDat aContainer(), getModel(), options); ResultSetDataContainer dataContainer = new ResultSetDataContainer(this, options);
List<DataTransferProcessorDescriptor> appProcessors = new ArrayList<>(); List<DataTransferProcessorDescriptor> appProcessors = new ArrayList<>();
for (final DataTransferNodeDescriptor consumerNode : DataTransferRegistr y.getInstance().getAvailableConsumers(Collections.singleton(dataContainer))) { for (final DataTransferNodeDescriptor consumerNode : DataTransferRegistr y.getInstance().getAvailableConsumers(Collections.singleton(dataContainer))) {
for (DataTransferProcessorDescriptor processor : consumerNode.getPro cessors()) { for (DataTransferProcessorDescriptor processor : consumerNode.getPro cessors()) {
if (processor.getAppFileExtension() != null) { if (processor.getAppFileExtension() != null) {
appProcessors.add(processor); appProcessors.add(processor);
} }
} }
} }
skipping to change at line 1250 skipping to change at line 1267
void fillCopyAsMenu(IContributionManager copyAsMenu) { void fillCopyAsMenu(IContributionManager copyAsMenu) {
copyAsMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandle rCopySpecial.CMD_COPY_SPECIAL)); copyAsMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandle rCopySpecial.CMD_COPY_SPECIAL));
copyAsMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandle rCopySpecial.CMD_COPY_COLUMN_NAMES)); copyAsMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandle rCopySpecial.CMD_COPY_COLUMN_NAMES));
copyAsMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandle rMain.CMD_COPY_ROW_NAMES)); copyAsMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandle rMain.CMD_COPY_ROW_NAMES));
// Add copy commands for different formats // Add copy commands for different formats
copyAsMenu.add(new Separator()); copyAsMenu.add(new Separator());
ResultSetDataContainerOptions options = new ResultSetDataContainerOption s(); ResultSetDataContainerOptions options = new ResultSetDataContainerOption s();
ResultSetDataContainer dataContainer = new ResultSetDataContainer(getDat aContainer(), getModel(), options); ResultSetDataContainer dataContainer = new ResultSetDataContainer(this, options);
List<DataTransferProcessorDescriptor> appProcessors = new ArrayList<>(); List<DataTransferProcessorDescriptor> appProcessors = new ArrayList<>();
for (final DataTransferNodeDescriptor consumerNode : DataTransferRegistr y.getInstance().getAvailableConsumers(Collections.singleton(dataContainer))) { for (final DataTransferNodeDescriptor consumerNode : DataTransferRegistr y.getInstance().getAvailableConsumers(Collections.singleton(dataContainer))) {
for (DataTransferProcessorDescriptor processor : consumerNode.getPro cessors()) { for (DataTransferProcessorDescriptor processor : consumerNode.getPro cessors()) {
if (processor.isBinaryFormat()) { if (processor.isBinaryFormat()) {
continue; continue;
} }
appProcessors.add(processor); appProcessors.add(processor);
} }
skipping to change at line 1575 skipping to change at line 1592
int fetchSize = CommonUtils.toInt(resultSetSize.getText()); int fetchSize = CommonUtils.toInt(resultSetSize.getText());
if (fetchSize > 0 && dataContainer != null && dataContainer.getD ataSource() != null) { if (fetchSize > 0 && dataContainer != null && dataContainer.getD ataSource() != null) {
DBPPreferenceStore store = dataContainer.getDataSource().get Container().getPreferenceStore(); DBPPreferenceStore store = dataContainer.getDataSource().get Container().getPreferenceStore();
int oldFetchSize = store.getInt(ResultSetPreferences.RESULT_ SET_MAX_ROWS); int oldFetchSize = store.getInt(ResultSetPreferences.RESULT_ SET_MAX_ROWS);
if (oldFetchSize > 0 && oldFetchSize != fetchSize) { if (oldFetchSize > 0 && oldFetchSize != fetchSize) {
store.setValue(ResultSetPreferences.RESULT_SET_MAX_ROWS, fetchSize); store.setValue(ResultSetPreferences.RESULT_SET_MAX_ROWS, fetchSize);
PrefUtils.savePreferenceStore(store); PrefUtils.savePreferenceStore(store);
} }
} }
}); });
UIUtils.addDefaultEditActionsSupport(site, resultSetSize);
rowCountLabel = new ActiveStatusMessage(statusBar, DBeaverIcons.getI mage(UIIcon.RS_REFRESH), ResultSetMessages.controls_resultset_viewer_calculate_r ow_count, this) { rowCountLabel = new ActiveStatusMessage(statusBar, DBeaverIcons.getI mage(UIIcon.RS_REFRESH), ResultSetMessages.controls_resultset_viewer_calculate_r ow_count, this) {
@Override @Override
protected boolean isActionEnabled() { protected boolean isActionEnabled() {
return hasData(); return hasData();
} }
@Override @Override
protected ILoadService<String> createLoadService() { protected ILoadService<String> createLoadService() {
return new DatabaseLoadService<String>("Load row count", get ExecutionContext()) { return new DatabaseLoadService<String>("Load row count", get ExecutionContext()) {
skipping to change at line 1670 skipping to change at line 1688
activePresentation.changeMode(recordMode); activePresentation.changeMode(recordMode);
updateStatusMessage(); updateStatusMessage();
//restorePresentationState(state); //restorePresentationState(state);
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Misc // Misc
private void dispose() private void dispose()
{ {
if (activePresentation != null) {
activePresentation.dispose();
}
DBPProject project = container.getProject();
if (project != null) {
project.getDataSourceRegistry().removeDataSourceListener(this);
}
savePresentationSettings(); savePresentationSettings();
clearData(); clearData();
for (ToolBarManager tb : toolbarList) { for (ToolBarManager tb : toolbarList) {
try { try {
tb.dispose(); tb.dispose();
} catch (Throwable e) { } catch (Throwable e) {
// ignore // ignore
log.debug("Error disposing toolbar " + tb, e); log.debug("Error disposing toolbar " + tb, e);
} }
skipping to change at line 1972 skipping to change at line 1998
} else { } else {
newRecordMode = (rows.size() <= 1); newRecordMode = (rows.size() <= 1);
} }
if (newRecordMode != recordMode) { if (newRecordMode != recordMode) {
toggleMode(); toggleMode();
} }
} }
} }
} }
void appendData(List<Object[]> rows) void appendData(List<Object[]> rows, boolean resetOldRows)
{ {
model.appendData(rows); model.appendData(rows, resetOldRows);
setStatus(NLS.bind(ResultSetMessages.controls_resultset_viewer_status_ro ws_size, model.getRowCount(), rows.size()) + getExecutionTimeMessage()); setStatus(NLS.bind(ResultSetMessages.controls_resultset_viewer_status_ro ws_size, model.getRowCount(), rows.size()) + getExecutionTimeMessage());
updateEditControls(); updateEditControls();
} }
@Override @Override
public int promptToSaveOnClose() public int promptToSaveOnClose()
{ {
if (!isDirty()) { if (!isDirty()) {
skipping to change at line 2491 skipping to change at line 2517
MenuManager refTablesMenu = new MenuManager(menuName, null, "ref-tables" ); MenuManager refTablesMenu = new MenuManager(menuName, null, "ref-tables" );
refTablesMenu.setActionDefinitionId(ResultSetHandlerMain.CMD_REFERENCES_ MENU); refTablesMenu.setActionDefinitionId(ResultSetHandlerMain.CMD_REFERENCES_ MENU);
refTablesMenu.add(ResultSetReferenceMenu.NOREFS_ACTION); refTablesMenu.add(ResultSetReferenceMenu.NOREFS_ACTION);
refTablesMenu.addMenuListener(manager -> refTablesMenu.addMenuListener(manager ->
ResultSetReferenceMenu.fillRefTablesActions(this, getSelection().get SelectedRows(), singleSource, manager, openInNewWindow)); ResultSetReferenceMenu.fillRefTablesActions(this, getSelection().get SelectedRows(), singleSource, manager, openInNewWindow));
return refTablesMenu; return refTablesMenu;
} }
@Override
public void handleDataSourceEvent(DBPEvent event) {
if (event.getObject() instanceof DBVEntity && event.getData() instanceof
DBVEntityForeignKey && event.getObject() == getVirtualEntity()) {
// Virtual foreign key change - let's refresh
refreshData(null);
}
}
private class TransformerAction extends Action { private class TransformerAction extends Action {
private final DBDAttributeBinding attribute; private final DBDAttributeBinding attribute;
TransformerAction(DBDAttributeBinding attr, String text, int style, bool ean checked) { TransformerAction(DBDAttributeBinding attr, String text, int style, bool ean checked) {
super(text, style); super(text, style);
this.attribute = attr; this.attribute = attr;
setChecked(checked); setChecked(checked);
} }
@NotNull @NotNull
DBVTransformSettings getTransformSettings() { DBVTransformSettings getTransformSettings() {
final DBVTransformSettings settings = DBVUtils.getTransformSettings( attribute, true); final DBVTransformSettings settings = DBVUtils.getTransformSettings( attribute, true);
skipping to change at line 2634 skipping to change at line 2668
saveTransformerSettings(); saveTransformerSettings();
} }
}); });
} }
} }
} }
private void fillFiltersMenu(@NotNull IMenuManager filtersMenu, @Nullable DB DAttributeBinding attribute, @Nullable ResultSetRow row) private void fillFiltersMenu(@NotNull IMenuManager filtersMenu, @Nullable DB DAttributeBinding attribute, @Nullable ResultSetRow row)
{ {
if (attribute != null && supportsDataFilter()) { if (attribute != null && supportsDataFilter()) {
filtersMenu.add(ActionUtils.makeCommandContribution(site, ResultSetH
andlerMain.CMD_FILTER_MENU_DISTINCT));
if (row != null) { if (row != null) {
filtersMenu.add(new Separator()); filtersMenu.add(new Separator());
//filtersMenu.add(new FilterByListAction(operator, type, attribu te)); //filtersMenu.add(new FilterByListAction(operator, type, attribu te));
DBCLogicalOperator[] operators = attribute.getValueHandler().get SupportedOperators(attribute); DBCLogicalOperator[] operators = attribute.getValueHandler().get SupportedOperators(attribute);
// Operators with single input // Operators with single input
for (FilterByAttributeType type : FilterByAttributeType.values() ) { for (FilterByAttributeType type : FilterByAttributeType.values() ) {
if (type == FilterByAttributeType.NONE) { if (type == FilterByAttributeType.NONE) {
// Value filters are available only if certain cell is s elected // Value filters are available only if certain cell is s elected
skipping to change at line 2681 skipping to change at line 2713
filtersMenu.add(new FilterByAttributeAction(operator, Fi lterByAttributeType.INPUT, attribute)); filtersMenu.add(new FilterByAttributeAction(operator, Fi lterByAttributeType.INPUT, attribute));
} }
} }
// Operators with no inputs // Operators with no inputs
for (DBCLogicalOperator operator : operators) { for (DBCLogicalOperator operator : operators) {
if (operator.getArgumentCount() == 0) { if (operator.getArgumentCount() == 0) {
filtersMenu.add(new FilterByAttributeAction(operator, Fi lterByAttributeType.NONE, attribute)); filtersMenu.add(new FilterByAttributeAction(operator, Fi lterByAttributeType.NONE, attribute));
} }
} }
filtersMenu.add(ActionUtils.makeCommandContribution(site, Result
SetHandlerMain.CMD_FILTER_MENU_DISTINCT));
} }
filtersMenu.add(new Separator()); filtersMenu.add(new Separator());
DBDAttributeConstraint constraint = model.getDataFilter().getConstra int(attribute); DBDAttributeConstraint constraint = model.getDataFilter().getConstra int(attribute);
if (constraint != null && constraint.hasCondition()) { if (constraint != null && constraint.hasCondition()) {
filtersMenu.add(new FilterResetAttributeAction(attribute)); filtersMenu.add(new FilterResetAttributeAction(attribute));
} }
} }
filtersMenu.add(new Separator()); filtersMenu.add(new Separator());
filtersMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandl erMain.CMD_FILTER_SAVE_SETTING)); filtersMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandl erMain.CMD_FILTER_SAVE_SETTING));
filtersMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandl erMain.CMD_FILTER_CLEAR_SETTING)); filtersMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandl erMain.CMD_FILTER_CLEAR_SETTING));
skipping to change at line 2732 skipping to change at line 2766
throw new DBException(ModelMessages.error_not_connected_to_database) ; throw new DBException(ModelMessages.error_not_connected_to_database) ;
} }
DBSEntityConstraint refConstraint = association.getReferencedConstraint( ); DBSEntityConstraint refConstraint = association.getReferencedConstraint( );
if (refConstraint == null) { if (refConstraint == null) {
throw new DBException("Broken association (referenced constraint mis sing)"); throw new DBException("Broken association (referenced constraint mis sing)");
} }
if (!(refConstraint instanceof DBSEntityReferrer)) { if (!(refConstraint instanceof DBSEntityReferrer)) {
throw new DBException("Referenced constraint [" + refConstraint + "] is not a referrer"); throw new DBException("Referenced constraint [" + refConstraint + "] is not a referrer");
} }
DBSEntity targetEntity = refConstraint.getParentObject(); DBSEntity targetEntity = refConstraint.getParentObject();
if (targetEntity == null) {
throw new DBException("Null constraint parent");
}
targetEntity = DBVUtils.getRealEntity(monitor, targetEntity); targetEntity = DBVUtils.getRealEntity(monitor, targetEntity);
if (!(targetEntity instanceof DBSDataContainer)) { if (!(targetEntity instanceof DBSDataContainer)) {
throw new DBException("Entity [" + DBUtils.getObjectFullName(targetE ntity, DBPEvaluationContext.UI) + "] is not a data container"); throw new DBException("Entity [" + DBUtils.getObjectFullName(targetE ntity, DBPEvaluationContext.UI) + "] is not a data container");
} }
// make constraints // make constraints
List<DBDAttributeConstraint> constraints = new ArrayList<>(); List<DBDAttributeConstraint> constraints = new ArrayList<>();
// Set conditions // Set conditions
List<? extends DBSEntityAttributeRef> ownAttrs = CommonUtils.safeList((( DBSEntityReferrer) association).getAttributeReferences(monitor)); List<? extends DBSEntityAttributeRef> ownAttrs = CommonUtils.safeList((( DBSEntityReferrer) association).getAttributeReferences(monitor));
skipping to change at line 2761 skipping to change at line 2792
// Add association constraints // Add association constraints
for (int i = 0; i < ownAttrs.size(); i++) { for (int i = 0; i < ownAttrs.size(); i++) {
DBSEntityAttributeRef ownAttr = ownAttrs.get(i); DBSEntityAttributeRef ownAttr = ownAttrs.get(i);
DBSEntityAttributeRef refAttr = refAttrs.get(i); DBSEntityAttributeRef refAttr = refAttrs.get(i);
DBDAttributeBinding ownBinding = bindingsModel.getAttributeBinding(o wnAttr.getAttribute()); DBDAttributeBinding ownBinding = bindingsModel.getAttributeBinding(o wnAttr.getAttribute());
if (ownBinding == null) { if (ownBinding == null) {
DBWorkbench.getPlatformUI().showError("Can't navigate", "Attribu te " + ownAttr.getAttribute() + " is missing in result set"); DBWorkbench.getPlatformUI().showError("Can't navigate", "Attribu te " + ownAttr.getAttribute() + " is missing in result set");
return; return;
} }
DBDAttributeConstraint constraint = new DBDAttributeConstraint(refAt DBSEntityAttribute attribute = refAttr.getAttribute();
tr.getAttribute(), DBDAttributeConstraint.NULL_VISUAL_POSITION); if (attribute != null) {
constraint.setVisible(true); DBDAttributeConstraint constraint = new DBDAttributeConstraint(a
constraints.add(constraint); ttribute, DBDAttributeConstraint.NULL_VISUAL_POSITION);
constraint.setVisible(true);
constraints.add(constraint);
createFilterConstraint(rows, ownBinding, constraint);
}
createFilterConstraint(rows, ownBinding, constraint);
} }
// Save cur data filter in state // Save cur data filter in state
if (curState == null) { if (curState == null) {
setNewState((DBSDataContainer) targetEntity, model.getDataFilter()); setNewState((DBSDataContainer) targetEntity, model.getDataFilter());
} }
curState.filter = new DBDDataFilter(bindingsModel.getDataFilter()); curState.filter = new DBDDataFilter(bindingsModel.getDataFilter());
navigateEntity(monitor, newWindow, targetEntity, constraints); navigateEntity(monitor, newWindow, targetEntity, constraints);
} }
/** /**
skipping to change at line 2792 skipping to change at line 2826
{ {
if (!confirmProceed()) { if (!confirmProceed()) {
return; return;
} }
if (getExecutionContext() == null) { if (getExecutionContext() == null) {
throw new DBException(ModelMessages.error_not_connected_to_database) ; throw new DBException(ModelMessages.error_not_connected_to_database) ;
} }
DBSEntity targetEntity = association.getParentObject(); DBSEntity targetEntity = association.getParentObject();
if (targetEntity == null) {
throw new DBException("Null constraint parent");
}
//DBSDataContainer dataContainer = DBUtils.getAdapter(DBSDataContainer.c lass, targetEntity); //DBSDataContainer dataContainer = DBUtils.getAdapter(DBSDataContainer.c lass, targetEntity);
targetEntity = DBVUtils.getRealEntity(monitor, targetEntity); targetEntity = DBVUtils.getRealEntity(monitor, targetEntity);
if (!(targetEntity instanceof DBSDataContainer)) { if (!(targetEntity instanceof DBSDataContainer)) {
throw new DBException("Referencing entity [" + DBUtils.getObjectFull Name(targetEntity, DBPEvaluationContext.UI) + "] is not a data container"); throw new DBException("Referencing entity [" + DBUtils.getObjectFull Name(targetEntity, DBPEvaluationContext.UI) + "] is not a data container");
} }
// make constraints // make constraints
List<DBDAttributeConstraint> constraints = new ArrayList<>(); List<DBDAttributeConstraint> constraints = new ArrayList<>();
// Set conditions // Set conditions
skipping to change at line 2886 skipping to change at line 2917
panelsDirty = true; panelsDirty = true;
break; break;
} }
} }
if (panelsDirty) { if (panelsDirty) {
int result = ConfirmationDialog.showConfirmDialog( int result = ConfirmationDialog.showConfirmDialog(
ResourceBundle.getBundle(ResultSetMessages.BUNDLE_NAME), ResourceBundle.getBundle(ResultSetMessages.BUNDLE_NAME),
viewerPanel.getShell(), viewerPanel.getShell(),
ResultSetPreferences.CONFIRM_RS_PANEL_RESET, ResultSetPreferences.CONFIRM_RS_PANEL_RESET,
ConfirmationDialog.CONFIRM); ConfirmationDialog.CONFIRM);
if (result == IDialogConstants.CANCEL_ID) { return result != IDialogConstants.CANCEL_ID;
return false;
}
} }
return true; return true;
} }
}.confirm(); }.confirm();
} }
private void openResultsInNewWindow(DBRProgressMonitor monitor, DBSEntity ta rgetEntity, final DBDDataFilter newFilter) { private void openResultsInNewWindow(DBRProgressMonitor monitor, DBSEntity ta rgetEntity, final DBDDataFilter newFilter) {
if (targetEntity instanceof DBSDataContainer) { if (targetEntity instanceof DBSDataContainer) {
getContainer().openNewContainer(monitor, (DBSDataContainer) targetEn tity, newFilter); getContainer().openNewContainer(monitor, (DBSDataContainer) targetEn tity, newFilter);
} else { } else {
skipping to change at line 3221 skipping to change at line 3250
/** /**
* Reads row count and sets value in status label * Reads row count and sets value in status label
*/ */
private long readRowCount(DBRProgressMonitor monitor) throws DBException { private long readRowCount(DBRProgressMonitor monitor) throws DBException {
final DBCExecutionContext executionContext = getExecutionContext(); final DBCExecutionContext executionContext = getExecutionContext();
DBSDataContainer dataContainer = getDataContainer(); DBSDataContainer dataContainer = getDataContainer();
if (executionContext == null || dataContainer == null) { if (executionContext == null || dataContainer == null) {
throw new DBException(ModelMessages.error_not_connected_to_database) ; throw new DBException(ModelMessages.error_not_connected_to_database) ;
} }
try (DBCSession session = executionContext.openSession( long[] result = new long[1];
monitor, DBExecUtils.tryExecuteRecover(monitor, executionContext.getDataSource(),
DBCExecutionPurpose.USER, param -> {
"Read total row count")) try (DBCSession session = executionContext.openSession(
{ monitor,
long rowCount = dataContainer.countData( DBCExecutionPurpose.USER,
new AbstractExecutionSource(dataContainer, executionContext, thi "Read total row count")) {
s), long rowCount = dataContainer.countData(
session, new AbstractExecutionSource(dataContainer, executionContext,
model.getDataFilter(), this),
DBSDataContainer.FLAG_NONE); session,
model.setTotalRowCount(rowCount); model.getDataFilter(),
return rowCount; DBSDataContainer.FLAG_NONE);
} model.setTotalRowCount(rowCount);
result[0] = rowCount;
} catch (DBCException e) {
throw new InvocationTargetException(e);
}
});
return result[0];
} }
private int getSegmentMaxRows() private int getSegmentMaxRows()
{ {
if (getDataContainer() == null) { if (getDataContainer() == null) {
return 0; return 0;
} }
return getPreferenceStore().getInt(ResultSetPreferences.RESULT_SET_MAX_R OWS); return getPreferenceStore().getInt(ResultSetPreferences.RESULT_SET_MAX_R OWS);
} }
skipping to change at line 3278 skipping to change at line 3312
final int maxRows, final int maxRows,
final int focusRow, final int focusRow,
final boolean saveHistory, final boolean saveHistory,
final boolean scroll, final boolean scroll,
@Nullable final Runnable finalizer) @Nullable final Runnable finalizer)
{ {
if (viewerPanel.isDisposed()) { if (viewerPanel.isDisposed()) {
return false; return false;
} }
DBCExecutionContext executionContext = getExecutionContext(); DBCExecutionContext executionContext = getExecutionContext();
if (executionContext == null || dataContainer.getDataSource() != executi
onContext.getDataSource()) {
// This may happen during cross-database entity navigation
executionContext = DBUtils.getDefaultContext(dataContainer, false);
}
if (executionContext == null) { if (executionContext == null) {
UIUtils.showMessageBox(viewerPanel.getShell(), "Data read", "Can't r ead data - no active connection", SWT.ICON_WARNING); UIUtils.showMessageBox(viewerPanel.getShell(), "Data read", "Can't r ead data - no active connection", SWT.ICON_WARNING);
return false; return false;
} }
// Cancel any refresh jobs // Cancel any refresh jobs
autoRefreshControl.cancelRefresh(); autoRefreshControl.cancelRefresh();
// Read data // Read data
final DBDDataFilter useDataFilter = dataFilter != null ? dataFilter : final DBDDataFilter useDataFilter = dataFilter != null ? dataFilter :
(dataContainer == getDataContainer() ? model.getDataFilter() : null) ; (dataContainer == getDataContainer() ? model.getDataFilter() : null) ;
skipping to change at line 3441 skipping to change at line 3479
queueDataPump(dataPumpJob); queueDataPump(dataPumpJob);
return true; return true;
} }
/** /**
* Adds new data read job in queue. * Adds new data read job in queue.
* In some cases there may be many frequent data read requests (e.g. when us er works * In some cases there may be many frequent data read requests (e.g. when us er works
* with references panel). We need to execute only current one and the last one. All * with references panel). We need to execute only current one and the last one. All
* intrmediate data read requests must be ignored. * intrmediate data read requests must be ignored.
* @param dataPumpJob
*/ */
private void queueDataPump(ResultSetJobDataRead dataPumpJob) { private void queueDataPump(ResultSetJobDataRead dataPumpJob) {
synchronized (dataPumpJobQueue) { synchronized (dataPumpJobQueue) {
// Clear queue // Clear queue
dataPumpJobQueue.clear(); dataPumpJobQueue.clear();
dataPumpJobQueue.add(dataPumpJob); dataPumpJobQueue.add(dataPumpJob);
} }
new AbstractJob("Initiate data read") { new AbstractJob("Initiate data read") {
{ {
setUser(false); setUser(false);
skipping to change at line 3751 skipping to change at line 3788
return null; return null;
} }
} }
private DBVEntity getVirtualEntity() { private DBVEntity getVirtualEntity() {
DBSEntity entity = model.isSingleSource() ? model.getSingleSource() : nu ll; DBSEntity entity = model.isSingleSource() ? model.getSingleSource() : nu ll;
return getVirtualEntity(entity); return getVirtualEntity(entity);
} }
private DBVEntity getVirtualEntity(DBSEntity entity) { private DBVEntity getVirtualEntity(DBSEntity entity) {
return entity != null ? if (entity != null) {
DBVUtils.getVirtualEntity(entity, true) : return DBVUtils.getVirtualEntity(entity, true);
DBVUtils.getVirtualEntity(getDataContainer(), true); }
DBSDataContainer dataContainer = getDataContainer();
if (dataContainer != null) {
return DBVUtils.getVirtualEntity(dataContainer, true);
}
return null;
} }
private void checkEntityIdentifiers(ResultSetPersister persister) throws DBE xception private void checkEntityIdentifiers(ResultSetPersister persister) throws DBE xception
{ {
final DBCExecutionContext executionContext = getExecutionContext(); final DBCExecutionContext executionContext = getExecutionContext();
if (executionContext == null) { if (executionContext == null) {
throw new DBCException("Can't persist data - not connected to databa se"); throw new DBCException("Can't persist data - not connected to databa se");
} }
 End of changes. 28 change blocks. 
49 lines changed or deleted 95 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)