diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.form b/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.form index fe82b9dea740..9925d4326077 100644 --- a/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.form +++ b/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.form @@ -317,7 +317,7 @@ - + @@ -330,7 +330,7 @@ - + @@ -338,10 +338,21 @@ - + + + + + + + + + + + + diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.java b/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.java index 84c44a22ab82..3e5387f081d2 100644 --- a/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.java @@ -102,6 +102,7 @@ public class EditorOptionsPanel { private JComboBox myRichCopyColorSchemeComboBox; private JCheckBox myShowInlineDialogForCheckBox; private JBLabel myStripTrailingSpacesExplanationLabel; + private JCheckBox myCbEnableRichCopyByDefault; private static final String ACTIVE_COLOR_SCHEME = ApplicationBundle.message("combobox.richcopy.color.scheme.active"); @@ -229,6 +230,7 @@ public class EditorOptionsPanel { myErrorHighlightingPanel.reset(); RichCopySettings settings = RichCopySettings.getInstance(); + myCbEnableRichCopyByDefault.setSelected(settings.isEnabled()); myRichCopyColorSchemeComboBox.removeAllItems(); EditorColorsScheme[] schemes = EditorColorsManager.getInstance().getAllSchemes(); myRichCopyColorSchemeComboBox.addItem(RichCopySettings.ACTIVE_GLOBAL_SCHEME_MARKER); @@ -360,6 +362,7 @@ public class EditorOptionsPanel { myErrorHighlightingPanel.apply(); RichCopySettings settings = RichCopySettings.getInstance(); + settings.setEnabled(myCbEnableRichCopyByDefault.isSelected()); Object item = myRichCopyColorSchemeComboBox.getSelectedItem(); if (item instanceof String) { settings.setSchemeName(item.toString()); @@ -485,6 +488,7 @@ public class EditorOptionsPanel { isModified |= myErrorHighlightingPanel.isModified(); RichCopySettings settings = RichCopySettings.getInstance(); + isModified |= isModified(myCbEnableRichCopyByDefault, settings.isEnabled()); isModified |= !Comparing.equal(settings.getSchemeName(), myRichCopyColorSchemeComboBox.getSelectedItem()); return isModified; diff --git a/platform/lang-impl/src/com/intellij/openapi/editor/richcopy/CopyAsPlainTextAction.java b/platform/lang-impl/src/com/intellij/openapi/editor/richcopy/CopyAsPlainTextAction.java new file mode 100644 index 000000000000..f5adc9454213 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/openapi/editor/richcopy/CopyAsPlainTextAction.java @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Created by IntelliJ IDEA. + * User: max + * Date: May 13, 2002 + * Time: 5:37:50 PM + * To change template for new class use + * Code Style | Class Templates options (Tools | IDE Options). + */ +package com.intellij.openapi.editor.richcopy; + +public class CopyAsPlainTextAction extends ForcedCopyModeAction { + public CopyAsPlainTextAction() { + super(false); + } +} diff --git a/platform/lang-impl/src/com/intellij/openapi/editor/richcopy/CopyAsRichTextAction.java b/platform/lang-impl/src/com/intellij/openapi/editor/richcopy/CopyAsRichTextAction.java new file mode 100644 index 000000000000..5f6c2bd3625f --- /dev/null +++ b/platform/lang-impl/src/com/intellij/openapi/editor/richcopy/CopyAsRichTextAction.java @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Created by IntelliJ IDEA. + * User: max + * Date: May 13, 2002 + * Time: 5:37:50 PM + * To change template for new class use + * Code Style | Class Templates options (Tools | IDE Options). + */ +package com.intellij.openapi.editor.richcopy; + +public class CopyAsRichTextAction extends ForcedCopyModeAction { + public CopyAsRichTextAction() { + super(true); + } +} diff --git a/platform/lang-impl/src/com/intellij/openapi/editor/richcopy/ForcedCopyModeAction.java b/platform/lang-impl/src/com/intellij/openapi/editor/richcopy/ForcedCopyModeAction.java new file mode 100644 index 000000000000..93f4cc371f06 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/openapi/editor/richcopy/ForcedCopyModeAction.java @@ -0,0 +1,51 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.editor.richcopy; + +import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.richcopy.settings.RichCopySettings; + +public abstract class ForcedCopyModeAction extends AnAction { + private final boolean myRichCopyEnabled; + + protected ForcedCopyModeAction(boolean richCopyEnabled) { + myRichCopyEnabled = richCopyEnabled; + } + + @Override + public void update(AnActionEvent e) { + Presentation p = e.getPresentation(); + Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext()); + p.setVisible(RichCopySettings.getInstance().isEnabled() != myRichCopyEnabled && + (!e.getPlace().equals(ActionPlaces.EDITOR_POPUP) || + editor != null && editor.getSelectionModel().hasSelection(true))); + p.setEnabled(true); + } + + @Override + public void actionPerformed(AnActionEvent e) { + RichCopySettings settings = RichCopySettings.getInstance(); + boolean savedValue = settings.isEnabled(); + try { + settings.setEnabled(myRichCopyEnabled); + ActionManager.getInstance().getAction(IdeActions.ACTION_EDITOR_COPY).actionPerformed(e); + } + finally { + settings.setEnabled(savedValue); + } + } +} diff --git a/platform/lang-impl/src/com/intellij/openapi/editor/richcopy/TextWithMarkupProcessor.java b/platform/lang-impl/src/com/intellij/openapi/editor/richcopy/TextWithMarkupProcessor.java index 6458bfe13a9e..a70eed809667 100644 --- a/platform/lang-impl/src/com/intellij/openapi/editor/richcopy/TextWithMarkupProcessor.java +++ b/platform/lang-impl/src/com/intellij/openapi/editor/richcopy/TextWithMarkupProcessor.java @@ -71,7 +71,7 @@ public class TextWithMarkupProcessor extends CopyPastePostProcessor collectTransferableData(PsiFile file, Editor editor, int[] startOffsets, int[] endOffsets) { - if (!Registry.is("editor.richcopy.enable")) { + if (!RichCopySettings.getInstance().isEnabled()) { return Collections.emptyList(); } diff --git a/platform/lang-impl/src/com/intellij/openapi/editor/richcopy/settings/RichCopySettings.java b/platform/lang-impl/src/com/intellij/openapi/editor/richcopy/settings/RichCopySettings.java index 12040067fa59..dc9152042f21 100644 --- a/platform/lang-impl/src/com/intellij/openapi/editor/richcopy/settings/RichCopySettings.java +++ b/platform/lang-impl/src/com/intellij/openapi/editor/richcopy/settings/RichCopySettings.java @@ -34,6 +34,7 @@ public class RichCopySettings implements PersistentStateComponent + + + + + + + + + + diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index c161fbc76720..dd03c96f747d 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -420,7 +420,6 @@ output.reader.blocking.mode=false ide.certificate.manager=true -editor.richcopy.enable=true editor.richcopy.max.size.megabytes=10 editor.richcopy.strip.indents=true allow.dialog.based.popups=true