mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Github: project-level settings
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
<checkoutProvider implementation="org.jetbrains.plugins.github.extensions.GithubCheckoutProvider"/>
|
||||
<applicationService serviceInterface="org.jetbrains.plugins.github.util.GithubSettings"
|
||||
serviceImplementation="org.jetbrains.plugins.github.util.GithubSettings"/>
|
||||
<projectService serviceInterface="org.jetbrains.plugins.github.util.GithubProjectSettings"
|
||||
serviceImplementation="org.jetbrains.plugins.github.util.GithubProjectSettings"/>
|
||||
<vcsAnnotationGutterActionProvider implementation="org.jetbrains.plugins.github.extensions.GithubAnnotationGutterActionProvider" />
|
||||
<checkoutCompletedListener implementation="org.jetbrains.plugins.github.extensions.GithubCheckoutListener" order="after PlatformProjectCheckoutListener"/>
|
||||
<vcsConfigurableProvider implementation="org.jetbrains.plugins.github.ui.GithubSettingsConfigurable"/>
|
||||
|
||||
+7
-4
@@ -23,6 +23,7 @@ import com.intellij.util.Consumer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.plugins.github.util.GithubProjectSettings;
|
||||
import org.jetbrains.plugins.github.util.GithubSettings;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -33,8 +34,9 @@ import java.util.regex.Pattern;
|
||||
* @author Aleksey Pivovarov
|
||||
*/
|
||||
public class GithubCreatePullRequestDialog extends DialogWrapper {
|
||||
private final GithubCreatePullRequestPanel myGithubCreatePullRequestPanel;
|
||||
private static final Pattern GITHUB_REPO_PATTERN = Pattern.compile("[a-zA-Z0-9_.-]+:[a-zA-Z0-9_.-]+");
|
||||
@NotNull private final GithubCreatePullRequestPanel myGithubCreatePullRequestPanel;
|
||||
@NotNull private static final Pattern GITHUB_REPO_PATTERN = Pattern.compile("[a-zA-Z0-9_.-]+:[a-zA-Z0-9_.-]+");
|
||||
@NotNull private final Project myProject;
|
||||
|
||||
public GithubCreatePullRequestDialog(@NotNull final Project project,
|
||||
@NotNull Collection<String> branches,
|
||||
@@ -45,7 +47,8 @@ public class GithubCreatePullRequestDialog extends DialogWrapper {
|
||||
|
||||
myGithubCreatePullRequestPanel.setBranches(branches);
|
||||
|
||||
String configBranch = GithubSettings.getInstance().getCreatePullRequestDefaultBranch();
|
||||
myProject = project;
|
||||
String configBranch = GithubProjectSettings.getInstance(myProject).getCreatePullRequestDefaultBranch();
|
||||
myGithubCreatePullRequestPanel.setSelectedBranch(configBranch != null ? configBranch : suggestedBranch);
|
||||
|
||||
setTitle("Create Pull Request");
|
||||
@@ -92,7 +95,7 @@ public class GithubCreatePullRequestDialog extends DialogWrapper {
|
||||
@Override
|
||||
protected void doOKAction() {
|
||||
super.doOKAction();
|
||||
GithubSettings.getInstance().setCreatePullRequestDefaultBranch(getTargetBranch());
|
||||
GithubProjectSettings.getInstance(myProject).setCreatePullRequestDefaultBranch(getTargetBranch());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.jetbrains.plugins.github.util;
|
||||
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Aleksey Pivovarov
|
||||
*/
|
||||
@State(
|
||||
name = "GithubProjectSettings",
|
||||
storages = {@Storage(
|
||||
file = StoragePathMacros.WORKSPACE_FILE )})
|
||||
public class GithubProjectSettings implements PersistentStateComponent<GithubProjectSettings.State> {
|
||||
private State myState = new State();
|
||||
|
||||
public State getState() {
|
||||
return myState;
|
||||
}
|
||||
|
||||
public void loadState(State state) {
|
||||
myState = state;
|
||||
}
|
||||
|
||||
public static class State {
|
||||
@Nullable public String CREATE_PULL_REQUEST_DEFAULT_BRANCH = null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getCreatePullRequestDefaultBranch() {
|
||||
return myState.CREATE_PULL_REQUEST_DEFAULT_BRANCH;
|
||||
}
|
||||
|
||||
public void setCreatePullRequestDefaultBranch(@NotNull String branch) {
|
||||
myState.CREATE_PULL_REQUEST_DEFAULT_BRANCH = branch;
|
||||
}
|
||||
|
||||
public static GithubProjectSettings getInstance(@NotNull Project project) {
|
||||
return ServiceManager.getService(project, GithubProjectSettings.class);
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,6 @@ public class GithubSettings implements PersistentStateComponent<GithubSettings.S
|
||||
public boolean PRIVATE_GIST = true;
|
||||
public boolean SAVE_PASSWORD = true;
|
||||
@NotNull public Collection<String> TRUSTED_HOSTS = new ArrayList<String>();
|
||||
@Nullable public String CREATE_PULL_REQUEST_DEFAULT_BRANCH = null;
|
||||
}
|
||||
|
||||
public static GithubSettings getInstance() {
|
||||
@@ -121,11 +120,6 @@ public class GithubSettings implements PersistentStateComponent<GithubSettings.S
|
||||
return passwordSafe.getSettings().getProviderType() == PasswordSafeSettings.ProviderType.MASTER_PASSWORD;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getCreatePullRequestDefaultBranch() {
|
||||
return myState.CREATE_PULL_REQUEST_DEFAULT_BRANCH;
|
||||
}
|
||||
|
||||
public void setAnonymousGist(final boolean anonymousGist) {
|
||||
myState.ANONYMOUS_GIST = anonymousGist;
|
||||
}
|
||||
@@ -142,10 +136,6 @@ public class GithubSettings implements PersistentStateComponent<GithubSettings.S
|
||||
myState.OPEN_IN_BROWSER_GIST = openInBrowserGist;
|
||||
}
|
||||
|
||||
public void setCreatePullRequestDefaultBranch(@NotNull String branch) {
|
||||
myState.CREATE_PULL_REQUEST_DEFAULT_BRANCH = branch;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collection<String> getTrustedHosts() {
|
||||
return myState.TRUSTED_HOSTS;
|
||||
|
||||
Reference in New Issue
Block a user