mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-26 06:22:48 -04:00
removed StringUtils
This commit is contained in:
parent
4b9b437dc1
commit
4f3154958f
@ -6,7 +6,7 @@ import de.neemann.digital.draw.elements.VisualElement;
|
||||
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;
|
||||
@ -316,11 +316,11 @@ public class LibraryNode implements Iterable<LibraryNode> {
|
||||
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"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,7 +21,7 @@ import de.neemann.digital.gui.sync.Sync;
|
||||
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.*;
|
||||
@ -292,7 +292,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
if (tt != null && tt.length() == 0)
|
||||
return null;
|
||||
else
|
||||
return StringUtils.textToHTML(tt);
|
||||
return new LineBreaker().toHTML().breakLines(tt);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,7 +14,7 @@ import de.neemann.digital.gui.sync.NoSync;
|
||||
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;
|
||||
@ -95,7 +95,7 @@ public final class EditorFactory {
|
||||
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);
|
||||
@ -211,7 +211,7 @@ public final class EditorFactory {
|
||||
|
||||
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
|
||||
|
@ -11,7 +11,7 @@ import de.neemann.digital.lang.Lang;
|
||||
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;
|
||||
@ -79,7 +79,7 @@ public class TestResultDialog extends JDialog {
|
||||
|
||||
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)
|
||||
|
@ -43,10 +43,28 @@ public class ErrorMessage implements Runnable {
|
||||
|
||||
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
|
||||
*
|
||||
|
@ -1,64 +0,0 @@
|
||||
package de.neemann.gui;
|
||||
|
||||
/**
|
||||
* Some helper functions concerning strings
|
||||
*/
|
||||
public final class StringUtils {
|
||||
|
||||
|
||||
private StringUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a list to a {@link StringBuilder}
|
||||
*
|
||||
* @param sb the StringBuilder
|
||||
* @param i the list
|
||||
* @param separator the separator to use
|
||||
*/
|
||||
public static void addList(StringBuilder sb, Iterable<?> i, String separator) {
|
||||
boolean first = true;
|
||||
for (Object o : i) {
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
sb.append(separator);
|
||||
sb.append(o.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a exception message
|
||||
*
|
||||
* @param e the {@link Throwable} instance
|
||||
* @return the message
|
||||
*/
|
||||
public static String getExceptionMessage(Throwable e) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
while (e != null) {
|
||||
final String m = e.getMessage();
|
||||
if (m != null && m.length() > 0)
|
||||
sb.append(m);
|
||||
else
|
||||
sb.append(e.getClass().getSimpleName());
|
||||
e = e.getCause();
|
||||
if (e != null)
|
||||
sb.append("\ncaused by: ");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats text to html if it contains line breaks.
|
||||
* Short texts are unchanged. Ignores the containing line breaks.
|
||||
*
|
||||
* @param text the text
|
||||
* @return the unchanged text or a HTML segment
|
||||
*/
|
||||
public static String textToHTML(String text) {
|
||||
return new LineBreaker().toHTML().breakLines(text);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user