Search in sources :

Example 1 with DarculaLookAndFeelInfo

use of com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo in project intellij-plugins by StepicOrg.

the class StudyBrowserWindow method getContent.

@NotNull
private String getContent(@NotNull final String template, @NotNull Map<String, Object> params) {
    final EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme();
    int fontSize = editorColorsScheme.getEditorFontSize();
    Map<String, Object> map = new HashMap<>();
    map.put("font_size", String.valueOf(fontSize - 2));
    map.put("highlight", getExternalURL("/highlight/highlight.pack.js"));
    if (LafManager.getInstance().getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo) {
        map.put("css_highlight", getExternalURL("/highlight/styles/darcula.css"));
    } else {
        map.put("css_highlight", getExternalURL("/highlight/styles/idea.css"));
    }
    map.put("charset", Charset.defaultCharset().displayName());
    map.put("loader", getExternalURL("/templates/img/loader.svg"));
    map.put("login_css", getExternalURL("/templates/login/css/login.css"));
    map.putAll(params);
    return Templater.processTemplate(template, map);
}
Also used : HashMap(java.util.HashMap) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) JSObject(netscape.javascript.JSObject) DarculaLookAndFeelInfo(com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with DarculaLookAndFeelInfo

use of com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo in project intellij-community by JetBrains.

the class InitialConfigurationDialog method doOKAction.

@Override
protected void doOKAction() {
    Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myMainPanel));
    super.doOKAction();
    // set keymap
    ((KeymapManagerImpl) KeymapManager.getInstance()).setActiveKeymap((Keymap) myKeymapComboBox.getSelectedItem());
    // set color scheme
    EditorColorsManager.getInstance().setGlobalScheme((EditorColorsScheme) myColorSchemeComboBox.getSelectedItem());
    // create default todo_pattern for color scheme
    TodoConfiguration.getInstance().resetToDefaultTodoPatterns();
    final boolean createScript = myCreateScriptCheckbox.isSelected();
    final boolean createEntry = myCreateEntryCheckBox.isSelected();
    if (createScript || createEntry) {
        final String pathName = myScriptPathTextField.getText();
        final boolean globalEntry = myGlobalEntryCheckBox.isSelected();
        ProgressManager.getInstance().run(new Task.Backgroundable(project, getTitle()) {

            @Override
            public void run(@NotNull final ProgressIndicator indicator) {
                indicator.setFraction(0.0);
                if (createScript) {
                    indicator.setText("Creating launcher script...");
                    try {
                        CreateLauncherScriptAction.createLauncherScript(pathName);
                    } catch (Exception e) {
                        CreateLauncherScriptAction.reportFailure(e, getProject());
                    }
                }
                indicator.setFraction(0.5);
                if (createEntry) {
                    indicator.setText("Creating desktop entry...");
                    try {
                        CreateDesktopEntryAction.createDesktopEntry(globalEntry);
                    } catch (Exception e) {
                        CreateDesktopEntryAction.reportFailure(e, getProject());
                    }
                }
                indicator.setFraction(1.0);
            }
        });
    }
    UIManager.LookAndFeelInfo info = (UIManager.LookAndFeelInfo) myAppearanceComboBox.getSelectedItem();
    LafManagerImpl lafManager = (LafManagerImpl) LafManager.getInstance();
    if (info.getName().contains("Darcula") != (LafManager.getInstance().getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo)) {
        lafManager.setLookAndFeelAfterRestart(info);
        String message = "IDE appearance settings will be applied after restart. Would you like to restart now?";
        int rc = Messages.showYesNoDialog(project, message, "IDE Appearance", Messages.getQuestionIcon());
        if (rc == Messages.YES) {
            ((ApplicationImpl) ApplicationManager.getApplication()).restart(true);
        }
    } else if (!info.equals(lafManager.getCurrentLookAndFeel())) {
        lafManager.setCurrentLookAndFeel(info);
        lafManager.updateUI();
    }
}
Also used : Task(com.intellij.openapi.progress.Task) DarculaLookAndFeelInfo(com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo) ApplicationImpl(com.intellij.openapi.application.impl.ApplicationImpl) DarculaLookAndFeelInfo(com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo) Project(com.intellij.openapi.project.Project) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) LafManagerImpl(com.intellij.ide.ui.laf.LafManagerImpl) KeymapManagerImpl(com.intellij.openapi.keymap.impl.KeymapManagerImpl)

