View Javadoc

1   /**
2    * Copyright (C) 2008 Atlassian
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package com.atlassian.theplugin.configuration;
18  
19  import com.atlassian.connector.intellij.configuration.UserCfgBean;
20  import com.intellij.openapi.components.PersistentStateComponent;
21  import com.intellij.openapi.components.State;
22  import com.intellij.openapi.components.Storage;
23  import org.jetbrains.annotations.NotNull;
24  
25  @State(name = "atlassian-ide-plugin-workspace",
26  		storages = {@Storage(id = "atlassian-ide-plugin-workspace-id", file = "$WORKSPACE_FILE$")})
27  public class WorkspaceConfigurationBean implements PersistentStateComponent<WorkspaceConfigurationBean> {
28  
29  	private BambooWorkspaceConfiguration bambooConfiguration = new BambooWorkspaceConfiguration();
30  	private CrucibleWorkspaceConfiguration crucibleConfiguration = new CrucibleWorkspaceConfiguration();
31  
32  	private String activeToolWindowTab = ""; //PluginToolWindow.ToolWindowPanels.JIRA.toString();
33  
34  	private UserCfgBean defaultCredentials = new UserCfgBean();
35  	private boolean defaultCredentialsAsked;
36      private boolean defaultJiraServerAsked;
37      private boolean defaultFishEyeServerAsked;
38  
39  
40  	public WorkspaceConfigurationBean() {
41  
42  	}
43  
44      public boolean isDefaultJiraServerAsked() {
45          return defaultJiraServerAsked;
46      }
47  
48      public void setDefaultJiraServerAsked(boolean defaultJiraServerAsked) {
49          this.defaultJiraServerAsked = defaultJiraServerAsked;
50      }
51  
52      public boolean isDefaultFishEyeServerAsked() {
53          return defaultFishEyeServerAsked;
54      }
55  
56      public void setDefaultFishEyeServerAsked(boolean defaultFishEyeServerAsked) {
57          this.defaultFishEyeServerAsked = defaultFishEyeServerAsked;
58      }
59  
60      public BambooWorkspaceConfiguration getBambooConfiguration() {
61  		return bambooConfiguration;
62  	}
63  
64  	public void setBambooConfiguration(BambooWorkspaceConfiguration bambooConfiguration) {
65  		this.bambooConfiguration = bambooConfiguration;
66  	}
67  
68  	public CrucibleWorkspaceConfiguration getCrucibleConfiguration() {
69  		return crucibleConfiguration;
70  	}
71  
72  	public void setCrucibleConfiguration(CrucibleWorkspaceConfiguration crucibleConfiguration) {
73  		this.crucibleConfiguration = crucibleConfiguration;
74  	}
75  
76  	public void copyConfiguration(WorkspaceConfigurationBean state) {
77  		bambooConfiguration.copyConfiguration(state.getBambooConfiguration());
78  		crucibleConfiguration.copyConfiguration(state.getCrucibleConfiguration());
79  		this.activeToolWindowTab = state.getActiveToolWindowTab();
80  		defaultCredentials = new UserCfgBean(state.defaultCredentials.getUsername(),
81  				state.defaultCredentials.getEncodedPassword());
82  		defaultCredentialsAsked = state.defaultCredentialsAsked;
83          defaultJiraServerAsked = state.defaultJiraServerAsked;
84          defaultFishEyeServerAsked = state.defaultFishEyeServerAsked;
85  	}
86  
87  	public String getActiveToolWindowTab() {
88  		return activeToolWindowTab;
89  	}
90  
91  	public void setActiveToolWindowTab(String activeToolWindowTab) {
92  		this.activeToolWindowTab = activeToolWindowTab;
93  	}
94  
95  	public WorkspaceConfigurationBean getState() {
96  		return this;
97  	}
98  
99  	public void loadState(WorkspaceConfigurationBean state) {
100 		copyConfiguration(state);
101 //		projectConfigurationBean.copyConfiguration(state);
102 	}
103 
104 	public boolean isDefaultCredentialsAsked() {
105 		return defaultCredentialsAsked;
106 	}
107 
108 	public void setDefaultCredentialsAsked(final boolean defaultCredentialsAsked) {
109 		this.defaultCredentialsAsked = defaultCredentialsAsked;
110 	}
111 
112 	@NotNull
113 	public UserCfgBean getDefaultCredentials() {
114 		return defaultCredentials;
115 	}
116 
117 	public void setDefaultCredentials(@NotNull final UserCfgBean defaultCredentials) {
118 		this.defaultCredentials = defaultCredentials;
119 		if (defaultCredentials.getUsername().length() > 0) {
120 			defaultCredentialsAsked = true;
121 		}
122 	}
123 }