Search in sources :

Example 1 with GeneralSettings

use of com.intellij.ide.GeneralSettings in project intellij-community by JetBrains.

the class BrowserSettingsPanel method apply.

public void apply() {
    GeneralSettings settings = GeneralSettings.getInstance();
    settings.setUseDefaultBrowser(getDefaultBrowser() == DefaultBrowserPolicy.SYSTEM);
    if (alternativeBrowserPathField.isEnabled()) {
        settings.setBrowserPath(alternativeBrowserPathField.getText());
    }
    WebBrowserManager browserManager = WebBrowserManager.getInstance();
    browserManager.setShowBrowserHover(showBrowserHover.isSelected());
    browserManager.defaultBrowserPolicy = getDefaultBrowser();
    browserManager.setList(browsersEditor.apply());
}
Also used : GeneralSettings(com.intellij.ide.GeneralSettings)

Example 2 with GeneralSettings

use of com.intellij.ide.GeneralSettings in project intellij-community by JetBrains.

the class BrowserLauncherAppless method browse.

public void browse(@NotNull URI uri, @Nullable Project project) {
    LOG.debug("Launch browser: [" + uri + "]");
    GeneralSettings settings = getGeneralSettingsInstance();
    if (settings.isUseDefaultBrowser()) {
        boolean tryToUseCli = true;
        if (isDesktopActionSupported(Desktop.Action.BROWSE)) {
            try {
                Desktop.getDesktop().browse(uri);
                LOG.debug("Browser launched using JDK 1.6 API");
                return;
            } catch (Exception e) {
                LOG.warn("Error while using Desktop API, fallback to CLI", e);
                // if "No application knows how to open", then we must not try to use OS open
                tryToUseCli = !e.getMessage().contains("Error code: -10814");
            }
        }
        if (tryToUseCli) {
            List<String> command = getDefaultBrowserCommand();
            if (command != null) {
                doLaunch(uri.toString(), command, null, project, ArrayUtil.EMPTY_STRING_ARRAY, null);
                return;
            }
        }
    }
    browseUsingNotSystemDefaultBrowserPolicy(uri, settings, project);
}
Also used : GeneralSettings(com.intellij.ide.GeneralSettings) ExecutionException(com.intellij.execution.ExecutionException) IOException(java.io.IOException)

Example 3 with GeneralSettings

use of com.intellij.ide.GeneralSettings in project intellij-community by JetBrains.

the class DaemonRespondToChangesTest method testDaemonIgnoresFrameDeactivation.

public void testDaemonIgnoresFrameDeactivation() throws Throwable {
    // return default value to avoid unnecessary save
    DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true);
    String text = "class S { ArrayList<caret>XXX x;}";
    configureByText(StdFileTypes.JAVA, text);
    highlightErrors();
    GeneralSettings settings = GeneralSettings.getInstance();
    ApplicationEx application = ApplicationManagerEx.getApplicationEx();
    boolean frameSave = settings.isSaveOnFrameDeactivation();
    boolean appSave = application.isDoNotSave();
    settings.setSaveOnFrameDeactivation(true);
    application.doNotSave(false);
    try {
        SaveAndSyncHandlerImpl.doSaveDocumentsAndProjectsAndApp();
        checkDaemonReaction(false, SaveAndSyncHandlerImpl::doSaveDocumentsAndProjectsAndApp);
    } finally {
        application.doNotSave(appSave);
        settings.setSaveOnFrameDeactivation(frameSave);
    }
}
Also used : ApplicationEx(com.intellij.openapi.application.ex.ApplicationEx) SaveAndSyncHandlerImpl(com.intellij.ide.SaveAndSyncHandlerImpl) GeneralSettings(com.intellij.ide.GeneralSettings)

Example 4 with GeneralSettings

use of com.intellij.ide.GeneralSettings in project intellij-community by JetBrains.

the class ProjectUtil method confirmOpenNewProject.

/**
   * @return {@link com.intellij.ide.GeneralSettings#OPEN_PROJECT_SAME_WINDOW}
   *         {@link com.intellij.ide.GeneralSettings#OPEN_PROJECT_NEW_WINDOW}
   *         {@link com.intellij.openapi.ui.Messages#CANCEL} - if user canceled the dialog
   * @param isNewProject
   */
public static int confirmOpenNewProject(boolean isNewProject) {
    final GeneralSettings settings = GeneralSettings.getInstance();
    int confirmOpenNewProject = ApplicationManager.getApplication().isUnitTestMode() ? GeneralSettings.OPEN_PROJECT_NEW_WINDOW : settings.getConfirmOpenNewProject();
    if (confirmOpenNewProject == GeneralSettings.OPEN_PROJECT_ASK) {
        if (isNewProject) {
            int exitCode = Messages.showYesNoDialog(IdeBundle.message("prompt.open.project.in.new.frame"), IdeBundle.message("title.new.project"), IdeBundle.message("button.existingframe"), IdeBundle.message("button.newframe"), Messages.getQuestionIcon(), new ProjectNewWindowDoNotAskOption());
            return exitCode == Messages.YES ? GeneralSettings.OPEN_PROJECT_SAME_WINDOW : GeneralSettings.OPEN_PROJECT_NEW_WINDOW;
        } else {
            int exitCode = Messages.showYesNoCancelDialog(IdeBundle.message("prompt.open.project.in.new.frame"), IdeBundle.message("title.open.project"), IdeBundle.message("button.existingframe"), IdeBundle.message("button.newframe"), CommonBundle.getCancelButtonText(), Messages.getQuestionIcon(), new ProjectNewWindowDoNotAskOption());
            return exitCode == Messages.YES ? GeneralSettings.OPEN_PROJECT_SAME_WINDOW : exitCode == Messages.NO ? GeneralSettings.OPEN_PROJECT_NEW_WINDOW : Messages.CANCEL;
        }
    }
    return confirmOpenNewProject;
}
Also used : GeneralSettings(com.intellij.ide.GeneralSettings)

Example 5 with GeneralSettings

use of com.intellij.ide.GeneralSettings in project intellij-community by JetBrains.

the class TipPanel method prevTip.

public void prevTip() {
    if (myTips.size() == 0) {
        myBrowser.setText(IdeBundle.message("error.tips.not.found", ApplicationNamesInfo.getInstance().getFullProductName()));
        return;
    }
    final GeneralSettings settings = GeneralSettings.getInstance();
    int lastTip = settings.getLastTip();
    final TipAndTrickBean tip;
    lastTip--;
    if (lastTip <= 0) {
        tip = myTips.get(myTips.size() - 1);
        lastTip = myTips.size();
    } else {
        tip = myTips.get(lastTip - 1);
    }
    setTip(tip, lastTip, myBrowser, settings);
}
Also used : GeneralSettings(com.intellij.ide.GeneralSettings)

Aggregations

GeneralSettings (com.intellij.ide.GeneralSettings)8 ExecutionException (com.intellij.execution.ExecutionException)1 SaveAndSyncHandlerImpl (com.intellij.ide.SaveAndSyncHandlerImpl)1 ApplicationEx (com.intellij.openapi.application.ex.ApplicationEx)1 IOException (java.io.IOException)1