mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Added Java EE names tab to Java code style settings, some API changes
This commit is contained in:
@@ -15,16 +15,28 @@
|
||||
*/
|
||||
package com.intellij.application.options;
|
||||
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Rustam Vishnyakov
|
||||
*/
|
||||
public class JavaCodeStyleMainPanel extends MultiTabCodeStyleAbstractPanel {
|
||||
protected JavaCodeStyleMainPanel(CodeStyleSettings settings) {
|
||||
super(settings);
|
||||
|
||||
protected JavaCodeStyleMainPanel(CodeStyleSettings currentSettings, CodeStyleSettings settings) {
|
||||
super(currentSettings, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,5 +50,74 @@ public class JavaCodeStyleMainPanel extends MultiTabCodeStyleAbstractPanel {
|
||||
addTab(new JavaDocFormattingPanel(settings));
|
||||
addTab(new CodeStyleImportsPanelWrapper(settings));
|
||||
addTab(new CodeStyleGenerationWrapper(settings));
|
||||
for (CodeStyleSettingsProvider provider : Extensions.getExtensions(CodeStyleSettingsProvider.EXTENSION_POINT_NAME)) {
|
||||
if (provider.getLanguage() == JavaLanguage.INSTANCE && !provider.hasSettingsPage()) {
|
||||
Configurable configurable = provider.createSettingsPage(getCurrentSettings(), settings);
|
||||
ConfigurableWrapper wrapper = new ConfigurableWrapper(configurable, settings);
|
||||
addTab(wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ConfigurableWrapper extends CodeStyleAbstractPanel {
|
||||
|
||||
private Configurable myConfigurable;
|
||||
|
||||
public ConfigurableWrapper(Configurable configurable, CodeStyleSettings settings) {
|
||||
super(settings);
|
||||
myConfigurable = configurable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getRightMargin() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EditorHighlighter createHighlighter(EditorColorsScheme scheme) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected FileType getFileType() {
|
||||
return JavaFileType.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTabTitle() {
|
||||
return myConfigurable.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPreviewText() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(CodeStyleSettings settings) {
|
||||
try {
|
||||
myConfigurable.apply();
|
||||
}
|
||||
catch (ConfigurationException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified(CodeStyleSettings settings) {
|
||||
return myConfigurable.isModified();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getPanel() {
|
||||
return myConfigurable.createComponent();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void resetImpl(CodeStyleSettings settings) {
|
||||
myConfigurable.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -29,9 +29,9 @@ public class JavaCodeStyleSettingsProvider extends CodeStyleSettingsProvider {
|
||||
@NotNull
|
||||
@Override
|
||||
public Configurable createSettingsPage(CodeStyleSettings settings, CodeStyleSettings originalSettings) {
|
||||
return new CodeStyleAbstractConfigurable(settings, originalSettings, "Java") {
|
||||
return new CodeStyleAbstractConfigurable(settings, originalSettings, "Java") {
|
||||
protected CodeStyleAbstractPanel createPanel(final CodeStyleSettings settings) {
|
||||
return new JavaCodeStyleMainPanel(settings);
|
||||
return new JavaCodeStyleMainPanel(getCurrentSettings(), settings);
|
||||
}
|
||||
public String getHelpTopic() {
|
||||
return null;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.psi.codeStyle;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -43,7 +44,8 @@ public abstract class CodeStyleSettingsProvider {
|
||||
*/
|
||||
@Nullable
|
||||
public String getConfigurableDisplayName() {
|
||||
return null;
|
||||
Language lang = getLanguage();
|
||||
return lang == null ? null : lang.getDisplayName();
|
||||
}
|
||||
|
||||
public boolean hasSettingsPage() {
|
||||
@@ -53,4 +55,17 @@ public abstract class CodeStyleSettingsProvider {
|
||||
public DisplayPriority getPriority() {
|
||||
return DisplayPriority.LANGUAGE_SETTINGS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies a language this provider applies to. If the language is not null, its display name will
|
||||
* be used as a configurable name by default if <code>getConfigurableDisplayName()</code> is not
|
||||
* overridden.
|
||||
*
|
||||
* @return null by default.
|
||||
*/
|
||||
@Nullable
|
||||
public Language getLanguage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
@@ -103,4 +103,8 @@ public abstract class CodeStyleAbstractConfigurable implements Configurable, Opt
|
||||
public Set<String> processListOptions() {
|
||||
return myPanel.processListOptions();
|
||||
}
|
||||
|
||||
protected CodeStyleSettings getCurrentSettings() {
|
||||
return mySettings;
|
||||
}
|
||||
}
|
||||
|
||||
+11
-1
@@ -88,8 +88,14 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
|
||||
private boolean myShowsPreviewHighlighters;
|
||||
private boolean mySkipPreviewHighlighting;
|
||||
private LanguageSelector myLanguageSelector;
|
||||
|
||||
private final CodeStyleSettings myCurrentSettings;
|
||||
|
||||
protected CodeStyleAbstractPanel(CodeStyleSettings settings) {
|
||||
this(null, settings);
|
||||
}
|
||||
|
||||
protected CodeStyleAbstractPanel(@Nullable CodeStyleSettings currentSettings, CodeStyleSettings settings) {
|
||||
myCurrentSettings = currentSettings;
|
||||
mySettings = settings;
|
||||
myEditor = createEditor();
|
||||
|
||||
@@ -614,5 +620,9 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
|
||||
public boolean setPanelLanguage(Language language) {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected CodeStyleSettings getCurrentSettings() {
|
||||
return myCurrentSettings;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -35,7 +35,7 @@ public class CommonCodeStyleSettingsConfigurable extends CodeStyleAbstractConfig
|
||||
|
||||
@Override
|
||||
protected CodeStyleAbstractPanel createPanel(CodeStyleSettings settings) {
|
||||
return new MyCodeStylePanel(settings);
|
||||
return new MyCodeStylePanel(getCurrentSettings(), settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,8 +48,8 @@ public class CommonCodeStyleSettingsConfigurable extends CodeStyleAbstractConfig
|
||||
private CodeStyleBlankLinesPanel myBlankLinesPanel;
|
||||
private WrappingAndBracesPanel myWrappingAndBracesPanel;
|
||||
|
||||
protected MyCodeStylePanel(CodeStyleSettings settings) {
|
||||
super(settings);
|
||||
protected MyCodeStylePanel(CodeStyleSettings currentSettings, CodeStyleSettings settings) {
|
||||
super(currentSettings, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -39,9 +39,8 @@ public abstract class MultiTabCodeStyleAbstractPanel extends CodeStyleAbstractPa
|
||||
private JPanel myPanel;
|
||||
private JTabbedPane myTabbedPane;
|
||||
|
||||
|
||||
protected MultiTabCodeStyleAbstractPanel(CodeStyleSettings settings) {
|
||||
super(settings);
|
||||
protected MultiTabCodeStyleAbstractPanel(CodeStyleSettings currentSettings, CodeStyleSettings settings) {
|
||||
super(currentSettings, settings);
|
||||
}
|
||||
|
||||
protected void initTabs(CodeStyleSettings settings) {
|
||||
@@ -240,4 +239,5 @@ public abstract class MultiTabCodeStyleAbstractPanel extends CodeStyleAbstractPa
|
||||
provider.customizeSettings(panel, panel.getSettingsType());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user