Skip to content

Commit

Permalink
TEIIDDES-1986 Added provision for the SqlEditorPanel to actually perf…
Browse files Browse the repository at this point in the history
…orm the paste.
  • Loading branch information
blafond committed Jan 2, 2014
1 parent b453036 commit 51e9e91
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ public void modifyText( ExtendedModifyEvent event ) {
});

this.textEditor = new StyledTextEditor(this.sqlTextViewer);
this.textEditor.setAlwaysAllowPaste(true);
this.textEditor.addMenuListener(this);

// sqlDocument.set("SELECT * FROM TABLE");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ public static StyledTextEditor createReadOnlyEditor( Composite parent,

private ContextMenuAction undoAction;

private boolean alwaysAllowPaste = false;
/**
* The parent of the {@link StyledText} control. Will be <code>null</code> if the {@link StyledText} control is passed in at
* construction.
Expand Down Expand Up @@ -773,7 +774,15 @@ public void setAllowSelectAll( boolean allowSelectAll ) {
// synchronize key accelerator with focus
if (this.selectAllAction != null) {
this.selectAllAction.setAccelerator((this.allowSelectAll && getTextWidget().isFocusControl()) ? SWT.CTRL | 'A' : 0);
}
}// @Override
// public void keyPressed(KeyEvent e) {
//
// }
//
// @Override
// public void keyReleased(KeyEvent e) {
//
// }
}

/**
Expand Down Expand Up @@ -860,6 +869,14 @@ public void setUndoRedoHistoryLimit( int limit ) {
this.viewer.getUndoManager().setMaximalUndoLevel(limit);
}
}

public void setAlwaysAllowPaste(boolean value) {
this.alwaysAllowPaste = value;
}

protected boolean getAlwaysAllowPaste() {
return this.alwaysAllowPaste;
}

private class ContextMenuAction extends Action {

Expand Down Expand Up @@ -969,7 +986,9 @@ public void run() {
} else if (this.id.equals(PASTE_ID)) {
// Removed the paste() call below due an SWT change that results in it being redundant and paste being
// performed twice
// getTextWidget().paste();
if( getAlwaysAllowPaste() ) {
getTextWidget().paste();
}
} else if (this.id.equals(SELECT_ALL_ID)) {
getTextWidget().selectAll();
}
Expand Down

0 comments on commit 51e9e91

Please sign in to comment.