Skip to content

Commit

Permalink
repl ui: addition of expand left/right/up and select previous structu…
Browse files Browse the repository at this point in the history
…re edition commands
  • Loading branch information
laurentpetit committed Dec 21, 2010
1 parent 681e45b commit dbec06e
Show file tree
Hide file tree
Showing 13 changed files with 138 additions and 253 deletions.
64 changes: 64 additions & 0 deletions ccw.core/plugin.xml
Expand Up @@ -1320,5 +1320,69 @@
</with>
</enabledWhen>
</handler>
<handler
class="ccw.util.ClojureHandlerFactory:ccw.editors.antlrbased.handlers/expand-right"
commandId="ccw.ui.edit.text.clojure.expand.selection.right">
<enabledWhen>
<with
variable="activeContexts">
<iterate
ifEmpty="false"
operator="or">
<equals
value="ccw.ui.clojureEditorScope">
</equals>
</iterate>
</with>
</enabledWhen>
</handler>
<handler
class="ccw.util.ClojureHandlerFactory:ccw.editors.antlrbased.handlers/expand-left"
commandId="ccw.ui.edit.text.clojure.expand.selection.left">
<enabledWhen>
<with
variable="activeContexts">
<iterate
ifEmpty="false"
operator="or">
<equals
value="ccw.ui.clojureEditorScope">
</equals>
</iterate>
</with>
</enabledWhen>
</handler>
<handler
class="ccw.util.ClojureHandlerFactory:ccw.editors.antlrbased.handlers/expand-up"
commandId="ccw.ui.edit.text.clojure.expand.selection.up">
<enabledWhen>
<with
variable="activeContexts">
<iterate
ifEmpty="false"
operator="or">
<equals
value="ccw.ui.clojureEditorScope">
</equals>
</iterate>
</with>
</enabledWhen>
</handler>
<handler
class="ccw.util.ClojureHandlerFactory:ccw.editors.antlrbased.handlers/select-last"
commandId="ccw.ui.edit.text.clojure.select.last">
<enabledWhen>
<with
variable="activeContexts">
<iterate
ifEmpty="false"
operator="or">
<equals
value="ccw.ui.clojureEditorScope">
</equals>
</iterate>
</with>
</enabledWhen>
</handler>
</extension>
</plugin>
3 changes: 0 additions & 3 deletions ccw.core/src/ccw/CCWPlugin.java
Expand Up @@ -189,9 +189,6 @@ private void startClojureCode(BundleContext bundleContext) throws Exception {
ClojureOSGi.loadAOTClass(bundleContext, "ccw.editors.antlrbased.PareditAutoEditStrategy");
ClojureOSGi.loadAOTClass(bundleContext, "ccw.editors.antlrbased.ClojureFormat");
ClojureOSGi.loadAOTClass(bundleContext, "ccw.editors.antlrbased.StacktraceHyperlink");
ClojureOSGi.loadAOTClass(bundleContext, "ccw.editors.antlrbased.ExpandSelectionUpAction");
ClojureOSGi.loadAOTClass(bundleContext, "ccw.editors.antlrbased.ExpandSelectionLeftAction");
ClojureOSGi.loadAOTClass(bundleContext, "ccw.editors.antlrbased.ExpandSelectionRightAction");
ClojureOSGi.loadAOTClass(bundleContext, "ccw.editors.antlrbased.IndentSelectionAction");
ClojureOSGi.loadAOTClass(bundleContext, "ccw.editors.antlrbased.SwitchStructuralEditionModeAction");
ClojureOSGi.loadAOTClass(bundleContext, "ccw.editors.antlrbased.OpenDeclarationAction");
Expand Down
3 changes: 0 additions & 3 deletions ccw.core/src/ccw/compile.clj
Expand Up @@ -22,9 +22,6 @@
'ccw.editors.antlrbased.PareditAutoEditStrategy
'ccw.editors.antlrbased.ClojureFormat
'ccw.editors.antlrbased.StacktraceHyperlink
'ccw.editors.antlrbased.ExpandSelectionUpAction
'ccw.editors.antlrbased.ExpandSelectionLeftAction
'ccw.editors.antlrbased.ExpandSelectionRightAction
'ccw.editors.antlrbased.IndentSelectionAction
'ccw.editors.antlrbased.SwitchStructuralEditionModeAction
'ccw.editors.antlrbased.OpenDeclarationAction
Expand Down
33 changes: 7 additions & 26 deletions ccw.core/src/ccw/editors/antlrbased/AntlrBasedClojureEditor.java
Expand Up @@ -60,10 +60,9 @@ public class AntlrBasedClojureEditor extends TextEditor implements IClojureEdito



/** History for structure select action
* STOLEN FROM THE JDT */
private SelectionHistory fSelectionHistory;

public SelectionHistory getSelectionHistory() {
return sourceViewer().getSelectionHistory();
}

/** The projection support */
private ProjectionSupport fProjectionSupport;
Expand Down Expand Up @@ -269,25 +268,11 @@ public void run() {
setAction(CONTENT_ASSIST_PROPOSAL, action);
markAsStateDependentAction(CONTENT_ASSIST_PROPOSAL, true);

// Copied directly from JDT (no interest in owning the code currently)
fSelectionHistory = new SelectionHistory(this);
StructureSelectHistoryAction historyAction= new StructureSelectHistoryAction(this, fSelectionHistory);
historyAction.setActionDefinitionId(IClojureEditorActionDefinitionIds.SELECT_LAST);
setAction("RestoreSelection", historyAction);
fSelectionHistory.setHistoryAction(historyAction);
// StructureSelectHistoryHandler historyAction= new StructureSelectHistoryHandler(this);
// historyAction.setActionDefinitionId(IClojureEditorActionDefinitionIds.SELECT_LAST);
// setAction("RestoreSelection", historyAction);
// sourceViewer().getSelectionHistory().setHistoryAction(historyAction);

action = new ExpandSelectionUpAction(this, fSelectionHistory);
action.setActionDefinitionId(IClojureEditorActionDefinitionIds.EXPAND_SELECTION_UP);
setAction(/*ExpandSelectionUpAction.ID*/"ExpandSelectionUpAction", action);

action = new ExpandSelectionLeftAction(this, fSelectionHistory);
action.setActionDefinitionId(IClojureEditorActionDefinitionIds.EXPAND_SELECTION_LEFT);
setAction(/*ExpandSelectionLeftAction.ID*/"ExpandSelectionLeftAction", action);

action = new ExpandSelectionRightAction(this, fSelectionHistory);
action.setActionDefinitionId(IClojureEditorActionDefinitionIds.EXPAND_SELECTION_RIGHT);
setAction(/*ExpandSelectionRightAction.ID*/"ExpandSelectionRightAction", action);

action = new IndentSelectionAction(this);
action.setActionDefinitionId(IClojureEditorActionDefinitionIds.INDENT_SELECTION);
setAction(/*IndentSelectionAction.ID*/"IndentSelectionAction", action);
Expand Down Expand Up @@ -537,10 +522,6 @@ public void dispose() {
if (getPairsMatcher() != null) {
getPairsMatcher().dispose();
}
if (fSelectionHistory != null) {
fSelectionHistory.dispose();
fSelectionHistory = null;
}
super.dispose();
}

Expand Down
16 changes: 16 additions & 0 deletions ccw.core/src/ccw/editors/antlrbased/ClojureSourceViewer.java
Expand Up @@ -89,6 +89,14 @@ public abstract class ClojureSourceViewer extends ProjectionViewer implements

private boolean inEscapeSequence;

/** History for structure select action
* STOLEN FROM THE JDT */
private SelectionHistory fSelectionHistory;

public SelectionHistory getSelectionHistory() {
return fSelectionHistory;
}

public ClojureSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean showAnnotationsOverview, int styles, IPreferenceStore store) {
super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles);
setPreferenceStore(store);
Expand Down Expand Up @@ -165,9 +173,12 @@ public void configure(SourceViewerConfiguration configuration) {
if (configuration instanceof ClojureSourceViewerConfiguration)
fConfiguration = (ClojureSourceViewerConfiguration) configuration;

fSelectionHistory = new SelectionHistory(this);

fIsConfigured= true;
}


/**
* Creates a color from the information stored in the given preference store.
* Returns <code>null</code> if there is no such information available.
Expand Down Expand Up @@ -274,6 +285,11 @@ public void unconfigure() {
if (fPreferenceStore != null)
fPreferenceStore.removePropertyChangeListener(this);

if (fSelectionHistory != null) {
fSelectionHistory.dispose();
fSelectionHistory = null;
}

super.unconfigure();
fIsConfigured= false;
fConfiguration = null;
Expand Down
55 changes: 0 additions & 55 deletions ccw.core/src/ccw/editors/antlrbased/ExpandSelectionLeftAction.clj

This file was deleted.

54 changes: 0 additions & 54 deletions ccw.core/src/ccw/editors/antlrbased/ExpandSelectionRightAction.clj

This file was deleted.

54 changes: 0 additions & 54 deletions ccw.core/src/ccw/editors/antlrbased/ExpandSelectionUpAction.clj

This file was deleted.

5 changes: 5 additions & 0 deletions ccw.core/src/ccw/editors/antlrbased/IClojureEditor.java
Expand Up @@ -4,6 +4,7 @@
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.source.DefaultCharacterPairMatcher;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.ui.texteditor.AbstractTextEditor;

import ccw.repl.REPLView;
Expand Down Expand Up @@ -58,6 +59,10 @@ public interface IClojureEditor {
*/
IRegion getSignedSelection ();

SelectionHistory getSelectionHistory();

ISelectionProvider getSelectionProvider();

/**
* Returns the current namespace of the editor.
*/
Expand Down

0 comments on commit dbec06e

Please sign in to comment.