settings for icon gutters
[fedora-idea.git] / lang-impl / src / com / intellij / application / options / CodeStyleAbstractConfigurable.java
blob1cdf012a4b82af2fb1960ba3ad1a9f6ca3bbcc8d
1 /*
2 * Copyright (c) 2004 JetBrains s.r.o. All Rights Reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
8 * -Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * -Redistribution in binary form must reproduct the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the distribution.
15 * Neither the name of JetBrains or IntelliJ IDEA
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * This software is provided "AS IS," without a warranty of any kind. ALL
20 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
21 * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
22 * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. JETBRAINS AND ITS LICENSORS SHALL NOT
23 * BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT
24 * OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR ITS
25 * DERIVATIVES. IN NO EVENT WILL JETBRAINS OR ITS LICENSORS BE LIABLE FOR ANY LOST
26 * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
27 * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
28 * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN
29 * IF JETBRAINS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 package com.intellij.application.options;
34 import com.intellij.application.options.codeStyle.CodeStyleSchemesModel;
35 import com.intellij.openapi.options.Configurable;
36 import com.intellij.openapi.options.ConfigurationException;
37 import com.intellij.openapi.util.Disposer;
38 import com.intellij.psi.codeStyle.CodeStyleSettings;
40 import javax.swing.*;
42 public abstract class CodeStyleAbstractConfigurable implements Configurable {
43 private CodeStyleAbstractPanel myPanel;
44 private final CodeStyleSettings mySettings;
45 private final CodeStyleSettings myCloneSettings;
46 private final String myDisplayName;
47 private CodeStyleSchemesModel myModel;
49 public CodeStyleAbstractConfigurable(CodeStyleSettings settings, CodeStyleSettings cloneSettings,
50 final String displayName) {
51 mySettings = settings;
52 myCloneSettings = cloneSettings;
53 myDisplayName = displayName;
56 public String getDisplayName() {
57 return myDisplayName;
60 public Icon getIcon() {
61 return null;
64 public JComponent createComponent() {
65 myPanel = createPanel(myCloneSettings);
66 myPanel.setModel(myModel);
67 return myPanel.getPanel();
70 protected abstract CodeStyleAbstractPanel createPanel(final CodeStyleSettings settings);
72 public void apply() throws ConfigurationException {
73 if (myPanel != null) {
74 myPanel.apply(mySettings);
78 public void reset() {
79 if (myPanel != null) {
80 myPanel.reset(mySettings);
84 public void resetFromClone(){
85 if (myPanel != null) {
86 myPanel.reset(myCloneSettings);
90 public boolean isModified() {
91 return myPanel != null && myPanel.isModified(mySettings);
94 public void disposeUIResources() {
95 if (myPanel != null) {
96 Disposer.dispose(myPanel);
97 myPanel = null;
101 public CodeStyleAbstractPanel getPanel() {
102 return myPanel;
105 public void setModel(final CodeStyleSchemesModel model) {
106 if (myPanel != null) {
107 myPanel.setModel(model);
109 myModel = model;
112 public void onSomethingChanged() {
113 myPanel.onSomethingChanged();