diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectJdksConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectJdksConfigurable.java index af9991e52262..a717cadac336 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectJdksConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectJdksConfigurable.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -22,7 +22,6 @@ */ package com.intellij.openapi.roots.ui.configuration; -import com.intellij.ide.util.PropertiesComponent; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.openapi.options.ConfigurationException; @@ -37,9 +36,9 @@ import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel; import com.intellij.openapi.ui.MasterDetailsComponent; import com.intellij.openapi.ui.MasterDetailsStateService; import com.intellij.openapi.ui.NamedConfigurable; -import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.util.Conditions; import com.intellij.openapi.util.Ref; +import com.intellij.ui.JBSplitter; import com.intellij.ui.TreeSpeedSearch; import com.intellij.util.Consumer; import com.intellij.util.IconUtil; @@ -53,11 +52,8 @@ import java.awt.*; import java.util.*; public class ProjectJdksConfigurable extends MasterDetailsComponent { - private final ProjectSdksModel myProjectJdksModel; private final Project myProject; - @NonNls - private static final String SPLITTER_PROPORTION = "project.jdk.splitter"; public ProjectJdksConfigurable(Project project) { this(project, ProjectStructureConfigurable.getInstance(project).getProjectJdksModel()); @@ -107,27 +103,17 @@ public class ProjectJdksConfigurable extends MasterDetailsComponent { addNode(new MyNode(configurable), myRoot); } selectJdk(myProjectJdksModel.getProjectSdk()); //restore selection - final String value = PropertiesComponent.getInstance().getValue(SPLITTER_PROPORTION); - if (value != null) { - try { - final Splitter splitter = extractSplitter(); - if (splitter != null) { - (splitter).setProportion(Float.parseFloat(value)); - } - } - catch (NumberFormatException e) { - //do not set proportion - } + + JBSplitter splitter = extractSplitter(); + if (splitter != null) { + splitter.setAndLoadSplitterProportionKey("project.jdk.splitter"); } } @Nullable - private Splitter extractSplitter() { + private JBSplitter extractSplitter() { final Component[] components = myWholePanel.getComponents(); - if (components.length == 1 && components[0] instanceof Splitter) { - return (Splitter)components[0]; - } - return null; + return components.length == 1 && components[0] instanceof JBSplitter ? (JBSplitter)components[0] : null; } @Override @@ -170,10 +156,6 @@ public class ProjectJdksConfigurable extends MasterDetailsComponent { @Override public void disposeUIResources() { - final Splitter splitter = extractSplitter(); - if (splitter != null) { - PropertiesComponent.getInstance().setValue(SPLITTER_PROPORTION, String.valueOf(splitter.getProportion())); - } myProjectJdksModel.disposeUIResources(); super.disposeUIResources(); } diff --git a/java/java-impl/src/com/intellij/unscramble/UnscrambleDialog.java b/java/java-impl/src/com/intellij/unscramble/UnscrambleDialog.java index 3773b8d5f5f1..124557bbc7cc 100644 --- a/java/java-impl/src/com/intellij/unscramble/UnscrambleDialog.java +++ b/java/java-impl/src/com/intellij/unscramble/UnscrambleDialog.java @@ -180,6 +180,7 @@ public class UnscrambleDialog extends DialogWrapper { return selectedUnscrambler; } + @NotNull public static List getSavedLogFileUrls() { final List res = new ArrayList(); final String savedUrl = PropertiesComponent.getInstance().getValue(PROPERTY_LOG_FILE_HISTORY_URLS); @@ -254,21 +255,16 @@ public class UnscrambleDialog extends DialogWrapper { public void dispose() { if (isOK()){ final List list = myLogFile.getHistory(); - PropertiesComponent.getInstance().setValue(PROPERTY_LOG_FILE_HISTORY_URLS, StringUtil.join(list, ":::")); + PropertiesComponent.getInstance().setValue(PROPERTY_LOG_FILE_HISTORY_URLS, list.isEmpty() ? null : StringUtil.join(list, ":::"), null); UnscrambleSupport selectedUnscrambler = getSelectedUnscrambler(); - saveProperty(PROPERTY_UNSCRAMBLER_NAME_USED, selectedUnscrambler == null ? null : selectedUnscrambler.getPresentableName()); - - saveProperty(PROPERTY_LOG_FILE_LAST_URL, myLogFile.getText()); + PropertiesComponent.getInstance().setValue(PROPERTY_UNSCRAMBLER_NAME_USED, selectedUnscrambler == null ? null : selectedUnscrambler.getPresentableName(), null); + PropertiesComponent.getInstance().setValue(PROPERTY_LOG_FILE_LAST_URL, StringUtil.nullize(myLogFile.getText()), null); } super.dispose(); } - private void saveProperty(String name, String value) { - PropertiesComponent.getInstance().setValue(name, value); - PropertiesComponent.getInstance(myProject).setValue(name, value); - } - - private String getPropertyValue(String name) { + @Nullable + private String getPropertyValue(@NotNull String name) { String projectValue = PropertiesComponent.getInstance(myProject).getValue(name); if (projectValue != null) { return projectValue; @@ -294,7 +290,6 @@ public class UnscrambleDialog extends DialogWrapper { String text = myStacktraceEditorPanel.getText(); myStacktraceEditorPanel.setText(normalizeText(text)); } - } public static String normalizeText(@NonNls String text) { diff --git a/java/java-tests/testSrc/com/intellij/execution/impl/RunConfigurableTest.java b/java/java-tests/testSrc/com/intellij/execution/impl/RunConfigurableTest.java index 847dc0f64d64..b89cd1447653 100644 --- a/java/java-tests/testSrc/com/intellij/execution/impl/RunConfigurableTest.java +++ b/java/java-tests/testSrc/com/intellij/execution/impl/RunConfigurableTest.java @@ -20,6 +20,7 @@ import com.intellij.execution.configurations.ConfigurationType; import com.intellij.execution.configurations.UnknownConfigurationType; import com.intellij.execution.junit.JUnitConfigurationType; import com.intellij.ide.util.PropertiesComponent; +import com.intellij.openapi.project.Project; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.Trinity; @@ -196,7 +197,8 @@ public class RunConfigurableTest extends LightIdeaTestCase { } private static RunManagerImpl createRunManager(Element element) throws InvalidDataException { - RunManagerImpl runManager = new RunManagerImpl(getProject(), PropertiesComponent.getInstance()); + Project project = getProject(); + RunManagerImpl runManager = new RunManagerImpl(project, PropertiesComponent.getInstance(project)); runManager.initializeConfigurationTypes(new ConfigurationType[]{ApplicationConfigurationType.getInstance(), JUnitConfigurationType.getInstance(), UnknownConfigurationType.INSTANCE}); runManager.loadState(element); diff --git a/platform/core-api/src/com/intellij/ide/util/PropertiesComponent.java b/platform/core-api/src/com/intellij/ide/util/PropertiesComponent.java index c97bab4d16a1..38378bb88e46 100644 --- a/platform/core-api/src/com/intellij/ide/util/PropertiesComponent.java +++ b/platform/core-api/src/com/intellij/ide/util/PropertiesComponent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -17,6 +17,7 @@ package com.intellij.ide.util; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtilRt; import com.intellij.util.ObjectUtils; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -25,6 +26,10 @@ import org.jetbrains.annotations.Nullable; import java.lang.reflect.Field; /** + * Roaming is disabled for PropertiesComponent, so, use it only and only for temporary non-roamable properties. + * + * See http://www.jetbrains.org/intellij/sdk/docs/basics/persisting_state_of_components.html "Using PropertiesComponent for Simple non-roamable Persistence" + * * @author max * @author Konstantin Bulenkov */ @@ -36,12 +41,25 @@ public abstract class PropertiesComponent { @Nullable public abstract String getValue(@NonNls String name); - public abstract void setValue(@NonNls String name, String value); + /** + * @deprecated Use {@link #setValue(String, String, String)} to avoid write defaults. + */ + public abstract void setValue(@NotNull String name, String value); /** * Set value or unset if equals to default value */ - public abstract void setValue(@NotNull String name, @NotNull String value, @NotNull String defaultValue); + public abstract void setValue(@NotNull String name, @Nullable String value, @Nullable String defaultValue); + + /** + * Set value or unset if equals to default value + */ + public abstract void setValue(@NotNull String name, float value, float defaultValue); + + /** + * Set value or unset if equals to default value + */ + public abstract void setValue(@NotNull String name, int value, int defaultValue); @Nullable public abstract String[] getValues(@NonNls String name); @@ -73,11 +91,7 @@ public abstract class PropertiesComponent { } public final int getOrInitInt(@NonNls String name, int defaultValue) { - try { - return Integer.parseInt(getValue(name)); - } catch (NumberFormatException e) { - return defaultValue; - } + return StringUtilRt.parseInt(name, defaultValue); } public final long getOrInitLong(@NonNls String name, long defaultValue) { diff --git a/platform/core-impl/src/com/intellij/ide/PowerSaveMode.java b/platform/core-impl/src/com/intellij/ide/PowerSaveMode.java index 9860b4a30ea0..218bd40fd4a4 100644 --- a/platform/core-impl/src/com/intellij/ide/PowerSaveMode.java +++ b/platform/core-impl/src/com/intellij/ide/PowerSaveMode.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -41,7 +41,7 @@ public class PowerSaveMode { if (instance.myEnabled != value) { instance.myEnabled = value; instance.myBus.syncPublisher(TOPIC).powerSaveStateChanged(); - PropertiesComponent.getInstance().setValue(POWER_SAVE_MODE, String.valueOf(value)); + PropertiesComponent.getInstance().setValue(POWER_SAVE_MODE, String.valueOf(value), "false"); } } diff --git a/platform/core-impl/src/com/intellij/ide/util/PropertiesComponentImpl.java b/platform/core-impl/src/com/intellij/ide/util/PropertiesComponentImpl.java index 396407696748..4a470a37eec7 100644 --- a/platform/core-impl/src/com/intellij/ide/util/PropertiesComponentImpl.java +++ b/platform/core-impl/src/com/intellij/ide/util/PropertiesComponentImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -76,8 +76,8 @@ public class PropertiesComponentImpl extends PropertiesComponent implements Pers } @Override - public void setValue(@NotNull String name, @NotNull String value, @NotNull String defaultValue) { - if (value.equals(defaultValue)) { + public void setValue(@NotNull String name, @Nullable String value, @Nullable String defaultValue) { + if (value == null || value.equals(defaultValue)) { myMap.remove(name); } else { @@ -85,6 +85,26 @@ public class PropertiesComponentImpl extends PropertiesComponent implements Pers } } + @Override + public void setValue(@NotNull String name, float value, float defaultValue) { + if (value == defaultValue) { + myMap.remove(name); + } + else { + myMap.put(name, String.valueOf(value)); + } + } + + @Override + public void setValue(@NotNull String name, int value, int defaultValue) { + if (value == defaultValue) { + myMap.remove(name); + } + else { + myMap.put(name, String.valueOf(value)); + } + } + @Override public void unsetValue(String name) { myMap.remove(name); diff --git a/platform/lang-impl/src/com/intellij/execution/RunManagerConfig.java b/platform/lang-impl/src/com/intellij/execution/RunManagerConfig.java index 9277b7b36e22..b305ef9f2cc3 100644 --- a/platform/lang-impl/src/com/intellij/execution/RunManagerConfig.java +++ b/platform/lang-impl/src/com/intellij/execution/RunManagerConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -16,37 +16,32 @@ package com.intellij.execution; -import com.intellij.execution.impl.RunManagerImpl; -import com.intellij.execution.util.StoringPropertyContainer; import com.intellij.ide.util.PropertiesComponent; +import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.NonNls; public class RunManagerConfig { public static final String MAKE = ExecutionBundle.message("before.run.property.make"); - private final StoringPropertyContainer myProperties; - private final PropertiesComponent myPropertiesComponent; + public static final int MIN_RECENT_LIMIT = 0; + public static final int DEFAULT_RECENT_LIMIT = 5; + + private final PropertiesComponent myPropertiesComponent; + @NonNls private static final String RECENTS_LIMIT = "recentsLimit"; @NonNls private static final String RESTART_REQUIRES_CONFIRMATION = "restartRequiresConfirmation"; @NonNls private static final String STOP_INCOMPATIBLE_REQUIRES_CONFIRMATION = "stopIncompatibleRequiresConfirmation"; - public RunManagerConfig(PropertiesComponent propertiesComponent, - RunManagerImpl manager) { + public RunManagerConfig(PropertiesComponent propertiesComponent) { myPropertiesComponent = propertiesComponent; - myProperties = new StoringPropertyContainer("RunManagerConfig.", propertiesComponent); } public int getRecentsLimit() { - try { - return Math.max(MIN_RECENT_LIMIT, Integer.valueOf(myPropertiesComponent.getOrInit(RECENTS_LIMIT, "5")).intValue()); - } - catch (NumberFormatException e) { - return 5; - } + return Math.max(MIN_RECENT_LIMIT, StringUtil.parseInt(myPropertiesComponent.getValue(RECENTS_LIMIT), DEFAULT_RECENT_LIMIT)); } public void setRecentsLimit(int recentsLimit) { - myPropertiesComponent.setValue(RECENTS_LIMIT, Integer.toString(recentsLimit)); + myPropertiesComponent.setValue(RECENTS_LIMIT, recentsLimit, DEFAULT_RECENT_LIMIT); } public boolean isRestartRequiresConfirmation() { @@ -54,7 +49,7 @@ public class RunManagerConfig { } public void setRestartRequiresConfirmation(boolean restartRequiresConfirmation) { - myPropertiesComponent.setValue(RESTART_REQUIRES_CONFIRMATION, String.valueOf(restartRequiresConfirmation)); + myPropertiesComponent.setValue(RESTART_REQUIRES_CONFIRMATION, String.valueOf(restartRequiresConfirmation), "true"); } public boolean isStopIncompatibleRequiresConfirmation() { diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunConfigurable.java b/platform/lang-impl/src/com/intellij/execution/impl/RunConfigurable.java index 29ae43243dd0..9299557f8229 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunConfigurable.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunConfigurable.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -28,7 +28,6 @@ import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.options.*; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.ui.popup.ListPopup; import com.intellij.openapi.ui.popup.ListPopupStep; @@ -45,7 +44,6 @@ import com.intellij.ui.treeStructure.Tree; import com.intellij.util.ArrayUtilRt; import com.intellij.util.IconUtil; import com.intellij.util.PlatformIcons; -import com.intellij.util.config.StorageAccessors; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.Convertor; import com.intellij.util.containers.HashMap; @@ -78,7 +76,7 @@ class RunConfigurable extends BaseConfigurable { private static final Icon REMOVE_ICON = IconUtil.getRemoveIcon(); private static final Icon SHARED_ICON = AllIcons.Nodes.Shared; private static final Icon NON_SHARED_ICON = EmptyIcon.ICON_16; - @NonNls private static final String DIVIDER_PROPORTION = "dividerProportion"; + @NonNls private static final Object DEFAULTS = new Object() { @Override public String toString() { @@ -94,9 +92,8 @@ class RunConfigurable extends BaseConfigurable { final MyTreeModel myTreeModel = new MyTreeModel(myRoot); final Tree myTree = new Tree(myTreeModel); private final JPanel myRightPanel = new JPanel(new BorderLayout()); - private final Splitter mySplitter = new Splitter(false); + private final JBSplitter mySplitter = new JBSplitter("RunConfigurable.dividerProportion", 0.3f); private JPanel myWholePanel; - private final StorageAccessors myProperties = StorageAccessors.createGlobal("RunConfigurable"); private Configurable mySelectedConfigurable = null; private static final Logger LOG = Logger.getInstance("#com.intellij.execution.impl.RunConfigurable"); private final JTextField myRecentsLimit = new JTextField("5", 2); @@ -614,6 +611,7 @@ class RunConfigurable extends BaseConfigurable { } myWholePanel = new JPanel(new BorderLayout()); + mySplitter.setFirstComponent(createLeftPanel()); mySplitter.setSecondComponent(myRightPanel); myWholePanel.add(mySplitter, BorderLayout.CENTER); @@ -625,8 +623,6 @@ class RunConfigurable extends BaseConfigurable { d.height = Math.max(d.height, 600); myWholePanel.setPreferredSize(d); - mySplitter.setProportion(myProperties.getFloat(DIVIDER_PROPORTION, 0.3f)); - return myWholePanel; } @@ -908,7 +904,6 @@ class RunConfigurable extends BaseConfigurable { } }); myRightPanel.removeAll(); - myProperties.setFloat(DIVIDER_PROPORTION, mySplitter.getProportion()); mySplitter.dispose(); } diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java index d0ea71ac35be..1878d6d46509 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java @@ -95,9 +95,8 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo private final EventDispatcher myDispatcher = EventDispatcher.create(RunManagerListener.class); - public RunManagerImpl(final Project project, - PropertiesComponent propertiesComponent) { - myConfig = new RunManagerConfig(propertiesComponent, this); + public RunManagerImpl(@NotNull Project project, @NotNull PropertiesComponent propertiesComponent) { + myConfig = new RunManagerConfig(propertiesComponent); myProject = project; initializeConfigurationTypes(ConfigurationType.CONFIGURATION_TYPE_EP.getExtensions()); diff --git a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/AllFileTemplatesConfigurable.java b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/AllFileTemplatesConfigurable.java index bc3638498dbf..54abae8843de 100644 --- a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/AllFileTemplatesConfigurable.java +++ b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/AllFileTemplatesConfigurable.java @@ -646,7 +646,7 @@ public class AllFileTemplatesConfigurable implements SearchableConfigurable, Con public void disposeUIResources() { if (myCurrentTab != null) { final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(); - propertiesComponent.setValue(CURRENT_TAB, myCurrentTab.getTitle()); + propertiesComponent.setValue(CURRENT_TAB, myCurrentTab.getTitle(), TEMPLATES_TITLE); final FileTemplate template = myCurrentTab.getSelectedTemplate(); if (template != null) { propertiesComponent.setValue(SELECTED_TEMPLATE, template.getName()); diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java index 6f36b1704a29..d456b06c70d3 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java @@ -41,7 +41,6 @@ import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.JDOMUtil; @@ -65,7 +64,6 @@ import com.intellij.ui.*; import com.intellij.ui.components.JBLabel; import com.intellij.util.Alarm; import com.intellij.util.Function; -import com.intellij.util.config.StorageAccessors; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.Convertor; import com.intellij.util.containers.Queue; @@ -105,13 +103,13 @@ public class SingleInspectionProfilePanel extends JPanel { @NonNls private static final String INSPECTION_FILTER_HISTORY = "INSPECTION_FILTER_HISTORY"; private static final String UNDER_CONSTRUCTION = InspectionsBundle.message("inspection.tool.description.under.construction.text"); @NonNls private static final String EMPTY_HTML = ""; - @NonNls private static final String VERTICAL_DIVIDER_PROPORTION = "VERTICAL_DIVIDER_PROPORTION"; - @NonNls private static final String HORIZONTAL_DIVIDER_PROPORTION = "HORIZONTAL_DIVIDER_PROPORTION"; + + private static final float DIVIDER_PROPORTION_DEFAULT = 0.5f; + private final List myInitialToolDescriptors = new ArrayList(); private final InspectionConfigTreeNode myRoot = new InspectionConfigTreeNode(InspectionsBundle.message("inspection.root.node.title")); private final Alarm myAlarm = new Alarm(); - private final StorageAccessors myProperties = StorageAccessors.createGlobal("SingleInspectionProfilePanel"); private final InspectionProjectProfileManager myProjectProfileManager; @NotNull private Profile myOriginal; private InspectionProfileImpl mySelectedProfile; @@ -132,8 +130,8 @@ public class SingleInspectionProfilePanel extends JPanel { private String myCurrentProfileName; private boolean myIsInRestore = false; private boolean myShareProfile; - private Splitter myRightSplitter; - private Splitter myMainSplitter; + private JBSplitter myRightSplitter; + private JBSplitter myMainSplitter; private String[] myInitialScopesOrder; private Disposable myDisposable = new Disposable() { @@ -1056,8 +1054,6 @@ public class SingleInspectionProfilePanel extends JPanel { if (myInspectionProfilePanel == null) { return; } - myProperties.setFloat(VERTICAL_DIVIDER_PROPORTION, myMainSplitter.getProportion()); - myProperties.setFloat(HORIZONTAL_DIVIDER_PROPORTION, myRightSplitter.getProportion()); myAlarm.cancelAllRequests(); myProfileFilter.dispose(); if (mySelectedProfile != null) { @@ -1085,9 +1081,8 @@ public class SingleInspectionProfilePanel extends JPanel { new Insets(2, 0, 0, 0))); descriptionPanel.add(ScrollPaneFactory.createScrollPane(myBrowser), BorderLayout.CENTER); - myRightSplitter = new Splitter(true); + myRightSplitter = new JBSplitter(true, "SingleInspectionProfilePanel.HORIZONTAL_DIVIDER_PROPORTION", DIVIDER_PROPORTION_DEFAULT); myRightSplitter.setFirstComponent(descriptionPanel); - myRightSplitter.setProportion(myProperties.getFloat(HORIZONTAL_DIVIDER_PROPORTION, 0.5f)); myOptionsPanel = new JPanel(new GridBagLayout()); initOptionsAndDescriptionPanel(); @@ -1102,7 +1097,8 @@ public class SingleInspectionProfilePanel extends JPanel { northPanel.add(myProfileFilter, new GridBagConstraints(0, 0, 1, 1, 0.5, 1, GridBagConstraints.BASELINE_TRAILING, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); northPanel.add(createTreeToolbarPanel().getComponent(), new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); - myMainSplitter = new Splitter(false, myProperties.getFloat(VERTICAL_DIVIDER_PROPORTION, 0.5f), 0.01f, 0.99f); + myMainSplitter = new JBSplitter(false, DIVIDER_PROPORTION_DEFAULT, 0.01f, 0.99f); + myMainSplitter.setSplitterProportionKey("SingleInspectionProfilePanel.VERTICAL_DIVIDER_PROPORTION"); myMainSplitter.setFirstComponent(tree); myMainSplitter.setSecondComponent(myRightSplitter); myMainSplitter.setHonorComponentsMinimumSize(false); diff --git a/platform/lang-impl/testSources/com/intellij/execution/impl/ModuleRunConfigurationManagerTest.java b/platform/lang-impl/testSources/com/intellij/execution/impl/ModuleRunConfigurationManagerTest.java index 7b3218210b62..d40f19f327ad 100644 --- a/platform/lang-impl/testSources/com/intellij/execution/impl/ModuleRunConfigurationManagerTest.java +++ b/platform/lang-impl/testSources/com/intellij/execution/impl/ModuleRunConfigurationManagerTest.java @@ -131,7 +131,7 @@ public class ModuleRunConfigurationManagerTest extends LightPlatformTestCase { private final class MyRunManagerImpl extends RunManagerImpl { public MyRunManagerImpl() { - super(LightPlatformTestCase.getProject(), PropertiesComponent.getInstance()); + super(LightPlatformTestCase.getProject(), PropertiesComponent.getInstance(LightPlatformTestCase.getProject())); } @NotNull diff --git a/platform/platform-api/src/com/intellij/ui/JBSplitter.java b/platform/platform-api/src/com/intellij/ui/JBSplitter.java index 5f01602d92c5..5fd2be90001e 100644 --- a/platform/platform-api/src/com/intellij/ui/JBSplitter.java +++ b/platform/platform-api/src/com/intellij/ui/JBSplitter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -33,25 +33,47 @@ public class JBSplitter extends Splitter { */ @Nullable private String mySplitterProportionKey = null; + private final float myDefaultProportion; public JBSplitter() { super(); + + myDefaultProportion = 0.5f; + } + + public JBSplitter(@NotNull String proportionKey, float defaultProportion) { + this(false, proportionKey, defaultProportion); + } + + public JBSplitter(boolean vertical, @NotNull String proportionKey, float defaultProportion) { + super(vertical, defaultProportion); + + mySplitterProportionKey = proportionKey; + myDefaultProportion = defaultProportion; } public JBSplitter(boolean vertical) { super(vertical); + + myDefaultProportion = 0.5f; } public JBSplitter(boolean vertical, float proportion) { super(vertical, proportion); + + myDefaultProportion = proportion; } public JBSplitter(float proportion) { super(false, proportion); + + myDefaultProportion = proportion; } public JBSplitter(boolean vertical, float proportion, float minProp, float maxProp) { super(vertical, proportion, minProp, maxProp); + + myDefaultProportion = proportion; } /** @@ -95,14 +117,14 @@ public class JBSplitter extends Splitter { } protected void loadProportion() { - if (! StringUtil.isEmpty(mySplitterProportionKey)) { + if (!StringUtil.isEmpty(mySplitterProportionKey)) { setProportion(PropertiesComponent.getInstance().getFloat(mySplitterProportionKey, myProportion)); } } protected void saveProportion() { - if (! StringUtil.isEmpty(mySplitterProportionKey)) { - PropertiesComponent.getInstance().setValue(mySplitterProportionKey, String.valueOf(myProportion)); + if (!StringUtil.isEmpty(mySplitterProportionKey)) { + PropertiesComponent.getInstance().setValue(mySplitterProportionKey, myProportion, myDefaultProportion); } } } diff --git a/platform/platform-api/src/com/intellij/ui/OnePixelSplitter.java b/platform/platform-api/src/com/intellij/ui/OnePixelSplitter.java index 57e01129f41d..4400a746da31 100644 --- a/platform/platform-api/src/com/intellij/ui/OnePixelSplitter.java +++ b/platform/platform-api/src/com/intellij/ui/OnePixelSplitter.java @@ -18,6 +18,7 @@ package com.intellij.ui; import com.intellij.openapi.ui.Divider; import com.intellij.openapi.ui.OnePixelDivider; import com.intellij.util.Producer; +import org.jetbrains.annotations.NotNull; import java.awt.*; @@ -42,6 +43,12 @@ public class OnePixelSplitter extends JBSplitter { init(); } + public OnePixelSplitter(@NotNull String proportionKey, float defaultProportion) { + super(proportionKey, defaultProportion); + + init(); + } + public OnePixelSplitter(float proportion) { super(proportion); init(); diff --git a/platform/platform-api/src/com/intellij/util/config/Storage.java b/platform/platform-api/src/com/intellij/util/config/Storage.java index a2ab59baf11f..c83e54c1f2f4 100644 --- a/platform/platform-api/src/com/intellij/util/config/Storage.java +++ b/platform/platform-api/src/com/intellij/util/config/Storage.java @@ -24,6 +24,11 @@ import java.util.Collections; import java.util.Iterator; import java.util.Map; +@Deprecated +/** + * @deprecated Use {@link PropertiesComponent} directly. + * @see {@link JBSplitter} + */ public interface Storage { void put(String key, String value); String get(String key); diff --git a/platform/platform-api/src/com/intellij/util/config/StorageAccessors.java b/platform/platform-api/src/com/intellij/util/config/StorageAccessors.java index 0454b2c41cc1..6f064a36ba78 100644 --- a/platform/platform-api/src/com/intellij/util/config/StorageAccessors.java +++ b/platform/platform-api/src/com/intellij/util/config/StorageAccessors.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -15,12 +15,17 @@ */ package com.intellij.util.config; +import com.intellij.ide.util.PropertiesComponent; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +@SuppressWarnings("unused") +@Deprecated /** - * @author dyoma + * @deprecated Use {@link PropertiesComponent} directly. + * @see {@link JBSplitter} */ public class StorageAccessors { private final Storage myStorage; @@ -29,12 +34,10 @@ public class StorageAccessors { myStorage = storage; } - public static StorageAccessors createGlobal(@NonNls String prefix) { + @NotNull + public static StorageAccessors createGlobal(@NotNull @NonNls String prefix) { Application application = ApplicationManager.getApplication(); - Storage storage; - if (application != null) storage = new Storage.PropertiesComponentStorage(prefix + "."); - else storage = new Storage.MapStorage(); - return new StorageAccessors(storage); + return new StorageAccessors(application == null ? new Storage.MapStorage() : new Storage.PropertiesComponentStorage(prefix + ".")); } public float getFloat(@NonNls String id, float defaultValue) { diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java b/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java index d9e7b50403ea..686c20b4f0b9 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -99,7 +99,7 @@ public class ChooseComponentsToExportDialog extends DialogWrapper { myPathPanel = new FieldPanel(IdeBundle.message("editbox.export.settings.to"), null, browseAction, null); - String exportPath = PropertiesComponent.getInstance().getOrInit("export.settings.path", DEFAULT_PATH); + String exportPath = PropertiesComponent.getInstance().getValue("export.settings.path", DEFAULT_PATH); myPathPanel.setText(exportPath); myPathPanel.setChangeListener(new Runnable() { @Override @@ -143,7 +143,7 @@ public class ChooseComponentsToExportDialog extends DialogWrapper { @Override protected void doOKAction() { - PropertiesComponent.getInstance().setValue("export.settings.path", myPathPanel.getText()); + PropertiesComponent.getInstance().setValue("export.settings.path", myPathPanel.getText(), DEFAULT_PATH); super.doOKAction(); } diff --git a/platform/testRunner/src/com/intellij/execution/testframework/autotest/AutoTestManager.java b/platform/testRunner/src/com/intellij/execution/testframework/autotest/AutoTestManager.java index cb7cc00f0276..bcd0388cb4bd 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/autotest/AutoTestManager.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/autotest/AutoTestManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -35,6 +35,7 @@ import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Key; +import com.intellij.openapi.util.text.StringUtilRt; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.content.Content; import com.intellij.util.Consumer; @@ -48,6 +49,8 @@ import javax.swing.*; */ public class AutoTestManager { private static final String AUTO_TEST_MANAGER_DELAY = "auto.test.manager.delay"; + private static final int AUTO_TEST_MANAGER_DELAY_DEFAULT = 3000; + private static final Key ON_TERMINATION_RESTARTER_KEY = Key.create("auto.test.manager.on.termination.restarter"); private static final Key EXECUTION_ENVIRONMENT_KEY = Key.create("auto.test.manager.execution.environment"); @@ -62,7 +65,7 @@ public class AutoTestManager { public AutoTestManager(@NotNull Project project) { myProject = project; - myDelayMillis = PropertiesComponent.getInstance(project).getOrInitInt(AUTO_TEST_MANAGER_DELAY, 3000); + myDelayMillis = StringUtilRt.parseInt(PropertiesComponent.getInstance(project).getValue(AUTO_TEST_MANAGER_DELAY), AUTO_TEST_MANAGER_DELAY_DEFAULT); myDocumentWatcher = createWatcher(); } @@ -226,6 +229,6 @@ public class AutoTestManager { if (hasEnabledAutoTests()) { myDocumentWatcher.activate(); } - PropertiesComponent.getInstance(myProject).setValue(AUTO_TEST_MANAGER_DELAY, String.valueOf(myDelayMillis)); + PropertiesComponent.getInstance(myProject).setValue(AUTO_TEST_MANAGER_DELAY, myDelayMillis, AUTO_TEST_MANAGER_DELAY_DEFAULT); } } diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntSetPanel.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntSetPanel.java index 86506e642d84..4b2694018844 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntSetPanel.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntSetPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -27,8 +27,8 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.util.Factory; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.ui.JBSplitter; import com.intellij.util.config.AbstractProperty; -import com.intellij.util.config.StorageAccessors; import com.intellij.util.containers.HashMap; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; @@ -93,8 +93,7 @@ public class AntSetPanel { } private static class Form implements AntUIUtil.PropertiesEditor { - private final Splitter mySplitter = new Splitter(false); - private final StorageAccessors myAccessors = StorageAccessors.createGlobal("antConfigurations"); + private final Splitter mySplitter = new JBSplitter("antConfigurations.splitter", 03f); private final RightPanel myRightPanel; private final AnActionListEditor myAnts = new AnActionListEditor(); private final UIPropertyBinding.Composite myBinding = new UIPropertyBinding.Composite(); @@ -110,7 +109,6 @@ public class AntSetPanel { }; public Form(final GlobalAntConfiguration antInstallation) { - mySplitter.setProportion(myAccessors.getFloat("splitter", 0.3f)); mySplitter.setShowDividerControls(true); mySplitter.setFirstComponent(myAnts); myGlobalWorkingProperties = new EditPropertyContainer(antInstallation.getProperties()); diff --git a/plugins/copyright/src/com/maddyhome/idea/copyright/actions/UpdateCopyrightAction.java b/plugins/copyright/src/com/maddyhome/idea/copyright/actions/UpdateCopyrightAction.java index 0e1e1107d896..a6ae84e1f536 100644 --- a/plugins/copyright/src/com/maddyhome/idea/copyright/actions/UpdateCopyrightAction.java +++ b/plugins/copyright/src/com/maddyhome/idea/copyright/actions/UpdateCopyrightAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -45,7 +45,9 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.util.*; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; public class UpdateCopyrightAction extends BaseAnalysisAction { public static final String UPDATE_EXISTING_COPYRIGHTS = "update.existing.copyrights"; @@ -131,7 +133,7 @@ public class UpdateCopyrightAction extends BaseAnalysisAction { @Override protected void analyze(@NotNull final Project project, @NotNull final AnalysisScope scope) { - PropertiesComponent.getInstance().setValue(UPDATE_EXISTING_COPYRIGHTS, String.valueOf(myUpdateExistingCopyrightsCb.isSelected())); + PropertiesComponent.getInstance().setValue(UPDATE_EXISTING_COPYRIGHTS, String.valueOf(myUpdateExistingCopyrightsCb.isSelected()), "true"); final Map preparations = new LinkedHashMap(); Task.Backgroundable task = new Task.Backgroundable(project, "Prepare Copyright...", true) { @Override diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/AssociationsEditor.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/AssociationsEditor.java index 35d23b1fb649..41593b1c1f6d 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/AssociationsEditor.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/AssociationsEditor.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2015 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.intellij.lang.xpath.xslt.associations.impl; import com.intellij.ide.projectView.ProjectViewNode; @@ -15,7 +30,6 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.Progressive; import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.util.Disposer; import com.intellij.psi.PsiFile; import com.intellij.ui.*; @@ -23,12 +37,10 @@ import com.intellij.ui.components.JBList; import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.treeStructure.Tree; import com.intellij.util.IconUtil; -import com.intellij.util.config.StorageAccessors; import com.intellij.util.ui.UIUtil; import icons.XpathIcons; import org.intellij.lang.xpath.xslt.XsltSupport; import org.intellij.lang.xpath.xslt.associations.FileAssociationsManager; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -46,13 +58,10 @@ import java.util.Collections; import java.util.List; class AssociationsEditor { - @NonNls private static final String DIVIDER_PROPORTION = "dividerProportion"; - private JPanel myComponent; private JBList myList; private Tree myTree; - private Splitter mySplitter; - private final StorageAccessors myProperties = StorageAccessors.createGlobal("AssociationsEditor"); + private JBSplitter mySplitter; private final AssociationsModel myListModel; private final TransactionalManager myManager; @@ -109,7 +118,7 @@ class AssociationsEditor { private void initUI() { myComponent = new JPanel(new BorderLayout()); - mySplitter = new Splitter(false, 0.3f); + mySplitter = new JBSplitter("AssociationsEditor.dividerProportion", 0.3f); myComponent.add(mySplitter, BorderLayout.CENTER); JPanel leftPanel = new JPanel(new BorderLayout()); @@ -130,9 +139,6 @@ class AssociationsEditor { .disableUpDownActions().disableAddAction().disableRemoveAction().createPanel(); UIUtil.addBorder(rightPanel, IdeBorderFactory.createTitledBorder("Associated Files", false, new Insets(0, 0, 0, 0))); mySplitter.setSecondComponent(rightPanel); - - final float dividerProportion = myProperties.getFloat(DIVIDER_PROPORTION, 0.3f); - mySplitter.setProportion(dividerProportion); } private void expandTree(DefaultTreeModel newModel) { @@ -191,7 +197,6 @@ class AssociationsEditor { } public void dispose() { - myProperties.setFloat(DIVIDER_PROPORTION, mySplitter.getProportion()); Disposer.dispose(myBuilder); myManager.dispose(); } diff --git a/python/ide/src/com/jetbrains/python/PyIdeCommonOptionsForm.java b/python/ide/src/com/jetbrains/python/PyIdeCommonOptionsForm.java index 254e41a9acc7..e792d4a1f2da 100644 --- a/python/ide/src/com/jetbrains/python/PyIdeCommonOptionsForm.java +++ b/python/ide/src/com/jetbrains/python/PyIdeCommonOptionsForm.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -138,7 +138,7 @@ public class PyIdeCommonOptionsForm implements AbstractPyCommonOptionsForm { storeState(); } private void storeState() { - PropertiesComponent.getInstance().setValue(EXPAND_PROPERTY_KEY, String.valueOf(isExpanded())); + PropertiesComponent.getInstance().setValue(EXPAND_PROPERTY_KEY, String.valueOf(isExpanded()), "true"); } }; myDecorator.setOn(PropertiesComponent.getInstance().getBoolean(EXPAND_PROPERTY_KEY, true)); diff --git a/python/pluginSrc/com/jetbrains/python/run/PyPluginCommonOptionsForm.java b/python/pluginSrc/com/jetbrains/python/run/PyPluginCommonOptionsForm.java index 15f041cfabd9..ee46566b89cc 100644 --- a/python/pluginSrc/com/jetbrains/python/run/PyPluginCommonOptionsForm.java +++ b/python/pluginSrc/com/jetbrains/python/run/PyPluginCommonOptionsForm.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -15,6 +15,7 @@ */ package com.jetbrains.python.run; +import com.intellij.application.options.ModulesComboBox; import com.intellij.execution.configuration.EnvironmentVariablesComponent; import com.intellij.execution.util.PathMappingsComponent; import com.intellij.ide.util.PropertiesComponent; @@ -26,7 +27,6 @@ import com.intellij.openapi.projectRoots.impl.SdkListCellRenderer; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.roots.ui.configuration.ModulesAlphaComparator; -import com.intellij.application.options.ModulesComboBox; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.io.FileUtil; import com.intellij.ui.CollectionComboBoxModel; @@ -110,7 +110,7 @@ public class PyPluginCommonOptionsForm implements AbstractPyCommonOptionsForm { storeState(); } private void storeState() { - PropertiesComponent.getInstance().setValue(EXPAND_PROPERTY_KEY, String.valueOf(isExpanded())); + PropertiesComponent.getInstance().setValue(EXPAND_PROPERTY_KEY, String.valueOf(isExpanded()), "true"); } }; myDecorator.setOn(PropertiesComponent.getInstance().getBoolean(EXPAND_PROPERTY_KEY, true)); diff --git a/xml/impl/src/com/intellij/javaee/DefaultHtmlDoctypeInitialConfigurator.java b/xml/impl/src/com/intellij/javaee/DefaultHtmlDoctypeInitialConfigurator.java index 3483ec35c944..139815188606 100644 --- a/xml/impl/src/com/intellij/javaee/DefaultHtmlDoctypeInitialConfigurator.java +++ b/xml/impl/src/com/intellij/javaee/DefaultHtmlDoctypeInitialConfigurator.java @@ -1,7 +1,23 @@ +/* + * Copyright 2000-2015 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.javaee; import com.intellij.ide.util.PropertiesComponent; import com.intellij.openapi.project.ProjectManager; +import com.intellij.openapi.util.text.StringUtilRt; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; @@ -21,7 +37,7 @@ public class DefaultHtmlDoctypeInitialConfigurator { .setDefaultHtmlDoctype(Html5SchemaProvider.getHtml5SchemaLocation(), projectManager.getDefaultProject()); } // sometimes VFS fails to pick up updated schema contents and we need to force refresh - if (propertiesComponent.getOrInitInt("DefaultHtmlDoctype.Refreshed", 0) < VERSION) { + if (StringUtilRt.parseInt(propertiesComponent.getValue("DefaultHtmlDoctype.Refreshed"), 0) < VERSION) { propertiesComponent.setValue("DefaultHtmlDoctype.Refreshed", Integer.toString(VERSION)); final String schemaUrl = VfsUtilCore.pathToUrl(Html5SchemaProvider.getHtml5SchemaLocation()); final VirtualFile schemaFile = VirtualFileManager.getInstance().findFileByUrl(schemaUrl);