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

Copy column/row names command fix (do not show options for single element)

上级 a371d830
......@@ -21,7 +21,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.model.data.DBDAttributeBinding;
import java.util.Collection;
import java.util.List;
/**
* Result set selection
......@@ -32,10 +32,10 @@ public interface IResultSetSelection extends IStructuredSelection {
IResultSetController getController();
@NotNull
Collection<DBDAttributeBinding> getSelectedAttributes();
List<DBDAttributeBinding> getSelectedAttributes();
@NotNull
Collection<ResultSetRow> getSelectedRows();
List<ResultSetRow> getSelectedRows();
DBDAttributeBinding getElementAttribute(Object element);
......
......@@ -283,16 +283,22 @@ public class ResultSetCommandHandler extends AbstractHandler {
break;
}
case CMD_COPY_COLUMN_NAMES: {
ResultSetCopySpecialHandler.CopyConfigDialog configDialog = new ResultSetCopySpecialHandler.CopyConfigDialog(activeShell, "CopyGridNamesOptionsDialog");
if (configDialog.open() != IDialogConstants.OK_ID) {
return null;
}
StringBuilder buffer = new StringBuilder();
IResultSetSelection selection = rsv.getSelection();
Collection<DBDAttributeBinding> attrs = selection.isEmpty() ? rsv.getModel().getVisibleAttributes() : selection.getSelectedAttributes();
List<DBDAttributeBinding> attrs = selection.isEmpty() ? rsv.getModel().getVisibleAttributes() : selection.getSelectedAttributes();
ResultSetCopySettings settings = new ResultSetCopySettings();
if (attrs.size() > 1) {
ResultSetCopySpecialHandler.CopyConfigDialog configDialog = new ResultSetCopySpecialHandler.CopyConfigDialog(activeShell, "CopyGridNamesOptionsDialog");
if (configDialog.open() != IDialogConstants.OK_ID) {
return null;
}
settings = configDialog.copySettings;
}
for (DBDAttributeBinding attr : attrs) {
if (buffer.length() > 0) {
buffer.append(configDialog.copySettings.getColumnDelimiter());
buffer.append(settings.getColumnDelimiter());
}
String colName = attr.getLabel();
if (CommonUtils.isEmpty(colName)) {
......@@ -300,20 +306,24 @@ public class ResultSetCommandHandler extends AbstractHandler {
}
buffer.append(colName);
}
ResultSetUtils.copyToClipboard(buffer.toString());
break;
}
case CMD_COPY_ROW_NAMES: {
ResultSetCopySpecialHandler.CopyConfigDialog configDialog = new ResultSetCopySpecialHandler.CopyConfigDialog(activeShell, "CopyGridNamesOptionsDialog");
if (configDialog.open() != IDialogConstants.OK_ID) {
return null;
}
StringBuilder buffer = new StringBuilder();
IResultSetSelection selection = rsv.getSelection();
for (ResultSetRow row : selection.getSelectedRows()) {
List<ResultSetRow> selectedRows = rsv.getSelection().getSelectedRows();
ResultSetCopySettings settings = new ResultSetCopySettings();
if (selectedRows.size() > 1) {
ResultSetCopySpecialHandler.CopyConfigDialog configDialog = new ResultSetCopySpecialHandler.CopyConfigDialog(activeShell, "CopyGridNamesOptionsDialog");
if (configDialog.open() != IDialogConstants.OK_ID) {
return null;
}
settings = configDialog.copySettings;
}
for (ResultSetRow row : selectedRows) {
if (buffer.length() > 0) {
buffer.append(configDialog.copySettings.getRowDelimiter());
buffer.append(settings.getRowDelimiter());
}
buffer.append(row.getVisualNumber() + 1);
}
......
......@@ -3249,13 +3249,13 @@ public class ResultSetViewer extends Viewer
@NotNull
@Override
public Collection<DBDAttributeBinding> getSelectedAttributes() {
public List<DBDAttributeBinding> getSelectedAttributes() {
return Collections.emptyList();
}
@NotNull
@Override
public Collection<ResultSetRow> getSelectedRows() {
public List<ResultSetRow> getSelectedRows() {
return Collections.emptyList();
}
......
......@@ -55,7 +55,6 @@ import org.jkiss.dbeaver.ui.controls.StyledTextFindReplaceTarget;
import org.jkiss.dbeaver.ui.controls.resultset.*;
import org.jkiss.utils.CommonUtils;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
......@@ -612,16 +611,16 @@ public class PlainTextPresentation extends AbstractPresentation implements IAdap
@NotNull
@Override
public Collection<DBDAttributeBinding> getSelectedAttributes() {
public List<DBDAttributeBinding> getSelectedAttributes() {
if (curAttribute == null) {
return Collections.emptyList();
}
return Collections.singleton(curAttribute);
return Collections.singletonList(curAttribute);
}
@NotNull
@Override
public Collection<ResultSetRow> getSelectedRows()
public List<ResultSetRow> getSelectedRows()
{
ResultSetRow currentRow = controller.getCurrentRow();
if (currentRow == null) {
......
......@@ -1260,7 +1260,7 @@ public class SpreadsheetPresentation extends AbstractPresentation implements IRe
@NotNull
@Override
public Collection<DBDAttributeBinding> getSelectedAttributes() {
public List<DBDAttributeBinding> getSelectedAttributes() {
if (controller.isRecordMode()) {
Object[] elements = spreadsheet.getContentProvider().getElements(false);
List<DBDAttributeBinding> attrs = new ArrayList<>();
......@@ -1284,7 +1284,7 @@ public class SpreadsheetPresentation extends AbstractPresentation implements IRe
@NotNull
@Override
public Collection<ResultSetRow> getSelectedRows()
public List<ResultSetRow> getSelectedRows()
{
if (controller.isRecordMode()) {
ResultSetRow currentRow = controller.getCurrentRow();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册