Zen Coding settings migrate to Editor | Smart Keys (IDEA-52619)

This commit is contained in:
Eugene Kudelevsky
2010-03-03 20:37:43 +03:00
parent 6979b6a1fa
commit 0208e273f4
9 changed files with 29 additions and 203 deletions
@@ -290,7 +290,6 @@
<basicWordSelectionFilter implementation="com.intellij.codeInsight.editorActions.XmlBasicWordSelectionFilter"/>
<defaultLiveTemplatesProvider implementation="com.intellij.codeInsight.template.XmlDefaultLiveTemplatesProvider"/>
<customLiveTemplate implementation="com.intellij.codeInsight.template.XmlZenCodingTemplate"/>
<applicationConfigurable implementation="com.intellij.codeInsight.template.ZenCodingSettingsConfigurable"/>
<productivityFeaturesProvider implementation="com.intellij.featureStatistics.XmlProductivityFeatureProvider"/>
<idIndexer filetype="XML" implementationClass="com.intellij.psi.impl.cache.impl.idCache.XmlIdIndexer"/>
@@ -622,6 +622,9 @@
<option name="closing" hit="Automatically insert closing tag" />
<option name="insert" hit="Automatically insert closing tag" />
<option name="tag" hit="Automatically insert closing tag" />
<option name="zen" hit="Enable Zen Coding" />
<option name="enable" hit="Enable Zen Coding" />
<option name="coding" hit="Enable Zen Coding" />
<option name="attributes" hit="Automatically insert required attributes" />
<option name="automatically" hit="Automatically insert required attributes" />
<option name="insert" hit="Automatically insert required attributes" />
@@ -42,6 +42,7 @@ public class WebEditorOptions implements PersistentStateComponent<WebEditorOptio
private boolean myAutomaticallyInsertClosingTag = true;
private boolean myAutomaticallyInsertRequiredAttributes = true;
private boolean myAutomaticallyStartAttribute = true;
private boolean myEnableZenCoding = true;
public static WebEditorOptions getInstance() {
return ServiceManager.getService(WebEditorOptions.class);
@@ -83,10 +84,18 @@ public class WebEditorOptions implements PersistentStateComponent<WebEditorOptio
return myAutomaticallyStartAttribute;
}
public boolean isZenCodingEnabled() {
return myEnableZenCoding;
}
public void setAutomaticallyStartAttribute(final boolean automaticallyStartAttribute) {
myAutomaticallyStartAttribute = automaticallyStartAttribute;
}
public void setEnableZenCoding(boolean enableZenCoding) {
myEnableZenCoding = enableZenCoding;
}
@NotNull
public File[] getExportFiles() {
return new File[]{PathManager.getOptionsFile("editor")};
@@ -8,7 +8,7 @@
<properties/>
<border type="none"/>
<children>
<grid id="247ce" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="247ce" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -37,9 +37,18 @@
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<selected value="false"/>
<text value="Automatically start attribute"/>
</properties>
</component>
<component id="ba426" class="javax.swing.JCheckBox" binding="myEnableZenCodingCheckBox">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Enable Zen Coding"/>
</properties>
</component>
</children>
</grid>
<vspacer id="e0bcf">
@@ -28,6 +28,7 @@ public class WebEditorOptionsProvider implements EditorOptionsProvider {
private JCheckBox myAutomaticallyInsertClosingTagCheckBox;
private JCheckBox myAutomaticallyInsertRequiredAttributesCheckBox;
private JCheckBox myAutomaticallyStartAttributeAfterCheckBox;
private JCheckBox myEnableZenCodingCheckBox;
public String getDisplayName() {
return XmlBundle.message("web.editor.configuration.title");
@@ -47,9 +48,10 @@ public class WebEditorOptionsProvider implements EditorOptionsProvider {
public boolean isModified() {
final WebEditorOptions xmlEditorOptions = WebEditorOptions.getInstance();
return xmlEditorOptions.isAutomaticallyInsertClosingTag() != myAutomaticallyInsertClosingTagCheckBox.isSelected()
|| xmlEditorOptions.isAutomaticallyInsertRequiredAttributes() != myAutomaticallyInsertRequiredAttributesCheckBox.isSelected()
|| xmlEditorOptions.isAutomaticallyStartAttribute() != myAutomaticallyStartAttributeAfterCheckBox.isSelected();
return xmlEditorOptions.isAutomaticallyInsertClosingTag() != myAutomaticallyInsertClosingTagCheckBox.isSelected() ||
xmlEditorOptions.isAutomaticallyInsertRequiredAttributes() != myAutomaticallyInsertRequiredAttributesCheckBox.isSelected() ||
xmlEditorOptions.isAutomaticallyStartAttribute() != myAutomaticallyStartAttributeAfterCheckBox.isSelected() ||
xmlEditorOptions.isZenCodingEnabled() != myEnableZenCodingCheckBox.isSelected();
}
public void apply() throws ConfigurationException {
@@ -57,6 +59,7 @@ public class WebEditorOptionsProvider implements EditorOptionsProvider {
xmlEditorOptions.setAutomaticallyInsertClosingTag(myAutomaticallyInsertClosingTagCheckBox.isSelected());
xmlEditorOptions.setAutomaticallyInsertRequiredAttributes(myAutomaticallyInsertRequiredAttributesCheckBox.isSelected());
xmlEditorOptions.setAutomaticallyStartAttribute(myAutomaticallyStartAttributeAfterCheckBox.isSelected());
xmlEditorOptions.setEnableZenCoding(myEnableZenCodingCheckBox.isSelected());
}
public void reset() {
@@ -64,6 +67,7 @@ public class WebEditorOptionsProvider implements EditorOptionsProvider {
myAutomaticallyInsertClosingTagCheckBox.setSelected(xmlEditorOptions.isAutomaticallyInsertClosingTag());
myAutomaticallyInsertRequiredAttributesCheckBox.setSelected(xmlEditorOptions.isAutomaticallyInsertRequiredAttributes());
myAutomaticallyStartAttributeAfterCheckBox.setSelected(xmlEditorOptions.isAutomaticallyStartAttribute());
myEnableZenCodingCheckBox.setSelected(xmlEditorOptions.isZenCodingEnabled());
}
public void disposeUIResources() {
@@ -1,49 +0,0 @@
/*
* Copyright 2000-2010 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.codeInsight.template;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.util.xmlb.XmlSerializerUtil;
/**
* @author Eugene.Kudelevsky
*/
@State(
name="DuplocatorSettings",
storages = {
@Storage(
id="DuplocatorSettings",
file="$APP_CONFIG$/other.xml"
)}
)
public class ZenCodingSettings implements PersistentStateComponent<ZenCodingSettings> {
public boolean ENABLED = true;
public static ZenCodingSettings getInstance() {
return ServiceManager.getService(ZenCodingSettings.class);
}
public ZenCodingSettings getState() {
return this;
}
public void loadState(ZenCodingSettings state) {
XmlSerializerUtil.copyBean(state, this);
}
}
@@ -1,78 +0,0 @@
/*
* Copyright 2000-2010 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.codeInsight.template;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.SearchableConfigurable;
import com.intellij.xml.XmlBundle;
import org.jetbrains.annotations.Nls;
import javax.swing.*;
/**
* @author Eugene.Kudelevsky
*/
public class ZenCodingSettingsConfigurable implements SearchableConfigurable {
private ZenCodingSettingsPanel myPanel;
public String getId() {
return getHelpTopic();
}
public Runnable enableSearch(String option) {
return null;
}
@Nls
public String getDisplayName() {
return XmlBundle.message("zen.coding.settings");
}
public Icon getIcon() {
return null;
}
public String getHelpTopic() {
return null;
}
public JComponent createComponent() {
if (myPanel == null) {
myPanel = new ZenCodingSettingsPanel();
}
return myPanel.getComponent();
}
public boolean isModified() {
return myPanel != null && myPanel.isModified();
}
public void apply() throws ConfigurationException {
if (myPanel != null) {
myPanel.apply();
}
}
public void reset() {
if (myPanel != null) {
myPanel.reset();
}
}
public void disposeUIResources() {
myPanel = null;
}
}
@@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.codeInsight.template.ZenCodingSettingsPanel">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="3be87" class="javax.swing.JCheckBox" binding="myEnableZenCodingCheckBox">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/XmlBundle" key="zen.coding.enable.label"/>
</properties>
</component>
<vspacer id="c2c50">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
</children>
</grid>
</form>
@@ -1,45 +0,0 @@
/*
* Copyright 2000-2010 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.codeInsight.template;
import javax.swing.*;
/**
* @author Eugene.Kudelevsky
*/
public class ZenCodingSettingsPanel {
private JPanel myPanel;
private JCheckBox myEnableZenCodingCheckBox;
public JPanel getComponent() {
return myPanel;
}
public boolean isModified() {
ZenCodingSettings settings = ZenCodingSettings.getInstance();
return settings.ENABLED != myEnableZenCodingCheckBox.isSelected();
}
public void apply() {
ZenCodingSettings settings = ZenCodingSettings.getInstance();
settings.ENABLED = myEnableZenCodingCheckBox.isSelected();
}
public void reset() {
ZenCodingSettings settings = ZenCodingSettings.getInstance();
myEnableZenCodingCheckBox.setSelected(settings.ENABLED);
}
}