Example 3 with DarculaLookAndFeelInfo

use of com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo in project intellij-community by JetBrains.

the class ColorAndFontOptions method changeLafIfNecessary.

private static void changeLafIfNecessary(boolean isDarkEditorTheme) {
    String propKey = "change.laf.on.editor.theme.change";
    String value = PropertiesComponent.getInstance().getValue(propKey);
    if ("false".equals(value))
        return;
    boolean applyAlways = "true".equals(value);
    DialogWrapper.DoNotAskOption doNotAskOption = new DialogWrapper.DoNotAskOption.Adapter() {

        @Override
        public void rememberChoice(boolean isSelected, int exitCode) {
            if (isSelected) {
                PropertiesComponent.getInstance().setValue(propKey, Boolean.toString(exitCode == Messages.YES));
            }
        }

        @Override
        public boolean shouldSaveOptionsOnCancel() {
            return true;
        }
    };
    final String productName = ApplicationNamesInfo.getInstance().getFullProductName();
    final LafManager lafManager = LafManager.getInstance();
    if (isDarkEditorTheme && !UIUtil.isUnderDarcula()) {
        if (applyAlways || Messages.showYesNoDialog("Looks like you have set a dark editor theme. Would you like to set dark theme for entire " + productName, "Change " + productName + " theme", Messages.YES_BUTTON, Messages.NO_BUTTON, Messages.getQuestionIcon(), doNotAskOption) == Messages.YES) {
            lafManager.setCurrentLookAndFeel(new DarculaLookAndFeelInfo());
            lafManager.updateUI();
            //noinspection SSBasedInspection
            SwingUtilities.invokeLater(DarculaInstaller::install);
        }
    } else if (!isDarkEditorTheme && UIUtil.isUnderDarcula()) {
        if (lafManager instanceof LafManagerImpl && (applyAlways || Messages.showYesNoDialog("Looks like you have set a bright editor theme. Would you like to set bright theme for entire " + productName, "Change " + productName + " theme", Messages.YES_BUTTON, Messages.NO_BUTTON, Messages.getQuestionIcon(), doNotAskOption) == Messages.YES)) {
            lafManager.setCurrentLookAndFeel(((LafManagerImpl) lafManager).getDefaultLaf());
            lafManager.updateUI();
            //noinspection SSBasedInspection
            SwingUtilities.invokeLater(DarculaInstaller::uninstall);
        }
    }
}
Also used : DarculaInstaller(com.intellij.ide.ui.laf.darcula.DarculaInstaller) LafManager(com.intellij.ide.ui.LafManager) DarculaLookAndFeelInfo(com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo) LafManagerImpl(com.intellij.ide.ui.laf.LafManagerImpl) DialogWrapper(com.intellij.openapi.ui.DialogWrapper)

Example 4 with DarculaLookAndFeelInfo

use of com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo in project intellij-community by JetBrains.

the class StudyBrowserWindow method createHtmlWithCodeHighlighting.

