-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #203 from couchbaselabs/named_params
Adding the Named params support
- Loading branch information
Showing
11 changed files
with
611 additions
and
168 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
src/main/java/com/couchbase/intellij/persistence/NamedParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.couchbase.intellij.persistence; | ||
|
||
import lombok.Data; | ||
|
||
import java.util.Map; | ||
|
||
@Data | ||
public class NamedParams { | ||
private Map<String, String> params; | ||
} |
69 changes: 69 additions & 0 deletions
69
src/main/java/com/couchbase/intellij/persistence/storage/NamedParamsStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.couchbase.intellij.persistence.storage; | ||
|
||
import com.couchbase.intellij.persistence.FavoriteQueries; | ||
import com.couchbase.intellij.persistence.NamedParams; | ||
import com.intellij.openapi.application.ApplicationManager; | ||
import com.intellij.openapi.components.PersistentStateComponent; | ||
import com.intellij.openapi.components.State; | ||
import com.intellij.openapi.components.Storage; | ||
import com.intellij.util.xmlb.XmlSerializerUtil; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
|
||
@State( | ||
name = "NamedParamsStorage", | ||
storages = { | ||
@Storage( | ||
value = "named_params.xml" | ||
) | ||
} | ||
) | ||
public class NamedParamsStorage implements PersistentStateComponent<NamedParamsStorage.State> { | ||
|
||
private final NamedParamsStorage.State myState = new NamedParamsStorage.State(); | ||
|
||
public static NamedParamsStorage getInstance() { | ||
return ApplicationManager.getApplication().getService(NamedParamsStorage.class); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public NamedParamsStorage.State getState() { | ||
return myState; | ||
} | ||
|
||
@Override | ||
public void loadState(@NotNull NamedParamsStorage.State state) { | ||
XmlSerializerUtil.copyBean(state, myState); | ||
} | ||
|
||
public NamedParams getValue() { | ||
if (myState.namedParams == null) { | ||
myState.namedParams = new NamedParams(); | ||
} | ||
|
||
if(myState.namedParams.getParams() == null) { | ||
myState.namedParams.setParams(new HashMap<>()); | ||
} | ||
return myState.namedParams; | ||
} | ||
|
||
public void setValue(NamedParams newValue) { | ||
myState.namedParams = newValue; | ||
} | ||
|
||
public static class State { | ||
public NamedParams namedParams = null; | ||
|
||
public NamedParams getNamedParams() { | ||
return namedParams; | ||
} | ||
|
||
public void setNamedParams(NamedParams namedParams) { | ||
this.namedParams = namedParams; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.