mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
show detecting excludes configuration as a node in 'facets' tree
This commit is contained in:
-44
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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 com.intellij.openapi.roots.ui.configuration.projectRoot;
|
||||
|
||||
import com.intellij.framework.detection.DetectionExcludesConfiguration;
|
||||
import com.intellij.framework.detection.impl.exclude.DetectionExcludesConfigurable;
|
||||
import com.intellij.framework.detection.impl.exclude.DetectionExcludesConfigurationImpl;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class EditFrameworkDetectionExcludesAction extends DumbAwareAction {
|
||||
private final Project myProject;
|
||||
|
||||
public EditFrameworkDetectionExcludesAction(@NotNull Project project) {
|
||||
super("Edit Detection Excludes...", null, PlatformIcons.EDIT);
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final DetectionExcludesConfigurationImpl configuration = (DetectionExcludesConfigurationImpl)DetectionExcludesConfiguration.getInstance(myProject);
|
||||
ShowSettingsUtil.getInstance().editConfigurable(myProject, new DetectionExcludesConfigurable(myProject, configuration));
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -43,6 +43,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
@@ -83,6 +84,8 @@ public class FacetStructureConfigurable extends BaseStructureConfigurable {
|
||||
if (!InvalidFacetManager.getInstance(myProject).getInvalidFacets().isEmpty()) {
|
||||
addFacetTypeNode(InvalidFacetType.getInstance());
|
||||
}
|
||||
myRoot.add(new MyNode(new FrameworkDetectionConfigurable(myProject)));
|
||||
((DefaultTreeModel)myTree.getModel()).reload();
|
||||
}
|
||||
|
||||
private void addFacetTypeNode(FacetType<?, ?> facetType) {
|
||||
@@ -182,8 +185,6 @@ public class FacetStructureConfigurable extends BaseStructureConfigurable {
|
||||
actions.add(new MyRemoveAction());
|
||||
actions.add(Separator.getInstance());
|
||||
addCollapseExpandActions(actions);
|
||||
actions.add(Separator.getInstance());
|
||||
actions.add(new EditFrameworkDetectionExcludesAction(myProject));
|
||||
return actions;
|
||||
}
|
||||
|
||||
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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 com.intellij.openapi.roots.ui.configuration.projectRoot;
|
||||
|
||||
import com.intellij.framework.detection.DetectionExcludesConfiguration;
|
||||
import com.intellij.framework.detection.impl.exclude.DetectionExcludesConfigurable;
|
||||
import com.intellij.framework.detection.impl.exclude.DetectionExcludesConfigurationImpl;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.NamedConfigurable;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class FrameworkDetectionConfigurable extends NamedConfigurable<DetectionExcludesConfiguration> {
|
||||
private final DetectionExcludesConfiguration myExcludesConfiguration;
|
||||
private final DetectionExcludesConfigurable myConfigurable;
|
||||
|
||||
public FrameworkDetectionConfigurable(@NotNull Project project) {
|
||||
myExcludesConfiguration = DetectionExcludesConfiguration.getInstance(project);
|
||||
myConfigurable = new DetectionExcludesConfigurable(project, (DetectionExcludesConfigurationImpl)myExcludesConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayName(String name) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DetectionExcludesConfiguration getEditableObject() {
|
||||
return myExcludesConfiguration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBannerSlogan() {
|
||||
return "Framework Detection";
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent createOptionsPanel() {
|
||||
return myConfigurable.createComponent();
|
||||
}
|
||||
|
||||
@Nls
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Detection";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return myConfigurable.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpTopic() {
|
||||
return myConfigurable.getHelpTopic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return myConfigurable.isModified();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() throws ConfigurationException {
|
||||
myConfigurable.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
myConfigurable.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeUIResources() {
|
||||
myConfigurable.disposeUIResources();
|
||||
}
|
||||
}
|
||||
+2
@@ -59,6 +59,7 @@ public class DetectionExcludesConfigurable implements Configurable {
|
||||
|
||||
@Nls
|
||||
@Override
|
||||
@NotNull
|
||||
public JComponent createComponent() {
|
||||
myMainPanel = new JPanel(new BorderLayout());
|
||||
final JBList excludesList = new JBList(myModel);
|
||||
@@ -78,6 +79,7 @@ public class DetectionExcludesConfigurable implements Configurable {
|
||||
doAddAction(button);
|
||||
}
|
||||
});
|
||||
myMainPanel.add(new JLabel("Exclude from detection:"), BorderLayout.NORTH);
|
||||
myMainPanel.add(decorator.createPanel());
|
||||
return myMainPanel;
|
||||
}
|
||||
|
||||
+3
-3
@@ -23,7 +23,7 @@ import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
@@ -180,7 +180,7 @@ public class DetectionExcludesConfigurationImpl extends DetectionExcludesConfigu
|
||||
|
||||
final ExcludesConfigurationState state = new ExcludesConfigurationState();
|
||||
state.getFrameworkTypes().addAll(myExcludedFrameworks);
|
||||
Collections.sort(state.getFrameworkTypes());
|
||||
Collections.sort(state.getFrameworkTypes(), String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
for (String typeId : myExcludedFiles.keySet()) {
|
||||
final VirtualFilePointerContainer container = myExcludedFiles.get(typeId);
|
||||
@@ -191,7 +191,7 @@ public class DetectionExcludesConfigurationImpl extends DetectionExcludesConfigu
|
||||
Collections.sort(state.getFiles(), new Comparator<ExcludedFileState>() {
|
||||
@Override
|
||||
public int compare(ExcludedFileState o1, ExcludedFileState o2) {
|
||||
return Comparing.comparePairs(o1.getUrl(), o1.getFrameworkType(), o2.getUrl(), o2.getFrameworkType());
|
||||
return StringUtil.comparePairs(o1.getFrameworkType(), o1.getUrl(), o2.getFrameworkType(), o2.getUrl(), true);
|
||||
}
|
||||
});
|
||||
return state;
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.framework.detection.impl.exclude;
|
||||
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -28,7 +28,7 @@ abstract class ExcludeListItem {
|
||||
public static final Comparator<ExcludeListItem> COMPARATOR = new Comparator<ExcludeListItem>() {
|
||||
@Override
|
||||
public int compare(ExcludeListItem o1, ExcludeListItem o2) {
|
||||
return Comparing.comparePairs(o1.getPresentableFrameworkName(), o1.getFileUrl(), o2.getPresentableFrameworkName(), o2.getFileUrl());
|
||||
return StringUtil.comparePairs(o1.getPresentableFrameworkName(), o1.getFileUrl(), o2.getPresentableFrameworkName(), o2.getFileUrl(), true);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+2
-1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.framework.detection.impl.exclude;
|
||||
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.util.xmlb.annotations.AbstractCollection;
|
||||
import com.intellij.util.xmlb.annotations.Property;
|
||||
|
||||
@@ -54,7 +55,7 @@ public class ExcludesConfigurationState {
|
||||
if (!(o instanceof ExcludesConfigurationState)) return false;
|
||||
|
||||
ExcludesConfigurationState state = (ExcludesConfigurationState)o;
|
||||
return myFiles.equals(state.myFiles) && myFrameworkTypes.equals(state.myFrameworkTypes);
|
||||
return Comparing.haveEqualElements(myFiles, state.myFiles) && Comparing.haveEqualElements(myFrameworkTypes, state.myFrameworkTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -168,9 +168,4 @@ public class Comparing {
|
||||
if (o2 == null) return 1;
|
||||
return o1.compareTo(o2);
|
||||
}
|
||||
|
||||
public static <F extends Comparable<F>, S extends Comparable<S>> int comparePairs(F aFirst, S aSecond, F bFirst, S bSecond) {
|
||||
final int compare = compare(aFirst, bFirst);
|
||||
return compare != 0 ? compare : compare(aSecond, bSecond);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1965,6 +1965,11 @@ public class StringUtil {
|
||||
return ignoreCase ? s1.compareToIgnoreCase(s2) : s1.compareTo(s2);
|
||||
}
|
||||
|
||||
public static int comparePairs(@Nullable String s1, @Nullable String t1, @Nullable String s2, @Nullable String t2, boolean ignoreCase) {
|
||||
final int compare = compare(s1, s2, ignoreCase);
|
||||
return compare != 0 ? compare : compare(t1, t2, ignoreCase);
|
||||
}
|
||||
|
||||
public static int hashCode(@NotNull CharSequence s) {
|
||||
return stringHashCode(s);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user