mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:10:43 +07:00
[CR-IC-1807] Remove unused file exclusion code
This commit is contained in:
@@ -1,94 +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.file.exclude.ui;
|
||||
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.file.exclude.ProjectFileExclusionManagerImpl;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
/**
|
||||
* @author Rustam Vishnyakov
|
||||
*/
|
||||
public class ExcludeFromProjectAction extends AnAction {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
DataContext dataContext = e.getDataContext();
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
|
||||
if (project == null) return;
|
||||
final VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
|
||||
if (file == null) return;
|
||||
if (file.isDirectory()) {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
addExcludedFolder(project, file);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
ProjectFileExclusionManagerImpl fileExManager = ProjectFileExclusionManagerImpl.getInstance(project);
|
||||
if (fileExManager == null) return;
|
||||
fileExManager.addExclusion(file);
|
||||
}
|
||||
}
|
||||
|
||||
private static void addExcludedFolder(Project project, VirtualFile folder) {
|
||||
Module module = ModuleUtilCore.findModuleForFile(folder, project);
|
||||
if (module == null) return;
|
||||
ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel();
|
||||
for (ContentEntry entry : model.getContentEntries()) {
|
||||
VirtualFile entryFile = entry.getFile();
|
||||
if (entryFile != null) {
|
||||
if (VfsUtilCore.isAncestor(entryFile, folder, true)) {
|
||||
entry.addExcludeFolder(folder);
|
||||
model.commit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
model.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
DataContext dataContext = e.getDataContext();
|
||||
final VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
|
||||
final Presentation presentation = e.getPresentation();
|
||||
if (file == null) {
|
||||
presentation.setVisible(false);
|
||||
return;
|
||||
}
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
|
||||
if (project != null) {
|
||||
ProjectFileExclusionManagerImpl fileExManager = ProjectFileExclusionManagerImpl.getInstance(project);
|
||||
if (fileExManager == null) {
|
||||
presentation.setVisible(false);
|
||||
return;
|
||||
}
|
||||
if (file.equals(project.getBaseDir()) || !file.isWritable()) {
|
||||
presentation.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,109 +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.file.exclude.ui;
|
||||
|
||||
import com.intellij.openapi.file.exclude.ProjectFileExclusionManagerImpl;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.SearchableConfigurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Rustam Vishnyakov
|
||||
*/
|
||||
public class ExcludedFilesConfigurable implements SearchableConfigurable {
|
||||
|
||||
private final ExcludedFilesPanel myExcludedFilesPanel;
|
||||
private final ProjectFileExclusionManagerImpl myExclusionManager;
|
||||
|
||||
public ExcludedFilesConfigurable(Project project) {
|
||||
myExclusionManager = ProjectFileExclusionManagerImpl.getInstance(project);
|
||||
myExcludedFilesPanel = new ExcludedFilesPanel(myExclusionManager != null ? myExclusionManager.getSortedFiles() : null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getId() {
|
||||
return getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable enableSearch(String option) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nls
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Excluded Files"; //TODO<rv> Move to resources
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpTopic() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent createComponent() {
|
||||
return myExcludedFilesPanel.getTopJPanel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
if (myExclusionManager == null) return false;
|
||||
Collection<VirtualFile> currFiles = myExclusionManager.getExcludedFiles();
|
||||
Collection<VirtualFile> newFiles = myExcludedFilesPanel.getExcludedFiles();
|
||||
for (VirtualFile file : currFiles) {
|
||||
if (!newFiles.contains(file)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() throws ConfigurationException {
|
||||
if (myExclusionManager == null) return;
|
||||
final Collection<VirtualFile> currFiles = myExclusionManager.getExcludedFiles();
|
||||
final Collection<VirtualFile> newFiles = myExcludedFilesPanel.getExcludedFiles();
|
||||
final List<VirtualFile> putBackFiles = new ArrayList<VirtualFile>();
|
||||
for (VirtualFile file : currFiles) {
|
||||
if (!newFiles.contains(file)) {
|
||||
putBackFiles.add(file);
|
||||
}
|
||||
}
|
||||
for (VirtualFile file : putBackFiles) {
|
||||
myExclusionManager.removeExclusion(file);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
myExcludedFilesPanel.resetFiles(myExclusionManager != null ? myExclusionManager.getSortedFiles() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeUIResources() {
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.openapi.file.exclude.ui.ExcludedFilesPanel">
|
||||
<grid id="27dc6" binding="myTopPanel" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="61994" class="javax.swing.JButton" binding="myPutBackButton">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
|
||||
<maximum-size width="200" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Put Back"/>
|
||||
<verticalAlignment value="0"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="b73bf">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="cdbe2" class="com.intellij.ui.table.JBTable" binding="myFileTable">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="2" col-span="1" vsize-policy="3" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -1,130 +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.file.exclude.ui;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.event.TableModelListener;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Rustam Vishnyakov
|
||||
*/
|
||||
public class ExcludedFilesPanel {
|
||||
private JPanel myTopPanel;
|
||||
private JButton myPutBackButton;
|
||||
private JBTable myFileTable;
|
||||
|
||||
private final FileTableModel myFileTableModel;
|
||||
|
||||
public ExcludedFilesPanel(Collection<VirtualFile> files) {
|
||||
myFileTableModel = new FileTableModel(files);
|
||||
myFileTable.setModel(myFileTableModel);
|
||||
myFileTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
|
||||
myFileTableModel.addTableModelListener(new TableModelListener() {
|
||||
@Override
|
||||
public void tableChanged(TableModelEvent e) {
|
||||
updateSelection();
|
||||
}
|
||||
});
|
||||
|
||||
myPutBackButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
myFileTableModel.removeFile(myFileTable.getSelectedRow());
|
||||
}
|
||||
});
|
||||
|
||||
updateSelection();
|
||||
}
|
||||
|
||||
private void updateSelection() {
|
||||
if (myFileTableModel.getRowCount() == 0) {
|
||||
myPutBackButton.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
myPutBackButton.setEnabled(true);
|
||||
myFileTable.setRowSelectionInterval(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public JPanel getTopJPanel() {
|
||||
return myTopPanel;
|
||||
}
|
||||
|
||||
private static class FileTableModel extends AbstractTableModel {
|
||||
private final List<VirtualFile> myExcludedFiles = new ArrayList<VirtualFile>();
|
||||
|
||||
public FileTableModel(@Nullable Collection<VirtualFile> files) {
|
||||
if (files != null) {
|
||||
myExcludedFiles.addAll(files);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return myExcludedFiles.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
VirtualFile file = myExcludedFiles.get(rowIndex);
|
||||
return file.getPath();
|
||||
}
|
||||
|
||||
public void removeFile(int index) {
|
||||
if (index >= 0 && index < myExcludedFiles.size()) {
|
||||
myExcludedFiles.remove(index);
|
||||
}
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
public Collection<VirtualFile> getExcludedFiles() {
|
||||
return myExcludedFiles;
|
||||
}
|
||||
|
||||
public void resetFiles(@Nullable Collection<VirtualFile> files) {
|
||||
myExcludedFiles.clear();
|
||||
if (files != null) {
|
||||
myExcludedFiles.addAll(files);
|
||||
}
|
||||
fireTableDataChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<VirtualFile> getExcludedFiles() {
|
||||
return myFileTableModel.getExcludedFiles();
|
||||
}
|
||||
|
||||
public void resetFiles(Collection<VirtualFile> files) {
|
||||
myFileTableModel.resetFiles(files);
|
||||
}
|
||||
}
|
||||
@@ -391,7 +391,6 @@
|
||||
|
||||
<group id="ProjectViewPopupMenuModifyGroup">
|
||||
<reference ref="$Delete"/>
|
||||
<action id="ExcludeFromProject" class="com.intellij.openapi.file.exclude.ui.ExcludeFromProjectAction"/>
|
||||
<group id="MarkFileAs" class="com.intellij.openapi.file.exclude.ui.MarkFileGroup">
|
||||
<action id="MarkAsPlainTextAction" class="com.intellij.openapi.file.exclude.ui.MarkAsPlainTextAction"/>
|
||||
<action id="MarkAsOriginalTypeAction" class="com.intellij.openapi.file.exclude.ui.MarkAsOriginalTypeAction"/>
|
||||
|
||||
@@ -365,12 +365,6 @@
|
||||
<exportable serviceInterface="com.intellij.profile.codeInspection.InspectionProfileManager"/>
|
||||
<schemeOwner serviceInterface="com.intellij.profile.codeInspection.InspectionProfileManager"/>
|
||||
|
||||
<!-- File Exclusions -->
|
||||
<!--
|
||||
<projectService serviceInterface="com.intellij.openapi.file.exclude.ProjectFileExclusionManager"
|
||||
serviceImplementation="com.intellij.openapi.file.exclude.ProjectFileExclusionManagerImpl"/>
|
||||
<projectConfigurable instance="com.intellij.openapi.file.exclude.ui.ExcludedFilesConfigurable"/>
|
||||
-->
|
||||
<fileTypeFactory implementation="com.intellij.openapi.file.exclude.EnforcedPlainTextFileTypeFactory"/>
|
||||
<applicationService serviceInterface="com.intellij.openapi.file.exclude.EnforcedPlainTextFileTypeManager"
|
||||
serviceImplementation="com.intellij.openapi.file.exclude.EnforcedPlainTextFileTypeManager"/>
|
||||
|
||||
Reference in New Issue
Block a user