IDEA-154559 'Git Reset' dialogue looks weird on Linux Mint

This commit is contained in:
Vassiliy.Kudryashov
2017-11-22 15:36:56 +03:00
parent 632bad9efe
commit 336e80d215
3 changed files with 30 additions and 13 deletions
@@ -119,6 +119,22 @@ public class XmlStringUtil {
return HTML_START + result + HTML_END;
}
/**
*
* @param lines Text to be used for example in multi-line labels
* @return HTML where specified lines separated by <br> and each line wrapped in <nobr> to prevent breaking text inside
*/
@NotNull
public static String wrapInHtmlLines(@NotNull CharSequence...lines) {
StringBuilder sb = new StringBuilder(HTML_START);
for (int i = 0; i < lines.length; i++) {
CharSequence sequence = lines[i];
if (i >0) sb.append("<br>");
sb.append("<nobr>").append(sequence).append("</nobr>");
}
return sb.append(HTML_END).toString();
}
public static boolean isWrappedInHtml(@NotNull String tooltip) {
return StringUtil.startsWithIgnoreCase(tooltip, HTML_START) &&
StringUtil.endsWithIgnoreCase(tooltip, HTML_END);
@@ -75,16 +75,17 @@ public class GitNewResetDialog extends DialogWrapper {
String description = prepareDescription(myProject, myCommits);
panel.add(new JBLabel(XmlStringUtil.wrapInHtml(description)), gb.nextLine().next().coverLine());
String explanation = "<nobr>This will reset the current branch head to the selected commit,</nobr><br/>" +
"<nobr>and update the working tree and the index according to the selected mode:</nobr>";
panel.add(new JBLabel(XmlStringUtil.wrapInHtml(explanation), UIUtil.ComponentStyle.SMALL), gb.nextLine().next().coverLine());
panel.add(new JBLabel(XmlStringUtil.wrapInHtmlLines(
"This will reset the current branch head to the selected commit,",
"and update the working tree and the index according to the selected mode:"
), UIUtil.ComponentStyle.SMALL), gb.nextLine().next().coverLine());
for (GitResetMode mode : GitResetMode.values()) {
JBRadioButton button = new JBRadioButton(mode.getName());
button.setMnemonic(mode.getName().charAt(0));
myButtonGroup.add(button);
panel.add(button, gb.nextLine().next());
panel.add(new JBLabel(XmlStringUtil.wrapInHtml(mode.getDescription()), UIUtil.ComponentStyle.SMALL), gb.next());
panel.add(new JBLabel(XmlStringUtil.wrapInHtmlLines(mode.getDescription()), UIUtil.ComponentStyle.SMALL), gb.next());
}
myEnumModel = RadioButtonEnumModel.bindEnum(GitResetMode.class, myButtonGroup);
@@ -19,18 +19,18 @@ import org.jetbrains.annotations.NotNull;
public enum GitResetMode {
SOFT("Soft", "--soft", "<nobr>Files won't change, differences will be staged for commit.</nobr>"),
MIXED("Mixed", "--mixed", "<nobr>Files won't change, differences won't be staged.</nobr>"),
HARD("Hard", "--hard", "<nobr>Files will be reverted to the state of the selected commit.</nobr><br/>" +
"<nobr>Warning: any local changes will be lost.</nobr>"),
KEEP("Keep", "--keep", "<nobr>Files will be reverted to the state of the selected commit,</nobr><br/>" +
"<nobr>but local changes will be kept intact.</nobr>");
SOFT("Soft", "--soft", "Files won't change, differences will be staged for commit."),
MIXED("Mixed", "--mixed", "Files won't change, differences won't be staged."),
HARD("Hard", "--hard", "Files will be reverted to the state of the selected commit.",
"Warning: any local changes will be lost."),
KEEP("Keep", "--keep", "Files will be reverted to the state of the selected commit,",
"but local changes will be kept intact.");
@NotNull private final String myName;
@NotNull private final String myArgument;
@NotNull private final String myDescription;
@NotNull private final String[] myDescription;
GitResetMode(@NotNull String name, @NotNull String argument, @NotNull String description) {
GitResetMode(@NotNull String name, @NotNull String argument, @NotNull String... description) {
myName = name;
myArgument = argument;
myDescription = description;
@@ -52,7 +52,7 @@ public enum GitResetMode {
}
@NotNull
public String getDescription() {
public String[] getDescription() {
return myDescription;
}