Search in sources :

Example 1 with Status

use of com.dsoft.pb.idef.elements.Status in project ramus by Vitaliy-Yakovchuk.

the class StatusPlugin method getAttributeConverter.

@Override
public AttributeConverter getAttributeConverter() {
    return new SimpleAttributeConverter() {

        @Override
        protected Object toObject(Persistent persistent) {
            StatusPersistent p = (StatusPersistent) persistent;
            return new Status(p.getType(), p.getOtherName());
        }

        @Override
        protected Persistent toPersistent(Object value) {
            StatusPersistent p = new StatusPersistent();
            Status s = (Status) value;
            p.setOtherName(s.getAtherName());
            p.setType(s.getType());
            return p;
        }
    };
}
Also used : Status(com.dsoft.pb.idef.elements.Status) Persistent(com.ramussoft.common.persistent.Persistent) SimpleAttributeConverter(com.ramussoft.core.attribute.simple.SimpleAttributeConverter)

Example 2 with Status

use of com.dsoft.pb.idef.elements.Status in project ramus by Vitaliy-Yakovchuk.

the class NFunction method setDefaultValues.

public void setDefaultValues() {
    boolean inTransaction = false;
    if (engine instanceof Journaled) {
        inTransaction = ((Journaled) engine).isUserTransactionStarted();
        if (!inTransaction)
            ((Journaled) engine).startUserTransaction();
    }
    setSectorData(new byte[0]);
    setBackground(Options.getColor("DEFAULD_FUNCTIONAL_BLOCK_COLOR", Color.white));
    setForeground(Options.getColor("DEFAULD_FUNCTIONAL_BLOCK_TEXT_COLOR", Color.black));
    setBounds(new FRectangle(IDEFPanel.DEFAULT_X, IDEFPanel.DEFAULT_Y, IDEFPanel.DEFAULT_WIDTH * 1.2, IDEFPanel.DEFAULT_HEIGHT * 1.2));
    setFont(Options.getFont("DEFAULT_FUNCTIONAL_BLOCK_FONT", new Font("Dialog", 0, 10)));
    setStatus(new Status());
    if (engine instanceof Journaled)
        if (!inTransaction)
            ((Journaled) engine).commitUserTransaction();
}
Also used : Status(com.dsoft.pb.idef.elements.Status) Journaled(com.ramussoft.common.journal.Journaled) FRectangle(com.dsoft.pb.types.FRectangle) Font(java.awt.Font)

Example 3 with Status

use of com.dsoft.pb.idef.elements.Status in project ramus by Vitaliy-Yakovchuk.

the class IDLImporter method importFromIDL.

