use of com.intellij.openapi.editor.event.EditorMouseEvent in project intellij-community by JetBrains.
the class ResourceBundleEditor method reinitSettings.
private void reinitSettings(final EditorEx editor) {
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
editor.setColorsScheme(scheme);
editor.setBorder(BorderFactory.createLineBorder(JBColor.border(), 1));
EditorSettings settings = editor.getSettings();
settings.setLineNumbersShown(false);
settings.setWhitespacesShown(false);
settings.setLineMarkerAreaShown(false);
settings.setIndentGuidesShown(false);
settings.setFoldingOutlineShown(false);
settings.setAdditionalColumnsCount(0);
settings.setAdditionalLinesCount(0);
settings.setRightMarginShown(true);
settings.setRightMargin(60);
settings.setVirtualSpace(false);
editor.setHighlighter(new LexerEditorHighlighter(new PropertiesValueHighlighter(), scheme));
editor.setVerticalScrollbarVisible(true);
// disabling default context menu
editor.setContextMenuGroupId(null);
editor.addEditorMouseListener(new EditorPopupHandler() {
@Override
public void invokePopup(EditorMouseEvent event) {
if (!event.isConsumed() && event.getArea() == EditorMouseEventArea.EDITING_AREA) {
DefaultActionGroup group = new DefaultActionGroup();
group.add(CustomActionsSchema.getInstance().getCorrectedAction(IdeActions.GROUP_CUT_COPY_PASTE));
group.add(CustomActionsSchema.getInstance().getCorrectedAction(IdeActions.ACTION_EDIT_SOURCE));
group.addSeparator();
group.add(new AnAction("Propagate Value Across of Resource Bundle") {
@Override
public void actionPerformed(AnActionEvent e) {
final String valueToPropagate = editor.getDocument().getText();
final String currentSelectedProperty = getSelectedPropertyName();
if (currentSelectedProperty == null) {
return;
}
ApplicationManager.getApplication().runWriteAction(() -> WriteCommandAction.runWriteCommandAction(myProject, () -> {
try {
final PropertiesFile[] propertiesFiles = myResourceBundle.getPropertiesFiles().stream().filter(f -> {
final IProperty property = f.findPropertyByKey(currentSelectedProperty);
return property == null || !valueToPropagate.equals(property.getValue());
}).toArray(PropertiesFile[]::new);
final PsiFile[] filesToPrepare = Arrays.stream(propertiesFiles).map(PropertiesFile::getContainingFile).toArray(PsiFile[]::new);
if (FileModificationService.getInstance().preparePsiElementsForWrite(filesToPrepare)) {
for (PropertiesFile file : propertiesFiles) {
myPropertiesInsertDeleteManager.insertOrUpdateTranslation(currentSelectedProperty, valueToPropagate, file);
}
recreateEditorsPanel();
}
} catch (final IncorrectOperationException e1) {
LOG.error(e1);
}
}));
}
});
EditorPopupHandler handler = EditorActionUtil.createEditorPopupHandler(group);
handler.invokePopup(event);
event.consume();
}
}
});
}
use of com.intellij.openapi.editor.event.EditorMouseEvent in project intellij-community by JetBrains.
the class EventLogConsole method createLogEditor.
private Editor createLogEditor() {
Project project = myProjectModel.getProject();
final EditorEx editor = ConsoleViewUtil.setupConsoleEditor(project, false, false);
editor.getSettings().setWhitespacesShown(false);
installNotificationsFont(editor);
myProjectModel.getProject().getMessageBus().connect().subscribe(ProjectManager.TOPIC, new ProjectManagerAdapter() {
@Override
public void projectClosed(Project project) {
if (project == myProjectModel.getProject()) {
EditorFactory.getInstance().releaseEditor(editor);
}
}
});
((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true);
final ClearLogAction clearLog = new ClearLogAction(this);
clearLog.registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.CONSOLE_CLEAR_ALL).getShortcutSet(), editor.getContentComponent());
// disabling default context menu
editor.setContextMenuGroupId(null);
editor.addEditorMouseListener(new EditorPopupHandler() {
public void invokePopup(final EditorMouseEvent event) {
final ActionManager actionManager = ActionManager.getInstance();
DefaultActionGroup actions = createPopupActions(actionManager, clearLog, editor, event);
final ActionPopupMenu menu = actionManager.createActionPopupMenu(ActionPlaces.EDITOR_POPUP, actions);
final MouseEvent mouseEvent = event.getMouseEvent();
menu.getComponent().show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
}
});
return editor;
}
use of com.intellij.openapi.editor.event.EditorMouseEvent in project intellij-community by JetBrains.
the class ConsoleViewImpl method createConsoleEditor.
@NotNull
private EditorEx createConsoleEditor() {
return ReadAction.compute(() -> {
EditorEx editor = doCreateConsoleEditor();
LOG.assertTrue(UndoUtil.isUndoDisabledFor(editor.getDocument()));
// disabling default context menu
editor.setContextMenuGroupId(null);
editor.addEditorMouseListener(new EditorPopupHandler() {
@Override
public void invokePopup(final EditorMouseEvent event) {
popupInvoked(event.getMouseEvent());
}
});
int bufferSize = ConsoleBuffer.useCycleBuffer() ? ConsoleBuffer.getCycleBufferSize() : 0;
editor.getDocument().setCyclicBufferSize(bufferSize);
editor.putUserData(CONSOLE_VIEW_IN_EDITOR_VIEW, this);
// We want to fold long soft-wrapped command lines
editor.getSettings().setAllowSingleLogicalLineFolding(true);
return editor;
});
}
use of com.intellij.openapi.editor.event.EditorMouseEvent in project intellij-community by JetBrains.
the class EditorActionUtil method showEditorPopup.
private static void showEditorPopup(final EditorMouseEvent event, @NotNull final ActionGroup group) {
if (!event.isConsumed() && event.getArea() == EditorMouseEventArea.EDITING_AREA) {
ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.EDITOR_POPUP, group);
MouseEvent e = event.getMouseEvent();
final Component c = e.getComponent();
if (c != null && c.isShowing()) {
popupMenu.getComponent().show(c, e.getX(), e.getY());
}
e.consume();
}
}
use of com.intellij.openapi.editor.event.EditorMouseEvent in project intellij-community by JetBrains.
the class EditorActionUtil method createEditorPopupHandler.
public static EditorPopupHandler createEditorPopupHandler(@NotNull final String groupId) {
return new EditorPopupHandler() {
@Override
public void invokePopup(final EditorMouseEvent event) {
if (!event.isConsumed() && event.getArea() == EditorMouseEventArea.EDITING_AREA) {
ActionGroup group = (ActionGroup) CustomActionsSchema.getInstance().getCorrectedAction(groupId);
showEditorPopup(event, group);
}
}
};
}
Aggregations