diff options
Diffstat (limited to 'platform/platform-api/src/com/intellij/openapi/ui')
7 files changed, 108 insertions, 60 deletions
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Banner.java b/platform/platform-api/src/com/intellij/openapi/ui/Banner.java index 8dbe02228bae..59f99ad46a05 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Banner.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Banner.java @@ -18,6 +18,7 @@ package com.intellij.openapi.ui; import com.intellij.icons.AllIcons; import com.intellij.openapi.options.OptionsBundle; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.registry.Registry; import com.intellij.ui.components.labels.LinkLabel; import com.intellij.ui.components.labels.LinkListener; import com.intellij.ui.components.panels.NonOpaquePanel; @@ -45,7 +46,7 @@ class Banner extends NonOpaquePanel implements PropertyChangeListener{ public Banner() { setLayout(new BorderLayout()); - setBorder(new EmptyBorder(2, 6, 2, 4)); + setBorder(new EmptyBorder(2, Registry.is("ide.new.settings.dialog") ? 12 : 6, 2, 4)); myProjectIcon.setVisible(false); myProjectIcon.setBorder(new EmptyBorder(0, 12, 0, 4)); diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java b/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java index 463d950ae900..00440b0dd8a6 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java @@ -17,6 +17,7 @@ package com.intellij.openapi.ui; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.registry.Registry; import com.intellij.ui.components.panels.NonOpaquePanel; import com.intellij.ui.components.panels.Wrapper; import com.intellij.util.ArrayUtil; @@ -65,47 +66,54 @@ public class DetailsComponent { protected void paintComponent(final Graphics g) { if (NullableComponent.Check.isNull(myContent) || !myDetailsEnabled) return; - GraphicsConfig c = new GraphicsConfig(g); - c.setAntialiasing(true); - - Insets insets = getInsets(); - if (insets == null) { - insets = new Insets(0, 0, 0, 0); + GraphicsConfig c = null; + Insets insets = null; + final int leftX; + final int rightX; + final int rightY; + if (!Registry.is("ide.new.settings.dialog")) { + c = new GraphicsConfig(g); + c.setAntialiasing(true); + + insets = getInsets(); + if (insets == null) { + insets = new Insets(0, 0, 0, 0); + } + + g.setColor(UIUtil.getFocusedFillColor()); + + final Rectangle banner = myBanner.getBounds(); + final GeneralPath header = new GeneralPath(); + + leftX = insets.left; + final int leftY = insets.top; + rightX = insets.left + getWidth() - 1 - insets.right; + rightY = banner.y + banner.height; + + header.moveTo(leftX, rightY); + int arc = 8; + header.lineTo(leftX, leftY + arc); + header.quadTo(leftX, leftY, leftX + arc, leftY); + header.lineTo(rightX - arc, leftY); + header.quadTo(rightX, leftY, rightX, leftY + arc); + header.lineTo(rightX, rightY); + header.closePath(); + + c.getG().fill(header); + + g.setColor(UIUtil.getFocusedBoundsColor()); + + c.getG().draw(header); + + + if (myPaintBorder) { + final int down = getHeight() - insets.top - insets.bottom - 1; + g.drawLine(leftX, rightY, leftX, down); + g.drawLine(rightX, rightY, rightX, down); + g.drawLine(leftX, down, rightX, down); + } + c.restore(); } - - g.setColor(UIUtil.getFocusedFillColor()); - - final Rectangle banner = myBanner.getBounds(); - final GeneralPath header = new GeneralPath(); - - final int leftX = insets.left; - final int leftY = insets.top; - final int rightX = insets.left + getWidth() - 1 - insets.right; - final int rightY = banner.y + banner.height; - - header.moveTo(leftX, rightY); - int arc = 8; - header.lineTo(leftX, leftY + arc); - header.quadTo(leftX, leftY, leftX + arc, leftY); - header.lineTo(rightX - arc, leftY); - header.quadTo(rightX, leftY, rightX, leftY + arc); - header.lineTo(rightX, rightY); - header.closePath(); - - c.getG().fill(header); - - g.setColor(UIUtil.getFocusedBoundsColor()); - - c.getG().draw(header); - - if (myPaintBorder) { - final int down = getHeight() - insets.top - insets.bottom - 1; - g.drawLine(leftX, rightY, leftX, down); - g.drawLine(rightX, rightY, rightX, down); - g.drawLine(leftX, down, rightX, down); - } - - c.restore(); } }; diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java index ed374a905462..e4c8c6852727 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java @@ -21,6 +21,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.help.HelpManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.containers.ContainerUtil; import org.intellij.lang.annotations.MagicConstant; import org.jetbrains.annotations.NonNls; @@ -55,26 +56,34 @@ public class DialogBuilder implements Disposable { return showImpl(true).getExitCode(); } + public boolean showAndGet() { + return showImpl(true).isOK(); + } + public void showNotModal() { showImpl(false); } - public DialogBuilder(Project project) { + public DialogBuilder(@Nullable Project project) { myDialogWrapper = new MyDialogWrapper(project, true); Disposer.register(myDialogWrapper.getDisposable(), this); } - public DialogBuilder(Component parent) { + public DialogBuilder(@Nullable Component parent) { myDialogWrapper = new MyDialogWrapper(parent, true); Disposer.register(myDialogWrapper.getDisposable(), this); } + public DialogBuilder() { + this(((Project)null)); + } + @Override public void dispose() { } private MyDialogWrapper showImpl(boolean isModal) { - LOG.assertTrue(myTitle != null && myTitle.trim().length() != 0, + LOG.assertTrue(!StringUtil.isEmptyOrSpaces(myTitle), String.format("Dialog title shouldn't be empty or null: [%s]", myTitle)); myDialogWrapper.setTitle(myTitle); myDialogWrapper.init(); @@ -91,6 +100,12 @@ public class DialogBuilder implements Disposable { } @NotNull + public DialogBuilder centerPanel(@NotNull JComponent centerPanel) { + myCenterPanel = centerPanel; + return this; + } + + @NotNull public DialogBuilder setNorthPanel(@NotNull JComponent northPanel) { myNorthPanel = northPanel; return this; @@ -100,6 +115,7 @@ public class DialogBuilder implements Disposable { myTitle = title; } + @NotNull public DialogBuilder title(@NotNull String title) { myTitle = title; return this; @@ -196,6 +212,18 @@ public class DialogBuilder implements Disposable { myDialogWrapper.setOKActionEnabled(isEnabled); } + @NotNull + public DialogBuilder okActionEnabled(boolean isEnabled) { + myDialogWrapper.setOKActionEnabled(isEnabled); + return this; + } + + @NotNull + public DialogBuilder resizable(boolean resizable) { + myDialogWrapper.setResizable(resizable); + return this; + } + public CustomizableAction getOkAction() { return get(getActionDescriptors(), OkActionDescriptor.class); } @@ -267,7 +295,7 @@ public class DialogBuilder implements Disposable { protected Action createAction(final DialogWrapper dialogWrapper) { return new AbstractAction(){ @Override - public void actionPerformed(ActionEvent e) { + public void actionPerformed(@NotNull ActionEvent e) { dialogWrapper.close(myExitCode); } }; @@ -325,7 +353,7 @@ public class DialogBuilder implements Disposable { private class MyDialogWrapper extends DialogWrapper { private String myHelpId = null; - private MyDialogWrapper(Project project, boolean canBeParent) { + private MyDialogWrapper(@Nullable Project project, boolean canBeParent) { super(project, canBeParent); } diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java index 75cb4de7af74..741f67dee2c4 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java @@ -1233,6 +1233,7 @@ public abstract class DialogWrapper { if (SystemInfo.isWindows) { installEnterHook(root); } + myErrorTextAlarm.setActivationComponent(root); } @NotNull @@ -1838,15 +1839,14 @@ public abstract class DialogWrapper { return; } myLastErrorText = text; - if (myActualSize == null && !StringUtil.isEmpty(text)) { - myActualSize = getSize(); - } - myErrorTextAlarm.cancelAllRequests(); myErrorTextAlarm.addRequest(new Runnable() { @Override public void run() { final String text = myLastErrorText; + if (myActualSize == null && !StringUtil.isEmpty(text)) { + myActualSize = getSize(); + } myErrorText.setError(text); if (text != null && text.length() > myMaxErrorTextLength) { // during the first update, resize only for growing. during a subsequent update, diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapperPeerFactory.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapperPeerFactory.java index c9515a884f97..c1239e523896 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapperPeerFactory.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapperPeerFactory.java @@ -24,17 +24,24 @@ import org.jetbrains.annotations.Nullable; import java.awt.*; public abstract class DialogWrapperPeerFactory { + @NotNull public static DialogWrapperPeerFactory getInstance() { if (ApplicationManager.getApplication() == null) { - try { - return (DialogWrapperPeerFactory)Class.forName("com.intellij.openapi.ui.impl.DialogWrapperPeerFactoryImpl").newInstance(); - } - catch (Exception e) { - throw new RuntimeException("Can't instantiate DialogWrapperPeerFactory", e); - } + return getInstanceByName(); } - return ServiceManager.getService(DialogWrapperPeerFactory.class); + DialogWrapperPeerFactory factory = ServiceManager.getService(DialogWrapperPeerFactory.class); + return factory == null ? getInstanceByName() : factory; + } + + @NotNull + private static DialogWrapperPeerFactory getInstanceByName() { + try { + return (DialogWrapperPeerFactory)Class.forName("com.intellij.openapi.ui.impl.DialogWrapperPeerFactoryImpl").newInstance(); + } + catch (Exception e) { + throw new RuntimeException("Can't instantiate DialogWrapperPeerFactory", e); + } } @NotNull diff --git a/platform/platform-api/src/com/intellij/openapi/ui/MessageDialogBuilder.java b/platform/platform-api/src/com/intellij/openapi/ui/MessageDialogBuilder.java index ab193aff20c2..7819ef68a7e5 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/MessageDialogBuilder.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/MessageDialogBuilder.java @@ -40,6 +40,7 @@ public abstract class MessageDialogBuilder<T extends MessageDialogBuilder> { myMessage = message; } + @NotNull public static YesNo yesNo(@NotNull String title, @NotNull String message) { return new YesNo(title, message).icon(Messages.getQuestionIcon()); } diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java index dae35d4b685d..1a07b33d696d 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java @@ -143,9 +143,12 @@ public class Messages { try { if (canShowMacSheetPanel()) { - Window parentWindow = WindowManager.getInstance().suggestParentWindow(project); - return MacMessages.getInstance() - .showMessageDialog(title, message, options, false, parentWindow, defaultOptionIndex, defaultOptionIndex, doNotAskOption); + WindowManager windowManager = WindowManager.getInstance(); + if (windowManager != null) { + Window parentWindow = windowManager.suggestParentWindow(project); + return MacMessages.getInstance() + .showMessageDialog(title, message, options, false, parentWindow, defaultOptionIndex, defaultOptionIndex, doNotAskOption); + } } } catch (Exception exception) { |