mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
notnull 2
This commit is contained in:
@@ -29,6 +29,7 @@ import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
@@ -38,7 +39,7 @@ import java.awt.datatransfer.Transferable;
|
||||
* @author yole
|
||||
*/
|
||||
public class JavaFilePasteProvider implements PasteProvider {
|
||||
public void performPaste(final DataContext dataContext) {
|
||||
public void performPaste(@NotNull final DataContext dataContext) {
|
||||
final Project project = DataKeys.PROJECT.getData(dataContext);
|
||||
final IdeView ideView = DataKeys.IDE_VIEW.getData(dataContext);
|
||||
if (project == null || ideView == null) return;
|
||||
@@ -107,11 +108,11 @@ public class JavaFilePasteProvider implements PasteProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPastePossible(final DataContext dataContext) {
|
||||
public boolean isPastePossible(@NotNull final DataContext dataContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isPasteEnabled(final DataContext dataContext) {
|
||||
public boolean isPasteEnabled(@NotNull final DataContext dataContext) {
|
||||
final Project project = DataKeys.PROJECT.getData(dataContext);
|
||||
final IdeView ideView = DataKeys.IDE_VIEW.getData(dataContext);
|
||||
if (project == null || ideView == null || ideView.getDirectories().length == 0) {
|
||||
|
||||
@@ -293,14 +293,14 @@ public final class PackageViewPane extends AbstractProjectViewPSIPane {
|
||||
}
|
||||
|
||||
private final class MyDeletePSIElementProvider implements DeleteProvider {
|
||||
public boolean canDeleteElement(DataContext dataContext) {
|
||||
public boolean canDeleteElement(@NotNull DataContext dataContext) {
|
||||
for (PsiDirectory directory : getSelectedDirectories()) {
|
||||
if (!directory.getManager().isInProject(directory)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void deleteElement(DataContext dataContext) {
|
||||
public void deleteElement(@NotNull DataContext dataContext) {
|
||||
List<PsiDirectory> allElements = Arrays.asList(getSelectedDirectories());
|
||||
List<PsiElement> validElements = new ArrayList<PsiElement>();
|
||||
for (PsiElement psiElement : allElements) {
|
||||
|
||||
+5
-4
@@ -21,17 +21,18 @@ package com.intellij.openapi.editor.ex;
|
||||
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.util.messages.Topic;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface DocumentBulkUpdateListener {
|
||||
Topic<DocumentBulkUpdateListener> TOPIC = Topic.create("Bulk document change notifcation like reformat, etc.", DocumentBulkUpdateListener.class);
|
||||
|
||||
void updateStarted(Document doc);
|
||||
void updateFinished(Document doc);
|
||||
void updateStarted(@NotNull Document doc);
|
||||
void updateFinished(@NotNull Document doc);
|
||||
|
||||
abstract class Adapter implements DocumentBulkUpdateListener {
|
||||
@Override
|
||||
public void updateFinished(final Document doc) {}
|
||||
public void updateFinished(@NotNull final Document doc) {}
|
||||
@Override
|
||||
public void updateStarted(final Document doc) {}
|
||||
public void updateStarted(@NotNull final Document doc) {}
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public class BlockSupportImpl extends BlockSupport {
|
||||
public BlockSupportImpl(Project project) {
|
||||
project.getMessageBus().connect().subscribe(DocumentBulkUpdateListener.TOPIC, new DocumentBulkUpdateListener.Adapter() {
|
||||
@Override
|
||||
public void updateStarted(final Document doc) {
|
||||
public void updateStarted(@NotNull final Document doc) {
|
||||
doc.putUserData(DO_NOT_REPARSE_INCREMENTALLY, Boolean.TRUE);
|
||||
}
|
||||
});
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ public class CodeFoldingManagerImpl extends CodeFoldingManager implements Projec
|
||||
CodeFoldingManagerImpl(Project project) {
|
||||
myProject = project;
|
||||
project.getMessageBus().connect().subscribe(DocumentBulkUpdateListener.TOPIC, new DocumentBulkUpdateListener.Adapter() {
|
||||
public void updateStarted(final Document doc) {
|
||||
public void updateStarted(@NotNull final Document doc) {
|
||||
resetFoldingInfo(doc);
|
||||
}
|
||||
});
|
||||
|
||||
+1
-1
@@ -1,4 +1,3 @@
|
||||
|
||||
package com.intellij.codeInsight.intention.impl.config;
|
||||
|
||||
import com.intellij.openapi.editor.*;
|
||||
@@ -218,6 +217,7 @@ class LazyEditor extends UserDataHolderBase implements Editor {
|
||||
return getEditor().getHeaderComponent();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public IndentsModel getIndentsModel() {
|
||||
return getEditor().getIndentsModel();
|
||||
}
|
||||
|
||||
@@ -142,6 +142,7 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
|
||||
public void initComponents() {
|
||||
final EditorColorsScheme colorsScheme = myConsoleEditor.getColorsScheme();
|
||||
final DelegateColorScheme scheme = new DelegateColorScheme(colorsScheme) {
|
||||
@NotNull
|
||||
@Override
|
||||
public Color getDefaultBackground() {
|
||||
final Color color = getColor(ConsoleViewContentType.CONSOLE_BACKGROUND_KEY);
|
||||
|
||||
@@ -82,22 +82,22 @@ public abstract class CopyPasteDelegator implements CopyPasteSupport {
|
||||
}
|
||||
|
||||
private class MyEditable implements CutProvider, CopyProvider, PasteProvider {
|
||||
public void performCopy(DataContext dataContext) {
|
||||
public void performCopy(@NotNull DataContext dataContext) {
|
||||
PsiElement[] elements = getValidSelectedElements();
|
||||
PsiCopyPasteManager.getInstance().setElements(elements, true);
|
||||
updateView();
|
||||
}
|
||||
|
||||
public boolean isCopyEnabled(DataContext dataContext) {
|
||||
public boolean isCopyEnabled(@NotNull DataContext dataContext) {
|
||||
PsiElement[] elements = getValidSelectedElements();
|
||||
return CopyHandler.canCopy(elements) || PsiCopyPasteManager.asFileList(elements) != null;
|
||||
}
|
||||
|
||||
public boolean isCopyVisible(DataContext dataContext) {
|
||||
public boolean isCopyVisible(@NotNull DataContext dataContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void performCut(DataContext dataContext) {
|
||||
public void performCut(@NotNull DataContext dataContext) {
|
||||
PsiElement[] elements = getValidSelectedElements();
|
||||
if (MoveHandler.adjustForMove(myProject, elements, null) == null) {
|
||||
return;
|
||||
@@ -108,16 +108,16 @@ public abstract class CopyPasteDelegator implements CopyPasteSupport {
|
||||
updateView();
|
||||
}
|
||||
|
||||
public boolean isCutEnabled(DataContext dataContext) {
|
||||
public boolean isCutEnabled(@NotNull DataContext dataContext) {
|
||||
final PsiElement[] elements = getValidSelectedElements();
|
||||
return elements.length != 0 && MoveHandler.canMove(elements, null);
|
||||
}
|
||||
|
||||
public boolean isCutVisible(DataContext dataContext) {
|
||||
public boolean isCutVisible(@NotNull DataContext dataContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void performPaste(DataContext dataContext) {
|
||||
public void performPaste(@NotNull DataContext dataContext) {
|
||||
if (!performDefaultPaste(dataContext)) {
|
||||
for(PasteProvider provider: Extensions.getExtensions(EP_NAME)) {
|
||||
if (provider.isPasteEnabled(dataContext)) {
|
||||
@@ -176,11 +176,11 @@ public abstract class CopyPasteDelegator implements CopyPasteSupport {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isPastePossible(DataContext dataContext) {
|
||||
public boolean isPastePossible(@NotNull DataContext dataContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isPasteEnabled(DataContext dataContext){
|
||||
public boolean isPasteEnabled(@NotNull DataContext dataContext){
|
||||
if (isDefaultPasteEnabled(dataContext)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.refactoring.copy.CopyFilesOrDirectoriesHandler;
|
||||
import com.intellij.refactoring.move.moveFilesOrDirectories.MoveFilesOrDirectoriesHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.io.File;
|
||||
@@ -42,7 +43,7 @@ import java.util.List;
|
||||
* @author yole
|
||||
*/
|
||||
public class FileListPasteProvider implements PasteProvider {
|
||||
public void performPaste(DataContext dataContext) {
|
||||
public void performPaste(@NotNull DataContext dataContext) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
|
||||
final IdeView ideView = LangDataKeys.IDE_VIEW.getData(dataContext);
|
||||
if (project == null || ideView == null) return;
|
||||
@@ -78,11 +79,11 @@ public class FileListPasteProvider implements PasteProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPastePossible(DataContext dataContext) {
|
||||
public boolean isPastePossible(@NotNull DataContext dataContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isPasteEnabled(DataContext dataContext) {
|
||||
public boolean isPasteEnabled(@NotNull DataContext dataContext) {
|
||||
final Transferable contents = CopyPasteManager.getInstance().getContents();
|
||||
final IdeView ideView = LangDataKeys.IDE_VIEW.getData(dataContext);
|
||||
return contents != null && FileCopyPasteUtil.isFileListFlavorSupported(contents) && ideView != null;
|
||||
|
||||
@@ -34,12 +34,13 @@ import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.Producer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.datatransfer.Transferable;
|
||||
|
||||
public class PasteReferenceProvider implements PasteProvider {
|
||||
public void performPaste(DataContext dataContext) {
|
||||
public void performPaste(@NotNull DataContext dataContext) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
|
||||
final Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
|
||||
if (project == null || editor == null) return;
|
||||
@@ -61,13 +62,13 @@ public class PasteReferenceProvider implements PasteProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPastePossible(DataContext dataContext) {
|
||||
public boolean isPastePossible(@NotNull DataContext dataContext) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
|
||||
final Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
|
||||
return project != null && editor != null && getCopiedFqn(dataContext) != null;
|
||||
}
|
||||
|
||||
public boolean isPasteEnabled(DataContext dataContext) {
|
||||
public boolean isPasteEnabled(@NotNull DataContext dataContext) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
|
||||
String fqn = getCopiedFqn(dataContext);
|
||||
if (project == null || fqn == null) {
|
||||
|
||||
@@ -540,7 +540,7 @@ public class CommanderPanel extends JPanel {
|
||||
}
|
||||
|
||||
private final class MyDeleteElementProvider implements DeleteProvider {
|
||||
public void deleteElement(final DataContext dataContext) {
|
||||
public void deleteElement(@NotNull final DataContext dataContext) {
|
||||
LocalHistoryAction a = LocalHistory.getInstance().startAction(IdeBundle.message("progress.deleting"));
|
||||
try {
|
||||
final PsiElement[] elements = getSelectedElements();
|
||||
@@ -551,7 +551,7 @@ public class CommanderPanel extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canDeleteElement(final DataContext dataContext) {
|
||||
public boolean canDeleteElement(@NotNull final DataContext dataContext) {
|
||||
final PsiElement[] elements = getSelectedElements();
|
||||
return DeleteHandler.shouldEnableDeleteAction(elements);
|
||||
}
|
||||
|
||||
+2
-2
@@ -441,12 +441,12 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider {
|
||||
}
|
||||
|
||||
private final class MyDeletePSIElementProvider implements DeleteProvider {
|
||||
public boolean canDeleteElement(DataContext dataContext) {
|
||||
public boolean canDeleteElement(@NotNull DataContext dataContext) {
|
||||
final PsiElement[] elements = getElementsToDelete();
|
||||
return DeleteHandler.shouldEnableDeleteAction(elements);
|
||||
}
|
||||
|
||||
public void deleteElement(DataContext dataContext) {
|
||||
public void deleteElement(@NotNull DataContext dataContext) {
|
||||
List<PsiElement> allElements = Arrays.asList(getElementsToDelete());
|
||||
List<PsiElement> validElements = new ArrayList<PsiElement>();
|
||||
for (PsiElement psiElement : allElements) {
|
||||
|
||||
@@ -97,7 +97,7 @@ public abstract class TypeHierarchyBrowserBase extends HierarchyBrowserBaseEx {
|
||||
}
|
||||
|
||||
private final class MyDeleteProvider implements DeleteProvider {
|
||||
public final void deleteElement(final DataContext dataContext) {
|
||||
public final void deleteElement(@NotNull final DataContext dataContext) {
|
||||
final PsiElement aClass = getSelectedElement();
|
||||
if (!canBeDeleted(aClass)) return;
|
||||
LocalHistoryAction a = LocalHistory.getInstance().startAction(IdeBundle.message("progress.deleting.class", getQualifiedName(aClass)));
|
||||
@@ -110,7 +110,7 @@ public abstract class TypeHierarchyBrowserBase extends HierarchyBrowserBaseEx {
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean canDeleteElement(final DataContext dataContext) {
|
||||
public final boolean canDeleteElement(@NotNull final DataContext dataContext) {
|
||||
final PsiElement aClass = getSelectedElement();
|
||||
if (!canBeDeleted(aClass)) {
|
||||
return false;
|
||||
|
||||
@@ -851,12 +851,12 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
}
|
||||
|
||||
private final class MyDeletePSIElementProvider implements DeleteProvider {
|
||||
public boolean canDeleteElement(DataContext dataContext) {
|
||||
public boolean canDeleteElement(@NotNull DataContext dataContext) {
|
||||
final PsiElement[] elements = getElementsToDelete();
|
||||
return DeleteHandler.shouldEnableDeleteAction(elements);
|
||||
}
|
||||
|
||||
public void deleteElement(DataContext dataContext) {
|
||||
public void deleteElement(@NotNull DataContext dataContext) {
|
||||
List<PsiElement> allElements = Arrays.asList(getElementsToDelete());
|
||||
List<PsiElement> validElements = new ArrayList<PsiElement>();
|
||||
for (PsiElement psiElement : allElements) {
|
||||
@@ -1002,11 +1002,11 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
final LibraryOrderEntry orderEntry = getSelectedLibrary();
|
||||
if (orderEntry != null) {
|
||||
return new DeleteProvider() {
|
||||
public void deleteElement(DataContext dataContext) {
|
||||
public void deleteElement(@NotNull DataContext dataContext) {
|
||||
detachLibrary(orderEntry, myProject);
|
||||
}
|
||||
|
||||
public boolean canDeleteElement(DataContext dataContext) {
|
||||
public boolean canDeleteElement(@NotNull DataContext dataContext) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -812,12 +812,12 @@ public class ScopeTreeViewPanel extends JPanel implements Disposable {
|
||||
}
|
||||
|
||||
private final class MyDeletePSIElementProvider implements DeleteProvider {
|
||||
public boolean canDeleteElement(DataContext dataContext) {
|
||||
public boolean canDeleteElement(@NotNull DataContext dataContext) {
|
||||
final PsiElement[] elements = getSelectedPsiElements();
|
||||
return DeleteHandler.shouldEnableDeleteAction(elements);
|
||||
}
|
||||
|
||||
public void deleteElement(DataContext dataContext) {
|
||||
public void deleteElement(@NotNull DataContext dataContext) {
|
||||
List<PsiElement> allElements = Arrays.asList(getSelectedPsiElements());
|
||||
ArrayList<PsiElement> validElements = new ArrayList<PsiElement>();
|
||||
for (PsiElement psiElement : allElements) {
|
||||
|
||||
@@ -45,6 +45,7 @@ import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.refactoring.util.RefactoringUIUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.io.ReadOnlyAttributeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -56,7 +57,7 @@ public class DeleteHandler {
|
||||
}
|
||||
|
||||
public static class DefaultDeleteProvider implements DeleteProvider {
|
||||
public boolean canDeleteElement(DataContext dataContext) {
|
||||
public boolean canDeleteElement(@NotNull DataContext dataContext) {
|
||||
if (PlatformDataKeys.PROJECT.getData(dataContext) == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -82,7 +83,7 @@ public class DeleteHandler {
|
||||
return elements;
|
||||
}
|
||||
|
||||
public void deleteElement(DataContext dataContext) {
|
||||
public void deleteElement(@NotNull DataContext dataContext) {
|
||||
PsiElement[] elements = getPsiElements(dataContext);
|
||||
if (elements == null) return;
|
||||
Project project = PlatformDataKeys.PROJECT.getData(dataContext);
|
||||
|
||||
@@ -301,6 +301,7 @@ public class EditorWindow extends UserDataHolderBase implements EditorEx {
|
||||
return myDelegate.getContentComponent();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public EditorGutterComponentEx getGutterComponentEx() {
|
||||
return myDelegate.getGutterComponentEx();
|
||||
@@ -364,6 +365,7 @@ public class EditorWindow extends UserDataHolderBase implements EditorEx {
|
||||
return new LogicalPosition(lineNumber, column);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public EditorColorsScheme createBoundColorSchemeDelegate(@Nullable EditorColorsScheme customGlobalScheme) {
|
||||
return myDelegate.createBoundColorSchemeDelegate(customGlobalScheme);
|
||||
@@ -598,6 +600,7 @@ public class EditorWindow extends UserDataHolderBase implements EditorEx {
|
||||
return new LogicalPosition(pos.line, pos.column);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DataContext getDataContext() {
|
||||
return myDelegate.getDataContext();
|
||||
@@ -745,6 +748,7 @@ public class EditorWindow extends UserDataHolderBase implements EditorEx {
|
||||
return myDelegate.calcColumnNumber(myDocumentWindow.injectedToHost(offset), myDocumentWindow.injectedToHostLine(lineIndex));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public IndentsModel getIndentsModel() {
|
||||
return myDelegate.getIndentsModel();
|
||||
|
||||
+19
-11
@@ -27,6 +27,7 @@ import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.NullableFunction;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -37,9 +38,9 @@ abstract class LibraryOrderEntryBaseImpl extends OrderEntryBaseImpl {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.impl.LibraryOrderEntryBaseImpl");
|
||||
protected final ProjectRootManagerImpl myProjectRootManagerImpl;
|
||||
@NotNull protected DependencyScope myScope = DependencyScope.COMPILE;
|
||||
private RootProvider myCurrentlySubscribedRootProvider = null;
|
||||
@Nullable private RootProvider myCurrentlySubscribedRootProvider = null;
|
||||
|
||||
LibraryOrderEntryBaseImpl(RootModelImpl rootModel, ProjectRootManagerImpl instanceImpl) {
|
||||
LibraryOrderEntryBaseImpl(@NotNull RootModelImpl rootModel, @NotNull ProjectRootManagerImpl instanceImpl) {
|
||||
super(rootModel);
|
||||
myProjectRootManagerImpl = instanceImpl;
|
||||
}
|
||||
@@ -48,12 +49,13 @@ abstract class LibraryOrderEntryBaseImpl extends OrderEntryBaseImpl {
|
||||
updateFromRootProviderAndSubscribe();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public VirtualFile[] getFiles(OrderRootType type) {
|
||||
public VirtualFile[] getFiles(@NotNull OrderRootType type) {
|
||||
if (type == OrderRootType.COMPILATION_CLASSES) {
|
||||
return getRootFiles(OrderRootType.CLASSES);
|
||||
}
|
||||
else if (type == OrderRootType.PRODUCTION_COMPILATION_CLASSES) {
|
||||
if (type == OrderRootType.PRODUCTION_COMPILATION_CLASSES) {
|
||||
if (!myScope.isForProductionCompile()) {
|
||||
return VirtualFile.EMPTY_ARRAY;
|
||||
}
|
||||
@@ -65,15 +67,16 @@ abstract class LibraryOrderEntryBaseImpl extends OrderEntryBaseImpl {
|
||||
return getRootFiles(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String[] getUrls(OrderRootType type) {
|
||||
public String[] getUrls(@NotNull OrderRootType type) {
|
||||
LOG.assertTrue(!getRootModel().getModule().isDisposed());
|
||||
RootProvider rootProvider = getRootProvider();
|
||||
if (rootProvider == null) return ArrayUtil.EMPTY_STRING_ARRAY;
|
||||
if (type == OrderRootType.COMPILATION_CLASSES) {
|
||||
return rootProvider.getUrls(OrderRootType.CLASSES);
|
||||
}
|
||||
else if (type == OrderRootType.PRODUCTION_COMPILATION_CLASSES) {
|
||||
if (type == OrderRootType.PRODUCTION_COMPILATION_CLASSES) {
|
||||
if (!myScope.isForProductionCompile()) {
|
||||
return ArrayUtil.EMPTY_STRING_ARRAY;
|
||||
}
|
||||
@@ -85,28 +88,32 @@ abstract class LibraryOrderEntryBaseImpl extends OrderEntryBaseImpl {
|
||||
return rootProvider.getUrls(type);
|
||||
}
|
||||
|
||||
public VirtualFile[] getRootFiles(OrderRootType type) {
|
||||
public VirtualFile[] getRootFiles(@NotNull OrderRootType type) {
|
||||
RootProvider rootProvider = getRootProvider();
|
||||
return rootProvider == null ? VirtualFile.EMPTY_ARRAY : filterDirectories(rootProvider.getFiles(type));
|
||||
}
|
||||
|
||||
protected VirtualFile[] filterDirectories(VirtualFile[] files) {
|
||||
protected VirtualFile[] filterDirectories(@NotNull VirtualFile[] files) {
|
||||
List<VirtualFile> filtered = ContainerUtil.mapNotNull(files, new NullableFunction<VirtualFile, VirtualFile>() {
|
||||
public VirtualFile fun(VirtualFile file) {
|
||||
@Override
|
||||
public VirtualFile fun(@NotNull VirtualFile file) {
|
||||
return file.isDirectory() ? file : null;
|
||||
}
|
||||
});
|
||||
return VfsUtil.toVirtualFileArray(filtered);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected abstract RootProvider getRootProvider();
|
||||
|
||||
@NotNull
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public String[] getRootUrls(OrderRootType type) {
|
||||
public String[] getRootUrls(@NotNull OrderRootType type) {
|
||||
RootProvider rootProvider = getRootProvider();
|
||||
return rootProvider == null ? ArrayUtil.EMPTY_STRING_ARRAY : rootProvider.getUrls(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public final Module getOwnerModule() {
|
||||
return getRootModel().getModule();
|
||||
@@ -114,6 +121,7 @@ abstract class LibraryOrderEntryBaseImpl extends OrderEntryBaseImpl {
|
||||
|
||||
protected void updateFromRootProviderAndSubscribe() {
|
||||
getRootModel().makeExternalChange(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
resubscribe(getRootProvider());
|
||||
}
|
||||
@@ -125,7 +133,7 @@ abstract class LibraryOrderEntryBaseImpl extends OrderEntryBaseImpl {
|
||||
subscribe(wrapper);
|
||||
}
|
||||
|
||||
private void subscribe(RootProvider wrapper) {
|
||||
private void subscribe(@Nullable RootProvider wrapper) {
|
||||
if (wrapper != null) {
|
||||
myProjectRootManagerImpl.subscribeToRootProvider(this, wrapper);
|
||||
}
|
||||
|
||||
+2
-2
@@ -45,7 +45,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ModuleDeleteProvider implements DeleteProvider, TitledHandler {
|
||||
public boolean canDeleteElement(DataContext dataContext) {
|
||||
public boolean canDeleteElement(@NotNull DataContext dataContext) {
|
||||
final Module[] modules = LangDataKeys.MODULE_CONTEXT_ARRAY.getData(dataContext);
|
||||
return modules != null && !isPrimaryModule(modules);
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public class ModuleDeleteProvider implements DeleteProvider, TitledHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void deleteElement(DataContext dataContext) {
|
||||
public void deleteElement(@NotNull DataContext dataContext) {
|
||||
final Module[] modules = LangDataKeys.MODULE_CONTEXT_ARRAY.getData(dataContext);
|
||||
assert modules != null;
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
*
|
||||
@@ -68,9 +67,9 @@ public class PsiToDocumentSynchronizer extends PsiTreeChangeAdapter {
|
||||
void syncDocument(Document document, PsiTreeChangeEventImpl event);
|
||||
}
|
||||
|
||||
private void doSync(final PsiTreeChangeEvent event, boolean force, final DocSyncAction syncAction) {
|
||||
private void doSync(@NotNull final PsiTreeChangeEvent event, boolean force, @NotNull final DocSyncAction syncAction) {
|
||||
if (!toProcessPsiEvent()) return;
|
||||
PsiFile psiFile = event.getFile();
|
||||
final PsiFile psiFile = event.getFile();
|
||||
if (psiFile == null || psiFile.getNode() == null) return;
|
||||
|
||||
final DocumentEx document = (DocumentEx)myPsiDocumentManager.getCachedDocument(psiFile);
|
||||
@@ -96,7 +95,7 @@ public class PsiToDocumentSynchronizer extends PsiTreeChangeAdapter {
|
||||
myPsiDocumentManager.commitOtherFilesAssociatedWithDocument(document, psiFile);
|
||||
|
||||
final boolean insideTransaction = myTransactionsMap.containsKey(document);
|
||||
if(!insideTransaction){
|
||||
if (!insideTransaction) {
|
||||
document.setModificationStamp(psiFile.getModificationStamp());
|
||||
if (LOG.isDebugEnabled()) {
|
||||
PsiDocumentManagerImpl.checkConsistency(psiFile, document);
|
||||
|
||||
@@ -82,11 +82,11 @@ public class ConsoleViewContentType {
|
||||
return myTextAttributes;
|
||||
}
|
||||
|
||||
public synchronized static void registerNewConsoleViewType(final Key processOutputType, final ConsoleViewContentType attributes) {
|
||||
public static synchronized void registerNewConsoleViewType(final Key processOutputType, final ConsoleViewContentType attributes) {
|
||||
ourRegisteredTypes.put(processOutputType, attributes);
|
||||
}
|
||||
|
||||
public synchronized static ConsoleViewContentType getConsoleViewType(final Key processOutputType) {
|
||||
public static synchronized ConsoleViewContentType getConsoleViewType(final Key processOutputType) {
|
||||
if (ourRegisteredTypes.containsKey(processOutputType)) {
|
||||
return ourRegisteredTypes.get(processOutputType);
|
||||
}
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
package com.intellij.ide;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface CopyProvider {
|
||||
void performCopy(DataContext dataContext);
|
||||
boolean isCopyEnabled(DataContext dataContext);
|
||||
boolean isCopyVisible(DataContext dataContext);
|
||||
void performCopy(@NotNull DataContext dataContext);
|
||||
boolean isCopyEnabled(@NotNull DataContext dataContext);
|
||||
boolean isCopyVisible(@NotNull DataContext dataContext);
|
||||
}
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
package com.intellij.ide;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface CutProvider {
|
||||
void performCut(DataContext dataContext);
|
||||
boolean isCutEnabled(DataContext dataContext);
|
||||
boolean isCutVisible(DataContext dataContext);
|
||||
void performCut(@NotNull DataContext dataContext);
|
||||
boolean isCutEnabled(@NotNull DataContext dataContext);
|
||||
boolean isCutVisible(@NotNull DataContext dataContext);
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public abstract class DataManager {
|
||||
* @return {@link DataContext} constructed by the current focused component
|
||||
* @deprecated use either {@link #getDataContext(java.awt.Component)} or {@link #getDataContextFromFocus()}
|
||||
*/
|
||||
@NotNull
|
||||
public abstract DataContext getDataContext();
|
||||
|
||||
public abstract AsyncResult<DataContext> getDataContextFromFocus();
|
||||
|
||||
@@ -16,8 +16,9 @@
|
||||
package com.intellij.ide;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface DeleteProvider {
|
||||
void deleteElement(DataContext dataContext);
|
||||
boolean canDeleteElement(DataContext dataContext);
|
||||
void deleteElement(@NotNull DataContext dataContext);
|
||||
boolean canDeleteElement(@NotNull DataContext dataContext);
|
||||
}
|
||||
|
||||
@@ -17,14 +17,15 @@
|
||||
package com.intellij.ide;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface PasteProvider {
|
||||
void performPaste(DataContext dataContext);
|
||||
void performPaste(@NotNull DataContext dataContext);
|
||||
|
||||
/**
|
||||
* Should perform fast and memory cheap negation. May return incorrect true.
|
||||
* See #12326
|
||||
*/
|
||||
boolean isPastePossible(DataContext dataContext);
|
||||
boolean isPasteEnabled(DataContext dataContext);
|
||||
boolean isPastePossible(@NotNull DataContext dataContext);
|
||||
boolean isPasteEnabled(@NotNull DataContext dataContext);
|
||||
}
|
||||
|
||||
@@ -323,5 +323,6 @@ public interface Editor extends UserDataHolder {
|
||||
@Nullable
|
||||
JComponent getHeaderComponent();
|
||||
|
||||
@NotNull
|
||||
IndentsModel getIndentsModel();
|
||||
}
|
||||
|
||||
+7
-2
@@ -21,6 +21,7 @@ import com.intellij.openapi.command.UndoConfirmationPolicy;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
@@ -59,6 +60,7 @@ public abstract class EditorAction extends AnAction implements DumbAware {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void actionPerformed(AnActionEvent e) {
|
||||
DataContext dataContext = e.getDataContext();
|
||||
Editor editor = getEditor(dataContext);
|
||||
@@ -70,11 +72,12 @@ public abstract class EditorAction extends AnAction implements DumbAware {
|
||||
return PlatformDataKeys.EDITOR.getData(dataContext);
|
||||
}
|
||||
|
||||
public final void actionPerformed(final Editor editor, final DataContext dataContext) {
|
||||
public final void actionPerformed(final Editor editor, @NotNull final DataContext dataContext) {
|
||||
if (editor == null) return;
|
||||
|
||||
final EditorActionHandler handler = getHandler();
|
||||
Runnable command = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
handler.execute(editor, getProjectAwareDataContext(editor, dataContext));
|
||||
}
|
||||
@@ -103,6 +106,7 @@ public abstract class EditorAction extends AnAction implements DumbAware {
|
||||
update(editor, presentation, dataContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
Presentation presentation = e.getPresentation();
|
||||
DataContext dataContext = e.getDataContext();
|
||||
@@ -120,12 +124,13 @@ public abstract class EditorAction extends AnAction implements DumbAware {
|
||||
}
|
||||
}
|
||||
|
||||
private static DataContext getProjectAwareDataContext(final Editor editor, final DataContext original) {
|
||||
private static DataContext getProjectAwareDataContext(final Editor editor, @NotNull final DataContext original) {
|
||||
if (PlatformDataKeys.PROJECT.getData(original) == editor.getProject()) {
|
||||
return original;
|
||||
}
|
||||
|
||||
return new DataContext() {
|
||||
@Override
|
||||
public Object getData(String dataId) {
|
||||
if (PlatformDataKeys.PROJECT.is(dataId)) {
|
||||
return editor.getProject();
|
||||
|
||||
@@ -32,7 +32,9 @@ public interface EditorColorsScheme extends Cloneable, JDOMExternalizable, Schem
|
||||
TextAttributes getAttributes(TextAttributesKey key);
|
||||
void setAttributes(TextAttributesKey key, TextAttributes attributes);
|
||||
|
||||
@NotNull
|
||||
Color getDefaultBackground();
|
||||
@NotNull
|
||||
Color getDefaultForeground();
|
||||
|
||||
Color getColor(ColorKey key);
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.intellij.ui;
|
||||
import com.intellij.ide.CopyProvider;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
@@ -34,7 +35,7 @@ public class TreeCopyProvider implements CopyProvider {
|
||||
myTree = tree;
|
||||
}
|
||||
|
||||
public void performCopy(DataContext dataContext) {
|
||||
public void performCopy(@NotNull DataContext dataContext) {
|
||||
try {
|
||||
final Clipboard clipboard = myTree.getToolkit().getSystemClipboard();
|
||||
myTree.getTransferHandler().exportToClipboard(myTree, clipboard, TransferHandler.COPY);
|
||||
@@ -45,11 +46,11 @@ public class TreeCopyProvider implements CopyProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCopyEnabled(DataContext dataContext) {
|
||||
public boolean isCopyEnabled(@NotNull DataContext dataContext) {
|
||||
return myTree.getSelectionPath() != null;
|
||||
}
|
||||
|
||||
public boolean isCopyVisible(DataContext dataContext) {
|
||||
public boolean isCopyVisible(@NotNull DataContext dataContext) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.impl.EditorFactoryImpl;
|
||||
import com.intellij.openapi.editor.impl.softwrap.SoftWrapAppliancePlaces;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
@@ -60,6 +61,7 @@ public class ConsoleViewUtil {
|
||||
|
||||
public static DelegateColorScheme updateConsoleColorScheme(EditorColorsScheme scheme) {
|
||||
return new DelegateColorScheme(scheme) {
|
||||
@NotNull
|
||||
@Override
|
||||
public Color getDefaultBackground() {
|
||||
final Color color = getColor(ConsoleViewContentType.CONSOLE_BACKGROUND_KEY);
|
||||
|
||||
+3
-3
@@ -165,7 +165,7 @@ public class NewErrorTreeViewPanel extends JPanel implements DataProvider, Occur
|
||||
Disposer.dispose(myBuilder);
|
||||
}
|
||||
|
||||
public void performCopy(DataContext dataContext) {
|
||||
public void performCopy(@NotNull DataContext dataContext) {
|
||||
final ErrorTreeNodeDescriptor descriptor = getSelectedNodeDescriptor();
|
||||
if (descriptor != null) {
|
||||
final String[] lines = descriptor.getElement().getText();
|
||||
@@ -173,11 +173,11 @@ public class NewErrorTreeViewPanel extends JPanel implements DataProvider, Occur
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCopyEnabled(DataContext dataContext) {
|
||||
public boolean isCopyEnabled(@NotNull DataContext dataContext) {
|
||||
return getSelectedNodeDescriptor() != null;
|
||||
}
|
||||
|
||||
public boolean isCopyVisible(DataContext dataContext) {
|
||||
public boolean isCopyVisible(@NotNull DataContext dataContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -201,6 +201,7 @@ public class DataManagerImpl extends DataManager implements ApplicationComponent
|
||||
myWindowManager = windowManager;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DataContext getDataContext() {
|
||||
return getDataContext(getFocusedComponent());
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ public class CommandLineApplication {
|
||||
|
||||
public static class MyDataManagerImpl extends DataManagerImpl {
|
||||
|
||||
@NotNull
|
||||
public DataContext getDataContext() {
|
||||
return new CommandLineDataContext();
|
||||
}
|
||||
|
||||
@@ -231,8 +231,10 @@ public class CommandMerger {
|
||||
return !myCurrentActions.isEmpty();
|
||||
}
|
||||
|
||||
public boolean isUndoAvailable(Collection<DocumentReference> refs) {
|
||||
if (hasNonUndoableActions()) return false;
|
||||
public boolean isUndoAvailable(@NotNull Collection<DocumentReference> refs) {
|
||||
if (hasNonUndoableActions()) {
|
||||
return false;
|
||||
}
|
||||
if (refs.isEmpty()) return isGlobal() && hasActions();
|
||||
|
||||
for (DocumentReference each : refs) {
|
||||
|
||||
@@ -386,29 +386,35 @@ public class UndoManagerImpl extends UndoManager implements ProjectComponent, Ap
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
|
||||
Collection<DocumentReference> refs = getDocRefs(editor);
|
||||
if (refs == null) return false;
|
||||
if (refs == null) {
|
||||
return false;
|
||||
}
|
||||
return isUndoOrRedoAvailable(refs, undo);
|
||||
}
|
||||
|
||||
public boolean isUndoOrRedoAvailable(DocumentReference ref) {
|
||||
public boolean isUndoOrRedoAvailable(@NotNull DocumentReference ref) {
|
||||
Set<DocumentReference> refs = Collections.singleton(ref);
|
||||
return isUndoOrRedoAvailable(refs, true) || isUndoOrRedoAvailable(refs, false);
|
||||
}
|
||||
|
||||
private boolean isUndoOrRedoAvailable(Collection<DocumentReference> refs, boolean isUndo) {
|
||||
private boolean isUndoOrRedoAvailable(@NotNull Collection<DocumentReference> refs, boolean isUndo) {
|
||||
if (isUndo && myMerger.isUndoAvailable(refs)) return true;
|
||||
UndoRedoStacksHolder stackHolder = getStackHolder(isUndo);
|
||||
return stackHolder.canBeUndoneOrRedone(refs);
|
||||
}
|
||||
|
||||
private static Collection<DocumentReference> getDocRefs(FileEditor editor) {
|
||||
private static Collection<DocumentReference> getDocRefs(@Nullable FileEditor editor) {
|
||||
if (editor instanceof TextEditor && ((TextEditor)editor).getEditor().isViewer()) {
|
||||
return null;
|
||||
}
|
||||
if (editor == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return getDocumentReferences(editor);
|
||||
}
|
||||
|
||||
static Set<DocumentReference> getDocumentReferences(FileEditor editor) {
|
||||
@NotNull
|
||||
static Set<DocumentReference> getDocumentReferences(@NotNull FileEditor editor) {
|
||||
Set<DocumentReference> result = new THashSet<DocumentReference>();
|
||||
|
||||
if (editor instanceof DocumentReferenceProvider) {
|
||||
@@ -416,7 +422,7 @@ public class UndoManagerImpl extends UndoManager implements ProjectComponent, Ap
|
||||
return result;
|
||||
}
|
||||
|
||||
Document[] documents = editor == null ? null : TextEditorProvider.getDocuments(editor);
|
||||
Document[] documents = TextEditorProvider.getDocuments(editor);
|
||||
if (documents != null) {
|
||||
for (Document each : documents) {
|
||||
Document original = getOriginal(each);
|
||||
@@ -429,6 +435,7 @@ public class UndoManagerImpl extends UndoManager implements ProjectComponent, Ap
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private UndoRedoStacksHolder getStackHolder(boolean isUndo) {
|
||||
return isUndo ? myUndoStacksHolder : myRedoStacksHolder;
|
||||
}
|
||||
|
||||
+25
-18
@@ -32,19 +32,20 @@ class UndoRedoStacksHolder {
|
||||
private final boolean myUndo;
|
||||
|
||||
private final LinkedList<UndoableGroup> myGlobalStack = new LinkedList<UndoableGroup>();
|
||||
private final Map<DocumentReference, LinkedList<UndoableGroup>> myDocumentStacks
|
||||
= new HashMap<DocumentReference, LinkedList<UndoableGroup>>();
|
||||
private final Map<DocumentReference, LinkedList<UndoableGroup>> myDocumentStacks = new HashMap<DocumentReference, LinkedList<UndoableGroup>>();
|
||||
private final WeakList<Document> myDocumentsWithStacks = new WeakList<Document>();
|
||||
|
||||
public UndoRedoStacksHolder(boolean isUndo) {
|
||||
myUndo = isUndo;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
LinkedList<UndoableGroup> getStack(@NotNull DocumentReference r) {
|
||||
return r.getFile() != null ? doGetStackForFile(r) : doGetStackForDocument(r);
|
||||
}
|
||||
|
||||
private LinkedList<UndoableGroup> doGetStackForFile(DocumentReference r) {
|
||||
@NotNull
|
||||
private LinkedList<UndoableGroup> doGetStackForFile(@NotNull DocumentReference r) {
|
||||
LinkedList<UndoableGroup> result = myDocumentStacks.get(r);
|
||||
if (result == null) {
|
||||
result = new LinkedList<UndoableGroup>();
|
||||
@@ -53,7 +54,8 @@ class UndoRedoStacksHolder {
|
||||
return result;
|
||||
}
|
||||
|
||||
private LinkedList<UndoableGroup> doGetStackForDocument(DocumentReference r) {
|
||||
@NotNull
|
||||
private LinkedList<UndoableGroup> doGetStackForDocument(@NotNull DocumentReference r) {
|
||||
// If document is not associated with file, we have to store its stack in document
|
||||
// itself to avoid memory leaks caused by holding stacks of all documents, ever created, here.
|
||||
// And to know, what documents do exist now, we have to maintain weak reference list of them.
|
||||
@@ -68,7 +70,7 @@ class UndoRedoStacksHolder {
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean canBeUndoneOrRedone(Collection<DocumentReference> refs) {
|
||||
public boolean canBeUndoneOrRedone(@NotNull Collection<DocumentReference> refs) {
|
||||
if (refs.isEmpty()) return !myGlobalStack.isEmpty() && myGlobalStack.getLast().isValid();
|
||||
for (DocumentReference each : refs) {
|
||||
if (!getStack(each).isEmpty() && getStack(each).getLast().isValid()) return true;
|
||||
@@ -100,7 +102,8 @@ class UndoRedoStacksHolder {
|
||||
return mostRecentAction;
|
||||
}
|
||||
|
||||
public Set<DocumentReference> collectClashingActions(UndoableGroup group) {
|
||||
@NotNull
|
||||
public Set<DocumentReference> collectClashingActions(@NotNull UndoableGroup group) {
|
||||
Set<DocumentReference> result = new THashSet<DocumentReference>();
|
||||
|
||||
for (DocumentReference each : group.getAffectedDocuments()) {
|
||||
@@ -120,13 +123,13 @@ class UndoRedoStacksHolder {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void addToStacks(UndoableGroup group) {
|
||||
public void addToStacks(@NotNull UndoableGroup group) {
|
||||
for (LinkedList<UndoableGroup> each : getAffectedStacks(group)) {
|
||||
doAddToStack(each, group, each == myGlobalStack ? UndoManagerImpl.getGlobalUndoLimit() : UndoManagerImpl.getDocumentUndoLimit());
|
||||
}
|
||||
}
|
||||
|
||||
private void doAddToStack(LinkedList<UndoableGroup> stack, UndoableGroup group, int limit) {
|
||||
private void doAddToStack(@NotNull LinkedList<UndoableGroup> stack, @NotNull UndoableGroup group, int limit) {
|
||||
if (!group.isUndoable() && stack.isEmpty()) return;
|
||||
|
||||
stack.addLast(group);
|
||||
@@ -135,14 +138,14 @@ class UndoRedoStacksHolder {
|
||||
}
|
||||
}
|
||||
|
||||
public void removeFromStacks(UndoableGroup group) {
|
||||
public void removeFromStacks(@NotNull UndoableGroup group) {
|
||||
for (LinkedList<UndoableGroup> each : getAffectedStacks(group)) {
|
||||
assert each.getLast() == group;
|
||||
each.removeLast();
|
||||
}
|
||||
}
|
||||
|
||||
public void clearStacks(boolean clearGlobal, Set<DocumentReference> refs) {
|
||||
public void clearStacks(boolean clearGlobal, @NotNull Set<DocumentReference> refs) {
|
||||
for (LinkedList<UndoableGroup> each : getAffectedStacks(clearGlobal, refs)) {
|
||||
while(!each.isEmpty()) {
|
||||
clearStacksFrom(each.getLast());
|
||||
@@ -169,7 +172,7 @@ class UndoRedoStacksHolder {
|
||||
myDocumentsWithStacks.removeAll(docsToDrop);
|
||||
}
|
||||
|
||||
private void clearStacksFrom(UndoableGroup from) {
|
||||
private void clearStacksFrom(@NotNull UndoableGroup from) {
|
||||
for (LinkedList<UndoableGroup> each : getAffectedStacks(from)) {
|
||||
int pos = each.indexOf(from);
|
||||
if (pos == -1) continue;
|
||||
@@ -183,11 +186,14 @@ class UndoRedoStacksHolder {
|
||||
}
|
||||
}
|
||||
|
||||
private List<LinkedList<UndoableGroup>> getAffectedStacks(UndoableGroup group) {
|
||||
@NotNull
|
||||
private List<LinkedList<UndoableGroup>> getAffectedStacks(@NotNull UndoableGroup group) {
|
||||
return getAffectedStacks(group.isGlobal(), group.getAffectedDocuments());
|
||||
}
|
||||
private List<LinkedList<UndoableGroup>> getAffectedStacks(boolean global, Collection<DocumentReference> refs) {
|
||||
List<LinkedList<UndoableGroup>> result = new ArrayList<LinkedList<UndoableGroup>>();
|
||||
|
||||
@NotNull
|
||||
private List<LinkedList<UndoableGroup>> getAffectedStacks(boolean global, @NotNull Collection<DocumentReference> refs) {
|
||||
List<LinkedList<UndoableGroup>> result = new ArrayList<LinkedList<UndoableGroup>>(refs.size() + 1);
|
||||
if (global) result.add(myGlobalStack);
|
||||
for (DocumentReference each : refs) {
|
||||
result.add(getStack(each));
|
||||
@@ -199,33 +205,34 @@ class UndoRedoStacksHolder {
|
||||
clearStacks(true, getAffectedDocuments());
|
||||
}
|
||||
|
||||
public void collectAllAffectedDocuments(Collection<DocumentReference> result) {
|
||||
public void collectAllAffectedDocuments(@NotNull Collection<DocumentReference> result) {
|
||||
for (UndoableGroup each : myGlobalStack) {
|
||||
result.addAll(each.getAffectedDocuments());
|
||||
}
|
||||
collectLocalAffectedDocuments(result);
|
||||
}
|
||||
|
||||
private void collectLocalAffectedDocuments(Collection<DocumentReference> result) {
|
||||
private void collectLocalAffectedDocuments(@NotNull Collection<DocumentReference> result) {
|
||||
result.addAll(myDocumentStacks.keySet());
|
||||
for (Document each : myDocumentsWithStacks) {
|
||||
result.add(DocumentReferenceManager.getInstance().create(each));
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Set<DocumentReference> getAffectedDocuments() {
|
||||
Set<DocumentReference> result = new THashSet<DocumentReference>();
|
||||
collectAllAffectedDocuments(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getLastCommandTimestamp(DocumentReference r) {
|
||||
public int getLastCommandTimestamp(@NotNull DocumentReference r) {
|
||||
LinkedList<UndoableGroup> stack = getStack(r);
|
||||
if (stack.isEmpty()) return 0;
|
||||
return Math.max(stack.getFirst().getCommandTimestamp(), stack.getLast().getCommandTimestamp());
|
||||
}
|
||||
|
||||
public void invalidateActionsFor(DocumentReference ref) {
|
||||
public void invalidateActionsFor(@NotNull DocumentReference ref) {
|
||||
for (LinkedList<UndoableGroup> eachStack : getAffectedStacks(true, Collections.singleton(ref))) {
|
||||
for (UndoableGroup eachGroup : eachStack) {
|
||||
eachGroup.invalidateActionsFor(ref);
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
@@ -265,6 +266,7 @@ class UndoableGroup {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collection<DocumentReference> getAffectedDocuments() {
|
||||
Set<DocumentReference> result = new THashSet<DocumentReference>();
|
||||
for (UndoableAction action : myActions) {
|
||||
|
||||
+2
@@ -95,12 +95,14 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme {
|
||||
myDefaultColorSchemesManager = defaultColorSchemesManager;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Color getDefaultBackground() {
|
||||
final Color c = getAttributes(HighlighterColors.TEXT).getBackgroundColor();
|
||||
return c != null ? c : Color.white;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Color getDefaultForeground() {
|
||||
final Color c = getAttributes(HighlighterColors.TEXT).getForegroundColor();
|
||||
|
||||
+2
@@ -59,11 +59,13 @@ public abstract class DelegateColorScheme implements EditorColorsScheme {
|
||||
myDelegate.setAttributes(key, attributes);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Color getDefaultBackground() {
|
||||
return myDelegate.getDefaultBackground();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Color getDefaultForeground() {
|
||||
return myDelegate.getDefaultForeground();
|
||||
|
||||
@@ -47,6 +47,7 @@ public interface EditorEx extends Editor {
|
||||
@NonNls String PROP_FONT_SIZE = "fontSize";
|
||||
Key<TextRange> LAST_PASTED_REGION = Key.create("LAST_PASTED_REGION");
|
||||
|
||||
@NotNull
|
||||
EditorGutterComponentEx getGutterComponentEx();
|
||||
|
||||
EditorHighlighter getHighlighter();
|
||||
@@ -108,6 +109,7 @@ public interface EditorEx extends Editor {
|
||||
|
||||
void setFile(VirtualFile vFile);
|
||||
|
||||
@NotNull
|
||||
DataContext getDataContext();
|
||||
|
||||
boolean processKeyTyped(@NotNull KeyEvent e);
|
||||
@@ -156,6 +158,7 @@ public interface EditorEx extends Editor {
|
||||
* @param customGlobalScheme
|
||||
* @return
|
||||
*/
|
||||
@NotNull
|
||||
EditorColorsScheme createBoundColorSchemeDelegate(@Nullable EditorColorsScheme customGlobalScheme);
|
||||
|
||||
/**
|
||||
|
||||
@@ -109,12 +109,12 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
|
||||
myVisualLineEnd = doc.getLineCount() > 1 ? doc.getLineStartOffset(1) : doc.getLineCount() == 0 ? 0 : doc.getLineEndOffset(0);
|
||||
DocumentBulkUpdateListener bulkUpdateListener = new DocumentBulkUpdateListener() {
|
||||
@Override
|
||||
public void updateStarted(Document doc) {
|
||||
public void updateStarted(@NotNull Document doc) {
|
||||
if (doc != myEditor.getDocument() && myOffset >= doc.getTextLength()) return;
|
||||
savedBeforeBulkCaretMarker = doc.createRangeMarker(myOffset, myOffset);
|
||||
}
|
||||
@Override
|
||||
public void updateFinished(Document doc) {
|
||||
public void updateFinished(@NotNull Document doc) {
|
||||
if (doc != myEditor.getDocument() || myIsInUpdate) return;
|
||||
if (savedBeforeBulkCaretMarker != null && savedBeforeBulkCaretMarker.isValid()) {
|
||||
moveToOffset(savedBeforeBulkCaretMarker.getStartOffset());
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+3
-1
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.openapi.editor.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
@@ -44,5 +46,5 @@ public interface TextDrawingCallback {
|
||||
* @param fontInfo font info to use during drawing target text at the given graphics buffer
|
||||
* @param color color to use during drawing target text at the given graphics buffer
|
||||
*/
|
||||
void drawChars(Graphics g, char[] data, int start, int end, int x, int y, Color color, FontInfo fontInfo);
|
||||
void drawChars(@NotNull Graphics g, @NotNull char[] data, int start, int end, int x, int y, Color color, FontInfo fontInfo);
|
||||
}
|
||||
|
||||
+1
@@ -286,6 +286,7 @@ public class TextComponentEditor extends UserDataHolderBase implements Editor {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public IndentsModel getIndentsModel() {
|
||||
return new EmptyIndentsModel();
|
||||
|
||||
+3
-2
@@ -25,6 +25,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.UIBundle;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Comparator;
|
||||
@@ -33,12 +34,12 @@ import java.util.Arrays;
|
||||
public final class VirtualFileDeleteProvider implements DeleteProvider {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.fileChooser.actions.VirtualFileDeleteProvider");
|
||||
|
||||
public boolean canDeleteElement(DataContext dataContext) {
|
||||
public boolean canDeleteElement(@NotNull DataContext dataContext) {
|
||||
final VirtualFile[] files = PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
|
||||
return files != null && files.length > 0;
|
||||
}
|
||||
|
||||
public void deleteElement(DataContext dataContext) {
|
||||
public void deleteElement(@NotNull DataContext dataContext) {
|
||||
final VirtualFile[] files = PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
|
||||
if (files == null || files.length == 0) return;
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class VfsImplUtil {
|
||||
return null;
|
||||
}
|
||||
for (String pathElement : StringUtil.tokenize(normalizedPath.substring(basePath.length()), FILE_SEPARATORS)) {
|
||||
if (pathElement.length() == 0 || ".".equals(pathElement)) continue;
|
||||
if (pathElement.isEmpty() || ".".equals(pathElement)) continue;
|
||||
if ("..".equals(pathElement)) {
|
||||
file = file.getParent();
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class VfsImplUtil {
|
||||
if (file == null || !file.exists()) return null;
|
||||
|
||||
for (String pathElement : StringUtil.tokenize(normalizedPath.substring(basePath.length()), FILE_SEPARATORS)) {
|
||||
if (pathElement.length() == 0 || ".".equals(pathElement)) continue;
|
||||
if (pathElement.isEmpty() || ".".equals(pathElement)) continue;
|
||||
if ("..".equals(pathElement)) {
|
||||
file = file.getParent();
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public class VfsImplUtil {
|
||||
|
||||
LOG.assertTrue(basePath.length() <= normalizedPath.length(), vfs + " failed to extract root path: " + basePath + " from " + normalizedPath);
|
||||
for (String pathElement : StringUtil.tokenize(normalizedPath.substring(basePath.length()), FILE_SEPARATORS)) {
|
||||
if (pathElement.length() == 0 || ".".equals(pathElement)) continue;
|
||||
if (pathElement.isEmpty() || ".".equals(pathElement)) continue;
|
||||
if ("..".equals(pathElement)) {
|
||||
file = file.getParent();
|
||||
}
|
||||
|
||||
@@ -106,18 +106,18 @@ public abstract class TestTreeView extends Tree implements DataProvider, CopyPro
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performCopy(DataContext dataContext) {
|
||||
public void performCopy(@NotNull DataContext dataContext) {
|
||||
final PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataContext);
|
||||
CopyPasteManager.getInstance().setContents(new StringSelection(CopyReferenceAction.elementToFqn(element)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCopyEnabled(DataContext dataContext) {
|
||||
public boolean isCopyEnabled(@NotNull DataContext dataContext) {
|
||||
return LangDataKeys.PSI_ELEMENT.getData(dataContext) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCopyVisible(DataContext dataContext) {
|
||||
public boolean isCopyVisible(@NotNull DataContext dataContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1176,7 +1176,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performCopy(DataContext dataContext) {
|
||||
public void performCopy(@NotNull DataContext dataContext) {
|
||||
final Node selectedNode = getSelectedNode();
|
||||
assert selectedNode != null;
|
||||
final String plainText = selectedNode.getText(UsageViewImpl.this);
|
||||
@@ -1184,12 +1184,12 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCopyEnabled(DataContext dataContext) {
|
||||
public boolean isCopyEnabled(@NotNull DataContext dataContext) {
|
||||
return getSelectedNode() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCopyVisible(DataContext dataContext) {
|
||||
public boolean isCopyVisible(@NotNull DataContext dataContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -476,7 +476,7 @@ public class ShelvedChangesViewManager implements ProjectComponent {
|
||||
}
|
||||
|
||||
private class MyChangeListDeleteProvider implements DeleteProvider {
|
||||
public void deleteElement(DataContext dataContext) {
|
||||
public void deleteElement(@NotNull DataContext dataContext) {
|
||||
//noinspection unchecked
|
||||
final List<ShelvedChangeList> shelvedChangeLists = getLists(dataContext);
|
||||
if (shelvedChangeLists.isEmpty()) return;
|
||||
@@ -490,7 +490,7 @@ public class ShelvedChangesViewManager implements ProjectComponent {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canDeleteElement(DataContext dataContext) {
|
||||
public boolean canDeleteElement(@NotNull DataContext dataContext) {
|
||||
//noinspection unchecked
|
||||
return ! getLists(dataContext).isEmpty();
|
||||
}
|
||||
@@ -512,7 +512,7 @@ public class ShelvedChangesViewManager implements ProjectComponent {
|
||||
}
|
||||
|
||||
private class MyChangesDeleteProvider implements DeleteProvider {
|
||||
public void deleteElement(DataContext dataContext) {
|
||||
public void deleteElement(@NotNull DataContext dataContext) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
|
||||
if (project == null) return;
|
||||
final ShelvedChangeList[] shelved = SHELVED_CHANGELIST_KEY.getData(dataContext);
|
||||
@@ -559,7 +559,7 @@ public class ShelvedChangesViewManager implements ProjectComponent {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canDeleteElement(DataContext dataContext) {
|
||||
public boolean canDeleteElement(@NotNull DataContext dataContext) {
|
||||
final ShelvedChangeList[] shelved = SHELVED_CHANGELIST_KEY.getData(dataContext);
|
||||
if (shelved == null || (shelved.length != 1)) return false;
|
||||
final List<ShelvedChange> changes = SHELVED_CHANGE_KEY.getData(dataContext);
|
||||
@@ -586,14 +586,14 @@ public class ShelvedChangesViewManager implements ProjectComponent {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void deleteElement(DataContext dataContext) {
|
||||
public void deleteElement(@NotNull DataContext dataContext) {
|
||||
final DeleteProvider delegate = selectDelegate(dataContext);
|
||||
if (delegate != null) {
|
||||
delegate.deleteElement(dataContext);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canDeleteElement(DataContext dataContext) {
|
||||
public boolean canDeleteElement(@NotNull DataContext dataContext) {
|
||||
return selectDelegate(dataContext) != null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,12 +106,12 @@ public class LineStatusTrackerManager implements ProjectComponent, LineStatusTra
|
||||
});
|
||||
|
||||
project.getMessageBus().connect().subscribe(DocumentBulkUpdateListener.TOPIC, new DocumentBulkUpdateListener.Adapter() {
|
||||
public void updateStarted(final Document doc) {
|
||||
public void updateStarted(@NotNull final Document doc) {
|
||||
final LineStatusTracker tracker = getLineStatusTracker(doc);
|
||||
if (tracker != null) tracker.startBulkUpdate();
|
||||
}
|
||||
|
||||
public void updateFinished(final Document doc) {
|
||||
public void updateFinished(@NotNull final Document doc) {
|
||||
final LineStatusTracker tracker = getLineStatusTracker(doc);
|
||||
if (tracker != null) tracker.finishBulkUpdate();
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.intellij.util.OpenSourceUtil;
|
||||
import com.intellij.util.StringBuilderSpinAllocator;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -591,15 +592,15 @@ public final class TreeView implements AntOutputView, OccurenceNavigator {
|
||||
public Object getData(String dataId) {
|
||||
if (PlatformDataKeys.COPY_PROVIDER.is(dataId)) {
|
||||
return new CopyProvider() {
|
||||
public boolean isCopyEnabled(DataContext dataContext) {
|
||||
public boolean isCopyEnabled(@NotNull DataContext dataContext) {
|
||||
return getSelectionPath() != null;
|
||||
}
|
||||
|
||||
public boolean isCopyVisible(DataContext dataContext) {
|
||||
public boolean isCopyVisible(@NotNull DataContext dataContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void performCopy(DataContext dataContext) {
|
||||
public void performCopy(@NotNull DataContext dataContext) {
|
||||
TreePath selection = getSelectionPath();
|
||||
Object value = selection.getLastPathComponent();
|
||||
String text;
|
||||
|
||||
+2
-2
@@ -666,12 +666,12 @@ public class DynamicToolWindowWrapper {
|
||||
else if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId)) {
|
||||
return new DeleteProvider() {
|
||||
@Override
|
||||
public void deleteElement(DataContext dataContext) {
|
||||
public void deleteElement(@NotNull DataContext dataContext) {
|
||||
deleteRow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDeleteElement(DataContext dataContext) {
|
||||
public boolean canDeleteElement(@NotNull DataContext dataContext) {
|
||||
return myTreeTable.getTree().getSelectionPaths() != null;
|
||||
}
|
||||
};
|
||||
|
||||
+3
-2
@@ -25,6 +25,7 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.refactoring.safeDelete.SafeDeleteHandler;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -44,14 +45,14 @@ class ResourceBundleDeleteProvider implements DeleteProvider {
|
||||
myResourceBundle = resourceBundle;
|
||||
}
|
||||
|
||||
public void deleteElement(DataContext dataContext) {
|
||||
public void deleteElement(@NotNull DataContext dataContext) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
|
||||
List<PropertiesFile> propertiesFiles = myResourceBundle.getPropertiesFiles(project);
|
||||
assert project != null;
|
||||
new SafeDeleteHandler().invoke(project, ContainerUtil.map2Array(propertiesFiles, PsiElement.class, MAPPER), dataContext);
|
||||
}
|
||||
|
||||
public boolean canDeleteElement(DataContext dataContext) {
|
||||
public boolean canDeleteElement(@NotNull DataContext dataContext) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
|
||||
return project != null;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -62,15 +63,15 @@ public final class CutCopyPasteSupport implements CopyProvider, CutProvider, Pas
|
||||
myEditor = uiEditor;
|
||||
}
|
||||
|
||||
public boolean isCopyEnabled(final DataContext dataContext) {
|
||||
public boolean isCopyEnabled(@NotNull final DataContext dataContext) {
|
||||
return FormEditingUtil.getSelectedComponents(myEditor).size() > 0 && !myEditor.getInplaceEditingLayer().isEditing();
|
||||
}
|
||||
|
||||
public boolean isCopyVisible(DataContext dataContext) {
|
||||
public boolean isCopyVisible(@NotNull DataContext dataContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void performCopy(final DataContext dataContext) {
|
||||
public void performCopy(@NotNull final DataContext dataContext) {
|
||||
doCopy();
|
||||
}
|
||||
|
||||
@@ -88,15 +89,15 @@ public final class CutCopyPasteSupport implements CopyProvider, CutProvider, Pas
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCutEnabled(final DataContext dataContext) {
|
||||
public boolean isCutEnabled(@NotNull final DataContext dataContext) {
|
||||
return isCopyEnabled(dataContext) && FormEditingUtil.canDeleteSelection(myEditor);
|
||||
}
|
||||
|
||||
public boolean isCutVisible(DataContext dataContext) {
|
||||
public boolean isCutVisible(@NotNull DataContext dataContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void performCut(final DataContext dataContext) {
|
||||
public void performCut(@NotNull final DataContext dataContext) {
|
||||
if (doCopy() && myEditor.ensureEditable()) {
|
||||
CommandProcessor.getInstance().executeCommand(myEditor.getProject(), new Runnable() {
|
||||
public void run() {
|
||||
@@ -106,15 +107,15 @@ public final class CutCopyPasteSupport implements CopyProvider, CutProvider, Pas
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPastePossible(final DataContext dataContext) {
|
||||
public boolean isPastePossible(@NotNull final DataContext dataContext) {
|
||||
return isPasteEnabled(dataContext);
|
||||
}
|
||||
|
||||
public boolean isPasteEnabled(final DataContext dataContext) {
|
||||
public boolean isPasteEnabled(@NotNull final DataContext dataContext) {
|
||||
return getSerializedComponents() != null && !myEditor.getInplaceEditingLayer().isEditing();
|
||||
}
|
||||
|
||||
public void performPaste(final DataContext dataContext) {
|
||||
public void performPaste(@NotNull final DataContext dataContext) {
|
||||
final String serializedComponents = getSerializedComponents();
|
||||
if (serializedComponents == null) {
|
||||
return;
|
||||
|
||||
@@ -591,7 +591,7 @@ public final class ComponentTree extends Tree implements DataProvider {
|
||||
myEditor = editor;
|
||||
}
|
||||
|
||||
public void deleteElement(DataContext dataContext) {
|
||||
public void deleteElement(@NotNull DataContext dataContext) {
|
||||
if (myEditor != null) {
|
||||
LwInspectionSuppression[] suppressions = LW_INSPECTION_SUPPRESSION_ARRAY_DATA_KEY.getData(dataContext);
|
||||
if (suppressions != null) {
|
||||
@@ -610,7 +610,7 @@ public final class ComponentTree extends Tree implements DataProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canDeleteElement(DataContext dataContext) {
|
||||
public boolean canDeleteElement(@NotNull DataContext dataContext) {
|
||||
if (myEditor != null) {
|
||||
LwInspectionSuppression[] suppressions = LW_INSPECTION_SUPPRESSION_ARRAY_DATA_KEY.getData(dataContext);
|
||||
if (suppressions != null) {
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.intellij.uiDesigner.radComponents.RadContainer;
|
||||
import com.intellij.uiDesigner.radComponents.RadRootContainer;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -458,14 +459,14 @@ public class GridCaptionPanel extends JPanel implements ComponentSelectionListen
|
||||
}
|
||||
|
||||
private class MyDeleteProvider implements DeleteProvider {
|
||||
public void deleteElement(DataContext dataContext) {
|
||||
public void deleteElement(@NotNull DataContext dataContext) {
|
||||
int[] selection = getSelectedCells(null);
|
||||
if (selection.length > 0) {
|
||||
FormEditingUtil.deleteRowOrColumn(myEditor, mySelectedContainer, selection, myIsRow);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canDeleteElement(DataContext dataContext) {
|
||||
public boolean canDeleteElement(@NotNull DataContext dataContext) {
|
||||
if (mySelectedContainer == null || mySelectionModel.isSelectionEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1037,7 +1037,7 @@ public final class GuiEditor extends JPanel implements DataProvider {
|
||||
* Allows "DEL" button to work through the standard mechanism
|
||||
*/
|
||||
private final class MyDeleteProvider implements DeleteProvider {
|
||||
public void deleteElement(final DataContext dataContext) {
|
||||
public void deleteElement(@NotNull final DataContext dataContext) {
|
||||
if (!GuiEditor.this.ensureEditable()) {
|
||||
return;
|
||||
}
|
||||
@@ -1048,7 +1048,7 @@ public final class GuiEditor extends JPanel implements DataProvider {
|
||||
}, UIDesignerBundle.message("command.delete.selection"), null);
|
||||
}
|
||||
|
||||
public boolean canDeleteElement(final DataContext dataContext) {
|
||||
public boolean canDeleteElement(@NotNull final DataContext dataContext) {
|
||||
final UIDesignerToolWindowManager manager = UIDesignerToolWindowManager.getInstance(getProject());
|
||||
return
|
||||
!manager.getPropertyInspector().isEditing() &&
|
||||
|
||||
+3
-2
@@ -31,6 +31,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.uiDesigner.binding.FormClassIndex;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -150,12 +151,12 @@ public class FormMergerTreeStructureProvider implements TreeStructureProvider {
|
||||
myElements = collectFormPsiElements(selected);
|
||||
}
|
||||
|
||||
public void deleteElement(DataContext dataContext) {
|
||||
public void deleteElement(@NotNull DataContext dataContext) {
|
||||
Project project = PlatformDataKeys.PROJECT.getData(dataContext);
|
||||
DeleteHandler.deletePsiElement(myElements, project);
|
||||
}
|
||||
|
||||
public boolean canDeleteElement(DataContext dataContext) {
|
||||
public boolean canDeleteElement(@NotNull DataContext dataContext) {
|
||||
return DeleteHandler.shouldEnableDeleteAction(myElements);
|
||||
}
|
||||
|
||||
|
||||
+12
-11
@@ -34,6 +34,7 @@ import com.intellij.openapi.ide.CopyPasteManager;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
@@ -58,7 +59,7 @@ public class CommonEditActionsProvider implements DeleteProvider, CopyProvider,
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public boolean canDeleteElement(DataContext dataContext) {
|
||||
public boolean canDeleteElement(@NotNull DataContext dataContext) {
|
||||
// TODO: InplaceEditing
|
||||
List<RadComponent> selection = myDesigner.getActionsArea().getSelection();
|
||||
if (selection.isEmpty()) {
|
||||
@@ -73,7 +74,7 @@ public class CommonEditActionsProvider implements DeleteProvider, CopyProvider,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteElement(DataContext dataContext) {
|
||||
public void deleteElement(@NotNull DataContext dataContext) {
|
||||
CommandProcessor.getInstance().executeCommand(myDesigner.getProject(), new Runnable() {
|
||||
public void run() {
|
||||
myDesigner.getToolProvider().execute(new ThrowableRunnable<Exception>() {
|
||||
@@ -125,18 +126,18 @@ public class CommonEditActionsProvider implements DeleteProvider, CopyProvider,
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public boolean isCopyVisible(DataContext dataContext) {
|
||||
public boolean isCopyVisible(@NotNull DataContext dataContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCopyEnabled(DataContext dataContext) {
|
||||
public boolean isCopyEnabled(@NotNull DataContext dataContext) {
|
||||
// TODO: InplaceEditing
|
||||
return !myDesigner.getActionsArea().getSelection().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performCopy(DataContext dataContext) {
|
||||
public void performCopy(@NotNull DataContext dataContext) {
|
||||
doCopy();
|
||||
}
|
||||
|
||||
@@ -164,12 +165,12 @@ public class CommonEditActionsProvider implements DeleteProvider, CopyProvider,
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public boolean isPastePossible(DataContext dataContext) {
|
||||
public boolean isPastePossible(@NotNull DataContext dataContext) {
|
||||
return isPasteEnabled(dataContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPasteEnabled(DataContext dataContext) {
|
||||
public boolean isPasteEnabled(@NotNull DataContext dataContext) {
|
||||
// TODO: InplaceEditing
|
||||
return getSerializedComponentData() != null;
|
||||
}
|
||||
@@ -203,7 +204,7 @@ public class CommonEditActionsProvider implements DeleteProvider, CopyProvider,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performPaste(DataContext dataContext) {
|
||||
public void performPaste(@NotNull DataContext dataContext) {
|
||||
ComponentPasteFactory factory = myDesigner.createPasteFactory(getSerializedComponentData());
|
||||
if (factory != null) {
|
||||
myDesigner.getToolProvider().setActiveTool(new PasteTool(true, factory));
|
||||
@@ -217,17 +218,17 @@ public class CommonEditActionsProvider implements DeleteProvider, CopyProvider,
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public boolean isCutVisible(DataContext dataContext) {
|
||||
public boolean isCutVisible(@NotNull DataContext dataContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCutEnabled(DataContext dataContext) {
|
||||
public boolean isCutEnabled(@NotNull DataContext dataContext) {
|
||||
return isCopyEnabled(dataContext) && canDeleteElement(dataContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performCut(DataContext dataContext) {
|
||||
public void performCut(@NotNull DataContext dataContext) {
|
||||
if (doCopy()) {
|
||||
deleteElement(dataContext);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user