Search in sources :

Example 1 with LineBreaker

use of de.neemann.gui.LineBreaker in project Digital by hneemann.

the class GenerateFile method generate.

@Override
public void generate(JDialog parent, File circuitFile, TruthTable table, ExpressionListenerStore expressions) throws Exception {
    ModelAnalyserInfo mai = table.getModelAnalyzerInfo();
    if (mai == null) {
        JOptionPane.showMessageDialog(parent, new LineBreaker().toHTML().breakLines(Lang.get("msg_circuitIsRequired")), Lang.get("msg_warning"), JOptionPane.WARNING_MESSAGE);
        return;
    } else {
        ArrayList<String> pinsWithoutNumber = mai.getPinsWithoutNumber();
        if (!pinsWithoutNumber.isEmpty()) {
            int res = JOptionPane.showConfirmDialog(parent, new LineBreaker().toHTML().breakLines(Lang.get("msg_thereAreMissingPinNumbers", pinsWithoutNumber)), Lang.get("msg_warning"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
            if (res != JOptionPane.OK_OPTION)
                return;
        }
    }
    if (circuitFile == null)
        circuitFile = new File("circuit." + suffix);
    else
        circuitFile = SaveAsHelper.checkSuffix(circuitFile, suffix);
    JFileChooser fileChooser = new MyFileChooser();
    fileChooser.setFileFilter(new FileNameExtensionFilter("JEDEC", suffix));
    fileChooser.setSelectedFile(circuitFile);
    if (fileChooser.showSaveDialog(parent) == JFileChooser.APPROVE_OPTION) {
        ExpressionToFileExporter expressionExporter = factory.create();
        expressionExporter.getPinMapping().addAll(mai.getPins());
        expressionExporter.getPinMapping().setClockPin(mai.getClockPinInt());
        new BuilderExpressionCreator(expressionExporter.getBuilder(), ExpressionModifier.IDENTITY).create(expressions);
        expressionExporter.export(SaveAsHelper.checkSuffix(fileChooser.getSelectedFile(), suffix));
    }
}
Also used : MyFileChooser(de.neemann.gui.MyFileChooser) ModelAnalyserInfo(de.neemann.digital.analyse.ModelAnalyserInfo) ExpressionToFileExporter(de.neemann.digital.builder.ExpressionToFileExporter) LineBreaker(de.neemann.gui.LineBreaker) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) File(java.io.File) BuilderExpressionCreator(de.neemann.digital.gui.components.table.BuilderExpressionCreator)

Example 2 with LineBreaker

use of de.neemann.gui.LineBreaker in project Digital by hneemann.

the class LibraryNode method getToolTipText.

/**
 * @return the tool tip text
 */
public String getToolTipText() {
    if (isCustom()) {
        if (isUnique()) {
            if (description == null) {
                if (toolTipText == null) {
                    try {
                        LOGGER.debug("load tooltip from " + file);
                        Circuit c = Circuit.loadCircuit(file, null);
                        toolTipText = new LineBreaker().toHTML().breakLines(c.getAttributes().get(Keys.DESCRIPTION));
                    } catch (Exception e) {
                        toolTipText = Lang.get("msg_fileNotImportedYet");
                    }
                }
                return toolTipText;
            } else
                return new LineBreaker().toHTML().breakLines(description.getDescription(new ElementAttributes()));
        } else
            return Lang.get("msg_fileIsNotUnique");
    } else
        return new LineBreaker().toHTML().breakLines(Lang.getNull("elem_" + getName() + "_tt"));
}
Also used : Circuit(de.neemann.digital.draw.elements.Circuit) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) LineBreaker(de.neemann.gui.LineBreaker) IOException(java.io.IOException)

Aggregations

LineBreaker (de.neemann.gui.LineBreaker)2 ModelAnalyserInfo (de.neemann.digital.analyse.ModelAnalyserInfo)1 ExpressionToFileExporter (de.neemann.digital.builder.ExpressionToFileExporter)1 ElementAttributes (de.neemann.digital.core.element.ElementAttributes)1 Circuit (de.neemann.digital.draw.elements.Circuit)1 BuilderExpressionCreator (de.neemann.digital.gui.components.table.BuilderExpressionCreator)1 MyFileChooser (de.neemann.gui.MyFileChooser)1 File (java.io.File)1 IOException (java.io.IOException)1 FileNameExtensionFilter (javax.swing.filechooser.FileNameExtensionFilter)1