Skip to content

Commit

Permalink
fix custom use aliases do not work after restarting the IDE #54
Browse files Browse the repository at this point in the history
  • Loading branch information
Haehnchen committed Apr 11, 2016
1 parent 95314f0 commit 96799a8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
7 changes: 6 additions & 1 deletion META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin version="2" url="https://github.com/Haehnchen/idea-php-annotation-plugin">
<id>de.espend.idea.php.annotation</id>
<name>PHP Annotations</name>
<version>3.0</version>
<version>3.0.1</version>
<vendor email="daniel@espendiller.net" url="http://www.espend.de">Daniel Espendiller</vendor>

<description><![CDATA[
Expand Down Expand Up @@ -45,6 +45,11 @@
2.x: PhpStorm9, 10<br>
1.x: PhpStorm8<br>
<h2>3.0.1</h2>
<ul>
<li>Custom use aliases do not work after restarting the IDE <a href="https://github.com/Haehnchen/idea-php-annotation-plugin/issues/54">#54</a></li>
</ul>
<h2>3.0</h2>
<ul>
<li>Change minimal api level to PhpStorm 2016.1</li>
Expand Down
15 changes: 8 additions & 7 deletions src/de/espend/idea/php/annotation/ApplicationSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.util.containers.HashMap;
import com.intellij.util.xmlb.XmlSerializerUtil;
import de.espend.idea.php.annotation.dict.UseAliasOption;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.*;

/**
* @author Daniel Espendiller <daniel@espendiller.net>
Expand All @@ -23,7 +19,12 @@ public class ApplicationSettings implements PersistentStateComponent<Application

public boolean appendRoundBracket = true;

public List<UseAliasOption> useAliasOptions = null;
public List<UseAliasOption> useAliasOptions = new ArrayList<UseAliasOption>();

/**
* First user change, so that can provide defaults
*/
public boolean provideDefaults = true;

@Nullable
@Override
Expand Down Expand Up @@ -54,7 +55,7 @@ public static Collection<UseAliasOption> getDefaultUseAliasOption() {

@NotNull
public static Collection<UseAliasOption> getUseAliasOptionsWithDefaultFallback() {
if(getInstance().useAliasOptions == null) {
if(getInstance().provideDefaults && getInstance().useAliasOptions.size() == 0) {
return getDefaultUseAliasOption();
}

Expand Down
7 changes: 7 additions & 0 deletions src/de/espend/idea/php/annotation/ui/UseAliasListForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ public void actionPerformed(ActionEvent e) {
tableView.getTableViewModel().fireTableDataChanged();
changed = true;
resetList();
try {
apply();
ApplicationSettings.getInstance().provideDefaults = false;
JOptionPane.showMessageDialog(panel, "Default alias applied");
} catch (ConfigurationException ignored) {
}
}
});

Expand Down Expand Up @@ -159,6 +165,7 @@ public void apply() throws ConfigurationException {
}

ApplicationSettings.getInstance().useAliasOptions = options;
ApplicationSettings.getInstance().provideDefaults = false;
this.changed = false;
}

Expand Down

0 comments on commit 96799a8

Please sign in to comment.