mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
@@ -148,6 +148,7 @@ public class ProjectFacetInfoSet extends FacetInfoSet<Module> {
|
||||
Element element = XmlSerializer.serialize(facetsBean, new SkipDefaultValuesSerializationFilters());
|
||||
try {
|
||||
FileUtil.delete(file);
|
||||
FileUtil.createParentDirs(file);
|
||||
JDOMUtil.writeDocument(new Document(element), file, SystemProperties.getLineSeparator());
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
||||
+10
-1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ide.scriptingContext;
|
||||
|
||||
import com.intellij.ide.scriptingContext.ui.ScriptingContextsConfigurable;
|
||||
import com.intellij.ide.scriptingContext.ui.ScriptingLibrariesPanel;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
@@ -28,13 +29,15 @@ import javax.swing.*;
|
||||
/**
|
||||
* @author Rustam Vishnyakov
|
||||
*/
|
||||
public abstract class LangScriptingContextConfigurable implements Configurable {
|
||||
public abstract class LangScriptingContextConfigurable implements Configurable, Configurable.Composite {
|
||||
private ScriptingLibrariesPanel myPanel;
|
||||
private ScriptingLibraryManager myLibManager;
|
||||
private ScriptingContextsConfigurable myContextsConfigurable;
|
||||
|
||||
public LangScriptingContextConfigurable(Project project, LangScriptingContextProvider provider) {
|
||||
myLibManager = new ScriptingLibraryManager(project, provider.getLibraryType());
|
||||
myPanel = new ScriptingLibrariesPanel(provider, project, myLibManager);
|
||||
myContextsConfigurable = new ScriptingContextsConfigurable(project, provider);
|
||||
}
|
||||
|
||||
@Nls
|
||||
@@ -74,4 +77,10 @@ public abstract class LangScriptingContextConfigurable implements Configurable {
|
||||
public void disposeUIResources() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Configurable[] getConfigurables() {
|
||||
//return new Configurable[] {myContextsConfigurable};
|
||||
return new Configurable[] {};
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -18,6 +18,7 @@ package com.intellij.ide.scriptingContext;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.libraries.LibraryType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -33,4 +34,6 @@ public abstract class LangScriptingContextProvider {
|
||||
|
||||
public abstract boolean acceptsExtension(String fileExt);
|
||||
|
||||
public abstract ScriptingLibraryMappings getLibraryMappings(Project project);
|
||||
|
||||
}
|
||||
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.ide.scriptingContext;
|
||||
|
||||
import com.intellij.lang.LanguagePerFileMappings;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.libraries.LibraryType;
|
||||
import com.intellij.openapi.roots.libraries.scripting.ScriptingLibraryManager;
|
||||
import com.intellij.openapi.roots.libraries.scripting.ScriptingLibraryTable;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Rustam Vishnyakov
|
||||
*/
|
||||
public class ScriptingLibraryMappings extends LanguagePerFileMappings<ScriptingLibraryTable.LibraryModel> {
|
||||
|
||||
private final ScriptingLibraryManager myLibraryManager;
|
||||
|
||||
public ScriptingLibraryMappings(final Project project, final LibraryType libraryType) {
|
||||
super(project);
|
||||
myLibraryManager = new ScriptingLibraryManager(project, libraryType);
|
||||
}
|
||||
|
||||
protected String serialize(final ScriptingLibraryTable.LibraryModel library) {
|
||||
return library.getName();
|
||||
}
|
||||
|
||||
public List<ScriptingLibraryTable.LibraryModel> getAvailableValues() {
|
||||
return getLibraries();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ScriptingLibraryTable.LibraryModel getDefaultMapping(@Nullable VirtualFile file) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ScriptingLibraryTable.LibraryModel> getLibraries() {
|
||||
ArrayList<ScriptingLibraryTable.LibraryModel> libraryModels = new ArrayList<ScriptingLibraryTable.LibraryModel>();
|
||||
libraryModels.addAll(Arrays.asList(myLibraryManager.getLibraries()));
|
||||
return libraryModels;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -39,7 +39,7 @@ import java.util.Arrays;
|
||||
|
||||
public class EditLibraryDialog extends DialogWrapper {
|
||||
|
||||
private static final int FILE_URL_COL = 0;
|
||||
private static final int FILE_LOCATION_COL = 0;
|
||||
private static final int FILE_TYPE_COL = 1;
|
||||
|
||||
private static final String SOURCE_TYPE = "Source";
|
||||
@@ -88,9 +88,13 @@ public class EditLibraryDialog extends DialogWrapper {
|
||||
typeCol.setMaxWidth(80);
|
||||
MyTableCellEditor cellEditor = new MyTableCellEditor(new JComboBox(new String[] {SOURCE_TYPE, COMPACT_TYPE}), myFileTableModel);
|
||||
typeCol.setCellEditor(cellEditor);
|
||||
typeCol.getCellEditor();
|
||||
}
|
||||
|
||||
public EditLibraryDialog(String title, LangScriptingContextProvider provider, Project project, ScriptingLibraryTable.LibraryModel lib) {
|
||||
this(title, provider, project);
|
||||
myLibName.setText(lib.getName());
|
||||
myFileTableModel.setFiles(lib.getSourceFiles(), lib.getCompactFiles());
|
||||
}
|
||||
|
||||
private static class MyTableCellEditor extends DefaultCellEditor {
|
||||
|
||||
@@ -118,13 +122,6 @@ public class EditLibraryDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public EditLibraryDialog(String title, LangScriptingContextProvider provider, Project project, ScriptingLibraryTable.LibraryModel lib) {
|
||||
this(title, provider, project);
|
||||
myLibName.setText(lib.getName());
|
||||
myFileTableModel.setFiles(lib.getSourceFiles(), lib.getCompactFiles());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
return contentPane;
|
||||
@@ -166,8 +163,8 @@ public class EditLibraryDialog extends DialogWrapper {
|
||||
@Override
|
||||
public String getColumnName(int column) {
|
||||
switch(column) {
|
||||
case FILE_URL_COL:
|
||||
return "URL";
|
||||
case FILE_LOCATION_COL:
|
||||
return "Location";
|
||||
case FILE_TYPE_COL:
|
||||
return "Type";
|
||||
}
|
||||
@@ -228,7 +225,7 @@ public class EditLibraryDialog extends DialogWrapper {
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
VirtualFile file = myFiles.get(rowIndex);
|
||||
switch (columnIndex) {
|
||||
case FILE_URL_COL:
|
||||
case FILE_LOCATION_COL:
|
||||
return file;
|
||||
case FILE_TYPE_COL:
|
||||
return myCompactFiles.contains(file) ? COMPACT_TYPE : SOURCE_TYPE;
|
||||
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.ide.scriptingContext.ui;
|
||||
|
||||
import com.intellij.ide.scriptingContext.LangScriptingContextProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.libraries.scripting.ScriptingLibraryTable;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.util.ui.tree.LanguagePerFileConfigurable;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Rustam Vishnyakov
|
||||
*/
|
||||
public class ScriptingContextsConfigurable extends LanguagePerFileConfigurable<ScriptingLibraryTable.LibraryModel> {
|
||||
|
||||
public ScriptingContextsConfigurable(final Project project, final LangScriptingContextProvider provider) {
|
||||
super(project, ScriptingLibraryTable.LibraryModel.class, provider.getLibraryMappings(project),
|
||||
"Specify which libraries are used in specific files and/or directories.", "Library",
|
||||
"Override library settings for child directories and files?", "Override Library Settings");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String visualize(@NotNull ScriptingLibraryTable.LibraryModel library) {
|
||||
return library.getName();
|
||||
}
|
||||
|
||||
@Nls
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Usage Context";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return IconLoader.getIcon("/general/configurableFileTypes.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpTopic() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+15
-4
@@ -15,14 +15,17 @@
|
||||
*/
|
||||
package com.intellij.openapi.roots.libraries.scripting;
|
||||
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.ex.ProjectRootManagerEx;
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryTableBase;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
|
||||
import com.intellij.openapi.roots.libraries.LibraryType;
|
||||
import com.intellij.openapi.util.EmptyRunnable;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -64,9 +67,17 @@ public class ScriptingLibraryManager {
|
||||
}
|
||||
myLibTable = null;
|
||||
}
|
||||
if (myLibLevel == LibraryLevel.GLOBAL) {
|
||||
ModuleManager.getInstance(myProject).getModifiableModel().commit();
|
||||
}
|
||||
updateOpenProjects();
|
||||
}
|
||||
|
||||
private static void updateOpenProjects() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
for (Project project : ProjectManager.getInstance().getOpenProjects()) {
|
||||
ProjectRootManagerEx.getInstanceEx(project).makeRootsChange(EmptyRunnable.getInstance(), false, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateLibraries(LibraryTable.ModifiableModel libTableModel, OrderRootType rootType) {
|
||||
|
||||
+1
-2
@@ -40,8 +40,7 @@ public class ScriptingLibraryTable {
|
||||
private HashSet<VirtualFile> myCompactFilesCache;
|
||||
|
||||
public ScriptingLibraryTable(@NotNull LibraryTable libraryTable, LibraryType libraryType) {
|
||||
LibraryTable.ModifiableModel tableModel = libraryTable.getModifiableModel();
|
||||
for (Library library : tableModel.getLibraries()) {
|
||||
for (Library library : libraryTable.getLibraries()) {
|
||||
if (library instanceof LibraryEx) {
|
||||
LibraryType libType = ((LibraryEx)library).getType();
|
||||
if (libType != null && libType.equals(libraryType)) {
|
||||
|
||||
Reference in New Issue
Block a user