diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/JavaDebuggerEditorsProvider.java b/java/debugger/impl/src/org/jetbrains/java/debugger/JavaDebuggerEditorsProvider.java index 4f2fb2a6e55e..fe92203e34ae 100644 --- a/java/debugger/impl/src/org/jetbrains/java/debugger/JavaDebuggerEditorsProvider.java +++ b/java/debugger/impl/src/org/jetbrains/java/debugger/JavaDebuggerEditorsProvider.java @@ -24,6 +24,7 @@ import com.intellij.lang.Language; import com.intellij.openapi.editor.Document; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.util.PsiTreeUtil; @@ -72,7 +73,7 @@ public class JavaDebuggerEditorsProvider extends XDebuggerEditorsProviderBase { PsiDocumentManager.getInstance(project).commitDocument(document); PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document); if (psiFile != null) { - return new XExpressionImpl(psiFile.getText(), language, ((JavaCodeFragment)psiFile).importsToString(), mode); + return new XExpressionImpl(psiFile.getText(), language, StringUtil.nullize(((JavaCodeFragment)psiFile).importsToString()), mode); } return super.createExpression(project, document, language, mode); } diff --git a/platform/platform-api/src/com/intellij/ui/components/DefaultScrollBarUI.java b/platform/platform-api/src/com/intellij/ui/components/DefaultScrollBarUI.java index 111135eb8600..fe08ba5f8afd 100644 --- a/platform/platform-api/src/com/intellij/ui/components/DefaultScrollBarUI.java +++ b/platform/platform-api/src/com/intellij/ui/components/DefaultScrollBarUI.java @@ -44,13 +44,13 @@ class DefaultScrollBarUI extends ScrollBarUI { private final Listener myListener = new Listener(); private final Timer myScrollTimer = UIUtil.createNamedTimer("ScrollBarThumbScrollTimer", 60, myListener); - final TwoWayAnimator myTrackAnimator = new TwoWayAnimator("ScrollBarTrack", 6, 125, 150, 300) { + final TwoWayAnimator myTrackAnimator = new TwoWayAnimator("ScrollBarTrack", 11, 150, 125, 300, 125) { @Override void onValueUpdate() { repaint(); } }; - final TwoWayAnimator myThumbAnimator = new TwoWayAnimator("ScrollBarThumb", 6, 125, 150, 300) { + final TwoWayAnimator myThumbAnimator = new TwoWayAnimator("ScrollBarThumb", 11, 150, 125, 300, 125) { @Override void onValueUpdate() { repaint(); diff --git a/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java b/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java index 1bb605f7d92c..aa6eddedd596 100644 --- a/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java +++ b/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java @@ -66,9 +66,11 @@ public class JBScrollPane extends JScrollPane { @Deprecated public static final RegionPainter MAC_THUMB_PAINTER = new RoundThumbPainter(2, .2f, .3f, Gray.x00); + static final RegionPainter MAC_OVERLAY_THUMB_PAINTER = new RoundThumbPainter(2, 0f, .5f, Gray.x00); @Deprecated public static final RegionPainter MAC_THUMB_DARK_PAINTER = new RoundThumbPainter(2, .10f, .05f, Gray.xFF); + static final RegionPainter MAC_OVERLAY_THUMB_DARK_PAINTER = new RoundThumbPainter(2, 0f, .15f, Gray.xFF); private int myViewportBorderWidth = -1; private boolean myHasOverlayScrollbars; diff --git a/platform/platform-api/src/com/intellij/ui/components/MacScrollBarUI.java b/platform/platform-api/src/com/intellij/ui/components/MacScrollBarUI.java index 2a72c70ffa47..53e46b483ae4 100644 --- a/platform/platform-api/src/com/intellij/ui/components/MacScrollBarUI.java +++ b/platform/platform-api/src/com/intellij/ui/components/MacScrollBarUI.java @@ -100,11 +100,12 @@ final class MacScrollBarUI extends DefaultScrollBarUI { @Override void paintThumb(Graphics2D g, int x, int y, int width, int height, JComponent c) { - RegionPainter p = ScrollColorProducer.isDark(c) ? JBScrollPane.MAC_THUMB_DARK_PAINTER : JBScrollPane.MAC_THUMB_PAINTER; if (c.isOpaque()) { + RegionPainter p = ScrollColorProducer.isDark(c) ? JBScrollPane.MAC_THUMB_DARK_PAINTER : JBScrollPane.MAC_THUMB_PAINTER; paint(p, g, x, y, width, height, c, myThumbAnimator.myValue, true); } else if (myThumbAnimator.myValue > 0) { + RegionPainter p = ScrollColorProducer.isDark(c) ? JBScrollPane.MAC_OVERLAY_THUMB_DARK_PAINTER : JBScrollPane.MAC_OVERLAY_THUMB_PAINTER; paint(p, g, x, y, width, height, c, myThumbAnimator.myValue, false); } } @@ -112,7 +113,7 @@ final class MacScrollBarUI extends DefaultScrollBarUI { @Override void onThumbMove() { if (myScrollBar != null && myScrollBar.isShowing() && !myScrollBar.isOpaque()) { - if (myThumbAnimator.myValue == 0) myTrackAnimator.rewind(false); + if (!myTrackHovered && myThumbAnimator.myValue == 0) myTrackAnimator.rewind(false); myThumbAnimator.rewind(true); myAlarm.cancelAllRequests(); if (!myTrackHovered) { diff --git a/platform/platform-api/src/com/intellij/ui/components/TwoWayAnimator.java b/platform/platform-api/src/com/intellij/ui/components/TwoWayAnimator.java index 84a017cfdbef..32d2304d7817 100644 --- a/platform/platform-api/src/com/intellij/ui/components/TwoWayAnimator.java +++ b/platform/platform-api/src/com/intellij/ui/components/TwoWayAnimator.java @@ -32,10 +32,10 @@ abstract class TwoWayAnimator { abstract void onValueUpdate(); - TwoWayAnimator(String name, int totalFrames, int cycleDuration, int pauseForward, int pauseBackward) { + TwoWayAnimator(String name, int totalFrames, int pauseForward, int durationForward, int pauseBackward, int durationBackward) { myMaxFrame = totalFrames - 1; - myForwardAnimator = new MyAnimator(name + "ForwardAnimator", totalFrames, cycleDuration, pauseForward, true); - myBackwardAnimator = new MyAnimator(name + "BackwardAnimator", totalFrames, cycleDuration, pauseBackward, false); + myForwardAnimator = new MyAnimator(name + "ForwardAnimator", totalFrames, durationForward, pauseForward, true); + myBackwardAnimator = new MyAnimator(name + "BackwardAnimator", totalFrames, durationBackward, pauseBackward, false); } void start(boolean forward) { diff --git a/platform/platform-resources-en/src/messages/XDebuggerBundle.properties b/platform/platform-resources-en/src/messages/XDebuggerBundle.properties index 19e568e7a77f..0303f726758c 100644 --- a/platform/platform-resources-en/src/messages/XDebuggerBundle.properties +++ b/platform/platform-resources-en/src/messages/XDebuggerBundle.properties @@ -46,7 +46,7 @@ suspend.policy.panel.makeDefault=Make De&fault xbreakpoints.properties.actions.group.title=Actions xbreakpoints.log.message.checkbox=Log &message to console -xbreakpoints.log.expression.checkbox=Log evaluated &expression: +xbreakpoints.log.expression.checkbox=&Evaluate and log: xbreakpoints.condition.checkbox=&Condition: xbreakpoints.enabled.label=Enable&d xbreakpoint.group.depends.on=Depends on diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XExpressionState.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XExpressionState.java index 65dc92e97ec1..70e28978a48a 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XExpressionState.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XExpressionState.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.xmlb.annotations.Attribute; import com.intellij.util.xmlb.annotations.Text; import com.intellij.xdebugger.XExpression; +import com.intellij.xdebugger.evaluation.EvaluationMode; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -39,21 +40,29 @@ public class XExpressionState { @Attribute("custom") public String myCustomInfo; + @Attribute("mode") + public EvaluationMode myMode = EvaluationMode.EXPRESSION; + @Text public String myOldExpression; public XExpressionState() { } - public XExpressionState(boolean disabled, @NotNull String expression, String language, String customInfo) { + public XExpressionState(boolean disabled, @NotNull String expression, String language, String customInfo, EvaluationMode mode) { myDisabled = disabled; myExpression = expression; myLanguage = language; myCustomInfo = customInfo; + myMode = mode; } public XExpressionState(boolean disabled, XExpression expression) { - this(disabled, expression.getExpression(), expression.getLanguage() != null ? expression.getLanguage().getID() : null, expression.getCustomInfo()); + this(disabled, + expression.getExpression(), + expression.getLanguage() != null ? expression.getLanguage().getID() : null, + expression.getCustomInfo(), + expression.getMode()); } public XExpressionState(XExpression expression) { @@ -74,6 +83,6 @@ public class XExpressionState { if (StringUtil.isEmptyOrSpaces(myExpression)) { return null; } - return new XExpressionImpl(myExpression, Language.findLanguageByID(myLanguage), myCustomInfo); + return new XExpressionImpl(myExpression, Language.findLanguageByID(myLanguage), myCustomInfo, myMode); } } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointActionsPanel.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointActionsPanel.java index 22e4e053e24d..02ceba3714e8 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointActionsPanel.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointActionsPanel.java @@ -59,7 +59,7 @@ public class XBreakpointActionsPanel extends XBreakpointPropertiesSubPanel { onCheckboxChanged(); } }; - myLogExpressionComboBox = new XDebuggerExpressionComboBox(project, debuggerEditorsProvider, LOG_EXPRESSION_HISTORY_ID, myBreakpoint.getSourcePosition()); + myLogExpressionComboBox = new XDebuggerExpressionComboBox(project, debuggerEditorsProvider, LOG_EXPRESSION_HISTORY_ID, myBreakpoint.getSourcePosition(), true); JComponent logExpressionComponent = myLogExpressionComboBox.getComponent(); myLogExpressionPanel.add(logExpressionComponent, BorderLayout.CENTER); myLogExpressionComboBox.setEnabled(false); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.java index 6f334d5ef31d..fe8c9ae01a9d 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.java @@ -139,7 +139,7 @@ public class XLightBreakpointPropertiesPanel implements XSuspendPolicyPanel.Dele myCustomPanels = new ArrayList<>(); if (debuggerEditorsProvider != null) { myConditionEnabledCheckbox = new JBCheckBox(XDebuggerBundle.message("xbreakpoints.condition.checkbox")); - myConditionComboBox = new XDebuggerExpressionComboBox(project, debuggerEditorsProvider, CONDITION_HISTORY_ID, myBreakpoint.getSourcePosition()); + myConditionComboBox = new XDebuggerExpressionComboBox(project, debuggerEditorsProvider, CONDITION_HISTORY_ID, myBreakpoint.getSourcePosition(), true); JComponent conditionComponent = myConditionComboBox.getComponent(); conditionComponent.setBorder(JBUI.Borders.emptyRight(3)); myConditionExpressionPanel.add(conditionComponent, BorderLayout.CENTER); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/CodeFragmentInputComponent.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/CodeFragmentInputComponent.java index 7039fd3eaf46..a6bcc1126849 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/CodeFragmentInputComponent.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/CodeFragmentInputComponent.java @@ -66,10 +66,14 @@ public class CodeFragmentInputComponent extends EvaluationInputComponent { @Override @NotNull - protected XDebuggerEditorBase getInputEditor() { + public XDebuggerEditorBase getInputEditor() { return myMultilineEditor; } + public JPanel getMainComponent() { + return myMainPanel; + } + @Override public void addComponent(JPanel contentPanel, JPanel resultPanel) { final JBSplitter splitter = new JBSplitter(true, 0.3f, 0.2f, 0.7f); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerEditorBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerEditorBase.java index 7fef7449e5c2..7f60fe884156 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerEditorBase.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerEditorBase.java @@ -15,6 +15,7 @@ */ package com.intellij.xdebugger.impl.ui; +import com.intellij.icons.AllIcons; import com.intellij.ide.DataManager; import com.intellij.lang.Language; import com.intellij.lang.LanguageUtil; @@ -26,6 +27,8 @@ import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.ComponentWithBrowseButton; +import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.ui.popup.ListPopup; import com.intellij.openapi.util.IconLoader; @@ -40,6 +43,7 @@ import com.intellij.xdebugger.evaluation.EvaluationMode; import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider; import com.intellij.xdebugger.impl.XDebuggerHistoryManager; import com.intellij.xdebugger.impl.breakpoints.XExpressionImpl; +import com.intellij.xdebugger.impl.evaluate.CodeFragmentInputComponent; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -119,13 +123,23 @@ public abstract class XDebuggerEditorBase { false); } - protected JPanel addChooseFactoryLabel(JComponent component, boolean top) { - JPanel panel = new JPanel(new BorderLayout()); - panel.add(component, BorderLayout.CENTER); + protected JPanel decorate(JComponent component, boolean multiline, boolean showEditor) { + JPanel panel = JBUI.Panels.simplePanel(); - JPanel factoryPanel = new JPanel(new BorderLayout()); - factoryPanel.add(myChooseFactory, top ? BorderLayout.NORTH : BorderLayout.CENTER); + JPanel factoryPanel = JBUI.Panels.simplePanel(); + factoryPanel.add(myChooseFactory, multiline ? BorderLayout.NORTH : BorderLayout.CENTER); panel.add(factoryPanel, BorderLayout.WEST); + + if (!multiline && showEditor) { + ComponentWithBrowseButton componentWithButton = + new ComponentWithBrowseButton<>(component, e -> showCodeFragmentEditor(component, this)); + componentWithButton.setButtonIcon(AllIcons.Actions.ShowViewer); + componentWithButton.getButton().setDisabledIcon(IconLoader.getDisabledIcon(AllIcons.Actions.ShowViewer)); + panel.add(componentWithButton, BorderLayout.CENTER); + } else { + panel.add(component, BorderLayout.CENTER); + } + return panel; } @@ -164,8 +178,8 @@ public abstract class XDebuggerEditorBase { if (language == null) { language = LanguageUtil.getFileTypeLanguage(getEditorsProvider().getFileType()); } + text = new XExpressionImpl(text.getExpression(), language, text.getCustomInfo(), text.getMode()); } - text = new XExpressionImpl(text.getExpression(), language, text.getCustomInfo(), getMode()); Collection languages = getEditorsProvider().getSupportedLanguages(myProject, mySourcePosition); boolean many = languages.size() > 1; @@ -267,4 +281,44 @@ public abstract class XDebuggerEditorBase { setExpression(expressions.get(myHistoryIndex)); } } + + private void showCodeFragmentEditor(Component parent, XDebuggerEditorBase baseEditor) { + DialogWrapper dialog = new DialogWrapper(parent, true) { + CodeFragmentInputComponent inputComponent = + new CodeFragmentInputComponent(baseEditor.getProject(), baseEditor.getEditorsProvider(), mySourcePosition, + XExpressionImpl.changeMode(baseEditor.getExpression(), EvaluationMode.CODE_FRAGMENT), + null, null); + + { + setTitle("Edit"); + init(); + } + + @Nullable + @Override + protected String getDimensionServiceKey() { + return "#xdebugger.code.fragment.editor"; + } + + @Nullable + @Override + protected JComponent createCenterPanel() { + return inputComponent.getMainComponent(); + } + + @Override + protected void doOKAction() { + super.doOKAction(); + baseEditor.setExpression(inputComponent.getInputEditor().getExpression()); + IdeFocusManager.findInstance().requestFocus(baseEditor.getEditorComponent(), false); + } + + @Nullable + @Override + public JComponent getPreferredFocusedComponent() { + return inputComponent.getInputEditor().getPreferredFocusedComponent(); + } + }; + dialog.show(); + } } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerExpressionComboBox.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerExpressionComboBox.java index 3d394a79d34a..0bf83c4d51bd 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerExpressionComboBox.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerExpressionComboBox.java @@ -41,14 +41,14 @@ import java.awt.*; */ public class XDebuggerExpressionComboBox extends XDebuggerEditorBase { private final JComponent myComponent; - private final ComboBox myComboBox; + private final ComboBox myComboBox; private EditorComboBoxEditor myEditor; private XExpression myExpression; - public XDebuggerExpressionComboBox(final @NotNull Project project, final @NotNull XDebuggerEditorsProvider debuggerEditorsProvider, final @Nullable @NonNls String historyId, - final @Nullable XSourcePosition sourcePosition) { + public XDebuggerExpressionComboBox(@NotNull Project project, @NotNull XDebuggerEditorsProvider debuggerEditorsProvider, @Nullable @NonNls String historyId, + @Nullable XSourcePosition sourcePosition, boolean showEditor) { super(project, debuggerEditorsProvider, EvaluationMode.EXPRESSION, historyId, sourcePosition); - myComboBox = new ComboBox(100); + myComboBox = new ComboBox<>(100); myComboBox.setEditable(true); myExpression = XExpressionImpl.EMPTY_EXPRESSION; Dimension minimumSize = new Dimension(myComboBox.getMinimumSize()); @@ -56,7 +56,7 @@ public class XDebuggerExpressionComboBox extends XDebuggerEditorBase { myComboBox.setMinimumSize(minimumSize); initEditor(); fillComboBox(); - myComponent = addChooseFactoryLabel(myComboBox, false); + myComponent = decorate(myComboBox, false, showEditor); } public ComboBox getComboBox() { @@ -146,7 +146,7 @@ public class XDebuggerExpressionComboBox extends XDebuggerEditorBase { public XExpression getExpression() { Object document = myEditor.getItem(); if (document instanceof Document) { // sometimes null on Mac - return getEditorsProvider().createExpression(getProject(), (Document)document, myExpression.getLanguage(), EvaluationMode.EXPRESSION); + return getEditorsProvider().createExpression(getProject(), (Document)document, myExpression.getLanguage(), myExpression.getMode()); } return myExpression; } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerExpressionEditor.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerExpressionEditor.java index 056504e7d0ac..ef7a7c4aad19 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerExpressionEditor.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerExpressionEditor.java @@ -78,7 +78,7 @@ public class XDebuggerExpressionEditor extends XDebuggerEditorBase { myEditorTextField.setFontInheritedFromLAF(false); myEditorTextField.setFont(EditorUtil.getEditorFont()); } - myComponent = addChooseFactoryLabel(myEditorTextField, multiline); + myComponent = decorate(myEditorTextField, multiline, false); } @Override diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTreeInplaceEditor.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTreeInplaceEditor.java index bd2a2a93d4de..c10d2ecdb25c 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTreeInplaceEditor.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTreeInplaceEditor.java @@ -37,7 +37,7 @@ public abstract class XDebuggerTreeInplaceEditor extends TreeInplaceEditor { public XDebuggerTreeInplaceEditor(final XDebuggerTreeNode node, @NonNls final String historyId) { myNode = node; myTree = myNode.getTree(); - myExpressionEditor = new XDebuggerExpressionComboBox(myTree.getProject(), myTree.getEditorsProvider(), historyId, myTree.getSourcePosition()); + myExpressionEditor = new XDebuggerExpressionComboBox(myTree.getProject(), myTree.getEditorsProvider(), historyId, myTree.getSourcePosition(), false); } @Override diff --git a/python/educational-core/student/resources/META-INF/plugin.xml b/python/educational-core/student/resources/META-INF/plugin.xml index 9cd1dc9e0b1b..ac60e179eee0 100644 --- a/python/educational-core/student/resources/META-INF/plugin.xml +++ b/python/educational-core/student/resources/META-INF/plugin.xml @@ -71,6 +71,10 @@ text="Fill Answer Placeholders"> + + + diff --git a/python/educational-core/student/src/com/jetbrains/edu/learning/StudyProjectComponent.java b/python/educational-core/student/src/com/jetbrains/edu/learning/StudyProjectComponent.java index 9b0d2aea6a8c..7ed217600d10 100644 --- a/python/educational-core/student/src/com/jetbrains/edu/learning/StudyProjectComponent.java +++ b/python/educational-core/student/src/com/jetbrains/edu/learning/StudyProjectComponent.java @@ -25,13 +25,13 @@ import com.intellij.openapi.wm.ToolWindow; import com.intellij.openapi.wm.ToolWindowAnchor; import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.util.containers.hash.HashMap; +import com.jetbrains.edu.learning.actions.StudyToolbarAction; import com.jetbrains.edu.learning.core.EduNames; import com.jetbrains.edu.learning.core.EduUtils; import com.jetbrains.edu.learning.courseFormat.Course; import com.jetbrains.edu.learning.courseFormat.Lesson; import com.jetbrains.edu.learning.courseFormat.Task; import com.jetbrains.edu.learning.courseFormat.TaskFile; -import com.jetbrains.edu.learning.actions.*; import com.jetbrains.edu.learning.editor.StudyEditorFactoryListener; import com.jetbrains.edu.learning.ui.StudyProgressToolWindowFactory; import com.jetbrains.edu.learning.ui.StudyToolWindow; @@ -52,8 +52,9 @@ public class StudyProjectComponent implements ProjectComponent { private static final Logger LOG = Logger.getInstance(StudyProjectComponent.class.getName()); private final Project myProject; private FileCreatedByUserListener myListener; + // Shows could we use JavaFX Task Description panel or should use Swing - private boolean useJavaFx = true; + private boolean useJavaFx = false; private Map>> myDeletedShortcuts = new HashMap>>(); private StudyProjectComponent(@NotNull final Project project) { myProject = project; @@ -63,11 +64,9 @@ public class StudyProjectComponent implements ProjectComponent { public void projectOpened() { final Course course = StudyTaskManager.getInstance(myProject).getCourse(); // Check if user has javafx lib in his JDK. Now bundled JDK doesn't have this lib inside. - try { + if (StudyUtils.hasJavaFx()) { Platform.setImplicitExit(false); - } - catch (NoClassDefFoundError e) { - useJavaFx = false; + useJavaFx = true; } if (course != null && !course.isUpToDate()) { @@ -118,7 +117,9 @@ public class StudyProjectComponent implements ProjectComponent { if (action instanceof StudyToolbarAction) { String id = ((StudyToolbarAction)action).getActionId(); String[] shortcuts = ((StudyToolbarAction)action).getShortcuts(); - addShortcut(id, shortcuts); + if (shortcuts != null) { + addShortcut(id, shortcuts); + } } } } @@ -287,6 +288,10 @@ public class StudyProjectComponent implements ProjectComponent { return useJavaFx; } + public void setUseJavaFx(boolean useJavaFx) { + this.useJavaFx = useJavaFx; + } + private class FileCreatedByUserListener extends VirtualFileAdapter { @Override public void fileCreated(@NotNull VirtualFileEvent event) { diff --git a/python/educational-core/student/src/com/jetbrains/edu/learning/StudyUtils.java b/python/educational-core/student/src/com/jetbrains/edu/learning/StudyUtils.java index 8ed23fb768d3..73d7843efcc8 100644 --- a/python/educational-core/student/src/com/jetbrains/edu/learning/StudyUtils.java +++ b/python/educational-core/student/src/com/jetbrains/edu/learning/StudyUtils.java @@ -502,4 +502,14 @@ public class StudyUtils { public static boolean isStudyProject(@NotNull Project project) { return StudyTaskManager.getInstance(project).getCourse() != null; } + + public static boolean hasJavaFx() { + try { + Class.forName("javafx.application.Platform"); + return true; + } + catch (ClassNotFoundException e) { + return false; + } + } } diff --git a/python/educational-core/student/src/com/jetbrains/edu/learning/actions/StudySwitchTaskPanelAction.kt b/python/educational-core/student/src/com/jetbrains/edu/learning/actions/StudySwitchTaskPanelAction.kt new file mode 100644 index 000000000000..dc657082cdae --- /dev/null +++ b/python/educational-core/student/src/com/jetbrains/edu/learning/actions/StudySwitchTaskPanelAction.kt @@ -0,0 +1,89 @@ +package com.jetbrains.edu.learning.actions + +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.project.Project +import com.intellij.openapi.ui.ComboBox +import com.intellij.openapi.ui.DialogWrapper +import com.jetbrains.edu.learning.StudyProjectComponent +import com.jetbrains.edu.learning.StudyUtils +import javax.swing.DefaultComboBoxModel +import javax.swing.JComponent +import javax.swing.JLabel +import javax.swing.event.ListDataEvent +import javax.swing.event.ListDataListener + + +class StudySwitchTaskPanelAction: AnAction() { + + override fun actionPerformed(e: AnActionEvent?) { + val project = e?.project + if (project != null) { + if (createDialog(project).showAndGet()) { + StudyUtils.initToolWindows(project) + } + } + } + + fun createDialog(project: Project): DialogWrapper { + return MyDialog(project, false) + } + + + class MyDialog: DialogWrapper { + val JAVAFX_ITEM = "Panel with code highlighting" + val SWING_ITEM = "Simple panel" + private val myProject: Project + private val myComboBox: ComboBox + + + constructor(project: Project, canBeParent: Boolean) : super(project, canBeParent) { + myProject = project + myComboBox = ComboBox() + val comboBoxModel = DefaultComboBoxModel() + val projectComponent = StudyProjectComponent.getInstance(project) + + if (StudyUtils.hasJavaFx()) { + comboBoxModel.addElement(JAVAFX_ITEM) + } + comboBoxModel.addElement(SWING_ITEM) + comboBoxModel.addListDataListener(object : ListDataListener { + override fun contentsChanged(e: ListDataEvent?) { + isOKActionEnabled = (projectComponent.useJavaFx() && myComboBox.selectedItem == SWING_ITEM) + || (!projectComponent.useJavaFx() && myComboBox.selectedItem == JAVAFX_ITEM) + } + + override fun intervalRemoved(e: ListDataEvent?) { + } + + override fun intervalAdded(e: ListDataEvent?) { + } + + }) + comboBoxModel.selectedItem = if (projectComponent.useJavaFx()) JAVAFX_ITEM else SWING_ITEM + myComboBox.model = comboBoxModel + title = "Switch Task Description Panel" + isOKActionEnabled = false + myComboBox.setMinimumAndPreferredWidth(300) + init() + } + + + override fun createCenterPanel(): JComponent? { + return myComboBox + } + + override fun createNorthPanel(): JComponent? { + return JLabel("Choose panel: ") + } + + override fun getPreferredFocusedComponent(): JComponent? { + return myComboBox + } + + override fun doOKAction() { + super.doOKAction() + StudyProjectComponent.getInstance(myProject).setUseJavaFx(myComboBox.selectedItem == JAVAFX_ITEM) + } + } +} \ No newline at end of file diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlUtil.java b/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlUtil.java index c479ceba74be..390e325b0b10 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlUtil.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlUtil.java @@ -615,6 +615,7 @@ public class HtmlUtil { Language language = file.getLanguage(); while (language != null) { if ("JavaScript".equals(language.getID())) return true; + if ("Dart".equals(language.getID())) return true; language = language.getBaseLanguage(); }