@Nullable
private String createHtmlWithCodeHighlighting(@NotNull final String content, @NotNull StudyPluginConfigurator configurator) {
    String template = null;
    InputStream stream = getClass().getResourceAsStream("/code-mirror/template.html");
    try {
        template = StreamUtil.readText(stream, "utf-8");
    } catch (IOException e) {
        LOG.warn(e.getMessage());
    } finally {
        try {
            stream.close();
        } catch (IOException e) {
            LOG.warn(e.getMessage());
        }
    }
    if (template == null) {
        LOG.warn("Code mirror template is null");
        return null;
    }
    final EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme();
    int fontSize = editorColorsScheme.getEditorFontSize();
    template = template.replace("${font_size}", String.valueOf(fontSize - 2));
    template = template.replace("${codemirror}", getClass().getResource("/code-mirror/codemirror.js").toExternalForm());
    template = template.replace("${language_script}", configurator.getLanguageScriptUrl());
    template = template.replace("${default_mode}", configurator.getDefaultHighlightingMode());
    template = template.replace("${runmode}", getClass().getResource("/code-mirror/runmode.js").toExternalForm());
    template = template.replace("${colorize}", getClass().getResource("/code-mirror/colorize.js").toExternalForm());
    template = template.replace("${javascript}", getClass().getResource("/code-mirror/javascript.js").toExternalForm());
    if (LafManager.getInstance().getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo) {
        template = template.replace("${css_oldcodemirror}", getClass().getResource("/code-mirror/codemirror-old-darcula.css").toExternalForm());
        template = template.replace("${css_codemirror}", getClass().getResource("/code-mirror/codemirror-darcula.css").toExternalForm());
    } else {
        template = template.replace("${css_oldcodemirror}", getClass().getResource("/code-mirror/codemirror-old.css").toExternalForm());
        template = template.replace("${css_codemirror}", getClass().getResource("/code-mirror/codemirror.css").toExternalForm());
    }
    template = template.replace("${code}", content);
    return template;
}
Also used : InputStream(java.io.InputStream) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) DarculaLookAndFeelInfo(com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo) IOException(java.io.IOException) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with DarculaLookAndFeelInfo

use of com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo in project intellij-community by JetBrains.

the class StudyBrowserWindow method initComponents.

private void initComponents() {
    Platform.runLater(() -> {
        myPane = new StackPane();
        myWebComponent = new WebView();
        myWebComponent.setOnDragDetected(event -> {
        });
        myEngine = myWebComponent.getEngine();
        if (myShowProgress) {
            myProgressBar = makeProgressBarWithListener();
            myWebComponent.setVisible(false);
            myPane.getChildren().addAll(myWebComponent, myProgressBar);
        } else {
            myPane.getChildren().add(myWebComponent);
        }
        if (myLinkInNewBrowser) {
            initHyperlinkListener();
        }
        Scene scene = new Scene(myPane);
        myPanel.setScene(scene);
        myPanel.setVisible(true);
        updateLaf(LafManager.getInstance().getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo);
    });
    add(myPanel, BorderLayout.CENTER);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
}
Also used : DarculaLookAndFeelInfo(com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo) WebView(javafx.scene.web.WebView) Scene(javafx.scene.Scene) StackPane(javafx.scene.layout.StackPane)

Aggregations

DarculaLookAndFeelInfo (com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo)8 Scene (javafx.scene.Scene)3 WebView (javafx.scene.web.WebView)3 LafManagerImpl (com.intellij.ide.ui.laf.LafManagerImpl)2 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)2 HashMap (java.util.HashMap)2 StackPane (javafx.scene.layout.StackPane)2 LafManager (com.intellij.ide.ui.LafManager)1 DarculaInstaller (com.intellij.ide.ui.laf.darcula.DarculaInstaller)1 ApplicationImpl (com.intellij.openapi.application.impl.ApplicationImpl)1 KeymapManagerImpl (com.intellij.openapi.keymap.impl.KeymapManagerImpl)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 Project (com.intellij.openapi.project.Project)1 DialogWrapper (com.intellij.openapi.ui.DialogWrapper)1 MouseEvent (java.awt.event.MouseEvent)1 MouseWheelEvent (java.awt.event.MouseWheelEvent)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 JFXPanel (javafx.embed.swing.JFXPanel)1