diff --git a/build/scripts/libLicenses.gant b/build/scripts/libLicenses.gant index 60851759bd32..17f419dece1d 100644 --- a/build/scripts/libLicenses.gant +++ b/build/scripts/libLicenses.gant @@ -191,7 +191,7 @@ libraryLicense(name: "Jaxen", version: "", license: "modified Apache", url: "htt libraryLicense(name: "JavaHelp", version: "2.0_02", license: "included as license/javahelp_license.html in IntelliJ IDEA distribution", url: "http://java.sun.com/products/javahelp/") libraryLicense(name: "Java-WebSocket", libraryName: "java_websocket.jar", version: "1.4.0 Trunk", license: "MIT", url: "https://github.com/TooTallNate/Java-WebSocket", licenseUrl:"https://github.com/TooTallNate/Java-WebSocket/blob/master/LICENSE") libraryLicense(name: "Apache XML Graphics Commons", libraryName: "xmlgraphics-commons-1.3.1.jar", version: "1.3.1", license: "Apache 2.0", url: "http://xmlgraphics.apache.org/commons/", licenseUrl:"http://www.apache.org/licenses/LICENSE-2.0") -libraryLicense(name: "SnuggleTeX", libraryName: "snuggletex-core-1.3-SNAPSHOT.jar", version: "1.3 (with patches by JetBrains)", license: "BSD", url: "http://snuggletex.sourceforge.net/", licenseUrl:"http://snuggletex.sourceforge.net/maven/license.html") +libraryLicense(name: "SnuggleTeX", version: "1.3 (with patches by JetBrains)", license: "BSD", url: "http://snuggletex.sourceforge.net/", licenseUrl:"http://snuggletex.sourceforge.net/maven/license.html") libraryLicense(name: "JEuclid", libraryName: "jeuclid-core-3.1.9.jar", version: "3.1.9", license: "Apache 2.0", url: "http://jeuclid.sourceforge.net", licenseUrl:"http://sourceforge.net/p/jeuclid/code/ci/default/tree/LICENSE.txt") libraryLicense(name: "JCIP Annotations", libraryName: "jcip", license: "Creative Commons Attribution License", url: "http://www.jcip.net", licenseUrl: "http://creativecommons.org/licenses/by/2.5") libraryLicense(name: "JDOM", version: "1.1 (with patches by JetBrains)", license: "modified Apache", url: "http://www.jdom.org/", licenseUrl: "http://www.jdom.org/docs/faq.html#a0030") diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java index 8ec833e8258b..d7a8b0c2661e 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java @@ -187,23 +187,11 @@ public class ReformatCodeAction extends AnAction implements DumbAware { } if (rearrangeEntries && file != null && editor != null) { - final ArrangementEngine engine = ServiceManager.getService(project, ArrangementEngine.class); - try { - final PsiFile finalFile = file; - SelectionModel selectionModel = editor.getSelectionModel(); - final TextRange rangeToUse = selectionModel.hasSelection() - ? TextRange.create(selectionModel.getSelectionStart(), selectionModel.getSelectionEnd()) - : TextRange.create(0, editor.getDocument().getTextLength()); - CommandProcessor.getInstance().executeCommand(project, new Runnable() { - @Override - public void run() { - engine.arrange(editor, finalFile, Collections.singleton(rangeToUse)); - } - }, getTemplatePresentation().getText(), null); - } - finally { - PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); - } + SelectionModel selectionModel = editor.getSelectionModel(); + final TextRange rangeToUse = selectionModel.hasSelection() + ? TextRange.create(selectionModel.getSelectionStart(), selectionModel.getSelectionEnd()) + : TextRange.create(0, editor.getDocument().getTextLength()); + new RearrangeCodeProcessor(project, file, Collections.singleton(rangeToUse)).run(); } } diff --git a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/JBRunnerTabs.java b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/JBRunnerTabs.java index d680e8a7e173..50582bdf9f90 100644 --- a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/JBRunnerTabs.java +++ b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/JBRunnerTabs.java @@ -24,7 +24,6 @@ import com.intellij.ui.ColorUtil; import com.intellij.ui.Gray; import com.intellij.ui.awt.RelativePoint; import com.intellij.ui.tabs.TabInfo; -import com.intellij.ui.tabs.TabsUtil; import com.intellij.ui.tabs.UiDecorator; import com.intellij.ui.tabs.impl.JBTabsImpl; import com.intellij.ui.tabs.impl.TabLabel; @@ -75,7 +74,7 @@ public class int _y = effectiveBounds.y + insets.top + 3; int _width = effectiveBounds.width - insets.left - insets.right; int _height = effectiveBounds.height - insets.top - insets.bottom - 3; - _height -= TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT; + _height -= getActiveTabUnderlineHeight(); if (dark) { g2d.setPaint(UIUtil.getGradientPaint(_x, _y, ColorUtil.shift(UIUtil.getListBackground(), 1.3), _x, _y + effectiveBounds.height, UIUtil.getPanelBackground())); g2d.fillRect(_x, _y, _width, _height); @@ -122,7 +121,7 @@ public class Rectangle rectangle; int y = r2.y + insets.top; int height = maxLength - insets.top - insets.bottom; - height -= TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT; + height -= getActiveTabUnderlineHeight(); rectangle = new Rectangle(maxOffset, y, r2.width - maxOffset - insets.left - insets.right, height); @@ -194,7 +193,7 @@ public class shape.insets = shape.path.transformInsets(getLayoutInsets()); shape.labelPath = shape.path.createTransform(r); - shape.labelBottomY = shape.labelPath.getMaxY() - shape.labelPath.deltaY(TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT - 1); + shape.labelBottomY = shape.labelPath.getMaxY() - shape.labelPath.deltaY(getActiveTabUnderlineHeight() - 1); shape.labelTopY = shape.labelPath.getY() + shape.labelPath.deltaY(1); shape.labelLeftX = shape.labelPath.getX(); shape.labelRightX = shape.labelPath.getMaxX() - shape.labelPath.deltaX(1); @@ -210,8 +209,8 @@ public class int lastX = shape.path.getWidth() - shape.path.deltaX(shape.insets.right); shape.path.lineTo(lastX, shape.labelBottomY); - shape.path.lineTo(lastX, shape.labelBottomY + shape.labelPath.deltaY(TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT - 1)); - shape.path.lineTo(leftX, shape.labelBottomY + shape.labelPath.deltaY(TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT - 1)); + shape.path.lineTo(lastX, shape.labelBottomY + shape.labelPath.deltaY(getActiveTabUnderlineHeight() - 1)); + shape.path.lineTo(leftX, shape.labelBottomY + shape.labelPath.deltaY(getActiveTabUnderlineHeight() - 1)); shape.path.closePath(); shape.fillPath = shape.path.copy(); @@ -298,7 +297,7 @@ public class @Override public Dimension getPreferredSize() { Dimension result = super.getPreferredSize(); - result.height += TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT; + result.height += myTabs.getActiveTabUnderlineHeight(); return result; } } diff --git a/platform/lang-impl/src/com/intellij/injected/editor/EditorWindowImpl.java b/platform/lang-impl/src/com/intellij/injected/editor/EditorWindowImpl.java index 077c41e477ff..10bf53bce6bb 100644 --- a/platform/lang-impl/src/com/intellij/injected/editor/EditorWindowImpl.java +++ b/platform/lang-impl/src/com/intellij/injected/editor/EditorWindowImpl.java @@ -47,6 +47,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; import com.intellij.util.containers.WeakList; +import com.intellij.util.ui.ButtonlessScrollBarUI; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -825,7 +826,7 @@ public class EditorWindowImpl extends UserDataHolderBase implements EditorWindow } @Override - public void registerScrollBarRepaintCallback(@Nullable RepaintCallback callback) { + public void registerScrollBarRepaintCallback(@Nullable ButtonlessScrollBarUI.ScrollbarRepaintCallback callback) { myDelegate.registerScrollBarRepaintCallback(callback); } diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBEditorTabs.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBEditorTabs.java index 43f06bff2850..5b10dbfe2b43 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBEditorTabs.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBEditorTabs.java @@ -26,7 +26,6 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.ui.tabs.JBTabsPosition; import com.intellij.ui.tabs.TabInfo; -import com.intellij.ui.tabs.TabsUtil; import com.intellij.ui.tabs.impl.singleRow.ScrollableSingleRowLayout; import com.intellij.ui.tabs.impl.singleRow.SingleRowLayout; import com.intellij.ui.tabs.impl.table.TableLayout; @@ -98,9 +97,11 @@ public class JBEditorTabs extends JBTabsImpl { @Override public boolean hasUnderline() { - return true; + return isSingleRow(); } + + protected void doPaintInactive(Graphics2D g2d, boolean leftGhostExists, TabLabel label, @@ -116,14 +117,14 @@ public class JBEditorTabs extends JBTabsImpl { if ((!isSingleRow() /* for multiline */) || (isSingleRow() && isHorizontalTabs())) { if (isSingleRow() && getPosition() == JBTabsPosition.bottom) { - _y += TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT; + _y += getActiveTabUnderlineHeight(); } else { if (isSingleRow()) { - _height -= TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT; + _height -= getActiveTabUnderlineHeight(); } else { TabInfo info = label.getInfo(); if (((TableLayout)getEffectiveLayout()).isLastRow(info)) { - _height -= TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT; + _height -= getActiveTabUnderlineHeight(); } } } @@ -131,7 +132,19 @@ public class JBEditorTabs extends JBTabsImpl { final boolean vertical = getTabsPosition() == JBTabsPosition.left || getTabsPosition() == JBTabsPosition.right; final Color tabColor = label.getInfo().getTabColor(); + final Composite oldComposite = g2d.getComposite(); + //if (label != getSelectedLabel()) { + // g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.9f)); + //} getPainter().doPaintInactive(g2d, effectiveBounds, _x, _y, _width, _height, tabColor, row, column, vertical); + //g2d.setComposite(oldComposite); + } + + + + @Override + public int getActiveTabUnderlineHeight() { + return hasUnderline() ? super.getActiveTabUnderlineHeight() : 1; } JBEditorTabsPainter getPainter() { @@ -186,9 +199,9 @@ public class JBEditorTabs extends JBTabsImpl { int y = r2.y + insets.top; int height = maxLength - insets.top - insets.bottom; if (getTabsPosition() == JBTabsPosition.bottom) { - y = r2.height - height - insets.top + TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT; + y = r2.height - height - insets.top + getActiveTabUnderlineHeight(); } else { - height -= TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT; + height -= getActiveTabUnderlineHeight(); } rectangle = new Rectangle(maxOffset, y, r2.width - maxOffset - insets.left - insets.right, height); @@ -229,7 +242,7 @@ public class JBEditorTabs extends JBTabsImpl { shape.insets = shape.path.transformInsets(getLayoutInsets()); shape.labelPath = shape.path.createTransform(getSelectedLabel().getBounds()); - shape.labelBottomY = shape.labelPath.getMaxY() - shape.labelPath.deltaY(TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT - 1); + shape.labelBottomY = shape.labelPath.getMaxY() - shape.labelPath.deltaY(getActiveTabUnderlineHeight() - 1); shape.labelTopY = shape.labelPath.getY() + (getPosition() == JBTabsPosition.top || getPosition() == JBTabsPosition.bottom ? shape.labelPath.deltaY(1) : 0) ; shape.labelLeftX = shape.labelPath.getX() + (getPosition() == JBTabsPosition.top || getPosition() == JBTabsPosition.bottom ? 0 : shape.labelPath.deltaX( @@ -247,8 +260,8 @@ public class JBEditorTabs extends JBTabsImpl { int lastX = shape.path.getWidth() - shape.path.deltaX(shape.insets.right); shape.path.lineTo(lastX, shape.labelBottomY); - shape.path.lineTo(lastX, shape.labelBottomY + shape.labelPath.deltaY(TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT - 1)); - shape.path.lineTo(leftX, shape.labelBottomY + shape.labelPath.deltaY(TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT - 1)); + shape.path.lineTo(lastX, shape.labelBottomY + shape.labelPath.deltaY(getActiveTabUnderlineHeight() - 1)); + shape.path.lineTo(leftX, shape.labelBottomY + shape.labelPath.deltaY(getActiveTabUnderlineHeight() - 1)); shape.path.closePath(); shape.fillPath = shape.path.copy(); diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java index 4c6ecada830a..97c158e08d9f 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java @@ -345,6 +345,10 @@ public class JBTabsImpl extends JComponent return this; } + public int getActiveTabUnderlineHeight() { + return TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT; + } + public boolean isEditorTabs() { return false; } diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLabel.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLabel.java index a360c4e9294f..8a0aa2b39473 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLabel.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLabel.java @@ -53,7 +53,7 @@ public class TabLabel extends JPanel { private boolean myCentered; private final Wrapper myLabelPlaceholder = new Wrapper(false); - private final JBTabsImpl myTabs; + protected final JBTabsImpl myTabs; private BufferedImage myInactiveStateImage; private Rectangle myLastPaintedInactiveImageBounds; @@ -241,7 +241,12 @@ public class TabLabel extends JPanel { } }); + final Composite oldComposite = ((Graphics2D)g).getComposite(); + if (myTabs instanceof JBEditorTabs && !myTabs.isSingleRow() && myTabs.getSelectedInfo() != myInfo) { + ((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f)); + } super.paint(g); + ((Graphics2D)g).setComposite(oldComposite); doTranslate(new PairConsumer() { @Override @@ -253,7 +258,7 @@ public class TabLabel extends JPanel { protected int getNonSelectedOffset() { if (myTabs.isEditorTabs() && (myTabs.isSingleRow() || ((TableLayout)myTabs.getEffectiveLayout()).isLastRow(getInfo()))) { - return -TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT / 2 + 1; + return -myTabs.getActiveTabUnderlineHeight() / 2 + 1; } return 1; } @@ -275,7 +280,7 @@ public class TabLabel extends JPanel { switch (pos) { case top: case bottom: - if (myTabs.hasUnderline()) size.height += TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT - 1; + if (myTabs.hasUnderline()) size.height += myTabs.getActiveTabUnderlineHeight() - 1; break; case left: case right: diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/SingleRowLayout.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/SingleRowLayout.java index 6bd2e1aa52bf..ca8bb535f046 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/SingleRowLayout.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/SingleRowLayout.java @@ -18,7 +18,6 @@ package com.intellij.ui.tabs.impl.singleRow; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.tabs.JBTabsPosition; import com.intellij.ui.tabs.TabInfo; -import com.intellij.ui.tabs.TabsUtil; import com.intellij.ui.tabs.impl.*; import org.jetbrains.annotations.Nullable; @@ -50,8 +49,8 @@ public class SingleRowLayout extends TabLayout { protected int getIconY(Rectangle iconRec) { final int shift; switch (myTabs.getTabsPosition()) { - case bottom: shift = TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT; break; - case top: shift = -(TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT / 2); break; + case bottom: shift = myTabs.getActiveTabUnderlineHeight(); break; + case top: shift = -(myTabs.getActiveTabUnderlineHeight() / 2); break; default: shift = 0; } return super.getIconY(iconRec) + shift; diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/table/TableLayout.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/table/TableLayout.java index 9b313783dea7..af45cf9b1b0d 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/table/TableLayout.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/table/TableLayout.java @@ -16,7 +16,6 @@ package com.intellij.ui.tabs.impl.table; import com.intellij.ui.tabs.TabInfo; -import com.intellij.ui.tabs.TabsUtil; import com.intellij.ui.tabs.impl.JBTabsImpl; import com.intellij.ui.tabs.impl.LayoutPassInfo; import com.intellij.ui.tabs.impl.TabLabel; @@ -103,10 +102,10 @@ public class TableLayout extends TabLayout { toMove.add(data.table.get(i)); } - for (TableRow eachMove : toMove) { - data.table.remove(eachMove); - data.table.add(0, eachMove); - } + //for (TableRow eachMove : toMove) { + // data.table.remove(eachMove); + // data.table.add(0, eachMove); + //} return data; @@ -131,7 +130,7 @@ public class TableLayout extends TabLayout { int eachY = insets.top; int eachX; int row = 0; - final int tabUnderlineFix = myTabs.isEditorTabs() ? TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT : 0; + final int tabUnderlineFix = myTabs.isEditorTabs() ? myTabs.getActiveTabUnderlineHeight() : 0; for (TableRow eachRow : data.table) { eachX = insets.left; diff --git a/platform/platform-api/src/com/intellij/util/ui/ButtonlessScrollBarUI.java b/platform/platform-api/src/com/intellij/util/ui/ButtonlessScrollBarUI.java index 9cd99e474c65..a816efde21c5 100644 --- a/platform/platform-api/src/com/intellij/util/ui/ButtonlessScrollBarUI.java +++ b/platform/platform-api/src/com/intellij/util/ui/ButtonlessScrollBarUI.java @@ -91,7 +91,8 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI { private Animator myMacScrollbarFadeAnimator; private double myMacScrollbarFadeLevel = 0; private boolean myMacScrollbarHidden; - + + private ScrollbarRepaintCallback myRepaintCallback; protected ButtonlessScrollBarUI() { myAdjustmentListener = new AdjustmentListener() { @@ -264,6 +265,43 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI { } } + /** + * This is overridden only to increase the invalid area. + * This ensures that whole track will be repainted in case of installed callback + */ + @Override + protected void setThumbBounds(int x, int y, int width, int height) { + if (myRepaintCallback == null) { + super.setThumbBounds(x, y, width, height); + } + else { + /* If the thumbs bounds haven't changed, we're done. + */ + if ((thumbRect.x == x) && + (thumbRect.y == y) && + (thumbRect.width == width) && + (thumbRect.height == height)) { + return; + } + + /* Update thumbRect, and repaint the union of x,y,w,h and + * the old thumbRect. + */ + int minX = Math.min(x, trackRect.x); + int minY = Math.min(y, trackRect.y); + int maxX = Math.max(x + width, trackRect.x + trackRect.width); + int maxY = Math.max(y + height, trackRect.y + trackRect.height); + + thumbRect.setBounds(x, y, width, height); + scrollbar.repaint(minX, minY, maxX - minX, maxY - minY); + + // Once there is API to determine the mouse location this will need + // to be changed. + setThumbRollover(false); + } + } + + @Override protected ModelListener createModelListener() { return new ModelListener() { @@ -615,6 +653,10 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI { else { g.drawLine(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y); } + + if (myRepaintCallback != null) { + myRepaintCallback.call(g); + } } @Override @@ -774,6 +816,10 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI { return myMacScrollbarHidden && Registry.is("editor.distraction.free.mode"); } + public void registerRepaintCallback(ScrollbarRepaintCallback callback) { + myRepaintCallback = callback; + } + private static class EmptyButton extends JButton { private EmptyButton() { setFocusable(false); @@ -795,4 +841,8 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI { return getMaximumSize(); } } + + public interface ScrollbarRepaintCallback { + void call(Graphics g); + } } diff --git a/platform/platform-api/src/com/intellij/util/ui/FormBuilder.java b/platform/platform-api/src/com/intellij/util/ui/FormBuilder.java index 2c6bff621b55..a8821c686fdf 100644 --- a/platform/platform-api/src/com/intellij/util/ui/FormBuilder.java +++ b/platform/platform-api/src/com/intellij/util/ui/FormBuilder.java @@ -41,6 +41,7 @@ public class FormBuilder { private int myVerticalGap; private int myHorizontalGap; + private int myFormLeftIndent; public FormBuilder() { myPanel = new JPanel(new GridBagLayout()); @@ -49,6 +50,7 @@ public class FormBuilder { myAlignLabelOnRight = false; myVerticalGap = DEFAULT_VGAP; myHorizontalGap = DEFAULT_HGAP; + myFormLeftIndent = 0; } public static FormBuilder createFormBuilder() { @@ -143,7 +145,7 @@ public class FormBuilder { c.weighty = 0; c.fill = NONE; c.anchor = getLabelAnchor(component, false); - c.insets = new Insets(topInset, myIndent, DEFAULT_VGAP, 0); + c.insets = new Insets(topInset, myIndent + myFormLeftIndent, DEFAULT_VGAP, 0); if (label != null) myPanel.add(label, c); @@ -153,7 +155,7 @@ public class FormBuilder { c.weighty = getWeightY(component); c.fill = getFill(component); c.anchor = WEST; - c.insets = new Insets(label == null ? topInset : 0, myIndent, 0, 0); + c.insets = new Insets(label == null ? topInset : 0, myIndent + myFormLeftIndent, 0, 0); myPanel.add(component, c); @@ -167,7 +169,7 @@ public class FormBuilder { c.weighty = 0; c.fill = NONE; c.anchor = getLabelAnchor(component, true); - c.insets = new Insets(topInset, myIndent, 0, myHorizontalGap); + c.insets = new Insets(topInset, myIndent + myFormLeftIndent, 0, myHorizontalGap); myPanel.add(label, c); @@ -176,7 +178,7 @@ public class FormBuilder { c.weighty = getWeightY(component); c.fill = getFill(component); c.anchor = WEST; - c.insets = new Insets(topInset, 0, 0, 0); + c.insets = new Insets(topInset, myIndent, 0, 0); myPanel.add(component, c); @@ -237,8 +239,17 @@ public class FormBuilder { return this; } + /** + * @deprecated use {@code setHorizontalGap} or {@code setFormLeftIndent}, to be removed in IDEA 16 + */ + @Deprecated public FormBuilder setIndent(int indent) { myIndent = indent; return this; } + + public FormBuilder setFormLeftIndent(int formLeftIndent) { + myFormLeftIndent = formLeftIndent; + return this; + } } diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/ui/EditorPlace.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/ui/EditorPlace.java index 7e24e92c5cf1..52d46d0df04b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/ui/EditorPlace.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/ui/EditorPlace.java @@ -32,15 +32,14 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import javax.swing.plaf.ScrollBarUI; import java.awt.*; -import java.util.*; +import java.util.ArrayList; import java.util.List; /** * The container for an {@link Editor}, which is added then to {@link com.intellij.openapi.diff.impl.util.ThreePanels}. */ -public class EditorPlace extends JComponent implements Disposable, EditorEx.RepaintCallback { +public class EditorPlace extends JComponent implements Disposable, ButtonlessScrollBarUI.ScrollbarRepaintCallback { private static final Logger LOG = Logger.getInstance(EditorPlace.class); @NotNull private final MergePanel2.DiffEditorState myState; @@ -58,121 +57,57 @@ public class EditorPlace extends JComponent implements Disposable, EditorEx.Repa } @Override - public void paint(Graphics g) { - super.paint(g); + public void call(Graphics g) { paintThis(g); } - public void call(Graphics g) { - repaintScrollbar(); - } - - private void repaintScrollbar() { - if (myEditor == null || myColumn != MergePanelColumn.BASE) { - return; // we draw above the scrollbar only in the central column - } - Component editorComponent = myEditor.getComponent(); - JScrollBar scrollBar = myEditor.getScrollPane().getVerticalScrollBar(); - repaint(editorComponent.getWidth() - scrollBar.getWidth(), 0, scrollBar.getWidth(), scrollBar.getHeight()); - } - private void paintThis(Graphics g) { - if (myEditor != null) { - ArrayList polygons = DividerPolygon.createVisiblePolygons(myMergePanel.getSecondEditingSide(), FragmentSide.SIDE1, - DiffDivider.MERGE_DIVIDER_POLYGONS_OFFSET); - for (DividerPolygon polygon : polygons) { - int startY = polygon.getTopLeftY(); - int endY = polygon.getBottomLeftY(); - int height = endY - startY; + if (myEditor == null) return; + // painting only above the central scrollbar, because painting on edge scrollbars is not needed, and there are error stripes + if (myColumn != MergePanelColumn.BASE) return; - if (height == 0) { // draw at least a one-pixel line (e.g. for insertion or deletion), as it is done in highlighters - height = 1; - } + int offset = DiffDivider.MERGE_SCROLL_DIVIDER_POLYGONS_OFFSET; + ArrayList polygons = + DividerPolygon.createVisiblePolygons(myMergePanel.getSecondEditingSide(true), FragmentSide.SIDE1, offset); + for (DividerPolygon polygon : polygons) { + int startY = polygon.getTopLeftY(); + int endY = polygon.getBottomLeftY(); + int height = endY - startY; - drawPolygonAboveScrollBar((Graphics2D)g, startY, height, polygon.getColor(), polygon.isApplied()); + if (height == 0) { // draw at least a one-pixel line (e.g. for insertion or deletion), as it is done in highlighters + height = 1; } + + drawPolygon((Graphics2D)g, startY, height, polygon.getColor(), polygon.isApplied()); } } - private void drawPolygonAboveScrollBar(@NotNull Graphics2D g, int startY, int height, @NotNull Color color, boolean applied) { - // painting only above the central scrollbar, because painting on edge scrollbars is not needed, and there are error stripes - if (myColumn != MergePanelColumn.BASE) { - return; - } - - g.setColor(color); - JScrollBar scrollBar = myEditor.getScrollPane().getVerticalScrollBar(); - int startX = scrollBar.getX(); - int endX = startX + scrollBar.getWidth() - 1; - - Rectangle thumb = calcThumbBounds(scrollBar); + private void drawPolygon(@NotNull Graphics2D g, int startY, int height, @NotNull Color color, boolean applied) { + int scrollbarWidth = myEditor.getScrollPane().getVerticalScrollBar().getWidth(); + int startX = 0; + int endX = startX + scrollbarWidth - 1; int endY = startY + height; + + g.setColor(color); if (!applied) { if (height > 2) { - fillRectAboveScrollBar(g, startX, startY, scrollBar.getWidth(), height, thumb); + g.fillRect(startX, startY, scrollbarWidth, height); Color framingColor = DiffUtil.getFramingColor(color); - if (outsideBounds(startY, thumb)) { - UIUtil.drawLine(g, startX, startY, endX, startY, null, framingColor); - } - if (outsideBounds(endY, thumb)) { - UIUtil.drawLine(g, startX, endY, endX, endY, null, framingColor); - } + UIUtil.drawLine(g, startX, startY, endX, startY, null, framingColor); + UIUtil.drawLine(g, startX, endY, endX, endY, null, framingColor); } else { - if (outsideBounds(startY, thumb)) { - DiffUtil.drawDoubleShadowedLine(g, startX, endX, startY, color); - } + DiffUtil.drawDoubleShadowedLine(g, startX, endX, startY, color); } } else { - if (outsideBounds(startY, thumb)) { - UIUtil.drawBoldDottedLine(g, startX, endX, startY, null, color, false); - } - if (outsideBounds(endY, thumb)) { - UIUtil.drawBoldDottedLine(g, startX, endX, endY, null, color, false); - } + UIUtil.drawBoldDottedLine(g, startX, endX, startY, null, color, false); + UIUtil.drawBoldDottedLine(g, startX, endX, endY, null, color, false); } } - private static void fillRectAboveScrollBar(Graphics2D g, int startX, int startY, int width, int height, Rectangle thumb) { - int endY = startY + height; - int thumbEndY = thumb == null ? 0 : thumb.y + thumb.height; // it's for further readability (could have a 2-level ifs for the variable) - if (thumb == null) { - g.fillRect(startX, startY, width, height); - } - else if (outsideBounds(startY, thumb) && !outsideBounds(endY, thumb)) { - g.fillRect(startX, startY, width, thumb.y - startY); - } - else if (!outsideBounds(startY, thumb) && outsideBounds(endY, thumb)) { - g.fillRect(startX, thumbEndY, width, endY - thumbEndY); - } - else if (startY < thumb.y && endY > thumbEndY) { // surrounding the thumb - g.fillRect(startX, startY, width, thumb.y - startY); - g.fillRect(startX, thumbEndY, width, endY - thumbEndY); - } - else if (outsideBounds(startY, thumb) && outsideBounds(endY, thumb)) { // outside without intersection - g.fillRect(startX, startY, width, height); - } - } - - private static boolean outsideBounds(int y, @Nullable Rectangle rectangle) { - if (rectangle == null) { - return true; - } - return y < rectangle.y || y > rectangle.y + rectangle.height; - } - - @Nullable - private static Rectangle calcThumbBounds(JScrollBar scrollBar) { - ScrollBarUI scrollBarUI = scrollBar.getUI(); - if (scrollBarUI instanceof ButtonlessScrollBarUI) { - return ((ButtonlessScrollBarUI)scrollBarUI).getThumbBounds(); - } - return null; - } - public void addNotify() { if (myEditor != null) { super.addNotify(); @@ -249,6 +184,7 @@ public class EditorPlace extends JComponent implements Disposable, EditorEx.Repa public interface EditorListener { void onEditorCreated(EditorPlace place); + void onEditorReleased(Editor releasedEditor); } diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/util/DiffDivider.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/util/DiffDivider.java index e9c3168e401c..010aa8d7c6bd 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/util/DiffDivider.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/util/DiffDivider.java @@ -29,6 +29,7 @@ import java.awt.*; public class DiffDivider extends JComponent { public static final int MERGE_DIVIDER_POLYGONS_OFFSET = 1; + public static final int MERGE_SCROLL_DIVIDER_POLYGONS_OFFSET = 2; private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.diff.impl.util.DiffDivider"); private final Editor[] myEditors = new Editor[2]; private final FragmentSide myLeftSide; diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorEx.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorEx.java index 62064a0b1a49..8752e13681b8 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorEx.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorEx.java @@ -32,6 +32,7 @@ import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.ui.ButtonlessScrollBarUI; import org.intellij.lang.annotations.MagicConstant; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -262,10 +263,5 @@ public interface EditorEx extends Editor { * @param callback callback which will be called from the {@link javax.swing.JComponent#paint(java.awt.Graphics)} method of * the editor vertical scrollbar. */ - void registerScrollBarRepaintCallback(@Nullable RepaintCallback callback); - - interface RepaintCallback { - void call(Graphics g); - } - + void registerScrollBarRepaintCallback(@Nullable ButtonlessScrollBarUI.ScrollbarRepaintCallback callback); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index c8f01ad58e60..7e803c59438c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -597,7 +597,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi } @Override - public void registerScrollBarRepaintCallback(@Nullable RepaintCallback callback) { + public void registerScrollBarRepaintCallback(@Nullable ButtonlessScrollBarUI.ScrollbarRepaintCallback callback) { myVerticalScrollBar.registerRepaintCallback(callback); } @@ -4779,7 +4779,6 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi class MyScrollBar extends JBScrollBar implements IdeGlassPane.TopComponent { @NonNls private static final String APPLE_LAF_AQUA_SCROLL_BAR_UI_CLASS = "apple.laf.AquaScrollBarUI"; private ScrollBarUI myPersistentUI; - @Nullable private RepaintCallback myRepaintCallback; private MyScrollBar(@JdkConstants.AdjustableOrientation int orientation) { super(orientation); @@ -4804,9 +4803,6 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi @Override public void paint(@NotNull Graphics g) { super.paint(g); - if (myRepaintCallback != null) { - myRepaintCallback.call(g); - } } /** @@ -4877,8 +4873,10 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi return myEditorComponent.getScrollableBlockIncrement(vr, SwingConstants.VERTICAL, direction); } - public void registerRepaintCallback(@Nullable RepaintCallback callback) { - myRepaintCallback = callback; + public void registerRepaintCallback(@Nullable ButtonlessScrollBarUI.ScrollbarRepaintCallback callback) { + if (myPersistentUI instanceof ButtonlessScrollBarUI) { + ((ButtonlessScrollBarUI)myPersistentUI).registerRepaintCallback(callback); + } } } diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ModifierKeyDoubleClickHandler.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ModifierKeyDoubleClickHandler.java index 8a9031986ef8..d4b7b96e5006 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ModifierKeyDoubleClickHandler.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ModifierKeyDoubleClickHandler.java @@ -117,7 +117,7 @@ public class ModifierKeyDoubleClickHandler { resetState(); return false; } - if (ourOtherKeyWasPressed.get() && Clock.getTime() - ourLastTimePressed.get() < 500) { + if (myActionKeyCode == -1 && ourOtherKeyWasPressed.get() && Clock.getTime() - ourLastTimePressed.get() < 500) { resetState(); return false; } diff --git a/platform/platform-impl/src/com/intellij/ui/JBTabsPaneImpl.java b/platform/platform-impl/src/com/intellij/ui/JBTabsPaneImpl.java index fe041c5ea02b..cfea2dfb0d8e 100644 --- a/platform/platform-impl/src/com/intellij/ui/JBTabsPaneImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/JBTabsPaneImpl.java @@ -65,11 +65,11 @@ public class JBTabsPaneImpl implements TabbedPane, SwingConstants { maxOffset++; g2d.setPaint(UIUtil.getPanelBackground()); if (getFirstTabOffset() > 0) { - g2d.fillRect(clip.x, clip.y, clip.x + getFirstTabOffset() - 1, clip.y + maxLength - TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT); + g2d.fillRect(clip.x, clip.y, clip.x + getFirstTabOffset() - 1, clip.y + maxLength - getActiveTabUnderlineHeight()); } - g2d.fillRect(clip.x + maxOffset, clip.y, clip.width - maxOffset, clip.y + maxLength - TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT); + g2d.fillRect(clip.x + maxOffset, clip.y, clip.width - maxOffset, clip.y + maxLength - getActiveTabUnderlineHeight()); g2d.setPaint(new JBColor(Gray._181, UIUtil.getPanelBackground())); - g2d.drawLine(clip.x + maxOffset, clip.y + maxLength - TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT, clip.x + clip.width, clip.y + maxLength - TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT); + g2d.drawLine(clip.x + maxOffset, clip.y + maxLength - getActiveTabUnderlineHeight(), clip.x + clip.width, clip.y + maxLength - getActiveTabUnderlineHeight()); g2d.setPaint(UIUtil.getPanelBackground()); g2d.drawLine(clip.x, clip.y + maxLength, clip.width, clip.y + maxLength); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java index a97679b164d3..813d3b8cc165 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java @@ -42,6 +42,7 @@ import com.intellij.openapi.editor.markup.GutterIconRenderer; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.ToolWindowId; @@ -381,13 +382,21 @@ public class XDebugSessionImpl implements XDebugSession { private > void handleBreakpoint(final XBreakpointHandler handler, final B b, final boolean register, final boolean temporary) { - if (register && isBreakpointActive(b)) { - synchronized (myRegisteredBreakpoints) { - myRegisteredBreakpoints.put(b, new CustomizedBreakpointPresentation()); + if (register) { + boolean active = ApplicationManager.getApplication().runReadAction(new Computable() { + @Override + public Boolean compute() { + return isBreakpointActive(b); + } + }); + if (active) { + synchronized (myRegisteredBreakpoints) { + myRegisteredBreakpoints.put(b, new CustomizedBreakpointPresentation()); + } + handler.registerBreakpoint(b); } - handler.registerBreakpoint(b); } - if (!register) { + else { boolean removed; synchronized (myRegisteredBreakpoints) { removed = myRegisteredBreakpoints.remove(b) != null; diff --git a/python/ipnb/ipnb.iml b/python/ipnb/ipnb.iml index 0d6f9d8986a8..c1d41f3385d3 100644 --- a/python/ipnb/ipnb.iml +++ b/python/ipnb/ipnb.iml @@ -26,41 +26,17 @@ - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/python/ipnb/lib/batik.jar b/python/ipnb/lib/batik.jar new file mode 100644 index 000000000000..a90c8ad7c7f8 Binary files /dev/null and b/python/ipnb/lib/batik.jar differ diff --git a/python/ipnb/resources/org/jetbrains/plugins/ipnb/math-characters.txt b/python/ipnb/resources/org/jetbrains/plugins/ipnb/math-characters.txt new file mode 100644 index 000000000000..024394e18d7d --- /dev/null +++ b/python/ipnb/resources/org/jetbrains/plugins/ipnb/math-characters.txt @@ -0,0 +1,4 @@ +## This is hand-edited. Add all of the non-auto-generated definitions +3A6:varPhi:ALPHA +3C6:varphi:ALPHA +02248:thickapprox:REL \ No newline at end of file diff --git a/python/ipnb/src/org/jetbrains/plugins/ipnb/IpnbUtils.java b/python/ipnb/src/org/jetbrains/plugins/ipnb/IpnbUtils.java index 53ca1003c5d8..848338dc1c64 100644 --- a/python/ipnb/src/org/jetbrains/plugins/ipnb/IpnbUtils.java +++ b/python/ipnb/src/org/jetbrains/plugins/ipnb/IpnbUtils.java @@ -1,7 +1,10 @@ package org.jetbrains.plugins.ipnb; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.BrowserHyperlinkListener; +import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.text.MarkdownUtil; import com.petebevin.markdown.MarkdownProcessor; import net.sourceforge.jeuclid.MathMLParserSupport; import net.sourceforge.jeuclid.context.LayoutContextImpl; @@ -29,6 +32,7 @@ import java.awt.image.BufferedImage; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; +import java.util.ArrayList; import java.util.Dictionary; import java.util.Hashtable; @@ -49,8 +53,22 @@ public class IpnbUtils { "padding: 8px 35px 8px 14px;" + "border: 1px solid #fbeed5;}"; - public static String markdown2Html(@NotNull final String description) { - return ourMarkdownProcessor.markdown(description); + private static final String ourAlertSuccessRule = ".alert-success{ background-color: #dff0d8;\n" + + "color: #468847;" + + "padding: 8px 35px 8px 14px;" + + "border: 1px solid #d6e9c6;}"; + + private static final String ourAlertErrorRule = ".alert-error{ background-color: #f2dede;\n" + + "color: #b94a48;" + + "padding: 8px 35px 8px 14px;" + + "border: 1px solid #eed3d7;}"; + + public static String markdown2Html(@NotNull String description) { + description = StringUtil.replace(description, "class=\"alert alert-success\"", "class=\"alert-success\""); + description = StringUtil.replace(description, "class=\"alert alert-error\"", "class=\"alert-error\""); + ArrayList lines = ContainerUtil.newArrayList(description.split("\n|\r|\r\n")); + MarkdownUtil.replaceHeaders(lines); + return ourMarkdownProcessor.markdown(StringUtil.join(lines, "\n")); } public static void addLatexToPanel(@NotNull final String source, @NotNull final JPanel panel) { @@ -61,6 +79,8 @@ public class IpnbUtils { sheet.addRule(ourBodyRule); sheet.addRule(ourCodeRule); sheet.addRule(ourAlertRule); + sheet.addRule(ourAlertSuccessRule); + sheet.addRule(ourAlertErrorRule); editorPane.setEditable(false); @@ -75,6 +95,7 @@ public class IpnbUtils { } }); editorPane.addHyperlinkListener(new BrowserHyperlinkListener()); + //TODO: jump to the section (see User Interface#Utilities) panel.add(editorPane); } @@ -137,8 +158,8 @@ public class IpnbUtils { markdown.append(charAt); } if (formula.length() != 0) { - addFormula(formula.toString(), editorPane, imageIndex); - result.append(""); + addFormula(formula.toString(), editorPane, imageIndex, result); + imageIndex += 1; formula = new StringBuilder(); } @@ -146,12 +167,12 @@ public class IpnbUtils { if (inEnd && charAt == '}') { inMultiStringCode -= 1; + inEnd = false; } } if (formula.length() != 0) { - addFormula(formula.toString(), editorPane, imageIndex); - result.append(""); + addFormula(formula.toString(), editorPane, imageIndex, result); } if (markdown.length() != 0) { result.append(markdown.toString()); @@ -159,7 +180,7 @@ public class IpnbUtils { return markdown2Html(result.toString()); } - private static void addFormula(@NotNull final String formulaText, JEditorPane editorPane, int imageIndex) { + private static void addFormula(@NotNull final String formulaText, JEditorPane editorPane, int imageIndex, StringBuilder result) { final SnuggleEngine engine = new SnuggleEngine(); engine.getPackages().add(0, IpnbTexPackageDefinitions.getPackage()); @@ -206,5 +227,10 @@ public class IpnbUtils { catch (ParserConfigurationException e) { LOG.error(e); } + if (formulaText.startsWith("$$") || formulaText.startsWith("\\begin")) { + result.append("

"); + } + else + result.append(""); } } diff --git a/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/IpnbEditorUtil.java b/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/IpnbEditorUtil.java index 28797477f363..21396fa9d3f0 100644 --- a/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/IpnbEditorUtil.java +++ b/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/IpnbEditorUtil.java @@ -44,7 +44,7 @@ public class IpnbEditorUtil { public enum PromptType { In, Out, None } public static Dimension PROMPT_SIZE = new Dimension(80, 30); - public static int PANEL_WIDTH = 900; + public static int PANEL_WIDTH = (int)(Toolkit.getDefaultToolkit().getScreenSize().width * 0.5); public static Editor createPythonCodeEditor(@NotNull final Project project, @NotNull final IpnbCodeSourcePanel codeSourcePanel) { final EditorFactory editorFactory = EditorFactory.getInstance(); diff --git a/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/IpnbFileEditor.java b/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/IpnbFileEditor.java index 320f4fdec67a..9a4ece93f156 100644 --- a/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/IpnbFileEditor.java +++ b/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/IpnbFileEditor.java @@ -107,12 +107,28 @@ public class IpnbFileEditor extends UserDataHolderBase implements FileEditor, Te private JPanel createControlPanel() { final JPanel controlPanel = new JPanel(); controlPanel.setBackground(IpnbEditorUtil.getBackground()); - addSaveButton(controlPanel); - addAddButton(controlPanel); - addCutButton(controlPanel); - addCopyButton(controlPanel); - addPasteButton(controlPanel); - addRunButton(controlPanel); + + final JPanel savePanel = new JPanel(new GridBagLayout()); + savePanel.setBackground(IpnbEditorUtil.getBackground()); + addSaveButton(savePanel); + controlPanel.add(savePanel); + + final JPanel addPanel = new JPanel(new GridBagLayout()); + addPanel.setBackground(IpnbEditorUtil.getBackground()); + addAddButton(addPanel); + controlPanel.add(addPanel); + + final JPanel editorPanel = new JPanel(new GridBagLayout()); + editorPanel.setBackground(IpnbEditorUtil.getBackground()); + addCutButton(editorPanel); + addCopyButton(editorPanel); + addPasteButton(editorPanel); + controlPanel.add(editorPanel); + + final JPanel runPanel = new JPanel(new GridBagLayout()); + runPanel.setBackground(IpnbEditorUtil.getBackground()); + addRunButton(runPanel); + controlPanel.add(runPanel); myCellTypeCombo = new ComboBox(ourCellTypes); @@ -146,6 +162,7 @@ public class IpnbFileEditor extends UserDataHolderBase implements FileEditor, Te action.runCell(myIpnbFilePanel, true); } }); + myRunCellButton.setToolTipText("Run Cell"); controlPanel.add(myRunCellButton); } @@ -156,7 +173,7 @@ public class IpnbFileEditor extends UserDataHolderBase implements FileEditor, Te final IpnbSaveAction action = (IpnbSaveAction)ActionManager.getInstance().getAction("IpnbSaveAction"); action.saveAndCheckpoint(IpnbFileEditor.this); } - }, AllIcons.Actions.Menu_saveall); + }, AllIcons.Actions.Menu_saveall, "Save and Checkpoint"); } private void addCutButton(@NotNull final JPanel controlPanel) { @@ -166,7 +183,7 @@ public class IpnbFileEditor extends UserDataHolderBase implements FileEditor, Te final IpnbCutCellAction action = (IpnbCutCellAction)ActionManager.getInstance().getAction("IpnbCutCellAction"); action.cutCell(myIpnbFilePanel); } - }, AllIcons.Actions.Menu_cut); + }, AllIcons.Actions.Menu_cut, "Cut Cell"); } private void addCopyButton(@NotNull final JPanel controlPanel) { @@ -176,7 +193,7 @@ public class IpnbFileEditor extends UserDataHolderBase implements FileEditor, Te final IpnbCopyCellAction action = (IpnbCopyCellAction)ActionManager.getInstance().getAction("IpnbCopyCellAction"); action.copyCell(myIpnbFilePanel); } - }, AllIcons.Actions.Copy); + }, AllIcons.Actions.Copy, "Copy Cell"); } private void addPasteButton(@NotNull final JPanel controlPanel) { @@ -186,15 +203,19 @@ public class IpnbFileEditor extends UserDataHolderBase implements FileEditor, Te final IpnbPasteCellAction action = (IpnbPasteCellAction)ActionManager.getInstance().getAction("IpnbPasteCellAction"); action.pasteCell(myIpnbFilePanel); } - }, AllIcons.Actions.Menu_paste); + }, AllIcons.Actions.Menu_paste, "Paste Cell Below"); } - private static void addButton(@NotNull final JPanel controlPanel, @NotNull final ActionListener listener, @NotNull final Icon icon) { + private static void addButton(@NotNull final JPanel controlPanel, + @NotNull final ActionListener listener, + @NotNull final Icon icon, + @NotNull final String tooltip) { final JButton button = new JButton(); button.setBackground(IpnbEditorUtil.getBackground()); button.setPreferredSize(new Dimension(30, 30)); button.setIcon(icon); button.addActionListener(listener); + button.setToolTipText(tooltip); controlPanel.add(button); } @@ -205,7 +226,7 @@ public class IpnbFileEditor extends UserDataHolderBase implements FileEditor, Te final IpnbAddCellAction action = (IpnbAddCellAction)ActionManager.getInstance().getAction("IpnbAddCellAction"); action.addCell(myIpnbFilePanel); } - }, AllIcons.General.Add); + }, AllIcons.General.Add, "Insert Cell Below"); } public JButton getRunCellButton() { diff --git a/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/IpnbFilePanel.java b/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/IpnbFilePanel.java index 06cbe95a9d05..930c97f5d9d7 100644 --- a/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/IpnbFilePanel.java +++ b/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/IpnbFilePanel.java @@ -282,6 +282,7 @@ public class IpnbFilePanel extends JPanel implements Scrollable, DataProvider { if (mySelectedCell != null && e.getID() == KeyEvent.KEY_PRESSED) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { mySelectedCell.switchToEditing(); + repaint(); } int index = myIpnbPanels.indexOf(mySelectedCell); final Rectangle rect = getVisibleRect(); @@ -346,7 +347,14 @@ public class IpnbFilePanel extends JPanel implements Scrollable, DataProvider { super.paintComponent(g); if (mySelectedCell != null) { g.setColor(mySelectedCell.isEditing() ? JBColor.GREEN : JBColor.GRAY); - g.drawRoundRect(100, mySelectedCell.getTop() - 1, getWidth() - 200, mySelectedCell.getHeight() + 2, 5, 5); + if (mySelectedCell instanceof IpnbCodePanel) { + g.drawRoundRect(mySelectedCell.getX() - 50, mySelectedCell.getTop() - 1, + mySelectedCell.getWidth() + 145 - IpnbEditorUtil.PROMPT_SIZE.width, mySelectedCell.getHeight() + 2, 5, 5); + } + else { + g.drawRoundRect(mySelectedCell.getX() - IpnbEditorUtil.PROMPT_SIZE.width - 55, mySelectedCell.getTop() - 1, + mySelectedCell.getWidth() + 150, mySelectedCell.getHeight() + 2, 5, 5); + } } } diff --git a/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/IpnbTexPackageDefinitions.java b/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/IpnbTexPackageDefinitions.java index 70ad4f854902..ce0a86671f03 100644 --- a/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/IpnbTexPackageDefinitions.java +++ b/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/IpnbTexPackageDefinitions.java @@ -3,24 +3,31 @@ package org.jetbrains.plugins.ipnb.editor.panels; import org.w3c.dom.Element; import uk.ac.ed.ph.snuggletex.SnugglePackage; import uk.ac.ed.ph.snuggletex.dombuilding.CommandHandler; +import uk.ac.ed.ph.snuggletex.dombuilding.EqnArrayHandler; import uk.ac.ed.ph.snuggletex.internal.DOMBuilder; import uk.ac.ed.ph.snuggletex.internal.SnuggleParseException; +import uk.ac.ed.ph.snuggletex.semantics.Interpretation; import uk.ac.ed.ph.snuggletex.tokens.CommandToken; import uk.ac.ed.ph.snuggletex.tokens.FlowToken; import java.util.List; +import static uk.ac.ed.ph.snuggletex.definitions.Globals.ALL_MODES; import static uk.ac.ed.ph.snuggletex.definitions.Globals.MATH_MODE_ONLY; +import static uk.ac.ed.ph.snuggletex.definitions.LaTeXMode.MATH; +import static uk.ac.ed.ph.snuggletex.definitions.TextFlowContext.START_NEW_XHTML_BLOCK; public final class IpnbTexPackageDefinitions { private static final SnugglePackage ourPackage; - - public static SnugglePackage getPackage() { + + public static SnugglePackage getPackage() { return ourPackage; } - - static { + + private static String ourMathCharacters = "org/jetbrains/plugins/ipnb/math-characters.txt"; + + static { ourPackage = new SnugglePackage("Ipnb"); ourPackage.addComplexCommandSameArgMode("dot", false, 1, MATH_MODE_ONLY, new CommandHandler() { @@ -38,5 +45,8 @@ public final class IpnbTexPackageDefinitions { builder.appendMathMLOperatorElement(parentElement, "\u03c0"); } }, null); + ourPackage.addEnvironment("eqnarray", ALL_MODES, MATH, Interpretation.TABULAR, new EqnArrayHandler(), START_NEW_XHTML_BLOCK); + + ourPackage.loadMathCharacterDefinitions(ourMathCharacters); } } diff --git a/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/code/IpnbCodeSourcePanel.java b/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/code/IpnbCodeSourcePanel.java index 58f1bd8ac049..367c6c7a6a46 100644 --- a/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/code/IpnbCodeSourcePanel.java +++ b/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/code/IpnbCodeSourcePanel.java @@ -65,7 +65,7 @@ public class IpnbCodeSourcePanel extends IpnbPanel imp @Override protected JComponent createViewPanel() { - final JPanel panel = new JPanel(new VerticalFlowLayout(FlowLayout.LEFT, true, true)); + final JPanel panel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, true, true)); panel.setBackground(UIUtil.isUnderDarcula() ? IpnbEditorUtil.getBackground() : Gray._247); if (mySource.startsWith("%")) {