-Committed StringGetter to the flames

-Fixed a missing locale string
-Simplified some code (Entry)
-Changed the CTRL+/- implementation to a much cleaner version (also
works with the numpad now)
-Added Spacebar to cycle the clock
This commit is contained in:
Dominic Laudate 2014-10-30 19:46:09 -04:00
parent 607d8675ed
commit 75c347437a
228 changed files with 1430 additions and 1503 deletions

View File

@ -45,7 +45,7 @@ public abstract class ModelAction extends Action {
static String getShapesName(Collection<CanvasObject> coll) {
if (coll.size() != 1) {
return _("shapeMultiple");
return getFromLocale("shapeMultiple");
} else {
CanvasObject shape = coll.iterator().next();
return shape.getDisplayName();

View File

@ -45,7 +45,7 @@ public class ModelAddAction extends ModelAction {
@Override
public String getName() {
return _("actionAdd", getShapesName(added));
return getFromLocale("actionAdd", getShapesName(added));
}
@Override

View File

@ -57,9 +57,9 @@ public class ModelChangeAttributeAction extends ModelAction {
attr = a;
}
if (a == null) {
return _("actionChangeAttributes");
return getFromLocale("actionChangeAttributes");
} else {
return _("actionChangeAttribute", a.getDisplayName());
return getFromLocale("actionChangeAttribute", a.getDisplayName());
}
}

View File

@ -27,7 +27,7 @@ public class ModelDeleteHandleAction extends ModelAction {
@Override
public String getName() {
return _("actionDeleteHandle");
return getFromLocale("actionDeleteHandle");
}
@Override

View File

@ -30,7 +30,7 @@ public class ModelEditTextAction extends ModelAction {
@Override
public String getName() {
return _("actionEditText");
return getFromLocale("actionEditText");
}
@Override

View File

@ -26,7 +26,7 @@ public class ModelInsertHandleAction extends ModelAction {
@Override
public String getName() {
return _("actionInsertHandle");
return getFromLocale("actionInsertHandle");
}
@Override

View File

@ -32,7 +32,7 @@ public class ModelMoveHandleAction extends ModelAction {
@Override
public String getName() {
return _("actionMoveHandle");
return getFromLocale("actionMoveHandle");
}
@Override

View File

@ -31,7 +31,7 @@ public class ModelRemoveAction extends ModelAction {
@Override
public String getName() {
return _("actionRemove", getShapesName(removed.keySet()));
return getFromLocale("actionRemove", getShapesName(removed.keySet()));
}
@Override

View File

@ -182,11 +182,11 @@ public class ModelReorderAction extends ModelAction {
@Override
public String getName() {
if (type < 0) {
return _("actionRaise", getShapesName(objects));
return getFromLocale("actionRaise", getShapesName(objects));
} else if (type > 0) {
return _("actionLower", getShapesName(objects));
return getFromLocale("actionLower", getShapesName(objects));
} else {
return _("actionReorder", getShapesName(objects));
return getFromLocale("actionReorder", getShapesName(objects));
}
}

View File

@ -34,7 +34,7 @@ public class ModelTranslateAction extends ModelAction {
@Override
public String getName() {
return _("actionTranslate", getShapesName(moved));
return getFromLocale("actionTranslate", getShapesName(moved));
}
@Override

View File

@ -53,11 +53,11 @@ class AttrTableSelectionModel extends AttributeSetTableModel
if (firstObject == null) {
return null;
} else if (commonClass == null) {
return _("selectionVarious", "" + totalCount);
return getFromLocale("selectionVarious", "" + totalCount);
} else if (commonCount == 1) {
return _("selectionOne", firstObject.getDisplayName());
return getFromLocale("selectionOne", firstObject.getDisplayName());
} else {
return _("selectionMultiple", firstObject.getDisplayName(),
return getFromLocale("selectionMultiple", firstObject.getDisplayName(),
"" + commonCount);
}
}

View File

@ -70,7 +70,7 @@ public class Curve extends FillableCanvasObject {
@Override
public String getDisplayName() {
return _("shapeCurve");
return getFromLocale("shapeCurve");
}
@Override

View File

@ -21,37 +21,37 @@ public class DrawAttr {
= new Font("SansSerif", Font.PLAIN, 12);
public static final AttributeOption ALIGN_LEFT
= new AttributeOption(Integer.valueOf(EditableLabel.LEFT), __("alignStart"));
= new AttributeOption(Integer.valueOf(EditableLabel.LEFT), getFromLocale("alignStart"));
public static final AttributeOption ALIGN_CENTER
= new AttributeOption(Integer.valueOf(EditableLabel.CENTER), __("alignMiddle"));
= new AttributeOption(Integer.valueOf(EditableLabel.CENTER), getFromLocale("alignMiddle"));
public static final AttributeOption ALIGN_RIGHT
= new AttributeOption(Integer.valueOf(EditableLabel.RIGHT), __("alignEnd"));
= new AttributeOption(Integer.valueOf(EditableLabel.RIGHT), getFromLocale("alignEnd"));
public static final AttributeOption PAINT_STROKE
= new AttributeOption("stroke", __("paintStroke"));
= new AttributeOption("stroke", getFromLocale("paintStroke"));
public static final AttributeOption PAINT_FILL
= new AttributeOption("fill", __("paintFill"));
= new AttributeOption("fill", getFromLocale("paintFill"));
public static final AttributeOption PAINT_STROKE_FILL
= new AttributeOption("both", __("paintBoth"));
= new AttributeOption("both", getFromLocale("paintBoth"));
public static final Attribute<Font> FONT
= Attributes.forFont("font", __("attrFont"));
= Attributes.forFont("font", getFromLocale("attrFont"));
public static final Attribute<AttributeOption> ALIGNMENT
= Attributes.forOption("align", __("attrAlign"),
= Attributes.forOption("align", getFromLocale("attrAlign"),
new AttributeOption[] { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT });
public static final Attribute<AttributeOption> PAINT_TYPE
= Attributes.forOption("paintType", __("attrPaint"),
= Attributes.forOption("paintType", getFromLocale("attrPaint"),
new AttributeOption[] { PAINT_STROKE, PAINT_FILL, PAINT_STROKE_FILL });
public static final Attribute<Integer> STROKE_WIDTH
= Attributes.forIntegerRange("stroke-width", __("attrStrokeWidth"), 1, 8);
= Attributes.forIntegerRange("stroke-width", getFromLocale("attrStrokeWidth"), 1, 8);
public static final Attribute<Color> STROKE_COLOR
= Attributes.forColor("stroke", __("attrStroke"));
= Attributes.forColor("stroke", getFromLocale("attrStroke"));
public static final Attribute<Color> FILL_COLOR
= Attributes.forColor("fill", __("attrFill"));
= Attributes.forColor("fill", getFromLocale("attrFill"));
public static final Attribute<Color> TEXT_DEFAULT_FILL
= Attributes.forColor("fill", __("attrFill"));
= Attributes.forColor("fill", getFromLocale("attrFill"));
public static final Attribute<Integer> CORNER_RADIUS
= Attributes.forIntegerRange("rx", __("attrRx"), 1, 1000);
= Attributes.forIntegerRange("rx", getFromLocale("attrRx"), 1, 1000);
// for text
public static final List<Attribute<?>> ATTRS_TEXT

View File

@ -74,7 +74,7 @@ public class Line extends AbstractCanvasObject {
@Override
public String getDisplayName() {
return _("shapeLine");
return getFromLocale("shapeLine");
}
@Override

View File

@ -34,7 +34,7 @@ public class Oval extends Rectangular {
@Override
public String getDisplayName() {
return _("shapeOval");
return getFromLocale("shapeOval");
}
@Override

View File

@ -88,9 +88,9 @@ public class Poly extends FillableCanvasObject {
@Override
public String getDisplayName() {
if (closed) {
return _("shapePolygon");
return getFromLocale("shapePolygon");
} else {
return _("shapePolyline");
return getFromLocale("shapePolyline");
}
}

View File

@ -39,7 +39,7 @@ public class Rectangle extends Rectangular {
@Override
public String getDisplayName() {
return _("shapeRect");
return getFromLocale("shapeRect");
}
@Override

View File

@ -38,7 +38,7 @@ public class RoundRectangle extends Rectangular {
@Override
public String getDisplayName() {
return _("shapeRoundRect");
return getFromLocale("shapeRoundRect");
}
@Override

View File

@ -77,7 +77,7 @@ public class Text extends AbstractCanvasObject {
@Override
public String getDisplayName() {
return _("shapeText");
return getFromLocale("shapeText");
}
@Override

View File

@ -26,7 +26,7 @@ import com.cburch.logisim.gui.generic.LFrame;
import com.cburch.logisim.gui.menu.LogisimMenuBar;
import com.cburch.logisim.util.LocaleListener;
import com.cburch.logisim.util.LocaleManager;
import static com.cburch.logisim.util.LocaleString._;
import static com.cburch.logisim.util.LocaleString.getFromLocale;
@SuppressWarnings("serial")
public class Analyzer extends LFrame {
@ -40,18 +40,18 @@ public class Analyzer extends LFrame {
private class MyListener implements LocaleListener {
@Override
public void localeChanged() {
Analyzer.this.setTitle(_("analyzerWindowTitle"));
tabbedPane.setTitleAt(INPUTS_TAB, _("inputsTab"));
tabbedPane.setTitleAt(OUTPUTS_TAB, _("outputsTab"));
tabbedPane.setTitleAt(TABLE_TAB, _("tableTab"));
tabbedPane.setTitleAt(EXPRESSION_TAB, _("expressionTab"));
tabbedPane.setTitleAt(MINIMIZED_TAB, _("minimizedTab"));
tabbedPane.setToolTipTextAt(INPUTS_TAB, _("inputsTabTip"));
tabbedPane.setToolTipTextAt(OUTPUTS_TAB, _("outputsTabTip"));
tabbedPane.setToolTipTextAt(TABLE_TAB, _("tableTabTip"));
tabbedPane.setToolTipTextAt(EXPRESSION_TAB, _("expressionTabTip"));
tabbedPane.setToolTipTextAt(MINIMIZED_TAB, _("minimizedTabTip"));
buildCircuit.setText(_("buildCircuitButton"));
Analyzer.this.setTitle(getFromLocale("analyzerWindowTitle"));
tabbedPane.setTitleAt(INPUTS_TAB, getFromLocale("inputsTab"));
tabbedPane.setTitleAt(OUTPUTS_TAB, getFromLocale("outputsTab"));
tabbedPane.setTitleAt(TABLE_TAB, getFromLocale("tableTab"));
tabbedPane.setTitleAt(EXPRESSION_TAB, getFromLocale("expressionTab"));
tabbedPane.setTitleAt(MINIMIZED_TAB, getFromLocale("minimizedTab"));
tabbedPane.setToolTipTextAt(INPUTS_TAB, getFromLocale("inputsTabTip"));
tabbedPane.setToolTipTextAt(OUTPUTS_TAB, getFromLocale("outputsTabTip"));
tabbedPane.setToolTipTextAt(TABLE_TAB, getFromLocale("tableTabTip"));
tabbedPane.setToolTipTextAt(EXPRESSION_TAB, getFromLocale("expressionTabTip"));
tabbedPane.setToolTipTextAt(MINIMIZED_TAB, getFromLocale("minimizedTabTip"));
buildCircuit.setText(getFromLocale("buildCircuitButton"));
inputsPanel.localeChanged();
outputsPanel.localeChanged();
truthTablePanel.localeChanged();

View File

@ -8,7 +8,7 @@ import javax.swing.JFrame;
import com.cburch.logisim.util.LocaleListener;
import com.cburch.logisim.util.LocaleManager;
import com.cburch.logisim.util.WindowMenuItemManager;
import static com.cburch.logisim.util.LocaleString._;
import static com.cburch.logisim.util.LocaleString.getFromLocale;
public class AnalyzerManager extends WindowMenuItemManager
implements LocaleListener {
@ -32,7 +32,7 @@ public class AnalyzerManager extends WindowMenuItemManager
private static AnalyzerManager analysisManager = null;
private AnalyzerManager() {
super(_("analyzerWindowTitle"), true);
super(getFromLocale("analyzerWindowTitle"), true);
LocaleManager.addLocaleListener(this);
}
@ -47,6 +47,6 @@ public class AnalyzerManager extends WindowMenuItemManager
@Override
public void localeChanged() {
setText(_("analyzerWindowTitle"));
setText(getFromLocale("analyzerWindowTitle"));
}
}

View File

@ -111,10 +111,10 @@ class BuildCircuitButton extends JButton {
gc.gridy++;
gb.setConstraints(nands, gc); add(nands);
projectLabel.setText(_("buildProjectLabel"));
nameLabel.setText(_("buildNameLabel"));
twoInputs.setText(_("buildTwoInputsLabel"));
nands.setText(_("buildNandsLabel"));
projectLabel.setText(getFromLocale("buildProjectLabel"));
nameLabel.setText(getFromLocale("buildNameLabel"));
twoInputs.setText(getFromLocale("buildTwoInputsLabel"));
nands.setText(getFromLocale("buildNandsLabel"));
}
}
@ -131,7 +131,7 @@ class BuildCircuitButton extends JButton {
while (!ok) {
DialogPanel dlog = new DialogPanel();
int action = JOptionPane.showConfirmDialog(parent,
dlog, _("buildDialogTitle"), JOptionPane.OK_CANCEL_OPTION,
dlog, getFromLocale("buildDialogTitle"), JOptionPane.OK_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (action != JOptionPane.OK_OPTION) {
return;
@ -140,23 +140,23 @@ class BuildCircuitButton extends JButton {
ProjectItem projectItem = (ProjectItem) dlog.project.getSelectedItem();
if (projectItem == null) {
JOptionPane.showMessageDialog(parent, _("buildNeedProjectError"),
_("buildDialogErrorTitle"), JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(parent, getFromLocale("buildNeedProjectError"),
getFromLocale("buildDialogErrorTitle"), JOptionPane.ERROR_MESSAGE);
continue;
}
dest = projectItem.project;
name = dlog.name.getText().trim();
if (name.equals("")) {
JOptionPane.showMessageDialog(parent, _("buildNeedCircuitError"),
_("buildDialogErrorTitle"), JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(parent, getFromLocale("buildNeedCircuitError"),
getFromLocale("buildDialogErrorTitle"), JOptionPane.ERROR_MESSAGE);
continue;
}
if (dest.getLogisimFile().getCircuit(name) != null) {
int choice = JOptionPane.showConfirmDialog(parent,
_("buildConfirmReplaceMessage", name),
_("buildConfirmReplaceTitle"), JOptionPane.YES_NO_OPTION);
getFromLocale("buildConfirmReplaceMessage", name),
getFromLocale("buildConfirmReplaceTitle"), JOptionPane.YES_NO_OPTION);
if (choice != JOptionPane.YES_OPTION) {
continue;
}
@ -183,7 +183,7 @@ class BuildCircuitButton extends JButton {
}
void localeChanged() {
setText(_("buildCircuitButton"));
setText(getFromLocale("buildCircuitButton"));
}
private void performAction(Project dest, String name, boolean replace,
@ -199,7 +199,7 @@ class BuildCircuitButton extends JButton {
CircuitMutation xn = CircuitBuilder.build(circuit, model, twoInputs,
useNands);
dest.doAction(xn.toAction(__("replaceCircuitAction")));
dest.doAction(xn.toAction(getFromLocale("replaceCircuitAction")));
} else {
// add the circuit
Circuit circuit = new Circuit(name);

View File

@ -29,8 +29,7 @@ import com.cburch.logisim.analyze.model.OutputExpressionsListener;
import com.cburch.logisim.analyze.model.Expression;
import com.cburch.logisim.analyze.model.Parser;
import com.cburch.logisim.analyze.model.ParserException;
import com.cburch.logisim.util.StringGetter;
import static com.cburch.logisim.util.LocaleString._;
import static com.cburch.logisim.util.LocaleString.getFromLocale;
@SuppressWarnings("serial")
class ExpressionTab extends AnalyzerTab implements TabInterface {
@ -132,7 +131,7 @@ class ExpressionTab extends AnalyzerTab implements TabInterface {
private MyListener myListener = new MyListener();
private AnalyzerModel model;
private int curExprStringLength = 0;
private StringGetter errorMessage;
private String errorMessage;
public ExpressionTab(AnalyzerModel model) {
this.model = model;
@ -186,9 +185,9 @@ class ExpressionTab extends AnalyzerTab implements TabInterface {
void localeChanged() {
selector.localeChanged();
prettyView.localeChanged();
clear.setText(_("exprClearButton"));
revert.setText(_("exprRevertButton"));
enter.setText(_("exprEnterButton"));
clear.setText(getFromLocale("exprClearButton"));
revert.setText(getFromLocale("exprRevertButton"));
enter.setText(getFromLocale("exprEnterButton"));
if (errorMessage != null) {
error.setText(errorMessage.toString());
}
@ -209,7 +208,7 @@ class ExpressionTab extends AnalyzerTab implements TabInterface {
return selector.getSelectedOutput();
}
private void setError(StringGetter msg) {
private void setError(String msg) {
if (msg == null) {
errorMessage = null;
error.setText(" ");

View File

@ -14,7 +14,7 @@ import javax.swing.JPanel;
import com.cburch.logisim.analyze.model.Expression;
import com.cburch.logisim.analyze.model.ExpressionVisitor;
import static com.cburch.logisim.util.LocaleString._;
import static com.cburch.logisim.util.LocaleString.getFromLocale;
@SuppressWarnings("serial")
class ExpressionView extends JPanel {
@ -242,7 +242,7 @@ class ExpressionView extends JPanel {
lineY = new int[] { MINIMUM_HEIGHT };
} else {
if (exprData.text.length() == 0) {
lineText = new String[] { _("expressionEmpty") };
lineText = new String[] { getFromLocale("expressionEmpty") };
lineNots = new ArrayList<ArrayList<NotData>>();
lineNots.add(new ArrayList<NotData>());
} else {

View File

@ -24,7 +24,7 @@ import com.cburch.logisim.analyze.model.TruthTableEvent;
import com.cburch.logisim.analyze.model.TruthTableListener;
import com.cburch.logisim.analyze.model.VariableList;
import com.cburch.logisim.util.GraphicsUtil;
import static com.cburch.logisim.util.LocaleString._;
import static com.cburch.logisim.util.LocaleString.getFromLocale;
@SuppressWarnings("serial")
class KarnaughMapPanel extends JPanel implements TruthTablePanel {
@ -165,9 +165,9 @@ class KarnaughMapPanel extends JPanel implements TruthTablePanel {
String message = null;
if (output == null) {
message = _("karnaughNoOutputError");
message = getFromLocale("karnaughNoOutputError");
} else if (table.getInputColumnCount() > MAX_VARS) {
message = _("karnaughTooManyInputsError");
message = getFromLocale("karnaughTooManyInputsError");
}
if (message != null) {
if (g == null) {
@ -214,9 +214,9 @@ class KarnaughMapPanel extends JPanel implements TruthTablePanel {
Dimension sz = getSize();
String message = null;
if (output == null) {
message = _("karnaughNoOutputError");
message = getFromLocale("karnaughNoOutputError");
} else if (inputCount > MAX_VARS) {
message = _("karnaughTooManyInputsError");
message = getFromLocale("karnaughTooManyInputsError");
}
if (message != null) {
g.setFont(BODY_FONT);

View File

@ -23,7 +23,7 @@ import com.cburch.logisim.analyze.model.AnalyzerModel;
import com.cburch.logisim.analyze.model.OutputExpressions;
import com.cburch.logisim.analyze.model.OutputExpressionsEvent;
import com.cburch.logisim.analyze.model.OutputExpressionsListener;
import static com.cburch.logisim.util.LocaleString._;
import static com.cburch.logisim.util.LocaleString.getFromLocale;
@SuppressWarnings("serial")
class MinimizedTab extends AnalyzerTab {
@ -45,8 +45,8 @@ class MinimizedTab extends AnalyzerTab {
}
void localeChanged() {
choices[0] = _("minimizedSumOfProducts");
choices[1] = _("minimizedProductOfSums");
choices[0] = getFromLocale("minimizedSumOfProducts");
choices[1] = getFromLocale("minimizedProductOfSums");
fireContentsChanged(this, 0, choices.length);
}
@ -195,8 +195,8 @@ class MinimizedTab extends AnalyzerTab {
selector.localeChanged();
karnaughMap.localeChanged();
minimizedExpr.localeChanged();
setAsExpr.setText(_("minimizedSetButton"));
formatLabel.setText(_("minimizedFormat"));
setAsExpr.setText(getFromLocale("minimizedSetButton"));
formatLabel.setText(getFromLocale("minimizedFormat"));
((FormatModel) formatChoice.getModel()).localeChanged();
}

View File

@ -15,7 +15,7 @@ import com.cburch.logisim.analyze.model.AnalyzerModel;
import com.cburch.logisim.analyze.model.VariableList;
import com.cburch.logisim.analyze.model.VariableListEvent;
import com.cburch.logisim.analyze.model.VariableListListener;
import static com.cburch.logisim.util.LocaleString._;
import static com.cburch.logisim.util.LocaleString.getFromLocale;
@SuppressWarnings("serial")
class OutputSelector {
@ -132,7 +132,7 @@ class OutputSelector {
}
void localeChanged() {
label.setText(_("outputSelectLabel"));
label.setText(getFromLocale("outputSelectLabel"));
}
public void addItemListener(ItemListener l) {

View File

@ -19,7 +19,7 @@ import com.cburch.logisim.analyze.model.TruthTable;
import com.cburch.logisim.analyze.model.TruthTableEvent;
import com.cburch.logisim.analyze.model.TruthTableListener;
import com.cburch.logisim.util.GraphicsUtil;
import static com.cburch.logisim.util.LocaleString._;
import static com.cburch.logisim.util.LocaleString.getFromLocale;
@SuppressWarnings("serial")
class TableTab extends JPanel implements TruthTablePanel, TabInterface {
@ -140,7 +140,7 @@ class TableTab extends JPanel implements TruthTablePanel, TabInterface {
int outputs = table.getOutputColumnCount();
if (inputs == 0 && outputs == 0) {
g.setFont(BODY_FONT);
GraphicsUtil.drawCenteredText(g, _("tableEmptyMessage"), sz.width / 2, sz.height / 2);
GraphicsUtil.drawCenteredText(g, getFromLocale("tableEmptyMessage"), sz.width / 2, sz.height / 2);
return;
}
@ -158,14 +158,14 @@ class TableTab extends JPanel implements TruthTablePanel, TabInterface {
int x = left;
int y = top + headerMetric.getAscent() + 1;
if (inputs == 0) {
x = paintHeader(_("tableNullHeader"), x, y, g, headerMetric);
x = paintHeader(getFromLocale("tableNullHeader"), x, y, g, headerMetric);
} else {
for (int i = 0; i < inputs; i++) {
x = paintHeader(table.getInputHeader(i), x, y, g, headerMetric);
}
}
if (outputs == 0) {
x = paintHeader(_("tableNullHeader"), x, y, g, headerMetric);
x = paintHeader(getFromLocale("tableNullHeader"), x, y, g, headerMetric);
} else {
for (int i = 0; i < outputs; i++) {
x = paintHeader(table.getOutputHeader(i), x, y, g, headerMetric);
@ -257,7 +257,7 @@ class TableTab extends JPanel implements TruthTablePanel, TabInterface {
cellHeight = fm.getHeight();
cellWidth = 24;
if (inputs == 0 || outputs == 0) {
cellWidth = Math.max(cellWidth, fm.stringWidth(_("tableNullHeader")));
cellWidth = Math.max(cellWidth, fm.stringWidth(getFromLocale("tableNullHeader")));
}
for (int i = 0; i < inputs + outputs; i++) {
String header = i < inputs ? table.getInputHeader(i)

View File

@ -16,7 +16,7 @@ import javax.swing.JOptionPane;
import com.cburch.logisim.analyze.model.Entry;
import com.cburch.logisim.analyze.model.TruthTable;
import static com.cburch.logisim.util.LocaleString._;
import static com.cburch.logisim.util.LocaleString.getFromLocale;
@SuppressWarnings("serial")
class TableTabClip implements ClipboardOwner {
@ -119,8 +119,8 @@ class TableTabClip implements ClipboardOwner {
// I don't know - the above was observed to throw an odd ArrayIndexOutOfBounds
// exception on a Linux computer using Sun's Java 5 JVM
JOptionPane.showMessageDialog(table.getRootPane(),
_("clipPasteSupportedError"),
_("clipPasteErrorTitle"),
getFromLocale("clipPasteSupportedError"),
getFromLocale("clipPasteErrorTitle"),
JOptionPane.ERROR_MESSAGE);
return;
}
@ -181,8 +181,8 @@ class TableTabClip implements ClipboardOwner {
}
} else {
JOptionPane.showMessageDialog(table.getRootPane(),
_("clipPasteSupportedError"),
_("clipPasteErrorTitle"),
getFromLocale("clipPasteSupportedError"),
getFromLocale("clipPasteErrorTitle"),
JOptionPane.ERROR_MESSAGE);
return;
}
@ -201,8 +201,8 @@ class TableTabClip implements ClipboardOwner {
if (r0 + entries.length > rows
|| c0 + entries[0].length > inputs + outputs) {
JOptionPane.showMessageDialog(table.getRootPane(),
_("clipPasteEndError"),
_("clipPasteErrorTitle"),
getFromLocale("clipPasteEndError"),
getFromLocale("clipPasteErrorTitle"),
JOptionPane.ERROR_MESSAGE);
return;
}
@ -213,8 +213,8 @@ class TableTabClip implements ClipboardOwner {
if (r1 - r0 + 1 != entries.length
|| c1 - c0 + 1 != entries[0].length) {
JOptionPane.showMessageDialog(table.getRootPane(),
_("clipPasteSizeError"),
_("clipPasteErrorTitle"),
getFromLocale("clipPasteSizeError"),
getFromLocale("clipPasteErrorTitle"),
JOptionPane.ERROR_MESSAGE);
return;
}

View File

@ -28,7 +28,7 @@ import javax.swing.event.ListSelectionListener;
import com.cburch.logisim.analyze.model.VariableList;
import com.cburch.logisim.analyze.model.VariableListEvent;
import com.cburch.logisim.analyze.model.VariableListListener;
import static com.cburch.logisim.util.LocaleString._;
import static com.cburch.logisim.util.LocaleString.getFromLocale;
@SuppressWarnings("serial")
class VariableTab extends AnalyzerTab implements TabInterface {
@ -229,11 +229,11 @@ class VariableTab extends AnalyzerTab implements TabInterface {
@Override
void localeChanged() {
remove.setText(_("variableRemoveButton"));
moveUp.setText(_("variableMoveUpButton"));
moveDown.setText(_("variableMoveDownButton"));
add.setText(_("variableAddButton"));
rename.setText(_("variableRenameButton"));
remove.setText(getFromLocale("variableRemoveButton"));
moveUp.setText(getFromLocale("variableMoveUpButton"));
moveDown.setText(getFromLocale("variableMoveDownButton"));
add.setText(getFromLocale("variableAddButton"));
rename.setText(getFromLocale("variableRenameButton"));
validateInput();
}
@ -268,13 +268,13 @@ class VariableTab extends AnalyzerTab implements TabInterface {
errorShown = false;
ok = false;
} else if (!Character.isJavaIdentifierStart(text.charAt(0))) {
error.setText(_("variableStartError"));
error.setText(getFromLocale("variableStartError"));
ok = false;
} else {
for (int i = 1; i < text.length() && ok; i++) {
char c = text.charAt(i);
if (!Character.isJavaIdentifierPart(c)) {
error.setText(_("variablePartError", "" + c));
error.setText(getFromLocale("variablePartError", "" + c));
ok = false;
}
}
@ -283,14 +283,14 @@ class VariableTab extends AnalyzerTab implements TabInterface {
for (int i = 0, n = data.size(); i < n && ok; i++) {
String other = data.get(i);
if (text.equals(other)) {
error.setText(_("variableDuplicateError"));
error.setText(getFromLocale("variableDuplicateError"));
ok = false;
}
}
}
if (ok || !errorShown) {
if (data.size() >= data.getMaximumSize()) {
error.setText(_("variableMaximumError", "" + data.getMaximumSize()));
error.setText(getFromLocale("variableMaximumError", "" + data.getMaximumSize()));
} else {
error.setText(" ");
}

View File

@ -3,15 +3,14 @@
package com.cburch.logisim.analyze.model;
import com.cburch.logisim.util.StringGetter;
import static com.cburch.logisim.util.LocaleString.*;
public class Entry {
public static final Entry ZERO = new Entry("0");
public static final Entry ONE = new Entry("1");
public static final Entry DONT_CARE = new Entry("x");
public static final Entry BUS_ERROR = new Entry(__("busError"));
public static final Entry OSCILLATE_ERROR = new Entry(__("oscillateError"));
public static final Entry BUS_ERROR = new Entry(getFromLocale("busError"), true);
public static final Entry OSCILLATE_ERROR = new Entry(getFromLocale("oscillateError"), true);
public static Entry parse(String description) {
if (ZERO.description.equals(description)) {
@ -34,16 +33,16 @@ public class Entry {
}
private String description;
private StringGetter errorMessage;
private String errorMessage;
private Entry(String description) {
this.description = description;
this.errorMessage = null;
}
private Entry(StringGetter errorMessage) {
this.description = "!!";
this.errorMessage = errorMessage;
private Entry(String message, boolean... isError) {
if (isError.length > 0 && isError[0]) {
this.description = "!!";
this.errorMessage = message;
} else {
this.description = message;
this.errorMessage = null;
}
}
public String getDescription() {

View File

@ -5,7 +5,6 @@ package com.cburch.logisim.analyze.model;
import java.util.ArrayList;
import com.cburch.logisim.util.StringGetter;
import static com.cburch.logisim.util.LocaleString.*;
public class Parser {
@ -21,7 +20,7 @@ public class Parser {
for (Token token : tokens) {
if (token.type == TOKEN_ERROR) {
throw token.error(__("invalidCharacterError", token.text));
throw token.error(getFromLocale("invalidCharacterError", token.text));
} else if (token.type == TOKEN_IDENT) {
int index = model.getInputs().indexOf(token.text);
if (index < 0) {
@ -36,7 +35,7 @@ public class Parser {
} else if (opText.equals("OR")) {
token.type = TOKEN_OR;
} else {
throw token.error(__("badVariableName", token.text));
throw token.error(getFromLocale("badVariableName", token.text));
}
}
}
@ -126,7 +125,7 @@ public class Parser {
this.text = text;
}
ParserException error(StringGetter message) {
ParserException error(String message) {
return new ParserException(message, offset, length);
}
}
@ -228,16 +227,16 @@ public class Parser {
} else if (t.type == TOKEN_NOT) {
if (current != null) {
push(stack, current, Expression.AND_LEVEL,
new Token(TOKEN_AND, t.offset, _("implicitAndOperator")));
new Token(TOKEN_AND, t.offset, getFromLocale("implicitAndOperator")));
}
push(stack, null, Expression.NOT_LEVEL, t);
current = null;
} else if (t.type == TOKEN_NOT_POSTFIX) {
throw t.error(__("unexpectedApostrophe"));
throw t.error(getFromLocale("unexpectedApostrophe"));
} else if (t.type == TOKEN_LPAREN) {
if (current != null) {
push(stack, current, Expression.AND_LEVEL,
new Token(TOKEN_AND, t.offset, 0, _("implicitAndOperator")));
new Token(TOKEN_AND, t.offset, 0, getFromLocale("implicitAndOperator")));
}
push(stack, null, -2, t);
current = null;
@ -245,7 +244,7 @@ public class Parser {
current = popTo(stack, -1, current);
// there had better be a LPAREN atop the stack now.
if (stack.isEmpty()) {
throw t.error(__("lparenMissingError"));
throw t.error(getFromLocale("lparenMissingError"));
}
pop(stack);
while (i + 1 < tokens.size() && tokens.get(i + 1).type == TOKEN_NOT_POSTFIX) {
@ -255,7 +254,7 @@ public class Parser {
current = popTo(stack, Expression.AND_LEVEL, current);
} else {
if (current == null) {
throw t.error(__("missingLeftOperandError", t.text));
throw t.error(getFromLocale("missingLeftOperandError", t.text));
}
int level = 0;
switch (t.type) {
@ -270,7 +269,7 @@ public class Parser {
current = popTo(stack, -1, current);
if (!stack.isEmpty()) {
Context top = pop(stack);
throw top.cause.error(__("rparenMissingError"));
throw top.cause.error(getFromLocale("rparenMissingError"));
}
return current;
}
@ -295,7 +294,7 @@ public class Parser {
while (!stack.isEmpty() && peekLevel(stack) >= level) {
Context top = pop(stack);
if (current == null) {
throw top.cause.error(__("missingRightOperandError", top.cause.text));
throw top.cause.error(getFromLocale("missingRightOperandError", top.cause.text));
}
switch (top.level) {

View File

@ -3,15 +3,13 @@
package com.cburch.logisim.analyze.model;
import com.cburch.logisim.util.StringGetter;
@SuppressWarnings("serial")
public class ParserException extends Exception {
private StringGetter message;
private String message;
private int start;
private int length;
public ParserException(StringGetter message, int start, int length) {
public ParserException(String message, int start, int length) {
super(message.toString());
this.message = message;
this.start = start;
@ -23,7 +21,7 @@ public class ParserException extends Exception {
return message.toString();
}
public StringGetter getMessageGetter() {
public String getMessageGetter() {
return message;
}

View File

@ -100,12 +100,12 @@ public class Analyze {
String defaultList;
if (Pin.FACTORY.isInputPin(pin)) {
defaultList = _("defaultInputLabels");
defaultList = getFromLocale("defaultInputLabels");
if (defaultList.indexOf(",") < 0) {
defaultList = "a,b,c,d,e,f,g,h";
}
} else {
defaultList = _("defaultOutputLabels");
defaultList = getFromLocale("defaultOutputLabels");
if (defaultList.indexOf(",") < 0) {
defaultList = "x,y,z,u,v,w,s,t";
}

View File

@ -11,19 +11,19 @@ public class AnalyzeException extends Exception {
public static class Circular extends AnalyzeException {
public Circular() {
super(_("analyzeCircularError"));
super(getFromLocale("analyzeCircularError"));
}
}
public static class Conflict extends AnalyzeException {
public Conflict() {
super(_("analyzeConflictError"));
super(getFromLocale("analyzeConflictError"));
}
}
public static class CannotHandle extends AnalyzeException {
public CannotHandle(String reason) {
super(_("analyzeCannotHandleError", reason));
super(getFromLocale("analyzeCannotHandleError", reason));
}
}

View File

@ -5,14 +5,13 @@ package com.cburch.logisim.circuit;
import com.cburch.logisim.proj.Action;
import com.cburch.logisim.proj.Project;
import com.cburch.logisim.util.StringGetter;
public class CircuitAction extends Action {
private StringGetter name;
private String name;
private CircuitTransaction forward;
private CircuitTransaction reverse;
CircuitAction(StringGetter name, CircuitMutation forward) {
CircuitAction(String name, CircuitMutation forward) {
this.name = name;
this.forward = forward;
}

View File

@ -23,19 +23,19 @@ import static com.cburch.logisim.util.LocaleString.*;
public class CircuitAttributes extends AbstractAttributeSet {
public static final Attribute<String> NAME_ATTR
= Attributes.forString("circuit", __("circuitName"));
= Attributes.forString("circuit", getFromLocale("circuitName"));
public static final Attribute<Direction> LABEL_LOCATION_ATTR
= Attributes.forDirection("labelloc", __("circuitLabelLocAttr"));
= Attributes.forDirection("labelloc", getFromLocale("circuitLabelLocAttr"));
public static final Attribute<String> CIRCUIT_LABEL_ATTR
= Attributes.forString("clabel", __("circuitLabelAttr"));
= Attributes.forString("clabel", getFromLocale("circuitLabelAttr"));
public static final Attribute<Direction> CIRCUIT_LABEL_FACING_ATTR
= Attributes.forDirection("clabelup", __("circuitLabelDirAttr"));
= Attributes.forDirection("clabelup", getFromLocale("circuitLabelDirAttr"));
public static final Attribute<Font> CIRCUIT_LABEL_FONT_ATTR
= Attributes.forFont("clabelfont", __("circuitLabelFontAttr"));
= Attributes.forFont("clabelfont", getFromLocale("circuitLabelFontAttr"));
private static final Attribute<?>[] STATIC_ATTRS = {
NAME_ATTR, CIRCUIT_LABEL_ATTR, CIRCUIT_LABEL_FACING_ATTR, CIRCUIT_LABEL_FONT_ATTR,

View File

@ -13,7 +13,6 @@ import java.util.Map;
import com.cburch.logisim.comp.Component;
import com.cburch.logisim.data.Attribute;
import com.cburch.logisim.proj.Action;
import com.cburch.logisim.util.StringGetter;
import static com.cburch.logisim.util.LocaleString.*;
public final class CircuitMutation extends CircuitTransaction {
@ -77,9 +76,9 @@ public final class CircuitMutation extends CircuitTransaction {
changes.add(change);
}
public Action toAction(StringGetter name) {
public Action toAction(String name) {
if (name == null) {
name = __("unknownChangeAction");
name = getFromLocale("unknownChangeAction");
}
return new CircuitAction(name, this);

View File

@ -8,7 +8,6 @@ import com.cburch.logisim.data.AttributeOption;
import com.cburch.logisim.data.Attributes;
import com.cburch.logisim.data.BitWidth;
import com.cburch.logisim.data.Value;
import com.cburch.logisim.util.StringGetter;
import static com.cburch.logisim.util.LocaleString.*;
public abstract class RadixOption extends AttributeOption {
@ -22,7 +21,7 @@ public abstract class RadixOption extends AttributeOption {
RADIX_2, RADIX_8, RADIX_10_SIGNED, RADIX_10_UNSIGNED, RADIX_16
};
public static final Attribute<RadixOption> ATTRIBUTE
= Attributes.forOption("radix", __("radixAttr"), OPTIONS);
= Attributes.forOption("radix", getFromLocale("radixAttr"), OPTIONS);
public static RadixOption decode(String value) {
for (RadixOption opt : OPTIONS) {
@ -34,15 +33,15 @@ public abstract class RadixOption extends AttributeOption {
}
private String saveName;
private StringGetter displayGetter;
private String displayGetter;
private RadixOption(String saveName, StringGetter displayGetter) {
private RadixOption(String saveName, String displayGetter) {
super(saveName, displayGetter);
this.saveName = saveName;
this.displayGetter = displayGetter;
}
public StringGetter getDisplayGetter() {
public String getDisplayGetter() {
return displayGetter;
}
@ -68,7 +67,7 @@ public abstract class RadixOption extends AttributeOption {
private static class Radix2 extends RadixOption {
private Radix2() {
super("2", __("radix2"));
super("2", getFromLocale("radix2"));
}
@Override
@ -94,7 +93,7 @@ public abstract class RadixOption extends AttributeOption {
private static class Radix10Signed extends RadixOption {
private Radix10Signed() {
super("10signed", __("radix10Signed"));
super("10signed", getFromLocale("radix10Signed"));
}
@Override
@ -132,7 +131,7 @@ public abstract class RadixOption extends AttributeOption {
private static class Radix10Unsigned extends RadixOption {
private Radix10Unsigned() {
super("10unsigned", __("radix10Unsigned"));
super("10unsigned", getFromLocale("radix10Unsigned"));
}
@Override
@ -159,7 +158,7 @@ public abstract class RadixOption extends AttributeOption {
private static class Radix8 extends RadixOption {
private Radix8() {
super("8", __("radix8"));
super("8", getFromLocale("radix8"));
}
@Override
@ -180,7 +179,7 @@ public abstract class RadixOption extends AttributeOption {
private static class Radix16 extends RadixOption {
private Radix16() {
super("16", __("radix16"));
super("16", getFromLocale("radix16"));
}
@Override

View File

@ -213,7 +213,7 @@ public class Simulator {
public void tick() {
ticker.tickOnce();
}
}
public void step() {
synchronized(manager) {

View File

@ -166,7 +166,7 @@ public class Splitter extends ManagedComponent
}
if (end == 0) {
return _("splitterCombinedTip");
return getFromLocale("splitterCombinedTip");
} else if (end > 0){
int bits = 0;
StringBuilder buf = new StringBuilder();
@ -198,7 +198,7 @@ public class Splitter extends ManagedComponent
case 1: base = "splitterSplit1Tip"; break;
default: base = "splitterSplitManyTip"; break;
}
return _(base, buf.toString());
return getFromLocale(base, buf.toString());
} else {
return null;
}

View File

@ -18,23 +18,23 @@ import static com.cburch.logisim.util.LocaleString.*;
class SplitterAttributes extends AbstractAttributeSet {
public static final AttributeOption APPEAR_LEGACY
= new AttributeOption("legacy", __("splitterAppearanceLegacy"));
= new AttributeOption("legacy", getFromLocale("splitterAppearanceLegacy"));
public static final AttributeOption APPEAR_LEFT
= new AttributeOption("left", __("splitterAppearanceLeft"));
= new AttributeOption("left", getFromLocale("splitterAppearanceLeft"));
public static final AttributeOption APPEAR_RIGHT
= new AttributeOption("right", __("splitterAppearanceRight"));
= new AttributeOption("right", getFromLocale("splitterAppearanceRight"));
public static final AttributeOption APPEAR_CENTER
= new AttributeOption("center", __("splitterAppearanceCenter"));
= new AttributeOption("center", getFromLocale("splitterAppearanceCenter"));
public static final Attribute<AttributeOption> ATTR_APPEARANCE
= Attributes.forOption("appear", __("splitterAppearanceAttr"),
= Attributes.forOption("appear", getFromLocale("splitterAppearanceAttr"),
new AttributeOption[] { APPEAR_LEFT, APPEAR_RIGHT, APPEAR_CENTER,
APPEAR_LEGACY});
public static final Attribute<BitWidth> ATTR_WIDTH
= Attributes.forBitWidth("incoming", __("splitterBitWidthAttr"));
= Attributes.forBitWidth("incoming", getFromLocale("splitterBitWidthAttr"));
public static final Attribute<Integer> ATTR_FANOUT
= Attributes.forIntegerRange("fanout", __("splitterFanOutAttr"), 1, 32);
= Attributes.forIntegerRange("fanout", getFromLocale("splitterFanOutAttr"), 1, 32);
private static final List<Attribute<?>> INIT_ATTRIBUTES
= Arrays.asList(new Attribute<?>[] {
@ -57,7 +57,7 @@ class SplitterAttributes extends AbstractAttributeSet {
@Override
public String toString() {
if (value < 0) {
return _("splitterBitNone");
return getFromLocale("splitterBitNone");
} else {
String ret = "" + value;
Direction noteDir;
@ -81,7 +81,7 @@ class SplitterAttributes extends AbstractAttributeSet {
BitOutOption[] options;
private BitOutAttribute(int which, BitOutOption[] options) {
super("bit" + which, __("splitterBitAttr", "" + which));
super("bit" + which, getFromLocale("splitterBitAttr", "" + which));
this.which = which;
this.options = options;
}

View File

@ -9,7 +9,6 @@ import java.awt.event.ActionListener;
import javax.swing.JMenuItem;
import com.cburch.logisim.proj.Project;
import com.cburch.logisim.util.StringGetter;
import static com.cburch.logisim.util.LocaleString.*;
@SuppressWarnings("serial")
@ -38,11 +37,11 @@ class SplitterDistributeItem extends JMenuItem implements ActionListener {
setText(toGetter().toString());
}
private StringGetter toGetter() {
private String toGetter() {
if (order > 0) {
return __("splitterDistributeAscending");
return getFromLocale("splitterDistributeAscending");
} else {
return __("splitterDistributeDescending");
return getFromLocale("splitterDistributeDescending");
}
}

View File

@ -24,7 +24,6 @@ import com.cburch.logisim.tools.key.JoinedConfigurator;
import com.cburch.logisim.tools.key.KeyConfigurator;
import com.cburch.logisim.tools.key.ParallelConfigurator;
import com.cburch.logisim.util.Icons;
import com.cburch.logisim.util.StringGetter;
import static com.cburch.logisim.util.LocaleString.*;
public class SplitterFactory extends AbstractComponentFactory {
@ -38,8 +37,8 @@ public class SplitterFactory extends AbstractComponentFactory {
public String getName() { return "Splitter"; }
@Override
public StringGetter getDisplayGetter() {
return __("splitterComponent");
public String getDisplayGetter() {
return getFromLocale("splitterComponent");
}
@Override

View File

@ -35,12 +35,11 @@ import com.cburch.logisim.proj.Project;
import com.cburch.logisim.std.wiring.Pin;
import com.cburch.logisim.tools.MenuExtender;
import com.cburch.logisim.util.GraphicsUtil;
import com.cburch.logisim.util.StringGetter;
import com.cburch.logisim.util.StringUtil;
import static com.cburch.logisim.util.LocaleString.*;
public class SubcircuitFactory extends InstanceFactory {
private class CircuitFeature implements StringGetter, MenuExtender, ActionListener {
private class CircuitFeature implements MenuExtender, ActionListener {
private Instance instance;
private Project proj;
@ -57,7 +56,7 @@ public class SubcircuitFactory extends InstanceFactory {
public void configureMenu(JPopupMenu menu, Project proj) {
this.proj = proj;
String name = instance.getFactory().getDisplayName();
String text = _("subcircuitViewItem", name);
String text = getFromLocale("subcircuitViewItem", name);
JMenuItem item = new JMenuItem(text);
item.addActionListener(this);
menu.add(item);
@ -86,7 +85,7 @@ public class SubcircuitFactory extends InstanceFactory {
super("", null);
this.source = source;
setFacingAttribute(StdAttr.FACING);
setDefaultToolTip(new CircuitFeature(null));
setDefaultToolTip(null);
setInstancePoker(SubcircuitPoker.class);
}
@ -100,7 +99,7 @@ public class SubcircuitFactory extends InstanceFactory {
}
@Override
public StringGetter getDisplayGetter() {
public String getDisplayGetter() {
return StringUtil.constantGetter(source.getName());
}

View File

@ -33,14 +33,14 @@ public final class Wire implements Component, AttributeSet, CustomHandles,
public static final int WIDTH = 1;
public static final AttributeOption VALUE_HORZ
= new AttributeOption("horz", __("wireDirectionHorzOption"));
= new AttributeOption("horz", getFromLocale("wireDirectionHorzOption"));
public static final AttributeOption VALUE_VERT
= new AttributeOption("vert", __("wireDirectionVertOption"));
= new AttributeOption("vert", getFromLocale("wireDirectionVertOption"));
public static final Attribute<AttributeOption> dir_attr
= Attributes.forOption("direction", __("wireDirectionAttr"),
= Attributes.forOption("direction", getFromLocale("wireDirectionAttr"),
new AttributeOption[] { VALUE_HORZ, VALUE_VERT });
public static final Attribute<Integer> len_attr
= Attributes.forInteger("length", __("wireLengthAttr"));
= Attributes.forInteger("length", getFromLocale("wireLengthAttr"));
private static final List<Attribute<?>> ATTRIBUTES
= Arrays.asList(new Attribute<?>[] { dir_attr, len_attr });

View File

@ -13,7 +13,6 @@ import com.cburch.logisim.data.AttributeSet;
import com.cburch.logisim.data.Bounds;
import com.cburch.logisim.data.Location;
import com.cburch.logisim.util.GraphicsUtil;
import com.cburch.logisim.util.StringGetter;
import static com.cburch.logisim.util.LocaleString.*;
class WireFactory extends AbstractComponentFactory {
@ -25,8 +24,8 @@ class WireFactory extends AbstractComponentFactory {
public String getName() { return "Wire"; }
@Override
public StringGetter getDisplayGetter() {
return __("wireComponent");
public String getDisplayGetter() {
return getFromLocale("wireComponent");
}
@Override

View File

@ -9,9 +9,6 @@ import java.util.Arrays;
import java.util.List;
import org.apache.commons.collections15.list.UnmodifiableList;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import com.cburch.draw.model.CanvasObject;
import com.cburch.draw.model.Handle;
import com.cburch.draw.model.HandleGesture;
@ -24,7 +21,7 @@ import static com.cburch.logisim.util.LocaleString.*;
public class AppearanceAnchor extends AppearanceElement {
public static final Attribute<Direction> FACING
= Attributes.forDirection("facing", __("appearanceFacingAttr"));
= Attributes.forDirection("facing", getFromLocale("appearanceFacingAttr"));
static final List<Attribute<?>> ATTRIBUTES
= UnmodifiableList.decorate(Arrays.asList(new Attribute<?>[] { FACING }));
@ -56,7 +53,7 @@ public class AppearanceAnchor extends AppearanceElement {
@Override
public String getDisplayName() {
return _("circuitAnchor");
return getFromLocale("circuitAnchor");
}
/*@Override

View File

@ -9,9 +9,6 @@ import java.util.Arrays;
import java.util.List;
import org.apache.commons.collections15.list.UnmodifiableList;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import com.cburch.draw.model.CanvasObject;
import com.cburch.draw.model.Handle;
import com.cburch.draw.model.HandleGesture;
@ -51,7 +48,7 @@ public class AppearancePort extends AppearanceElement {
@Override
public String getDisplayName() {
return _("circuitPort");
return getFromLocale("circuitPort");
}
/*@Override

View File

@ -17,7 +17,6 @@ import com.cburch.logisim.data.Location;
import com.cburch.logisim.data.Value;
import com.cburch.logisim.util.GraphicsUtil;
import com.cburch.logisim.util.Icons;
import com.cburch.logisim.util.StringGetter;
import com.cburch.logisim.util.StringUtil;
public abstract class AbstractComponentFactory implements ComponentFactory {
@ -37,7 +36,7 @@ public abstract class AbstractComponentFactory implements ComponentFactory {
@Override
public String getDisplayName() { return getDisplayGetter().toString(); }
@Override
public StringGetter getDisplayGetter() { return StringUtil.constantGetter(getName()); }
public String getDisplayGetter() { return StringUtil.constantGetter(getName()); }
@Override
public abstract Component createComponent(Location loc, AttributeSet attrs);
@Override

View File

@ -11,7 +11,6 @@ import com.cburch.logisim.data.AttributeDefaultProvider;
import com.cburch.logisim.data.AttributeSet;
import com.cburch.logisim.data.Bounds;
import com.cburch.logisim.data.Location;
import com.cburch.logisim.util.StringGetter;
/**
* Represents a category of components that appear in a circuit. This class
@ -26,7 +25,7 @@ public interface ComponentFactory extends AttributeDefaultProvider {
public String getName();
public String getDisplayName();
public StringGetter getDisplayGetter();
public String getDisplayGetter();
public Component createComponent(Location loc, AttributeSet attrs);
public Bounds getOffsetBounds(AttributeSet attrs);
public AttributeSet createAttributeSet();

View File

@ -6,8 +6,6 @@ package com.cburch.logisim.comp;
import com.cburch.logisim.data.BitWidth;
import com.cburch.logisim.data.Location;
import org.apache.commons.lang3.builder.HashCodeBuilder;
public class EndData {
public static final int INPUT_ONLY = 1;
public static final int OUTPUT_ONLY = 2;

View File

@ -7,13 +7,11 @@ import java.awt.Window;
import javax.swing.JTextField;
import com.cburch.logisim.util.StringGetter;
public abstract class Attribute<V> {
private String name;
private StringGetter disp;
private String disp;
public Attribute(String name, StringGetter disp) {
public Attribute(String name, String disp) {
this.name = name;
this.disp = disp;
}

View File

@ -3,20 +3,18 @@
package com.cburch.logisim.data;
import com.cburch.logisim.util.StringGetter;
public class AttributeOption implements AttributeOptionInterface {
private Object value;
private String name;
private StringGetter desc;
private String desc;
public AttributeOption(Object value, StringGetter desc) {
public AttributeOption(Object value, String desc) {
this.value = value;
this.name = value.toString();
this.desc = desc;
}
public AttributeOption(Object value, String name, StringGetter desc) {
public AttributeOption(Object value, String name, String desc) {
this.value = value;
this.name = name;
this.desc = desc;

View File

@ -15,7 +15,6 @@ import javax.swing.plaf.basic.BasicComboBoxRenderer;
import com.bric.swing.ColorPicker;
import com.cburch.logisim.util.FontUtil;
import com.cburch.logisim.util.JInputComponent;
import com.cburch.logisim.util.StringGetter;
import com.connectina.swing.fontchooser.JFontChooser;
import static com.cburch.logisim.util.LocaleString.*;
@ -23,13 +22,7 @@ import static com.cburch.logisim.util.LocaleString.*;
public class Attributes {
private Attributes() { }
private static class ConstantGetter implements StringGetter {
private String str;
public ConstantGetter(String str) { this.str = str; }
@Override
public String toString() { return str; }
}
private static StringGetter getter(String s) { return new ConstantGetter(s); }
private static String getter(String s) { return s; }
//
// methods with display name == standard name
@ -91,62 +84,62 @@ public class Attributes {
//
// methods with internationalization support
//
public static Attribute<String> forString(String name, StringGetter disp) {
public static Attribute<String> forString(String name, String disp) {
return new StringAttribute(name, disp);
}
public static <V> Attribute<V> forOption(String name, StringGetter disp,
public static <V> Attribute<V> forOption(String name, String disp,
V[] vals) {
return new OptionAttribute<V>(name, disp, vals);
}
public static Attribute<Integer> forInteger(String name, StringGetter disp) {
public static Attribute<Integer> forInteger(String name, String disp) {
return new IntegerAttribute(name, disp);
}
public static Attribute<Integer> forHexInteger(String name, StringGetter disp) {
public static Attribute<Integer> forHexInteger(String name, String disp) {
return new HexIntegerAttribute(name, disp);
}
public static Attribute<Integer> forIntegerRange(String name, StringGetter disp,
public static Attribute<Integer> forIntegerRange(String name, String disp,
int start, int end) {
return new IntegerRangeAttribute(name, disp, start, end);
}
public static Attribute<Double> forDouble(String name, StringGetter disp) {
public static Attribute<Double> forDouble(String name, String disp) {
return new DoubleAttribute(name, disp);
}
public static Attribute<Boolean> forBoolean(String name, StringGetter disp) {
public static Attribute<Boolean> forBoolean(String name, String disp) {
return new BooleanAttribute(name, disp);
}
public static Attribute<Direction> forDirection(String name, StringGetter disp) {
public static Attribute<Direction> forDirection(String name, String disp) {
return new DirectionAttribute(name, disp);
}
public static Attribute<BitWidth> forBitWidth(String name, StringGetter disp) {
public static Attribute<BitWidth> forBitWidth(String name, String disp) {
return new BitWidth.Attribute(name, disp);
}
public static Attribute<BitWidth> forBitWidth(String name, StringGetter disp, int min, int max) {
public static Attribute<BitWidth> forBitWidth(String name, String disp, int min, int max) {
return new BitWidth.Attribute(name, disp, min, max);
}
public static Attribute<Font> forFont(String name, StringGetter disp) {
public static Attribute<Font> forFont(String name, String disp) {
return new FontAttribute(name, disp);
}
public static Attribute<Location> forLocation(String name, StringGetter disp) {
public static Attribute<Location> forLocation(String name, String disp) {
return new LocationAttribute(name, disp);
}
public static Attribute<Color> forColor(String name, StringGetter disp) {
public static Attribute<Color> forColor(String name, String disp) {
return new ColorAttribute(name, disp);
}
private static class StringAttribute extends Attribute<String> {
private StringAttribute(String name, StringGetter disp) {
private StringAttribute(String name, String disp) {
super(name, disp);
}
@ -182,7 +175,7 @@ public class Attributes {
private static class OptionAttribute<V> extends Attribute<V> {
private V[] vals;
private OptionAttribute(String name, StringGetter disp,
private OptionAttribute(String name, String disp,
V[] vals) {
super(name, disp);
this.vals = vals;
@ -224,7 +217,7 @@ public class Attributes {
}
private static class IntegerAttribute extends Attribute<Integer> {
private IntegerAttribute(String name, StringGetter disp) {
private IntegerAttribute(String name, String disp) {
super(name, disp);
}
@ -235,7 +228,7 @@ public class Attributes {
}
private static class HexIntegerAttribute extends Attribute<Integer> {
private HexIntegerAttribute(String name, StringGetter disp) {
private HexIntegerAttribute(String name, String disp) {
super(name, disp);
}
@ -270,7 +263,7 @@ public class Attributes {
}
private static class DoubleAttribute extends Attribute<Double> {
private DoubleAttribute(String name, StringGetter disp) {
private DoubleAttribute(String name, String disp) {
super(name, disp);
}
@ -283,18 +276,18 @@ public class Attributes {
private static class BooleanAttribute extends OptionAttribute<Boolean> {
private static Boolean[] vals = { Boolean.TRUE, Boolean.FALSE };
private BooleanAttribute(String name, StringGetter disp) {
private BooleanAttribute(String name, String disp) {
super(name, disp, vals);
}
@Override
public String toDisplayString(Boolean value) {
if (value.booleanValue()) {
return _("booleanTrueOption");
return getFromLocale("booleanTrueOption");
}
else {
return _("booleanFalseOption");
return getFromLocale("booleanFalseOption");
}
}
@ -310,7 +303,7 @@ public class Attributes {
Integer[] options = null;
int start;
int end;
private IntegerRangeAttribute(String name, StringGetter disp, int start, int end) {
private IntegerRangeAttribute(String name, String disp, int start, int end) {
super(name, disp);
this.start = start;
this.end = end;
@ -361,7 +354,7 @@ public class Attributes {
Direction.WEST,
};
public DirectionAttribute(String name, StringGetter disp) {
public DirectionAttribute(String name, String disp) {
super(name, disp, vals);
}
@ -377,7 +370,7 @@ public class Attributes {
}
private static class FontAttribute extends Attribute<Font> {
private FontAttribute(String name, StringGetter disp) {
private FontAttribute(String name, String disp) {
super(name, disp);
}
@ -428,7 +421,7 @@ public class Attributes {
}
private static class LocationAttribute extends Attribute<Location> {
public LocationAttribute(String name, StringGetter desc) {
public LocationAttribute(String name, String desc) {
super(name, desc);
}
@Override
@ -438,7 +431,7 @@ public class Attributes {
}
private static class ColorAttribute extends Attribute<Color> {
public ColorAttribute(String name, StringGetter desc) {
public ColorAttribute(String name, String desc) {
super(name, desc);
}

View File

@ -6,8 +6,6 @@ package com.cburch.logisim.data;
import javax.swing.JComboBox;
import com.cburch.logisim.util.StringGetter;
public class BitWidth implements Comparable<BitWidth> {
public static final BitWidth UNKNOWN = new BitWidth(0);
public static final BitWidth ONE = new BitWidth(1);
@ -17,13 +15,13 @@ public class BitWidth implements Comparable<BitWidth> {
static class Attribute extends com.cburch.logisim.data.Attribute<BitWidth> {
private BitWidth[] choices;
public Attribute(String name, StringGetter disp) {
public Attribute(String name, String disp) {
super(name, disp);
ensurePrefab();
choices = prefab;
}
public Attribute(String name, StringGetter disp, int min, int max) {
public Attribute(String name, String disp, int min, int max) {
super(name, disp);
choices = new BitWidth[max - min + 1];
for (int i = 0; i < choices.length; i++) {

View File

@ -3,22 +3,21 @@
package com.cburch.logisim.data;
import com.cburch.logisim.util.StringGetter;
import static com.cburch.logisim.util.LocaleString.*;
public class Direction implements AttributeOptionInterface {
public static final Direction EAST
= new Direction("east", __("directionEastOption"),
__("directionEastVertical"), 0);
= new Direction("east", getFromLocale("directionEastOption"),
getFromLocale("directionEastVertical"), 0);
public static final Direction WEST
= new Direction("west", __("directionWestOption"),
__("directionWestVertical"), 1);
= new Direction("west", getFromLocale("directionWestOption"),
getFromLocale("directionWestVertical"), 1);
public static final Direction NORTH
= new Direction("north", __("directionNorthOption"),
__("directionNorthVertical"), 2);
= new Direction("north", getFromLocale("directionNorthOption"),
getFromLocale("directionNorthVertical"), 2);
public static final Direction SOUTH
= new Direction("south", __("directionSouthOption"),
__("directionSouthVertical"), 3);
= new Direction("south", getFromLocale("directionSouthOption"),
getFromLocale("directionSouthVertical"), 3);
public static final Direction[] cardinals
= { NORTH, EAST, SOUTH, WEST };
@ -43,11 +42,11 @@ public class Direction implements AttributeOptionInterface {
}
private String name;
private StringGetter disp;
private StringGetter vert;
private String disp;
private String vert;
private int id;
private Direction(String name, StringGetter disp, StringGetter vert, int id) {
private Direction(String name, String disp, String vert, int id) {
this.name = name;
this.disp = disp;
this.vert = vert;
@ -64,7 +63,7 @@ public class Direction implements AttributeOptionInterface {
return disp.toString();
}
public StringGetter getDisplayGetter() {
public String getDisplayGetter() {
return disp;
}
@ -78,7 +77,10 @@ public class Direction implements AttributeOptionInterface {
}
public boolean equals( Direction other ) {
return this.id == other.id;
if (other != null) {
return this.id == other.id;
}
return false;
}
public double toRadians() {

View File

@ -384,11 +384,11 @@ public class Value {
}
if (isErrorValue()) {
return _("valueError");
return getFromLocale("valueError");
}
if (!isFullyDefined()) {
return _("valueUnknown");
return getFromLocale("valueUnknown");
}
@ -414,11 +414,11 @@ public class Value {
}
if (isErrorValue()) {
return _("valueError");
return getFromLocale("valueError");
}
if (!isFullyDefined()) {
return _("valueUnknown");
return getFromLocale("valueUnknown");
}
return Integer.toString(toIntValue(), radix);
@ -430,11 +430,11 @@ public class Value {
case 0: return "-";
case 1:
if (error != 0) {
return _("valueErrorSymbol");
return getFromLocale("valueErrorSymbol");
}
else if (unknown != 0) {
return _("valueUnknownSymbol");
return getFromLocale("valueUnknownSymbol");
}
else if (value != 0) {

View File

@ -135,7 +135,7 @@ class LibraryManager {
// Otherwise we'll have to decode it.
int sep = desc.indexOf(desc_sep);
if (sep < 0) {
loader.showError(_("fileDescriptorError", desc));
loader.showError(getFromLocale("fileDescriptorError", desc));
return null;
}
String type = desc.substring(0, sep);
@ -144,7 +144,7 @@ class LibraryManager {
if (type.equals("")) {
Library ret = loader.getBuiltin().getLibrary(name);
if (ret == null) {
loader.showError(_("fileBuiltinMissingError", name));
loader.showError(getFromLocale("fileBuiltinMissingError", name));
return null;
}
return ret;
@ -158,7 +158,7 @@ class LibraryManager {
File toRead = loader.getFileFor(fileName, Loader.JAR_FILTER);
return loadJarLibrary(loader, toRead, className);
} else {
loader.showError(_("fileTypeError",
loader.showError(getFromLocale("fileTypeError",
type, desc));
return null;
}
@ -207,7 +207,7 @@ class LibraryManager {
public void reload(Loader loader, LoadedLibrary lib) {
LibraryDescriptor descriptor = invMap.get(lib);
if (descriptor == null) {
loader.showError(_("unknownLibraryFileError",
loader.showError(getFromLocale("unknownLibraryFileError",
lib.getDisplayName()));
} else {
try {
@ -262,7 +262,7 @@ class LibraryManager {
if (desc != null) {
return desc.toDescriptor(loader);
} else {
throw new LoaderException(_("fileDescriptorUnknownError", lib.getDisplayName()));
throw new LoaderException(getFromLocale("fileDescriptorUnknownError", lib.getDisplayName()));
}
}
}

View File

@ -51,7 +51,7 @@ public class Loader implements LibraryLoader {
@Override
public String getDescription() {
return _("logisimFileFilter");
return getFromLocale("logisimFileFilter");
}
}
@ -64,7 +64,7 @@ public class Loader implements LibraryLoader {
@Override
public String getDescription() {
return _("jarFileFilter");
return getFromLocale("jarFileFilter");
}
}
@ -256,8 +256,8 @@ public class Loader implements LibraryLoader {
Library reference = LibraryManager.instance.findReference(file, dest);
if (reference != null) {
JOptionPane.showMessageDialog(parent,
_("fileCircularError", reference.getDisplayName()),
_("fileSaveErrorTitle"),
getFromLocale("fileCircularError", reference.getDisplayName()),
getFromLocale("fileSaveErrorTitle"),
JOptionPane.ERROR_MESSAGE);
return false;
}
@ -291,9 +291,9 @@ public class Loader implements LibraryLoader {
}
JOptionPane.showMessageDialog(parent,
_("fileSaveError",
getFromLocale("fileSaveError",
e.toString()),
_("fileSaveErrorTitle"),
getFromLocale("fileSaveErrorTitle"),
JOptionPane.ERROR_MESSAGE);
return false;
}
@ -311,9 +311,9 @@ public class Loader implements LibraryLoader {
}
JOptionPane.showMessageDialog(parent,
_("fileSaveCloseError",
getFromLocale("fileSaveCloseError",
e.toString()),
_("fileSaveErrorTitle"),
getFromLocale("fileSaveErrorTitle"),
JOptionPane.ERROR_MESSAGE);
return false;
}
@ -326,8 +326,8 @@ public class Loader implements LibraryLoader {
dest.delete();
}
JOptionPane.showMessageDialog(parent,
_("fileSaveZeroError"),
_("fileSaveErrorTitle"),
getFromLocale("fileSaveZeroError"),
getFromLocale("fileSaveErrorTitle"),
JOptionPane.ERROR_MESSAGE);
return false;
}
@ -385,8 +385,8 @@ public class Loader implements LibraryLoader {
for (File fileOpening : filesOpening) {
if (fileOpening.equals(actual)) {
logger.error( "An error occurred when opening the file.\n"
+ _("logisimCircularError" ) );
throw new LoadFailedException(_("logisimCircularError",
+ getFromLocale("logisimCircularError" ) );
throw new LoadFailedException(getFromLocale("logisimCircularError",
toProjectName(actual)));
}
}
@ -397,8 +397,8 @@ public class Loader implements LibraryLoader {
ret = LogisimFile.load(actual, this);
} catch (IOException e) {
logger.error( "An error occurred when opening the file.\n"
+ _("logisimCircularError" ) );
throw new LoadFailedException(_("logisimLoadError",
+ getFromLocale("logisimCircularError" ) );
throw new LoadFailedException(getFromLocale("logisimLoadError",
toProjectName(actual), e.toString()));
} finally {
filesOpening.pop();
@ -446,11 +446,11 @@ public class Loader implements LibraryLoader {
retClass = loader.loadClass(className);
} catch (ClassNotFoundException e) {
logger.error( "Class not found" );
throw new LoadFailedException(_("jarClassNotFoundError", className));
throw new LoadFailedException(getFromLocale("jarClassNotFoundError", className));
}
if (!(Library.class.isAssignableFrom(retClass))) {
logger.error( "Class not library" );
throw new LoadFailedException(_("jarClassNotLibraryError", className));
throw new LoadFailedException(getFromLocale("jarClassNotLibraryError", className));
}
// instantiate library
@ -459,7 +459,7 @@ public class Loader implements LibraryLoader {
ret = (Library) retClass.newInstance();
} catch (Exception e) {
logger.error( "Class not library" );
throw new LoadFailedException(_("jarLibraryNotCreatedError", className));
throw new LoadFailedException(getFromLocale("jarLibraryNotCreatedError", className));
}
return ret;
}
@ -521,10 +521,10 @@ public class Loader implements LibraryLoader {
JScrollPane scrollPane = new JScrollPane(textArea);
scrollPane.setPreferredSize(new Dimension(350, 150));
JOptionPane.showMessageDialog(parent, scrollPane,
_("fileErrorTitle"), JOptionPane.ERROR_MESSAGE);
getFromLocale("fileErrorTitle"), JOptionPane.ERROR_MESSAGE);
} else {
JOptionPane.showMessageDialog(parent, description,
_("fileErrorTitle"), JOptionPane.ERROR_MESSAGE);
getFromLocale("fileErrorTitle"), JOptionPane.ERROR_MESSAGE);
}
}
@ -540,7 +540,7 @@ public class Loader implements LibraryLoader {
String message = source.getMessage();
while (message != null) {
JOptionPane.showMessageDialog(parent,
message, _("fileMessageTitle"),
message, getFromLocale("fileMessageTitle"),
JOptionPane.INFORMATION_MESSAGE);
message = source.getMessage();
}
@ -569,14 +569,14 @@ public class Loader implements LibraryLoader {
while (!file.canRead()) {
// It doesn't exist. Figure it out from the user.
JOptionPane.showMessageDialog(parent,
_("fileLibraryMissingError",
getFromLocale("fileLibraryMissingError",
file.getName()));
JFileChooser chooser = createChooser();
chooser.setFileFilter(filter);
chooser.setDialogTitle(_("fileLibraryMissingTitle", file.getName()));
int action = chooser.showDialog(parent, _("fileLibraryMissingButton"));
chooser.setDialogTitle(getFromLocale("fileLibraryMissingTitle", file.getName()));
int action = chooser.showDialog(parent, getFromLocale("fileLibraryMissingButton"));
if (action != JFileChooser.APPROVE_OPTION) {
throw new LoaderException(_("fileLoadCanceledError"));
throw new LoaderException(getFromLocale("fileLoadCanceledError"));
}
file = chooser.getSelectedFile();
}

View File

@ -49,12 +49,12 @@ public class LogisimFile extends Library implements LibraryEventSource {
try {
file.write(out, file.loader);
} catch (IOException e) {
file.loader.showError(_("fileDuplicateError", e.toString()));
file.loader.showError(getFromLocale("fileDuplicateError", e.toString()));
}
try {
out.close();
} catch (IOException e) {
file.loader.showError(_("fileDuplicateError", e.toString()));
file.loader.showError(getFromLocale("fileDuplicateError", e.toString()));
}
}
}
@ -73,7 +73,7 @@ public class LogisimFile extends Library implements LibraryEventSource {
LogisimFile(Loader loader) {
this.loader = loader;
name = _("defaultProjectName");
name = getFromLocale("defaultProjectName");
if (Projects.windowNamed(name)) {
for (int i = 2; true; i++) {
if (!Projects.windowNamed(name + " " + i)) {
@ -278,7 +278,7 @@ public class LogisimFile extends Library implements LibraryEventSource {
for (Circuit circuit : getCircuits()) {
for (Component comp : circuit.getNonWires()) {
if (factories.contains(comp.getFactory())) {
return _("unloadUsedError",
return getFromLocale("unloadUsedError",
circuit.getName());
}
}
@ -288,10 +288,10 @@ public class LogisimFile extends Library implements LibraryEventSource {
MouseMappings mm = options.getMouseMappings();
for (Tool t : lib.getTools()) {
if (tb.usesToolFromSource(t)) {
return _("unloadToolbarError");
return getFromLocale("unloadToolbarError");
}
if (mm.usesToolFromSource(t)) {
return _("unloadMappingError");
return getFromLocale("unloadMappingError");
}
}
@ -319,7 +319,7 @@ public class LogisimFile extends Library implements LibraryEventSource {
loader.showError("internal error configuring parser");
} catch (TransformerException e) {
String msg = e.getMessage();
String err = _("xmlConversionError");
String err = getFromLocale("xmlConversionError");
if (msg == null) {
err += ": " + msg;
}
@ -334,7 +334,7 @@ public class LogisimFile extends Library implements LibraryEventSource {
try {
reader.connect(writer);
} catch (IOException e) {
newloader.showError(_("fileDuplicateError", e.toString()));
newloader.showError(getFromLocale("fileDuplicateError", e.toString()));
try {
reader.close();
} catch (IOException e1) {
@ -345,7 +345,7 @@ public class LogisimFile extends Library implements LibraryEventSource {
try {
return LogisimFile.load(reader, newloader);
} catch (IOException e) {
newloader.showError(_("fileDuplicateError", e.toString()));
newloader.showError(getFromLocale("fileDuplicateError", e.toString()));
return null;
}
}
@ -402,7 +402,7 @@ public class LogisimFile extends Library implements LibraryEventSource {
in = new ReaderInputStream(new FileReader(file), "UTF8");
return loadSub(in, loader);
} catch (Exception t) {
loader.showError(_("xmlFormatError", firstExcept.toString()));
loader.showError(getFromLocale("xmlFormatError", firstExcept.toString()));
} finally {
try {
in.close();
@ -418,7 +418,7 @@ public class LogisimFile extends Library implements LibraryEventSource {
try {
return loadSub(in, loader);
} catch (SAXException e) {
loader.showError(_("xmlFormatError", e.toString()));
loader.showError(getFromLocale("xmlFormatError", e.toString()));
return null;
}
}

View File

@ -65,7 +65,7 @@ public class LogisimFileActions {
@Override
public String getName() {
return _("addCircuitAction");
return getFromLocale("addCircuitAction");
}
@Override
@ -89,7 +89,7 @@ public class LogisimFileActions {
@Override
public String getName() {
return _("removeCircuitAction");
return getFromLocale("removeCircuitAction");
}
@Override
@ -116,7 +116,7 @@ public class LogisimFileActions {
@Override
public String getName() {
return _("moveCircuitAction");
return getFromLocale("moveCircuitAction");
}
@Override
@ -154,9 +154,9 @@ public class LogisimFileActions {
@Override
public String getName() {
if (libs.length == 1) {
return _("loadLibraryAction");
return getFromLocale("loadLibraryAction");
} else {
return _("loadLibrariesAction");
return getFromLocale("loadLibrariesAction");
}
}
@ -185,9 +185,9 @@ public class LogisimFileActions {
@Override
public String getName() {
if (libs.length == 1) {
return _("unloadLibraryAction");
return getFromLocale("unloadLibraryAction");
} else {
return _("unloadLibrariesAction");
return getFromLocale("unloadLibrariesAction");
}
}
@ -216,7 +216,7 @@ public class LogisimFileActions {
@Override
public String getName() {
return _("setMainCircuitAction");
return getFromLocale("setMainCircuitAction");
}
@Override
@ -255,7 +255,7 @@ public class LogisimFileActions {
@Override
public String getName() {
return _("revertDefaultsAction");
return getFromLocale("revertDefaultsAction");
}
@Override

View File

@ -12,16 +12,16 @@ import static com.cburch.logisim.util.LocaleString.*;
public class Options {
public static final AttributeOption GATE_UNDEFINED_IGNORE
= new AttributeOption("ignore", __("gateUndefinedIgnore"));
= new AttributeOption("ignore", getFromLocale("gateUndefinedIgnore"));
public static final AttributeOption GATE_UNDEFINED_ERROR
= new AttributeOption("error", __("gateUndefinedError"));
= new AttributeOption("error", getFromLocale("gateUndefinedError"));
public static final Attribute<Integer> sim_limit_attr
= Attributes.forInteger("simlimit", __("simLimitOption"));
= Attributes.forInteger("simlimit", getFromLocale("simLimitOption"));
public static final Attribute<Integer> sim_rand_attr
= Attributes.forInteger("simrand", __("simRandomOption"));
= Attributes.forInteger("simrand", getFromLocale("simRandomOption"));
public static final Attribute<AttributeOption> ATTR_GATE_UNDEFINED
= Attributes.forOption("gateUndefined", __("gateUndefinedOption"),
= Attributes.forOption("gateUndefined", getFromLocale("gateUndefinedOption"),
new AttributeOption[] { GATE_UNDEFINED_IGNORE, GATE_UNDEFINED_ERROR });
public static final Integer sim_rand_dflt = Integer.valueOf(32);

View File

@ -110,22 +110,22 @@ public class XmlCircuitReader extends CircuitTransaction {
try {
String str = elt.getAttribute("from");
if (str == null || str.equals("")) {
throw new XmlReaderException(_("wireStartMissingError"));
throw new XmlReaderException(getFromLocale("wireStartMissingError"));
}
pt0 = Location.parse(str);
} catch (NumberFormatException e) {
throw new XmlReaderException(_("wireStartInvalidError"));
throw new XmlReaderException(getFromLocale("wireStartInvalidError"));
}
Location pt1;
try {
String str = elt.getAttribute("to");
if (str == null || str.equals("")) {
throw new XmlReaderException(_("wireEndMissingError"));
throw new XmlReaderException(getFromLocale("wireEndMissingError"));
}
pt1 = Location.parse(str);
} catch (NumberFormatException e) {
throw new XmlReaderException(_("wireEndInvalidError"));
throw new XmlReaderException(getFromLocale("wireEndInvalidError"));
}
mutator.add(dest, Wire.create(pt0, pt1));
@ -136,21 +136,21 @@ public class XmlCircuitReader extends CircuitTransaction {
// Determine the factory that creates this element
String name = elt.getAttribute("name");
if (name == null || name.equals("")) {
throw new XmlReaderException(_("compNameMissingError"));
throw new XmlReaderException(getFromLocale("compNameMissingError"));
}
String libName = elt.getAttribute("lib");
Library lib = reader.findLibrary(libName);
if (lib == null) {
throw new XmlReaderException(_("compUnknownError", "no-lib"));
throw new XmlReaderException(getFromLocale("compUnknownError", "no-lib"));
}
Tool tool = lib.getTool(name);
if (tool == null || !(tool instanceof AddTool)) {
if (libName == null || libName.equals("")) {
throw new XmlReaderException(_("compUnknownError", name));
throw new XmlReaderException(getFromLocale("compUnknownError", name));
} else {
throw new XmlReaderException(_("compAbsentError", name, libName));
throw new XmlReaderException(getFromLocale("compAbsentError", name, libName));
}
}
ComponentFactory source = ((AddTool) tool).getFactory();
@ -162,13 +162,13 @@ public class XmlCircuitReader extends CircuitTransaction {
// Create component if location known
if (loc_str == null || loc_str.equals("")) {
throw new XmlReaderException(_("compLocMissingError", source.getName()));
throw new XmlReaderException(getFromLocale("compLocMissingError", source.getName()));
} else {
try {
Location loc = Location.parse(loc_str);
return source.createComponent(loc, attrs);
} catch (NumberFormatException e) {
throw new XmlReaderException(_("compLocInvalidError",
throw new XmlReaderException(getFromLocale("compLocInvalidError",
source.getName(), loc_str));
}
}

View File

@ -92,7 +92,7 @@ class XmlReader {
for (Element circElt : XmlIterator.forChildElements(elt, "circuit")) {
String name = circElt.getAttribute("name");
if (name == null || name.equals("")) {
addError(_("circNameMissingError"), "C??");
addError(getFromLocale("circNameMissingError"), "C??");
}
CircuitData circData = new CircuitData(circElt, new Circuit(name));
file.addCircuit(circData.circuit);
@ -138,11 +138,11 @@ class XmlReader {
private Library toLibrary(Element elt) {
if (!elt.hasAttribute("name")) {
loader.showError(_("libNameMissingError"));
loader.showError(getFromLocale("libNameMissingError"));
return null;
}
if (!elt.hasAttribute("desc")) {
loader.showError(_("libDescMissingError"));
loader.showError(getFromLocale("libDescMissingError"));
return null;
}
String name = elt.getAttribute("name");
@ -155,7 +155,7 @@ class XmlReader {
libs.put(name, ret);
for (Element sub_elt : XmlIterator.forChildElements(elt, "tool")) {
if (!sub_elt.hasAttribute("name")) {
loader.showError(_("toolNameMissingError"));
loader.showError(getFromLocale("toolNameMissingError"));
} else {
String tool_str = sub_elt.getAttribute("name");
Tool tool = ret.getTool(tool_str);
@ -197,13 +197,13 @@ class XmlReader {
try {
AbstractCanvasObject m = AppearanceSvgReader.createShape(sub, pins);
if (m == null) {
addError(_("fileAppearanceNotFound", sub.getTagName()),
addError(getFromLocale("fileAppearanceNotFound", sub.getTagName()),
context + "." + sub.getTagName());
} else {
shapes.add(m);
}
} catch (RuntimeException e) {
addError(_("fileAppearanceError", sub.getTagName()),
addError(getFromLocale("fileAppearanceError", sub.getTagName()),
context + "." + sub.getTagName());
}
}
@ -229,14 +229,14 @@ class XmlReader {
String mods_str = sub_elt.getAttribute("map");
if (mods_str == null || mods_str.equals("")) {
loader.showError(_("mappingMissingError"));
loader.showError(getFromLocale("mappingMissingError"));
continue;
}
int mods;
try {
mods = InputEventUtil.fromString(mods_str);
} catch (NumberFormatException e) {
loader.showError(_("mappingBadError", mods_str));
loader.showError(getFromLocale("mappingBadError", mods_str));
continue;
}
@ -281,11 +281,11 @@ class XmlReader {
Library lib = findLibrary(elt.getAttribute("lib"));
String name = elt.getAttribute("name");
if (name == null || name.equals("")) {
throw new XmlReaderException(_("toolNameMissing"));
throw new XmlReaderException(getFromLocale("toolNameMissing"));
}
Tool tool = lib.getTool(name);
if (tool == null) {
throw new XmlReaderException(_("toolNotFound"));
throw new XmlReaderException(getFromLocale("toolNotFound"));
}
return tool;
}
@ -301,7 +301,7 @@ class XmlReader {
messages = new ArrayList<String>();
}
messages.add(_("attrNameMissingError"));
messages.add(getFromLocale("attrNameMissingError"));
} else {
String attrName = attrElt.getAttribute("name");
String attrVal;
@ -351,7 +351,7 @@ class XmlReader {
messages = new ArrayList<String>();
}
messages.add(_("attrValueInvalidError",
messages.add(getFromLocale("attrValueInvalidError",
attrVal, attrName));
}
}
@ -368,7 +368,7 @@ class XmlReader {
Library ret = libs.get(lib_name);
if (ret == null) {
throw new XmlReaderException(_("libMissingError", lib_name));
throw new XmlReaderException(getFromLocale("libMissingError", lib_name));
} else {
return ret;
}

View File

@ -179,7 +179,7 @@ public class AppearanceEditHandler extends EditHandler
}
canvas.getProject().doAction(new SelectionAction(canvas,
__("pasteClipboardAction"), null, add, add,
getFromLocale("pasteClipboardAction"), null, add, add,
anchorLocation, clip.getAnchorFacing()));
}
@ -206,7 +206,7 @@ public class AppearanceEditHandler extends EditHandler
if (!remove.isEmpty()) {
canvas.getProject().doAction(new SelectionAction(canvas,
__("deleteSelectionAction"), remove, null, select,
getFromLocale("deleteSelectionAction"), remove, null, select,
anchorLocation, anchorFacing));
}
}
@ -230,7 +230,7 @@ public class AppearanceEditHandler extends EditHandler
if (!clones.isEmpty()) {
canvas.getProject().doAction(new SelectionAction(canvas,
__("duplicateSelectionAction"), null, clones, select,
getFromLocale("duplicateSelectionAction"), null, clones, select,
null, null));
}
}

View File

@ -60,9 +60,9 @@ public class ClipboardActions extends Action {
@Override
public String getName() {
if (remove) {
return _("cutSelectionAction");
return getFromLocale("cutSelectionAction");
} else {
return _("copySelectionAction");
return getFromLocale("copySelectionAction");
}
}

View File

@ -23,7 +23,7 @@ public class RevertAppearanceAction extends Action {
@Override
public String getName() {
return _("revertAppearanceAction");
return getFromLocale("revertAppearanceAction");
}
@Override

View File

@ -16,10 +16,9 @@ import com.cburch.logisim.data.Direction;
import com.cburch.logisim.data.Location;
import com.cburch.logisim.proj.Action;
import com.cburch.logisim.proj.Project;
import com.cburch.logisim.util.StringGetter;
class SelectionAction extends Action {
private StringGetter displayName;
private String displayName;
private AppearanceCanvas canvas;
private CanvasModel canvasModel;
private Map<CanvasObject, Integer> toRemove;
@ -31,7 +30,7 @@ class SelectionAction extends Action {
private Location anchorOldLocation;
private Direction anchorOldFacing;
public SelectionAction(AppearanceCanvas canvas, StringGetter displayName,
public SelectionAction(AppearanceCanvas canvas, String displayName,
Collection<CanvasObject> toRemove, Collection<CanvasObject> toAdd,
Collection<CanvasObject> newSelection, Location anchorLocation,
Direction anchorFacing) {

View File

@ -73,12 +73,12 @@ public class AttrTable extends JPanel implements LocaleListener {
Object value;
public MyDialog(Dialog parent, JInputComponent input) {
super(parent, _("attributeDialogTitle"), true);
super(parent, getFromLocale("attributeDialogTitle"), true);
configure(input);
}
public MyDialog(Frame parent, JInputComponent input) {
super(parent, _("attributeDialogTitle"), true);
super(parent, getFromLocale("attributeDialogTitle"), true);
configure(input);
}
@ -198,7 +198,7 @@ public class AttrTable extends JPanel implements LocaleListener {
attrModel.getRow(rowIndex).setValue(value);
} catch (AttrTableSetException e) {
JOptionPane.showMessageDialog(parent, e.getMessage(),
_("attributeChangeInvalidTitle"),
getFromLocale("attributeChangeInvalidTitle"),
JOptionPane.WARNING_MESSAGE);
}
}
@ -358,7 +358,7 @@ public class AttrTable extends JPanel implements LocaleListener {
row.setValue(retval);
} catch (AttrTableSetException e) {
JOptionPane.showMessageDialog(parent, e.getMessage(),
_("attributeChangeInvalidTitle"),
getFromLocale("attributeChangeInvalidTitle"),
JOptionPane.WARNING_MESSAGE);
}
editor = new JLabel(row.getValue());

View File

@ -70,11 +70,11 @@ public abstract class AttributeSetTableModel
}
setValueRequested(attr, value);
} catch (ClassCastException e) {
String msg = _("attributeChangeInvalidError")
String msg = getFromLocale("attributeChangeInvalidError")
+ ": " + e;
throw new AttrTableSetException(msg);
} catch (NumberFormatException e) {
String msg = _("attributeChangeInvalidError");
String msg = getFromLocale("attributeChangeInvalidError");
String emsg = e.getMessage();
if (emsg != null && emsg.length() > 0) {
msg += ": " + emsg;

View File

@ -7,8 +7,6 @@ import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.KeyEventPostProcessor;
import java.awt.KeyboardFocusManager;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
@ -16,9 +14,14 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.AbstractSpinnerModel;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.KeyStroke;
import com.cburch.logisim.util.CustomAction;
import static com.cburch.logisim.util.LocaleString.*;
@ -48,8 +51,6 @@ public class ZoomControl extends JPanel {
return null;
}
@Override
public Object getValue() {
double zoom = model.getZoomFactor();
@ -98,7 +99,7 @@ public class ZoomControl extends JPanel {
@Override
public String getToolTipText(MouseEvent e) {
return _("zoomShowGrid");
return getFromLocale("zoomShowGrid");
}
private void update() {
@ -148,8 +149,15 @@ public class ZoomControl extends JPanel {
private JSpinner spinner;
private SpinnerModel spinnerModel;
private GridIcon grid;
private boolean pressed = false;
public void zoomIn() {
spinnerModel.setValue(spinnerModel.getNextValue());
}
public void zoomOut() {
spinnerModel.setValue(spinnerModel.getPreviousValue());
}
public ZoomControl(ZoomModel model) {
super(new BorderLayout());
this.model = model;
@ -157,26 +165,20 @@ public class ZoomControl extends JPanel {
spinnerModel = new SpinnerModel();
spinner = new JSpinner();
spinner.setModel(spinnerModel);
//Zooming with CTRL+/-
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventPostProcessor(new KeyEventPostProcessor() {
public boolean postProcessKeyEvent(KeyEvent e) {
if (!pressed && e.isControlDown()){
if (e.getKeyCode() == KeyEvent.VK_EQUALS) {
spinnerModel.setValue(spinnerModel.getNextValue());
pressed = true;
}
else if (e.getKeyCode() == KeyEvent.VK_MINUS) {
spinnerModel.setValue(spinnerModel.getPreviousValue());
pressed = true;
}
}
else
pressed = false;
return true;
}
});
InputMap im = this.getInputMap(ZoomControl.WHEN_IN_FOCUSED_WINDOW);
ActionMap am = this.getActionMap();
int mask = getToolkit().getMenuShortcutKeyMask();
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, mask), "CTRL+");
am.put("CTRL+", new CustomAction("CTRL+", this));
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, mask), "CTRL+");
am.put("CTRL+", new CustomAction("CTRL+", this));
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, mask), "CTRL-");
am.put("CTRL-", new CustomAction("CTRL-", this));
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, mask), "CTRL-");
am.put("CTRL-", new CustomAction("CTRL-", this));
this.add(spinner, BorderLayout.CENTER);
grid = new GridIcon();

View File

@ -131,15 +131,15 @@ class Clip implements ClipboardOwner {
} catch (IOException e) {
JOptionPane.showMessageDialog(editor.getRootPane(),
e.getMessage(),
// _("hexPasteSupportedError"),
_("hexPasteErrorTitle"),
// getFromLocale("hexPasteSupportedError"),
getFromLocale("hexPasteErrorTitle"),
JOptionPane.ERROR_MESSAGE);
return;
}
} else {
JOptionPane.showMessageDialog(editor.getRootPane(),
_("hexPasteSupportedError"),
_("hexPasteErrorTitle"),
getFromLocale("hexPasteSupportedError"),
getFromLocale("hexPasteErrorTitle"),
JOptionPane.ERROR_MESSAGE);
return;
}
@ -153,8 +153,8 @@ class Clip implements ClipboardOwner {
model.set(p0, data);
} else {
JOptionPane.showMessageDialog(editor.getRootPane(),
_("hexPasteEndError"),
_("hexPasteErrorTitle"),
getFromLocale("hexPasteEndError"),
getFromLocale("hexPasteErrorTitle"),
JOptionPane.ERROR_MESSAGE);
}
} else {
@ -172,8 +172,8 @@ class Clip implements ClipboardOwner {
model.set(p0, data);
} else {
JOptionPane.showMessageDialog(editor.getRootPane(),
_("hexPasteSizeError"),
_("hexPasteErrorTitle"),
getFromLocale("hexPasteSizeError"),
getFromLocale("hexPasteErrorTitle"),
JOptionPane.ERROR_MESSAGE);
}
}

View File

@ -97,7 +97,7 @@ public class HexFile {
leftValue = Long.parseLong(tok.substring(star + 1), 16);
}
} catch (NumberFormatException e) {
throw new IOException(_("hexNumberFormatError"));
throw new IOException(getFromLocale("hexNumberFormatError"));
}
int n = (int) Math.min(data.length - pos, leftCount);
@ -141,7 +141,7 @@ public class HexFile {
if (cur != start + 1) out.write((cur - start) + "*");
out.write(Integer.toHexString(val));
} catch (IOException e) {
throw new IOException(_("hexFileWriteError"));
throw new IOException(getFromLocale("hexFileWriteError"));
}
tokens++;
}
@ -154,7 +154,7 @@ public class HexFile {
while (reader.hasNext()) {
int[] values = reader.next();
if (offs + values.length - 1 > dst.getLastOffset()) {
throw new IOException(_("hexFileSizeError"));
throw new IOException(getFromLocale("hexFileSizeError"));
}
dst.set(offs, values);
offs += values.length;
@ -189,12 +189,12 @@ public class HexFile {
try {
in = new BufferedReader(new FileReader(src));
} catch (IOException e) {
throw new IOException(_("hexFileOpenError"));
throw new IOException(getFromLocale("hexFileOpenError"));
}
try {
String header = in.readLine();
if (!header.equals(RAW_IMAGE_HEADER)) {
throw new IOException(_("hexHeaderFormatError"));
throw new IOException(getFromLocale("hexHeaderFormatError"));
}
open(dst, in);
try {
@ -202,7 +202,7 @@ public class HexFile {
in = null;
oldIn.close();
} catch (IOException e) {
throw new IOException(_("hexFileReadError"));
throw new IOException(getFromLocale("hexFileReadError"));
}
} finally {
try {
@ -216,20 +216,20 @@ public class HexFile {
try {
out = new FileWriter(dst);
} catch (IOException e) {
throw new IOException(_("hexFileOpenError"));
throw new IOException(getFromLocale("hexFileOpenError"));
}
try {
try {
out.write(RAW_IMAGE_HEADER + "\n");
} catch (IOException e) {
throw new IOException(_("hexFileWriteError"));
throw new IOException(getFromLocale("hexFileWriteError"));
}
save(out, src);
} finally {
try {
out.close();
} catch (IOException e) {
throw new IOException(_("hexFileWriteError"));
throw new IOException(getFromLocale("hexFileWriteError"));
}
}
}

View File

@ -38,7 +38,7 @@ public class HexFrame extends LFrame {
private class WindowMenuManager extends WindowMenuItemManager
implements LocaleListener {
WindowMenuManager() {
super(_("hexFrameMenuItem"), false);
super(getFromLocale("hexFrameMenuItem"), false);
LocaleManager.addLocaleListener(this);
}
@ -49,7 +49,7 @@ public class HexFrame extends LFrame {
@Override
public void localeChanged() {
setText(_("hexFrameMenuItem"));
setText(getFromLocale("hexFrameMenuItem"));
}
}
@ -62,7 +62,7 @@ public class HexFrame extends LFrame {
Object src = event.getSource();
if (src == open) {
JFileChooser chooser = JFileChoosers.createSelected(lastFile);
chooser.setDialogTitle(_("openButton"));
chooser.setDialogTitle(getFromLocale("openButton"));
int choice = chooser.showOpenDialog(HexFrame.this);
if (choice == JFileChooser.APPROVE_OPTION) {
File f = chooser.getSelectedFile();
@ -71,12 +71,12 @@ public class HexFrame extends LFrame {
lastFile = f;
} catch (IOException e) {
JOptionPane.showMessageDialog(HexFrame.this, e.getMessage(),
_("hexOpenErrorTitle"), JOptionPane.ERROR_MESSAGE);
getFromLocale("hexOpenErrorTitle"), JOptionPane.ERROR_MESSAGE);
}
}
} else if (src == save) {
JFileChooser chooser = JFileChoosers.createSelected(lastFile);
chooser.setDialogTitle(_("saveButton"));
chooser.setDialogTitle(getFromLocale("saveButton"));
int choice = chooser.showSaveDialog(HexFrame.this);
if (choice == JFileChooser.APPROVE_OPTION) {
File f = chooser.getSelectedFile();
@ -85,7 +85,7 @@ public class HexFrame extends LFrame {
lastFile = f;
} catch (IOException e) {
JOptionPane.showMessageDialog(HexFrame.this, e.getMessage(),
_("hexSaveErrorTitle"), JOptionPane.ERROR_MESSAGE);
getFromLocale("hexSaveErrorTitle"), JOptionPane.ERROR_MESSAGE);
}
}
} else if (src == close) {
@ -97,10 +97,10 @@ public class HexFrame extends LFrame {
@Override
public void localeChanged() {
setTitle(_("hexFrameTitle"));
open.setText(_("openButton"));
save.setText(_("saveButton"));
close.setText(_("closeButton"));
setTitle(getFromLocale("hexFrameTitle"));
open.setText(getFromLocale("openButton"));
save.setText(getFromLocale("saveButton"));
close.setText(getFromLocale("closeButton"));
}
}

View File

@ -47,11 +47,11 @@ class FilePanel extends LogPanel {
private void computeEnableItems(Model model) {
if (model.isFileEnabled()) {
enableLabel.setText(_("fileEnabled"));
enableButton.setText(_("fileDisableButton"));
enableLabel.setText(getFromLocale("fileEnabled"));
enableButton.setText(getFromLocale("fileDisableButton"));
} else {
enableLabel.setText(_("fileDisabled"));
enableButton.setText(_("fileEnableButton"));
enableLabel.setText(getFromLocale("fileDisabled"));
enableButton.setText(getFromLocale("fileEnableButton"));
}
}
@ -69,20 +69,20 @@ class FilePanel extends LogPanel {
File file = chooser.getSelectedFile();
if (file.exists() && (!file.canWrite() || file.isDirectory())) {
JOptionPane.showMessageDialog(getLogFrame(),
_("fileCannotWriteMessage", file.getName()),
_("fileCannotWriteTitle"),
getFromLocale("fileCannotWriteMessage", file.getName()),
getFromLocale("fileCannotWriteTitle"),
JOptionPane.OK_OPTION);
return;
}
if (file.exists() && file.length() > 0) {
String[] options = {
_("fileOverwriteOption"),
_("fileAppendOption"),
_("fileCancelOption"),
getFromLocale("fileOverwriteOption"),
getFromLocale("fileAppendOption"),
getFromLocale("fileCancelOption"),
};
int option = JOptionPane.showOptionDialog(getLogFrame(),
_("fileExistsMessage", file.getName()),
_("fileExistsTitle"),
getFromLocale("fileExistsMessage", file.getName()),
getFromLocale("fileExistsTitle"),
0, JOptionPane.QUESTION_MESSAGE, null,
options, options[0]);
if (option == 0) {
@ -157,20 +157,20 @@ class FilePanel extends LogPanel {
@Override
public String getTitle() {
return _("fileTab");
return getFromLocale("fileTab");
}
@Override
public String getHelpText() {
return _("fileHelp");
return getFromLocale("fileHelp");
}
@Override
public void localeChanged() {
listener.computeEnableItems(getModel());
fileLabel.setText(_("fileLabel") + " ");
selectButton.setText(_("fileSelectButton"));
headerCheckBox.setText(_("fileHeaderCheck"));
fileLabel.setText(getFromLocale("fileLabel") + " ");
selectButton.setText(getFromLocale("fileSelectButton"));
headerCheckBox.setText(getFromLocale("fileHeaderCheck"));
}
@Override

View File

@ -40,7 +40,7 @@ public class LogFrame extends LFrame {
private class WindowMenuManager extends WindowMenuItemManager
implements LocaleListener, ProjectListener, LibraryListener {
WindowMenuManager() {
super(_("logFrameMenuItem"), false);
super(getFromLocale("logFrameMenuItem"), false);
project.addProjectListener(this);
project.addLibraryListener(this);
}
@ -53,7 +53,7 @@ public class LogFrame extends LFrame {
@Override
public void localeChanged() {
String title = project.getLogisimFile().getDisplayName();
setText(_("logFrameMenuItem", title));
setText(getFromLocale("logFrameMenuItem", title));
}
@Override
@ -111,7 +111,7 @@ public class LogFrame extends LFrame {
tabbedPane.setToolTipTextAt(i, panels[i].getToolTipText());
panels[i].localeChanged();
}
close.setText(_("closeButton"));
close.setText(getFromLocale("closeButton"));
windowManager.localeChanged();
}
@ -242,6 +242,6 @@ public class LogFrame extends LFrame {
private static String computeTitle(Model data, Project proj) {
String name = data == null ? "???" : data.getCircuitState().getCircuit().getName();
return _("logFrameTitle", name, proj.getLogisimFile().getDisplayName());
return getFromLocale("logFrameTitle", name, proj.getLogisimFile().getDisplayName());
}
}

View File

@ -177,21 +177,21 @@ class SelectionPanel extends LogPanel {
@Override
public String getTitle() {
return _("selectionTab");
return getFromLocale("selectionTab");
}
@Override
public String getHelpText() {
return _("selectionHelp");
return getFromLocale("selectionHelp");
}
@Override
public void localeChanged() {
addTool.setText(_("selectionAdd"));
changeBase.setText(_("selectionChangeBase"));
moveUp.setText(_("selectionMoveUp"));
moveDown.setText(_("selectionMoveDown"));
remove.setText(_("selectionRemove"));
addTool.setText(getFromLocale("selectionAdd"));
changeBase.setText(getFromLocale("selectionChangeBase"));
moveUp.setText(getFromLocale("selectionMoveUp"));
moveDown.setText(getFromLocale("selectionMoveDown"));
remove.setText(getFromLocale("selectionRemove"));
selector.localeChanged();
list.localeChanged();
}

View File

@ -139,12 +139,12 @@ class TablePanel extends LogPanel {
@Override
public String getTitle() {
return _("tableTab");
return getFromLocale("tableTab");
}
@Override
public String getHelpText() {
return _("tableHelp");
return getFromLocale("tableHelp");
}
@Override
@ -202,7 +202,7 @@ class TablePanel extends LogPanel {
int columns = sel.size();
if (columns == 0) {
g.setFont(BODY_FONT);
GraphicsUtil.drawCenteredText(g, _("tableEmptyMessage"), sz.width / 2, sz.height / 2);
GraphicsUtil.drawCenteredText(g, getFromLocale("tableEmptyMessage"), sz.width / 2, sz.height / 2);
return;
}

View File

@ -23,19 +23,19 @@ public class AttrTableCircuitModel extends AttributeSetTableModel {
@Override
public String getTitle() {
return _("circuitAttrTitle", circ.getName());
return getFromLocale("circuitAttrTitle", circ.getName());
}
@Override
public void setValueRequested(Attribute<Object> attr, Object value)
throws AttrTableSetException {
if (!proj.getLogisimFile().contains(circ)) {
String msg = _("cannotModifyCircuitError");
String msg = getFromLocale("cannotModifyCircuitError");
throw new AttrTableSetException(msg);
} else {
CircuitMutation xn = new CircuitMutation(circ);
xn.setForCircuit(attr, value);
proj.doAction(xn.toAction(__("changeCircuitAttrAction")));
proj.doAction(xn.toAction(getFromLocale("changeCircuitAttrAction")));
}
}
}

View File

@ -41,11 +41,11 @@ class AttrTableComponentModel extends AttributeSetTableModel {
public void setValueRequested(Attribute<Object> attr, Object value)
throws AttrTableSetException {
if (!proj.getLogisimFile().contains(circ)) {
String msg = _("cannotModifyCircuitError");
String msg = getFromLocale("cannotModifyCircuitError");
throw new AttrTableSetException(msg);
} else {
SetAttributeAction act = new SetAttributeAction(circ,
__("changeAttributeAction"));
getFromLocale("changeAttributeAction"));
act.set(comp, attr, value);
proj.doAction(act);
}

View File

@ -63,14 +63,14 @@ class AttrTableSelectionModel extends AttributeSetTableModel
}
if (variousFound) {
return _("selectionVarious", "" + totalCount);
return getFromLocale("selectionVarious", "" + totalCount);
} else if (factoryCount == 0) {
String circName = frame.getCanvas().getCircuit().getName();
return _("circuitAttrTitle", circName);
return getFromLocale("circuitAttrTitle", circName);
} else if (factoryCount == 1) {
return _("selectionOne", factory.getDisplayName());
return getFromLocale("selectionOne", factory.getDisplayName());
} else {
return _("selectionMultiple", factory.getDisplayName(),
return getFromLocale("selectionMultiple", factory.getDisplayName(),
"" + factoryCount);
}
}
@ -85,7 +85,7 @@ class AttrTableSelectionModel extends AttributeSetTableModel
circuitModel.setValueRequested(attr, value);
} else {
SetAttributeAction act = new SetAttributeAction(circuit,
__("selectionAttributeAction"));
getFromLocale("selectionAttributeAction"));
for (Component comp : selection.getComponents()) {
if (!(comp instanceof Wire)) {
act.set(comp, attr, value);

View File

@ -21,7 +21,7 @@ public class AttrTableToolModel extends AttributeSetTableModel {
@Override
public String getTitle() {
return _("toolAttrTitle", tool.getDisplayName());
return getFromLocale("toolAttrTitle", tool.getDisplayName());
}
public Tool getTool() {

View File

@ -3,14 +3,17 @@
package com.cburch.logisim.gui.main;
import static com.cburch.logisim.util.LocaleString._;
import static com.cburch.logisim.util.LocaleString.getFromLocale;
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import java.util.*;
import java.util.List;
import javax.swing.*;
import javax.swing.event.*;
import com.cburch.logisim.circuit.*;
import com.cburch.logisim.comp.*;
import com.cburch.logisim.comp.Component;
@ -20,6 +23,7 @@ import com.cburch.logisim.gui.generic.*;
import com.cburch.logisim.prefs.AppPreferences;
import com.cburch.logisim.proj.*;
import com.cburch.logisim.tools.*;
import com.cburch.logisim.tools.SelectTool.ComputingMessage;
import com.cburch.logisim.util.*;
@SuppressWarnings("serial")
@ -101,7 +105,7 @@ public class Canvas extends JPanel
@Override
public void mousePressed(MouseEvent e) {
viewport.setErrorMessage(null, null);
viewport.setErrorMessage(null, 0, 0, null);
proj.setStartupScreen(false);
Canvas.this.requestFocus();
drag_tool = getToolFor(e);
@ -205,7 +209,7 @@ public class Canvas extends JPanel
public void projectChanged(ProjectEvent event) {
int act = event.getAction();
if (act == ProjectEvent.ACTION_SET_CURRENT) {
viewport.setErrorMessage(null, null);
viewport.setErrorMessage(null, 0, 0, null);
if (painter.getHaloedComponent() != null) {
proj.getFrame().viewComponentAttributes(null, null);
}
@ -223,7 +227,7 @@ public class Canvas extends JPanel
mappings = file.getOptions().getMouseMappings();
}
} else if (act == ProjectEvent.ACTION_SET_TOOL) {
viewport.setErrorMessage(null, null);
viewport.setErrorMessage(null, 0, 0, null);
Tool t = event.getTool();
if (t == null) {
@ -372,7 +376,9 @@ public class Canvas extends JPanel
}
private class MyViewport extends JViewport {
StringGetter errorMessage = null;
String errorMessage = null;
int dx = 0;
int dy = 0;
Color errorColor = DEFAULT_ERROR_COLOR;
String widthMessage = null;
boolean isNorth = false;
@ -386,9 +392,11 @@ public class Canvas extends JPanel
MyViewport() { }
void setErrorMessage(StringGetter msg, Color color) {
void setErrorMessage(String msg, int dx, int dy, Color color) {
if (errorMessage != msg) {
errorMessage = msg;
this.dx = dx;
this.dy = dy;
errorColor = color == null ? DEFAULT_ERROR_COLOR : color;
paintThread.requestRepaint();
}
@ -445,7 +453,7 @@ public class Canvas extends JPanel
getHeight() - 10);
*/
StringGetter message = errorMessage;
String message = errorMessage;
if (message != null) {
g.setColor(errorColor);
paintString(g, message.toString());
@ -454,13 +462,13 @@ public class Canvas extends JPanel
if (proj.getSimulator().isOscillating()) {
g.setColor(DEFAULT_ERROR_COLOR);
paintString(g, _("canvasOscillationError"));
paintString(g, getFromLocale("canvasOscillationError"));
return;
}
if (proj.getSimulator().isExceptionEncountered()) {
g.setColor(DEFAULT_ERROR_COLOR);
paintString(g, _("canvasExceptionError"));
paintString(g, getFromLocale("canvasExceptionError"));
return;
}
@ -597,16 +605,16 @@ public class Canvas extends JPanel
}
public StringGetter getErrorMessage() {
return viewport.errorMessage;
public ComputingMessage getErrorMessage() {
return new ComputingMessage(viewport.dx, viewport.dy);
}
public void setErrorMessage(StringGetter message) {
viewport.setErrorMessage(message, null);
public void setErrorMessage(String message, int dx, int dy) {
viewport.setErrorMessage(message, dx, dy, null);
}
public void setErrorMessage(StringGetter message, Color color) {
viewport.setErrorMessage(message, color);
public void setErrorMessage(String message, int dx, int dy, Color color) {
viewport.setErrorMessage(message, dx, dy, color);
}
//
@ -764,7 +772,7 @@ public class Canvas extends JPanel
(int) (viewableBase.height / zoom));
}
viewport.setWidthMessage(_("canvasWidthError")
viewport.setWidthMessage(getFromLocale("canvasWidthError")
+ (exceptions.size() == 1 ? "" : " (" + exceptions.size() + ")"));
for (WidthIncompatibilityData ex : exceptions) {
// See whether any of the points are on the canvas.

View File

@ -27,13 +27,13 @@ class ExplorerToolbarModel extends AbstractToolbarModel
this.frame = frame;
itemToolbox = new LogisimToolbarItem(menu, "projtool.svg",
LogisimMenuBar.VIEW_TOOLBOX, __("projectViewToolboxTip"));
LogisimMenuBar.VIEW_TOOLBOX, getFromLocale("projectViewToolboxTip"));
itemSimulation = new LogisimToolbarItem(menu, "projsim.svg",
LogisimMenuBar.VIEW_SIMULATION, __("projectViewSimulationTip"));
LogisimMenuBar.VIEW_SIMULATION, getFromLocale("projectViewSimulationTip"));
itemLayout = new LogisimToolbarItem(menu, "projlayo.svg",
LogisimMenuBar.EDIT_LAYOUT, __("projectEditLayoutTip"));
LogisimMenuBar.EDIT_LAYOUT, getFromLocale("projectEditLayoutTip"));
itemAppearance = new LogisimToolbarItem(menu, "projapp.svg",
LogisimMenuBar.EDIT_APPEARANCE, __("projectEditAppearanceTip"));
LogisimMenuBar.EDIT_APPEARANCE, getFromLocale("projectEditAppearanceTip"));
items = UnmodifiableList.decorate(Arrays.asList(new ToolbarItem[] {
itemToolbox,

View File

@ -3,8 +3,7 @@
package com.cburch.logisim.gui.main;
import static com.cburch.logisim.util.LocaleString._;
import static com.cburch.logisim.util.LocaleString.__;
import static com.cburch.logisim.util.LocaleString.*;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
@ -22,20 +21,10 @@ import javax.swing.event.ChangeListener;
import javax.swing.filechooser.FileFilter;
import org.apache.batik.dom.GenericDOMImplementation;
import org.apache.batik.svggen.SVGGraphics2D;
import org.apache.batik.svggen.SVGGraphics2DIOException;
import org.apache.fop.svg.PDFGraphics2D;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Map.Entry;
import com.itextpdf.awt.DefaultFontMapper;
import com.itextpdf.awt.DefaultFontMapper.BaseFontParameters;
import com.itextpdf.awt.PdfGraphics2D;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.*;
import org.w3c.dom.DOMImplementation;
@ -46,7 +35,6 @@ import com.cburch.logisim.comp.ComponentDrawContext;
import com.cburch.logisim.data.Bounds;
import com.cburch.logisim.file.Loader;
import com.cburch.logisim.proj.Project;
import com.cburch.logisim.util.StringGetter;
class ExportImage {
private static final int SLIDER_DIVISIONS = 6;
@ -67,14 +55,14 @@ class ExportImage {
CircuitJList list = new CircuitJList(proj, true);
if (list.getModel().getSize() == 0) {
JOptionPane.showMessageDialog(proj.getFrame(),
_("exportEmptyCircuitsMessage"),
_("exportEmptyCircuitsTitle"),
getFromLocale("exportEmptyCircuitsMessage"),
getFromLocale("exportEmptyCircuitsTitle"),
JOptionPane.YES_NO_OPTION);
return;
}
OptionsPanel options = new OptionsPanel(list);
int action = JOptionPane.showConfirmDialog(frame,
options, _("exportImageSelect"),
options, getFromLocale("exportImageSelect"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (action != JOptionPane.OK_OPTION) return;
@ -87,25 +75,25 @@ class ExportImage {
int fmt = options.getImageFormat();
switch (options.getImageFormat()) {
case FORMAT_GIF:
filter = new ImageFileFilter(fmt, __("exportGifFilter"),
filter = new ImageFileFilter(fmt, getFromLocale("exportGifFilter"),
new String[] { "gif" });
break;
case FORMAT_PNG:
filter = new ImageFileFilter(fmt, __("exportPngFilter"),
filter = new ImageFileFilter(fmt, getFromLocale("exportPngFilter"),
new String[] { "png" });
break;
case FORMAT_JPG:
filter = new ImageFileFilter(fmt, __("exportJpgFilter"),
filter = new ImageFileFilter(fmt, getFromLocale("exportJpgFilter"),
new String[] { "jpg", "jpeg", "jpe", "jfi", "jfif", "jfi" });
break;
case FORMAT_SVG:
filter = null;
filter = new ImageFileFilter(fmt, __("exportSvgFilter"),
filter = new ImageFileFilter(fmt, getFromLocale("exportSvgFilter"),
new String[] { "svg" });
break;
case FORMAT_PDF:
filter = null;
filter = new ImageFileFilter(fmt, __("exportPdfFilter"),
filter = new ImageFileFilter(fmt, getFromLocale("exportPdfFilter"),
new String[] { "pdf" });
break;
default:
@ -118,12 +106,12 @@ class ExportImage {
JFileChooser chooser = loader.createChooser();
if (circuits.size() > 1) {
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setDialogTitle(_("exportImageDirectorySelect"));
chooser.setDialogTitle(getFromLocale("exportImageDirectorySelect"));
} else {
chooser.setFileFilter(filter);
chooser.setDialogTitle(_("exportImageFileSelect"));
chooser.setDialogTitle(getFromLocale("exportImageFileSelect"));
}
int returnVal = chooser.showDialog(frame, _("exportImageButton"));
int returnVal = chooser.showDialog(frame, getFromLocale("exportImageButton"));
if (returnVal != JFileChooser.APPROVE_OPTION) return;
// Determine whether destination is valid
@ -132,8 +120,8 @@ class ExportImage {
if (dest.exists()) {
if (!dest.isDirectory()) {
int confirm = JOptionPane.showConfirmDialog(proj.getFrame(),
_("confirmOverwriteMessage"),
_("confirmOverwriteTitle"),
getFromLocale("confirmOverwriteMessage"),
getFromLocale("confirmOverwriteTitle"),
JOptionPane.YES_NO_OPTION);
if (confirm != JOptionPane.YES_OPTION) return;
}
@ -142,8 +130,8 @@ class ExportImage {
boolean created = dest.mkdir();
if (!created) {
JOptionPane.showMessageDialog(proj.getFrame(),
_("exportNewDirectoryErrorMessage"),
_("exportNewDirectoryErrorTitle"),
getFromLocale("exportNewDirectoryErrorMessage"),
getFromLocale("exportNewDirectoryErrorTitle"),
JOptionPane.YES_NO_OPTION);
return;
}
@ -152,7 +140,7 @@ class ExportImage {
// Create the progress monitor
ProgressMonitor monitor = new ProgressMonitor(frame,
_("exportImageProgress"),
getFromLocale("exportImageProgress"),
null,
0, 10000);
monitor.setMillisToDecideToPopup(100);
@ -221,13 +209,13 @@ class ExportImage {
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.insets = new Insets(5, 0, 5, 0);
gbc.fill = GridBagConstraints.NONE;
addGb(new JLabel(_("labelCircuits") + " "));
addGb(new JLabel(getFromLocale("labelCircuits") + " "));
gbc.fill = GridBagConstraints.HORIZONTAL;
addGb(new JScrollPane(list));
gbc.fill = GridBagConstraints.NONE;
gbc.gridy++;
addGb(new JLabel(_("labelImageFormat") + " "));
addGb(new JLabel(getFromLocale("labelImageFormat") + " "));
Box formatsPanel = new Box(BoxLayout.Y_AXIS);
formatsPanel.add(formatPng);
formatsPanel.add(formatGif);
@ -237,12 +225,12 @@ class ExportImage {
addGb(formatsPanel);
gbc.gridy++;
addGb(new JLabel(_("labelScale") + " "));
addGb(new JLabel(getFromLocale("labelScale") + " "));
addGb(slider);
addGb(curScale);
gbc.gridy++;
addGb(new JLabel(_("labelPrinterView") + " "));
addGb(new JLabel(getFromLocale("labelPrinterView") + " "));
addGb(printerView);
}
@ -275,9 +263,9 @@ class ExportImage {
private static class ImageFileFilter extends FileFilter {
private int type;
private String[] extensions;
private StringGetter desc;
private String desc;
private ImageFileFilter(int type, StringGetter desc, String[] exts) {
private ImageFileFilter(int type, String desc, String[] exts) {
this.type = type;
this.desc = desc;
extensions = new String[exts.length];
@ -413,7 +401,7 @@ class ExportImage {
StringWriter writer = new StringWriter();
e.printStackTrace(new PrintWriter(writer));
String stackTrace = writer.toString();
JTextArea textArea = new JTextArea( _("couldNotCreateFile") + "\n" + stackTrace);
JTextArea textArea = new JTextArea( getFromLocale("couldNotCreateFile") + "\n" + stackTrace);
JOptionPane.showMessageDialog(frame, textArea);
monitor.close();
return;
@ -431,7 +419,7 @@ class ExportImage {
((Graphics2D) g).translate(-bds.getX(), -bds.getY());
} else {
JOptionPane.showMessageDialog(frame,
_("couldNotCreateImage"));
getFromLocale("couldNotCreateImage"));
monitor.close();
}

View File

@ -18,7 +18,6 @@ import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
@ -148,7 +147,7 @@ public class Frame extends LFrame implements LocaleListener {
class MyWindowListener extends WindowAdapter {
@Override
public void windowClosing(WindowEvent e) {
if (confirmClose(_("confirmCloseTitle"))) {
if (confirmClose(getFromLocale("confirmCloseTitle"))) {
layoutCanvas.closeCanvas();
Frame.this.dispose();
}
@ -409,9 +408,9 @@ public class Frame extends LFrame implements LocaleListener {
Circuit circuit = proj.getCurrentCircuit();
String name = proj.getLogisimFile().getName();
if (circuit != null) {
s = _("titleCircFileKnown", circuit.getName(), name);
s = getFromLocale("titleCircFileKnown", circuit.getName(), name);
} else {
s = _("titleFileKnown", name);
s = getFromLocale("titleFileKnown", name);
}
this.setTitle(s);
myProjectListener.enableSave();
@ -492,19 +491,19 @@ public class Frame extends LFrame implements LocaleListener {
}
public boolean confirmClose() {
return confirmClose(_("confirmCloseTitle"));
return confirmClose(getFromLocale("confirmCloseTitle"));
}
// returns true if user is OK with proceeding
public boolean confirmClose(String title) {
String message = _("confirmDiscardMessage", proj.getLogisimFile().getName());
String message = getFromLocale("confirmDiscardMessage", proj.getLogisimFile().getName());
if (!proj.isFileDirty()) {
return true;
}
toFront();
String[] options = { _("saveOption"), _("discardOption"), _("cancelOption") };
String[] options = { getFromLocale("saveOption"), getFromLocale("discardOption"), getFromLocale("cancelOption") };
int result = JOptionPane.showOptionDialog(this,
message, title, 0, JOptionPane.QUESTION_MESSAGE, null,
options, options[0]);

View File

@ -16,16 +16,15 @@ import javax.swing.Icon;
import com.cburch.draw.toolbar.ToolbarItem;
import com.cburch.logisim.gui.menu.LogisimMenuItem;
import com.cburch.logisim.util.Icons;
import com.cburch.logisim.util.StringGetter;
class LogisimToolbarItem implements ToolbarItem {
private MenuListener menu;
private Icon icon;
private LogisimMenuItem action;
private StringGetter toolTip;
private String toolTip;
public LogisimToolbarItem(MenuListener menu, String iconName,
LogisimMenuItem action, StringGetter toolTip) {
LogisimMenuItem action, String toolTip) {
this.menu = menu;
this.icon = Icons.getIcon(iconName);
this.action = action;
@ -36,7 +35,7 @@ class LogisimToolbarItem implements ToolbarItem {
this.icon = Icons.getIcon(iconName);
}
public void setToolTip(StringGetter toolTip) {
public void setToolTip(String toolTip) {
this.toolTip = toolTip;
}

View File

@ -45,14 +45,14 @@ public class Print {
Frame frame = proj.getFrame();
if (list.getModel().getSize() == 0) {
JOptionPane.showMessageDialog(proj.getFrame(),
_("printEmptyCircuitsMessage"),
_("printEmptyCircuitsTitle"),
getFromLocale("printEmptyCircuitsMessage"),
getFromLocale("printEmptyCircuitsTitle"),
JOptionPane.YES_NO_OPTION);
return;
}
ParmsPanel parmsPanel = new ParmsPanel(list);
int action = JOptionPane.showConfirmDialog(frame,
parmsPanel, _("printParmsTitle"),
parmsPanel, getFromLocale("printParmsTitle"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (action != JOptionPane.OK_OPTION) {
@ -81,8 +81,8 @@ public class Print {
job.print();
} catch (PrinterException e) {
JOptionPane.showMessageDialog(proj.getFrame(),
_("printError", e.toString()),
_("printErrorTitle"),
getFromLocale("printError", e.toString()),
getFromLocale("printErrorTitle"),
JOptionPane.ERROR_MESSAGE);
}
}
@ -114,21 +114,21 @@ public class Print {
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.insets = new Insets(5, 0, 5, 0);
gbc.fill = GridBagConstraints.NONE;
addGb(new JLabel(_("labelCircuits") + " "));
addGb(new JLabel(getFromLocale("labelCircuits") + " "));
gbc.fill = GridBagConstraints.HORIZONTAL;
addGb(new JScrollPane(list));
gbc.fill = GridBagConstraints.NONE;
gbc.gridy++;
addGb(new JLabel(_("labelHeader") + " "));
addGb(new JLabel(getFromLocale("labelHeader") + " "));
addGb(header);
gbc.gridy++;
addGb(new JLabel(_("labelRotateToFit") + " "));
addGb(new JLabel(getFromLocale("labelRotateToFit") + " "));
addGb(rotateToFit);
gbc.gridy++;
addGb(new JLabel(_("labelPrinterView") + " "));
addGb(new JLabel(getFromLocale("labelPrinterView") + " "));
addGb(printerView);
}

View File

@ -29,17 +29,17 @@ class ProjectToolbarModel extends AbstractToolbarModel
this.frame = frame;
itemAdd = new LogisimToolbarItem(menu, "projadd.svg", LogisimMenuBar.ADD_CIRCUIT,
__("projectAddCircuitTip"));
getFromLocale("projectAddCircuitTip"));
itemUp = new LogisimToolbarItem(menu, "projup.svg", LogisimMenuBar.MOVE_CIRCUIT_UP,
__("projectMoveCircuitUpTip"));
getFromLocale("projectMoveCircuitUpTip"));
itemDown = new LogisimToolbarItem(menu, "projdown.svg", LogisimMenuBar.MOVE_CIRCUIT_DOWN,
__("projectMoveCircuitDownTip"));
getFromLocale("projectMoveCircuitDownTip"));
itemDelete = new LogisimToolbarItem(menu, "projdel.svg", LogisimMenuBar.REMOVE_CIRCUIT,
__("projectRemoveCircuitTip"));
getFromLocale("projectRemoveCircuitTip"));
itemLayout = new LogisimToolbarItem(menu, "projlayo.svg", LogisimMenuBar.EDIT_LAYOUT,
__("projectEditLayoutTip"));
getFromLocale("projectEditLayoutTip"));
itemAppearance = new LogisimToolbarItem(menu, "projapp.svg", LogisimMenuBar.EDIT_APPEARANCE,
__("projectEditAppearanceTip"));
getFromLocale("projectEditAppearanceTip"));
items = UnmodifiableList.decorate(Arrays.asList(new ToolbarItem[] {
itemAdd,

View File

@ -118,8 +118,8 @@ public class SelectionActions {
@Override
public String getName() {
return numDrops == 1 ? _("dropComponentAction")
: _("dropComponentsAction");
return numDrops == 1 ? getFromLocale("dropComponentAction")
: getFromLocale("dropComponentsAction");
}
@Override
@ -171,8 +171,8 @@ public class SelectionActions {
@Override
public String getName() {
return numAnchor == 1 ? _("dropComponentAction")
: _("dropComponentsAction");
return numAnchor == 1 ? getFromLocale("dropComponentAction")
: getFromLocale("dropComponentsAction");
}
@Override
@ -218,7 +218,7 @@ public class SelectionActions {
@Override
public String getName() {
return _("deleteSelectionAction");
return getFromLocale("deleteSelectionAction");
}
@Override
@ -247,7 +247,7 @@ public class SelectionActions {
@Override
public String getName() {
return _("duplicateSelectionAction");
return getFromLocale("duplicateSelectionAction");
}
@Override
@ -278,7 +278,7 @@ public class SelectionActions {
@Override
public String getName() {
return _("cutSelectionAction");
return getFromLocale("cutSelectionAction");
}
@Override
@ -307,7 +307,7 @@ public class SelectionActions {
@Override
public String getName() {
return _("copySelectionAction");
return getFromLocale("copySelectionAction");
}
@Override
@ -351,13 +351,13 @@ public class SelectionActions {
}
dropped.add(compFactory.getDisplayName());
} else {
String msg = _("pasteCloneQuery",
String msg = getFromLocale("pasteCloneQuery",
compFactory.getName());
Object[] opts = { _("pasteCloneReplace"),
_("pasteCloneIgnore"),
_("pasteCloneCancel") };
Object[] opts = { getFromLocale("pasteCloneReplace"),
getFromLocale("pasteCloneIgnore"),
getFromLocale("pasteCloneCancel") };
int select = JOptionPane.showOptionDialog(proj.getFrame(),
msg, _("pasteCloneTitle"), 0,
msg, getFromLocale("pasteCloneTitle"), 0,
JOptionPane.QUESTION_MESSAGE, null, opts, opts[0]);
if (select == 0) {
copyFactory = candidate;
@ -383,7 +383,7 @@ public class SelectionActions {
if (dropped != null) {
Collections.sort(dropped);
StringBuilder droppedStr = new StringBuilder();
droppedStr.append(_("pasteDropMessage"));
droppedStr.append(getFromLocale("pasteDropMessage"));
String curName = dropped.get(0);
int curCount = 1;
int lines = 1;
@ -411,7 +411,7 @@ public class SelectionActions {
area.setCaretPosition(0);
JScrollPane areaPane = new JScrollPane(area);
JOptionPane.showMessageDialog(proj.getFrame(), areaPane,
_("pasteDropTitle"),
getFromLocale("pasteDropTitle"),
JOptionPane.WARNING_MESSAGE);
}
@ -455,7 +455,7 @@ public class SelectionActions {
@Override
public String getName() {
return _("pasteClipboardAction");
return getFromLocale("pasteClipboardAction");
}
@Override
@ -518,7 +518,7 @@ public class SelectionActions {
@Override
public String getName() {
return _("moveSelectionAction");
return getFromLocale("moveSelectionAction");
}
@Override

View File

@ -31,13 +31,13 @@ class SimulationToolbarModel extends AbstractToolbarModel
this.project = project;
simEnable = new LogisimToolbarItem(menu, "simplay.svg", LogisimMenuBar.SIMULATE_ENABLE,
__("simulateEnableStepsTip"));
getFromLocale("simulateEnableStepsTip"));
simStep = new LogisimToolbarItem(menu, "simstep.svg", LogisimMenuBar.SIMULATE_STEP,
__("simulateStepTip"));
getFromLocale("simulateStepTip"));
tickEnable = new LogisimToolbarItem(menu, "simtplay.svg", LogisimMenuBar.TICK_ENABLE,
__("simulateEnableTicksTip"));
getFromLocale("simulateEnableTicksTip"));
tickStep = new LogisimToolbarItem(menu, "simtstep.svg", LogisimMenuBar.TICK_STEP,
__("simulateTickTip"));
getFromLocale("simulateTickTip"));
items = UnmodifiableList.decorate(Arrays.asList(new ToolbarItem[] {
simEnable,
@ -76,11 +76,11 @@ class SimulationToolbarModel extends AbstractToolbarModel
boolean running = sim != null && sim.isRunning();
boolean ticking = sim != null && sim.isTicking();
simEnable.setIcon(running ? "simstop.svg" : "simplay.svg");
simEnable.setToolTip(running ? __("simulateDisableStepsTip")
: __("simulateEnableStepsTip"));
simEnable.setToolTip(running ? getFromLocale("simulateDisableStepsTip")
: getFromLocale("simulateEnableStepsTip"));
tickEnable.setIcon(ticking ? "simtstop.svg" : "simtplay.svg");
tickEnable.setToolTip(ticking ? __("simulateDisableTicksTip")
: __("simulateEnableTicksTip"));
tickEnable.setToolTip(ticking ? getFromLocale("simulateDisableTicksTip")
: getFromLocale("simulateEnableTicksTip"));
fireToolbarAppearanceChanged();
}
}

View File

@ -61,11 +61,11 @@ public class StatisticsDialog extends JDialog implements ActionListener {
@Override
public String getColumnName(int column) {
switch (column) {
case 0: return _("statsComponentColumn");
case 1: return _("statsLibraryColumn");
case 2: return _("statsSimpleCountColumn");
case 3: return _("statsUniqueCountColumn");
case 4: return _("statsRecursiveCountColumn");
case 0: return getFromLocale("statsComponentColumn");
case 1: return getFromLocale("statsLibraryColumn");
case 2: return getFromLocale("statsSimpleCountColumn");
case 3: return getFromLocale("statsUniqueCountColumn");
case 4: return getFromLocale("statsRecursiveCountColumn");
// should never happen
default: return "??";
}
@ -91,9 +91,9 @@ public class StatisticsDialog extends JDialog implements ActionListener {
if (row < countsLen) {
return count.getFactory().getDisplayName();
} else if (row == countsLen) {
return _("statsTotalWithout");
return getFromLocale("statsTotalWithout");
} else {
return _("statsTotalWith");
return getFromLocale("statsTotalWith");
}
case 1:
if (row < countsLen) {
@ -156,17 +156,17 @@ public class StatisticsDialog extends JDialog implements ActionListener {
StatisticsTableModel model) {
super(parent, true);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setTitle(_("statsDialogTitle", circuitName));
setTitle(getFromLocale("statsDialogTitle", circuitName));
JTable table = new StatisticsTable();
TableSorter mySorter = new TableSorter(model, table.getTableHeader());
Comparator<String> comp = new CompareString("",
_("statsTotalWithout"), _("statsTotalWith"));
getFromLocale("statsTotalWithout"), getFromLocale("statsTotalWith"));
mySorter.setColumnComparator(String.class, comp);
table.setModel(mySorter);
JScrollPane tablePane = new JScrollPane(table);
JButton button = new JButton(_("statsCloseButton"));
JButton button = new JButton(getFromLocale("statsCloseButton"));
button.addActionListener(this);
JPanel buttonPanel = new JPanel();
buttonPanel.add(button);

View File

@ -144,10 +144,10 @@ class TickCounter implements SimulatorListener {
if (min >= 1000.0) {
return _("tickRateKHz",
return getFromLocale("tickRateKHz",
roundString(rate / 1000.0, min / 1000.0));
} else {
return _("tickRateHz", roundString(rate, min));
return getFromLocale("tickRateHz", roundString(rate, min));
}
}
}

View File

@ -37,7 +37,7 @@ public class ToolAttributeAction extends Action {
@Override
public String getName() {
return _("changeToolAttrAction");
return getFromLocale("changeToolAttrAction");
}
@Override

View File

@ -23,13 +23,13 @@ class ToolboxToolbarModel extends AbstractToolbarModel
public ToolboxToolbarModel(MenuListener menu) {
itemAdd = new LogisimToolbarItem(menu, "projadd.svg", LogisimMenuBar.ADD_CIRCUIT,
__("projectAddCircuitTip"));
getFromLocale("projectAddCircuitTip"));
itemUp = new LogisimToolbarItem(menu, "projup.svg", LogisimMenuBar.MOVE_CIRCUIT_UP,
__("projectMoveCircuitUpTip"));
getFromLocale("projectMoveCircuitUpTip"));
itemDown = new LogisimToolbarItem(menu, "projdown.svg", LogisimMenuBar.MOVE_CIRCUIT_DOWN,
__("projectMoveCircuitDownTip"));
getFromLocale("projectMoveCircuitDownTip"));
itemDelete = new LogisimToolbarItem(menu, "projdel.svg", LogisimMenuBar.REMOVE_CIRCUIT,
__("projectRemoveCircuitTip"));
getFromLocale("projectRemoveCircuitTip"));
items = UnmodifiableList.decorate(Arrays.asList(new ToolbarItem[] {
itemAdd,

View File

@ -42,19 +42,19 @@ public abstract class EditPopup extends JPopupMenu {
protected void initialize() {
boolean x = false;
x |= add(LogisimMenuBar.CUT, _("editCutItem"));
x |= add(LogisimMenuBar.COPY, _("editCopyItem"));
x |= add(LogisimMenuBar.CUT, getFromLocale("editCutItem"));
x |= add(LogisimMenuBar.COPY, getFromLocale("editCopyItem"));
if (x) { addSeparator(); x = false; }
x |= add(LogisimMenuBar.DELETE, _("editClearItem"));
x |= add(LogisimMenuBar.DUPLICATE, _("editDuplicateItem"));
x |= add(LogisimMenuBar.DELETE, getFromLocale("editClearItem"));
x |= add(LogisimMenuBar.DUPLICATE, getFromLocale("editDuplicateItem"));
if (x) { addSeparator(); x = false; }
x |= add(LogisimMenuBar.RAISE, _("editRaiseItem"));
x |= add(LogisimMenuBar.LOWER, _("editLowerItem"));
x |= add(LogisimMenuBar.RAISE_TOP, _("editRaiseTopItem"));
x |= add(LogisimMenuBar.LOWER_BOTTOM, _("editLowerBottomItem"));
x |= add(LogisimMenuBar.RAISE, getFromLocale("editRaiseItem"));
x |= add(LogisimMenuBar.LOWER, getFromLocale("editLowerItem"));
x |= add(LogisimMenuBar.RAISE_TOP, getFromLocale("editRaiseTopItem"));
x |= add(LogisimMenuBar.LOWER_BOTTOM, getFromLocale("editLowerBottomItem"));
if (x) { addSeparator(); x = false; }
x |= add(LogisimMenuBar.ADD_CONTROL, _("editAddControlItem"));
x |= add(LogisimMenuBar.REMOVE_CONTROL, _("editRemoveControlItem"));
x |= add(LogisimMenuBar.ADD_CONTROL, getFromLocale("editAddControlItem"));
x |= add(LogisimMenuBar.REMOVE_CONTROL, getFromLocale("editRemoveControlItem"));
if (!x && getComponentCount() > 0) { remove(getComponentCount() - 1); }
}

View File

@ -26,12 +26,12 @@ class MenuEdit extends Menu {
Action last = proj == null ? null : proj.getLastAction();
if( last == null )
{
undo.setText( _( "editCantUndoItem" ) );
undo.setText( getFromLocale( "editCantUndoItem" ) );
undo.setEnabled( false );
}
else
{
undo.setText( _( "editUndoItem", last.getName() ) );
undo.setText( getFromLocale( "editUndoItem", last.getName() ) );
undo.setEnabled( true );
}
@ -45,7 +45,7 @@ class MenuEdit extends Menu {
// Set the detailed, localized text
redo.setText( _( "editRedoItem", lastRedo.getName() ) );
redo.setText( getFromLocale( "editRedoItem", lastRedo.getName() ) );
// Set it to enabled
redo.setEnabled( true );
@ -53,7 +53,7 @@ class MenuEdit extends Menu {
else
{ // If there is no project...
// Let them know they can't redo anything
redo.setText( _( "editCantRedoItem" ) );
redo.setText( getFromLocale( "editCantRedoItem" ) );
// And disable the button
redo.setEnabled( false );
@ -167,20 +167,20 @@ class MenuEdit extends Menu {
}
public void localeChanged() {
this.setText(_("editMenu"));
this.setText(getFromLocale("editMenu"));
myListener.projectChanged(null);
cut.setText(_("editCutItem"));
copy.setText(_("editCopyItem"));
paste.setText(_("editPasteItem"));
delete.setText(_("editClearItem"));
dup.setText(_("editDuplicateItem"));
selall.setText(_("editSelectAllItem"));
raise.setText(_("editRaiseItem"));
lower.setText(_("editLowerItem"));
raiseTop.setText(_("editRaiseTopItem"));
lowerBottom.setText(_("editLowerBottomItem"));
addCtrl.setText(_("editAddControlItem"));
remCtrl.setText(_("editRemoveControlItem"));
cut.setText(getFromLocale("editCutItem"));
copy.setText(getFromLocale("editCopyItem"));
paste.setText(getFromLocale("editPasteItem"));
delete.setText(getFromLocale("editClearItem"));
dup.setText(getFromLocale("editDuplicateItem"));
selall.setText(getFromLocale("editSelectAllItem"));
raise.setText(getFromLocale("editRaiseItem"));
lower.setText(getFromLocale("editLowerItem"));
raiseTop.setText(getFromLocale("editRaiseTopItem"));
lowerBottom.setText(getFromLocale("editLowerBottomItem"));
addCtrl.setText(getFromLocale("editAddControlItem"));
remCtrl.setText(getFromLocale("editRemoveControlItem"));
}
@Override

View File

@ -92,17 +92,17 @@ class MenuFile extends Menu implements ActionListener {
}
public void localeChanged() {
this.setText(_("fileMenu"));
newi.setText(_("fileNewItem"));
open.setText(_("fileOpenItem"));
this.setText(getFromLocale("fileMenu"));
newi.setText(getFromLocale("fileNewItem"));
open.setText(getFromLocale("fileOpenItem"));
openRecent.localeChanged();
close.setText(_("fileCloseItem"));
save.setText(_("fileSaveItem"));
saveAs.setText(_("fileSaveAsItem"));
exportImage.setText(_("fileExportImageItem"));
print.setText(_("filePrintItem"));
prefs.setText(_("filePreferencesItem"));
quit.setText(_("fileQuitItem"));
close.setText(getFromLocale("fileCloseItem"));
save.setText(getFromLocale("fileSaveItem"));
saveAs.setText(getFromLocale("fileSaveAsItem"));
exportImage.setText(getFromLocale("fileExportImageItem"));
print.setText(getFromLocale("filePrintItem"));
prefs.setText(getFromLocale("filePreferencesItem"));
quit.setText(getFromLocale("fileQuitItem"));
}
@Override

View File

@ -14,7 +14,6 @@ import java.util.Locale;
import javax.help.HelpSet;
import javax.help.JHelp;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
@ -52,14 +51,14 @@ class MenuHelp extends JMenu implements ActionListener {
}
public void localeChanged() {
this.setText(_("helpMenu"));
this.setText(getFromLocale("helpMenu"));
if (helpFrame != null) {
helpFrame.setTitle(_("helpWindowTitle"));
helpFrame.setTitle(getFromLocale("helpWindowTitle"));
}
tutorial.setText(_("helpTutorialItem"));
guide.setText(_("helpGuideItem"));
library.setText(_("helpLibraryItem"));
about.setText(_("helpAboutItem"));
tutorial.setText(getFromLocale("helpTutorialItem"));
guide.setText(getFromLocale("helpGuideItem"));
library.setText(getFromLocale("helpLibraryItem"));
about.setText(getFromLocale("helpAboutItem"));
if (helpFrame != null) {
helpFrame.setLocale(Locale.getDefault());
loadBroker();
@ -81,7 +80,7 @@ class MenuHelp extends JMenu implements ActionListener {
}
private void loadBroker() {
String helpUrl = _("helpsetUrl");
String helpUrl = getFromLocale("helpsetUrl");
if (helpUrl == null) {
helpUrl = "doc/doc_en.hs";
}
@ -93,7 +92,7 @@ class MenuHelp extends JMenu implements ActionListener {
if (hsURL == null) {
disableHelp();
JOptionPane.showMessageDialog(menubar.getParentWindow(),
_("helpNotFoundError"));
getFromLocale("helpNotFoundError"));
return;
}
helpSetUrl = helpUrl;
@ -101,7 +100,7 @@ class MenuHelp extends JMenu implements ActionListener {
helpComponent = new JHelp(helpSet);
if (helpFrame == null) {
helpFrame = new LFrame();
helpFrame.setTitle(_("helpWindowTitle"));
helpFrame.setTitle(getFromLocale("helpWindowTitle"));
helpFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
helpFrame.getContentPane().add(helpComponent);
helpFrame.pack();
@ -114,7 +113,7 @@ class MenuHelp extends JMenu implements ActionListener {
disableHelp();
e.printStackTrace();
JOptionPane.showMessageDialog(menubar.getParentWindow(),
_("helpUnavailableError"));
getFromLocale("helpUnavailableError"));
return;
}
}
@ -130,7 +129,7 @@ class MenuHelp extends JMenu implements ActionListener {
disableHelp();
e.printStackTrace();
JOptionPane.showMessageDialog(menubar.getParentWindow(),
_("helpDisplayError"));
getFromLocale("helpDisplayError"));
}
}

Some files were not shown because too many files have changed in this diff Show More