fixed problems related to frame-dialog relations

This commit is contained in:
hneemann 2016-05-15 12:33:55 +02:00
parent 83b29b0caf
commit 2a06732162
4 changed files with 24 additions and 15 deletions

View File

@ -40,15 +40,24 @@ public final class Not implements Expression {
}
/**
* Protects this not against simplification
* Protects this not against simplification.
* So it is possible to create a NAnd: You can create an And and protect the outer Not.
* No simplification will take place in this case and you will end up with a NAnd gate.
*
* @return this for call chaning
* @return this for call chaining
*/
public Not protect() {
protect = true;
return this;
}
/**
* @return true if this not is protected.
*/
public boolean isProtected() {
return protect;
}
@Override
public boolean calculate(Context context) throws ExpressionException {
return !expression.calculate(context);

View File

@ -20,7 +20,7 @@ import de.neemann.digital.draw.shapes.ShapeFactory;
import de.neemann.digital.gui.components.*;
import de.neemann.digital.gui.components.data.DataSetDialog;
import de.neemann.digital.gui.components.listing.ROMListingDialog;
import de.neemann.digital.gui.components.table.TableFrame;
import de.neemann.digital.gui.components.table.TableDialog;
import de.neemann.digital.gui.state.State;
import de.neemann.digital.gui.state.StateManager;
import de.neemann.digital.lang.Lang;
@ -445,7 +445,7 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E
public void actionPerformed(ActionEvent e) {
try {
Model model = new ModelDescription(circuitComponent.getCircuit(), library).createModel(false);
new TableFrame(Main.this, new ModelAnalyser(model).analyse(), shapeFactory).setVisible(true);
new TableDialog(Main.this, new ModelAnalyser(model).analyse(), shapeFactory).setVisible(true);
elementState.activate();
} catch (PinException | NodeException | AnalyseException e1) {
showErrorAndStopModel(Lang.get("msg_annalyseErr"), e1);
@ -459,7 +459,7 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E
@Override
public void actionPerformed(ActionEvent e) {
TruthTable tt = new TruthTable(3).addResult();
new TableFrame(Main.this, tt, shapeFactory).setVisible(true);
new TableDialog(Main.this, tt, shapeFactory).setVisible(true);
elementState.activate();
}
}

View File

@ -10,7 +10,7 @@ import java.awt.*;
*
* @author hneemann
*/
public class AllSolutionsFrame extends JDialog {
public class AllSolutionsDialog extends JDialog {
private final JTextArea textArea;
/**
@ -19,7 +19,7 @@ public class AllSolutionsFrame extends JDialog {
* @param owner the owner frame
* @param font the font to use
*/
public AllSolutionsFrame(Frame owner, Font font) {
public AllSolutionsDialog(JFrame owner, Font font) {
super(owner, Lang.get("win_allSolutions"), false);
setDefaultCloseOperation(HIDE_ON_CLOSE);
@ -39,7 +39,7 @@ public class AllSolutionsFrame extends JDialog {
* @param text the text
* @return this for call chaining
*/
public AllSolutionsFrame setText(String text) {
public AllSolutionsDialog setText(String text) {
textArea.setText(text);
return this;
}

View File

@ -36,7 +36,7 @@ import java.util.HashSet;
/**
* @author hneemann
*/
public class TableFrame extends JFrame {
public class TableDialog extends JDialog {
private static final Color MYGRAY = new Color(230, 230, 230);
private final JLabel label;
private final JTable table;
@ -49,7 +49,7 @@ public class TableFrame extends JFrame {
private TruthTableTableModel model;
private TableColumn column;
private int columnIndex;
private AllSolutionsFrame allSolutionsFrame;
private AllSolutionsDialog allSolutionsDialog;
private int variables;
/**
@ -58,8 +58,8 @@ public class TableFrame extends JFrame {
* @param parent the parent frame
* @param truthTable the table to show
*/
public TableFrame(JFrame parent, TruthTable truthTable, ShapeFactory shapeFactory) {
super(Lang.get("win_table"));
public TableDialog(JFrame parent, TruthTable truthTable, ShapeFactory shapeFactory) {
super(parent, Lang.get("win_table"));
this.shapeFactory = shapeFactory;
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
@ -73,7 +73,7 @@ public class TableFrame extends JFrame {
table.setDefaultRenderer(Integer.class, new CenterDefaultTableCellRenderer());
table.setRowHeight(25);
allSolutionsFrame = new AllSolutionsFrame(this, font);
allSolutionsDialog = new AllSolutionsDialog(parent, font);
header = table.getTableHeader();
header.addMouseListener(new MouseAdapter() {
@ -263,14 +263,14 @@ public class TableFrame extends JFrame {
sb.append(expr);
count++;
if (count == 2)
allSolutionsFrame.setVisible(true);
allSolutionsDialog.setVisible(true);
}
}.create();
if (sb.length() == 0)
label.setText("");
allSolutionsFrame.setText(sb.toString());
allSolutionsDialog.setText(sb.toString());
} catch (ExpressionException | FormatterException e1) {
new ErrorMessage(Lang.get("msg_errorDuringCalculation")).addCause(e1).show();
}