public void importFromIDL(InputStream in) throws IOException {
    Vector<Row> streams = plugin.getRecChilds(plugin.getBaseStream(), true);
    for (Row r : streams) {
        Stream stream = (Stream) r;
        if (!stream.isEmptyName()) {
            this.streams.put(stream.getName(), stream);
        }
    }
    reader = new InputStreamReader(in, encoding);
    length = reader.read(buff);
    while (true) {
        String line = readLine();
        if (line == null)
            return;
        switch(position) {
            case KIT:
                if (starts(MODELC, line)) {
                    String name = valueOf(line);
                    try {
                        base.setName(name);
                    } catch (Exception e) {
                    }
                    plugin.getBaseFunctionQualifier().setName(name);
                    plugin.getEngine().updateQualifier(plugin.getBaseFunctionQualifier());
                    loadFonts(line);
                } else if (starts(PROJECT_NAME, line)) {
                    String name = valueOf(line);
                    plugin.getBaseFunction().getProjectOptions().setProjectName(name);
                } else if (starts(AUTHOR, line)) {
                    String name = valueOf(line);
                    plugin.getBaseFunction().getProjectOptions().setProjectAutor(name);
                } else if (starts(DIAGRAM_GRAPHICC, line)) {
                    position = DIAGRAM_GRAPHIC;
                    String name = line.substring(DIAGRAM_GRAPHICC.length() + 1);
                    Function f = getFunction(name);
                    functions.add(f);
                    boxes.clear();
                    segments.clear();
                }
                break;
            case DIAGRAM_GRAPHIC:
                if (starts(TITLE, line)) {
                    String name = valueOf(line);
                    try {
                        getFunction().setName(name);
                    } catch (Exception e) {
                    }
                } else if (starts(STATUS, line)) {
                    String name = line.substring(STATUS.length() + 1);
                    int typeOf = Status.typeOf(name);
                    Status status = getFunction().getStatus();
                    status.setType(typeOf);
                    if (typeOf < 0) {
                        status.setOtherName(name);
                        status.setType(Status.OTHER);
                    }
                    getFunction().setStatus(getFunction().getStatus());
                } else if (starts(BOXC, line)) {
                    box = new Box();
                    box.index = Integer.parseInt(getLastWord(line));
                    boxes.add(box);
                    position = BOX;
                } else if (starts(ENDDIAGRAM, line)) {
                    position = KIT;
                    createSegments();
                    functions.remove(functions.size() - 1);
                } else if (starts("ARROWSEG", line)) {
                    position = ARROWSEG;
                    seg = new Arrowseg();
                    seg.index = Integer.parseInt(line.substring("ARROWSEG".length() + 1));
                    segments.add(seg);
                }
                break;
            case BOX:
                if (starts(NAME, line)) {
                    String name = valueOf(line);
                    box.name = name;
                } else if (starts(BOX_COORDINATES, line)) {
                    box.coordinates = line.substring(BOX_COORDINATES.length() + 1);
                } else if (starts(DETAIL_REFERENCE, line)) {
                    box.reference = line.substring(DETAIL_REFERENCE.length() + 1);
                } else if (starts(ENDBOX, line)) {
                    addBox();
                    position = DIAGRAM_GRAPHIC;
                }
                break;
            case ARROWSEG:
                if (starts(SOURCE, line)) {
                    seg.source = line.substring(SOURCE.length() + 1);
                } else if (starts(PATH, line)) {
                    seg.path = line.substring(PATH.length() + 1);
                } else if (starts(LABAL_COORDINATES, line)) {
                    seg.coordinates = line.substring(LABAL_COORDINATES.length() + 1);
                } else if (starts(LABEL, line)) {
                    seg.label = valueOf(line);
                } else if (starts(SQUIGGLE_COORDINATES, line)) {
                    seg.squiggleCoordinates = line.substring(SQUIGGLE_COORDINATES.length() + 1);
                } else if (starts(SINK, line)) {
                    seg.sink = line.substring(SINK.length() + 1);
                } else if (starts("ENDSEG", line)) {
                    position = DIAGRAM_GRAPHIC;
                }
                break;
        }
    }
}
Also used : Status(com.dsoft.pb.idef.elements.Status) Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) InputStreamReader(java.io.InputStreamReader) Stream(com.ramussoft.pb.Stream) InputStream(java.io.InputStream) Row(com.ramussoft.pb.Row) IOException(java.io.IOException)

Example 4 with Status

use of com.dsoft.pb.idef.elements.Status in project ramus by Vitaliy-Yakovchuk.

the class DataLoader method readStatus.

public static Status readStatus(final InputStream stream) throws IOException {
    final Status res = new Status();
    res.setType(stream.read());
    if (res.getType() == Status.OTHER)
        res.setOtherName(readString(stream));
    return res;
}
Also used : Status(com.dsoft.pb.idef.elements.Status)

Example 5 with Status

use of com.dsoft.pb.idef.elements.Status in project ramus by Vitaliy-Yakovchuk.

the class StatusPanel method getStatus.

/**
 * @return Returns the status.
 */
public Status getStatus() {
    final Status status = new Status();
    for (int i = 0; i < 5; i++) if (getButton(i).isSelected())
        status.setType(i);
    if (status.getType() == Status.OTHER) {
        String s = getJTextField().getText();
        if (s.equals(""))
            s = null;
        status.setOtherName(s);
    }
    return status;
}
Also used : Status(com.dsoft.pb.idef.elements.Status)

Aggregations

Status (com.dsoft.pb.idef.elements.Status)6 FRectangle (com.dsoft.pb.types.FRectangle)2 Function (com.ramussoft.pb.Function)2 MovingFunction (com.ramussoft.pb.idef.visual.MovingFunction)2 IOException (java.io.IOException)2 FloatPoint (com.dsoft.pb.types.FloatPoint)1 Journaled (com.ramussoft.common.journal.Journaled)1 Persistent (com.ramussoft.common.persistent.Persistent)1 SimpleAttributeConverter (com.ramussoft.core.attribute.simple.SimpleAttributeConverter)1 Crosspoint (com.ramussoft.pb.Crosspoint)1 Row (com.ramussoft.pb.Row)1 Stream (com.ramussoft.pb.Stream)1 Point (com.ramussoft.pb.idef.elements.Point)1 Color (java.awt.Color)1 Font (java.awt.Font)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 StringTokenizer (java.util.StringTokenizer)1