editor: folding repainiting

This commit is contained in:
Anton Makeev
2010-07-12 11:16:59 +04:00
parent 957af9e3ca
commit dc32ec5c35
2 changed files with 26 additions and 16 deletions
@@ -23,14 +23,17 @@ import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable;
import com.intellij.openapi.editor.impl.FoldingModelImpl;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.options.CompositeConfigurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import org.jetbrains.annotations.Nls;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -57,8 +60,9 @@ public class CodeFoldingConfigurable extends CompositeConfigurable<CodeFoldingOp
public JComponent createComponent() {
for (CodeFoldingOptionsProvider provider : getConfigurables()) {
myFoldingPanel.add(provider.createComponent(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0, 0, GridBagConstraints.NORTHWEST,
GridBagConstraints.NONE, new Insets(0,0,0,0), 0,0));
myFoldingPanel
.add(provider.createComponent(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0, 0, GridBagConstraints.NORTHWEST,
GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
}
return myRootPanel;
}
@@ -72,19 +76,25 @@ public class CodeFoldingConfigurable extends CompositeConfigurable<CodeFoldingOp
EditorSettingsExternalizable.getInstance().setFoldingOutlineShown(myCbFolding.isSelected());
super.apply();
final List<Pair<Editor, Project>> toUpdate = new ArrayList<Pair<Editor, Project>>();
for (final Editor editor : EditorFactory.getInstance().getAllEditors()) {
final Project project = editor.getProject();
if (project != null && !project.isDefault()) {
final CodeFoldingManager foldingManager = CodeFoldingManager.getInstance(project);
if (foldingManager != null) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
foldingManager.forceDefaultState(editor);
}
}, ModalityState.NON_MODAL);
}
toUpdate.add(Pair.create(editor, project));
}
}
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
for (Pair<Editor, Project> each : toUpdate) {
final CodeFoldingManager foldingManager = CodeFoldingManager.getInstance(each.second);
if (foldingManager != null) {
foldingManager.forceDefaultState(each.first);
EditorOptionsPanel.reinitAllEditors();
}
}
}
}, ModalityState.NON_MODAL);
}
public void reset() {
@@ -118,6 +118,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
public void reinitSettings() {
myBackgroundColor = null;
revalidateMarkup();
repaint();
}
@@ -212,7 +213,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
.line;
endLineNumber = Math.min(endLineNumber, lastLine + 1);
if (startLineNumber >= endLineNumber) {
return;
break;
}
for (int j = startLineNumber; j < endLineNumber; j++) {
@@ -234,7 +235,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
x += myTextAnnotationGutterSizes.get(i);
}
UIUtil.drawVDottedLine((Graphics2D)g, x - 1, clip.y, clip.y + clip.height, getBackground(), getOutlineColor(false));
UIUtil.drawVDottedLine((Graphics2D)g, getAnnotationsAreaOffset() + w - 1, clip.y, clip.y + clip.height, null, getOutlineColor(false));
}
private void paintFoldingTree(Graphics g, Rectangle clip) {
@@ -242,8 +243,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
paintFoldingTree((Graphics2D)g);
}
else {
UIUtil.drawVDottedLine((Graphics2D)g, clip.x + clip.width -1, clip.y, clip.y + clip.height,
myEditor.getBackgroundColor(), getOutlineColor(false));
UIUtil.drawVDottedLine((Graphics2D)g, clip.x + clip.width -1, clip.y, clip.y + clip.height, null, getOutlineColor(false));
}
}
@@ -275,7 +275,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
if (isLineNumbersShown()) {
paintBackground(g, clip, getLineNumberAreaOffset(), getLineNumberAreaWidth());
int x = getLineNumberAreaOffset() + getLineNumberAreaWidth() - 2;
UIUtil.drawVDottedLine((Graphics2D)g, x, clip.y, clip.y + clip.height, getBackground(), getOutlineColor(false));
UIUtil.drawVDottedLine((Graphics2D)g, x, clip.y, clip.y + clip.height, null, getOutlineColor(false));
paintLineNumbers(g);
}
}
@@ -698,7 +698,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
if (!isFoldingOutlineShown()) return;
Rectangle clip = g.getClipBounds();
UIUtil.drawVDottedLine(g, getWhitespaceSeparatorOffset(), clip.y, clip.y + clip.height, myEditor.getBackgroundColor(), getOutlineColor(false));
UIUtil.drawVDottedLine(g, getWhitespaceSeparatorOffset(), clip.y, clip.y + clip.height, null, getOutlineColor(false));
int anchorX = getFoldingAreaOffset();
int width = getFoldingAnchorWidth();