提交 670bb5a7 编写于 作者: J jurgen

Inline controls activation/deactivation fix

Former-commit-id: de455e0d
上级 cffd2904
......@@ -133,6 +133,7 @@ public abstract class JDBCAbstractValueHandler implements DBDValueHandler {
protected abstract class ValueEditor<T extends Control> implements DBDValueEditor {
protected final DBDValueController valueController;
protected final T control;
private boolean activated;
protected ValueEditor(final DBDValueController valueController)
{
this.valueController = valueController;
......@@ -166,22 +167,39 @@ public abstract class JDBCAbstractValueHandler implements DBDValueHandler {
protected void initInlineControl(final Control inlineControl)
{
boolean isInline = (valueController.getEditType() == DBDValueController.EditType.INLINE);
// Panel controls
inlineControl.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e)
{
UIUtils.enableHostEditorKeyBindings(valueController.getValueSite(), false);
if (!activated) {
UIUtils.enableHostEditorKeyBindings(valueController.getValueSite(), false);
activated = true;
}
}
@Override
public void focusLost(FocusEvent e)
{
UIUtils.enableHostEditorKeyBindings(valueController.getValueSite(), true);
if (activated) {
UIUtils.enableHostEditorKeyBindings(valueController.getValueSite(), true);
activated = false;
}
}
});
inlineControl.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e)
{
if (activated) {
UIUtils.enableHostEditorKeyBindings(valueController.getValueSite(), true);
activated = false;
}
}
});
boolean isInline = (valueController.getEditType() == DBDValueController.EditType.INLINE);
// if (!isInline) {
// inlineControl.setBackground(valueController.getEditPlaceholder().getBackground());
// }
......
......@@ -1137,6 +1137,7 @@ public class UIUtils {
} catch (Exception e) {
log.debug(e);
}
}
}
......
......@@ -87,13 +87,13 @@ public class ResultSetCommandHandler extends SpreadsheetCommandHandler {
} else if (actionId.equals(CMD_REJECT_CHANGES)) {
resultSet.rejectChanges();
} else if (actionId.equals(IWorkbenchCommandConstants.EDIT_COPY)) {
resultSet.copySelectionToClipboard(false, DBDDisplayFormat.EDIT);
resultSet.copySelectionToClipboard(false, false, DBDDisplayFormat.EDIT);
} else if (actionId.equals(ICommandIds.CMD_COPY_SPECIAL)) {
resultSet.copySelectionToClipboard(true, DBDDisplayFormat.UI);
resultSet.copySelectionToClipboard(true, false, DBDDisplayFormat.UI);
} else if (actionId.equals(IWorkbenchCommandConstants.EDIT_PASTE)) {
resultSet.pasteCellValue();
} else if (actionId.equals(IWorkbenchCommandConstants.EDIT_CUT)) {
resultSet.copySelectionToClipboard(false, DBDDisplayFormat.EDIT);
resultSet.copySelectionToClipboard(false, true, DBDDisplayFormat.EDIT);
}
......
......@@ -1682,7 +1682,7 @@ public class ResultSetViewer extends Viewer implements IDataSourceProvider, ISpr
new DataUpdater().rejectChanges();
}
public void copySelectionToClipboard(boolean copyHeader, DBDDisplayFormat format)
public void copySelectionToClipboard(boolean copyHeader, boolean cut, DBDDisplayFormat format)
{
String lineSeparator = ContentUtils.getDefaultLineSeparator();
List<Integer> colsSelected = new ArrayList<Integer>();
......@@ -1738,7 +1738,8 @@ public class ResultSetViewer extends Viewer implements IDataSourceProvider, ISpr
prevCol = pos.col;
}
GridPos cellPos = translateGridPos(pos);
Object value = curRows.get(cellPos.row)[cellPos.col];
Object[] curRow = curRows.get(cellPos.row);
Object value = curRow[cellPos.col];
String cellText = metaColumns[cellPos.col].getValueHandler().getValueDisplayString(
metaColumns[cellPos.col].getAttribute(),
value,
......@@ -1746,6 +1747,13 @@ public class ResultSetViewer extends Viewer implements IDataSourceProvider, ISpr
if (cellText != null) {
tdt.append(cellText);
}
if (cut) {
DBDValueController valueController = new ResultSetValueController(
curRow, cellPos.col, DBDValueController.EditType.NONE, null);
if (!valueController.isReadOnly()) {
valueController.updateValue(DBUtils.makeNullValue(valueController));
}
}
}
if (tdt.length() > 0) {
TextTransfer textTransfer = TextTransfer.getInstance();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册