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/java/idea-ui/src/com/intellij/ide/actions/ShowStructureSettingsAction.java b/java/idea-ui/src/com/intellij/ide/actions/ShowStructureSettingsAction.java index b43698ece136..700be0621a60 100644 --- a/java/idea-ui/src/com/intellij/ide/actions/ShowStructureSettingsAction.java +++ b/java/idea-ui/src/com/intellij/ide/actions/ShowStructureSettingsAction.java @@ -43,7 +43,10 @@ public class ShowStructureSettingsAction extends AnAction implements DumbAware { if (project == null) { project = ProjectManager.getInstance().getDefaultProject(); } + showDialog(project); + } + static void showDialog(Project project) { if (Registry.is("ide.new.project.settings")) { new SingleConfigurableEditor(project, ProjectStructureConfigurable.getInstance(project), OptionsEditorDialog.DIMENSION_KEY) { @Nullable diff --git a/java/idea-ui/src/com/intellij/ide/actions/TemplateProjectStructureAction.java b/java/idea-ui/src/com/intellij/ide/actions/TemplateProjectStructureAction.java index 093552e12be0..ed439c6c2b70 100644 --- a/java/idea-ui/src/com/intellij/ide/actions/TemplateProjectStructureAction.java +++ b/java/idea-ui/src/com/intellij/ide/actions/TemplateProjectStructureAction.java @@ -17,17 +17,12 @@ package com.intellij.ide.actions; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.options.ShowSettingsUtil; -import com.intellij.openapi.options.newEditor.OptionsEditorDialog; import com.intellij.openapi.project.DumbAware; -import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ex.ProjectManagerEx; -import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable; public class TemplateProjectStructureAction extends AnAction implements DumbAware { @Override public void actionPerformed(final AnActionEvent e) { - Project defaultProject = ProjectManagerEx.getInstanceEx().getDefaultProject(); - ShowSettingsUtil.getInstance().editConfigurable(defaultProject, OptionsEditorDialog.DIMENSION_KEY, ProjectStructureConfigurable.getInstance(defaultProject)); + ShowStructureSettingsAction.showDialog(ProjectManagerEx.getInstanceEx().getDefaultProject()); } } \ No newline at end of file diff --git a/platform/core-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java b/platform/core-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java index 0e5323d2ecce..e03244e0e0e9 100644 --- a/platform/core-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java +++ b/platform/core-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java @@ -847,6 +847,25 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { clearCachedTokenType(); } + /** + * + * @return true if there are error elements created and not dropped after marker was created + */ + public boolean hasErrorsAfter(Marker marker) { + assert marker instanceof StartMarker; + int idx = myProduction.lastIndexOf(marker); + if (idx < 0) { + LOG.error("The marker must be added before checked for errors."); + } + for (int i = idx+1; i < myProduction.size(); ++i) { + ProductionMarker m = myProduction.get(i); + if (m instanceof ErrorItem || m instanceof DoneWithErrorMarker) { + return true; + } + } + return false; + } + @SuppressWarnings({"SuspiciousMethodCalls"}) public void drop(Marker marker) { final DoneMarker doneMarker = ((StartMarker)marker).myDoneMarker; diff --git a/platform/core-impl/src/com/intellij/psi/impl/file/PsiDirectoryImpl.java b/platform/core-impl/src/com/intellij/psi/impl/file/PsiDirectoryImpl.java index edf8fdda95f5..e0ed0dd9182e 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/file/PsiDirectoryImpl.java +++ b/platform/core-impl/src/com/intellij/psi/impl/file/PsiDirectoryImpl.java @@ -28,7 +28,6 @@ import com.intellij.openapi.fileEditor.impl.LoadTextUtil; import com.intellij.openapi.progress.ProgressIndicatorProvider; import com.intellij.openapi.ui.Queryable; import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.NonPhysicalFileSystem; @@ -503,24 +502,23 @@ public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory, Qu CheckUtil.checkWritable(this); if (element instanceof PsiDirectory) { String name = ((PsiDirectory)element).getName(); - PsiDirectory[] subpackages = getSubdirectories(); - for (PsiDirectory dir : subpackages) { - if (Comparing.strEqual(dir.getName(), name)) { - throw new IncorrectOperationException(VfsBundle.message("dir.already.exists.error", dir.getVirtualFile().getPresentableUrl())); - } - } + checkName(name, getSubdirectories(), "dir.already.exists.error"); } else if (element instanceof PsiFile) { String name = ((PsiFile)element).getName(); - PsiFile[] files = getFiles(); - for (PsiFile file : files) { - if (Comparing.strEqual(file.getName(), name, SystemInfo.isFileSystemCaseSensitive)) { - throw new IncorrectOperationException(VfsBundle.message("file.already.exists.error", file.getVirtualFile().getPresentableUrl())); - } - } + checkName(name, getFiles(), "file.already.exists.error"); } else { - throw new IncorrectOperationException(); + throw new IncorrectOperationException(element.getClass().getName()); + } + } + + private void checkName(String name, PsiFileSystemItem[] items, String key) { + boolean caseSensitive = getVirtualFile().getFileSystem().isCaseSensitive(); + for (PsiFileSystemItem item : items) { + if (Comparing.strEqual(item.getName(), name, caseSensitive)) { + throw new IncorrectOperationException(VfsBundle.message(key, item.getVirtualFile().getPresentableUrl())); + } } } diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/LoadingIcon.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/LoadingIcon.java index 6d61c23a937e..0105032eba97 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/LoadingIcon.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/LoadingIcon.java @@ -34,19 +34,8 @@ class LoadingIcon extends JBImageIcon { private static final String LOADING_ICON = "/icons/loading.gif"; private static final Logger LOG = Logger.getInstance(LoadingIcon.class); - private final int myWidth; - private final int myHeight; - private final int myDeltaX; - private final int myDeltaY; - - LoadingIcon(@NotNull Image image, int width, int height) { + LoadingIcon(@NotNull Image image) { super(image); - int myOriginalWidth = image.getWidth(null); - int myOriginalHeight = image.getHeight(null); - myWidth = Math.max(width, myOriginalWidth); - myHeight = Math.max(height, myOriginalHeight); - myDeltaX = (myWidth - myOriginalWidth) / 2 - 2; - myDeltaY = (myHeight - myOriginalHeight) / 2 + 2; } @NotNull @@ -56,33 +45,18 @@ class LoadingIcon extends JBImageIcon { LOG.error("Couldn't load image: " + LOADING_ICON); return createEmpty(width, height); } - return new LoadingIcon(image, width, height); + return new LoadingIcon(image); } @NotNull static LoadingIcon createEmpty(int width, int height) { - return new LoadingIcon(UIUtil.createImage(width, height, Transparency.TRANSLUCENT), width, height); + return new LoadingIcon(UIUtil.createImage(width, height, Transparency.TRANSLUCENT)); } void setObserver(@NotNull JTree tree, @NotNull TreeNode treeNode) { setImageObserver(new NodeImageObserver(tree, treeNode)); } - @Override - public final synchronized void paintIcon(final Component c, final Graphics g, final int x, final int y) { - super.paintIcon(c, g, x + myDeltaX, y + myDeltaY); - } - - @Override - public int getIconHeight() { - return myHeight; - } - - @Override - public int getIconWidth() { - return myWidth; - } - private static class NodeImageObserver implements ImageObserver { @NotNull private final JTree myTree; @NotNull private final DefaultTreeModel myModel; diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java index f42698bc0de0..818e04a36426 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java @@ -355,6 +355,9 @@ public class PushLog extends JPanel implements TypeSafeDataProvider { if (!(value instanceof DefaultMutableTreeNode)) { return; } + myCheckbox.setBorder(null); //checkBox may have no border by default, but insets are not null, + // it depends on LaF, OS and isItRenderedPane, see com.intellij.ide.ui.laf.darcula.ui.DarculaCheckBoxBorder. + // null border works as expected always. if (value instanceof RepositoryNode) { //todo simplify, remove instance of myCheckbox.setVisible(((RepositoryNode)value).isCheckboxVisible()); diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryNode.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryNode.java index 956806b61bbc..169d09a19c73 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryNode.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryNode.java @@ -27,7 +27,6 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.border.EmptyBorder; -import java.awt.*; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; @@ -40,7 +39,8 @@ public class RepositoryNode extends CheckedTreeNode implements EditableTreeNode, @NotNull private final RepositoryWithBranchPanel myRepositoryPanel; @Nullable private Future> myFuture; - protected final int myLoadingIconWidth; + protected final int myCheckBoxHGap; + private final int myCheckBoxVGap; public RepositoryNode(@NotNull RepositoryWithBranchPanel repositoryPanel, @NotNull CheckBoxModel model, boolean enabled) { super(repositoryPanel); @@ -48,10 +48,9 @@ public class RepositoryNode extends CheckedTreeNode implements EditableTreeNode, setChecked(false); setEnabled(enabled); myRepositoryPanel = repositoryPanel; - - Dimension size = new JCheckBox().getPreferredSize(); - myLoadingIconWidth = size.width; - myLoadingIcon = LoadingIcon.create(myLoadingIconWidth, size.height); + myLoadingIcon = myRepositoryPanel.getLoadingIcon(); + myCheckBoxHGap = myRepositoryPanel.getLoadingIconAndCheckBoxGapH(); + myCheckBoxVGap = myRepositoryPanel.getLoadingIconAndCheckBoxGapV(); } @Override @@ -71,25 +70,44 @@ public class RepositoryNode extends CheckedTreeNode implements EditableTreeNode, @Override public void render(@NotNull ColoredTreeCellRenderer renderer) { int repoFixedWidth = 120; + int borderHOffset = myRepositoryPanel.getHBorderOffset(renderer); + int borderVOffset = myRepositoryPanel.getVBorderOffset(renderer); if (myLoading.get()) { renderer.setIcon(myLoadingIcon); renderer.setIconOnTheRight(false); - repoFixedWidth += myLoadingIconWidth; + int checkBoxWidth = myRepositoryPanel.getCheckBoxWidth(); + repoFixedWidth += checkBoxWidth; + if (myCheckBoxHGap > 0) { + renderer.append(""); + renderer.appendFixedTextFragmentWidth(checkBoxWidth + renderer.getIconTextGap() + borderHOffset); + } + if (myCheckBoxVGap > 0) { + int shiftV = myCheckBoxVGap - borderVOffset; + renderer.setBorder(new EmptyBorder(shiftV / 2, 0, shiftV / 2, 0)); + } } - renderer.append(getRepoName(renderer, repoFixedWidth), SimpleTextAttributes.GRAY_ATTRIBUTES); + else { + if (myCheckBoxHGap <= 0) { + renderer.append(""); + renderer.appendFixedTextFragmentWidth(myRepositoryPanel.calculateRendererShiftH(renderer)); + } + if (myCheckBoxVGap <= 0) { + int shiftV = -myCheckBoxVGap + borderVOffset; + renderer.setBorder(new EmptyBorder(shiftV / 2, 0, shiftV / 2, 0)); + } + } + renderer.append(getRepoName(renderer, repoFixedWidth), isChecked() ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES); renderer.appendFixedTextFragmentWidth(repoFixedWidth); - renderer.append(myRepositoryPanel.getSourceName(), SimpleTextAttributes.REGULAR_ATTRIBUTES); - renderer.append(myRepositoryPanel.getArrow(), SimpleTextAttributes.REGULAR_ATTRIBUTES); + renderer.append(myRepositoryPanel.getSourceName(), isChecked() ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES); + renderer.append(myRepositoryPanel.getArrow(), isChecked() ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES); PushTargetPanel pushTargetPanel = myRepositoryPanel.getTargetPanel(); pushTargetPanel.render(renderer); - Insets insets = BorderFactory.createEmptyBorder().getBorderInsets(pushTargetPanel); - renderer.setBorder(new EmptyBorder(insets)); } @NotNull private String getRepoName(@NotNull ColoredTreeCellRenderer renderer, int maxWidth) { String name = myRepositoryPanel.getRepositoryName(); - return GraphicsUtil.stringWidth(name, renderer.getFont()) > maxWidth - UIUtil.DEFAULT_VGAP ? name + " " : name; + return GraphicsUtil.stringWidth(name, renderer.getFont()) > maxWidth - UIUtil.DEFAULT_HGAP ? name + " " : name; } @Override diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryWithBranchPanel.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryWithBranchPanel.java index ff4cddc833b4..833ae6aa6b4c 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryWithBranchPanel.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryWithBranchPanel.java @@ -23,6 +23,7 @@ import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.ui.ValidationInfo; import com.intellij.openapi.ui.popup.util.PopupUtil; import com.intellij.ui.ColoredTreeCellRenderer; +import com.intellij.ui.SimpleColoredComponent; import com.intellij.ui.SimpleTextAttributes; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; @@ -32,6 +33,7 @@ import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import javax.swing.*; +import javax.swing.border.Border; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -46,6 +48,11 @@ public class RepositoryWithBranchPanel extends NonOpaquePa private final JLabel myRepositoryLabel; private final ColoredTreeCellRenderer myTextRenderer; @NotNull private final List> myListeners = ContainerUtil.createLockFreeCopyOnWriteList(); + private final int myCheckBoxLoadingIconGapH; + private final int myCheckBoxLoadingIconGapV; + private final LoadingIcon myLoadingIcon; + private final int myCheckBoxWidth; + public RepositoryWithBranchPanel(@NotNull final Project project, @NotNull String repoName, @NotNull String sourceName, @NotNull PushTargetPanel destPushTargetPanelComponent) { @@ -54,6 +61,7 @@ public class RepositoryWithBranchPanel extends NonOpaquePa myRepositoryCheckbox = new JBCheckBox(); myRepositoryCheckbox.setFocusable(false); myRepositoryCheckbox.setOpaque(false); + myRepositoryCheckbox.setBorder(null); myRepositoryCheckbox.addActionListener(new ActionListener() { @Override public void actionPerformed(@NotNull ActionEvent e) { @@ -89,6 +97,14 @@ public class RepositoryWithBranchPanel extends NonOpaquePa return error == null; } }); + + JCheckBox emptyBorderCheckBox = new JCheckBox(); + emptyBorderCheckBox.setBorder(null); + Dimension size = emptyBorderCheckBox.getPreferredSize(); + myCheckBoxWidth = size.width; + myLoadingIcon = LoadingIcon.create(myCheckBoxWidth, size.height); + myCheckBoxLoadingIconGapH = myCheckBoxWidth - myLoadingIcon.getIconWidth(); + myCheckBoxLoadingIconGapV = size.height - myLoadingIcon.getIconHeight(); } private void layoutComponents() { @@ -122,17 +138,24 @@ public class RepositoryWithBranchPanel extends NonOpaquePa boolean hasFocus) { Rectangle bounds = tree.getPathBounds(tree.getPathForRow(row)); invalidate(); + myTextRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); if (!(value instanceof SingleRepositoryNode)) { RepositoryNode node = (RepositoryNode)value; myRepositoryCheckbox.setSelected(node.isChecked()); myRepositoryCheckbox.setVisible(true); - myTextRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); + if (myCheckBoxLoadingIconGapH < 0) { + myTextRenderer.append(""); + myTextRenderer.appendFixedTextFragmentWidth(calculateRendererShiftH(myTextRenderer)); + } myTextRenderer.append(getRepositoryName(), SimpleTextAttributes.GRAY_ATTRIBUTES); myTextRenderer.appendFixedTextFragmentWidth(120); } else { - myTextRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); + SingleRepositoryNode singleRepositoryNode = ((SingleRepositoryNode)value); myRepositoryCheckbox.setVisible(false); + myTextRenderer.setIcon(singleRepositoryNode.getEmptyIcon()); + myTextRenderer.setIconOnTheRight(false); + myTextRenderer.append(""); } myTextRenderer.append(getSourceName(), SimpleTextAttributes.REGULAR_ATTRIBUTES); myTextRenderer.append(getArrow(), SimpleTextAttributes.REGULAR_ATTRIBUTES); @@ -168,6 +191,38 @@ public class RepositoryWithBranchPanel extends NonOpaquePa public PushTargetPanel getTargetPanel() { return myDestPushTargetPanelComponent; } + + public LoadingIcon getLoadingIcon() { + return myLoadingIcon; + } + + public int getCheckBoxWidth() { + return myCheckBoxWidth; + } + + + public int getLoadingIconAndCheckBoxGapH() { + return myCheckBoxLoadingIconGapH; + } + + public int calculateRendererShiftH(@NotNull SimpleColoredComponent coloredRenderer) { + int borderOffset = getHBorderOffset(coloredRenderer); + return -myCheckBoxLoadingIconGapH + coloredRenderer.getIconTextGap() + coloredRenderer.getIpad().left + borderOffset; + } + + public int getHBorderOffset(@NotNull SimpleColoredComponent coloredRenderer) { + Border border = coloredRenderer.getMyBorder(); + return border != null ? border.getBorderInsets(coloredRenderer).left : 0; + } + + public int getLoadingIconAndCheckBoxGapV() { + return myCheckBoxLoadingIconGapV; + } + + public int getVBorderOffset(@NotNull SimpleColoredComponent coloredRenderer) { + Border border = coloredRenderer.getMyBorder(); + return border != null ? border.getBorderInsets(coloredRenderer).top : 0; + } } diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/SingleRepositoryNode.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/SingleRepositoryNode.java index 98c177b3326b..fccb004fd527 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/SingleRepositoryNode.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/SingleRepositoryNode.java @@ -28,7 +28,8 @@ public class SingleRepositoryNode extends RepositoryNode { public SingleRepositoryNode(@NotNull RepositoryWithBranchPanel repositoryPanel, @NotNull CheckBoxModel model) { super(repositoryPanel, model, true); myRepositoryPanel = repositoryPanel; - myEmptyIcon = LoadingIcon.createEmpty(myLoadingIcon.getIconWidth(), myLoadingIcon.getIconHeight()); + myEmptyIcon = + LoadingIcon.createEmpty(repositoryPanel.getLoadingIcon().getIconWidth(), repositoryPanel.getLoadingIcon().getIconHeight()); } @Override @@ -36,17 +37,18 @@ public class SingleRepositoryNode extends RepositoryNode { return false; } + public LoadingIcon getEmptyIcon() { + return myEmptyIcon; + } + @Override public void fireOnSelectionChange(boolean isSelected) { } @Override public void render(@NotNull ColoredTreeCellRenderer renderer) { - renderer.setIcon(myLoading.get() ? myLoadingIcon : myEmptyIcon); + renderer.setIcon(myLoading.get() ? myRepositoryPanel.getLoadingIcon() : myEmptyIcon); renderer.setIconOnTheRight(false); - - renderer.append(""); - renderer.appendFixedTextFragmentWidth(myLoadingIconWidth); renderer.append(myRepositoryPanel.getSourceName(), SimpleTextAttributes.REGULAR_ATTRIBUTES); renderer.append(myRepositoryPanel.getArrow(), SimpleTextAttributes.REGULAR_ATTRIBUTES); PushTargetPanel pushTargetPanel = myRepositoryPanel.getTargetPanel(); diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsBranchEditorListener.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsBranchEditorListener.java index 0b3df11db78a..e49dec734665 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsBranchEditorListener.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsBranchEditorListener.java @@ -35,10 +35,7 @@ public class VcsBranchEditorListener extends LinkMouseListenerBase { public void mouseMoved(MouseEvent e) { Component component = (Component)e.getSource(); Object tag = getTagAt(e); - if (tag != null && tag instanceof PushTargetPanel) { - component.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); - } - else if (tag != null && tag instanceof TextWithLinkNode) { + if (tag instanceof PushTargetPanel || tag instanceof TextWithLinkNode) { component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else { 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/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/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/errorreport/itn/ITNProxy.java b/platform/platform-impl/src/com/intellij/errorreport/itn/ITNProxy.java index 4339b36cbf22..ad030b0c9e7f 100644 --- a/platform/platform-impl/src/com/intellij/errorreport/itn/ITNProxy.java +++ b/platform/platform-impl/src/com/intellij/errorreport/itn/ITNProxy.java @@ -49,9 +49,11 @@ import java.net.URLEncoder; import java.security.GeneralSecurityException; import java.security.KeyStore; import java.security.cert.Certificate; +import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.util.Calendar; +import java.util.List; import java.util.Map; import java.util.Set; @@ -216,7 +218,7 @@ public class ITNProxy { HttpsURLConnection connection = (HttpsURLConnection)url.openConnection(); connection.setSSLSocketFactory(ourSslContext.getSocketFactory()); - if (!SystemInfo.isJavaVersionAtLeast("1.7") || !SystemProperties.getBooleanProperty("jsse.enableSNIExtension", true)) { + if (!(SystemInfo.isJavaVersionAtLeast("1.7") && SystemProperties.getBooleanProperty("jsse.enableSNIExtension", true))) { connection.setHostnameVerifier(new EaHostnameVerifier(url.getHost(), "ftp.intellij.net")); } @@ -243,10 +245,15 @@ public class ITNProxy { KeyStore ks = KeyStore.getInstance(CertificateUtil.JKS); ks.load(null, null); ks.setCertificateEntry("JetBrains CA", ca); - TrustManagerFactory tmf = TrustManagerFactory.getInstance(CertificateUtil.X509); - tmf.init(ks); + TrustManagerFactory jbTmf = TrustManagerFactory.getInstance(CertificateUtil.X509); + jbTmf.init(ks); + + TrustManagerFactory sysTmf = TrustManagerFactory.getInstance(CertificateUtil.X509); + sysTmf.init((KeyStore)null); + SSLContext ctx = SSLContext.getInstance("TLS"); - ctx.init(null, tmf.getTrustManagers(), null); + TrustManager composite = new CompositeX509TrustManager(jbTmf.getTrustManagers(), sysTmf.getTrustManagers()); + ctx.init(null, new TrustManager[]{composite}, null); return ctx; } @@ -274,6 +281,46 @@ public class ITNProxy { } } + private static class CompositeX509TrustManager implements X509TrustManager { + private final List myManagers = ContainerUtil.newArrayList(); + + public CompositeX509TrustManager(TrustManager[]... managerSets) { + for (TrustManager[] set : managerSets) { + for (TrustManager manager : set) { + if (manager instanceof X509TrustManager) { + myManagers.add((X509TrustManager)manager); + } + } + } + } + + @Override + public void checkClientTrusted(X509Certificate[] certificates, String s) throws CertificateException { + throw new UnsupportedOperationException(); + } + + @Override + public void checkServerTrusted(X509Certificate[] certificates, String s) throws CertificateException { + for (X509TrustManager manager : myManagers) { + try { + manager.checkServerTrusted(certificates, s); + return; + } + catch (CertificateException ignored) { } + } + throw new CertificateException("No trusting managers found for " + s); + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + List result = ContainerUtil.newArrayList(); + for (X509TrustManager manager : myManagers) { + ContainerUtil.addAll(result, manager.getAcceptedIssuers()); + } + return result.toArray(new X509Certificate[result.size()]); + } + } + @SuppressWarnings("SpellCheckingInspection") private static final String JB_CA_CERT = "-----BEGIN CERTIFICATE-----\n" + "MIIFvjCCA6agAwIBAgIQMYHnK1dpIZVCoitWqBwhXjANBgkqhkiG9w0BAQsFADBn\n" + diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/ConfigurableEditor.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/ConfigurableEditor.java index 47382f70229d..022bff4a4248 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/ConfigurableEditor.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/ConfigurableEditor.java @@ -59,7 +59,12 @@ class ConfigurableEditor extends AbstractEditor implements AnActionListener, AWT private final MergingUpdateQueue myQueue = new MergingUpdateQueue("SettingsModification", 1000, false, this, this, this); private final IdentityHashMap myConfigurableContent = new IdentityHashMap(); private final JLabel myErrorLabel = new JLabel(); - private final AbstractAction myApplyAction; + private final AbstractAction myApplyAction = new AbstractAction(CommonBundle.getApplyButtonText()) { + @Override + public void actionPerformed(ActionEvent event) { + apply(); + } + }; private final AbstractAction myResetAction = new AbstractAction(RESET_NAME) { @Override public void actionPerformed(ActionEvent event) { @@ -71,14 +76,9 @@ class ConfigurableEditor extends AbstractEditor implements AnActionListener, AWT }; private Configurable myConfigurable; - ConfigurableEditor(Disposable parent, Configurable configurable, boolean showApplyButton) { + ConfigurableEditor(Disposable parent, Configurable configurable) { super(parent); - myApplyAction = !showApplyButton ? null : new AbstractAction(CommonBundle.getApplyButtonText()) { - @Override - public void actionPerformed(ActionEvent event) { - apply(); - } - }; + myApplyAction.setEnabled(false); myResetAction.putValue(Action.SHORT_DESCRIPTION, RESET_DESCRIPTION); myResetAction.setEnabled(false); myErrorLabel.setOpaque(true); @@ -179,9 +179,7 @@ class ConfigurableEditor extends AbstractEditor implements AnActionListener, AWT void updateCurrent(Configurable configurable, boolean reset) { boolean modified = configurable != null && configurable.isModified(); - if (myApplyAction != null) { - myApplyAction.setEnabled(modified); - } + myApplyAction.setEnabled(modified); myResetAction.setEnabled(modified); if (!modified && reset) { setError(null); diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/SettingsDialog.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/SettingsDialog.java index 1a32d0e94583..dadfbaca1cc7 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/SettingsDialog.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/SettingsDialog.java @@ -45,18 +45,22 @@ import java.util.ArrayList; public final class SettingsDialog extends DialogWrapper implements DataProvider { private final String myDimensionServiceKey; private final AbstractEditor myEditor; + private boolean myApplyButtonNeeded; + private boolean myResetButtonNeeded; public SettingsDialog(Project project, @NotNull String key, @NotNull Configurable configurable, boolean showApplyButton) { super(project, true); myDimensionServiceKey = key; - myEditor = new ConfigurableEditor(myDisposable, configurable, showApplyButton); + myEditor = new ConfigurableEditor(myDisposable, configurable); + myApplyButtonNeeded = showApplyButton; init(configurable); } public SettingsDialog(@NotNull Component parent, @NotNull String key, @NotNull Configurable configurable, boolean showApplyButton) { super(parent, true); myDimensionServiceKey = key; - myEditor = new ConfigurableEditor(myDisposable, configurable, showApplyButton); + myEditor = new ConfigurableEditor(myDisposable, configurable); + myApplyButtonNeeded = showApplyButton; init(configurable); } @@ -64,6 +68,7 @@ public final class SettingsDialog extends DialogWrapper implements DataProvider super(project, true); myDimensionServiceKey = "SettingsEditor"; myEditor = new SettingsEditor(myDisposable, project, groups, configurable, filter); + myApplyButtonNeeded = true; init(null); } @@ -125,11 +130,11 @@ public final class SettingsDialog extends DialogWrapper implements DataProvider actions.add(getOKAction()); actions.add(getCancelAction()); Action apply = myEditor.getApplyAction(); - if (apply != null) { + if (apply != null && myApplyButtonNeeded) { actions.add(apply); } Action reset = myEditor.getResetAction(); - if (reset != null) { + if (reset != null && myResetButtonNeeded) { actions.add(reset); } actions.add(getHelpAction()); diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/SettingsEditor.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/SettingsEditor.java index 5d1b8d296c52..d3e270c841e3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/SettingsEditor.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/SettingsEditor.java @@ -144,7 +144,7 @@ final class SettingsEditor extends AbstractEditor implements DataProvider { mySearch.repaint(); } }); - myEditor = new ConfigurableEditor(this, null, true) { + myEditor = new ConfigurableEditor(this, null) { @Override boolean apply() { checkModified(myFilter.myContext.getCurrentConfigurable()); 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/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 0dba778c9c3a..2ed97baa6141 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -3061,25 +3061,4 @@ public class UIUtil { textField.setColumns(4); } - - public static Border makeChameleonBorder(final Border border, final Condition conditionToShow, final T checker) { - return new Border() { - @Override - public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { - if (conditionToShow.value(checker)) { - border.paintBorder(c, g, x, y, width, height); - } - } - - @Override - public Insets getBorderInsets(Component c) { - return border.getBorderInsets(c); - } - - @Override - public boolean isBorderOpaque() { - return border.isBorderOpaque() && conditionToShow.value(checker); - } - }; - } } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java index d829395c5dc3..8d38a9ec0d39 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java @@ -18,15 +18,14 @@ package com.intellij.vcs.log.ui.frame; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.util.ProgressWindow; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.changes.issueLinks.IssueLinkHtmlRenderer; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.BrowserHyperlinkListener; import com.intellij.ui.IdeBorderFactory; -import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBLoadingPanel; +import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.components.JBTextField; import com.intellij.ui.components.panels.NonOpaquePanel; import com.intellij.util.containers.ContainerUtil; @@ -47,6 +46,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import javax.swing.border.Border; import javax.swing.border.LineBorder; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; @@ -86,7 +86,12 @@ class DetailsPanel extends JPanel implements ListSelectionListener { myRefsPanel = new RefsPanel(colorManager); myHashAuthorPanel = new DataPanel(logDataHolder.getProject(), false); - final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(); + final JScrollPane scrollPane = new JBScrollPane() { + @Override + public Border getBorder() { + return getVerticalScrollBar().isVisible() ? super.getBorder() : null; + } + }; myMessageDataPanel = new DataPanel(logDataHolder.getProject(), true) { @Override public Dimension getPreferredSize() { @@ -96,12 +101,6 @@ class DetailsPanel extends JPanel implements ListSelectionListener { } }; scrollPane.setViewportView(myMessageDataPanel); - scrollPane.setBorder(UIUtil.makeChameleonBorder(scrollPane.getBorder(), new Condition() { - @Override - public boolean value(JScrollBar bar) { - return bar != null && bar.isVisible(); - } - }, scrollPane.getVerticalScrollBar())); myContainingBranchesPanel = new ContainingBranchesPanel(); myMessagePanel = new MessagePanel(); @@ -113,17 +112,21 @@ class DetailsPanel extends JPanel implements ListSelectionListener { myLoadingPanel.add(header, BorderLayout.NORTH); myLoadingPanel.add(scrollPane, BorderLayout.CENTER); myLoadingPanel.add(myContainingBranchesPanel, BorderLayout.SOUTH); - myLoadingPanel.setBackground(UIUtil.getTableBackground()); + myLoadingPanel.setOpaque(false); setLayout(new CardLayout()); add(myLoadingPanel, STANDARD_LAYER); add(myMessagePanel, MESSAGE_LAYER); setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); - setBackground(UIUtil.getTableBackground()); showMessage("No commits selected"); } + @Override + public Color getBackground() { + return UIUtil.getTableBackground(); + } + void updateDataPack(@NotNull VisiblePack dataPack) { myDataPack = dataPack; } @@ -192,6 +195,7 @@ class DetailsPanel extends JPanel implements ListSelectionListener { myProject = project; addHyperlinkListener(BrowserHyperlinkListener.INSTANCE); setOpaque(false); + putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); } void setData(@Nullable VcsFullCommitDetails commit) { @@ -263,17 +267,25 @@ class DetailsPanel extends JPanel implements ListSelectionListener { myLoadingComponent = new NonOpaquePanel(new BorderLayout()); myLoadingComponent.add(new AsyncProcessIcon("Loading..."), BorderLayout.WEST); myLoadingComponent.add(Box.createHorizontalGlue(), BorderLayout.CENTER); - myBranchesList = new JBTextField(""); - myBranchesList.setEditable(false); - myBranchesList.setBorder(IdeBorderFactory.createEmptyBorder()); // setting border to null may mean "use default border" while setting empty border means we do not want a border - if (UIUtil.isUnderIntelliJLaF()) { - myBranchesList.setBackground(UIUtil.getPanelBackground()); - } else if (UIUtil.isUnderGTKLookAndFeel()) { - // setting border to empty does not help with gtk l&f - // so I just cover it completely with my line border - myBranchesList.setBorder(new LineBorder(UIUtil.getTextFieldBackground(), 3)); - } + myBranchesList = new JBTextField("") { + private final Border gtkBorder = new LineBorder(UIUtil.getTextFieldBackground(), 3) { + @Override + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + lineColor = UIUtil.getTextFieldBackground(); + super.paintBorder(c, g, x, y, width, height); + } + }; + private final Border emptyBorder = IdeBorderFactory.createEmptyBorder(); + @Override + public Border getBorder() { + // setting border to empty does not help with gtk l&f + // so I just cover it completely with my line border + return UIUtil.isUnderGTKLookAndFeel() ? gtkBorder : emptyBorder; + } + }; + myBranchesList.setOpaque(false); + myBranchesList.setEditable(false); setOpaque(false); setLayout(new BorderLayout()); add(label, BorderLayout.WEST); 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("%")) {