Skip to content

Commit

Permalink
removed StringUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
hneemann committed Apr 30, 2017
1 parent 4b9b437 commit 4f31549
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import de.neemann.digital.draw.shapes.ShapeFactory;
import de.neemann.digital.lang.Lang;
import de.neemann.gui.IconCreator;
import de.neemann.gui.StringUtils;
import de.neemann.gui.LineBreaker;

import javax.swing.*;
import java.io.File;
Expand Down Expand Up @@ -316,11 +316,11 @@ public String getToolTipText() {
if (description == null)
return Lang.get("msg_fileNotImportedYet");
else
return StringUtils.textToHTML(description.getDescription(new ElementAttributes()));
return new LineBreaker().toHTML().breakLines(description.getDescription(new ElementAttributes()));
} else
return Lang.get("msg_fileIsNotUnique");
} else
return StringUtils.textToHTML(Lang.getNull("elem_" + getName() + "_tt"));
return new LineBreaker().toHTML().breakLines(Lang.getNull("elem_" + getName() + "_tt"));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import de.neemann.digital.lang.Lang;
import de.neemann.gui.ErrorMessage;
import de.neemann.gui.IconCreator;
import de.neemann.gui.StringUtils;
import de.neemann.gui.LineBreaker;
import de.neemann.gui.ToolTipAction;

import javax.swing.*;
Expand Down Expand Up @@ -292,7 +292,7 @@ private String checkToolTip(String tt) {
if (tt != null && tt.length() == 0)
return null;
else
return StringUtils.textToHTML(tt);
return new LineBreaker().toHTML().breakLines(tt);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import de.neemann.digital.lang.Lang;
import de.neemann.digital.testing.TestData;
import de.neemann.gui.ErrorMessage;
import de.neemann.gui.StringUtils;
import de.neemann.gui.LineBreaker;
import de.neemann.gui.ToolTipAction;
import de.neemann.gui.language.Bundle;
import de.neemann.gui.language.Language;
Expand Down Expand Up @@ -95,7 +95,7 @@ public void addToPanel(JPanel panel, Key key, ElementAttributes elementAttribute
JLabel label = new JLabel(key.getName() + ": ");
if (labelAtTop)
label.setVerticalAlignment(JLabel.TOP);
final String description = StringUtils.textToHTML(key.getDescription());
final String description = new LineBreaker().toHTML().breakLines(key.getDescription());
label.setToolTipText(description);
panel.add(label, DialogLayout.LABEL);
JComponent component = getComponent(elementAttributes);
Expand Down Expand Up @@ -211,7 +211,7 @@ private final static class BooleanEditor implements Editor<Boolean> {

public BooleanEditor(Boolean value, Key<Boolean> key) {
bool = new JCheckBox(key.getName(), value);
bool.setToolTipText(StringUtils.textToHTML(key.getDescription()));
bool.setToolTipText(new LineBreaker().toHTML().breakLines(key.getDescription()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import de.neemann.digital.testing.*;
import de.neemann.gui.ErrorMessage;
import de.neemann.gui.IconCreator;
import de.neemann.gui.StringUtils;
import de.neemann.gui.LineBreaker;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
Expand Down Expand Up @@ -79,7 +79,7 @@ public TestResultDialog(JFrame owner, ArrayList<TestSet> tsl, Circuit circuit, E

tp.addTab(tabName, tabIcon, new JScrollPane(table));
if (tr.toManyResults())
tp.setToolTipTextAt(i, StringUtils.textToHTML(Lang.get("msg_test_missingLines_tt")));
tp.setToolTipTextAt(i, new LineBreaker().toHTML().breakLines(Lang.get("msg_test_missingLines_tt")));
i++;
}
if (errorTabIndex >= 0)
Expand Down
20 changes: 19 additions & 1 deletion src/main/java/de/neemann/gui/ErrorMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,28 @@ public ErrorMessage addCause(Throwable e) {

if (message.length() > 0)
message.append('\n');
message.append(StringUtils.getExceptionMessage(e));
addExceptionMessage(e);
return this;
}

/**
* Creates a exception message
*
* @param e the {@link Throwable} instance
*/
private void addExceptionMessage(Throwable e) {
while (e != null) {
final String m = e.getMessage();
if (m != null && m.length() > 0)
message.append(m);
else
message.append(e.getClass().getSimpleName());
e = e.getCause();
if (e != null)
message.append("\ncaused by: ");
}
}

/**
* Shows the error message
*
Expand Down
64 changes: 0 additions & 64 deletions src/main/java/de/neemann/gui/StringUtils.java

This file was deleted.

0 comments on commit 4f31549

Please sign in to comment.