use of com.intellij.openapi.editor.actions.ToggleUseSoftWrapsToolbarAction in project intellij-community by JetBrains.
the class ConsoleViewImpl method createConsoleActions.
@Override
@NotNull
public AnAction[] createConsoleActions() {
//Initializing prev and next occurrences actions
final CommonActionsManager actionsManager = CommonActionsManager.getInstance();
final AnAction prevAction = actionsManager.createPrevOccurenceAction(this);
prevAction.getTemplatePresentation().setText(getPreviousOccurenceActionName());
final AnAction nextAction = actionsManager.createNextOccurenceAction(this);
nextAction.getTemplatePresentation().setText(getNextOccurenceActionName());
final AnAction switchSoftWrapsAction = new ToggleUseSoftWrapsToolbarAction(SoftWrapAppliancePlaces.CONSOLE) {
@Override
protected Editor getEditor(AnActionEvent e) {
return myEditor;
}
@Override
public void setSelected(AnActionEvent e, final boolean state) {
super.setSelected(e, state);
if (myEditor == null) {
return;
}
final String placeholder = myCommandLineFolding.getPlaceholder(0);
final FoldingModel foldingModel = myEditor.getFoldingModel();
final int firstLineEnd = myEditor.getDocument().getLineEndOffset(0);
foldingModel.runBatchFoldingOperation(() -> {
FoldRegion[] regions = foldingModel.getAllFoldRegions();
if (regions.length > 0 && regions[0].getStartOffset() == 0 && regions[0].getEndOffset() == firstLineEnd) {
foldingModel.removeFoldRegion(regions[0]);
}
if (placeholder != null) {
FoldRegion foldRegion = foldingModel.addFoldRegion(0, firstLineEnd, placeholder);
if (foldRegion != null) {
foldRegion.setExpanded(false);
}
}
});
}
};
final AnAction autoScrollToTheEndAction = new ScrollToTheEndToolbarAction(myEditor);
//Initializing custom actions
final AnAction[] consoleActions = new AnAction[6 + customActions.size()];
consoleActions[0] = prevAction;
consoleActions[1] = nextAction;
consoleActions[2] = switchSoftWrapsAction;
consoleActions[3] = autoScrollToTheEndAction;
consoleActions[4] = ActionManager.getInstance().getAction("Print");
consoleActions[5] = new ClearAllAction(this);
for (int i = 0; i < customActions.size(); ++i) {
consoleActions[i + 6] = customActions.get(i);
}
ConsoleActionsPostProcessor[] postProcessors = Extensions.getExtensions(ConsoleActionsPostProcessor.EP_NAME);
AnAction[] result = consoleActions;
for (ConsoleActionsPostProcessor postProcessor : postProcessors) {
result = postProcessor.postProcess(this, result);
}
return result;
}
Aggregations