Merge branch 'master' of git.labs.intellij.net:idea/community

This commit is contained in:
Alexey Pegov
2010-02-04 16:27:27 +03:00
47 changed files with 1173 additions and 822 deletions
@@ -17,17 +17,19 @@ package com.intellij.openapi.roots.ui.configuration.artifacts.sourceItems;
import com.intellij.ide.projectView.PresentationData;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.DependencyScope;
import com.intellij.openapi.roots.ModuleOrderEntry;
import com.intellij.openapi.roots.OrderEntry;
import com.intellij.packaging.artifacts.Artifact;
import com.intellij.packaging.artifacts.ArtifactType;
import com.intellij.packaging.elements.PackagingElement;
import com.intellij.packaging.ui.ArtifactEditorContext;
import com.intellij.packaging.ui.PackagingSourceItem;
import com.intellij.packaging.ui.SourceItemPresentation;
import com.intellij.packaging.ui.SourceItemWeights;
import com.intellij.packaging.elements.PackagingElementFactory;
import com.intellij.packaging.ui.*;
import com.intellij.ui.ColoredTreeCellRenderer;
import com.intellij.ui.SimpleTextAttributes;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.List;
import java.util.*;
/**
* @author nik
@@ -36,7 +38,7 @@ public class ModuleSourceItemGroup extends PackagingSourceItem {
private final Module myModule;
public ModuleSourceItemGroup(@NotNull Module module) {
super(false);
super(true);
myModule = module;
}
@@ -54,7 +56,47 @@ public class ModuleSourceItemGroup extends PackagingSourceItem {
@NotNull
public List<? extends PackagingElement<?>> createElements(@NotNull ArtifactEditorContext context) {
return Collections.emptyList();
final Set<Module> modules = new LinkedHashSet<Module>();
collectDependentModules(myModule, modules, context);
final Artifact artifact = context.getArtifact();
final ArtifactType artifactType = artifact.getArtifactType();
Set<PackagingSourceItem> items = new LinkedHashSet<PackagingSourceItem>();
for (Module module : modules) {
for (PackagingSourceItemsProvider provider : PackagingSourceItemsProvider.EP_NAME.getExtensions()) {
final ModuleSourceItemGroup parent = new ModuleSourceItemGroup(module);
for (PackagingSourceItem sourceItem : provider.getSourceItems(context, artifact, parent)) {
if (artifactType.isSuitableItem(sourceItem) && sourceItem.isProvideElements()) {
items.add(sourceItem);
}
}
}
}
List<PackagingElement<?>> result = new ArrayList<PackagingElement<?>>();
final PackagingElementFactory factory = PackagingElementFactory.getInstance();
for (PackagingSourceItem item : items) {
final String path = artifactType.getDefaultPathFor(item.getKindOfProducedElements());
if (path != null) {
result.addAll(factory.createParentDirectories(path, item.createElements(context)));
}
}
return result;
}
private static void collectDependentModules(final Module module, Set<Module> modules, ArtifactEditorContext context) {
if (!modules.add(module)) return;
for (OrderEntry entry : context.getModulesProvider().getRootModel(module).getOrderEntries()) {
if (entry instanceof ModuleOrderEntry) {
final ModuleOrderEntry moduleEntry = (ModuleOrderEntry)entry;
final Module dependency = moduleEntry.getModule();
final DependencyScope scope = moduleEntry.getScope();
if (dependency != null && scope != DependencyScope.TEST && scope != DependencyScope.PROVIDED) {
collectDependentModules(dependency, modules, context);
}
}
}
}
public Module getModule() {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,7 +45,7 @@ public class StartupActionScriptManager {
for (ActionCommand actionCommand : commands) {
//noinspection HardCodedStringLiteral
System.out.println("Execute " + actionCommand);
LOG.info("Execute " + actionCommand);
actionCommand.execute();
}
if (commands.size() > 0) {
@@ -78,8 +78,7 @@ public class StartupActionScriptManager {
// problem with scrambled code
// fas fixed, but still appear because corrupted file still exists
// return empty list.
System.err.println("Internal file was corrupted. Problem is fixed.\nIf some plugins has been installed/uninstalled, please re-install/-uninstall them.");
e.printStackTrace();
LOG.error("Internal file was corrupted. Problem is fixed.\nIf some plugins has been installed/uninstalled, please re-install/-uninstall them.", e);
return new ArrayList<ActionCommand>();
}
@@ -94,17 +93,20 @@ public class StartupActionScriptManager {
private static void saveActionScript(List<ActionCommand> commands) throws IOException {
File temp = new File(PathManager.getPluginTempPath());
boolean exists = true;
if (!temp.exists()) {
temp.mkdirs();
exists = temp.mkdirs();
}
File file = new File(getActionScriptPath());
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file, false));
try {
oos.writeObject(commands);
}
finally {
oos.close();
if (exists) {
File file = new File(getActionScriptPath());
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file, false));
try {
oos.writeObject(commands);
}
finally {
oos.close();
}
}
}
@@ -145,7 +147,7 @@ public class StartupActionScriptManager {
if (!mySource.exists()) {
//noinspection HardCodedStringLiteral
System.err.println("Source file " + mySource.getAbsolutePath() + " does not exist for action " + this);
LOG.error("Source file " + mySource.getAbsolutePath() + " does not exist for action " + this);
}
else if (!canCreateFile(myDestination)) {
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),
@@ -184,7 +186,7 @@ public class StartupActionScriptManager {
public void execute() throws IOException {
if (!mySource.exists()) {
//noinspection HardCodedStringLiteral
System.err.println("Source file " + mySource.getAbsolutePath() + " does not exist for action " + this);
LOG.error("Source file " + mySource.getAbsolutePath() + " does not exist for action " + this);
}
else if (!canCreateFile(myDestination)) {
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),
@@ -222,7 +224,7 @@ public class StartupActionScriptManager {
public void execute() throws IOException {
if (mySource != null && mySource.exists() && !FileUtil.delete(mySource)) {
//noinspection HardCodedStringLiteral
System.err.println("Action " + this + " failed.");
LOG.error("Action " + this + " failed.");
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),
MessageFormat.format("<html>Cannot delete {0}<br>Please, check your access rights on folder <br>{1}",
mySource.getAbsolutePath(), mySource.getAbsolutePath()),
@@ -17,6 +17,7 @@ package com.intellij.openapi.wm;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.Expirable;
@@ -71,8 +72,10 @@ public abstract class IdeFocusManager {
public abstract ActionCallback requestDefaultFocus(boolean forced);
public static IdeFocusManager getInstance(@NotNull Project project) {
if (project.isDisposed() || !project.isInitialized()) return PassThroughtIdeFocusManager.getInstance();
public static IdeFocusManager getInstance(@Nullable Project project) {
if (project == null) return getGlobalInstance();
if (project.isDisposed() || !project.isInitialized()) return getGlobalInstance();
return project.getComponent(IdeFocusManager.class);
}
@@ -88,7 +91,7 @@ public abstract class IdeFocusManager {
}
if (instance == null) {
instance = PassThroughtIdeFocusManager.getInstance();
instance = getGlobalInstance();
}
return instance;
@@ -128,4 +131,8 @@ public abstract class IdeFocusManager {
public abstract Expirable getTimestamp(boolean trackOnlyForcedCommands);
public static IdeFocusManager getGlobalInstance() {
return ApplicationManager.getApplication().getComponent(IdeFocusManager.class);
}
}
@@ -163,7 +163,7 @@ public class JBTabsImpl extends JComponent
public JBTabsImpl(@Nullable Project project, ActionManager actionManager, IdeFocusManager focusManager, @NotNull Disposable parent) {
myProject = project;
myActionManager = actionManager;
myFocusManager = focusManager != null ? focusManager : PassThroughtIdeFocusManager.getInstance();
myFocusManager = focusManager != null ? focusManager : IdeFocusManager.getGlobalInstance();
setOpaque(true);
setPaintBorder(-1, -1, -1, -1);
@@ -252,7 +252,7 @@ public class JBTabsImpl extends JComponent
myDragHelper.start();
}
if (myProject != null && myFocusManager == PassThroughtIdeFocusManager.getInstance()) {
if (myProject != null && myFocusManager == IdeFocusManager.getGlobalInstance()) {
myFocusManager = IdeFocusManager.getInstance(myProject);
}
}
@@ -0,0 +1,82 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.diff.impl.fragments;
import com.intellij.openapi.diff.DiffColors;
import com.intellij.openapi.diff.actions.MergeOperations;
import com.intellij.openapi.diff.impl.highlighting.DiffMarkup;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.util.TextRange;
import java.util.Iterator;
public class FragmentHighlighterImpl implements FragmentHighlighter {
private final DiffMarkup myAppender1;
private final DiffMarkup myAppender2;
private final boolean myIsLast;
public FragmentHighlighterImpl(DiffMarkup appender1, DiffMarkup appender2, boolean isLast) {
myAppender1 = appender1;
myAppender2 = appender2;
myIsLast = isLast;
}
public void highlightInline(final InlineFragment fragment) {
myAppender1.highlightText(fragment, true);
myAppender2.highlightText(fragment, true);
}
public void highlightLine(final LineFragment fragment) {
addModifyActions(fragment, myAppender1, myAppender2);
final Iterator<Fragment> iterator = fragment.getChildrenIterator();
if (iterator == null) {
myAppender1.highlightText(fragment, false);
myAppender2.highlightText(fragment, false);
}
else {
for (; iterator.hasNext();) {
Fragment childFragment = iterator.next();
childFragment.highlight(this);
}
}
if (fragment.isEqual() && myIsLast) return;
addBottomLine(fragment, myAppender1, fragment.getEndLine1());
addBottomLine(fragment, myAppender2, fragment.getEndLine2());
}
private void addModifyActions(final LineFragment fragment, DiffMarkup wrapper, DiffMarkup otherWrapper) {
if (fragment.isEqual()) return;
if (fragment.isHasLineChildren()) return;
TextRange range = fragment.getRange(wrapper.getSide());
TextRange otherRange = fragment.getRange(wrapper.getSide().otherSide());
Document document = wrapper.getDocument();
Document otherDocument = otherWrapper.getDocument();
wrapper.addAction(MergeOperations.mostSensible(document, otherDocument, range, otherRange), range.getStartOffset());
otherWrapper.addAction(MergeOperations.mostSensible(otherDocument, document, otherRange, range), otherRange.getStartOffset());
}
private void addBottomLine(final Fragment fragment, DiffMarkup appender, int endLine) {
if (endLine <= 0) return;
TextRange range = fragment.getRange(appender.getSide());
appender.addLineMarker(endLine - 1, getRangeType(fragment, range));
}
private TextAttributesKey getRangeType(final Fragment fragment, final TextRange range) {
if (range.getLength() == 0) return DiffColors.DIFF_DELETED;
return fragment.getType() == null ? null : DiffColors.DIFF_MODIFIED;
}
}
@@ -24,6 +24,7 @@ import com.intellij.openapi.diff.impl.EditorSource;
import com.intellij.openapi.diff.impl.fragments.Fragment;
import com.intellij.openapi.diff.impl.util.GutterActionRenderer;
import com.intellij.openapi.diff.impl.util.TextDiffType;
import com.intellij.openapi.diff.impl.util.TextDiffTypeEnum;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.colors.TextAttributesKey;
@@ -59,7 +60,9 @@ public abstract class DiffMarkup implements EditorSource {
}
public void highlightText(Fragment fragment, boolean drawBorder) {
TextDiffType type = fragment.getType();
final TextDiffTypeEnum diffTypeEnum = fragment.getType();
if (diffTypeEnum == null) return;
TextDiffType type = TextDiffType.create(diffTypeEnum);
if (type == null) return;
TextRange range = fragment.getRange(getSide());
TextAttributes attributes = type.getTextAttributes(getEditor());
@@ -18,6 +18,7 @@ package com.intellij.openapi.diff.impl.highlighting;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diff.impl.ComparisonPolicy;
import com.intellij.openapi.diff.impl.fragments.FragmentHighlighterImpl;
import com.intellij.openapi.diff.impl.fragments.FragmentList;
import com.intellij.openapi.diff.impl.fragments.FragmentListImpl;
import com.intellij.openapi.diff.impl.fragments.LineFragment;
@@ -60,7 +61,8 @@ public class SimpleDiffPanelState<DiffMarkupType extends DiffMarkup> implements
public void run() {
for (Iterator<LineFragment> iterator = lines.iterator(); iterator.hasNext();) {
LineFragment line = iterator.next();
line.highlight(myAppender1, myAppender2, !iterator.hasNext());
final FragmentHighlighterImpl fragmentHighlighter = new FragmentHighlighterImpl(myAppender1, myAppender2, !iterator.hasNext());
line.highlight(fragmentHighlighter);
}
}
});
@@ -17,7 +17,7 @@ package com.intellij.openapi.diff.impl.processing;
import com.intellij.openapi.diff.ex.DiffFragment;
import com.intellij.openapi.diff.impl.fragments.LineFragment;
import com.intellij.openapi.diff.impl.util.TextDiffType;
import com.intellij.openapi.diff.impl.util.TextDiffTypeEnum;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
@@ -30,7 +30,7 @@ class LineFragmentsCollector {
private int myOffset1 = 0;
private int myOffset2 = 0;
private LineFragment addFragment(TextDiffType type, String text1, String text2) {
private LineFragment addFragment(TextDiffTypeEnum type, String text1, String text2) {
int lines1 = countLines(text1);
int lines2 = countLines(text2);
int endOffset1 = myOffset1 + getLength(text1);
@@ -65,11 +65,11 @@ class LineFragmentsCollector {
return myLineFragments;
}
static TextDiffType getType(DiffFragment fragment) {
TextDiffType type;
if (fragment.getText1() == null) type = TextDiffType.INSERT;
else if (fragment.getText2() == null) type = TextDiffType.DELETED;
else if (fragment.isModified()) type = TextDiffType.CHANGED;
static TextDiffTypeEnum getType(DiffFragment fragment) {
TextDiffTypeEnum type;
if (fragment.getText1() == null) type = TextDiffTypeEnum.INSERT;
else if (fragment.getText2() == null) type = TextDiffTypeEnum.DELETED;
else if (fragment.isModified()) type = TextDiffTypeEnum.CHANGED;
else type = null;
return type;
}
@@ -18,6 +18,7 @@ package com.intellij.openapi.diff.impl.splitter;
import com.intellij.openapi.diff.impl.EditingSides;
import com.intellij.openapi.diff.impl.highlighting.FragmentSide;
import com.intellij.openapi.diff.impl.util.TextDiffType;
import com.intellij.openapi.diff.impl.util.TextDiffTypeEnum;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.LogicalPosition;
import com.intellij.openapi.util.Comparing;
@@ -91,7 +92,9 @@ class DividerPoligon {
ArrayList<DividerPoligon> poligons = new ArrayList<DividerPoligon>();
for (int i = indecies.getStart(); i < indecies.getEnd(); i++) {
Trapezium trapezium = lineBlocks.getTrapezium(i);
TextDiffType type = lineBlocks.getType(i);
final TextDiffTypeEnum diffTypeEnum = lineBlocks.getType(i);
if (diffTypeEnum == null) continue;
TextDiffType type = TextDiffType.create(diffTypeEnum);
if (type == null) continue;
Color color = type.getPoligonColor(editor1);
poligons.add(createPoligon(transformations, trapezium, color, left));
@@ -20,7 +20,7 @@ import com.intellij.openapi.diff.impl.fragments.LineBlock;
import com.intellij.openapi.diff.impl.fragments.LineFragment;
import com.intellij.openapi.diff.impl.highlighting.FragmentSide;
import com.intellij.openapi.diff.impl.incrementalMerge.Change;
import com.intellij.openapi.diff.impl.util.TextDiffType;
import com.intellij.openapi.diff.impl.util.TextDiffTypeEnum;
import com.intellij.util.containers.IntArrayList;
import java.util.ArrayList;
@@ -29,12 +29,12 @@ import java.util.Comparator;
import java.util.Iterator;
public class LineBlocks {
public static final LineBlocks EMPTY = new LineBlocks(SimpleIntervalProvider.EMPTY, new TextDiffType[0]);
public static final LineBlocks EMPTY = new LineBlocks(SimpleIntervalProvider.EMPTY, new TextDiffTypeEnum[0]);
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.diff.impl.splitter.LineBlocks");
private final IntervalsProvider myIntervalsProvider;
private final TextDiffType[] myTypes;
private final TextDiffTypeEnum[] myTypes;
private LineBlocks(IntervalsProvider intervalsProvider, TextDiffType[] types) {
private LineBlocks(IntervalsProvider intervalsProvider, TextDiffTypeEnum[] types) {
myIntervalsProvider = intervalsProvider;
myTypes = types;
}
@@ -56,7 +56,7 @@ public class LineBlocks {
getIntervals(FragmentSide.SIDE2)[index]);
}
public TextDiffType getType(int index) {
public TextDiffTypeEnum getType(int index) {
return myTypes[index];
}
@@ -151,7 +151,7 @@ public class LineBlocks {
Arrays.sort(blocks, LineBlock.COMPARATOR);
Interval[] intervals1 = new Interval[blocks.length];
Interval[] intervals2 = new Interval[blocks.length];
TextDiffType[] types = new TextDiffType[blocks.length];
TextDiffTypeEnum[] types = new TextDiffTypeEnum[blocks.length];
for (int i = 0; i < blocks.length; i++) {
LineBlock block = blocks[i];
intervals1[i] = new Interval(block.getStartingLine1(), block.getModifiedLines1());
@@ -161,14 +161,14 @@ public class LineBlocks {
return create(intervals1, intervals2, types);
}
private static LineBlocks create(Interval[] intervals1, Interval[] intervals2, TextDiffType[] types) {
private static LineBlocks create(Interval[] intervals1, Interval[] intervals2, TextDiffTypeEnum[] types) {
return new LineBlocks(new SimpleIntervalProvider(intervals1, intervals2), types);
}
public static LineBlocks fromChanges(ArrayList<Change> changes) {
ArrayList<Interval> intervals1 = new ArrayList<Interval>();
ArrayList<Interval> intervals2 = new ArrayList<Interval>();
ArrayList<TextDiffType> types = new ArrayList<TextDiffType>();
ArrayList<TextDiffTypeEnum> types = new ArrayList<TextDiffTypeEnum>();
//int prevEnd1 = 0;
//int prevEnd2 = 0;
for (Iterator<Change> iterator = changes.iterator(); iterator.hasNext();) {
@@ -185,7 +185,7 @@ public class LineBlocks {
intervals1.add(Interval.fromTo(start1, end1));
int end2 = change.getChangeSide(FragmentSide.SIDE2).getEndLine();
intervals2.add(Interval.fromTo(start2, end2));
types.add(change.getType().getTypeKey());
types.add(change.getType().getTypeKey().getType());
//prevEnd1 = end1;
//prevEnd2 = end2;
}
@@ -197,10 +197,10 @@ public class LineBlocks {
//}
return create(intervals1.toArray(new Interval[intervals1.size()]),
intervals2.toArray(new Interval[intervals2.size()]), types.toArray(new TextDiffType[types.size()]));
intervals2.toArray(new Interval[intervals2.size()]), types.toArray(new TextDiffTypeEnum[types.size()]));
}
public TextDiffType[] getTypes() {
public TextDiffTypeEnum[] getTypes() {
return myTypes;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,19 +23,21 @@ import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.util.containers.Convertor;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
import java.util.Arrays;
import java.util.List;
public class TextDiffType implements DiffStatusBar.LegendTypeDescriptor {
public static final TextDiffType INSERT = new TextDiffType(DiffBundle.message("diff.type.inserted.name"), DiffColors.DIFF_INSERTED);
public static final TextDiffType CHANGED = new TextDiffType(DiffBundle.message("diff.type.changed.name"), DiffColors.DIFF_MODIFIED);
public static final TextDiffType DELETED = new TextDiffType(DiffBundle.message("diff.type.deleted.name"), DiffColors.DIFF_DELETED);
public static final TextDiffType CONFLICT = new TextDiffType(DiffBundle.message("diff.type.conflict.name"), DiffColors.DIFF_CONFLICT);
public static final TextDiffType INSERT = new TextDiffType(TextDiffTypeEnum.INSERT, DiffBundle.message("diff.type.inserted.name"), DiffColors.DIFF_INSERTED);
public static final TextDiffType CHANGED = new TextDiffType(TextDiffTypeEnum.CHANGED, DiffBundle.message("diff.type.changed.name"), DiffColors.DIFF_MODIFIED);
public static final TextDiffType DELETED = new TextDiffType(TextDiffTypeEnum.DELETED, DiffBundle.message("diff.type.deleted.name"), DiffColors.DIFF_DELETED);
public static final TextDiffType CONFLICT = new TextDiffType(TextDiffTypeEnum.CONFLICT, DiffBundle.message("diff.type.conflict.name"), DiffColors.DIFF_CONFLICT);
public static final TextDiffType NONE = new TextDiffType(DiffBundle.message("diff.type.none.name"), null);
public static final TextDiffType NONE = new TextDiffType(TextDiffTypeEnum.NONE, DiffBundle.message("diff.type.none.name"), null);
private final TextDiffTypeEnum myType;
public static final List<TextDiffType> DIFF_TYPES = Arrays.asList(new TextDiffType[]{DELETED, CHANGED, INSERT});
public static final List<TextDiffType> MERGE_TYPES = Arrays.asList(new TextDiffType[]{DELETED, CHANGED, INSERT, CONFLICT});
private final TextAttributesKey myAttributesKey;
@@ -46,7 +48,23 @@ public class TextDiffType implements DiffStatusBar.LegendTypeDescriptor {
}
};
private TextDiffType(String displayName, TextAttributesKey attrubutesKey) {
public static TextDiffType create(@NotNull final TextDiffTypeEnum type) {
if (TextDiffTypeEnum.INSERT.equals(type)) {
return INSERT;
} else if (TextDiffTypeEnum.CHANGED.equals(type)) {
return CHANGED;
} else if (TextDiffTypeEnum.DELETED.equals(type)) {
return DELETED;
} else if (TextDiffTypeEnum.CONFLICT.equals(type)) {
return CONFLICT;
} else {
// NONE
return NONE;
}
}
private TextDiffType(TextDiffTypeEnum type, String displayName, TextAttributesKey attrubutesKey) {
myType = type;
myAttributesKey = attrubutesKey;
myDisplayName = displayName;
}
@@ -84,4 +102,8 @@ public class TextDiffType implements DiffStatusBar.LegendTypeDescriptor {
public String toString(){
return myDisplayName;
}
public TextDiffTypeEnum getType() {
return myType;
}
}
@@ -31,7 +31,6 @@ import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.EmptyRunnable;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.PassThroughtIdeFocusManager;
import com.intellij.openapi.wm.ex.WindowManagerEx;
import com.intellij.ui.FocusTrackback;
import com.intellij.ui.PopupBorder;
@@ -703,7 +702,7 @@ public class ProgressWindow extends BlockingProgressIndicator implements Disposa
}
private IdeFocusManager getFocusManager() {
return myProject != null ? IdeFocusManager.getInstance(myProject) : PassThroughtIdeFocusManager.getInstance();
return IdeFocusManager.getInstance(myProject);
}
public void dispose() {
@@ -0,0 +1,547 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.wm.impl;
import com.intellij.Patches;
import com.intellij.ide.IdeEventQueue;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationAdapter;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.EdtRunnable;
import com.intellij.openapi.util.Expirable;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.wm.*;
import com.intellij.openapi.wm.ex.IdeFocusTraversalPolicy;
import com.intellij.ui.FocusTrackback;
import com.intellij.util.Alarm;
import com.intellij.util.containers.WeakHashMap;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.awt.event.FocusEvent;
import java.awt.event.KeyEvent;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Map;
import java.util.Set;
public class FocusManagerImpl extends IdeFocusManager implements Disposable {
private Application myApp;
private FocusCommand myRequestFocusCmd;
private final ArrayList<FocusCommand> myFocusRequests = new ArrayList<FocusCommand>();
private final ArrayList<KeyEvent> myToDispatchOnDone = new ArrayList<KeyEvent>();
private int myFlushingIdleRequestsEntryCount = 0;
private WeakReference<FocusCommand> myLastForcedRequest = new WeakReference<FocusCommand>(null);
private FocusCommand myFocusCommandOnAppActivation;
private ActionCallback myCallbackOnActivation;
private final IdeEventQueue myQueue;
private final KeyProcessorConext myKeyProcessorContext = new KeyProcessorConext();
private long myCmdTimestamp;
private long myForcedCmdTimestamp;
final EdtAlarm myFocusedComponentAlaram;
private final EdtAlarm myForcedFocusRequestsAlarm;
private final EdtAlarm myIdleAlarm;
private final Set<Runnable> myIdleRequests = new com.intellij.util.containers.HashSet<Runnable>();
private final EdtRunnable myIdleRunnable = new EdtRunnable() {
public void runEdt() {
if (isFocusTransferReady() && !isIdleQueueEmpty()) {
flushIdleRequests();
}
else {
restartIdleAlarm();
}
}
};
private WindowManager myWindowManager;
private Map<IdeFrame, Component> myLastFocused = new WeakHashMap<IdeFrame, Component>();
private Map<IdeFrame, Component> myLastFocusedAtDeactivation = new WeakHashMap<IdeFrame, Component>();
public FocusManagerImpl(WindowManager wm) {
myApp = ApplicationManager.getApplication();
myQueue = IdeEventQueue.getInstance();
myWindowManager = wm;
myFocusedComponentAlaram = new EdtAlarm(this);
myForcedFocusRequestsAlarm = new EdtAlarm(this);
myIdleAlarm = new EdtAlarm(this);
final AppListener myAppListener = new AppListener();
myApp.addApplicationListener(myAppListener);
IdeEventQueue.getInstance().addDispatcher(new IdeEventQueue.EventDispatcher() {
public boolean dispatch(AWTEvent e) {
if (e instanceof FocusEvent) {
final FocusEvent fe = (FocusEvent)e;
final Component c = fe.getComponent();
if (c instanceof Window || c == null) return false;
Component parent = UIUtil.findUltimateParent(c);
if (parent instanceof IdeFrame) {
myLastFocused.put((IdeFrame)parent, c);
}
}
return false;
}
}, this);
}
public ActionCallback requestFocus(final Component c, final boolean forced) {
return requestFocus(new FocusCommand.ByComponent(c), forced);
}
public ActionCallback requestFocus(final FocusCommand command, final boolean forced) {
final ActionCallback result = new ActionCallback();
if (!forced) {
myFocusRequests.add(command);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
resetUnforcedCommand(command);
_requestFocus(command, forced, result);
}
});
}
else {
_requestFocus(command, forced, result);
}
result.doWhenProcessed(new Runnable() {
public void run() {
restartIdleAlarm();
}
});
return result;
}
private void _requestFocus(final FocusCommand command, final boolean forced, final ActionCallback result) {
if (checkForRejectOrByPass(command, forced, result)) return;
setCommand(command);
if (forced) {
myForcedFocusRequestsAlarm.cancelAllRequests();
setLastEffectiveForcedRequest(command);
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (checkForRejectOrByPass(command, forced, result)) return;
if (myRequestFocusCmd == command) {
final ActionCallback.TimedOut focusTimeout =
new ActionCallback.TimedOut(Registry.intValue("actionSystem.commandProcessingTimeout"),
"Focus command timed out, cmd=" + command, command.getAllocation(), true) {
@Override
protected void onTimeout() {
forceFinishFocusSettledown(command, result);
}
};
myCmdTimestamp++;
if (forced) {
myForcedCmdTimestamp++;
}
command.run().doWhenDone(new Runnable() {
public void run() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
result.setDone();
}
});
}
}).doWhenRejected(new Runnable() {
public void run() {
result.setRejected();
}
}).doWhenProcessed(new Runnable() {
public void run() {
resetCommand(command);
if (forced) {
myForcedFocusRequestsAlarm.addRequest(new EdtRunnable() {
public void runEdt() {
setLastEffectiveForcedRequest(null);
}
}, 250);
}
}
}).notify(focusTimeout);
}
else {
rejectCommand(command, result);
}
}
});
}
private boolean checkForRejectOrByPass(final FocusCommand cmd, final boolean forced, final ActionCallback result) {
if (cmd.isExpired()) {
rejectCommand(cmd, result);
return true;
}
final FocusCommand lastRequest = getLastEffectiveForcedRequest();
if (!forced && !isUnforcedRequestAllowed()) {
if (cmd.equals(lastRequest)) {
result.setDone();
}
else {
rejectCommand(cmd, result);
}
return true;
}
if (lastRequest != null && lastRequest.dominatesOver(cmd)) {
rejectCommand(cmd, result);
return true;
}
boolean doNotExecuteBecauseAppIsInactive =
!myApp.isActive() && (!canExecuteOnInactiveApplication(cmd) && Registry.is("actionSystem.suspendFocusTransferIfApplicationInactive"));
if (doNotExecuteBecauseAppIsInactive) {
if (myCallbackOnActivation != null) {
myCallbackOnActivation.setRejected();
}
myFocusCommandOnAppActivation = cmd;
myCallbackOnActivation = result;
return true;
}
return false;
}
private void setCommand(FocusCommand command) {
myRequestFocusCmd = command;
if (!myFocusRequests.contains(command)) {
myFocusRequests.add(command);
}
}
private void resetCommand(FocusCommand cmd) {
if (cmd == myRequestFocusCmd) {
myRequestFocusCmd = null;
}
final KeyEventProcessor processor = cmd.getProcessor();
if (processor != null) {
processor.finish(myKeyProcessorContext);
}
myFocusRequests.remove(cmd);
}
private void resetUnforcedCommand(FocusCommand cmd) {
myFocusRequests.remove(cmd);
}
private static boolean canExecuteOnInactiveApplication(FocusCommand cmd) {
return cmd.canExecuteOnInactiveApp();
}
private void setLastEffectiveForcedRequest(FocusCommand command) {
myLastForcedRequest = new WeakReference<FocusCommand>(command);
}
@Nullable
private FocusCommand getLastEffectiveForcedRequest() {
if (myLastForcedRequest == null) return null;
final FocusCommand request = myLastForcedRequest.get();
return request != null && !request.isExpired() ? request : null;
}
boolean isUnforcedRequestAllowed() {
return getLastEffectiveForcedRequest() == null;
}
public static FocusManagerImpl getInstance() {
return (FocusManagerImpl)ApplicationManager.getApplication().getComponent(IdeFocusManager.class);
}
public void dispose() {
}
private class KeyProcessorConext implements KeyEventProcessor.Context {
public java.util.List<KeyEvent> getQueue() {
return myToDispatchOnDone;
}
public void dispatch(final java.util.List<KeyEvent> events) {
doWhenFocusSettlesDown(new Runnable() {
public void run() {
myToDispatchOnDone.addAll(events);
restartIdleAlarm();
}
});
}
}
public void doWhenFocusSettlesDown(@NotNull final Runnable runnable) {
final boolean needsRestart = isIdleQueueEmpty();
myIdleRequests.add(runnable);
if (needsRestart) {
restartIdleAlarm();
}
}
private void restartIdleAlarm() {
myIdleAlarm.cancelAllRequests();
myIdleAlarm.addRequest(myIdleRunnable, Registry.intValue("actionSystem.focusIdleTimeout"));
}
private void flushIdleRequests() {
try {
myFlushingIdleRequestsEntryCount++;
final KeyEvent[] events = myToDispatchOnDone.toArray(new KeyEvent[myToDispatchOnDone.size()]);
IdeEventQueue.getInstance().getKeyEventDispatcher().resetState();
boolean keyWasPressed = false;
for (KeyEvent each : events) {
if (!isFocusTransferReady()) break;
if (!keyWasPressed) {
if (each.getID() == KeyEvent.KEY_PRESSED) {
keyWasPressed = true;
}
else {
myToDispatchOnDone.remove(each);
continue;
}
}
final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (owner != null && SwingUtilities.getWindowAncestor(owner) != null) {
myToDispatchOnDone.remove(each);
IdeEventQueue.getInstance().dispatchEvent(
new KeyEvent(owner, each.getID(), each.getWhen(), each.getModifiersEx(), each.getKeyCode(), each.getKeyChar(),
each.getKeyLocation()));
}
else {
break;
}
}
if (isPendingKeyEventsRedispatched()) {
final Runnable[] all = myIdleRequests.toArray(new Runnable[myIdleRequests.size()]);
myIdleRequests.clear();
for (Runnable each : all) {
each.run();
}
}
}
finally {
myFlushingIdleRequestsEntryCount--;
if (!isIdleQueueEmpty()) {
restartIdleAlarm();
}
}
}
public boolean isFocusTransferReady() {
if (!myFocusRequests.isEmpty()) return false;
if (myQueue == null) return true;
return !myQueue.isSuspendMode() && !myQueue.hasFocusEventsPending();
}
private boolean isIdleQueueEmpty() {
return isPendingKeyEventsRedispatched() && myIdleRequests.isEmpty();
}
private boolean isPendingKeyEventsRedispatched() {
return myToDispatchOnDone.isEmpty();
}
public boolean dispatch(KeyEvent e) {
if (!Registry.is("actionSystem.fixLostTyping")) return false;
if (myFlushingIdleRequestsEntryCount > 0) return false;
if (!isFocusTransferReady() || !isPendingKeyEventsRedispatched()) {
for (FocusCommand each : myFocusRequests) {
final KeyEventProcessor processor = each.getProcessor();
if (processor != null) {
final Boolean result = processor.dispatch(e, myKeyProcessorContext);
if (result != null) {
return result.booleanValue();
}
}
}
myToDispatchOnDone.add(e);
restartIdleAlarm();
return true;
}
else {
return false;
}
}
public void suspendKeyProcessingUntil(final ActionCallback done) {
requestFocus(new FocusCommand(done) {
public ActionCallback run() {
return done;
}
}.saveAllocation(), true);
}
public Expirable getTimestamp(final boolean trackOnlyForcedCommands) {
return new Expirable() {
long myOwnStamp = trackOnlyForcedCommands ? myForcedCmdTimestamp : myCmdTimestamp;
public boolean isExpired() {
return myOwnStamp < (trackOnlyForcedCommands ? myForcedCmdTimestamp : myCmdTimestamp);
}
};
}
static class EdtAlarm {
private final Alarm myAlarm;
private EdtAlarm(Disposable parent) {
myAlarm = new Alarm(Alarm.ThreadToUse.OWN_THREAD, parent);
}
public void cancelAllRequests() {
myAlarm.cancelAllRequests();
}
public void addRequest(EdtRunnable runnable, int delay) {
myAlarm.addRequest(runnable, delay);
}
}
private void forceFinishFocusSettledown(FocusCommand cmd, ActionCallback cmdCallback) {
rejectCommand(cmd, cmdCallback);
}
private void rejectCommand(FocusCommand cmd, ActionCallback callback) {
resetCommand(cmd);
resetUnforcedCommand(cmd);
callback.setRejected();
}
private class AppListener extends ApplicationAdapter {
@Override
public void applicationDeactivated(IdeFrame ideFrame) {
final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
Component parent = UIUtil.findUltimateParent(owner);
if (parent == ideFrame) {
myLastFocusedAtDeactivation.put(ideFrame, owner);
}
}
@Override
public void applicationActivated(final IdeFrame ideFrame) {
final FocusCommand cmd = myFocusCommandOnAppActivation;
ActionCallback callback = myCallbackOnActivation;
myFocusCommandOnAppActivation = null;
myCallbackOnActivation = null;
if (cmd != null) {
requestFocus(cmd, true).notify(callback).doWhenRejected(new Runnable() {
public void run() {
focusLastFocusedComponent(ideFrame);
}
});
}
else {
focusLastFocusedComponent(ideFrame);
}
}
private void focusLastFocusedComponent(IdeFrame ideFrame) {
final KeyboardFocusManager mgr = KeyboardFocusManager.getCurrentKeyboardFocusManager();
if (mgr.getFocusOwner() == null) {
Component c = myLastFocusedAtDeactivation.get(ideFrame);
if (c == null || !c.isShowing()) {
c = myLastFocused.get(ideFrame);
}
if (c != null && c.isShowing()) {
requestFocus(c, false);
}
}
myLastFocusedAtDeactivation.remove(ideFrame);
}
}
@Override
public JComponent getFocusTargetFor(@NotNull JComponent comp) {
return IdeFocusTraversalPolicy.getPreferredFocusedComponent(comp);
}
@Override
public Component getFocusedDescendantFor(Component comp) {
final Component focused = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (focused == null) return null;
if (focused == comp || SwingUtilities.isDescendingFrom(focused, comp)) return focused;
java.util.List<JBPopup> popups = FocusTrackback.getChildPopups(comp);
for (JBPopup each : popups) {
if (each.isFocused()) return focused;
}
return null;
}
@Override
public boolean isFocusBeingTransferred() {
return !isFocusTransferReady();
}
@Override
public ActionCallback requestDefaultFocus(boolean forced) {
return new ActionCallback.Done();
}
}
@@ -15,13 +15,10 @@
*/
package com.intellij.openapi.wm.impl;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.Expirable;
import com.intellij.openapi.wm.FocusCommand;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.ex.IdeFocusTraversalPolicy;
import com.intellij.ui.FocusTrackback;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -30,52 +27,42 @@ import java.awt.*;
import java.awt.event.KeyEvent;
public class IdeFocusManagerImpl extends IdeFocusManager {
private final ToolWindowManagerImpl myToolWindowManager;
private ToolWindowManagerImpl myToolWindowManager;
public IdeFocusManagerImpl(ToolWindowManagerImpl toolWindowManager) {
myToolWindowManager = toolWindowManager;
public IdeFocusManagerImpl(ToolWindowManagerImpl twManager) {
myToolWindowManager = twManager;
}
@NotNull
public ActionCallback requestFocus(@NotNull final Component c, final boolean forced) {
return myToolWindowManager.requestFocus(c, forced);
return getGlobalInstance().requestFocus(c, forced);
}
@NotNull
public ActionCallback requestFocus(@NotNull final FocusCommand command, final boolean forced) {
return myToolWindowManager.requestFocus(command, forced);
return getGlobalInstance().requestFocus(command, forced);
}
public JComponent getFocusTargetFor(@NotNull final JComponent comp) {
return IdeFocusTraversalPolicy.getPreferredFocusedComponent(comp);
return getGlobalInstance().getFocusTargetFor(comp);
}
public void doWhenFocusSettlesDown(@NotNull final Runnable runnable) {
myToolWindowManager.doWhenFocusSettlesDown(runnable);
getGlobalInstance().doWhenFocusSettlesDown(runnable);
}
@Nullable
public Component getFocusedDescendantFor(@NotNull final Component comp) {
final Component focused = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (focused == null) return null;
if (focused == comp || SwingUtilities.isDescendingFrom(focused, comp)) return focused;
java.util.List<JBPopup> popups = FocusTrackback.getChildPopups(comp);
for (JBPopup each : popups) {
if (each.isFocused()) return focused;
}
return null;
return getGlobalInstance().getFocusedDescendantFor(comp);
}
public boolean dispatch(KeyEvent e) {
return myToolWindowManager.dispatch(e);
return getGlobalInstance().dispatch(e);
}
@Override
public void suspendKeyProcessingUntil(@NotNull ActionCallback done) {
myToolWindowManager.suspendKeyProcessingUntil(done);
getGlobalInstance().suspendKeyProcessingUntil(done);
}
@@ -85,10 +72,10 @@ public class IdeFocusManagerImpl extends IdeFocusManager {
@Override
public Expirable getTimestamp(boolean trackOnlyForcedCommands) {
return myToolWindowManager.getTimestamp(trackOnlyForcedCommands);
return getGlobalInstance().getTimestamp(trackOnlyForcedCommands);
}
public boolean isFocusBeingTransferred() {
return !myToolWindowManager.isFocusTransferReady();
return getGlobalInstance().isFocusBeingTransferred();
}
}
@@ -106,40 +106,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
@NonNls private static final String HEIGHT_ATTR = "height";
@NonNls private static final String EXTENDED_STATE_ATTR = "extended-state";
private final EdtAlarm myFocusedComponentAlaram;
private final EdtAlarm myForcedFocusRequestsAlarm;
private final EdtAlarm myIdleAlarm;
private final Set<Runnable> myIdleRequests = new HashSet<Runnable>();
private final EdtRunnable myIdleRunnable = new EdtRunnable() {
public void runEdt() {
if (isFocusTransferReady() && !isIdleQueueEmpty()) {
flushIdleRequests();
}
else {
restartIdleAlarm();
}
}
};
private FocusCommand myRequestFocusCmd;
private final ArrayList<FocusCommand> myFocusRequests = new ArrayList<FocusCommand>();
private final ArrayList<KeyEvent> myToDispatchOnDone = new ArrayList<KeyEvent>();
private int myFlushingIdleRequestsEntryCount = 0;
private WeakReference<FocusCommand> myLastForcedRequest = new WeakReference<FocusCommand>(null);
private FocusCommand myFocusCommandOnAppActivation;
private ActionCallback myCallbackOnActivation;
private WeakReference<Component> myFocusedComponentOnDeactivation;
private WeakReference<Component> myLastFocusedProjectComponent;
private final IdeEventQueue myQueue;
private final KeyProcessorConext myKeyProcessorContext = new KeyProcessorConext();
private long myCmdTimestamp;
private long myForcedCmdTimestamp;
private final Application myApp;
private Set<String> myRestoredToolWindowIds = new java.util.HashSet<String>();
@@ -149,7 +116,6 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
*/
public ToolWindowManagerImpl(final Project project, WindowManagerEx windowManagerEx, final Application app) {
myApp = app;
myQueue = IdeEventQueue.getInstance();
myProject = project;
myWindowManager = windowManagerEx;
myListenerList = new EventListenerList();
@@ -170,39 +136,11 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
myActiveStack = new ActiveStack();
mySideStack = new SideStack();
myFocusedComponentAlaram = new EdtAlarm(project);
myForcedFocusRequestsAlarm = new EdtAlarm(project);
myIdleAlarm = new EdtAlarm(project);
final AppListener myAppListener = new AppListener();
app.addApplicationListener(myAppListener);
Disposer.register(project, new Disposable() {
public void dispose() {
app.removeApplicationListener(myAppListener);
}
});
IdeEventQueue.getInstance().addDispatcher(new IdeEventQueue.EventDispatcher() {
public boolean dispatch(AWTEvent e) {
if (e instanceof FocusEvent) {
final FocusEvent fe = (FocusEvent)e;
final Component c = fe.getComponent();
final IdeFrameImpl frame = myWindowManager.getFrame(myProject);
if (c instanceof Window || c == null || frame == null) return false;
if (isProjectComponent(c)) {
if (fe.getID() == FocusEvent.FOCUS_GAINED) {
myLastFocusedProjectComponent = new WeakReference<Component>(c);
}
}
}
return false;
}
}, myProject);
}
private Component getLastFocusedProjectComponent() {
return myLastFocusedProjectComponent != null ? myLastFocusedProjectComponent.get() : null;
FocusManagerImpl getFocusManagerImpl() {
return FocusManagerImpl.getInstance();
}
public Project getProject() {
@@ -414,7 +352,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
}).doWhenRejected(new Runnable() {
public void run() {
if (forced) {
requestFocus(new FocusCommand() {
getFocusManagerImpl().requestFocus(new FocusCommand() {
public ActionCallback run() {
final ArrayList<FinalizableCommand> cmds = new ArrayList<FinalizableCommand>();
@@ -514,7 +452,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
final ArrayList<FinalizableCommand> commandList,
boolean forced,
boolean autoFocusContents) {
if (!isUnforcedRequestAllowed() && !forced) return;
if (!getFocusManagerImpl().isUnforcedRequestAllowed() && !forced) return;
if (LOG.isDebugEnabled()) {
LOG.debug("enter: activateToolWindowImpl(" + id + ")");
@@ -1579,128 +1517,6 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
}
public void doWhenFocusSettlesDown(@NotNull final Runnable runnable) {
final boolean needsRestart = isIdleQueueEmpty();
myIdleRequests.add(runnable);
if (needsRestart) {
restartIdleAlarm();
}
}
private void restartIdleAlarm() {
myIdleAlarm.cancelAllRequests();
myIdleAlarm.addRequest(myIdleRunnable, Registry.intValue("actionSystem.focusIdleTimeout"));
}
private void flushIdleRequests() {
try {
myFlushingIdleRequestsEntryCount++;
final KeyEvent[] events = myToDispatchOnDone.toArray(new KeyEvent[myToDispatchOnDone.size()]);
IdeEventQueue.getInstance().getKeyEventDispatcher().resetState();
boolean keyWasPressed = false;
for (KeyEvent each : events) {
if (!isFocusTransferReady()) break;
if (!keyWasPressed) {
if (each.getID() == KeyEvent.KEY_PRESSED) {
keyWasPressed = true;
}
else {
myToDispatchOnDone.remove(each);
continue;
}
}
final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (owner != null && SwingUtilities.getWindowAncestor(owner) != null) {
myToDispatchOnDone.remove(each);
IdeEventQueue.getInstance().dispatchEvent(
new KeyEvent(owner, each.getID(), each.getWhen(), each.getModifiersEx(), each.getKeyCode(), each.getKeyChar(),
each.getKeyLocation()));
}
else {
break;
}
}
if (isPendingKeyEventsRedispatched()) {
final Runnable[] all = myIdleRequests.toArray(new Runnable[myIdleRequests.size()]);
myIdleRequests.clear();
for (Runnable each : all) {
each.run();
}
}
}
finally {
myFlushingIdleRequestsEntryCount--;
if (!isIdleQueueEmpty()) {
restartIdleAlarm();
}
}
}
public boolean isFocusTransferReady() {
if (!myFocusRequests.isEmpty()) return false;
if (myQueue == null) return true;
return !myQueue.isSuspendMode() && !myQueue.hasFocusEventsPending();
}
private boolean isIdleQueueEmpty() {
return isPendingKeyEventsRedispatched() && myIdleRequests.isEmpty();
}
private boolean isPendingKeyEventsRedispatched() {
return myToDispatchOnDone.isEmpty();
}
public boolean dispatch(KeyEvent e) {
if (!Registry.is("actionSystem.fixLostTyping")) return false;
if (myFlushingIdleRequestsEntryCount > 0) return false;
if (!isFocusTransferReady() || !isPendingKeyEventsRedispatched()) {
for (FocusCommand each : myFocusRequests) {
final KeyEventProcessor processor = each.getProcessor();
if (processor != null) {
final Boolean result = processor.dispatch(e, myKeyProcessorContext);
if (result != null) {
return result.booleanValue();
}
}
}
myToDispatchOnDone.add(e);
restartIdleAlarm();
return true;
}
else {
return false;
}
}
public void suspendKeyProcessingUntil(final ActionCallback done) {
requestFocus(new FocusCommand(done) {
public ActionCallback run() {
return done;
}
}.saveAllocation(), true);
}
public Expirable getTimestamp(final boolean trackOnlyForcedCommands) {
return new Expirable() {
long myOwnStamp = trackOnlyForcedCommands ? myForcedCmdTimestamp : myCmdTimestamp;
public boolean isExpired() {
return myOwnStamp < (trackOnlyForcedCommands ? myForcedCmdTimestamp : myCmdTimestamp);
}
};
}
public void stretchWidth(ToolWindowImpl toolWindow, int value) {
myToolWindowsPane.stretchWidth(toolWindow, value);
@@ -1832,10 +1648,10 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
return;
}
final WindowInfoImpl info = getInfo(myId);
myFocusedComponentAlaram.cancelAllRequests();
getFocusManagerImpl().myFocusedComponentAlaram.cancelAllRequests();
if (!info.isActive()) {
myFocusedComponentAlaram.addRequest(new EdtRunnable() {
getFocusManagerImpl().myFocusedComponentAlaram.addRequest(new EdtRunnable() {
public void runEdt() {
if (!myLayout.isToolWindowRegistered(myId)) return;
activateToolWindow(myId, false, false);
@@ -1952,26 +1768,17 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
}
public WindowManagerEx getWindowManager() {
return myWindowManager;
}
@NotNull
public String getComponentName() {
return "ToolWindowManager";
}
public ToolWindowsPane getToolWindowsPane() {
return myToolWindowsPane;
}
public ActionCallback requestFocus(final Component c, final boolean forced) {
return requestFocus(new FocusCommand.ByComponent(c), forced);
}
public ActionCallback requestDefaultFocus(final boolean forced) {
return requestFocus(new FocusCommand() {
return getFocusManagerImpl().requestFocus(new FocusCommand() {
public ActionCallback run() {
return processDefaultFocusRequest(forced);
}
@@ -1990,188 +1797,9 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
return new ActionCallback.Done();
}
public ActionCallback requestFocus(final FocusCommand command, final boolean forced) {
final ActionCallback result = new ActionCallback();
if (!forced) {
myFocusRequests.add(command);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
resetUnforcedCommand(command);
_requestFocus(command, forced, result);
}
});
}
else {
_requestFocus(command, forced, result);
}
result.doWhenProcessed(new Runnable() {
public void run() {
restartIdleAlarm();
}
});
return result;
}
private void _requestFocus(final FocusCommand command, final boolean forced, final ActionCallback result) {
if (checkForRejectOrByPass(command, forced, result)) return;
setCommand(command);
if (forced) {
myForcedFocusRequestsAlarm.cancelAllRequests();
setLastEffectiveForcedRequest(command);
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (checkForRejectOrByPass(command, forced, result)) return;
if (myRequestFocusCmd == command) {
final ActionCallback.TimedOut focusTimeout =
new ActionCallback.TimedOut(Registry.intValue("actionSystem.commandProcessingTimeout"),
"Focus command timed out, cmd=" + command, command.getAllocation(), true) {
@Override
protected void onTimeout() {
forceFinishFocusSettledown(command, result);
}
};
myCmdTimestamp++;
if (forced) {
myForcedCmdTimestamp++;
}
command.run().doWhenDone(new Runnable() {
public void run() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
result.setDone();
}
});
}
}).doWhenRejected(new Runnable() {
public void run() {
result.setRejected();
}
}).doWhenProcessed(new Runnable() {
public void run() {
resetCommand(command);
if (forced) {
myForcedFocusRequestsAlarm.addRequest(new EdtRunnable() {
public void runEdt() {
setLastEffectiveForcedRequest(null);
}
}, 250);
}
}
}).notify(focusTimeout);
}
else {
rejectCommand(command, result);
}
}
});
}
private void forceFinishFocusSettledown(FocusCommand cmd, ActionCallback cmdCallback) {
rejectCommand(cmd, cmdCallback);
}
private boolean checkForRejectOrByPass(final FocusCommand cmd, final boolean forced, final ActionCallback result) {
if (cmd.isExpired()) {
rejectCommand(cmd, result);
return true;
}
final FocusCommand lastRequest = getLastEffectiveForcedRequest();
if (!forced && !isUnforcedRequestAllowed()) {
if (cmd.equals(lastRequest)) {
result.setDone();
}
else {
rejectCommand(cmd, result);
}
return true;
}
if (lastRequest != null && lastRequest.dominatesOver(cmd)) {
rejectCommand(cmd, result);
return true;
}
boolean doNotExecuteBecauseAppIsInactive = !myApp.isActive()
&& (!canExecuteOnInactiveApplication(cmd) && Registry.is("actionSystem.suspendFocusTransferIfApplicationInactive"));
if (doNotExecuteBecauseAppIsInactive) {
if (myCallbackOnActivation != null) {
myCallbackOnActivation.setRejected();
}
myFocusCommandOnAppActivation = cmd;
myCallbackOnActivation = result;
return true;
}
return false;
}
private void rejectCommand(FocusCommand cmd, ActionCallback callback) {
resetCommand(cmd);
resetUnforcedCommand(cmd);
callback.setRejected();
}
private void setCommand(FocusCommand command) {
myRequestFocusCmd = command;
if (!myFocusRequests.contains(command)) {
myFocusRequests.add(command);
}
}
private void resetCommand(FocusCommand cmd) {
if (cmd == myRequestFocusCmd) {
myRequestFocusCmd = null;
}
final KeyEventProcessor processor = cmd.getProcessor();
if (processor != null) {
processor.finish(myKeyProcessorContext);
}
myFocusRequests.remove(cmd);
}
private void resetUnforcedCommand(FocusCommand cmd) {
myFocusRequests.remove(cmd);
}
private static boolean canExecuteOnInactiveApplication(FocusCommand cmd) {
return !Patches.REQUEST_FOCUS_MAY_ACTIVATE_APP || cmd.canExecuteOnInactiveApp();
}
private void setLastEffectiveForcedRequest(FocusCommand command) {
myLastForcedRequest = new WeakReference<FocusCommand>(command);
}
@Nullable
private FocusCommand getLastEffectiveForcedRequest() {
if (myLastForcedRequest == null) return null;
final FocusCommand request = myLastForcedRequest.get();
return request != null && !request.isExpired() ? request : null;
}
private boolean isUnforcedRequestAllowed() {
return getLastEffectiveForcedRequest() == null;
}
private boolean isProjectComponent(Component c) {
final Component frame = UIUtil.findUltimateParent(c);
@@ -2183,80 +1811,44 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
}
}
private class AppListener extends ApplicationAdapter {
@Override
public void applicationDeactivated(IdeFrame ideFrame) {
Component c;
final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (isProjectComponent(owner)) {
c = owner;
} else {
c = getLastFocusedProjectComponent();
}
myFocusedComponentOnDeactivation = c != null ? new WeakReference<Component>(c) : null;
}
@Override
public void applicationActivated(final IdeFrame ideFrame) {
final FocusCommand cmd = myFocusCommandOnAppActivation;
ActionCallback callback = myCallbackOnActivation;
myFocusCommandOnAppActivation = null;
myCallbackOnActivation = null;
if (cmd != null) {
requestFocus(cmd, true).notify(callback).doWhenRejected(new Runnable() {
public void run() {
focusLastFocusedComponent(ideFrame);
}
});
} else {
focusLastFocusedComponent(ideFrame);
}
}
private void focusLastFocusedComponent(IdeFrame ideFrame) {
final KeyboardFocusManager mgr = KeyboardFocusManager.getCurrentKeyboardFocusManager();
if (ideFrame == myWindowManager.getFrame(myProject)) {
final Component owner = mgr.getFocusOwner();
Component old = myFocusedComponentOnDeactivation != null ? myFocusedComponentOnDeactivation.get() : null;
if (owner == null && old != null && old.isShowing()) {
requestFocus(old, false);
}
myFocusedComponentOnDeactivation = null;
}
}
/**
* Delegate method for compatibility with older versions of IDEA
*/
@NotNull
public ActionCallback requestFocus(@NotNull Component c, boolean forced) {
return IdeFocusManager.getInstance(myProject).requestFocus(c, forced);
}
private static class EdtAlarm {
private final Alarm myAlarm;
private EdtAlarm(Disposable parent) {
myAlarm = new Alarm(Alarm.ThreadToUse.OWN_THREAD, parent);
}
public void cancelAllRequests() {
myAlarm.cancelAllRequests();
}
public void addRequest(EdtRunnable runnable, int delay) {
myAlarm.addRequest(runnable, delay);
}
@NotNull
public ActionCallback requestFocus(@NotNull FocusCommand command, boolean forced) {
return IdeFocusManager.getInstance(myProject).requestFocus(command, forced);
}
private class KeyProcessorConext implements KeyEventProcessor.Context {
public List<KeyEvent> getQueue() {
return myToDispatchOnDone;
}
public JComponent getFocusTargetFor(@NotNull JComponent comp) {
return IdeFocusManager.getInstance(myProject).getFocusTargetFor(comp);
}
public void dispatch(final List<KeyEvent> events) {
doWhenFocusSettlesDown(new Runnable() {
public void run() {
myToDispatchOnDone.addAll(events);
restartIdleAlarm();
}
});
}
public void doWhenFocusSettlesDown(@NotNull Runnable runnable) {
IdeFocusManager.getInstance(myProject).doWhenFocusSettlesDown(runnable);
}
public Component getFocusedDescendantFor(Component comp) {
return IdeFocusManager.getInstance(myProject).getFocusedDescendantFor(comp);
}
public boolean dispatch(KeyEvent e) {
return IdeFocusManager.getInstance(myProject).dispatch(e);
}
public void suspendKeyProcessingUntil(@NotNull ActionCallback done) {
IdeFocusManager.getInstance(myProject).suspendKeyProcessingUntil(done);
}
public boolean isFocusBeingTransferred() {
return IdeFocusManager.getInstance(myProject).isFocusBeingTransferred();
}
public Expirable getTimestamp(boolean trackOnlyForcedCommands) {
return IdeFocusManager.getInstance(myProject).getTimestamp(trackOnlyForcedCommands);
}
}
@@ -137,4 +137,8 @@ cannot.start.other.instance.is.running.error.message={0} was unable to create a
button.load.file=Load File
date.frequency=Once {0}
name.label.text=Na&me:
smth.already.exist.error.message={0} with name ''{1}'' already exist.
smth.already.exist.error.message={0} with name ''{1}'' already exist.
comparison.policy.default.name=Default
comparison.policy.trim.space.name=Trim space
comparison.policy.ignore.spaces.name=Ignore spaces
comparison.ignore.whitespace.acton.name=Ignore whitespace:
@@ -78,4 +78,4 @@ diff.type.inserted.name=Inserted
diff.type.changed.name=Changed
diff.type.deleted.name=Deleted
diff.type.conflict.name=Conflict
diff.type.none.name=None
diff.type.none.name=None
@@ -3,6 +3,12 @@
<component>
<implementation-class>com.intellij.ide.SwingCleanuper</implementation-class>
</component>
<component>
<interface-class>com.intellij.openapi.wm.IdeFocusManager</interface-class>
<implementation-class>com.intellij.openapi.wm.impl.FocusManagerImpl</implementation-class>
<headless-implementation-class>com.intellij.openapi.wm.impl.IdeFocusManagerHeadless</headless-implementation-class>
<skipForDummyProject/>
</component>
<component>
<interface-class>com.intellij.ide.DataManager</interface-class>
<implementation-class>com.intellij.ide.impl.DataManagerImpl</implementation-class>
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -76,4 +76,4 @@ public class DiffFragment {
public boolean isOneSide() {
return myText1 == null || myText2 == null;
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,13 +15,13 @@
*/
package com.intellij.openapi.diff.impl;
import com.intellij.CommonBundle;
import com.intellij.openapi.diff.ex.DiffFragment;
import com.intellij.openapi.diff.impl.highlighting.FragmentSide;
import com.intellij.openapi.diff.impl.highlighting.Util;
import com.intellij.openapi.diff.impl.processing.DiffCorrection;
import com.intellij.openapi.diff.impl.processing.Formatting;
import com.intellij.openapi.diff.impl.processing.Word;
import com.intellij.openapi.diff.DiffBundle;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
@@ -50,7 +50,7 @@ public abstract class ComparisonPolicy {
return DiffFragmentBuilder.buildFragments(builder, change);
}
public static final ComparisonPolicy DEFAULT = new ComparisonPolicy(DiffBundle.message("comparison.policy.default.name")) {
public static final ComparisonPolicy DEFAULT = new ComparisonPolicy(CommonBundle.message("comparison.policy.default.name")) {
protected Object[] getWrappers(String[] strings) {
return strings;
}
@@ -69,7 +69,7 @@ public abstract class ComparisonPolicy {
}
};
public static final ComparisonPolicy TRIM_SPACE = new ComparisonPolicy(DiffBundle.message("comparison.policy.trim.space.name")) {
public static final ComparisonPolicy TRIM_SPACE = new ComparisonPolicy(CommonBundle.message("comparison.policy.trim.space.name")) {
protected Object[] getLineWrappers(String[] lines) {
return trimStrings(lines);
}
@@ -182,7 +182,7 @@ public abstract class ComparisonPolicy {
private static class IgnoreSpacePolicy extends ComparisonPolicy implements DiffCorrection.FragmentProcessor<DiffCorrection.FragmentsCollector> {
public IgnoreSpacePolicy() {
super(DiffBundle.message("comparison.policy.ignore.spaces.name"));
super(CommonBundle.message("comparison.policy.ignore.spaces.name"));
}
protected Object[] getLineWrappers(String[] lines) {
@@ -183,4 +183,4 @@ public class DiffFragmentBuilder {
return builder.getFragments();
}
}
}
@@ -41,4 +41,4 @@ public class DiffRange implements DiffFragmentBuilder.Range {
public String toString() {
return "DiffRange: " + myStart + "," + myEnd;
}
}
}
@@ -15,19 +15,18 @@
*/
package com.intellij.openapi.diff.impl.fragments;
import com.intellij.openapi.diff.impl.highlighting.DiffMarkup;
import com.intellij.openapi.diff.impl.highlighting.FragmentSide;
import com.intellij.openapi.diff.impl.util.TextDiffType;
import com.intellij.openapi.diff.impl.util.TextDiffTypeEnum;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.TextRange;
public interface Fragment {
TextDiffType getType();
TextDiffTypeEnum getType();
TextRange getRange(FragmentSide side);
Fragment shift(TextRange range1, TextRange range2, int startingLine1, int startingLine2);
void highlight(DiffMarkup appender1, DiffMarkup appender2, boolean isLast);
void highlight(FragmentHighlighter fragmentHighlighter);
Fragment getSubfragmentAt(int offset, FragmentSide side, Condition<Fragment> condition);
}
@@ -0,0 +1,21 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.diff.impl.fragments;
public interface FragmentHighlighter {
void highlightInline(InlineFragment fragment);
void highlightLine(LineFragment fragment);
}
@@ -16,9 +16,8 @@
package com.intellij.openapi.diff.impl.fragments;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.diff.impl.highlighting.DiffMarkup;
import com.intellij.openapi.diff.impl.highlighting.FragmentSide;
import com.intellij.openapi.diff.impl.util.TextDiffType;
import com.intellij.openapi.diff.impl.util.TextDiffTypeEnum;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.TextRange;
@@ -28,15 +27,15 @@ public class InlineFragment implements Fragment {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.diff.impl.fragments.InlineFragment");
private final TextRange myRange1;
private final TextRange myRange2;
private final TextDiffType myType;
private final TextDiffTypeEnum myType;
public InlineFragment(TextDiffType type, TextRange range1, TextRange range2) {
public InlineFragment(TextDiffTypeEnum type, TextRange range1, TextRange range2) {
myType = type;
myRange1 = range1;
myRange2 = range2;
}
public TextDiffType getType() {
public TextDiffTypeEnum getType() {
return myType;
}
@@ -52,9 +51,8 @@ public class InlineFragment implements Fragment {
LineFragment.shiftRange(range2, myRange2));
}
public void highlight(DiffMarkup appender1, DiffMarkup appender2, boolean isLast) {
appender1.highlightText(this, true);
appender2.highlightText(this, true);
public void highlight(FragmentHighlighter fragmentHighlighter) {
fragmentHighlighter.highlightInline(this);
}
public Fragment getSubfragmentAt(int offset, FragmentSide side, Condition<Fragment> condition) {
@@ -15,7 +15,7 @@
*/
package com.intellij.openapi.diff.impl.fragments;
import com.intellij.openapi.diff.impl.util.TextDiffType;
import com.intellij.openapi.diff.impl.util.TextDiffTypeEnum;
import java.util.Comparator;
@@ -24,9 +24,9 @@ public class LineBlock {
private final int myModifiedLines1;
private final int myStartingLine2;
private final int myModifiedLines2;
private final TextDiffType myType;
private final TextDiffTypeEnum myType;
public LineBlock(int startingLine1, int modifiedLines1, int startingLine2, int modifiedLines2, TextDiffType blockType) {
public LineBlock(int startingLine1, int modifiedLines1, int startingLine2, int modifiedLines2, TextDiffTypeEnum blockType) {
myStartingLine1 = startingLine1;
myModifiedLines1 = modifiedLines1;
myStartingLine2 = startingLine2;
@@ -64,7 +64,7 @@ public class LineBlock {
}
};
public TextDiffType getType() {
public TextDiffTypeEnum getType() {
return myType;
}
}
@@ -16,13 +16,8 @@
package com.intellij.openapi.diff.impl.fragments;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.diff.DiffColors;
import com.intellij.openapi.diff.actions.MergeOperations;
import com.intellij.openapi.diff.impl.highlighting.DiffMarkup;
import com.intellij.openapi.diff.impl.highlighting.FragmentSide;
import com.intellij.openapi.diff.impl.util.TextDiffType;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.diff.impl.util.TextDiffTypeEnum;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.TextRange;
@@ -39,7 +34,7 @@ public class LineFragment extends LineBlock implements Fragment {
public LineFragment(int startingLine1, int modifiedLines1,
int startingLine2, int modifiedLines2,
TextDiffType blockType, TextRange range1, TextRange range2) {
TextDiffTypeEnum blockType, TextRange range1, TextRange range2) {
this(startingLine1, modifiedLines1,
startingLine2, modifiedLines2,
blockType, range1, range2, FragmentList.EMPTY);
@@ -47,7 +42,7 @@ public class LineFragment extends LineBlock implements Fragment {
private LineFragment(int startingLine1, int modifiedLines1,
int startingLine2, int modifiedLines2,
TextDiffType blockType, TextRange range1, TextRange range2, FragmentList children) {
TextDiffTypeEnum blockType, TextRange range1, TextRange range2, FragmentList children) {
super(startingLine1, modifiedLines1, startingLine2, modifiedLines2, blockType);
LOG.assertTrue(modifiedLines1 > 0 || modifiedLines2 > 0);
myRange1 = range1;
@@ -79,43 +74,8 @@ public class LineFragment extends LineBlock implements Fragment {
return new TextRange(newStart, newEnd);
}
public void highlight(DiffMarkup wrapper1, DiffMarkup wrapper2, boolean isLast) {
addModifyActions(wrapper1, wrapper2);
if (myChildren.isEmpty()) {
wrapper1.highlightText(this, false);
wrapper2.highlightText(this, false);
}
else {
for (Iterator<Fragment> iterator = myChildren.iterator(); iterator.hasNext();) {
Fragment fragment = iterator.next();
fragment.highlight(wrapper1, wrapper2, !iterator.hasNext());
}
}
if (isEqual() && isLast) return;
addBottomLine(wrapper1, getEndLine1());
addBottomLine(wrapper2, getEndLine2());
}
private void addModifyActions(DiffMarkup wrapper, DiffMarkup otherWrapper) {
if (isEqual()) return;
if (myHasLineChildren) return;
TextRange range = getRange(wrapper.getSide());
TextRange otherRange = getRange(wrapper.getSide().otherSide());
Document document = wrapper.getDocument();
Document otherDocument = otherWrapper.getDocument();
wrapper.addAction(MergeOperations.mostSensible(document, otherDocument, range, otherRange), range.getStartOffset());
otherWrapper.addAction(MergeOperations.mostSensible(otherDocument, document, otherRange, range), otherRange.getStartOffset());
}
private void addBottomLine(DiffMarkup appender, int endLine) {
if (endLine <= 0) return;
TextRange range = getRange(appender.getSide());
appender.addLineMarker(endLine - 1, getRangeType(range));
}
private TextAttributesKey getRangeType(TextRange range) {
if (range.getLength() == 0) return DiffColors.DIFF_DELETED;
return getType() == null ? null : DiffColors.DIFF_MODIFIED;
public void highlight(FragmentHighlighter fragmentHighlighter) {
fragmentHighlighter.highlightLine(this);
}
public boolean isOneSide() {
@@ -131,6 +91,10 @@ public class LineFragment extends LineBlock implements Fragment {
return childFragment != null ? childFragment : this;
}
public Iterator<Fragment> getChildrenIterator() {
return myChildren == null || myChildren.isEmpty() ? null : myChildren.iterator();
}
public String getText(String text, FragmentSide side) {
TextRange range = getRange(side);
return range.substring(text);
@@ -191,4 +155,18 @@ public class LineFragment extends LineBlock implements Fragment {
return getRange(FragmentSide.SIDE1).equals(fragment.getRange(FragmentSide.SIDE1)) &&
getRange(FragmentSide.SIDE2).equals(fragment.getRange(FragmentSide.SIDE2));
}
public boolean isHasLineChildren() {
return myHasLineChildren;
}
@Override
public int getEndLine1() {
return super.getEndLine1();
}
@Override
public int getEndLine2() {
return super.getEndLine2();
}
}
@@ -19,7 +19,6 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.diff.LineTokenizer;
import com.intellij.openapi.diff.ex.DiffFragment;
import com.intellij.openapi.diff.impl.ComparisonPolicy;
import com.intellij.openapi.diff.impl.DiffUtil;
import com.intellij.openapi.diff.impl.highlighting.FragmentSide;
import com.intellij.openapi.diff.impl.highlighting.Util;
import com.intellij.openapi.util.text.StringUtil;
@@ -133,7 +132,7 @@ public interface DiffCorrection {
}
protected final void actualAdd(DiffFragment fragment) {
if (DiffUtil.isEmpty(fragment)) return;
if (isEmpty(fragment)) return;
myItems.add(fragment);
}
@@ -153,6 +152,16 @@ public interface DiffCorrection {
}
}
// todo think where
public static int getTextLength(String text) {
return text != null ? text.length() : 0;
}
public static boolean isEmpty(DiffFragment fragment) {
return getTextLength(fragment.getText1()) == 0 &&
getTextLength(fragment.getText2()) == 0;
}
}
class FragmentsCollector extends BaseFragmentRunner<FragmentsCollector> {
@@ -15,9 +15,9 @@
*/
package com.intellij.openapi.diff.impl.processing;
import com.intellij.openapi.diff.LineTokenizer;
import com.intellij.openapi.diff.ex.DiffFragment;
import com.intellij.openapi.diff.impl.ComparisonPolicy;
import com.intellij.openapi.diff.impl.DiffUtil;
public interface DiffPolicy {
DiffFragment[] buildFragments(String text1, String text2);
@@ -33,8 +33,8 @@ public interface DiffPolicy {
}
public DiffFragment[] buildFragments(String text1, String text2) {
String[] strings1 = DiffUtil.convertToLines(text1);
String[] strings2 = DiffUtil.convertToLines(text2);
String[] strings1 = new LineTokenizer(text1).execute();
String[] strings2 = new LineTokenizer(text2).execute();
return myComparisonPolicy.buildDiffFragmentsFromLines(strings1, strings2);
}
@@ -0,0 +1,24 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.diff.impl.util;
public enum TextDiffTypeEnum {
INSERT,
CHANGED,
DELETED,
CONFLICT,
NONE
}
@@ -15,14 +15,14 @@
*/
package com.intellij.openapi.diff.impl.patch;
import com.intellij.openapi.diff.LineTokenizer;
import com.intellij.openapi.diff.ex.DiffFragment;
import com.intellij.openapi.diff.impl.ComparisonPolicy;
import com.intellij.openapi.diff.impl.DiffUtil;
import com.intellij.openapi.diff.impl.fragments.LineFragment;
import com.intellij.openapi.diff.impl.processing.DiffCorrection;
import com.intellij.openapi.diff.impl.processing.DiffFragmentsProcessor;
import com.intellij.openapi.diff.impl.processing.DiffPolicy;
import com.intellij.openapi.diff.impl.util.TextDiffType;
import com.intellij.openapi.diff.impl.util.TextDiffTypeEnum;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
@@ -104,14 +104,14 @@ public class PatchBuilder {
if (afterContent == null) {
throw new VcsException("Failed to fetch new content for changed file " + afterRevision.getFile().getPath());
}
String[] beforeLines = DiffUtil.convertToLines(beforeContent);
String[] afterLines = DiffUtil.convertToLines(afterContent);
String[] beforeLines = new LineTokenizer(beforeContent).execute();
String[] afterLines = new LineTokenizer(afterContent).execute();
DiffFragment[] woFormattingBlocks = DiffPolicy.LINES_WO_FORMATTING.buildFragments(beforeContent, afterContent);
DiffFragment[] step1lineFragments = new DiffCorrection.TrueLineBlocks(ComparisonPolicy.DEFAULT).correctAndNormalize(woFormattingBlocks);
ArrayList<LineFragment> fragments = new DiffFragmentsProcessor().process(step1lineFragments);
if (fragments.size() > 1 || (fragments.size() == 1 && fragments.get(0).getType() != null && fragments.get(0).getType() != TextDiffType.NONE)) {
if (fragments.size() > 1 || (fragments.size() == 1 && fragments.get(0).getType() != null && fragments.get(0).getType() != TextDiffTypeEnum.NONE)) {
TextFilePatch patch = buildPatchHeading(basePath, beforeRevision, afterRevision);
result.add(patch);
@@ -203,7 +203,7 @@ public class PatchBuilder {
if (content == null) {
throw new VcsException("Failed to fetch content for added file " + afterRevision.getFile().getPath());
}
String[] lines = DiffUtil.convertToLines(content);
String[] lines = new LineTokenizer(content).execute();
TextFilePatch result = buildPatchHeading(basePath, afterRevision, afterRevision);
PatchHunk hunk = new PatchHunk(-1, -1, 0, lines.length);
for(String line: lines) {
@@ -219,7 +219,7 @@ public class PatchBuilder {
if (content == null) {
throw new VcsException("Failed to fetch old content for deleted file " + beforeRevision.getFile().getPath());
}
String[] lines = DiffUtil.convertToLines(content);
String[] lines = new LineTokenizer(content).execute();
TextFilePatch result = buildPatchHeading(basePath, beforeRevision, beforeRevision);
PatchHunk hunk = new PatchHunk(0, lines.length, -1, -1);
for(String line: lines) {
@@ -235,7 +235,7 @@ public class PatchBuilder {
int endLine = -1;
while(!fragments.isEmpty()) {
LineFragment fragment = fragments.get(0);
if (fragment.getType() == null || fragment.getType() == TextDiffType.NONE) {
if (fragment.getType() == null || fragment.getType() == TextDiffTypeEnum.NONE) {
fragments.remove(0);
continue;
}
@@ -78,6 +78,7 @@ public class BrowseCvsRepositoryAction extends AbstractAction implements DumbAwa
CvsTabbedWindow tabbedWindow,
boolean successfully,
CvsHandler handler) {
if (mySelectedConfiguration == null) return;
if (! loginImpl(context.getProject(), new ModalityContextImpl(ModalityState.NON_MODAL, false),
new Consumer<VcsException>() {
public void consume(VcsException e) {
@@ -1102,13 +1102,12 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
// Register quickfix
final PsiElement nameElement = refElement.getReferenceNameElement();
final PsiElement toHighlight = nameElement != null ? nameElement : refElement;
final Annotation annotation = holder.createErrorAnnotation(toHighlight, message);
final Annotation annotation = holder.createInfoAnnotation(toHighlight, message);
// todo implement for nested classes
if (refElement.getQualifier() == null) {
registerCreateClassByTypeFix(refElement, annotation);
registerAddImportFixes(refElement, annotation);
}
annotation.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
}
else if (!resolveResult.isAccessible()) {
String message = GroovyBundle.message("cannot.access", refElement.getReferenceName());
@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowAnchor;
import com.intellij.openapi.wm.ToolWindowManager;
@@ -485,7 +486,7 @@ public class DynamicToolWindowWrapper {
int row = tree.getRowForPath(path);
myTreeTable.getSelectionModel().setSelectionInterval(row, row);
myTreeTable.scrollRectToVisible(myTreeTable.getCellRect(row, 0, true));
((ToolWindowManagerImpl)ToolWindowManager.getInstance(myProject)).requestFocus(myTreeTable, true);
IdeFocusManager.getInstance(myProject).requestFocus(myTreeTable, true);
}
@@ -23,6 +23,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiModifierList;
import com.intellij.psi.PsiModifierListOwner;
import com.intellij.psi.PsiWhiteSpace;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.GroovyRecursiveElementVisitor;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
@@ -119,14 +120,14 @@ public abstract class BaseInspectionVisitor extends GroovyRecursiveElementVisito
registerError(((GrReferenceExpression) method.getInvokedExpression()).getReferenceNameElement(), description, fix);
}
private void registerError(PsiElement location, String description,
private void registerError(@NotNull PsiElement location, String description,
LocalQuickFix[] fixes) {
problemsHolder.registerProblem(location,
description,
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, fixes);
}
protected void registerError(PsiElement location, Object... args) {
protected void registerError(@NotNull PsiElement location, Object... args) {
final LocalQuickFix[] fix = createFixes(location);
final String description = inspection.buildErrorString(args);
registerError(location, description, fix);
@@ -27,6 +27,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlo
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrNewExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
public class GroovyResultOfObjectAllocationIgnoredInspection extends BaseInspection {
@@ -60,6 +61,9 @@ public class GroovyResultOfObjectAllocationIgnoredInspection extends BaseInspect
public void visitNewExpression(GrNewExpression newExpression) {
super.visitNewExpression(newExpression);
final GrCodeReferenceElement refElement = newExpression.getReferenceElement();
if (refElement == null) return; //new expression is not correct so we shouldn't check it
final PsiElement parent = newExpression.getParent();
if (parent instanceof GrClosableBlock) {
return;
@@ -72,7 +76,7 @@ public class GroovyResultOfObjectAllocationIgnoredInspection extends BaseInspect
return;
}
}
registerError(newExpression.getReferenceElement(), newExpression.getArrayCount());
registerError(refElement, newExpression.getArrayCount());
}
}
}
@@ -30,6 +30,7 @@ public interface GrNewExpression extends GrCallExpression {
@Nullable
GrExpression getQualifier();
@Nullable
GrCodeReferenceElement getReferenceElement();
GroovyResolveResult[] multiResolveConstructor();
@@ -15,7 +15,10 @@
*/
package com.intellij.xml.util;
import com.intellij.codeInsight.lookup.*;
import com.intellij.codeInsight.lookup.DeferredUserLookupValue;
import com.intellij.codeInsight.lookup.LookupItem;
import com.intellij.codeInsight.lookup.LookupValueWithPriority;
import com.intellij.codeInsight.lookup.LookupValueWithUIHint;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Iconable;
import com.intellij.psi.PsiElement;
@@ -31,7 +34,7 @@ import java.util.List;
/**
* @author maxim
*/
public class ColorSampleLookupValue implements LookupValueWithUIHint, DeferredUserLookupValue, Iconable, LookupValueWithPriority {
public class ColorSampleLookupValue implements LookupValueWithUIHint, DeferredUserLookupValue, Iconable, LookupValueWithPriority {
private static Object[] ourColors;
private static Map<String, String> ourColorNameToHexCodeMap;
private static Map<String, String> ourHexCodeToColorNameMap;
@@ -39,210 +42,211 @@ public class ColorSampleLookupValue implements LookupValueWithUIHint, DeferredUs
@NonNls private static final String BR = "<br>";
@NonNls private static final String systemColorsString = "ActiveBorder\n" +
" Active window border.\n" +
"ActiveCaption\n" +
" Active window caption.\n" +
"AppWorkspace\n" +
" Background color of multiple document interface.\n" +
"Background\n" +
" Desktop background.\n" +
"ButtonFace\n" +
" Face color for three-dimensional display elements.\n" +
"ButtonHighlight\n" +
" Highlight color for three-dimensional display elements (for edges facing away from the light source).\n" +
"ButtonShadow\n" +
" Shadow color for three-dimensional display elements.\n" +
"ButtonText\n" +
" Text on push buttons.\n" +
"CaptionText\n" +
" Text in caption, size box, and scrollbar arrow box.\n" +
"GrayText\n" +
" Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.\n" +
"Highlight\n" +
" Item(s) selected in a control.\n" +
"HighlightText\n" +
" Text of item(s) selected in a control.\n" +
"InactiveBorder\n" +
" Inactive window border.\n" +
"InactiveCaption\n" +
" Inactive window caption.\n" +
"InactiveCaptionText\n" +
" Color of text in an inactive caption.\n" +
"InfoBackground\n" +
" Background color for tooltip controls.\n" +
"InfoText\n" +
" Text color for tooltip controls.\n" +
"Menu\n" +
" Menu background.\n" +
"MenuText\n" +
" Text in menus.\n" +
"Scrollbar\n" +
" Scroll bar gray area.\n" +
"ThreeDDarkShadow\n" +
" Dark shadow for three-dimensional display elements.\n" +
"ThreeDFace\n" +
" Face color for three-dimensional display elements.\n" +
"ThreeDHighlight\n" +
" Highlight color for three-dimensional display elements.\n" +
"ThreeDLightShadow\n" +
" Light color for three-dimensional display elements (for edges facing the light source).\n" +
"ThreeDShadow\n" +
" Dark shadow for three-dimensional display elements.\n" +
"Window\n" +
" Window background.\n" +
"WindowFrame\n" +
" Window frame.\n" +
"WindowText\n" +
" Text in windows. ";
" Active window border.\n" +
"ActiveCaption\n" +
" Active window caption.\n" +
"AppWorkspace\n" +
" Background color of multiple document interface.\n" +
"Background\n" +
" Desktop background.\n" +
"ButtonFace\n" +
" Face color for three-dimensional display elements.\n" +
"ButtonHighlight\n" +
" Highlight color for three-dimensional display elements (for edges facing away from the light source).\n" +
"ButtonShadow\n" +
" Shadow color for three-dimensional display elements.\n" +
"ButtonText\n" +
" Text on push buttons.\n" +
"CaptionText\n" +
" Text in caption, size box, and scrollbar arrow box.\n" +
"GrayText\n" +
" Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.\n" +
"Highlight\n" +
" Item(s) selected in a control.\n" +
"HighlightText\n" +
" Text of item(s) selected in a control.\n" +
"InactiveBorder\n" +
" Inactive window border.\n" +
"InactiveCaption\n" +
" Inactive window caption.\n" +
"InactiveCaptionText\n" +
" Color of text in an inactive caption.\n" +
"InfoBackground\n" +
" Background color for tooltip controls.\n" +
"InfoText\n" +
" Text color for tooltip controls.\n" +
"Menu\n" +
" Menu background.\n" +
"MenuText\n" +
" Text in menus.\n" +
"Scrollbar\n" +
" Scroll bar gray area.\n" +
"ThreeDDarkShadow\n" +
" Dark shadow for three-dimensional display elements.\n" +
"ThreeDFace\n" +
" Face color for three-dimensional display elements.\n" +
"ThreeDHighlight\n" +
" Highlight color for three-dimensional display elements.\n" +
"ThreeDLightShadow\n" +
" Light color for three-dimensional display elements (for edges facing the light source).\n" +
"ThreeDShadow\n" +
" Dark shadow for three-dimensional display elements.\n" +
"Window\n" +
" Window background.\n" +
"WindowFrame\n" +
" Window frame.\n" +
"WindowText\n" +
" Text in windows. ";
@NonNls private static final String standardColorsString = "maroon #800000 red #ff0000 orange #ffA500 yellow #ffff00 olive #808000\n" +
"purple #800080 fuchsia #ff00ff white #ffffff lime #00ff00 green #008000\n" +
"navy #000080 blue #0000ff aqua #00ffff teal #008080\n" +
"black #000000 silver #c0c0c0 gray #808080";
"purple #800080 fuchsia #ff00ff white #ffffff lime #00ff00 green #008000\n" +
"navy #000080 blue #0000ff aqua #00ffff teal #008080\n" +
"black #000000 silver #c0c0c0 gray #808080";
@NonNls private static final String colorsString = "aliceblue \t#f0f8ff \t240,248,255\n" +
" \t \tantiquewhite \t#faebd7 \t250,235,215\n" +
" \t \taqua \t#00ffff \t0,255,255\n" +
" \t \taquamarine \t#7fffd4 \t127,255,212\n" +
" \t \tazure \t#f0ffff \t240,255,255\n" +
" \t \tbeige \t#f5f5dc \t245,245,220\n" +
" \t \tbisque \t#ffe4c4 \t255,228,196\n" +
" \t \tblack \t#000000 \t0,0,0\n" +
" \t \tblanchedalmond \t#ffebcd \t255,235,205\n" +
" \t \tblue \t#0000ff \t0,0,255\n" +
" \t \tblueviolet \t#8a2be2 \t138,43,226\n" +
" \t \tbrown \t#a52a2a \t165,42,42\n" +
" \t \tburlywood \t#deb887 \t222,184,135\n" +
" \t \tcadetblue \t#5f9ea0 \t95,158,160\n" +
" \t \tchartreuse \t#7fff00 \t127,255,0\n" +
" \t \tchocolate \t#d2691e \t210,105,30\n" +
" \t \tcoral \t#ff7f50 \t255,127,80\n" +
" \t \tcornflowerblue \t#6495ed \t100,149,237\n" +
" \t \tcornsilk \t#fff8dc \t255,248,220\n" +
" \t \tcrimson \t#dc143c \t220,20,60\n" +
" \t \tcyan \t#00ffff \t0,255,255\n" +
" \t \tdarkblue \t#00008b \t0,0,139\n" +
" \t \tdarkcyan \t#008b8b \t0,139,139\n" +
" \t \tdarkgoldenrod \t#b8860b \t184,134,11\n" +
" \t \tdarkgray \t#a9a9a9 \t169,169,169\n" +
" \t \tdarkgreen \t#006400 \t0,100,0\n" +
" \t \tdarkkhaki \t#bdb76b \t189,183,107\n" +
" \t \tdarkmagenta \t#8b008b \t139,0,139\n" +
" \t \tdarkolivegreen \t#556b2f \t85,107,47\n" +
" \t \tdarkorange \t#ff8c00 \t255,140,0\n" +
" \t \tdarkorchid \t#9932cc \t153,50,204\n" +
" \t \tdarkred \t#8b0000 \t139,0,0\n" +
" \t \tdarksalmon \t#e9967a \t233,150,122\n" +
" \t \tdarkseagreen \t#8fbc8f \t143,188,143\n" +
" \t \tdarkslateblue \t#483d8b \t72,61,139\n" +
" \t \tdarkslategray \t#2f4f4f \t47,79,79\n" +
" \t \tdarkturquoise \t#00ced1 \t0,206,209\n" +
" \t \tdarkviolet \t#9400d3 \t148,0,211\n" +
" \t \tdeeppink \t#ff1493 \t255,20,147\n" +
" \t \tdeepskyblue \t#00bfff \t0,191,255\n" +
" \t \tdimgray \t#696969 \t105,105,105\n" +
" \t \tdodgerblue \t#1e90ff \t30,144,255\n" +
" \t \tfirebrick \t#b22222 \t178,34,34\n" +
" \t \tfloralwhite \t#fffaf0 \t255,250,240\n" +
" \t \tforestgreen \t#228b22 \t34,139,34\n" +
" \t \tfuchsia \t#ff00ff \t255,0,255\n" +
" \t \tgainsboro \t#dcdcdc \t220,220,220\n" +
" \t \tghostwhite \t#f8f8ff \t248,248,255\n" +
" \t \tgold \t#ffd700 \t255,215,0\n" +
" \t \tgoldenrod \t#daa520 \t218,165,32\n" +
" \t \tgray \t#808080 \t128,128,128\n" +
" \t \tgreen \t#008000 \t0,128,0\n" +
" \t \tgreenyellow \t#adff2f \t173,255,47\n" +
" \t \thoneydew \t#f0fff0 \t240,255,240\n" +
" \t \thotpink \t#ff69b4 \t255,105,180\n" +
" \t \tindianred \t#cd5c5c \t205,92,92\n" +
" \t \tindigo \t#4b0082 \t75,0,130\n" +
" \t \tivory \t#fffff0 \t255,255,240\n" +
" \t \tkhaki \t#f0e68c \t240,230,140\n" +
" \t \tlavender \t#e6e6fa \t230,230,250\n" +
" \t \tlavenderblush \t#fff0f5 \t255,240,245\n" +
" \t \tlawngreen \t#7cfc00 \t124,252,0\n" +
" \t \tlemonchiffon \t#fffacd \t255,250,205\n" +
" \t \tlightblue \t#add8e6 \t173,216,230\n" +
" \t \tlightcoral \t#f08080 \t240,128,128\n" +
" \t \tlightcyan \t#e0ffff \t224,255,255\n" +
" \t \tlightgoldenrodyellow \t#fafad2 \t250,250,210\n" +
" \t \tlightgray \t#d3d3d3 \t211,211,211\n" +
" \t \tlightgreen \t#90ee90 \t144,238,144\n" +
" \t \tlightpink \t#ffb6c1 \t255,182,193\n" +
" \t \tlightsalmon \t#ffa07a \t255,160,122\n" +
" \t \tlightseagreen \t#20b2aa \t32,178,170\n" +
" \t \tlightskyblue \t#87cefa \t135,206,250\n" +
" \t \tlightslategray \t#778899 \t119,136,153\n" +
" \t \tlightsteelblue \t#b0c4de \t176,196,222\n" +
" \t \tlightyellow \t#ffffe0 \t255,255,224\n" +
" \t \tlime \t#00ff00 \t0,255,0\n" +
" \t \tlimegreen \t#32cd32 \t50,205,50\n" +
" \t \tlinen \t#faf0e6 \t250,240,230\n" +
" \t \tmagenta \t#ff00ff \t255,0,255\n" +
" \t \tmaroon \t#800000 \t128,0,0\n" +
" \t \tmediumaquamarine \t#66cdaa \t102,205,170\n" +
" \t \tmediumblue \t#0000cd \t0,0,205\n" +
" \t \tmediumorchid \t#ba55d3 \t186,85,211\n" +
" \t \tmediumpurple \t#9370db \t147,112,219\n" +
" \t \tmediumseagreen \t#3cb371 \t60,179,113\n" +
" \t \tmediumslateblue \t#7b68ee \t123,104,238\n" +
" \t \tmediumspringgreen \t#00fa9a \t0,250,154\n" +
" \t \tmediumturquoise \t#48d1cc \t72,209,204\n" +
" \t \tmediumvioletred \t#c71585 \t199,21,133\n" +
" \t \tmidnightblue \t#191970 \t25,25,112\n" +
" \t \tmintcream \t#f5fffa \t245,255,250\n" +
" \t \tmistyrose \t#ffe4e1 \t255,228,225\n" +
" \t \tmoccasin \t#ffe4b5 \t255,228,181\n" +
" \t \tnavajowhite \t#ffdead \t255,222,173\n" +
" \t \tnavy \t#000080 \t0,0,128\n" +
" \t \toldlace \t#fdf5e6 \t253,245,230\n" +
" \t \tolive \t#808000 \t128,128,0\n" +
" \t \tolivedrab \t#6b8e23 \t107,142,35\n" +
" \t \torange \t#ffa500 \t255,165,0\n" +
" \t \torangered \t#ff4500 \t255,69,0\n" +
" \t \torchid \t#da70d6 \t218,112,214\n" +
" \t \tpalegoldenrod \t#eee8aa \t238,232,170\n" +
" \t \tpalegreen \t#98fb98 \t152,251,152\n" +
" \t \tpaleturquoise \t#afeeee \t175,238,238\n" +
" \t \tpalevioletred \t#db7093 \t219,112,147\n" +
" \t \tpapayawhip \t#ffefd5 \t255,239,213\n" +
" \t \tpeachpuff \t#ffdab9 \t255,218,185\n" +
" \t \tperu \t#cd853f \t205,133,63\n" +
" \t \tpink \t#ffc0cb \t255,192,203\n" +
" \t \tplum \t#dda0dd \t221,160,221\n" +
" \t \tpowderblue \t#b0e0e6 \t176,224,230\n" +
" \t \tpurple \t#800080 \t128,0,128\n" +
" \t \tred \t#ff0000 \t255,0,0\n" +
" \t \trosybrown \t#bc8f8f \t188,143,143\n" +
" \t \troyalblue \t#4169e1 \t65,105,225\n" +
" \t \tsaddlebrown \t#8b4513 \t139,69,19\n" +
" \t \tsalmon \t#fa8072 \t250,128,114\n" +
" \t \tsandybrown \t#f4a460 \t244,164,96\n" +
" \t \tseagreen \t#2e8b57 \t46,139,87\n" +
" \t \tseashell \t#fff5ee \t255,245,238\n" +
" \t \tsienna \t#a0522d \t160,82,45\n" +
" \t \tsilver \t#c0c0c0 \t192,192,192\n" +
" \t \tskyblue \t#87ceeb \t135,206,235\n" +
" \t \tslateblue \t#6a5acd \t106,90,205\n" +
" \t \tslategray \t#708090 \t112,128,144\n" +
" \t \tsnow \t#fffafa \t255,250,250\n" +
" \t \tspringgreen \t#00ff7f \t0,255,127\n" +
" \t \tsteelblue \t#4682b4 \t70,130,180\n" +
" \t \ttan \t#d2b48c \t210,180,140\n" +
" \t \tteal \t#008080 \t0,128,128\n" +
" \t \tthistle \t#d8bfd8 \t216,191,216\n" +
" \t \ttomato \t#ff6347 \t255,99,71\n" +
" \t \tturquoise \t#40e0d0 \t64,224,208\n" +
" \t \tviolet \t#ee82ee \t238,130,238\n" +
" \t \twheat \t#f5deb3 \t245,222,179\n" +
" \t \twhite \t#ffffff \t255,255,255\n" +
" \t \twhitesmoke \t#f5f5f5 \t245,245,245\n" +
" \t \tyellow \t#ffff00 \t255,255,0\n" +
" \t \tyellowgreen \t#9acd32 \t154,205,50";
" \t \tantiquewhite \t#faebd7 \t250,235,215\n" +
" \t \taqua \t#00ffff \t0,255,255\n" +
" \t \taquamarine \t#7fffd4 \t127,255,212\n" +
" \t \tazure \t#f0ffff \t240,255,255\n" +
" \t \tbeige \t#f5f5dc \t245,245,220\n" +
" \t \tbisque \t#ffe4c4 \t255,228,196\n" +
" \t \tblack \t#000000 \t0,0,0\n" +
" \t \tblanchedalmond \t#ffebcd \t255,235,205\n" +
" \t \tblue \t#0000ff \t0,0,255\n" +
" \t \tblueviolet \t#8a2be2 \t138,43,226\n" +
" \t \tbrown \t#a52a2a \t165,42,42\n" +
" \t \tburlywood \t#deb887 \t222,184,135\n" +
" \t \tcadetblue \t#5f9ea0 \t95,158,160\n" +
" \t \tchartreuse \t#7fff00 \t127,255,0\n" +
" \t \tchocolate \t#d2691e \t210,105,30\n" +
" \t \tcoral \t#ff7f50 \t255,127,80\n" +
" \t \tcornflowerblue \t#6495ed \t100,149,237\n" +
" \t \tcornsilk \t#fff8dc \t255,248,220\n" +
" \t \tcrimson \t#dc143c \t220,20,60\n" +
" \t \tcyan \t#00ffff \t0,255,255\n" +
" \t \tdarkblue \t#00008b \t0,0,139\n" +
" \t \tdarkcyan \t#008b8b \t0,139,139\n" +
" \t \tdarkgoldenrod \t#b8860b \t184,134,11\n" +
" \t \tdarkgray \t#a9a9a9 \t169,169,169\n" +
" \t \tdarkgreen \t#006400 \t0,100,0\n" +
" \t \tdarkkhaki \t#bdb76b \t189,183,107\n" +
" \t \tdarkmagenta \t#8b008b \t139,0,139\n" +
" \t \tdarkolivegreen \t#556b2f \t85,107,47\n" +
" \t \tdarkorange \t#ff8c00 \t255,140,0\n" +
" \t \tdarkorchid \t#9932cc \t153,50,204\n" +
" \t \tdarkred \t#8b0000 \t139,0,0\n" +
" \t \tdarksalmon \t#e9967a \t233,150,122\n" +
" \t \tdarkseagreen \t#8fbc8f \t143,188,143\n" +
" \t \tdarkslateblue \t#483d8b \t72,61,139\n" +
" \t \tdarkslategray \t#2f4f4f \t47,79,79\n" +
" \t \tdarkturquoise \t#00ced1 \t0,206,209\n" +
" \t \tdarkviolet \t#9400d3 \t148,0,211\n" +
" \t \tdeeppink \t#ff1493 \t255,20,147\n" +
" \t \tdeepskyblue \t#00bfff \t0,191,255\n" +
" \t \tdimgray \t#696969 \t105,105,105\n" +
" \t \tdodgerblue \t#1e90ff \t30,144,255\n" +
" \t \tfirebrick \t#b22222 \t178,34,34\n" +
" \t \tfloralwhite \t#fffaf0 \t255,250,240\n" +
" \t \tforestgreen \t#228b22 \t34,139,34\n" +
" \t \tfuchsia \t#ff00ff \t255,0,255\n" +
" \t \tgainsboro \t#dcdcdc \t220,220,220\n" +
" \t \tghostwhite \t#f8f8ff \t248,248,255\n" +
" \t \tgold \t#ffd700 \t255,215,0\n" +
" \t \tgoldenrod \t#daa520 \t218,165,32\n" +
" \t \tgray \t#808080 \t128,128,128\n" +
" \t \tgreen \t#008000 \t0,128,0\n" +
" \t \tgreenyellow \t#adff2f \t173,255,47\n" +
" \t \thoneydew \t#f0fff0 \t240,255,240\n" +
" \t \thotpink \t#ff69b4 \t255,105,180\n" +
" \t \tindianred \t#cd5c5c \t205,92,92\n" +
" \t \tindigo \t#4b0082 \t75,0,130\n" +
" \t \tivory \t#fffff0 \t255,255,240\n" +
" \t \tkhaki \t#f0e68c \t240,230,140\n" +
" \t \tlavender \t#e6e6fa \t230,230,250\n" +
" \t \tlavenderblush \t#fff0f5 \t255,240,245\n" +
" \t \tlawngreen \t#7cfc00 \t124,252,0\n" +
" \t \tlemonchiffon \t#fffacd \t255,250,205\n" +
" \t \tlightblue \t#add8e6 \t173,216,230\n" +
" \t \tlightcoral \t#f08080 \t240,128,128\n" +
" \t \tlightcyan \t#e0ffff \t224,255,255\n" +
" \t \tlightgoldenrodyellow \t#fafad2 \t250,250,210\n" +
" \t \tlightgray \t#d3d3d3 \t211,211,211\n" +
" \t \tlightgreen \t#90ee90 \t144,238,144\n" +
" \t \tlightpink \t#ffb6c1 \t255,182,193\n" +
" \t \tlightsalmon \t#ffa07a \t255,160,122\n" +
" \t \tlightseagreen \t#20b2aa \t32,178,170\n" +
" \t \tlightskyblue \t#87cefa \t135,206,250\n" +
" \t \tlightslategray \t#778899 \t119,136,153\n" +
" \t \tlightsteelblue \t#b0c4de \t176,196,222\n" +
" \t \tlightyellow \t#ffffe0 \t255,255,224\n" +
" \t \tlime \t#00ff00 \t0,255,0\n" +
" \t \tlimegreen \t#32cd32 \t50,205,50\n" +
" \t \tlinen \t#faf0e6 \t250,240,230\n" +
" \t \tmagenta \t#ff00ff \t255,0,255\n" +
" \t \tmaroon \t#800000 \t128,0,0\n" +
" \t \tmediumaquamarine \t#66cdaa \t102,205,170\n" +
" \t \tmediumblue \t#0000cd \t0,0,205\n" +
" \t \tmediumorchid \t#ba55d3 \t186,85,211\n" +
" \t \tmediumpurple \t#9370db \t147,112,219\n" +
" \t \tmediumseagreen \t#3cb371 \t60,179,113\n" +
" \t \tmediumslateblue \t#7b68ee \t123,104,238\n" +
" \t \tmediumspringgreen \t#00fa9a \t0,250,154\n" +
" \t \tmediumturquoise \t#48d1cc \t72,209,204\n" +
" \t \tmediumvioletred \t#c71585 \t199,21,133\n" +
" \t \tmidnightblue \t#191970 \t25,25,112\n" +
" \t \tmintcream \t#f5fffa \t245,255,250\n" +
" \t \tmistyrose \t#ffe4e1 \t255,228,225\n" +
" \t \tmoccasin \t#ffe4b5 \t255,228,181\n" +
" \t \tnavajowhite \t#ffdead \t255,222,173\n" +
" \t \tnavy \t#000080 \t0,0,128\n" +
" \t \toldlace \t#fdf5e6 \t253,245,230\n" +
" \t \tolive \t#808000 \t128,128,0\n" +
" \t \tolivedrab \t#6b8e23 \t107,142,35\n" +
" \t \torange \t#ffa500 \t255,165,0\n" +
" \t \torangered \t#ff4500 \t255,69,0\n" +
" \t \torchid \t#da70d6 \t218,112,214\n" +
" \t \tpalegoldenrod \t#eee8aa \t238,232,170\n" +
" \t \tpalegreen \t#98fb98 \t152,251,152\n" +
" \t \tpaleturquoise \t#afeeee \t175,238,238\n" +
" \t \tpalevioletred \t#db7093 \t219,112,147\n" +
" \t \tpapayawhip \t#ffefd5 \t255,239,213\n" +
" \t \tpeachpuff \t#ffdab9 \t255,218,185\n" +
" \t \tperu \t#cd853f \t205,133,63\n" +
" \t \tpink \t#ffc0cb \t255,192,203\n" +
" \t \tplum \t#dda0dd \t221,160,221\n" +
" \t \tpowderblue \t#b0e0e6 \t176,224,230\n" +
" \t \tpurple \t#800080 \t128,0,128\n" +
" \t \tred \t#ff0000 \t255,0,0\n" +
" \t \trosybrown \t#bc8f8f \t188,143,143\n" +
" \t \troyalblue \t#4169e1 \t65,105,225\n" +
" \t \tsaddlebrown \t#8b4513 \t139,69,19\n" +
" \t \tsalmon \t#fa8072 \t250,128,114\n" +
" \t \tsandybrown \t#f4a460 \t244,164,96\n" +
" \t \tseagreen \t#2e8b57 \t46,139,87\n" +
" \t \tseashell \t#fff5ee \t255,245,238\n" +
" \t \tsienna \t#a0522d \t160,82,45\n" +
" \t \tsilver \t#c0c0c0 \t192,192,192\n" +
" \t \tskyblue \t#87ceeb \t135,206,235\n" +
" \t \tslateblue \t#6a5acd \t106,90,205\n" +
" \t \tslategray \t#708090 \t112,128,144\n" +
" \t \tsnow \t#fffafa \t255,250,250\n" +
" \t \tspringgreen \t#00ff7f \t0,255,127\n" +
" \t \tsteelblue \t#4682b4 \t70,130,180\n" +
" \t \ttan \t#d2b48c \t210,180,140\n" +
" \t \tteal \t#008080 \t0,128,128\n" +
" \t \tthistle \t#d8bfd8 \t216,191,216\n" +
" \t \ttomato \t#ff6347 \t255,99,71\n" +
" \t \tturquoise \t#40e0d0 \t64,224,208\n" +
" \t \tviolet \t#ee82ee \t238,130,238\n" +
" \t \twheat \t#f5deb3 \t245,222,179\n" +
" \t \twhite \t#ffffff \t255,255,255\n" +
" \t \twhitesmoke \t#f5f5f5 \t245,245,245\n" +
" \t \tyellow \t#ffff00 \t255,255,0\n" +
" \t \tyellowgreen \t#9acd32 \t154,205,50";
private final boolean myIsStandard;
private final String myName;
private final String myValue;
private Color myColor;
private static final ArrayList<String> ourSystemColors;
private static final List<String> ourStandardColors;
static {
ourSystemColors = new ArrayList<String>();
@@ -253,6 +257,15 @@ public class ColorSampleLookupValue implements LookupValueWithUIHint, DeferredUs
ourSystemColors.add(name.toLowerCase());
tokenizer.nextToken();
}
ourStandardColors = new ArrayList<String>();
tokenizer = new StringTokenizer(standardColorsString, ", \n");
while (tokenizer.hasMoreTokens()) {
String name = tokenizer.nextToken();
ourStandardColors.add(name);
tokenizer.nextToken();
}
}
public ColorSampleLookupValue(String name, String value, boolean isStandard) {
@@ -290,6 +303,10 @@ public class ColorSampleLookupValue implements LookupValueWithUIHint, DeferredUs
return ourSystemColors.contains(s);
}
public static boolean isStandardColor(@NotNull @NonNls final String s) {
return ourStandardColors.contains(s);
}
public static Object[] getColors() {
if (ourColors == null) {
ourColorNameToHexCodeMap = new HashMap<String, String>(25);