mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -66,9 +66,11 @@ public class JBScrollPane extends JScrollPane {
|
||||
|
||||
@Deprecated
|
||||
public static final RegionPainter<Float> MAC_THUMB_PAINTER = new RoundThumbPainter(2, .2f, .3f, Gray.x00);
|
||||
static final RegionPainter<Float> MAC_OVERLAY_THUMB_PAINTER = new RoundThumbPainter(2, 0f, .5f, Gray.x00);
|
||||
|
||||
@Deprecated
|
||||
public static final RegionPainter<Float> MAC_THUMB_DARK_PAINTER = new RoundThumbPainter(2, .10f, .05f, Gray.xFF);
|
||||
static final RegionPainter<Float> MAC_OVERLAY_THUMB_DARK_PAINTER = new RoundThumbPainter(2, 0f, .15f, Gray.xFF);
|
||||
|
||||
private int myViewportBorderWidth = -1;
|
||||
private boolean myHasOverlayScrollbars;
|
||||
|
||||
@@ -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<Float> p = ScrollColorProducer.isDark(c) ? JBScrollPane.MAC_THUMB_DARK_PAINTER : JBScrollPane.MAC_THUMB_PAINTER;
|
||||
if (c.isOpaque()) {
|
||||
RegionPainter<Float> 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<Float> 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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
+13
-4
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+5
-1
@@ -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);
|
||||
|
||||
+60
-6
@@ -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<JComponent> 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<Language> 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();
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -41,14 +41,14 @@ import java.awt.*;
|
||||
*/
|
||||
public class XDebuggerExpressionComboBox extends XDebuggerEditorBase {
|
||||
private final JComponent myComponent;
|
||||
private final ComboBox myComboBox;
|
||||
private final ComboBox<XExpression> 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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -71,6 +71,10 @@
|
||||
text="Fill Answer Placeholders">
|
||||
<add-to-group group-id="HelpMenu" anchor="before" relative-to-action="HelpTopics"/>
|
||||
</action>
|
||||
<action id="StudySwitchPanel" class="com.jetbrains.edu.learning.actions.StudySwitchTaskPanelAction"
|
||||
text="Switch Task Description Panel">
|
||||
<add-to-group group-id="HelpMenu" anchor="before" relative-to-action="HelpTopics"/>
|
||||
</action>
|
||||
|
||||
</actions>
|
||||
|
||||
|
||||
+12
-7
@@ -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<Keymap, List<Pair<String, String>>> myDeletedShortcuts = new HashMap<Keymap, List<Pair<String, String>>>();
|
||||
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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+89
@@ -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<String>
|
||||
|
||||
|
||||
constructor(project: Project, canBeParent: Boolean) : super(project, canBeParent) {
|
||||
myProject = project
|
||||
myComboBox = ComboBox<String>()
|
||||
val comboBoxModel = DefaultComboBoxModel<String>()
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user