mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git@git.labs.intellij.net:idea/community
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.facet.impl.ui.libraries;
|
||||
|
||||
import com.intellij.framework.library.DownloadableFileDescription;
|
||||
import com.intellij.util.download.DownloadableFileDescription;
|
||||
import com.intellij.framework.library.DownloadableLibraryType;
|
||||
import com.intellij.framework.library.FrameworkLibraryVersion;
|
||||
import com.intellij.ide.ui.ListCellRendererWrapper;
|
||||
@@ -118,12 +118,12 @@ public class DownloadingOptionsDialog extends DialogWrapper {
|
||||
init();
|
||||
}
|
||||
|
||||
private void onVersionChanged(final @Nullable List<DownloadableFileDescription> selected) {
|
||||
private void onVersionChanged(final @Nullable List<? extends DownloadableFileDescription> selected) {
|
||||
final FrameworkLibraryVersion version = getSelectedVersion();
|
||||
if (Comparing.equal(myLastSelectedVersion, version)) return;
|
||||
|
||||
if (version != null) {
|
||||
final List<DownloadableFileDescription> downloads = version.getLibraryFiles();
|
||||
final List<? extends DownloadableFileDescription> downloads = version.getFiles();
|
||||
myFilesList.setModel(new CollectionListModel(
|
||||
ContainerUtil.map2Array(downloads, JCheckBox.class, new Function<DownloadableFileDescription, JCheckBox>() {
|
||||
@Override
|
||||
@@ -169,7 +169,7 @@ public class DownloadingOptionsDialog extends DialogWrapper {
|
||||
|
||||
private List<DownloadableFileDescription> getSelectedDownloads(FrameworkLibraryVersion version) {
|
||||
List<DownloadableFileDescription> selected = new ArrayList<DownloadableFileDescription>();
|
||||
List<DownloadableFileDescription> downloads = version.getLibraryFiles();
|
||||
List<? extends DownloadableFileDescription> downloads = version.getFiles();
|
||||
for (int i = 0; i < downloads.size(); i++) {
|
||||
if (myFilesList.isItemSelected(i)) {
|
||||
selected.add(downloads.get(i));
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.facet.impl.ui.libraries;
|
||||
|
||||
import com.intellij.framework.library.DownloadableFileDescription;
|
||||
import com.intellij.util.download.DownloadableFileDescription;
|
||||
import com.intellij.framework.library.DownloadableLibraryType;
|
||||
import com.intellij.framework.library.FrameworkLibraryVersion;
|
||||
import com.intellij.framework.library.LibraryVersionProperties;
|
||||
@@ -40,19 +40,19 @@ public class LibraryDownloadSettings {
|
||||
private final boolean myDownloadSources;
|
||||
private final boolean myDownloadJavaDocs;
|
||||
private final LibrariesContainer.LibraryLevel myLibraryLevel;
|
||||
private final List<DownloadableFileDescription> mySelectedDownloads;
|
||||
private final List<? extends DownloadableFileDescription> mySelectedDownloads;
|
||||
|
||||
public LibraryDownloadSettings(@NotNull FrameworkLibraryVersion libraryVersion,
|
||||
@Nullable DownloadableLibraryType libraryType,
|
||||
final LibrariesContainer.LibraryLevel libraryLevel, final String downloadedLibrariesPath) {
|
||||
this(libraryVersion, libraryType, downloadedLibrariesPath, libraryVersion.getDefaultLibraryName(), libraryLevel,
|
||||
libraryVersion.getLibraryFiles(), true, true);
|
||||
libraryVersion.getFiles(), true, true);
|
||||
}
|
||||
|
||||
public LibraryDownloadSettings(@NotNull FrameworkLibraryVersion libraryVersion, @Nullable DownloadableLibraryType libraryType,
|
||||
@NotNull String directoryForDownloadedLibrariesPath, @NotNull String libraryName,
|
||||
@NotNull LibrariesContainer.LibraryLevel libraryLevel,
|
||||
@NotNull List<DownloadableFileDescription> selectedDownloads,
|
||||
@NotNull List<? extends DownloadableFileDescription> selectedDownloads,
|
||||
boolean downloadSources, boolean downloadJavaDocs) {
|
||||
myVersion = libraryVersion;
|
||||
myLibraryType = libraryType;
|
||||
@@ -85,7 +85,7 @@ public class LibraryDownloadSettings {
|
||||
return myDirectoryForDownloadedLibrariesPath;
|
||||
}
|
||||
|
||||
public List<DownloadableFileDescription> getSelectedDownloads() {
|
||||
public List<? extends DownloadableFileDescription> getSelectedDownloads() {
|
||||
return mySelectedDownloads;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.facet.impl.ui.libraries;
|
||||
|
||||
import com.intellij.util.download.DownloadableFileSetVersions;
|
||||
import com.intellij.framework.library.DownloadableLibraryDescription;
|
||||
import com.intellij.framework.library.FrameworkLibraryVersion;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
@@ -100,7 +101,7 @@ public class LibraryOptionsPanel implements Disposable {
|
||||
final DownloadableLibraryDescription description = libraryDescription.getDownloadableDescription();
|
||||
if (description != null) {
|
||||
showCard("loading");
|
||||
description.fetchLibraryVersions(new DownloadableLibraryDescription.LibraryVersionsCallback() {
|
||||
description.fetchVersions(new DownloadableFileSetVersions.FileSetVersionsCallback<FrameworkLibraryVersion>() {
|
||||
@Override
|
||||
public void onSuccess(@NotNull final List<? extends FrameworkLibraryVersion> versions) {
|
||||
//noinspection SSBasedInspection
|
||||
|
||||
+6
-6
@@ -16,6 +16,7 @@
|
||||
package com.intellij.framework.library;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.net.URL;
|
||||
@@ -23,15 +24,14 @@ import java.net.URL;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class DownloadableLibraryAssistant {
|
||||
public static DownloadableLibraryAssistant getInstance() {
|
||||
return ServiceManager.getService(DownloadableLibraryAssistant.class);
|
||||
public abstract class DownloadableLibraryService {
|
||||
public static DownloadableLibraryService getInstance() {
|
||||
return ServiceManager.getService(DownloadableLibraryService.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract DownloadableFileDescription createFileDescription(@NotNull String downloadUrl, @NotNull String fileName);
|
||||
|
||||
@NotNull
|
||||
public abstract DownloadableLibraryDescription createLibraryDescription(@NotNull String groupId, @NotNull URL... localUrls);
|
||||
|
||||
@NotNull
|
||||
public abstract CustomLibraryDescription createDescriptionForType(Class<? extends DownloadableLibraryType> typeClass);
|
||||
}
|
||||
@@ -17,10 +17,7 @@ package com.intellij.framework.library.impl;
|
||||
|
||||
import com.intellij.facet.impl.ui.libraries.DownloadingOptionsDialog;
|
||||
import com.intellij.facet.impl.ui.libraries.LibraryDownloadSettings;
|
||||
import com.intellij.framework.library.DownloadableLibraryDescription;
|
||||
import com.intellij.framework.library.DownloadableLibraryType;
|
||||
import com.intellij.framework.library.FrameworkLibraryVersion;
|
||||
import com.intellij.framework.library.LibraryVersionProperties;
|
||||
import com.intellij.framework.library.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.roots.libraries.ui.LibraryEditorComponent;
|
||||
@@ -29,6 +26,7 @@ import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditorBa
|
||||
import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.download.DownloadableFileSetVersions;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -72,7 +70,7 @@ public class DownloadableLibraryEditor extends LibraryPropertiesEditor {
|
||||
|
||||
private void changeVersion() {
|
||||
final ModalityState current = ModalityState.current();
|
||||
myDescription.fetchLibraryVersions(new DownloadableLibraryDescription.LibraryVersionsCallback() {
|
||||
myDescription.fetchVersions(new DownloadableFileSetVersions.FileSetVersionsCallback<FrameworkLibraryVersion>() {
|
||||
@Override
|
||||
public void onSuccess(@NotNull final List<? extends FrameworkLibraryVersion> versions) {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
|
||||
+16
-9
@@ -15,10 +15,13 @@
|
||||
*/
|
||||
package com.intellij.framework.library.impl;
|
||||
|
||||
import com.intellij.framework.library.DownloadableFileDescription;
|
||||
import com.intellij.framework.library.DownloadableLibraryAssistant;
|
||||
import com.intellij.framework.library.DownloadableLibraryDescription;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.framework.library.DownloadableLibraryService;
|
||||
import com.intellij.framework.library.DownloadableLibraryType;
|
||||
import com.intellij.ide.util.frameworkSupport.CustomLibraryDescriptionImpl;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.roots.libraries.LibraryType;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.net.URL;
|
||||
@@ -26,16 +29,20 @@ import java.net.URL;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class DownloadableLibraryAssistantImpl extends DownloadableLibraryAssistant {
|
||||
@NotNull
|
||||
@Override
|
||||
public DownloadableFileDescription createFileDescription(@NotNull String downloadUrl, @NotNull String fileName) {
|
||||
return new DownloadableFileDescriptionImpl(downloadUrl, FileUtil.getNameWithoutExtension(fileName), FileUtil.getExtension(fileName));
|
||||
}
|
||||
public class DownloadableLibraryServiceImpl extends DownloadableLibraryService {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.framework.library.impl.DownloadableLibraryServiceImpl");
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DownloadableLibraryDescription createLibraryDescription(@NotNull String groupId, @NotNull URL... localUrls) {
|
||||
return new LibraryVersionsFetcher(groupId, localUrls);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CustomLibraryDescription createDescriptionForType(Class<? extends DownloadableLibraryType> typeClass) {
|
||||
final DownloadableLibraryType libraryType = LibraryType.EP_NAME.findExtension(typeClass);
|
||||
LOG.assertTrue(libraryType != null, typeClass);
|
||||
return new CustomLibraryDescriptionImpl(libraryType);
|
||||
}
|
||||
}
|
||||
-9
@@ -17,8 +17,6 @@ package com.intellij.ide.util.frameworkSupport;
|
||||
|
||||
import com.intellij.framework.library.DownloadableLibraryDescription;
|
||||
import com.intellij.framework.library.DownloadableLibraryType;
|
||||
import com.intellij.framework.library.LibraryVersionProperties;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.roots.libraries.LibraryType;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryFilter;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -31,7 +29,6 @@ import java.util.List;
|
||||
* @author nik
|
||||
*/
|
||||
public class CustomLibraryDescriptionImpl extends CustomLibraryDescriptionBase {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.util.frameworkSupport.CustomLibraryDescriptionImpl");
|
||||
private final DownloadableLibraryType myLibraryType;
|
||||
|
||||
public CustomLibraryDescriptionImpl(@NotNull DownloadableLibraryType downloadableLibraryType) {
|
||||
@@ -60,10 +57,4 @@ public class CustomLibraryDescriptionImpl extends CustomLibraryDescriptionBase {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static CustomLibraryDescriptionImpl createDescription(Class<? extends DownloadableLibraryType> typeClass) {
|
||||
final DownloadableLibraryType libraryType = LibraryType.EP_NAME.findExtension(typeClass);
|
||||
LOG.assertTrue(libraryType != null, typeClass);
|
||||
return new CustomLibraryDescriptionImpl(libraryType);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -18,10 +18,10 @@ package com.intellij.ide.util.frameworkSupport;
|
||||
import com.intellij.facet.impl.ui.libraries.RequiredLibrariesInfo;
|
||||
import com.intellij.facet.ui.libraries.LibraryDownloadInfo;
|
||||
import com.intellij.facet.ui.libraries.LibraryInfo;
|
||||
import com.intellij.framework.library.DownloadableFileDescription;
|
||||
import com.intellij.util.download.DownloadableFileDescription;
|
||||
import com.intellij.framework.library.DownloadableLibraryDescription;
|
||||
import com.intellij.framework.library.FrameworkLibraryVersion;
|
||||
import com.intellij.framework.library.impl.DownloadableFileDescriptionImpl;
|
||||
import com.intellij.util.download.impl.DownloadableFileDescriptionImpl;
|
||||
import com.intellij.framework.library.impl.DownloadableLibraryDescriptionImpl;
|
||||
import com.intellij.framework.library.impl.FrameworkLibraryVersionImpl;
|
||||
import com.intellij.openapi.roots.libraries.LibraryType;
|
||||
@@ -54,7 +54,8 @@ public class OldCustomLibraryDescription extends CustomLibraryDescriptionBase {
|
||||
for (LibraryInfo info : version.getLibraries()) {
|
||||
final LibraryDownloadInfo downloadingInfo = info.getDownloadingInfo();
|
||||
if (downloadingInfo != null) {
|
||||
final DownloadableFileDescription element = new DownloadableFileDescriptionImpl(downloadingInfo.getDownloadUrl(), downloadingInfo.getFileNamePrefix(), downloadingInfo.getFileNameSuffix());
|
||||
final DownloadableFileDescription
|
||||
element = new DownloadableFileDescriptionImpl(downloadingInfo.getDownloadUrl(), downloadingInfo.getFileNamePrefix(), downloadingInfo.getFileNameSuffix());
|
||||
downloads.add(element);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -338,7 +338,7 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
|
||||
private static boolean shouldRunClassNameCompletion(CompletionResultSet result, CompletionParameters parameters) {
|
||||
if (!Registry.is("show.all.classes.on.first.completion") && parameters.getInvocationCount() < 2) {
|
||||
if (!mayShowAllClasses(parameters)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -371,6 +371,10 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
return mayStartClassName(result, parameters.isRelaxedMatching());
|
||||
}
|
||||
|
||||
public static boolean mayShowAllClasses(CompletionParameters parameters) {
|
||||
return Registry.is("show.all.classes.on.first.completion") || parameters.getInvocationCount() >= 2;
|
||||
}
|
||||
|
||||
public static boolean mayStartClassName(CompletionResultSet result, final boolean relaxedMatching) {
|
||||
String prefix = result.getPrefixMatcher().getPrefix();
|
||||
if (StringUtil.isEmpty(prefix)) {
|
||||
|
||||
@@ -18,11 +18,13 @@ package com.intellij.codeInsight;
|
||||
import com.intellij.openapi.roots.LibraryOrderEntry;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public interface AttachSourcesProvider {
|
||||
@NotNull
|
||||
Collection<AttachSourcesAction> getActions(List<LibraryOrderEntry> orderEntries, PsiFile psiFile);
|
||||
|
||||
interface AttachSourcesAction {
|
||||
|
||||
+5
-9
@@ -27,6 +27,7 @@ import com.intellij.testFramework.PlatformTestUtil
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
import com.intellij.util.ui.UIUtil
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -63,7 +64,7 @@ abstract class CompletionAutoPopupTestCase extends LightCodeInsightFixtureTestCa
|
||||
}
|
||||
|
||||
protected void joinCompletion() {
|
||||
joinCommit()
|
||||
joinCommit() // file copy commit in background
|
||||
|
||||
def controller = AutoPopupController.getInstance(getProject())
|
||||
controller.executePendingRequests();
|
||||
@@ -95,15 +96,10 @@ abstract class CompletionAutoPopupTestCase extends LightCodeInsightFixtureTestCa
|
||||
|
||||
private def joinCommit() {
|
||||
final AtomicBoolean committed = new AtomicBoolean()
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
committed.set(true);
|
||||
}
|
||||
}
|
||||
edt {
|
||||
PsiDocumentManager manager = PsiDocumentManager.getInstance(getProject());
|
||||
manager.cancelAndRunWhenAllCommitted("wait for all comm", runnable);
|
||||
PsiDocumentManager.getInstance(project).cancelAndRunWhenAllCommitted("wait for all comm") {
|
||||
ApplicationManager.application.invokeLater { committed.set(true) }
|
||||
}
|
||||
}
|
||||
while (!committed.get()) {
|
||||
UIUtil.pump();
|
||||
|
||||
+71
-29
@@ -27,7 +27,9 @@ import com.intellij.ide.DataManager;
|
||||
import com.intellij.injected.editor.EditorWindow;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.injection.InjectedLanguageManager;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -220,7 +222,7 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
CommandProcessor.getInstance().executeCommand(project, initCmd, null, null);
|
||||
}
|
||||
|
||||
doComplete(time, initializationContext[0], hasModifiers);
|
||||
insertDummyIdentifier(initializationContext[0], hasModifiers, time);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -245,11 +247,15 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
return lookup;
|
||||
}
|
||||
|
||||
private void doComplete(final int invocationCount, CompletionInitializationContext initContext, boolean hasModifiers) {
|
||||
private void doComplete(CompletionInitializationContext initContext,
|
||||
boolean hasModifiers,
|
||||
int invocationCount,
|
||||
PsiFile hostFile,
|
||||
int hostStartOffset, Editor hostEditor, OffsetMap hostMap) {
|
||||
CompletionContext context = createCompletionContext(hostFile, hostStartOffset, hostEditor, hostMap);
|
||||
CompletionParameters parameters = createCompletionParameters(invocationCount, initContext, context);
|
||||
|
||||
final Editor editor = initContext.getEditor();
|
||||
|
||||
final CompletionParameters parameters = createCompletionParameters(invocationCount, initContext);
|
||||
|
||||
final Semaphore freezeSemaphore = new Semaphore();
|
||||
freezeSemaphore.down();
|
||||
final CompletionProgressIndicator indicator = new CompletionProgressIndicator(editor, parameters, this, freezeSemaphore,
|
||||
@@ -331,21 +337,9 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
private CompletionParameters createCompletionParameters(int invocationCount, final CompletionInitializationContext initContext) {
|
||||
final Ref<CompletionContext> ref = Ref.create(null);
|
||||
CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ref.set(insertDummyIdentifier(initContext));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
final CompletionContext newContext = ref.get();
|
||||
private CompletionParameters createCompletionParameters(int invocationCount,
|
||||
CompletionInitializationContext initContext,
|
||||
final CompletionContext newContext) {
|
||||
|
||||
final int offset = newContext.getStartOffset();
|
||||
final PsiFile fileCopy = newContext.file;
|
||||
@@ -459,12 +453,21 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private CompletionContext insertDummyIdentifier(CompletionInitializationContext initContext) {
|
||||
private void insertDummyIdentifier(final CompletionInitializationContext initContext,
|
||||
final boolean hasModifiers,
|
||||
final int invocationCount) {
|
||||
final PsiFile originalFile = initContext.getFile();
|
||||
PsiFile fileCopy = createFileCopy(originalFile);
|
||||
PsiFile hostFile = InjectedLanguageUtil.getTopLevelFile(fileCopy);
|
||||
final PsiFile fileCopy;
|
||||
AccessToken token = WriteAction.start();
|
||||
try {
|
||||
fileCopy = createFileCopy(originalFile);
|
||||
}
|
||||
finally {
|
||||
token.finish();
|
||||
}
|
||||
final PsiFile hostFile = InjectedLanguageUtil.getTopLevelFile(fileCopy);
|
||||
final InjectedLanguageManager injectedLanguageManager = InjectedLanguageManager.getInstance(hostFile.getProject());
|
||||
int hostStartOffset = injectedLanguageManager.injectedToHost(fileCopy, initContext.getStartOffset());
|
||||
final int hostStartOffset = injectedLanguageManager.injectedToHost(fileCopy, initContext.getStartOffset());
|
||||
final Editor hostEditor = InjectedLanguageUtil.getTopLevelEditor(initContext.getEditor());
|
||||
|
||||
final OffsetMap hostMap = new OffsetMap(hostEditor.getDocument());
|
||||
@@ -473,15 +476,54 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
hostMap.addOffset(key, injectedLanguageManager.injectedToHost(fileCopy, original.getOffset(key)));
|
||||
}
|
||||
|
||||
Document document = fileCopy.getViewProvider().getDocument();
|
||||
final Document document = fileCopy.getViewProvider().getDocument();
|
||||
assert document != null : "no document";
|
||||
patchFileCopy(initContext, fileCopy, document);
|
||||
|
||||
CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
patchFileCopy(initContext, fileCopy, document);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
final Document hostDocument = hostFile.getViewProvider().getDocument();
|
||||
assert hostDocument != null : "no host document";
|
||||
PsiDocumentManager.getInstance(hostFile.getProject()).commitDocument(hostDocument);
|
||||
|
||||
final Project project = hostFile.getProject();
|
||||
|
||||
if (autopopup) {
|
||||
final CompletionPhase.AutoPopupAlarm phase = new CompletionPhase.AutoPopupAlarm(false);
|
||||
CompletionServiceImpl.setCompletionPhase(phase);
|
||||
|
||||
CompletionAutoPopupHandler.runLaterWithCommitted(project, hostDocument, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (phase != CompletionServiceImpl.getCompletionPhase()) return;
|
||||
if (hostEditor.isDisposed()) return;
|
||||
if (DumbService.getInstance(project).isDumb()) return;
|
||||
|
||||
doComplete(initContext, hasModifiers, invocationCount, hostFile, hostStartOffset, hostEditor, hostMap);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
PsiDocumentManager.getInstance(hostFile.getProject()).commitDocument(hostDocument);
|
||||
|
||||
doComplete(initContext, hasModifiers, invocationCount, hostFile, hostStartOffset, hostEditor, hostMap);
|
||||
}
|
||||
}
|
||||
|
||||
private static CompletionContext createCompletionContext(PsiFile hostFile,
|
||||
int hostStartOffset,
|
||||
Editor hostEditor,
|
||||
OffsetMap hostMap) {
|
||||
assert hostFile.isValid() : "file became invalid";
|
||||
assert hostMap.getOffset(CompletionInitializationContext.START_OFFSET) < hostFile.getTextLength() : "startOffset outside the host file";
|
||||
|
||||
InjectedLanguageManager injectedLanguageManager = InjectedLanguageManager.getInstance(hostFile.getProject());
|
||||
CompletionContext context;
|
||||
PsiFile injected = InjectedLanguageUtil.findInjectedPsiNoCommit(hostFile, hostStartOffset);
|
||||
if (injected != null) {
|
||||
@@ -494,10 +536,10 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
for (final OffsetKey key : new ArrayList<OffsetKey>(hostMap.keySet())) {
|
||||
map.addOffset(key, injectedEditor.logicalPositionToOffset(injectedEditor.hostToInjected(hostEditor.offsetToLogicalPosition(hostMap.getOffset(key)))));
|
||||
}
|
||||
context = new CompletionContext(initContext.getProject(), injectedEditor, injected, map);
|
||||
context = new CompletionContext(hostFile.getProject(), injectedEditor, injected, map);
|
||||
assert hostStartOffset == injectedLanguageManager.injectedToHost(injected, context.getStartOffset()) : "inconsistent injected offset translation";
|
||||
} else {
|
||||
context = new CompletionContext(initContext.getProject(), hostEditor, hostFile, hostMap);
|
||||
context = new CompletionContext(hostFile.getProject(), hostEditor, hostFile, hostMap);
|
||||
}
|
||||
|
||||
assert context.getStartOffset() < context.file.getTextLength() : "start outside the file";
|
||||
|
||||
@@ -50,7 +50,7 @@ public abstract class CompletionPhase implements Disposable {
|
||||
|
||||
public final CompletionProgressIndicator indicator;
|
||||
|
||||
protected CompletionPhase(CompletionProgressIndicator indicator) {
|
||||
protected CompletionPhase(@Nullable CompletionProgressIndicator indicator) {
|
||||
this.indicator = indicator;
|
||||
}
|
||||
|
||||
@@ -65,8 +65,11 @@ public abstract class CompletionPhase implements Disposable {
|
||||
}
|
||||
|
||||
public static class AutoPopupAlarm extends CompletionPhase {
|
||||
public AutoPopupAlarm() {
|
||||
final boolean copyCommit;
|
||||
|
||||
public AutoPopupAlarm(boolean copyCommit) {
|
||||
super(null);
|
||||
this.copyCommit = copyCommit;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,6 +77,11 @@ public abstract class CompletionPhase implements Disposable {
|
||||
CompletionServiceImpl.setCompletionPhase(NoCompletion);
|
||||
return time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AutoPopupAlarm{copyCommit=" + copyCommit + '}';
|
||||
}
|
||||
}
|
||||
public static class Synchronous extends CompletionPhase {
|
||||
public Synchronous(CompletionProgressIndicator indicator) {
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ public class CompletionAutoPopupHandler extends TypedHandlerDelegate {
|
||||
public static void scheduleAutoPopup(final Project project, final Editor editor, final PsiFile file) {
|
||||
final boolean isMainEditor = FileEditorManager.getInstance(project).getSelectedTextEditor() == editor;
|
||||
|
||||
final CompletionPhase.AutoPopupAlarm phase = new CompletionPhase.AutoPopupAlarm();
|
||||
final CompletionPhase.AutoPopupAlarm phase = new CompletionPhase.AutoPopupAlarm(false);
|
||||
CompletionServiceImpl.setCompletionPhase(phase);
|
||||
|
||||
final Runnable request = new Runnable() {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.intellij.facet.impl.ui.libraries;
|
||||
|
||||
import com.intellij.framework.library.DownloadableFileDescription;
|
||||
import com.intellij.util.download.DownloadableFileDescription;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.application.Result;
|
||||
|
||||
+2
-13
@@ -15,21 +15,10 @@
|
||||
*/
|
||||
package com.intellij.framework.library;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import com.intellij.util.download.DownloadableFileSetVersions;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface DownloadableLibraryDescription {
|
||||
|
||||
void fetchLibraryVersions(@NotNull LibraryVersionsCallback callback);
|
||||
|
||||
abstract class LibraryVersionsCallback {
|
||||
public abstract void onSuccess(@NotNull List<? extends FrameworkLibraryVersion> versions);
|
||||
|
||||
public void onError(@NotNull String errorMessage) {
|
||||
}
|
||||
}
|
||||
public interface DownloadableLibraryDescription extends DownloadableFileSetVersions<FrameworkLibraryVersion> {
|
||||
}
|
||||
|
||||
@@ -16,22 +16,15 @@
|
||||
package com.intellij.framework.library;
|
||||
|
||||
import com.intellij.ide.util.frameworkSupport.FrameworkVersion;
|
||||
import com.intellij.util.download.DownloadableFileSetDescription;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface FrameworkLibraryVersion {
|
||||
public interface FrameworkLibraryVersion extends DownloadableFileSetDescription {
|
||||
@NotNull
|
||||
String getDefaultLibraryName();
|
||||
|
||||
@NotNull
|
||||
String getVersionString();
|
||||
|
||||
@NotNull
|
||||
List<DownloadableFileDescription> getLibraryFiles();
|
||||
|
||||
boolean isCompatibleWith(@NotNull FrameworkVersion frameworkVersion);
|
||||
}
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ public class DownloadableLibraryDescriptionImpl implements DownloadableLibraryDe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fetchLibraryVersions(@NotNull LibraryVersionsCallback callback) {
|
||||
public void fetchVersions(@NotNull FileSetVersionsCallback<FrameworkLibraryVersion> callback) {
|
||||
callback.onSuccess(myVersions);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-18
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package com.intellij.framework.library.impl;
|
||||
|
||||
import com.intellij.framework.library.DownloadableFileDescription;
|
||||
import com.intellij.util.download.DownloadableFileDescription;
|
||||
import com.intellij.framework.library.FrameworkLibraryVersion;
|
||||
import com.intellij.ide.util.frameworkSupport.FrameworkVersion;
|
||||
import com.intellij.util.download.impl.DownloadableFileSetDescriptionImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -26,9 +27,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class FrameworkLibraryVersionImpl implements FrameworkLibraryVersion {
|
||||
private final List<DownloadableFileDescription> myLibraryFiles;
|
||||
private final String myVersionString;
|
||||
public class FrameworkLibraryVersionImpl extends DownloadableFileSetDescriptionImpl implements FrameworkLibraryVersion {
|
||||
private final String myLibraryCategory;
|
||||
private final FrameworkVersion myFrameworkVersion;
|
||||
|
||||
@@ -36,30 +35,17 @@ public class FrameworkLibraryVersionImpl implements FrameworkLibraryVersion {
|
||||
List<DownloadableFileDescription> libraryFiles,
|
||||
String category,
|
||||
@Nullable FrameworkVersion frameworkVersion) {
|
||||
myVersionString = versionString;
|
||||
myLibraryFiles = libraryFiles;
|
||||
super(category, versionString, libraryFiles);
|
||||
myLibraryCategory = category;
|
||||
myFrameworkVersion = frameworkVersion;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getVersionString() {
|
||||
return myVersionString;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDefaultLibraryName() {
|
||||
return myVersionString.length() > 0 ? myLibraryCategory + "-" + myVersionString : myLibraryCategory;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<DownloadableFileDescription> getLibraryFiles() {
|
||||
return myLibraryFiles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompatibleWith(@NotNull FrameworkVersion frameworkVersion) {
|
||||
return myFrameworkVersion == null || myFrameworkVersion.getVersionName().equals(frameworkVersion.getVersionName());
|
||||
|
||||
+6
-43
@@ -15,64 +15,27 @@
|
||||
*/
|
||||
package com.intellij.framework.library.impl;
|
||||
|
||||
import com.intellij.facet.frameworks.LibrariesDownloadAssistant;
|
||||
import com.intellij.facet.frameworks.beans.Artifact;
|
||||
import com.intellij.facet.frameworks.beans.ArtifactItem;
|
||||
import com.intellij.framework.library.DownloadableFileDescription;
|
||||
import com.intellij.framework.library.DownloadableLibraryAssistant;
|
||||
import com.intellij.util.download.DownloadableFileDescription;
|
||||
import com.intellij.framework.library.DownloadableLibraryDescription;
|
||||
import com.intellij.framework.library.FrameworkLibraryVersion;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.download.impl.FileSetVersionsFetcherBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class LibraryVersionsFetcher implements DownloadableLibraryDescription {
|
||||
private static final Comparator<FrameworkLibraryVersion> VERSIONS_COMPARATOR = new Comparator<FrameworkLibraryVersion>() {
|
||||
@Override
|
||||
public int compare(FrameworkLibraryVersion o1, FrameworkLibraryVersion o2) {
|
||||
return -StringUtil.compareVersionNumbers(o1.getVersionString(), o2.getVersionString());
|
||||
}
|
||||
};
|
||||
private final String myGroupId;
|
||||
private final URL[] myLocalUrls;
|
||||
public class LibraryVersionsFetcher extends FileSetVersionsFetcherBase<FrameworkLibraryVersion> implements DownloadableLibraryDescription {
|
||||
|
||||
public LibraryVersionsFetcher(@NotNull String groupId, @NotNull URL[] localUrls) {
|
||||
myGroupId = groupId;
|
||||
myLocalUrls = localUrls;
|
||||
super(groupId, localUrls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fetchLibraryVersions(@NotNull final LibraryVersionsCallback callback) {
|
||||
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final Artifact[] versions = LibrariesDownloadAssistant.getVersions(myGroupId, myLocalUrls);
|
||||
final List<FrameworkLibraryVersion> result = new ArrayList<FrameworkLibraryVersion>();
|
||||
for (Artifact version : versions) {
|
||||
final ArtifactItem[] items = version.getItems();
|
||||
final List<DownloadableFileDescription> files = new ArrayList<DownloadableFileDescription>();
|
||||
for (ArtifactItem item : items) {
|
||||
String url = item.getUrl();
|
||||
final String prefix = version.getUrlPrefix();
|
||||
if (!url.startsWith("http://") && prefix != null) {
|
||||
url = prefix + url;
|
||||
}
|
||||
files.add(DownloadableLibraryAssistant.getInstance().createFileDescription(url, item.getName()));
|
||||
}
|
||||
result.add(new FrameworkLibraryVersionImpl(version.getVersion(), files, myGroupId, null));
|
||||
}
|
||||
Collections.sort(result, VERSIONS_COMPARATOR);
|
||||
callback.onSuccess(result);
|
||||
}
|
||||
});
|
||||
protected FrameworkLibraryVersion createVersion(Artifact version, List<DownloadableFileDescription> files) {
|
||||
return new FrameworkLibraryVersionImpl(version.getVersion(), files, myGroupId, null);
|
||||
}
|
||||
}
|
||||
|
||||
+9
-3
@@ -27,7 +27,9 @@ public class ANSIColoredConsoleColorsPage implements ColorSettingsPage {
|
||||
"-<stdout> C:></stdout>\n" +
|
||||
"-<stdin> help</stdin>\n" +
|
||||
"<stderr>Bad command or file name</stderr>\n" +
|
||||
"<warning>Log warning</warning>\n" +
|
||||
"\n" +
|
||||
"<logError>Log error</logError>\n" +
|
||||
"<logWarning>Log warning</logWarning>\n" +
|
||||
"\n" +
|
||||
"# Process output highlighted using ANSI colors codes\n" +
|
||||
"<red>ANSI: red</red>\n" +
|
||||
@@ -42,10 +44,13 @@ public class ANSIColoredConsoleColorsPage implements ColorSettingsPage {
|
||||
|
||||
private static final AttributesDescriptor[] ATTRS = new AttributesDescriptor[]{
|
||||
new AttributesDescriptor(OptionsBundle.message("options.general.color.descriptor.console.stdout"), ConsoleViewContentType.NORMAL_OUTPUT_KEY),
|
||||
new AttributesDescriptor(OptionsBundle.message("options.general.color.descriptor.console.warning"), ConsoleViewContentType.WARNING_OUTPUT_KEY),
|
||||
new AttributesDescriptor(OptionsBundle.message("options.general.color.descriptor.console.stderr"), ConsoleViewContentType.ERROR_OUTPUT_KEY),
|
||||
new AttributesDescriptor(OptionsBundle.message("options.general.color.descriptor.console.stdin"), ConsoleViewContentType.USER_INPUT_KEY),
|
||||
new AttributesDescriptor(OptionsBundle.message("options.general.color.descriptor.console.system.output"), ConsoleViewContentType.SYSTEM_OUTPUT_KEY),
|
||||
|
||||
new AttributesDescriptor(OptionsBundle.message("options.general.color.descriptor.console.logError"), ConsoleViewContentType.LOG_ERROR_OUTPUT_KEY),
|
||||
new AttributesDescriptor(OptionsBundle.message("options.general.color.descriptor.console.warning"), ConsoleViewContentType.LOG_WARNING_OUTPUT_KEY),
|
||||
|
||||
new AttributesDescriptor(OptionsBundle.message("color.settings.console.red"), ConsoleHighlighter.RED),
|
||||
new AttributesDescriptor(OptionsBundle.message("color.settings.console.green"), ConsoleHighlighter.GREEN),
|
||||
new AttributesDescriptor(OptionsBundle.message("color.settings.console.yellow"), ConsoleHighlighter.YELLOW),
|
||||
@@ -61,7 +66,8 @@ public class ANSIColoredConsoleColorsPage implements ColorSettingsPage {
|
||||
ADDITIONAL_HIGHLIGHT_DESCRIPTORS.put("stdout", ConsoleViewContentType.NORMAL_OUTPUT_KEY);
|
||||
ADDITIONAL_HIGHLIGHT_DESCRIPTORS.put("stdin", ConsoleViewContentType.USER_INPUT_KEY);
|
||||
ADDITIONAL_HIGHLIGHT_DESCRIPTORS.put("stderr", ConsoleViewContentType.ERROR_OUTPUT_KEY);
|
||||
ADDITIONAL_HIGHLIGHT_DESCRIPTORS.put("warning", ConsoleViewContentType.WARNING_OUTPUT_KEY);
|
||||
ADDITIONAL_HIGHLIGHT_DESCRIPTORS.put("logError", ConsoleViewContentType.LOG_WARNING_OUTPUT_KEY);
|
||||
ADDITIONAL_HIGHLIGHT_DESCRIPTORS.put("logWarning", ConsoleViewContentType.LOG_ERROR_OUTPUT_KEY);
|
||||
|
||||
ADDITIONAL_HIGHLIGHT_DESCRIPTORS.put("red", ConsoleHighlighter.RED);
|
||||
ADDITIONAL_HIGHLIGHT_DESCRIPTORS.put("green", ConsoleHighlighter.GREEN);
|
||||
|
||||
@@ -127,7 +127,7 @@ public class DocumentCommitThread implements Runnable, Disposable {
|
||||
assert !isDisposed;
|
||||
assert project.isInitialized();
|
||||
PsiFile psiFile = PsiDocumentManager.getInstance(project).getCachedPsiFile(document);
|
||||
if (psiFile == null || !psiFile.isPhysical()) return false;
|
||||
if (psiFile == null) return false;
|
||||
|
||||
doQueue(document, project, getCommitStage(document), reason);
|
||||
return true;
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.framework.library;
|
||||
package com.intellij.util.download;
|
||||
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.util.download;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class DownloadableFileService {
|
||||
public static DownloadableFileService getInstance() {
|
||||
return ServiceManager.getService(DownloadableFileService.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract DownloadableFileDescription createFileDescription(@NotNull String downloadUrl, @NotNull String fileName);
|
||||
|
||||
@NotNull
|
||||
public abstract DownloadableFileSetVersions<DownloadableFileSetDescription> createFileSetVersions(@NotNull String groupId, @NotNull URL... localUrls);
|
||||
|
||||
public abstract void loadVersionsToCombobox(@NotNull DownloadableFileSetVersions<?> versions, @NotNull JComboBox comboBox);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.util.download;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface DownloadableFileSetDescription {
|
||||
@NotNull
|
||||
String getName();
|
||||
|
||||
@NotNull
|
||||
String getVersionString();
|
||||
|
||||
@NotNull
|
||||
List<? extends DownloadableFileDescription> getFiles();
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.util.download;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface DownloadableFileSetVersions<F extends DownloadableFileSetDescription> {
|
||||
void fetchVersions(@NotNull FileSetVersionsCallback<F> callback);
|
||||
|
||||
abstract class FileSetVersionsCallback<F extends DownloadableFileSetDescription> {
|
||||
public abstract void onSuccess(@NotNull List<? extends F> versions);
|
||||
|
||||
public void onError(@NotNull String errorMessage) {
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -13,9 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.framework.library.impl;
|
||||
package com.intellij.util.download.impl;
|
||||
|
||||
import com.intellij.framework.library.DownloadableFileDescription;
|
||||
import com.intellij.util.download.DownloadableFileDescription;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Conditions;
|
||||
import com.intellij.util.text.UniqueNameGenerator;
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.util.download.impl;
|
||||
|
||||
import com.intellij.facet.frameworks.beans.Artifact;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.download.DownloadableFileDescription;
|
||||
import com.intellij.util.download.DownloadableFileService;
|
||||
import com.intellij.util.download.DownloadableFileSetDescription;
|
||||
import com.intellij.util.download.DownloadableFileSetVersions;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class DownloadableFileServiceImpl extends DownloadableFileService {
|
||||
@NotNull
|
||||
@Override
|
||||
public DownloadableFileDescription createFileDescription(@NotNull String downloadUrl, @NotNull String fileName) {
|
||||
return new DownloadableFileDescriptionImpl(downloadUrl, FileUtil.getNameWithoutExtension(fileName), FileUtil.getExtension(fileName));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DownloadableFileSetVersions<DownloadableFileSetDescription> createFileSetVersions(@NotNull String groupId,
|
||||
@NotNull URL... localUrls) {
|
||||
return new FileSetVersionsFetcherBase<DownloadableFileSetDescription>(groupId, localUrls) {
|
||||
@Override
|
||||
protected DownloadableFileSetDescription createVersion(Artifact version, List<DownloadableFileDescription> files) {
|
||||
return new DownloadableFileSetDescriptionImpl(version.getName(), version.getVersion(), files);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadVersionsToCombobox(@NotNull DownloadableFileSetVersions<?> versions, @NotNull JComboBox comboBox) {
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.util.download.impl;
|
||||
|
||||
import com.intellij.util.download.DownloadableFileDescription;
|
||||
import com.intellij.util.download.DownloadableFileSetDescription;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class DownloadableFileSetDescriptionImpl implements DownloadableFileSetDescription {
|
||||
protected final List<DownloadableFileDescription> myFiles;
|
||||
protected final String myVersionString;
|
||||
private final String myName;
|
||||
|
||||
public DownloadableFileSetDescriptionImpl(@NotNull String name,
|
||||
@NotNull String versionString,
|
||||
@NotNull List<DownloadableFileDescription> files) {
|
||||
myName = name;
|
||||
myVersionString = versionString;
|
||||
myFiles = files;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getVersionString() {
|
||||
return myVersionString;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<? extends DownloadableFileDescription> getFiles() {
|
||||
return myFiles;
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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.util.download.impl;
|
||||
|
||||
import com.intellij.facet.frameworks.LibrariesDownloadAssistant;
|
||||
import com.intellij.facet.frameworks.beans.Artifact;
|
||||
import com.intellij.facet.frameworks.beans.ArtifactItem;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.download.DownloadableFileDescription;
|
||||
import com.intellij.util.download.DownloadableFileService;
|
||||
import com.intellij.util.download.DownloadableFileSetDescription;
|
||||
import com.intellij.util.download.DownloadableFileSetVersions;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class FileSetVersionsFetcherBase<F extends DownloadableFileSetDescription> implements DownloadableFileSetVersions<F> {
|
||||
private static final Comparator<DownloadableFileSetDescription> VERSIONS_COMPARATOR = new Comparator<DownloadableFileSetDescription>() {
|
||||
@Override
|
||||
public int compare(DownloadableFileSetDescription o1, DownloadableFileSetDescription o2) {
|
||||
return -StringUtil.compareVersionNumbers(o1.getVersionString(), o2.getVersionString());
|
||||
}
|
||||
};
|
||||
protected final String myGroupId;
|
||||
private final URL[] myLocalUrls;
|
||||
|
||||
public FileSetVersionsFetcherBase(@NotNull String groupId, @NotNull URL[] localUrls) {
|
||||
myLocalUrls = localUrls;
|
||||
myGroupId = groupId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fetchVersions(@NotNull final FileSetVersionsCallback<F> callback) {
|
||||
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final Artifact[] versions = LibrariesDownloadAssistant.getVersions(myGroupId, myLocalUrls);
|
||||
final List<F> result = new ArrayList<F>();
|
||||
for (Artifact version : versions) {
|
||||
final ArtifactItem[] items = version.getItems();
|
||||
final List<DownloadableFileDescription> files = new ArrayList<DownloadableFileDescription>();
|
||||
for (ArtifactItem item : items) {
|
||||
String url = item.getUrl();
|
||||
final String prefix = version.getUrlPrefix();
|
||||
if (!url.startsWith("http://") && prefix != null) {
|
||||
url = prefix + url;
|
||||
}
|
||||
files.add(DownloadableFileService.getInstance().createFileDescription(url, item.getName()));
|
||||
}
|
||||
result.add(createVersion(version, files));
|
||||
}
|
||||
Collections.sort(result, VERSIONS_COMPARATOR);
|
||||
callback.onSuccess(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract F createVersion(Artifact version, List<DownloadableFileDescription> files);
|
||||
}
|
||||
@@ -39,13 +39,13 @@ public class ConsoleViewContentType {
|
||||
public static final ColorKey CONSOLE_BACKGROUND_KEY = ColorKey.createColorKey("CONSOLE_BACKGROUND_KEY");
|
||||
|
||||
public static final TextAttributesKey NORMAL_OUTPUT_KEY = TextAttributesKey.createTextAttributesKey("CONSOLE_NORMAL_OUTPUT");
|
||||
public static final TextAttributesKey WARNING_OUTPUT_KEY = TextAttributesKey.createTextAttributesKey("CONSOLE_WARNING_OUTPUT");
|
||||
public static final TextAttributesKey LOG_WARNING_OUTPUT_KEY = TextAttributesKey.createTextAttributesKey("LOG_WARNING_OUTPUT");
|
||||
public static final TextAttributesKey ERROR_OUTPUT_KEY = TextAttributesKey.createTextAttributesKey("CONSOLE_ERROR_OUTPUT");
|
||||
public static final TextAttributesKey LOG_ERROR_OUTPUT_KEY = TextAttributesKey.createTextAttributesKey("LOG_ERROR_OUTPUT");
|
||||
public static final TextAttributesKey USER_INPUT_KEY = TextAttributesKey.createTextAttributesKey("CONSOLE_USER_INPUT");
|
||||
public static final TextAttributesKey SYSTEM_OUTPUT_KEY = TextAttributesKey.createTextAttributesKey("CONSOLE_SYSTEM_OUTPUT");
|
||||
|
||||
public static final ConsoleViewContentType NORMAL_OUTPUT = new ConsoleViewContentType("NORMAL_OUTPUT", NORMAL_OUTPUT_KEY);
|
||||
public static final ConsoleViewContentType WARNING_OUTPUT = new ConsoleViewContentType("ERROR_OUTPUT", WARNING_OUTPUT_KEY);
|
||||
public static final ConsoleViewContentType ERROR_OUTPUT = new ConsoleViewContentType("ERROR_OUTPUT", ERROR_OUTPUT_KEY);
|
||||
public static final ConsoleViewContentType USER_INPUT = new ConsoleViewContentType("USER_OUTPUT", USER_INPUT_KEY);
|
||||
public static final ConsoleViewContentType SYSTEM_OUTPUT = new ConsoleViewContentType("SYSTEM_OUTPUT", SYSTEM_OUTPUT_KEY);
|
||||
|
||||
@@ -251,4 +251,7 @@ public interface IdeActions {
|
||||
String ACTION_MOVE_STATEMENT_DOWN_ACTION = "MoveStatementDown";
|
||||
|
||||
String ACTION_COMPARE_CLIPBOARD_WITH_SELECTION = "CompareClipboardWithSelection";
|
||||
|
||||
String ACTION_UNDO = "$Undo";
|
||||
String ACTION_REDO = "$Redo";
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.actionSystem.KeyboardShortcut;
|
||||
import com.intellij.openapi.actionSystem.Shortcut;
|
||||
import com.intellij.openapi.keymap.KeymapManager;
|
||||
@@ -50,8 +51,8 @@ public class TextComponentUndoProvider implements Disposable {
|
||||
myOldKeymap = myTextComponent.getKeymap();
|
||||
Keymap keymap = JTextComponent.addKeymap(null, myOldKeymap);
|
||||
com.intellij.openapi.keymap.Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap();
|
||||
Shortcut[] undoShortcuts = activeKeymap.getShortcuts("$Undo");
|
||||
Shortcut[] redoShortcuts = activeKeymap.getShortcuts("$Redo");
|
||||
Shortcut[] undoShortcuts = activeKeymap.getShortcuts(IdeActions.ACTION_UNDO);
|
||||
Shortcut[] redoShortcuts = activeKeymap.getShortcuts(IdeActions.ACTION_REDO);
|
||||
|
||||
Action undoAction = new AbstractAction ("Undo") {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
@@ -233,6 +233,20 @@ public class EventLog implements Notifications {
|
||||
}
|
||||
});
|
||||
group.add(new ScrollToTheEndToolbarAction(editor));
|
||||
group.add(new DumbAwareAction("Mark all as read", "Mark all unread notifications as read", IconLoader.getIcon("/general/reset.png")) {
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
e.getPresentation().setEnabled(!getProjectComponent(project).myProjectModel.getNotifications().isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
LogModel model = getProjectComponent(project).myProjectModel;
|
||||
for (Notification notification : model.getNotifications()) {
|
||||
model.removeNotification(notification);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, false);
|
||||
toolbar.setTargetComponent(panel);
|
||||
|
||||
@@ -26,13 +26,17 @@ import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
import com.intellij.openapi.editor.ScrollType;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.editor.event.EditorMouseEvent;
|
||||
import com.intellij.openapi.editor.ex.EditorMarkupModel;
|
||||
import com.intellij.openapi.editor.markup.*;
|
||||
import com.intellij.openapi.editor.markup.HighlighterLayer;
|
||||
import com.intellij.openapi.editor.markup.HighlighterTargetArea;
|
||||
import com.intellij.openapi.editor.markup.RangeHighlighter;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.util.EditorPopupHandler;
|
||||
@@ -53,7 +57,7 @@ class EventLogConsole {
|
||||
|
||||
EventLogConsole(@NotNull Project project, LogModel model) {
|
||||
myProjectModel = model;
|
||||
myLogEditor = ConsoleViewUtil.setupConsoleEditor(project, false, true);
|
||||
myLogEditor = ConsoleViewUtil.setupConsoleEditor(project, false, false);
|
||||
|
||||
((EditorMarkupModel) myLogEditor.getMarkupModel()).setErrorStripeVisible(true);
|
||||
|
||||
@@ -113,18 +117,19 @@ class EventLogConsole {
|
||||
Pair<String, Boolean> pair = EventLog.formatForLog(notification);
|
||||
|
||||
final NotificationType type = notification.getType();
|
||||
ConsoleViewContentType contentType = type == NotificationType.ERROR
|
||||
? ConsoleViewContentType.ERROR_OUTPUT
|
||||
TextAttributesKey key = type == NotificationType.ERROR
|
||||
? ConsoleViewContentType.LOG_ERROR_OUTPUT_KEY
|
||||
: type == NotificationType.INFORMATION
|
||||
? ConsoleViewContentType.NORMAL_OUTPUT
|
||||
: ConsoleViewContentType.WARNING_OUTPUT;
|
||||
? ConsoleViewContentType.NORMAL_OUTPUT_KEY
|
||||
: ConsoleViewContentType.LOG_WARNING_OUTPUT_KEY;
|
||||
|
||||
int msgStart = document.getTextLength();
|
||||
String message = pair.first;
|
||||
append(document, message);
|
||||
myLogEditor.getMarkupModel()
|
||||
.addRangeHighlighter(msgStart, document.getTextLength(), HighlighterLayer.CARET_ROW + 1, contentType.getAttributes(),
|
||||
HighlighterTargetArea.EXACT_RANGE);
|
||||
|
||||
TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(key);
|
||||
int layer = HighlighterLayer.CARET_ROW + 1;
|
||||
myLogEditor.getMarkupModel().addRangeHighlighter(msgStart, document.getTextLength(), layer, attributes, HighlighterTargetArea.EXACT_RANGE);
|
||||
|
||||
if (pair.second) {
|
||||
String s = " ";
|
||||
@@ -174,44 +179,6 @@ class EventLogConsole {
|
||||
: notification.getType() == NotificationType.WARNING ? Color.yellow : Color.green;
|
||||
lineHighlighter.setErrorStripeMarkColor(color);
|
||||
lineHighlighter.setErrorStripeTooltip(message);
|
||||
lineHighlighter.setGutterIconRenderer(new GutterIconRenderer() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return IconLoader.getIcon("/general/reset.png");
|
||||
}
|
||||
|
||||
@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return this == obj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltipText() {
|
||||
return "Mark as read";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNavigateAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnAction getClickAction() {
|
||||
return new AnAction() {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
myProjectModel.removeNotification(notification);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
myProjectModel.removeHandlers.put(notification, new Runnable() {
|
||||
@Override
|
||||
|
||||
@@ -43,7 +43,7 @@ public class LogModel {
|
||||
}
|
||||
|
||||
void addNotification(Notification notification) {
|
||||
if (NotificationsConfiguration.getSettings(notification.getGroupId()).getDisplayType() != NotificationDisplayType.NONE) {
|
||||
if (notification.isImportant() || NotificationsConfiguration.getSettings(notification.getGroupId()).getDisplayType() != NotificationDisplayType.NONE) {
|
||||
synchronized (myNotifications) {
|
||||
myNotifications.add(notification);
|
||||
}
|
||||
|
||||
-861
@@ -1,861 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.notification.impl.ui;
|
||||
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.impl.NotificationModelListener;
|
||||
import com.intellij.notification.impl.NotificationsManagerImpl;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.*;
|
||||
import com.intellij.openapi.ui.popup.util.MinimizeButton;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.wm.impl.content.GraphicsConfig;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.components.panels.Wrapper;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.ui.BaseButtonBehavior;
|
||||
import com.intellij.util.ui.TimedDeadzone;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
import javax.swing.event.ListDataEvent;
|
||||
import javax.swing.event.ListDataListener;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author spleaner
|
||||
*/
|
||||
public class NotificationsListPanel extends JPanel implements NotificationModelListener, Disposable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.notification.impl.ui.NotificationsListPanel");
|
||||
private static final String REMOVE_KEY = "REMOVE";
|
||||
|
||||
private static final Icon CLOSE_ICON = IconLoader.getIcon("/general/balloonClose.png");
|
||||
|
||||
private Project myProject;
|
||||
private final Wrapper myWrapper;
|
||||
private JComponent myActiveComponent;
|
||||
|
||||
private final JComponent myEmptyComponent;
|
||||
private final JComponent myListComponent;
|
||||
|
||||
public NotificationsListPanel(@Nullable final Project project) {
|
||||
setLayout(new BorderLayout());
|
||||
myProject = project;
|
||||
|
||||
myEmptyComponent = new JLabel("No new notifications.", JLabel.CENTER);
|
||||
myListComponent = ItemsList.create(project, this);
|
||||
|
||||
myWrapper = new Wrapper();
|
||||
myWrapper.setContent(getCurrentComponent(project));
|
||||
|
||||
setMinimumSize(new Dimension(350, 300));
|
||||
add(myWrapper, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
public void notificationsAdded(@NotNull Notification... notification) {
|
||||
switchView(myProject);
|
||||
}
|
||||
|
||||
public void notificationsRemoved(@NotNull Notification... notification) {
|
||||
switchView(myProject);
|
||||
}
|
||||
|
||||
public void notificationsRead(@NotNull Notification... notification) {
|
||||
switchView(myProject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNotify() {
|
||||
super.addNotify();
|
||||
getManager().addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNotify() {
|
||||
getManager().removeListener(this);
|
||||
super.removeNotify();
|
||||
}
|
||||
|
||||
private JComponent getCurrentComponent(@Nullable final Project project) {
|
||||
final boolean empty = getManager().count(project) == 0;
|
||||
final JComponent component = empty ? myEmptyComponent : myListComponent;
|
||||
if (myActiveComponent == component) return null;
|
||||
|
||||
myActiveComponent = component;
|
||||
return myActiveComponent;
|
||||
}
|
||||
|
||||
protected void switchView(@Nullable final Project project) {
|
||||
final JComponent component = getCurrentComponent(project);
|
||||
if (component != null) {
|
||||
myWrapper.setContent(component);
|
||||
myWrapper.revalidate();
|
||||
myWrapper.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
getManager().markRead();
|
||||
|
||||
myProject = null;
|
||||
}
|
||||
|
||||
private static NotificationsManagerImpl getManager() {
|
||||
return NotificationsManagerImpl.getNotificationsManagerImpl();
|
||||
}
|
||||
|
||||
static Dimension getMinSize() {
|
||||
final Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
size.width *= 0.1d;
|
||||
size.height *= 0.1d;
|
||||
return size;
|
||||
}
|
||||
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return myWrapper.getTargetComponent();
|
||||
}
|
||||
|
||||
public static JBPopup show(@Nullable final Project project, @NotNull final JComponent parent) {
|
||||
final NotificationsListPanel panel = new NotificationsListPanel(project);
|
||||
final ComponentPopupBuilder builder =
|
||||
JBPopupFactory.getInstance().createComponentPopupBuilder(panel, panel.getPreferredFocusedComponent());
|
||||
final JBPopup popup = builder.setResizable(true).setMinSize(getMinSize()).setDimensionServiceKey(null, "NotificationsPopup", true)
|
||||
.setCancelOnClickOutside(false).setBelongsToGlobalPopupStack(false).setCancelButton(new MinimizeButton("Hide")).setMovable(true)
|
||||
.setRequestFocus(true).setTitle("Notifications").createPopup();
|
||||
|
||||
popup.addListener(new JBPopupListener.Adapter() {
|
||||
@Override
|
||||
public void onClosed(LightweightWindowEvent event) {
|
||||
Disposer.dispose(panel);
|
||||
}
|
||||
});
|
||||
|
||||
popup.showInCenterOf(SwingUtilities.getRootPane(parent));
|
||||
return popup;
|
||||
}
|
||||
|
||||
private static class NotificationsListRenderer extends JComponent implements ListCellRenderer {
|
||||
private final JTextPane myText;
|
||||
private boolean mySelected;
|
||||
private boolean myHasFocus;
|
||||
private final JLabel myIconLabel;
|
||||
private Processor<Cursor> myProc;
|
||||
private boolean myWasRead;
|
||||
private JList myList;
|
||||
private JTextPane myFakeTextPane;
|
||||
private JViewport myFakeViewport;
|
||||
|
||||
private NotificationsListRenderer() {
|
||||
setLayout(new BorderLayout());
|
||||
setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4));
|
||||
|
||||
setOpaque(false);
|
||||
|
||||
myIconLabel = new JLabel();
|
||||
myIconLabel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
|
||||
myIconLabel.setOpaque(false);
|
||||
|
||||
myText = new JTextPane() {
|
||||
@Override
|
||||
public void setCursor(Cursor cursor) {
|
||||
super.setCursor(cursor);
|
||||
onCursorChanged(cursor);
|
||||
}
|
||||
};
|
||||
|
||||
myFakeTextPane = new JTextPane();
|
||||
myText.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0));
|
||||
myFakeTextPane.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0));
|
||||
myText.setOpaque(false);
|
||||
if (UIUtil.isUnderNimbusLookAndFeel()) {
|
||||
myText.setBackground(new Color(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
myText.setEditable(false);
|
||||
myFakeTextPane.setEditable(false);
|
||||
myText.setEditorKit(UIUtil.getHTMLEditorKit());
|
||||
myFakeTextPane.setEditorKit(UIUtil.getHTMLEditorKit());
|
||||
|
||||
myFakeViewport = new JViewport();
|
||||
myFakeViewport.setView(myFakeTextPane);
|
||||
|
||||
final Wrapper.North comp = new Wrapper.North(myIconLabel);
|
||||
comp.setOpaque(false);
|
||||
add(comp, BorderLayout.WEST);
|
||||
add(myText, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
public JTextPane getText() {
|
||||
return myText;
|
||||
}
|
||||
|
||||
public void setCursorHandler(Processor<Cursor> proc) {
|
||||
myProc = proc;
|
||||
}
|
||||
|
||||
public void resetCursorHandler() {
|
||||
myProc = null;
|
||||
}
|
||||
|
||||
public void onCursorChanged(Cursor cursor) {
|
||||
if (myProc != null) myProc.process(cursor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
final Container parent = myList.getParent();
|
||||
if (parent != null) {
|
||||
myFakeTextPane.setText(myText.getText());
|
||||
final Dimension size = parent.getSize();
|
||||
myFakeViewport.setSize(size);
|
||||
final Dimension preferredSize = myFakeTextPane.getPreferredSize();
|
||||
|
||||
final Insets insets = getInsets();
|
||||
return new Dimension(Math.min(size.width - 20, preferredSize.width), preferredSize.height + insets.top + insets.bottom);
|
||||
}
|
||||
|
||||
return super.getPreferredSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
final Graphics2D g2d = (Graphics2D)g;
|
||||
|
||||
final Rectangle bounds = getBounds();
|
||||
final Insets insets = getInsets();
|
||||
|
||||
final GraphicsConfig cfg = new GraphicsConfig(g);
|
||||
cfg.setAntialiasing(true);
|
||||
|
||||
final Shape shape = new RoundRectangle2D.Double(insets.left, insets.top, bounds.width - 1 - insets.left - insets.right,
|
||||
bounds.height - 1 - insets.top - insets.bottom, 6, 6);
|
||||
|
||||
if (mySelected) {
|
||||
g2d.setColor(UIUtil.getListSelectionBackground());
|
||||
g2d.fillRect(0, 0, bounds.width, bounds.height);
|
||||
}
|
||||
|
||||
g2d.setColor(Color.WHITE);
|
||||
g2d.fill(shape);
|
||||
|
||||
|
||||
Color bgColor = getBackground();
|
||||
if (myWasRead) {
|
||||
bgColor = new Color(bgColor.getRed(), bgColor.getGreen(), bgColor.getBlue(), 60);
|
||||
}
|
||||
|
||||
g2d.setColor(bgColor);
|
||||
g2d.fill(shape);
|
||||
|
||||
g2d.setColor(myHasFocus || mySelected ? getBackground().darker().darker() : myWasRead ? getBackground() : getBackground().darker());
|
||||
g2d.draw(shape);
|
||||
cfg.restore();
|
||||
|
||||
super.paintComponent(g);
|
||||
}
|
||||
|
||||
public Component getListCellRendererComponent(final JList list,
|
||||
final Object value,
|
||||
final int index,
|
||||
final boolean isSelected,
|
||||
final boolean cellHasFocus) {
|
||||
LOG.assertTrue(value instanceof Notification);
|
||||
final Notification notification = (Notification)value;
|
||||
|
||||
myList = list;
|
||||
|
||||
mySelected = isSelected;
|
||||
myHasFocus = cellHasFocus;
|
||||
|
||||
myText.setText(NotificationsUtil.buildHtml(notification));
|
||||
myIconLabel.setIcon(NotificationsUtil.getIcon(notification));
|
||||
myWasRead = NotificationsManagerImpl.getNotificationsManagerImpl().wasRead(notification);
|
||||
|
||||
setBackground(NotificationsUtil.getBackground(notification));
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private static class NotificationsListModel extends AbstractListModel implements NotificationModelListener, Disposable {
|
||||
private final List<Notification> myNotifications = new ArrayList<Notification>();
|
||||
private NotificationType myType;
|
||||
private Project myProject;
|
||||
private final NotNullFunction<Project, Collection<Notification>> myRebuildFunction;
|
||||
private boolean myArchive;
|
||||
|
||||
private NotificationsListModel(@Nullable Project project) {
|
||||
myProject = project;
|
||||
|
||||
myRebuildFunction = new NotNullFunction<Project, Collection<Notification>>() {
|
||||
@NotNull
|
||||
public Collection<Notification> fun(Project project) {
|
||||
return getManager().getByType(myType, project);
|
||||
}
|
||||
};
|
||||
|
||||
getManager().addListener(this);
|
||||
rebuildList();
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
getManager().removeListener(this);
|
||||
myProject = null;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return myNotifications.size();
|
||||
}
|
||||
|
||||
public Object getElementAt(final int index) {
|
||||
return index < myNotifications.size() ? myNotifications.get(index) : null;
|
||||
}
|
||||
|
||||
private void rebuildList() {
|
||||
myNotifications.clear();
|
||||
myNotifications.addAll(myRebuildFunction.fun(myProject));
|
||||
fireContentsChanged(this, 0, myNotifications.size() - 1);
|
||||
}
|
||||
|
||||
public void filter(final NotificationType type) {
|
||||
myType = type;
|
||||
rebuildList();
|
||||
}
|
||||
|
||||
public void notificationsAdded(@NotNull Notification... notification) {
|
||||
rebuildList();
|
||||
}
|
||||
|
||||
public void notificationsRemoved(@NotNull Notification... notification) {
|
||||
rebuildList();
|
||||
}
|
||||
|
||||
public void notificationsRead(@NotNull Notification... notification) {
|
||||
rebuildList();
|
||||
}
|
||||
}
|
||||
|
||||
private static class ItemsList extends JBList {
|
||||
private ItemsList(final NotificationsListModel model) {
|
||||
super(model);
|
||||
setOpaque(false);
|
||||
|
||||
setCellRenderer(new NotificationsListRenderer());
|
||||
getSelectionModel().setSelectionInterval(0, 0);
|
||||
|
||||
getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), REMOVE_KEY);
|
||||
getActionMap().put(REMOVE_KEY, new AbstractAction() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
removeSelected();
|
||||
}
|
||||
});
|
||||
|
||||
setBackground(UIUtil.getPanelBackground());
|
||||
|
||||
addMouseMotionListener(new MouseMotionListener() {
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
processMouse(e, false);
|
||||
}
|
||||
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
}
|
||||
});
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(final MouseEvent e) {
|
||||
if (!e.isPopupTrigger()) {
|
||||
processMouse(e, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ExpireButton.install(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldInstallItemTooltipExpander() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void processMouse(final MouseEvent e, final boolean click) {
|
||||
final int index = locationToIndex(e.getPoint());
|
||||
if (index > -1) {
|
||||
final Object value = getModel().getElementAt(index);
|
||||
if (value != null && value instanceof Notification) {
|
||||
final Notification notification = (Notification)value;
|
||||
final Component renderer = getCellRenderer().getListCellRendererComponent(this, value, index, false, false);
|
||||
if (renderer instanceof NotificationsListRenderer) {
|
||||
final Rectangle bounds = getCellBounds(index, index);
|
||||
renderer.setBounds(bounds);
|
||||
renderer.doLayout();
|
||||
|
||||
final JTextPane text = ((NotificationsListRenderer)renderer).getText();
|
||||
|
||||
Processor<Cursor> processor;
|
||||
HyperlinkListener listener = null;
|
||||
if (click) {
|
||||
listener = NotificationsUtil.wrapListener(notification);
|
||||
if (listener != null) text.addHyperlinkListener(listener);
|
||||
}
|
||||
else {
|
||||
processor = new Processor<Cursor>() {
|
||||
public boolean process(Cursor cursor) {
|
||||
ItemsList.this.setCursor(cursor);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
((NotificationsListRenderer)renderer).setCursorHandler(processor);
|
||||
}
|
||||
|
||||
final Point point = e.getPoint();
|
||||
point.translate(-bounds.x, -bounds.y);
|
||||
|
||||
final Rectangle r = text.getBounds();
|
||||
point.translate(-r.x, -r.y);
|
||||
|
||||
final MouseEvent newEvent =
|
||||
new MouseEvent(text, e.getID(), e.getWhen(), e.getModifiers(), point.x, point.y, e.getClickCount(), e.isPopupTrigger(),
|
||||
e.getButton());
|
||||
|
||||
text.dispatchEvent(newEvent);
|
||||
|
||||
((NotificationsListRenderer)renderer).resetCursorHandler();
|
||||
if (listener != null) {
|
||||
text.removeHyperlinkListener(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"ConstantConditions"})
|
||||
@Override
|
||||
public NotificationsListModel getModel() {
|
||||
final ListModel listModel = super.getModel();
|
||||
return listModel instanceof NotificationsListModel ? (NotificationsListModel)listModel : null;
|
||||
}
|
||||
|
||||
public void removeSelected() {
|
||||
final ListSelectionModel model = getSelectionModel();
|
||||
final NotificationsListModel listModel = getModel();
|
||||
if (!model.isSelectionEmpty()) {
|
||||
final int min = model.getMinSelectionIndex();
|
||||
final int max = model.getMaxSelectionIndex();
|
||||
|
||||
final List<Notification> tbr = new ArrayList<Notification>();
|
||||
for (int i = min; i <= max; i++) {
|
||||
if (model.isSelectedIndex(i)) {
|
||||
final Notification notification = (Notification)listModel.getElementAt(i);
|
||||
if (notification != null) {
|
||||
tbr.add(notification);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tbr.size() > 0) {
|
||||
getManager().remove(tbr.toArray(new Notification[tbr.size()]));
|
||||
|
||||
final int toSelect = Math.min(min, listModel.getSize() - 1);
|
||||
model.clearSelection();
|
||||
if (toSelect >= 0) {
|
||||
model.setSelectionInterval(toSelect, toSelect);
|
||||
scrollRectToVisible(getCellBounds(toSelect, toSelect));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
|
||||
private static void createFilterButton(final JPanel parent,
|
||||
final ButtonGroup group,
|
||||
final String title,
|
||||
final ActionListener listener,
|
||||
final NotNullFunction<MyButton, String> titleCallback,
|
||||
final char mnemonic,
|
||||
final boolean active) {
|
||||
final StickyButton b = new MyButton(title, listener) {
|
||||
@Override
|
||||
public void updateTitle() {
|
||||
setText(titleCallback.fun(this));
|
||||
}
|
||||
};
|
||||
|
||||
parent.add(b);
|
||||
group.add(b);
|
||||
|
||||
b.setFocusable(false);
|
||||
b.setSelected(active);
|
||||
b.setMnemonic(mnemonic);
|
||||
}
|
||||
|
||||
private static void updateButtons(@NotNull final JComponent filterBar) {
|
||||
final Component[] components = filterBar.getComponents();
|
||||
for (final Component c : components) {
|
||||
if (c instanceof MyButton) {
|
||||
((MyButton)c).updateTitle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static JComponent buildFilterBar(final ItemsList list, final Project project) {
|
||||
final JPanel box = new JPanel();
|
||||
box.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, box.getBackground().darker()),
|
||||
BorderFactory.createEmptyBorder(3, 3, 3, 3)));
|
||||
box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
|
||||
|
||||
final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
|
||||
createFilterButton(box, buttonGroup, "All", new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
list.filter(null);
|
||||
}
|
||||
}, new NotNullFunction<MyButton, String>() {
|
||||
@NotNull
|
||||
public String fun(MyButton myButton) {
|
||||
final int i = count(null, project);
|
||||
if (i > 0) {
|
||||
return String.format("All (%s)", i);
|
||||
}
|
||||
|
||||
return "All";
|
||||
}
|
||||
}, 'A', true);
|
||||
|
||||
createFilterButton(box, buttonGroup, "Error", new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
list.filter(NotificationType.ERROR);
|
||||
}
|
||||
}, new NotNullFunction<MyButton, String>() {
|
||||
@NotNull
|
||||
public String fun(MyButton myButton) {
|
||||
final int i = count(NotificationType.ERROR, project);
|
||||
myButton.setVisible(i > 0);
|
||||
if (i > 0) {
|
||||
return String.format("Error (%s)", i);
|
||||
}
|
||||
else if (myButton.isSelected()) {
|
||||
switchToAll(buttonGroup);
|
||||
}
|
||||
|
||||
return "Error";
|
||||
}
|
||||
}, 'E', false);
|
||||
|
||||
createFilterButton(box, buttonGroup, "Warning", new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
list.filter(NotificationType.WARNING);
|
||||
}
|
||||
}, new NotNullFunction<MyButton, String>() {
|
||||
@NotNull
|
||||
public String fun(MyButton myButton) {
|
||||
final int i = count(NotificationType.WARNING, project);
|
||||
myButton.setVisible(i > 0);
|
||||
if (i > 0) {
|
||||
return String.format("Warning (%s)", i);
|
||||
}
|
||||
else if (myButton.isSelected()) {
|
||||
switchToAll(buttonGroup);
|
||||
}
|
||||
|
||||
return "Warning";
|
||||
}
|
||||
}, 'W', false);
|
||||
|
||||
createFilterButton(box, buttonGroup, "Information", new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
list.filter(NotificationType.INFORMATION);
|
||||
}
|
||||
}, new NotNullFunction<MyButton, String>() {
|
||||
@NotNull
|
||||
public String fun(MyButton myButton) {
|
||||
final int i = count(NotificationType.INFORMATION, project);
|
||||
myButton.setVisible(i > 0);
|
||||
if (i > 0) {
|
||||
return String.format("Information (%s)", i);
|
||||
}
|
||||
else if (myButton.isSelected()) {
|
||||
switchToAll(buttonGroup);
|
||||
}
|
||||
|
||||
return "Information";
|
||||
}
|
||||
}, 'I', false);
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
private static void switchToAll(final ButtonGroup buttonGroup) {
|
||||
final Enumeration<AbstractButton> enumeration = buttonGroup.getElements();
|
||||
while (enumeration.hasMoreElements()) {
|
||||
final AbstractButton button = enumeration.nextElement();
|
||||
if (button.getText().startsWith("All")) {
|
||||
button.doClick();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int count(@Nullable final NotificationType type, @Nullable final Project project) {
|
||||
return NotificationsManagerImpl.getNotificationsManagerImpl().getByType(type, project).size();
|
||||
}
|
||||
|
||||
private void filter(@Nullable final NotificationType type) {
|
||||
final NotificationsListModel listModel = getModel();
|
||||
listModel.filter(type);
|
||||
if (listModel.getSize() > 0) setSelectedIndex(0);
|
||||
}
|
||||
|
||||
public static JComponent create(final Project project, final Disposable parentDisposable) {
|
||||
final NotificationsListModel model = new NotificationsListModel(project);
|
||||
Disposer.register(parentDisposable, model);
|
||||
|
||||
// TODO: switch filter if removed all of the notifications from current one!
|
||||
|
||||
final ItemsList list = new ItemsList(model);
|
||||
list.addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
list.setCellRenderer(new NotificationsListRenderer()); // request cell renderer size invalidation
|
||||
}
|
||||
});
|
||||
|
||||
final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(list);
|
||||
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
|
||||
scrollPane.setBorder(null);
|
||||
scrollPane.getViewport().setBackground(UIUtil.getPanelBackground());
|
||||
|
||||
final JComponent buttonBar = buildFilterBar(list, project);
|
||||
model.addListDataListener(new ListDataListener() {
|
||||
public void intervalAdded(ListDataEvent e) {
|
||||
updateButtons(buttonBar);
|
||||
}
|
||||
|
||||
public void intervalRemoved(ListDataEvent e) {
|
||||
updateButtons(buttonBar);
|
||||
}
|
||||
|
||||
public void contentsChanged(ListDataEvent e) {
|
||||
updateButtons(buttonBar);
|
||||
}
|
||||
});
|
||||
|
||||
final JPanel panel = new JPanel(new BorderLayout()) {
|
||||
@Override
|
||||
public void requestFocus() {
|
||||
updateButtons(buttonBar);
|
||||
list.requestFocus();
|
||||
}
|
||||
};
|
||||
|
||||
panel.add(buttonBar, BorderLayout.NORTH);
|
||||
panel.add(scrollPane, BorderLayout.CENTER);
|
||||
|
||||
return panel;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ExpireButton extends JComponent {
|
||||
private int myIndex = -1;
|
||||
private BaseButtonBehavior myBehavior;
|
||||
private JList myList;
|
||||
|
||||
private ExpireButton(final JList list) {
|
||||
myList = list;
|
||||
|
||||
final MouseAdapter adapter = new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
showAtPoint(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
hideCloseButton(e);
|
||||
}
|
||||
};
|
||||
|
||||
list.addMouseMotionListener(adapter);
|
||||
list.addMouseListener(adapter);
|
||||
|
||||
setOpaque(false);
|
||||
setToolTipText("Delete (" + KeymapUtil.getKeystrokeText(KeyStroke.getKeyStroke("DELETE")) + ")");
|
||||
|
||||
myBehavior = new BaseButtonBehavior(this, TimedDeadzone.NULL) {
|
||||
@Override
|
||||
protected void execute(final MouseEvent e) {
|
||||
expire();
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showAtPoint(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void showAtPoint(MouseEvent e) {
|
||||
final Point point = e.getSource() == myList ? e.getPoint() : SwingUtilities.convertPoint((Component)e.getSource(), e.getPoint(), myList);
|
||||
final int index = myList.locationToIndex(point);
|
||||
if (index > -1) {
|
||||
final Object value = myList.getModel().getElementAt(index);
|
||||
if (value != null && value instanceof Notification) {
|
||||
final Rectangle bounds = myList.getCellBounds(index, index);
|
||||
if (myList.getVisibleRect().contains(bounds) && bounds.contains(point)) {
|
||||
toggle(index, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void expire() {
|
||||
if (myIndex != -1) {
|
||||
final ListModel model = myList.getModel();
|
||||
final Object o = model.getElementAt(myIndex);
|
||||
if (o instanceof Notification) {
|
||||
final Notification notification = (Notification)o;
|
||||
if (!notification.isExpired()) {
|
||||
notification.expire();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
myIndex = -1;
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
public void setIndex(final int index) {
|
||||
myIndex = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return getMinimumSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return new Dimension(CLOSE_ICON.getIconWidth() + 2, CLOSE_ICON.getIconHeight() + 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
final Rectangle r = getBounds();
|
||||
if (myBehavior.isPressedByMouse()) {
|
||||
CLOSE_ICON.paintIcon(this, g, r.width - CLOSE_ICON.getIconWidth(), r.height - CLOSE_ICON.getIconHeight());
|
||||
}
|
||||
else {
|
||||
CLOSE_ICON.paintIcon(this, g, r.width - CLOSE_ICON.getIconWidth() - 2, r.height - CLOSE_ICON.getIconHeight() - 2);
|
||||
}
|
||||
}
|
||||
|
||||
public static void install(final JList list) {
|
||||
final ExpireButton button = new ExpireButton(list);
|
||||
button.setVisible(false);
|
||||
}
|
||||
|
||||
public void hideCloseButton(final MouseEvent e) {
|
||||
if (e != null) {
|
||||
final Object source = e.getSource();
|
||||
if (source instanceof JComponent) {
|
||||
final Container parent = getParent();
|
||||
if (parent != null) {
|
||||
final Point point = SwingUtilities.convertPoint((Component) source, e.getPoint(), getParent());
|
||||
if (!getBounds().contains(point)) {
|
||||
toggle(-1, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
toggle(-1, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void toggle(final int index, final boolean hide) {
|
||||
if (hide) {
|
||||
setIndex(index);
|
||||
setVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (getParent() == null) {
|
||||
final Window window = SwingUtilities.getWindowAncestor(myList);
|
||||
if (!(window instanceof JDialog)) return;
|
||||
final JLayeredPane layeredPane = ((JDialog)window).getLayeredPane();
|
||||
if (layeredPane == null) return;
|
||||
layeredPane.add(this);
|
||||
|
||||
layeredPane.addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
toggle(-1, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (getParent() != null) {
|
||||
final Dimension preferredSize = getPreferredSize();
|
||||
final Rectangle cellBounds = myList.getCellBounds(index, index);
|
||||
Point location = new Point(cellBounds.x + cellBounds.width - preferredSize.width, cellBounds.y);
|
||||
location = SwingUtilities.convertPoint(myList, location, getParent());
|
||||
setIndex(index);
|
||||
setBounds(location.x, location.y, preferredSize.width, preferredSize.height);
|
||||
}
|
||||
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return myIndex;
|
||||
}
|
||||
}
|
||||
|
||||
private abstract static class MyButton extends StickyButton {
|
||||
private MyButton(String text, ActionListener listener) {
|
||||
super(text, listener);
|
||||
}
|
||||
|
||||
private MyButton(String text) {
|
||||
super(text);
|
||||
}
|
||||
|
||||
public abstract void updateTitle();
|
||||
}
|
||||
}
|
||||
@@ -25,11 +25,6 @@ import java.awt.event.ActionListener;
|
||||
*/
|
||||
public class StickyButton extends JToggleButton {
|
||||
|
||||
public StickyButton(final String text, final ActionListener listener) {
|
||||
this(text);
|
||||
addActionListener(listener);
|
||||
}
|
||||
|
||||
public StickyButton(final String text) {
|
||||
super(text);
|
||||
|
||||
|
||||
@@ -127,7 +127,8 @@ options.general.color.descriptor.modified.lines=Modified lines
|
||||
options.general.color.descriptor.console.background=Console background
|
||||
options.general.color.descriptor.console.stdout=Console standard output
|
||||
options.general.color.descriptor.console.stderr=Console error output
|
||||
options.general.color.descriptor.console.warning=Console warning output
|
||||
options.general.color.descriptor.console.warning=Log console warning
|
||||
options.general.color.descriptor.console.logError=Log console error
|
||||
options.general.color.descriptor.console.stdin=Console user input
|
||||
options.general.color.descriptor.console.system.output=Console system output
|
||||
options.general.color.descriptor.hyperlink.new=Hyperlink
|
||||
|
||||
@@ -1139,11 +1139,16 @@
|
||||
<option name="FOREGROUND" value="7f0000"/>
|
||||
</value>
|
||||
</option>
|
||||
<option name="CONSOLE_WARNING_OUTPUT">
|
||||
<option name="LOG_WARNING_OUTPUT">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="80A000"/>
|
||||
</value>
|
||||
</option>
|
||||
<option name="LOG_ERROR_OUTPUT">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="ff0000"/>
|
||||
</value>
|
||||
</option>
|
||||
<option name="CONSOLE_USER_INPUT">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="007f00"/>
|
||||
|
||||
@@ -141,8 +141,8 @@
|
||||
<applicationService serviceInterface="com.intellij.ide.PowerSaveMode"
|
||||
serviceImplementation="com.intellij.ide.PowerSaveMode"/>
|
||||
|
||||
<applicationService serviceInterface="com.intellij.framework.library.DownloadableLibraryAssistant"
|
||||
serviceImplementation="com.intellij.framework.library.impl.DownloadableLibraryAssistantImpl"/>
|
||||
<applicationService serviceInterface="com.intellij.util.download.DownloadableFileService"
|
||||
serviceImplementation="com.intellij.util.download.impl.DownloadableFileServiceImpl"/>
|
||||
|
||||
<applicationService serviceInterface="com.intellij.psi.impl.DocumentCommitThread"
|
||||
serviceImplementation="com.intellij.psi.impl.DocumentCommitThread"/>
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -41,6 +42,7 @@ public class IvyAttachSourceProvider extends AbstractAttachSourceProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<AttachSourcesAction> getActions(List<LibraryOrderEntry> orderEntries, final PsiFile psiFile) {
|
||||
VirtualFile jar = getJarByPsiFile(psiFile);
|
||||
@@ -67,7 +69,7 @@ public class IvyAttachSourceProvider extends AbstractAttachSourceProvider {
|
||||
if (propertiesFile == null) return Collections.emptyList();
|
||||
|
||||
final Library library = getLibraryFromOrderEntriesList(orderEntries);
|
||||
if (library == null) return null;
|
||||
if (library == null) return Collections.emptyList();
|
||||
|
||||
final String sourceFileName = artifactName + '-' + version + "-sources.jar";
|
||||
|
||||
|
||||
+1
-1
@@ -295,7 +295,7 @@ public class GroovyCompletionContributor extends CompletionContributor {
|
||||
if (reference.getQualifier() == null) {
|
||||
GroovySmartCompletionContributor.addExpectedClassMembers(parameters, result);
|
||||
|
||||
if (!PsiJavaPatterns.psiElement().inside(GrImportStatement.class).accepts(position)) {
|
||||
if (JavaCompletionContributor.mayShowAllClasses(parameters) && !PsiJavaPatterns.psiElement().inside(GrImportStatement.class).accepts(position)) {
|
||||
if (JavaCompletionContributor.mayStartClassName(result, parameters.isRelaxedMatching())) {
|
||||
addAllClasses(parameters, result, inheritors);
|
||||
}
|
||||
|
||||
+2
@@ -27,6 +27,7 @@ import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.util.AsyncResult;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.maven.importing.MavenRootModelAdapter;
|
||||
import org.jetbrains.idea.maven.model.MavenArtifact;
|
||||
import org.jetbrains.idea.maven.model.MavenId;
|
||||
@@ -42,6 +43,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class MavenAttachSourcesProvider implements AttachSourcesProvider {
|
||||
@NotNull
|
||||
public Collection<AttachSourcesAction> getActions(final List<LibraryOrderEntry> orderEntries, final PsiFile psiFile) {
|
||||
Collection<MavenProject> projects = getMavenProjects(psiFile);
|
||||
if (projects.isEmpty()) return Collections.emptyList();
|
||||
|
||||
@@ -280,9 +280,6 @@
|
||||
<projectService serviceInterface="com.intellij.psi.controlFlow.ControlFlowFactory"
|
||||
serviceImplementation="com.intellij.psi.controlFlow.ControlFlowFactory"/>
|
||||
|
||||
<projectService serviceInterface="com.intellij.openapi.vcs.CodeSmellDetector"
|
||||
serviceImplementation="com.intellij.openapi.vcs.impl.CodeSmellDetectorImpl"/>
|
||||
|
||||
<applicationService serviceInterface="com.intellij.psi.CommonReferenceProviderTypes"
|
||||
serviceImplementation="com.intellij.psi.impl.CommonReferenceProviderTypesImpl"/>
|
||||
<projectService serviceInterface="com.intellij.psi.impl.file.PsiDirectoryFactory"
|
||||
@@ -307,6 +304,9 @@
|
||||
<projectService serviceInterface="com.intellij.codeInsight.NullableNotNullManager"
|
||||
serviceImplementation="com.intellij.codeInsight.NullableNotNullManager"/>
|
||||
|
||||
<applicationService serviceInterface="com.intellij.framework.library.DownloadableLibraryService"
|
||||
serviceImplementation="com.intellij.framework.library.impl.DownloadableLibraryServiceImpl"/>
|
||||
|
||||
<projectService serviceImplementation="com.intellij.javadoc.JavadocGenerationManager"/>
|
||||
|
||||
<highlightVisitor implementation="com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl"/>
|
||||
|
||||
@@ -247,6 +247,9 @@
|
||||
<projectService serviceImplementation="com.intellij.openapi.roots.ui.configuration.projectRoot.GlobalLibrariesConfigurable"/>
|
||||
<projectService serviceImplementation="com.intellij.openapi.roots.ui.configuration.projectRoot.JdkListConfigurable"/>
|
||||
|
||||
<projectService serviceInterface="com.intellij.openapi.vcs.CodeSmellDetector"
|
||||
serviceImplementation="com.intellij.openapi.vcs.impl.CodeSmellDetectorImpl"/>
|
||||
|
||||
<!-- Errors -->
|
||||
<!-- Show full error options configurable only in full IDEA - platform supports only default IDE profile for now -->
|
||||
<projectConfigurable provider="com.intellij.profile.codeInspection.ui.ProjectInspectionToolsConfigurableProvider"/>
|
||||
|
||||
Reference in New Issue
Block a user