mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
WI-4511 Automatically add a link to documentation depending on JS library (framework) [r=K.Safonov]
This commit is contained in:
+3
@@ -41,5 +41,8 @@ public abstract class LangScriptingContextProvider {
|
||||
|
||||
@Nullable
|
||||
public abstract String getLibraryTypeName(OrderRootType rootType);
|
||||
|
||||
@Nullable
|
||||
public abstract String getDefaultDocUrl(VirtualFile file);
|
||||
|
||||
}
|
||||
|
||||
@@ -419,13 +419,21 @@ public class EditLibraryDialog extends DialogWrapper {
|
||||
fireIntervalRemoved(this, index, index);
|
||||
}
|
||||
|
||||
public boolean contains(String url) {
|
||||
return myDocUrls.contains(url);
|
||||
}
|
||||
|
||||
public String[] getDocUrls() {
|
||||
return ArrayUtil.toStringArray(myDocUrls);
|
||||
}
|
||||
}
|
||||
|
||||
private void specifyDocUrl() {
|
||||
VirtualFile vf = Util.showSpecifyJavadocUrlDialog(contentPane);
|
||||
String defaultUrl = findUnspecifiedMatchingDocUrl(myFileTableModel.getSourceFiles());
|
||||
if (defaultUrl == null) {
|
||||
defaultUrl = findUnspecifiedMatchingDocUrl(myFileTableModel.getCompactFiles());
|
||||
}
|
||||
VirtualFile vf = Util.showSpecifyJavadocUrlDialog(contentPane, defaultUrl != null ? defaultUrl : "");
|
||||
if (vf != null && vf.isValid()) {
|
||||
String url = vf.getUrl();
|
||||
int index = myDocUrlListModel.addUrl(url);
|
||||
@@ -433,6 +441,21 @@ public class EditLibraryDialog extends DialogWrapper {
|
||||
myDocUrlList.setSelectedIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return myLibName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String findUnspecifiedMatchingDocUrl(VirtualFile[] files) {
|
||||
String docUrl;
|
||||
for (VirtualFile file : files) {
|
||||
docUrl = myProvider.getDefaultDocUrl(file);
|
||||
if (docUrl != null && !myDocUrlListModel.contains(docUrl)) return docUrl;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void removeDocUrl() {
|
||||
myDocUrlListModel.remove((String)myDocUrlList.getSelectedValue());
|
||||
|
||||
+4
-1
@@ -147,7 +147,7 @@ public class ScriptingLibraryManager {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Library createSourceLibrary(String libName, String sourceUrl, LibraryLevel libraryLevel) {
|
||||
public Library createSourceLibrary(String libName, String sourceUrl, String docUrl, LibraryLevel libraryLevel) {
|
||||
LibraryTable libraryTable = getLibraryTable(myProject, libraryLevel);
|
||||
if (libraryTable == null) return null;
|
||||
LibraryTable.ModifiableModel libTableModel = libraryTable.getModifiableModel();
|
||||
@@ -156,6 +156,9 @@ public class ScriptingLibraryManager {
|
||||
if (library != null) {
|
||||
Library.ModifiableModel libModel = library.getModifiableModel();
|
||||
libModel.addRoot(sourceUrl, OrderRootType.SOURCES);
|
||||
if (docUrl != null && docUrl.trim().length() > 0) {
|
||||
libModel.addRoot(docUrl, OrderRootType.DOCUMENTATION);
|
||||
}
|
||||
libModel.commit();
|
||||
libTableModel.commit();
|
||||
return library;
|
||||
|
||||
Reference in New Issue
Block a user