Search in sources :

Example 6 with AttributeException

use of doc.attributes.AttributeException in project OpenNotebook by jaltekruse.

the class BasicAddition method setAttributes.

@Override
protected void setAttributes() {
    setName("Basic Addition");
    setAuthor("Open Notebook Staff");
    setDirections("Simplify.");
    try {
        this.setAttributeValue(UUID_STR, new UUID(2846184626069213495L, 3575720896865422970L));
        addTags("Arithmetic", "Addition", "Integers");
    } catch (AttributeException e) {
        // should not be thrown
        e.printStackTrace();
    }
    setDate(new Date(2, 1, 2011));
}
Also used : UUID(java.util.UUID) AttributeException(doc.attributes.AttributeException) Date(doc.attributes.Date)

Example 7 with AttributeException

use of doc.attributes.AttributeException in project OpenNotebook by jaltekruse.

the class BasicAdditionAndSubraction method setAttributes.

@Override
protected void setAttributes() {
    setName("Basic Addition and Subtraction");
    setAuthor("Open Notebook Staff");
    setDirections("Simplify.");
    try {
        this.setAttributeValue(UUID_STR, new UUID(282048723434478295L, 3549720219560301290L));
        getTags().addValueWithString("Arithmetic");
        getTags().addValueWithString("Addition");
        getTags().addValueWithString("Integers");
        getTags().addValueWithString("Negative Numbers");
        getTags().addValueWithString("Subtraction");
        getTags().addValueWithString("Negation");
    } catch (AttributeException e) {
        // should not be thrown
        throw new RuntimeException(e);
    }
    setDate(new Date(2, 1, 2011));
}
Also used : UUID(java.util.UUID) AttributeException(doc.attributes.AttributeException) Date(doc.attributes.Date)

Example 8 with AttributeException

use of doc.attributes.AttributeException in project OpenNotebook by jaltekruse.

the class BasicArithmeticExpression method setAttributes.

@Override
protected void setAttributes() {
    setName("Basic Arithmetic Expression");
    setAuthor("Open Notebook Staff");
    setDirections("Simplify.");
    try {
        this.setAttributeValue(UUID_STR, new UUID(4234031236056521345L, 2345748762121345701L));
        getTags().addValueWithString("Arithmetic");
        getTags().addValueWithString("Addition");
        getTags().addValueWithString("Subtraction");
        getTags().addValueWithString("Multiplication");
        getTags().addValueWithString("Dividison");
        getTags().addValueWithString("Integers");
    } catch (AttributeException e) {
        // should not be thrown
        throw new RuntimeException(e);
    }
    setDate(new Date(2, 1, 2011));
}
Also used : UUID(java.util.UUID) AttributeException(doc.attributes.AttributeException) Date(doc.attributes.Date)

Example 9 with AttributeException

use of doc.attributes.AttributeException in project OpenNotebook by jaltekruse.

the class BasicAssociativeProperty method setAttributes.

@Override
protected void setAttributes() {
    setName("Basic Associative Property Problem");
    setAuthor("Open Notebook Staff");
    setDirections("Simplify. Use the associative and commutative properties of addition and multiplication" + " to reorder and regroup the numbers into easier calculations.");
    try {
        this.setAttributeValue(UUID_STR, new UUID(4470592837206498305L, 1948027489360475701L));
        getTags().addValueWithString("Arithmetic");
        getTags().addValueWithString("Addition");
        getTags().addValueWithString("Multiplication");
        getTags().addValueWithString("Integers");
        getTags().addValueWithString("Mental Math");
    } catch (AttributeException e) {
        // should not be thrown
        throw new RuntimeException(e);
    }
    setDate(new Date(2, 1, 2011));
}
Also used : UUID(java.util.UUID) AttributeException(doc.attributes.AttributeException) Date(doc.attributes.Date)

Example 10 with AttributeException

use of doc.attributes.AttributeException in project OpenNotebook by jaltekruse.

the class GenericAdjustmentPanel method addPanelContent.

@Override
public void addPanelContent() {
    setLayout(new GridBagLayout());
    GridBagConstraints con = new GridBagConstraints();
    con.fill = GridBagConstraints.HORIZONTAL;
    con.weightx = .1;
    con.gridx = 0;
    con.gridy = 0;
    con.insets = new Insets(0, 5, 0, 5);
    add(new JLabel(mAtt.getName()), con);
    field = new JTextField();
    con.weightx = 1;
    con.gridx = 1;
    con.insets = new Insets(0, 0, 0, 0);
    add(field, con);
    if (mAtt.getValue() instanceof Double) {
        int len = mAtt.getValue().toString().length();
        if (len > 5) {
            formatter = new Formatter();
            field.setText(String.format("%.5G", mAtt.getValue()));
        }
    } else {
        if (mAtt.getValue() == null) {
            field.setText("");
        } else
            field.setText(mAtt.getValue().toString());
    }
    field.addFocusListener(new FocusListener() {

        @Override
        public void focusGained(FocusEvent arg0) {
        }

        @Override
        public void focusLost(FocusEvent arg0) {
            try {
                if (mAtt.getParentObject() != null) {
                    mAtt.getParentObject().setAttributeValueWithString(mAtt.getName(), field.getText());
                } else {
                    mAtt.setValueWithString(field.getText());
                }
                if (notebookPanel != null) {
                    notebookPanel.getCurrentDocViewer().repaintDoc();
                    notebookPanel.getCurrentDocViewer().updateObjectToolFrame();
                }
            } catch (AttributeException e) {
                if (!showingDialog) {
                    JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
                    showingDialog = false;
                }
            }
        }
    });
    field.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            applyPanelValueToObject();
        }
    });
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) Formatter(java.util.Formatter) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) FocusEvent(java.awt.event.FocusEvent) AttributeException(doc.attributes.AttributeException) ActionListener(java.awt.event.ActionListener) FocusListener(java.awt.event.FocusListener)

Aggregations

AttributeException (doc.attributes.AttributeException)20 Date (doc.attributes.Date)9 UUID (java.util.UUID)9 StringAttribute (doc.attributes.StringAttribute)4 Node (expression.Node)3 NodeException (expression.NodeException)3 Vector (java.util.Vector)3 MathObjectAttribute (doc.attributes.MathObjectAttribute)2 GridBagConstraints (java.awt.GridBagConstraints)2 Insets (java.awt.Insets)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 JLabel (javax.swing.JLabel)2 Document (doc.Document)1 GridPoint (doc.GridPoint)1 Page (doc.Page)1 ProblemDatabase (doc.ProblemDatabase)1 BooleanAttribute (doc.attributes.BooleanAttribute)1 DoubleAttribute (doc.attributes.DoubleAttribute)1 GridPointAttribute (doc.attributes.GridPointAttribute)1