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  package com.atlassian.theplugin.idea.config;
17  
18  import com.atlassian.theplugin.commons.cfg.ProjectConfiguration;
19  import com.atlassian.theplugin.idea.Constants;
20  import com.atlassian.theplugin.idea.config.serverconfig.ServerConfigPanel;
21  import com.intellij.openapi.project.Project;
22  
23  import javax.swing.*;
24  import java.awt.*;
25  
26  public class ProjectConfigurationPanel extends JPanel {
27  	private final FooterPanel footerPanel = new FooterPanel();
28  	private final JTabbedPane contentPanel = new JTabbedPane();
29  	private final ServerConfigPanel serverConfigPanel;
30  
31  	private ProjectConfiguration projectConfiguration;
32  
33  	public ProjectConfiguration getProjectConfiguration() {
34  		serverConfigPanel.saveData();
35  		return projectConfiguration;
36  	}
37  
38  	public ProjectConfigurationPanel(Project project, ProjectConfiguration projectConfiguration) {
39  		this.projectConfiguration = projectConfiguration;
40  		serverConfigPanel = new ServerConfigPanel(project, projectConfiguration.getServers());
41  		initLayout();
42  	}
43  
44  	private void initLayout() {
45  		setLayout(new BorderLayout());
46  
47  		contentPanel.setOpaque(true);
48  		contentPanel.setBackground(new Color(Constants.BG_COLOR_R, Constants.BG_COLOR_G, Constants.BG_COLOR_B));
49  
50  		// add servers tab
51  		contentPanel.add(serverConfigPanel.getTitle(), serverConfigPanel);
52  
53  		add(contentPanel, BorderLayout.CENTER);
54  		add(footerPanel, BorderLayout.SOUTH);
55  	}
56  
57  	public void saveData(boolean finalizeData) {
58  		if (finalizeData) {
59  			serverConfigPanel.finalizeData();
60  		}
61  		serverConfigPanel.saveData();
62  	}
63  
64  
65  	public void setData(ProjectConfiguration aProjectConfiguration) {
66  		projectConfiguration = aProjectConfiguration;
67  		serverConfigPanel.setData(projectConfiguration.getServers());
68  	}
69  }