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);
}
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();
}
}
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);
}
}
}
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;
}
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);
}
Aggregations