diff --git a/build/update.sh b/build/update.sh
new file mode 100755
index 000000000000..f37a360464c3
--- /dev/null
+++ b/build/update.sh
@@ -0,0 +1,34 @@
+#! /bin/bash
+#
+# This script updates your IntelliJ IDEA CE installation from the latest compiled classes. This way you can easily
+# upgrade your working IDEA to the latest changes.
+#
+# Before you run the script, ensure you have the following:
+# 1. Your project for IntelliJ IDEA CE is fully built (do 'Rebuild Project' if you're not sure)
+# 2. WORK_IDEA_HOME points to the directory of IntelliJ IDEA build you want to upgrade
+# 3. DEV_IDEA_HOME points to the directory of the project you built at step 1
+# 4. You quit IntelliJ IDEA
+#
+
+if [ -z "$WORK_IDEA_HOME" ]; then
+ echo WORK_IDEA_HOME must be defined and point to build you're updating
+ exit
+fi
+
+if [ -z "$DEV_IDEA_HOME" ]; then
+ echo DEV_IDEA_HOME must be defined and point to source base your're updating from
+ exit
+fi
+
+echo Updating $WORK_IDEA_HOME from compiled classes in $DEV_IDEA_HOME
+
+rm -rf $WORK_IDEA_HOME/lib
+rm -rf $WORK_IDEA_HOME/plugins
+
+ant -f update.xml
+
+cd $DEV_IDEA_HOME
+cp -R $DEV_IDEA_HOME/out/deploy/* $WORK_IDEA_HOME
+
+cd $WORK_IDEA_HOME/bin
+
diff --git a/build/update.xml b/build/update.xml
new file mode 100644
index 000000000000..a397ee03a0d3
--- /dev/null
+++ b/build/update.xml
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/required_for_dist.txt b/lib/required_for_dist.txt
new file mode 100644
index 000000000000..358ef44e8b4c
--- /dev/null
+++ b/lib/required_for_dist.txt
@@ -0,0 +1,49 @@
+alloy.jar
+ant.jar
+asm-commons.jar
+asm.jar
+asm-tree-3.0.jar
+bcel.jar
+cglib-nodep-2.1_3.jar
+coverage-agent.jar
+coverage-report.jar
+coverage-report-idea.jar
+commons-codec-1.3.jar
+commons-collections.jar
+commons-lang-2.4.jar
+emma.jar
+freemarker.jar
+jdom.jar
+jgoodies-forms.jar
+looks-2.2.2.jar
+jcip-annotations.jar
+jh.jar
+JNIWrap.jar
+jsf-api.jar
+jsp-api.jar
+junit.jar
+junit-4.6.jar
+log4j.jar
+microba.jar
+nanoxml-2.2.3.jar
+org.eclipse.jdt.core_3.4.4.v_894_R34x.jar
+oromatcher.jar
+picocontainer.jar
+resolver.jar
+servlet-api.jar
+trove4j.jar
+velocity.jar
+xerces.jar
+xml-apis.jar
+xmlrpc-2.0.jar
+xstream.jar
+xpp3-1.1.4-min.jar
+yjp-controller-api-redist.jar
+jna.jar
+jna-utils.jar
+groovy-all-1.6.3.jar
+jaxen-1.1.1.jar
+commons-net-1.4.1.jar
+serviceMessages.jar
+xbean.jar
+jsr173_1.0_api.jar
diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleSpacesConfigurable.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleSpacesConfigurable.java
new file mode 100644
index 000000000000..f64d3503e5ca
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleSpacesConfigurable.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2000-2010 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.application.options.codeStyle;
+
+import com.intellij.application.options.CodeStyleAbstractConfigurable;
+import com.intellij.application.options.CodeStyleAbstractPanel;
+import com.intellij.openapi.application.ApplicationBundle;
+import com.intellij.openapi.fileTypes.StdFileTypes;
+import com.intellij.psi.codeStyle.CodeStyleSettings;
+
+import javax.swing.*;
+
+public class CodeStyleSpacesConfigurable extends CodeStyleAbstractConfigurable {
+ public CodeStyleSpacesConfigurable(CodeStyleSettings settings, CodeStyleSettings cloneSettings) {
+ super(settings, cloneSettings, ApplicationBundle.message("title.spaces"));
+ }
+
+ public Icon getIcon() {
+ return StdFileTypes.JAVA.getIcon();
+ }
+
+ protected CodeStyleAbstractPanel createPanel(final CodeStyleSettings settings) {
+ return new CodeStyleSpacesPanel(settings);
+ }
+
+ public String getHelpTopic() {
+ return "reference.settingsdialog.IDE.globalcodestyle.spaces";
+ }
+}
\ No newline at end of file
diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleSpacesPanel.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleSpacesPanel.java
new file mode 100644
index 000000000000..dfca03e0d4a3
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleSpacesPanel.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright 2000-2010 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.application.options.codeStyle;
+
+import com.intellij.openapi.application.ApplicationBundle;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.EditorSettings;
+import com.intellij.psi.codeStyle.CodeStyleSettings;
+
+import javax.swing.*;
+
+public class CodeStyleSpacesPanel extends OptionTreeWithPreviewPanel {
+ public CodeStyleSpacesPanel(CodeStyleSettings settings) {
+ super(settings);
+ }
+
+ private static final String AROUND_OPERATORS = ApplicationBundle.message("group.spaces.around.operators");
+ private static final String BEFORE_PARENTHESES = ApplicationBundle.message("group.spaces.before.parentheses");
+ private static final String BEFORE_LEFT_BRACE = ApplicationBundle.message("group.spaces.before.left.brace");
+ private static final String WITHIN_PARENTHESES = ApplicationBundle.message("group.spaces.within.parentheses");
+ private static final String TERNARY_OPERATOR = ApplicationBundle.message("group.spaces.in.ternary.operator");
+ private static final String OTHER = ApplicationBundle.message("group.spaces.other");
+
+ protected void initTables() {
+ initBooleanField("SPACE_BEFORE_METHOD_CALL_PARENTHESES", ApplicationBundle.message("checkbox.spaces.method.call.parentheses"), BEFORE_PARENTHESES);
+ initBooleanField("SPACE_BEFORE_METHOD_PARENTHESES", ApplicationBundle.message("checkbox.spaces.method.declaration.parentheses"), BEFORE_PARENTHESES);
+ initBooleanField("SPACE_BEFORE_IF_PARENTHESES", ApplicationBundle.message("checkbox.spaces.if.parentheses"), BEFORE_PARENTHESES);
+ initBooleanField("SPACE_BEFORE_WHILE_PARENTHESES", ApplicationBundle.message("checkbox.spaces.while.parentheses"), BEFORE_PARENTHESES);
+ initBooleanField("SPACE_BEFORE_FOR_PARENTHESES", ApplicationBundle.message("checkbox.spaces.for.parentheses"), BEFORE_PARENTHESES);
+ initBooleanField("SPACE_BEFORE_CATCH_PARENTHESES", ApplicationBundle.message("checkbox.spaces.catch.parentheses"), BEFORE_PARENTHESES);
+ initBooleanField("SPACE_BEFORE_SWITCH_PARENTHESES", ApplicationBundle.message("checkbox.spaces.switch.parentheses"), BEFORE_PARENTHESES);
+ initBooleanField("SPACE_BEFORE_SYNCHRONIZED_PARENTHESES", ApplicationBundle.message("checkbox.spaces.synchronized.parentheses"), BEFORE_PARENTHESES);
+ initBooleanField("SPACE_BEFORE_ANOTATION_PARAMETER_LIST", ApplicationBundle.message("checkbox.spaces.annotation.parameters"), BEFORE_PARENTHESES);
+
+ initBooleanField("SPACE_AROUND_ASSIGNMENT_OPERATORS", ApplicationBundle.message("checkbox.spaces.assignment.operators"), AROUND_OPERATORS);
+ initBooleanField("SPACE_AROUND_LOGICAL_OPERATORS", ApplicationBundle.message("checkbox.spaces.logical.operators"), AROUND_OPERATORS);
+ initBooleanField("SPACE_AROUND_EQUALITY_OPERATORS", ApplicationBundle.message("checkbox.spaces.equality.operators"), AROUND_OPERATORS);
+ initBooleanField("SPACE_AROUND_RELATIONAL_OPERATORS", ApplicationBundle.message("checkbox.spaces.relational.operators"), AROUND_OPERATORS);
+ initBooleanField("SPACE_AROUND_BITWISE_OPERATORS", ApplicationBundle.message("checkbox.spaces.bitwise.operators"), AROUND_OPERATORS);
+ initBooleanField("SPACE_AROUND_ADDITIVE_OPERATORS", ApplicationBundle.message("checkbox.spaces.additive.operators"), AROUND_OPERATORS);
+ initBooleanField("SPACE_AROUND_MULTIPLICATIVE_OPERATORS", ApplicationBundle.message("checkbox.spaces.multiplicative.operators"), AROUND_OPERATORS);
+ initBooleanField("SPACE_AROUND_SHIFT_OPERATORS", ApplicationBundle.message("checkbox.spaces.shift.operators"), AROUND_OPERATORS);
+
+ initBooleanField("SPACE_BEFORE_CLASS_LBRACE", ApplicationBundle.message("checkbox.spaces.class.left.brace"), BEFORE_LEFT_BRACE);
+ initBooleanField("SPACE_BEFORE_METHOD_LBRACE", ApplicationBundle.message("checkbox.spaces.method.left.brace"), BEFORE_LEFT_BRACE);
+ initBooleanField("SPACE_BEFORE_IF_LBRACE", ApplicationBundle.message("checkbox.spaces.if.left.brace"), BEFORE_LEFT_BRACE);
+ initBooleanField("SPACE_BEFORE_ELSE_LBRACE", ApplicationBundle.message("checkbox.spaces.else.left.brace"), BEFORE_LEFT_BRACE);
+ initBooleanField("SPACE_BEFORE_WHILE_LBRACE", ApplicationBundle.message("checkbox.spaces.while.left.brace"), BEFORE_LEFT_BRACE);
+ initBooleanField("SPACE_BEFORE_FOR_LBRACE", ApplicationBundle.message("checkbox.spaces.for.left.brace"), BEFORE_LEFT_BRACE);
+ initBooleanField("SPACE_BEFORE_DO_LBRACE", ApplicationBundle.message("checkbox.spaces.do.left.brace"), BEFORE_LEFT_BRACE);
+ initBooleanField("SPACE_BEFORE_SWITCH_LBRACE", ApplicationBundle.message("checkbox.spaces.switch.left.brace"), BEFORE_LEFT_BRACE);
+ initBooleanField("SPACE_BEFORE_TRY_LBRACE", ApplicationBundle.message("checkbox.spaces.try.left.brace"), BEFORE_LEFT_BRACE);
+ initBooleanField("SPACE_BEFORE_CATCH_LBRACE", ApplicationBundle.message("checkbox.spaces.catch.left.brace"), BEFORE_LEFT_BRACE);
+ initBooleanField("SPACE_BEFORE_FINALLY_LBRACE", ApplicationBundle.message("checkbox.spaces.finally.left.brace"), BEFORE_LEFT_BRACE);
+ initBooleanField("SPACE_BEFORE_SYNCHRONIZED_LBRACE", ApplicationBundle.message("checkbox.spaces.synchronized.left.brace"), BEFORE_LEFT_BRACE);
+ initBooleanField("SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE", ApplicationBundle.message("checkbox.spaces.array.initializer.left.brace"), BEFORE_LEFT_BRACE);
+
+ initBooleanField("SPACE_WITHIN_PARENTHESES", ApplicationBundle.message("checkbox.spaces.parentheses"), WITHIN_PARENTHESES);
+ initBooleanField("SPACE_WITHIN_METHOD_CALL_PARENTHESES", ApplicationBundle.message("checkbox.spaces.checkbox.spaces.method.call.parentheses"), WITHIN_PARENTHESES);
+ initBooleanField("SPACE_WITHIN_METHOD_PARENTHESES", ApplicationBundle.message("checkbox.spaces.checkbox.spaces.method.declaration.parentheses"), WITHIN_PARENTHESES);
+ initBooleanField("SPACE_WITHIN_IF_PARENTHESES", ApplicationBundle.message("checkbox.spaces.if.parentheses"), WITHIN_PARENTHESES);
+ initBooleanField("SPACE_WITHIN_WHILE_PARENTHESES", ApplicationBundle.message("checkbox.spaces.while.parentheses"), WITHIN_PARENTHESES);
+ initBooleanField("SPACE_WITHIN_FOR_PARENTHESES", ApplicationBundle.message("checkbox.spaces.for.parentheses"), WITHIN_PARENTHESES);
+ initBooleanField("SPACE_WITHIN_CATCH_PARENTHESES", ApplicationBundle.message("checkbox.spaces.catch.parentheses"), WITHIN_PARENTHESES);
+ initBooleanField("SPACE_WITHIN_SWITCH_PARENTHESES", ApplicationBundle.message("checkbox.spaces.switch.parentheses"), WITHIN_PARENTHESES);
+ initBooleanField("SPACE_WITHIN_SYNCHRONIZED_PARENTHESES", ApplicationBundle.message("checkbox.spaces.synchronized.parentheses"), WITHIN_PARENTHESES);
+ initBooleanField("SPACE_WITHIN_CAST_PARENTHESES", ApplicationBundle.message("checkbox.spaces.type.cast.parentheses"), WITHIN_PARENTHESES);
+ initBooleanField("SPACE_WITHIN_ANNOTATION_PARENTHESES", ApplicationBundle.message("checkbox.spaces.annotation.parentheses"), WITHIN_PARENTHESES);
+
+ initBooleanField("SPACE_BEFORE_QUEST", ApplicationBundle.message("checkbox.spaces.before.question"), TERNARY_OPERATOR);
+ initBooleanField("SPACE_AFTER_QUEST", ApplicationBundle.message("checkbox.spaces.after.question"), TERNARY_OPERATOR);
+ initBooleanField("SPACE_BEFORE_COLON", ApplicationBundle.message("checkbox.spaces.before.colon"), TERNARY_OPERATOR);
+ initBooleanField("SPACE_AFTER_COLON", ApplicationBundle.message("checkbox.spaces.after.colon"), TERNARY_OPERATOR);
+
+ initBooleanField("SPACE_AFTER_LABEL", ApplicationBundle.message("checkbox.spaces.after.colon.in.label.declaration"), OTHER);
+ initBooleanField("SPACE_WITHIN_BRACKETS", ApplicationBundle.message("checkbox.spaces.within.brackets"), OTHER);
+ initBooleanField("SPACE_WITHIN_ARRAY_INITIALIZER_BRACES", ApplicationBundle.message("checkbox.spaces.within.array.initializer.braces"), OTHER);
+ initBooleanField("SPACE_AFTER_COMMA", ApplicationBundle.message("checkbox.spaces.after.comma"), OTHER);
+ initBooleanField("SPACE_BEFORE_COMMA", ApplicationBundle.message("checkbox.spaces.before.comma"), OTHER);
+ initBooleanField("SPACE_AFTER_SEMICOLON", ApplicationBundle.message("checkbox.spaces.after.semicolon"), OTHER);
+ initBooleanField("SPACE_BEFORE_SEMICOLON", ApplicationBundle.message("checkbox.spaces.before.semicolon"), OTHER);
+ initBooleanField("SPACE_AFTER_TYPE_CAST", ApplicationBundle.message("checkbox.spaces.after.type.cast"), OTHER);
+ }
+
+ protected void setupEditorSettings(Editor editor) {
+ EditorSettings editorSettings = editor.getSettings();
+ editorSettings.setWhitespacesShown(true);
+ editorSettings.setLineMarkerAreaShown(false);
+ editorSettings.setLineNumbersShown(false);
+ editorSettings.setFoldingOutlineShown(false);
+ editorSettings.setAdditionalColumnsCount(0);
+ editorSettings.setAdditionalLinesCount(1);
+ }
+
+ protected String getPreviewText() {
+ return "@Annotation(param1=\"value1\", param2=\"value2\") public class Foo {\n" +
+ " int[] X = new int[]{1,3,5,6,7,87,1213,2};\n\n" +
+ " public void foo(int x, int y) {\n" +
+ " for(int i = 0; i < x; i++){\n" +
+ " y += (y ^ 0x123) << 2;\n" +
+ " }\n" +
+ " do {\n" +
+ " try {\n" +
+ " if(0 < x && x < 10) {\n" +
+ " while(x != y){\n" +
+ " x = f(x * 3 + 5);\n" +
+ " }\n" +
+ " } else {\n" +
+ " synchronized(this){\n" +
+ " switch(e.getCode()){\n" +
+ " //...\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " catch(MyException e) {\n" +
+ " }\n" +
+ " finally {\n" +
+ " int[] arr = (int[])g(y);\n" +
+ " x = y >= 0 ? arr[y] : -1;\n" +
+ " }\n" +
+ " }while(true);\n" +
+ " }\n" +
+ "}";
+ }
+
+ public JComponent getPanel() {
+ return getInternalPanel();
+ }
+}
\ No newline at end of file
diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/OptionTreeWithPreviewPanel.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/OptionTreeWithPreviewPanel.java
new file mode 100644
index 000000000000..3a97058cdf1b
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/OptionTreeWithPreviewPanel.java
@@ -0,0 +1,561 @@
+/*
+ * Copyright 2000-2010 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.application.options.codeStyle;
+
+import com.intellij.application.options.CodeStyleAbstractPanel;
+import com.intellij.ide.DataManager;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
+import com.intellij.openapi.application.ApplicationBundle;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.editor.colors.EditorColorsScheme;
+import com.intellij.openapi.editor.highlighter.EditorHighlighter;
+import com.intellij.openapi.fileTypes.FileType;
+import com.intellij.openapi.fileTypes.LanguageFileType;
+import com.intellij.openapi.fileTypes.StdFileTypes;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.project.ProjectManager;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.codeStyle.CodeStyleSettings;
+import com.intellij.ui.IdeBorderFactory;
+import com.intellij.ui.treeStructure.Tree;
+import com.intellij.util.containers.HashMap;
+import com.intellij.util.ui.UIUtil;
+import com.intellij.util.ui.tree.TreeUtil;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+import javax.swing.tree.*;
+import java.awt.*;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+/**
+ * @author max
+ */
+public abstract class OptionTreeWithPreviewPanel extends CodeStyleAbstractPanel {
+ private static final Logger LOG = Logger.getInstance("#com.intellij.application.options.CodeStyleSpacesPanel");
+ private final JTree myOptionsTree;
+ private final HashMap myKeyToFieldMap = new HashMap();
+ private final ArrayList myKeys = new ArrayList();
+ private final JPanel myPanel = new JPanel(new GridBagLayout());
+ private static LanguageFileType myFileType = StdFileTypes.JSP;
+
+ public OptionTreeWithPreviewPanel(CodeStyleSettings settings) {
+ super(settings);
+
+ initTables();
+
+ myOptionsTree = createOptionsTree();
+ myOptionsTree.setCellRenderer(new MyTreeCellRenderer());
+ myPanel.add(new JScrollPane(myOptionsTree),
+ new GridBagConstraints(0, 0, 1, 1, 0, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH,
+ new Insets(7, 7, 3, 4), 0, 0));
+
+ JPanel previewPanel = new JPanel(new BorderLayout()) {
+ public Dimension getPreferredSize() {
+ return new Dimension(200, 0);
+ }
+ };
+ previewPanel.setBorder(IdeBorderFactory.createTitledBorder(ApplicationBundle.message("title.preview")));
+
+ myPanel.add(previewPanel,
+ new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH,
+ new Insets(0, 0, 0, 4), 0, 0));
+
+ installPreviewPanel(previewPanel);
+ addPanelToWatch(myPanel);
+
+ }
+
+ protected JTree createOptionsTree() {
+ DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
+ String groupName = "";
+ DefaultMutableTreeNode groupNode = null;
+ for (int i = 0; i < myKeys.size(); i++) {
+ if (myKeys.get(i) instanceof BooleanOptionKey) {
+ BooleanOptionKey key = (BooleanOptionKey)myKeys.get(i);
+ String newGroupName = key.groupName;
+ if (!newGroupName.equals(groupName) || groupNode == null) {
+ groupName = newGroupName;
+ groupNode = new DefaultMutableTreeNode(newGroupName);
+ rootNode.add(groupNode);
+ }
+ groupNode.add(new MyToggleTreeNode(key, key.cbName));
+ }
+ else if (myKeys.get(i) instanceof IntSelectionOptionKey) {
+ IntSelectionOptionKey key = (IntSelectionOptionKey)myKeys.get(i);
+ String newGroupName = key.groupName;
+ if (!newGroupName.equals(groupName) || groupNode == null) {
+ groupName = newGroupName;
+ groupNode = new DefaultMutableTreeNode(newGroupName);
+ rootNode.add(groupNode);
+ }
+ MyToggleTreeNode[] nodes = new MyToggleTreeNode[key.rbNames.length];
+ for (int j = 0; j < nodes.length; j++) {
+ nodes[j] = new MyToggleTreeNode(key, key.rbNames[j]);
+ groupNode.add(nodes[j]);
+ }
+ key.setCreatedNodes(nodes);
+ }
+ }
+
+ DefaultTreeModel model = new DefaultTreeModel(rootNode);
+
+ final Tree optionsTree = new Tree(model);
+ TreeUtil.installActions(optionsTree);
+ optionsTree.setRootVisible(false);
+ UIUtil.setLineStyleAngled(optionsTree);
+ optionsTree.setShowsRootHandles(true);
+
+
+ optionsTree.addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent e) {
+ if (!optionsTree.isEnabled()) return;
+ if (e.getKeyCode() == KeyEvent.VK_SPACE) {
+ TreePath treePath = optionsTree.getLeadSelectionPath();
+ selectCheckbox(treePath);
+ e.consume();
+ }
+ }
+ });
+
+ optionsTree.addMouseListener(new MouseAdapter() {
+ public void mouseClicked(MouseEvent e) {
+ if (!optionsTree.isEnabled()) return;
+ TreePath treePath = optionsTree.getPathForLocation(e.getX(), e.getY());
+ selectCheckbox(treePath);
+ }
+ });
+
+ int row = 0;
+ while (row < optionsTree.getRowCount()) {
+ optionsTree.expandRow(row);
+ row++;
+ }
+
+ return optionsTree;
+ }
+
+ private void selectCheckbox(TreePath treePath) {
+ if (treePath == null) {
+ return;
+ }
+ Object o = treePath.getLastPathComponent();
+ if (o instanceof MyToggleTreeNode) {
+ MyToggleTreeNode node = (MyToggleTreeNode)o;
+ if (node.isCheckbox()) {
+ node.setSelected(!node.isSelected());
+ }
+ else {
+ MyToggleTreeNode[] group = node.getGroup();
+ for (int i = 0; i < group.length; i++) {
+ MyToggleTreeNode groupNode = group[i];
+ groupNode.setSelected(false);
+ int row = myOptionsTree.getRowForPath(new TreePath(groupNode.getPath()));
+ myOptionsTree.repaint(myOptionsTree.getRowBounds(row));
+ }
+ node.setSelected(true);
+ }
+ int row = myOptionsTree.getRowForPath(treePath);
+ myOptionsTree.repaint(myOptionsTree.getRowBounds(row));
+ //updatePreview();
+ somethingChanged();
+ }
+ }
+
+ protected EditorHighlighter createHighlighter(final EditorColorsScheme scheme) {
+ Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext());
+ if (project == null) {
+ project = ProjectManager.getInstance().getDefaultProject();
+ }
+ return myFileType.getEditorHighlighter(project, null, scheme);
+ }
+
+ protected abstract void initTables();
+
+ protected int getRightMargin() {
+ return -1;
+ }
+
+ @NonNls
+ protected abstract String getPreviewText();
+
+ protected void resetImpl(final CodeStyleSettings settings) {
+ TreeModel treeModel = myOptionsTree.getModel();
+ TreeNode root = (TreeNode)treeModel.getRoot();
+ resetNode(root, settings);
+ }
+
+ private void resetNode(TreeNode node, final CodeStyleSettings settings) {
+ if (node instanceof MyToggleTreeNode) {
+ resetMyTreeNode((MyToggleTreeNode)node, settings);
+ return;
+ }
+ for (int j = 0; j < node.getChildCount(); j++) {
+ TreeNode child = node.getChildAt(j);
+ resetNode(child, settings);
+ }
+ }
+
+ private void resetMyTreeNode(MyToggleTreeNode childNode, final CodeStyleSettings settings) {
+ try {
+ if (childNode.getKey() instanceof BooleanOptionKey) {
+ BooleanOptionKey key = (BooleanOptionKey)childNode.getKey();
+ Field field = (Field)myKeyToFieldMap.get(key);
+ childNode.setSelected(field.getBoolean(settings));
+ }
+ else if (childNode.getKey() instanceof IntSelectionOptionKey) {
+ IntSelectionOptionKey key = (IntSelectionOptionKey)childNode.getKey();
+ Field field = (Field)myKeyToFieldMap.get(key);
+ int fieldValue = field.getInt(settings);
+ for (int i = 0; i < key.rbNames.length; i++) {
+ if (childNode.getText().equals(key.rbNames[i])) {
+ childNode.setSelected(fieldValue == key.values[i]);
+ }
+ }
+ }
+ }
+ catch (IllegalArgumentException e) {
+ LOG.error(e);
+ }
+ catch (IllegalAccessException e) {
+ LOG.error(e);
+ }
+ }
+
+ public void apply(CodeStyleSettings settings) {
+ TreeModel treeModel = myOptionsTree.getModel();
+ TreeNode root = (TreeNode)treeModel.getRoot();
+ applyNode(root, settings);
+ }
+
+ private void applyNode(TreeNode node, final CodeStyleSettings settings) {
+ if (node instanceof MyToggleTreeNode) {
+ applyToggleNode((MyToggleTreeNode)node, settings);
+ return;
+ }
+ for (int j = 0; j < node.getChildCount(); j++) {
+ TreeNode child = node.getChildAt(j);
+ applyNode(child, settings);
+ }
+ }
+
+ private void applyToggleNode(MyToggleTreeNode childNode, final CodeStyleSettings settings) {
+ try {
+ if (childNode.getKey() instanceof BooleanOptionKey) {
+ BooleanOptionKey key = (BooleanOptionKey)childNode.getKey();
+ Field field = (Field)myKeyToFieldMap.get(key);
+ field.set(settings, childNode.isSelected() ? Boolean.TRUE : Boolean.FALSE);
+ }
+ else if (childNode.getKey() instanceof IntSelectionOptionKey) {
+ if (!childNode.isSelected()) return;
+ IntSelectionOptionKey key = (IntSelectionOptionKey)childNode.getKey();
+ Field field = (Field)myKeyToFieldMap.get(key);
+ for (int i = 0; i < key.rbNames.length; i++) {
+ if (childNode.getText().equals(key.rbNames[i])) {
+ field.set(settings, new Integer(key.values[i]));
+ break;
+ }
+ }
+ }
+ }
+ catch (IllegalArgumentException e) {
+ LOG.error(e);
+ }
+ catch (IllegalAccessException e) {
+ LOG.error(e);
+ }
+ }
+
+ public boolean isModified(CodeStyleSettings settings) {
+ TreeModel treeModel = myOptionsTree.getModel();
+ TreeNode root = (TreeNode)treeModel.getRoot();
+ if (isModified(root, settings)) {
+ return true;
+ }
+ return false;
+
+ }
+
+ private boolean isModified(TreeNode node, final CodeStyleSettings settings) {
+ if (node instanceof MyToggleTreeNode) {
+ if (isToggleNodeModified((MyToggleTreeNode)node, settings)) {
+ return true;
+ }
+ }
+ for (int j = 0; j < node.getChildCount(); j++) {
+ TreeNode child = node.getChildAt(j);
+ if (isModified(child, settings)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean isToggleNodeModified(MyToggleTreeNode childNode, final CodeStyleSettings settings) {
+ try {
+ if (childNode.getKey() instanceof BooleanOptionKey) {
+ BooleanOptionKey key = (BooleanOptionKey)childNode.getKey();
+ Field field = (Field)myKeyToFieldMap.get(key);
+ return childNode.isSelected() != field.getBoolean(settings);
+ }
+ else if (childNode.getKey() instanceof IntSelectionOptionKey) {
+ if (!childNode.isSelected()) return false;
+ IntSelectionOptionKey key = (IntSelectionOptionKey)childNode.getKey();
+ Field field = (Field)myKeyToFieldMap.get(key);
+ for (int i = 0; i < key.rbNames.length; i++) {
+ if (childNode.getText().equals(key.rbNames[i])) {
+ return field.getInt(settings) != key.values[i];
+ }
+ }
+ }
+ }
+ catch (IllegalArgumentException e) {
+ LOG.error(e);
+ }
+ catch (IllegalAccessException e) {
+ LOG.error(e);
+ }
+ return false;
+ }
+
+ protected void initBooleanField(@NonNls String fieldName, String cbName, String groupName) {
+ try {
+ Class styleSettingsClass = CodeStyleSettings.class;
+ Field field = styleSettingsClass.getField(fieldName);
+ BooleanOptionKey key = new BooleanOptionKey(groupName, cbName);
+ myKeyToFieldMap.put(key, field);
+ myKeys.add(key);
+ }
+ catch (NoSuchFieldException e) {
+ }
+ catch (SecurityException e) {
+ }
+ }
+
+ protected void initRadioGroupField(String fieldName, String groupName, String[] rbNames, int[] values) {
+ try {
+ Class styleSettingsClass = CodeStyleSettings.class;
+ Field field = styleSettingsClass.getField(fieldName);
+ IntSelectionOptionKey key = new IntSelectionOptionKey(groupName, rbNames, values);
+ myKeyToFieldMap.put(key, field);
+ myKeys.add(key);
+ }
+ catch (NoSuchFieldException e) {
+ }
+ catch (SecurityException e) {
+ }
+ }
+
+ protected void prepareForReformat(final PsiFile psiFile) {
+ //psiFile.putUserData(PsiUtil.FILE_LANGUAGE_LEVEL_KEY, LanguageLevel.HIGHEST);
+ }
+
+ protected class MyTreeCellRenderer implements TreeCellRenderer {
+ private final MyLabelPanel myLabel;
+ private final JCheckBox myCheckBox;
+ private final JRadioButton myRadioButton;
+
+ public MyTreeCellRenderer() {
+ myLabel = new MyLabelPanel();
+ myCheckBox = new JCheckBox();
+ myRadioButton = new JRadioButton();
+ myCheckBox.setMargin(new Insets(0, 0, 0, 0));
+ }
+
+ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean isSelected, boolean expanded,
+ boolean leaf, int row, boolean hasFocus) {
+
+ if (value instanceof MyToggleTreeNode) {
+ MyToggleTreeNode treeNode = (MyToggleTreeNode)value;
+ JToggleButton button = treeNode.isCheckbox() ? (JToggleButton)myCheckBox : (JToggleButton)myRadioButton;
+ button.setText(treeNode.getText());
+ button.setSelected(treeNode.isSelected);
+ if (isSelected) {
+ button.setForeground(UIUtil.getTreeSelectionForeground());
+ button.setBackground(UIUtil.getTreeSelectionBackground());
+ }
+ else {
+ button.setForeground(UIUtil.getTreeTextForeground());
+ button.setBackground(UIUtil.getTreeTextBackground());
+ }
+
+ button.setEnabled(tree.isEnabled());
+
+ return button;
+ }
+ else {
+ Font font = tree.getFont();
+ Font boldFont = new Font(font.getName(), Font.BOLD, font.getSize());
+ myLabel.setFont(boldFont);
+ myLabel.setText(value.toString());
+
+ if (isSelected) {
+ myLabel.setForeground(UIUtil.getTreeSelectionForeground());
+ myLabel.setBackground(UIUtil.getTreeSelectionBackground());
+ }
+ else {
+ myLabel.setForeground(UIUtil.getTreeTextForeground());
+ myLabel.setBackground(UIUtil.getTreeTextBackground());
+ }
+
+ myLabel.setEnabled(tree.isEnabled());
+
+ return myLabel;
+ }
+ }
+ }
+
+ private static class MyLabelPanel extends JPanel {
+ private String myText = "";
+ private final boolean hasFocus = false;
+
+ public MyLabelPanel() {
+ }
+
+ public void setText(String text) {
+ myText = text;
+ if (myText == null) {
+ myText = "";
+ }
+ }
+
+ protected void paintComponent(Graphics g) {
+ g.setFont(getMyFont());
+ FontMetrics fontMetrics = getFontMetrics(getMyFont());
+ int h = fontMetrics.getHeight();
+ int w = fontMetrics.charsWidth(myText.toCharArray(), 0, myText.length());
+ g.setColor(getBackground());
+ g.fillRect(0, 1, w + 2, h);
+ if (hasFocus) {
+ g.setColor(UIUtil.getTreeTextBackground());
+ g.drawRect(0, 1, w + 2, h);
+ }
+ g.setColor(getForeground());
+ g.drawString(myText, 2, h - fontMetrics.getDescent() + 1);
+ }
+
+ private Font getMyFont() {
+ Font font = UIUtil.getTreeFont();
+ return new Font(font.getName(), Font.BOLD, font.getSize());
+ }
+
+ public Dimension getPreferredSize() {
+ FontMetrics fontMetrics = getFontMetrics(getMyFont());
+ if (fontMetrics == null) {
+ return new Dimension(0, 0);
+ }
+ int h = fontMetrics.getHeight();
+ int w = fontMetrics.charsWidth(myText.toCharArray(), 0, myText.length());
+ return new Dimension(w + 4, h + 2);
+ }
+ }
+
+ private static class BooleanOptionKey {
+ final String groupName;
+ final String cbName;
+
+ public BooleanOptionKey(String groupName, String cbName) {
+ this.groupName = groupName;
+ this.cbName = cbName;
+ }
+
+ public boolean equals(Object obj) {
+ if (!(obj instanceof BooleanOptionKey)) return false;
+ BooleanOptionKey key = (BooleanOptionKey)obj;
+ return groupName.equals(key.groupName) && cbName.equals(key.cbName);
+ }
+
+ public int hashCode() {
+ return cbName.hashCode();
+ }
+ }
+
+ private static class IntSelectionOptionKey {
+ final String groupName;
+ final String[] rbNames;
+ final int[] values;
+ private MyToggleTreeNode[] myNodes;
+
+ public IntSelectionOptionKey(String groupName, String[] rbNames, int[] values) {
+ this.groupName = groupName;
+ this.rbNames = rbNames;
+ this.values = values;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof IntSelectionOptionKey)) return false;
+
+ final IntSelectionOptionKey intSelectionOptionKey = (IntSelectionOptionKey)o;
+
+ if (!groupName.equals(intSelectionOptionKey.groupName)) return false;
+ if (!Arrays.equals(rbNames, intSelectionOptionKey.rbNames)) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ return groupName.hashCode() + rbNames[0].hashCode() * 29;
+ }
+
+ public void setCreatedNodes(MyToggleTreeNode[] nodes) { myNodes = nodes; }
+
+ public MyToggleTreeNode[] getNodes() { return myNodes; }
+ }
+
+ private static class MyToggleTreeNode extends DefaultMutableTreeNode {
+ private final Object myKey;
+ private final String myText;
+ private boolean isSelected;
+ private final boolean isCheckbox;
+
+ public MyToggleTreeNode(Object key, String text) {
+ myKey = key;
+ myText = text;
+ isCheckbox = true;
+ }
+
+ public Object getKey() { return myKey; }
+
+ public String getText() { return myText; }
+
+ public boolean isCheckbox() { return isCheckbox; }
+
+ public void setSelected(boolean val) { isSelected = val; }
+
+ public boolean isSelected() { return isSelected; }
+
+ public MyToggleTreeNode[] getGroup() {
+ return ((IntSelectionOptionKey)myKey).getNodes();
+ }
+ }
+
+ @NotNull
+ protected FileType getFileType() {
+ return myFileType;
+ }
+
+ public JComponent getInternalPanel() {
+ return myPanel;
+ }
+}
\ No newline at end of file
diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/SpacesSettingsProvider.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/SpacesSettingsProvider.java
new file mode 100644
index 000000000000..ea8aec68698f
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/SpacesSettingsProvider.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2000-2010 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.application.options.codeStyle;
+
+import com.intellij.openapi.application.ApplicationBundle;
+import com.intellij.openapi.options.Configurable;
+import com.intellij.psi.codeStyle.CodeStyleSettings;
+import com.intellij.psi.codeStyle.CodeStyleSettingsProvider;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author yole
+ */
+public class SpacesSettingsProvider extends CodeStyleSettingsProvider {
+ @NotNull
+ public Configurable createSettingsPage(final CodeStyleSettings settings, final CodeStyleSettings originalSettings) {
+ return new CodeStyleSpacesConfigurable(settings, originalSettings);
+ }
+
+ @Override
+ public String getConfigurableDisplayName() {
+ return ApplicationBundle.message("title.spaces");
+ }
+}
\ No newline at end of file
diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark0Action.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark0Action.java
new file mode 100644
index 000000000000..babfb9e89362
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark0Action.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2000-2010 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.
+ */
+
+/*
+ * @author max
+ */
+package com.intellij.ide.bookmarks.actions;
+
+public class ToggleBookmark0Action extends ToggleNumberedBookmarkActionBase {
+ public ToggleBookmark0Action() {
+ super(0);
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark1Action.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark1Action.java
new file mode 100644
index 000000000000..c16ff3e0ee5e
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark1Action.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2000-2010 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.
+ */
+
+/*
+ * @author max
+ */
+package com.intellij.ide.bookmarks.actions;
+
+public class ToggleBookmark1Action extends ToggleNumberedBookmarkActionBase {
+ public ToggleBookmark1Action() {
+ super(1);
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark2Action.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark2Action.java
new file mode 100644
index 000000000000..788055d720b5
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark2Action.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2000-2010 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.
+ */
+
+/*
+ * @author max
+ */
+package com.intellij.ide.bookmarks.actions;
+
+public class ToggleBookmark2Action extends ToggleNumberedBookmarkActionBase {
+ public ToggleBookmark2Action() {
+ super(2);
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark3Action.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark3Action.java
new file mode 100644
index 000000000000..4d10f7a1db09
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark3Action.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2000-2010 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.
+ */
+
+/*
+ * @author max
+ */
+package com.intellij.ide.bookmarks.actions;
+
+public class ToggleBookmark3Action extends ToggleNumberedBookmarkActionBase {
+ public ToggleBookmark3Action() {
+ super(3);
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark4Action.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark4Action.java
new file mode 100644
index 000000000000..f9e59df7142f
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark4Action.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2000-2010 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.
+ */
+
+/*
+ * @author max
+ */
+package com.intellij.ide.bookmarks.actions;
+
+public class ToggleBookmark4Action extends ToggleNumberedBookmarkActionBase {
+ public ToggleBookmark4Action() {
+ super(4);
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark5Action.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark5Action.java
new file mode 100644
index 000000000000..fcc735a019ff
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark5Action.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2000-2010 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.
+ */
+
+/*
+ * @author max
+ */
+package com.intellij.ide.bookmarks.actions;
+
+public class ToggleBookmark5Action extends ToggleNumberedBookmarkActionBase {
+ public ToggleBookmark5Action() {
+ super(5);
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark6Action.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark6Action.java
new file mode 100644
index 000000000000..78320a7069d3
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark6Action.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2000-2010 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.
+ */
+
+/*
+ * @author max
+ */
+package com.intellij.ide.bookmarks.actions;
+
+public class ToggleBookmark6Action extends ToggleNumberedBookmarkActionBase {
+ public ToggleBookmark6Action() {
+ super(6);
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark7Action.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark7Action.java
new file mode 100644
index 000000000000..ec73888f729b
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark7Action.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2000-2010 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.
+ */
+
+/*
+ * @author max
+ */
+package com.intellij.ide.bookmarks.actions;
+
+public class ToggleBookmark7Action extends ToggleNumberedBookmarkActionBase {
+ public ToggleBookmark7Action() {
+ super(7);
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark8Action.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark8Action.java
new file mode 100644
index 000000000000..b756b5c29073
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark8Action.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2000-2010 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.
+ */
+
+/*
+ * @author max
+ */
+package com.intellij.ide.bookmarks.actions;
+
+public class ToggleBookmark8Action extends ToggleNumberedBookmarkActionBase {
+ public ToggleBookmark8Action() {
+ super(8);
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark9Action.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark9Action.java
new file mode 100644
index 000000000000..4742a89eb0f9
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleBookmark9Action.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2000-2010 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.
+ */
+
+/*
+ * @author max
+ */
+package com.intellij.ide.bookmarks.actions;
+
+public class ToggleBookmark9Action extends ToggleNumberedBookmarkActionBase {
+ public ToggleBookmark9Action() {
+ super(9);
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleNumberedBookmarkActionBase.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleNumberedBookmarkActionBase.java
new file mode 100644
index 000000000000..81c4e0c7efee
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/ToggleNumberedBookmarkActionBase.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2000-2010 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.
+ */
+
+/*
+ * @author max
+ */
+package com.intellij.ide.bookmarks.actions;
+
+import com.intellij.ide.bookmarks.Bookmark;
+import com.intellij.ide.bookmarks.BookmarkManager;
+import com.intellij.openapi.actionSystem.AnAction;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
+import com.intellij.openapi.project.DumbAware;
+import com.intellij.openapi.project.Project;
+
+public abstract class ToggleNumberedBookmarkActionBase extends AnAction implements DumbAware {
+ private int myNumber;
+
+ public ToggleNumberedBookmarkActionBase(int n) {
+ myNumber = n;
+ }
+
+ @Override
+ public void update(AnActionEvent e) {
+ DataContext dataContext = e.getDataContext();
+ final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
+ e.getPresentation().setEnabled(project != null);
+ }
+
+ @Override
+ public void actionPerformed(AnActionEvent e) {
+ DataContext dataContext = e.getDataContext();
+ final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
+
+ final BookmarkManager manager = BookmarkManager.getInstance(project);
+ BookmarksAction.BookmarkInContextInfo info = new BookmarksAction.BookmarkInContextInfo(dataContext, project).invoke();
+ final Bookmark oldBookmark = info.getBookmarkAtPlace();
+
+ if (oldBookmark != null) {
+ manager.removeBookmark(oldBookmark);
+ }
+
+ if (oldBookmark == null || oldBookmark.getMnemonic() != '0' + myNumber) {
+ final Bookmark bookmark = BookmarkManager.getInstance(project).addTextBookmark(info.getFile(), info.getLine(), "");
+ bookmark.setMnemonic((char)('0' + myNumber));
+ }
+ }
+}
diff --git a/platform/platform-resources/src/idea/Keymap_Default.xml b/platform/platform-resources/src/idea/Keymap_Default.xml
index ac3c05f9a6a6..1c6f648378fe 100644
--- a/platform/platform-resources/src/idea/Keymap_Default.xml
+++ b/platform/platform-resources/src/idea/Keymap_Default.xml
@@ -146,6 +146,7 @@
+
@@ -177,6 +178,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/platform/platform-resources/src/idea/Keymap_KDE.xml b/platform/platform-resources/src/idea/Keymap_KDE.xml
index e0e9e5eb9d8a..377d5c094ff6 100644
--- a/platform/platform-resources/src/idea/Keymap_KDE.xml
+++ b/platform/platform-resources/src/idea/Keymap_KDE.xml
@@ -41,6 +41,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/platform/platform-resources/src/idea/Keymap_Mac.xml b/platform/platform-resources/src/idea/Keymap_Mac.xml
index 1ce181be875d..6294e2ae81bf 100644
--- a/platform/platform-resources/src/idea/Keymap_Mac.xml
+++ b/platform/platform-resources/src/idea/Keymap_Mac.xml
@@ -126,6 +126,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/platform/platform-resources/src/idea/Keymap_MacClassic.xml b/platform/platform-resources/src/idea/Keymap_MacClassic.xml
index 1a7bd93d5cf3..fec2bd3b28f0 100644
--- a/platform/platform-resources/src/idea/Keymap_MacClassic.xml
+++ b/platform/platform-resources/src/idea/Keymap_MacClassic.xml
@@ -126,6 +126,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/platform/platform-resources/src/idea/Keymap_Netbeans.xml b/platform/platform-resources/src/idea/Keymap_Netbeans.xml
index bb20745e0528..de3d1dab3401 100644
--- a/platform/platform-resources/src/idea/Keymap_Netbeans.xml
+++ b/platform/platform-resources/src/idea/Keymap_Netbeans.xml
@@ -159,6 +159,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/platform/platform-resources/src/idea/LangActions.xml b/platform/platform-resources/src/idea/LangActions.xml
index 48f24dded32b..8bc4912eb516 100644
--- a/platform/platform-resources/src/idea/LangActions.xml
+++ b/platform/platform-resources/src/idea/LangActions.xml
@@ -366,6 +366,17 @@
+
+
+
+
+
+
+
+
+
+
+