minor refactoring of ATF150X fitter start

This commit is contained in:
hneemann 2017-06-18 10:46:48 +02:00
parent 1af390e521
commit ffed7c1570
4 changed files with 74 additions and 49 deletions

View File

@ -21,13 +21,28 @@ public class StartATF1502Fitter implements ExpressionToFileExporter.PostProcess
private final JDialog parent;
private final File fitterExe;
private static File getFitterExe(String fitterName) {
File fitter = Settings.getInstance().get(Keys.SETTINGS_ATF1502_FITTER);
return new File(fitter.getParentFile(), fitterName);
}
/**
* Creates a new instance
*
* @param parent the parent dialog
*/
public StartATF1502Fitter(JDialog parent) {
this(parent, Settings.getInstance().get(Keys.SETTINGS_ATF1502_FITTER));
this(parent, getFitterExe("fit1502.exe"));
}
/**
* Creates a new instance
*
* @param parent the parent dialog
* @param fitterName name of the needed fitter
*/
StartATF1502Fitter(JDialog parent, String fitterName) {
this(parent, getFitterExe(fitterName));
}
/**
@ -36,7 +51,7 @@ public class StartATF1502Fitter implements ExpressionToFileExporter.PostProcess
* @param parent the parent dialog
* @param fitterExe fitter executable
*/
public StartATF1502Fitter(JDialog parent, File fitterExe) {
private StartATF1502Fitter(JDialog parent, File fitterExe) {
this.parent = parent;
this.fitterExe = fitterExe;
}

View File

@ -1,10 +1,6 @@
package de.neemann.digital.builder.tt2;
import de.neemann.digital.core.element.Keys;
import de.neemann.digital.gui.Settings;
import javax.swing.*;
import java.io.File;
/**
* StartATF1504Fitter start the fitter for ATF1504
@ -12,15 +8,11 @@ import java.io.File;
*/
public class StartATF1504Fitter extends StartATF1502Fitter {
/**
* Creates a new intance
* Creates a new instance
*
* @param parent the parent dialog
*/
public StartATF1504Fitter(JDialog parent) {
super(parent, getATF1504(Settings.getInstance().get(Keys.SETTINGS_ATF1502_FITTER)));
}
private static File getATF1504(File file) {
return new File(file.getParentFile(), "fit1504.exe");
super(parent, "fit1504.exe");
}
}

View File

@ -0,0 +1,18 @@
package de.neemann.digital.builder.tt2;
import javax.swing.*;
/**
* StartATF1504Fitter start the fitter for ATF1504
* Created by hneemann on 12.03.17.
*/
public class StartATF1508Fitter extends StartATF1502Fitter {
/**
* Creates a new instance
*
* @param parent the parent dialog
*/
public StartATF1508Fitter(JDialog parent) {
super(parent, "fit1508.exe");
}
}

View File

@ -228,7 +228,7 @@ public class TableDialog extends JDialog {
if (pins.containsKey(name))
attr.set(Keys.PIN, pins.get(name).toString());
ElementAttributes modified = new AttributeDialog(this, pos, LIST, attr).showDialog();
if (modified!=null) {
if (modified != null) {
pins.remove(name);
final String newName = modified.get(Keys.LABEL).trim().replace(' ', '_');
final String pinStr = modified.get(Keys.PIN).trim();
@ -457,48 +457,48 @@ public class TableDialog extends JDialog {
hardware.add(gal22v10);
JMenu atf1502 = new JMenu("ATF1502");
atf1502.add(new ToolTipAction(Lang.get("menu_table_createCUPL")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
createCUPL(new ATF1502CuplExporter());
}
}.setToolTip(Lang.get("menu_table_createCUPL_tt")).createJMenuItem());
atf1502.add(new ToolTipAction(Lang.get("menu_table_createTT2")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
createHardware(
new ExpressionToFileExporter(new ATF1502TT2Exporter(filename.getName()))
.addProcessingStep(new StartATF1502Fitter(TableDialog.this))
.addProcessingStep(new CreateCHN("ATF1502AS")), filename, "tt2");
}
}.setToolTip(Lang.get("menu_table_createTT2_tt")).createJMenuItem());
hardware.add(atf1502);
JMenu atf1504 = new JMenu("ATF1504");
atf1504.add(new ToolTipAction(Lang.get("menu_table_createCUPL")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
createCUPL(new ATF1504CuplExporter());
}
}.setToolTip(Lang.get("menu_table_createCUPL_tt")).createJMenuItem());
atf1504.add(new ToolTipAction(Lang.get("menu_table_createTT2")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
createHardware(
new ExpressionToFileExporter(new ATF1504TT2Exporter(filename.getName()))
.addProcessingStep(new StartATF1504Fitter(TableDialog.this))
.addProcessingStep(new CreateCHN("ATF1504AS")), filename, "tt2");
}
}.setToolTip(Lang.get("menu_table_createTT2_tt")).createJMenuItem());
hardware.add(atf1504);
hardware.add(createATF150XExporterMenu("ATF1502",
new ATF1502CuplExporter(),
new ExpressionToFileExporter(new ATF1502TT2Exporter(filename.getName()))
.addProcessingStep(new StartATF1502Fitter(TableDialog.this))
.addProcessingStep(new CreateCHN("ATF1502AS"))
));
hardware.add(createATF150XExporterMenu("ATF1504",
new ATF1504CuplExporter(),
new ExpressionToFileExporter(new ATF1504TT2Exporter(filename.getName()))
.addProcessingStep(new StartATF1504Fitter(TableDialog.this))
.addProcessingStep(new CreateCHN("ATF1504AS"))
));
/*
hardware.add(createATF150XExporterMenu("ATF1508",
new ATF1508CuplExporter(),
new ExpressionToFileExporter(new ATF1508TT2Exporter(filename.getName()))
.addProcessingStep(new StartATF1508Fitter(TableDialog.this))
.addProcessingStep(new CreateCHN("ATF1508AS"))
));*/
createMenu.add(hardware);
return createMenu;
}
private JMenuItem createATF150XExporterMenu(String menuName, CuplExporter cuplExporter, ExpressionToFileExporter expressionToFileExporter) {
JMenu menu = new JMenu(menuName);
menu.add(new ToolTipAction(Lang.get("menu_table_createCUPL")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
createCUPL(cuplExporter);
}
}.setToolTip(Lang.get("menu_table_createCUPL_tt")).createJMenuItem());
menu.add(new ToolTipAction(Lang.get("menu_table_createTT2")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
createHardware(expressionToFileExporter, filename, "tt2");
}
}.setToolTip(Lang.get("menu_table_createTT2_tt")).createJMenuItem());
return menu;
}
private boolean createHardware(ExpressionToFileExporter expressionExporter, File filename, String suffix) {
boolean result = false;
if (filename == null)