diff --git a/jps/jps-builders/src/org/jetbrains/jps/cmdline/ClasspathBootstrap.java b/jps/jps-builders/src/org/jetbrains/jps/cmdline/ClasspathBootstrap.java index 9c387f11e865..bb4ce3509247 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/cmdline/ClasspathBootstrap.java +++ b/jps/jps-builders/src/org/jetbrains/jps/cmdline/ClasspathBootstrap.java @@ -26,7 +26,6 @@ import com.intellij.util.SystemProperties; import com.intellij.util.containers.ContainerUtil; import com.jgoodies.forms.layout.CellConstraints; import io.netty.util.NetUtil; -import jsr166e.extra.SequenceLock; import net.n3.nanoxml.IXMLBuilder; import org.jetbrains.annotations.Nullable; import org.jetbrains.jps.builders.impl.java.EclipseCompilerTool; @@ -144,7 +143,6 @@ public class ClasspathBootstrap { cp.add(getResourcePath(CellConstraints.class)); // jGoodies-forms cp.add(getResourcePath(NotNullVerifyingInstrumenter.class)); // not-null cp.add(getResourcePath(IXMLBuilder.class)); // nano-xml - cp.add(getResourcePath(SequenceLock.class)); // jsr166 cp.add(getJpsPluginSystemClassesPath().getAbsolutePath().replace('\\', '/')); //don't forget to update layoutCommunityJps() in layouts.gant accordingly diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/ThreeDiffSplitter.java b/platform/diff-impl/src/com/intellij/diff/tools/util/ThreeDiffSplitter.java index ba28d96c5caf..82231b8566d6 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/ThreeDiffSplitter.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/ThreeDiffSplitter.java @@ -17,27 +17,39 @@ package com.intellij.diff.tools.util; import com.intellij.diff.tools.util.DiffSplitter.Painter; import com.intellij.diff.util.Side; -import com.intellij.util.containers.ContainerUtil; +import com.intellij.icons.AllIcons; import org.jetbrains.annotations.CalledInAwt; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; +import java.awt.event.MouseEvent; import java.util.List; public class ThreeDiffSplitter extends JPanel { private static final int DIVIDER_WIDTH = 30; - @NotNull private final List myDividers; @NotNull private final List myContents; + @NotNull private final Divider myDivider1; + @NotNull private final Divider myDivider2; + + private float myProportion1; // first size divided by (first + second + third) + private float myProportion2; // third size divided by (first + second + third) public ThreeDiffSplitter(@NotNull List components) { - myDividers = ContainerUtil.list(new Divider(), new Divider()); + assert components.size() == 3; myContents = components; + myDivider1 = new Divider(Side.LEFT); + myDivider2 = new Divider(Side.RIGHT); - addAll(myContents); - addAll(myDividers); + add(myDivider1); + add(myDivider2); + for (JComponent content : myContents) { + add(content); + } + + resetProportions(); } @CalledInAwt @@ -56,32 +68,44 @@ public class ThreeDiffSplitter extends JPanel { @NotNull private Divider getDivider(@NotNull Side side) { - return myDividers.get(side.getIndex()); + return side.select(myDivider1, myDivider2); } - private void addAll(@NotNull List components) { - for (JComponent component : components) { - add(component, -1); - } + private void resetProportions() { + myProportion1 = myProportion2 = 1f / 3; + } + + private void setProportion(float proportion, @NotNull Side side) { + proportion = Math.min(1f, Math.max(0f, proportion)); + float otherProportion = side.select(myProportion2, myProportion1); + otherProportion = Math.min(otherProportion, 1f - proportion); + + myProportion1 = side.select(proportion, otherProportion); + myProportion2 = side.select(otherProportion, proportion); } @Override public void doLayout() { int width = getWidth(); int height = getHeight(); - int panelWidth = (width - DIVIDER_WIDTH * 2) / 3; + + int dividersTotalWidth = DIVIDER_WIDTH * 2; + int contentsTotalWidth = Math.max(width - dividersTotalWidth, 0); + + JComponent[] components = new JComponent[]{myContents.get(0), myDivider1, myContents.get(1), myDivider2, myContents.get(2)}; + int[] contentWidths = new int[5]; + contentWidths[1] = DIVIDER_WIDTH; // divider1 + contentWidths[3] = DIVIDER_WIDTH; // divider2 + contentWidths[0] = (int)(contentsTotalWidth * myProportion1); // content1 + contentWidths[4] = (int)(contentsTotalWidth * myProportion2); // content3 + contentWidths[2] = Math.max(contentsTotalWidth - contentWidths[0] - contentWidths[4], 0); // content2 + int x = 0; - for (int i = 0; i < myContents.size(); i++) { - JComponent component = myContents.get(i); - component.setBounds(x, 0, panelWidth, height); + for (int i = 0; i < 5; i++) { + JComponent component = components[i]; + component.setBounds(x, 0, contentWidths[i], height); component.validate(); - x += panelWidth; - if (i < myDividers.size()) { - JComponent divider = myDividers.get(i); - divider.setBounds(x, 0, DIVIDER_WIDTH, height); - divider.validate(); - x += DIVIDER_WIDTH; - } + x += contentWidths[i]; } } @@ -109,12 +133,21 @@ public class ThreeDiffSplitter extends JPanel { return new Dimension(width, height); } - private static class Divider extends JComponent { + private class Divider extends JPanel { + @NotNull private final Side mySide; @Nullable private Painter myPainter; + public Divider(@NotNull Side side) { + super(new GridBagLayout()); + mySide = side; + enableEvents(MouseEvent.MOUSE_EVENT_MASK | MouseEvent.MOUSE_MOTION_EVENT_MASK); + setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR)); + add(new JLabel(AllIcons.General.SplitGlueH), new GridBagConstraints()); + } + @Override - public void paint(Graphics g) { - super.paint(g); + protected void paintComponent(Graphics g) { + super.paintComponent(g); if (myPainter != null) myPainter.paint(g, this); } @@ -122,5 +155,32 @@ public class ThreeDiffSplitter extends JPanel { public void setPainter(@Nullable Painter painter) { myPainter = painter; } + + @Override + protected void processMouseMotionEvent(MouseEvent e) { + super.processMouseMotionEvent(e); + if (e.getID() == MouseEvent.MOUSE_DRAGGED) { + int totalWidth = ThreeDiffSplitter.this.getWidth(); + if (totalWidth > 0) { + Point point = SwingUtilities.convertPoint(this, e.getPoint(), ThreeDiffSplitter.this); + float proportion = (float)mySide.select(point.x, totalWidth - point.x) / (float)totalWidth; + setProportion(proportion, mySide); + + revalidate(); + repaint(); + } + } + } + + @Override + protected void processMouseEvent(MouseEvent e) { + super.processMouseEvent(e); + if (e.getID() == MouseEvent.MOUSE_CLICKED && e.getClickCount() == 2) { + resetProportions(); + + revalidate(); + repaint(); + } + } } } diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffDividerDrawUtil.java b/platform/diff-impl/src/com/intellij/diff/util/DiffDividerDrawUtil.java index df381c067ab6..1ec8502f8b05 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffDividerDrawUtil.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffDividerDrawUtil.java @@ -198,6 +198,7 @@ public class DiffDividerDrawUtil { @NotNull private static LineRange getVisibleInterval(Editor editor) { Rectangle area = editor.getScrollingModel().getVisibleArea(); + if (area.height < 0) return new LineRange(0, 0); LogicalPosition position1 = editor.xyToLogicalPosition(new Point(0, area.y)); LogicalPosition position2 = editor.xyToLogicalPosition(new Point(0, area.y + area.height)); return new LineRange(position1.line, position2.line); diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java index a21f28b14f8d..8e3ee5ee64a0 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java @@ -79,7 +79,6 @@ import com.intellij.util.io.storage.HeavyProcessLatch; import com.intellij.util.messages.MessageBus; import com.intellij.util.messages.MessageBusConnection; import gnu.trove.*; -import jsr166e.extra.SequenceLock; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; @@ -92,6 +91,7 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; /** * @author Eugene Zhuravlev @@ -1163,7 +1163,7 @@ public class FileBasedIndexImpl extends FileBasedIndex { ++myFilesModCount; } - private final Lock myCalcIndexableFilesLock = new SequenceLock(); + private final Lock myCalcIndexableFilesLock = new ReentrantLock(); @Nullable public ProjectIndexableFilesFilter projectIndexableFiles(@Nullable Project project) { diff --git a/platform/platform-api/src/com/intellij/notification/Notification.java b/platform/platform-api/src/com/intellij/notification/Notification.java index ae801545b093..9bb6d5bbe062 100644 --- a/platform/platform-api/src/com/intellij/notification/Notification.java +++ b/platform/platform-api/src/com/intellij/notification/Notification.java @@ -290,6 +290,6 @@ public class Notification { return myImportant; } - return getListener() != null; + return getListener() != null || !ContainerUtil.isEmpty(myActions); } } diff --git a/platform/platform-impl/src/com/intellij/notification/EventLog.java b/platform/platform-impl/src/com/intellij/notification/EventLog.java index 8f745f178c2e..71e27d5ceb27 100644 --- a/platform/platform-impl/src/com/intellij/notification/EventLog.java +++ b/platform/platform-impl/src/com/intellij/notification/EventLog.java @@ -130,7 +130,7 @@ public class EventLog { public String fun(AnAction action) { return "" + action.getTemplatePresentation().getText()+""; } - }, actions.size() > 3 ? "
" : " ") + "

"; + }, isLongLine(actions) ? "
" : " ") + "

"; Notification n = new Notification("", "", ".", NotificationType.INFORMATION, new NotificationListener() { @Override public void hyperlinkUpdate(@NotNull Notification n, @NotNull HyperlinkEvent event) { @@ -169,6 +169,21 @@ public class EventLog { return new LogEntry(logDoc.getText(), status, list); } + private static boolean isLongLine(@NotNull List actions) { + int size = actions.size(); + if (size > 3) { + return true; + } + if (size > 1) { + int length = 0; + for (AnAction action : actions) { + length += StringUtil.length(action.getTemplatePresentation().getText()); + } + return length > 30; + } + return false; + } + @NotNull private static String truncateLongString(AtomicBoolean showMore, String title) { if (title.length() > 1000) { diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeBackgroundUtil.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeBackgroundUtil.java index a446132fe6db..73dda41c536d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeBackgroundUtil.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeBackgroundUtil.java @@ -55,7 +55,7 @@ public class IdeBackgroundUtil { JRootPane rootPane = component.getRootPane(); Component glassPane = rootPane == null ? null : rootPane.getGlassPane(); final PaintersHelper helper = glassPane instanceof IdeGlassPaneImpl? ((IdeGlassPaneImpl)glassPane).getNamedPainters(paintersName) : null; - if (helper == null || !helper.hasPainters()) return (Graphics2D)g; + if (helper == null || !helper.needsRepaint()) return (Graphics2D)g; return new MyGraphics(g, helper, component); } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/PaintersHelper.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/PaintersHelper.java index 3ce5607e91ee..b24c89d74759 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/PaintersHelper.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/PaintersHelper.java @@ -53,6 +53,13 @@ final class PaintersHelper implements Painter.Listener { return !myPainters.isEmpty(); } + public boolean needsRepaint() { + for (Painter painter : myPainters) { + if (painter.needsRepaint()) return true; + } + return false; + } + public void addPainter(@NotNull Painter painter, @Nullable Component component) { myPainters.add(painter); myPainter2Component.put(painter, component == null ? myRootComponent : component); @@ -125,11 +132,6 @@ final class PaintersHelper implements Painter.Listener { } public static void initWallpaperPainter(@NotNull String propertyName, @NotNull PaintersHelper painters) { - String value = System.getProperty(propertyName); - if (value == null && !new File(PathManager.getConfigPath(), propertyName + ".png").exists()) { - // property not set & there's no default - return; - } ImagePainter painter = (ImagePainter)newWallpaperPainter(propertyName); painters.addPainter(painter, null); } @@ -143,41 +145,59 @@ final class PaintersHelper implements Painter.Listener { String current; + @Override + public boolean needsRepaint() { + return ensureImageLoaded(); + } + @Override public void executePaint(Component component, Graphics2D g) { - String value = StringUtil.notNullize(System.getProperty(propertyName), propertyName + ".png"); + if (!ensureImageLoaded()) return; + executePaint(g, component, image, fillType, alpha, insets); + } + + boolean ensureImageLoaded() { + String value = System.getProperty(propertyName); if (!Comparing.equal(value, current)) { current = value; image = scaled = null; insets = JBUI.emptyInsets(); - String[] parts = value.split(","); + loadImage(value); + } + return image != null; + } + + void loadImage(@Nullable String propertyValue) { + String[] parts = (propertyValue != null ? propertyValue : propertyName + ".png").split(","); + try { + alpha = StringUtil.parseInt(parts.length > 1 ? parts[1] : "", 10) / 100f; try { - alpha = StringUtil.parseInt(parts.length > 1 ? parts[1]: "", 10) / 100f; - try { - fillType = FillType.valueOf(parts.length > 2 ? parts[2].toUpperCase(Locale.ENGLISH) : ""); - } - catch (IllegalArgumentException e) { - fillType = FillType.SCALE; - } - String filePath = parts[0]; - - URL url = filePath.contains("://") ? new URL(filePath) : - (FileUtil.isAbsolutePlatformIndependent(filePath) - ? new File(filePath) - : new File(PathManager.getConfigPath(), filePath)).toURI().toURL(); - image = ImageLoader.loadFromUrl(url); + fillType = FillType.valueOf(parts.length > 2 ? parts[2].toUpperCase(Locale.ENGLISH) : ""); } - catch (Exception ignored) { + catch (IllegalArgumentException e) { + fillType = FillType.SCALE; } + String filePath = parts[0]; + + URL url = filePath.contains("://") ? new URL(filePath) : + (FileUtil.isAbsolutePlatformIndependent(filePath) + ? new File(filePath) + : new File(PathManager.getConfigPath(), filePath)).toURI().toURL(); + image = ImageLoader.loadFromUrl(url); + } + catch (Exception ignored) { } - if (image == null) return; - executePaint(g, component, image, fillType, alpha, insets); } }; } - public static AbstractPainter newImagePainter(final Image image, final FillType fillType, final float alpha, final Insets insets) { + public static AbstractPainter newImagePainter(@NotNull final Image image, final FillType fillType, final float alpha, final Insets insets) { return new ImagePainter() { + @Override + public boolean needsRepaint() { + return true; + } + @Override public void executePaint(Component component, Graphics2D g) { executePaint(g, component, image, fillType, alpha, insets); @@ -189,9 +209,6 @@ final class PaintersHelper implements Painter.Listener { VolatileImage scaled; - @Override - public boolean needsRepaint() { return true; } - public void executePaint(Graphics2D g, Component component, Image image, FillType fillType, float alpha, Insets insets) { int cw0 = component.getWidth(); int ch0 = component.getHeight(); diff --git a/platform/util/src/com/intellij/util/containers/RecentStringInterner.java b/platform/util/src/com/intellij/util/containers/RecentStringInterner.java index e46e1b9cc563..2d71a21ded3c 100644 --- a/platform/util/src/com/intellij/util/containers/RecentStringInterner.java +++ b/platform/util/src/com/intellij/util/containers/RecentStringInterner.java @@ -16,10 +16,10 @@ package com.intellij.util.containers; import com.intellij.openapi.util.LowMemoryWatcher; -import jsr166e.extra.SequenceLock; import org.jetbrains.annotations.NotNull; import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; /** * User: Maxim.Mossienko @@ -56,7 +56,7 @@ public class RecentStringInterner { super.putToProtectedQueue(value, value); } }; - myStripeLocks[i] = new SequenceLock(); + myStripeLocks[i] = new ReentrantLock(); } assert Integer.highestOneBit(stripes) == stripes; diff --git a/platform/util/src/com/intellij/util/io/CachingEnumerator.java b/platform/util/src/com/intellij/util/io/CachingEnumerator.java index 1ef73d05e040..74dfcb3d4e63 100644 --- a/platform/util/src/com/intellij/util/io/CachingEnumerator.java +++ b/platform/util/src/com/intellij/util/io/CachingEnumerator.java @@ -16,11 +16,11 @@ package com.intellij.util.io; import com.intellij.util.containers.SLRUMap; -import jsr166e.extra.SequenceLock; import org.jetbrains.annotations.Nullable; import java.io.IOException; import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; /** * @author peter @@ -44,7 +44,7 @@ public class CachingEnumerator implements DataEnumerator { for(int i = 0; i < STRIPE_COUNT; ++i) { myHashcodeToIdCache[i] = new SLRUMap(protectedSize / STRIPE_COUNT, probationalSize / STRIPE_COUNT); myIdToStringCache[i] = new SLRUMap(protectedSize / STRIPE_COUNT, probationalSize / STRIPE_COUNT); - myStripeLocks[i] = new SequenceLock(); + myStripeLocks[i] = new ReentrantLock(); } } diff --git a/platform/util/src/com/intellij/util/io/PagedFileStorage.java b/platform/util/src/com/intellij/util/io/PagedFileStorage.java index 22b858974950..b9cd6f0d21e2 100644 --- a/platform/util/src/com/intellij/util/io/PagedFileStorage.java +++ b/platform/util/src/com/intellij/util/io/PagedFileStorage.java @@ -22,7 +22,6 @@ import com.intellij.util.SystemProperties; import com.intellij.util.containers.ConcurrentIntObjectMap; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.hash.LinkedHashMap; -import jsr166e.extra.SequenceLock; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -35,6 +34,7 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.*; import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.locks.ReentrantLock; /** * @author max @@ -486,10 +486,10 @@ public class PagedFileStorage implements Forceable { private final ConcurrentIntObjectMap myIndex2Storage = ContainerUtil.createConcurrentIntObjectMap(); private final LinkedHashMap mySegments; - private final SequenceLock mySegmentsAccessLock = new SequenceLock(); // protects map operations of mySegments, needed for LRU order, mySize and myMappingChangeCount + private final ReentrantLock mySegmentsAccessLock = new ReentrantLock(); // protects map operations of mySegments, needed for LRU order, mySize and myMappingChangeCount // todo avoid locking for access - private final SequenceLock mySegmentsAllocationLock = new SequenceLock(); + private final ReentrantLock mySegmentsAllocationLock = new ReentrantLock(); private final ConcurrentLinkedQueue mySegmentsToRemove = new ConcurrentLinkedQueue(); private volatile long mySize; private volatile long mySizeLimit; @@ -780,7 +780,7 @@ public class PagedFileStorage implements Forceable { public static class StorageLockContext { private final boolean myCheckThreadAccess; - private final SequenceLock myLock; + private final ReentrantLock myLock; private final StorageLock myStorageLock; @Deprecated @@ -789,7 +789,7 @@ public class PagedFileStorage implements Forceable { } private StorageLockContext(StorageLock lock, boolean checkAccess) { - myLock = new SequenceLock(); + myLock = new ReentrantLock(); myStorageLock = lock; myCheckThreadAccess = checkAccess; } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/VcsLogUserFilterImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/VcsLogUserFilterImpl.java index f3f0a3c5678d..8bdc98e54098 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/VcsLogUserFilterImpl.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/VcsLogUserFilterImpl.java @@ -18,7 +18,7 @@ import java.util.Set; public class VcsLogUserFilterImpl implements VcsLogUserFilter { - public @NotNull static final String ME = "me"; + @NotNull public static final String ME = "me"; @NotNull private final Collection myUsers; @NotNull private final Map myData;