From dbd4154ee5257fd01009bc920b7369f9d6d80425 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Mon, 17 Nov 2014 16:12:31 +0300 Subject: [PATCH] adjust array range window fixes: IDEA-132937 and IDEA-132940 --- .../settings/ArrayRendererConfigurable.java | 32 +++++++++++++++---- .../src/messages/DebuggerBundle.properties | 4 ++- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/ArrayRendererConfigurable.java b/java/debugger/impl/src/com/intellij/debugger/settings/ArrayRendererConfigurable.java index eb74b08d528e..93e6ae14f204 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/ArrayRendererConfigurable.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/ArrayRendererConfigurable.java @@ -18,6 +18,8 @@ package com.intellij.debugger.settings; import com.intellij.debugger.DebuggerBundle; import com.intellij.debugger.ui.tree.render.ArrayRenderer; import com.intellij.openapi.application.ApplicationNamesInfo; +import com.intellij.openapi.options.Configurable; +import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.UnnamedConfigurable; import com.intellij.openapi.ui.Messages; @@ -26,7 +28,7 @@ import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import java.awt.*; -public class ArrayRendererConfigurable implements UnnamedConfigurable{ +public class ArrayRendererConfigurable implements UnnamedConfigurable, Configurable.NoScroll { private JTextField myEntriesLimit; private JTextField myStartIndex; private JTextField myEndIndex; @@ -50,17 +52,25 @@ public class ArrayRendererConfigurable implements UnnamedConfigurable{ myEntriesLimit.setText(String.valueOf(myRenderer.ENTRIES_LIMIT)); } - public void apply() { + public void apply() throws ConfigurationException { applyTo(myRenderer, true); } - private void applyTo(ArrayRenderer renderer, boolean showBigRangeWarning) { + private void applyTo(ArrayRenderer renderer, boolean showBigRangeWarning) throws ConfigurationException { int newStartIndex = getInt(myStartIndex); int newEndIndex = getInt(myEndIndex); int newLimit = getInt(myEntriesLimit); + if (newStartIndex < 0) { + throw new ConfigurationException(DebuggerBundle.message("error.array.renderer.configurable.start.index.less.than.zero")); + } + + if (newEndIndex < newStartIndex) { + throw new ConfigurationException(DebuggerBundle.message("error.array.renderer.configurable.end.index.less.than.start")); + } + if (newStartIndex >= 0 && newEndIndex >= 0) { - if (newStartIndex >= newEndIndex) { + if (newStartIndex > newEndIndex) { int currentStartIndex = renderer.START_INDEX; int currentEndIndex = renderer.END_INDEX; newEndIndex = newStartIndex + (currentEndIndex - currentStartIndex); @@ -116,9 +126,12 @@ public class ArrayRendererConfigurable implements UnnamedConfigurable{ myPanel.add(endIndexLabel, new GridBagConstraints(2, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 8), 0, 0)); myPanel.add(myEndIndex, new GridBagConstraints(3, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - myPanel.add(entriesLimitLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 8), 0, 0)); + myPanel.add(entriesLimitLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 8), 0, 0)); myPanel.add(myEntriesLimit, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 8), 0, 0)); - myPanel.add(new JLabel(DebuggerBundle.message("label.array.renderer.configurable.max.count2")), new GridBagConstraints(2, GridBagConstraints.RELATIVE, 2, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 0), 0, 0)); + myPanel.add(new JLabel(DebuggerBundle.message("label.array.renderer.configurable.max.count2")), new GridBagConstraints(2, GridBagConstraints.RELATIVE, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 0), 0, 0)); + + // push other components up + myPanel.add(new JLabel(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); final DocumentListener listener = new DocumentListener() { private void updateEntriesLimit() { @@ -186,7 +199,12 @@ public class ArrayRendererConfigurable implements UnnamedConfigurable{ public boolean isModified() { ArrayRenderer cloneRenderer = myRenderer.clone(); - applyTo(cloneRenderer, false); + try { + applyTo(cloneRenderer, false); + } + catch (ConfigurationException e) { + return true; + } final boolean valuesEqual = (myRenderer.END_INDEX == cloneRenderer.END_INDEX) && (myRenderer.START_INDEX == cloneRenderer.START_INDEX) && diff --git a/resources-en/src/messages/DebuggerBundle.properties b/resources-en/src/messages/DebuggerBundle.properties index 8e09ea8a52a5..d83994ac84ee 100644 --- a/resources-en/src/messages/DebuggerBundle.properties +++ b/resources-en/src/messages/DebuggerBundle.properties @@ -174,7 +174,9 @@ status.classes.reloaded={0,number} {0,choice, 0#classes|1#class|2#classes} reloa status.classes.not.all.versions.reloaded=For {0} of {1} {1,choice, 1#class|2#classes} not all versions were reloaded error.cannot.create.void.value=Cannot create void value warning.range.too.big=Range specified is too big. {0} needs too much resources to perform requested operation. Are you sure you want to continue? -title.range.too.big=Range is Too Big +title.range.too.big=Range Is Too Big +error.array.renderer.configurable.start.index.less.than.zero=Start index is less than 0 +error.array.renderer.configurable.end.index.less.than.start=End index is less than start index label.array.renderer.configurable.start.index=Array sta&rt index: label.array.renderer.configurable.end.index=en&d index: label.array.renderer.configurable.max.count1=Show &maximum