Search in sources :

Example 46 with Stream

use of com.ramussoft.pb.Stream in project ramus by Vitaliy-Yakovchuk.

the class DFDSRoleOptionsDialog method onOk.

@Override
protected void onOk() {
    if (!isCanOk()) {
        JOptionPane.showMessageDialog(this, ResourceLoader.getString("you_should_enter_name_or_at_least_on_added_elemen"));
        return;
    }
    if (!isOkStreamName()) {
        if (JOptionPane.showConfirmDialog(this, ResourceLoader.getString("you_entered_exists_stream_continue"), ResourceLoader.getString("warning"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
            return;
        }
    }
    DFDSRole role = (DFDSRole) object;
    Journaled journaled = (Journaled) dataPlugin.getEngine();
    journaled.startUserTransaction();
    Function function = object.getFunction();
    function.setFont(fontChooser.getSelFont());
    function.setBackground(backgroundColorChooser.getColor());
    function.setForeground(foregroundColorChooser.getColor());
    role.setAlternativeText(sectorNameEditor.getAlternativeTextField().getText());
    Stream stream = sectorRowsEditor.getStream();
    if (stream == null) {
        stream = sectorNameEditor.findStreamByName();
        if (stream == null) {
            stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
        }
    }
    final String t = sectorNameEditor.getArrowName();
    if (!t.equals("")) {
        if (!t.equals(stream.getName()) && sectorNameEditor.findStreamByName(stream.getName()) != null) {
            stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
        }
    }
    if (t.equals("")) {
        if (!stream.isEmptyName()) {
            stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
            stream.setEmptyName(true);
        }
    } else {
        stream.setName(t);
    }
    stream.setRows(sectorRowsEditor.getRows());
    role.setStream(stream, ReplaceStreamType.SIMPLE);
    // sector.setStreamAddedByRefactor(false);
    final Row[] rs = sectorRowsEditor.getRows();
    role.setRows(rs);
    if (rs != null) {
        RectangleVisualOptions ops = new RectangleVisualOptions();
        ops.bounds = function.getBounds();
        ops.background = function.getBackground();
        ops.font = function.getFont();
        ops.foreground = function.getForeground();
        for (Row row : rs) if (row != null) {
            IDEF0Plugin.setDefaultRectangleVisualOptions(dataPlugin.getEngine(), row.getElement(), ops);
        }
    }
    journaled.commitUserTransaction();
    setVisible(false);
}
Also used : DFDSRole(com.ramussoft.pb.dfds.visual.DFDSRole) Journaled(com.ramussoft.common.journal.Journaled) Function(com.ramussoft.pb.Function) RectangleVisualOptions(com.ramussoft.idef0.attribute.RectangleVisualOptions) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row)

Example 47 with Stream

use of com.ramussoft.pb.Stream in project ramus by Vitaliy-Yakovchuk.

the class DFDSMovingLabel method getText.

@Override
public String getText() {
    if (labelText == null) {
        String s = sector.getAlternativeText();
        if ("".equals(s)) {
            final Stream stream = sector.getStream();
            if (stream != null) {
                if (stream.isEmptyName()) {
                    Row[] rows = stream.getAdded();
                    StringBuilder sb = null;
                    for (Row row : rows) if (row != null) {
                        if (sb == null)
                            sb = new StringBuilder(row.getName());
                        else {
                            sb.append(";\n");
                            sb.append(row.getName());
                        }
                        String status = row.getAttachedStatus();
                        if (status != null) {
                            int i = status.indexOf('|');
                            if (i >= 0) {
                                status = status.substring(i + 1);
                                if (status.trim().length() == 0)
                                    status = null;
                            }
                        }
                        if (status != null) {
                            sb.append(" (");
                            sb.append(status);
                            sb.append(')');
                        }
                    }
                    if (sb != null)
                        s = sb.toString();
                } else
                    s = stream.getName();
            }
        }
        labelText = s;
    }
    return labelText;
}
Also used : Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row)

Example 48 with Stream

use of com.ramussoft.pb.Stream in project ramus by Vitaliy-Yakovchuk.

the class StreamsEditDialog method refresh.

private void refresh() {
    data = dataPlugin.getChilds(dataPlugin.getBaseStream(), true);
    for (int i = data.size() - 1; i >= 0; i--) {
        if (((Stream) data.get(i)).isEmptyName()) {
            data.remove(i);
        }
    }
    final Stream[] rs = data.toArray(new Stream[data.size()]);
    RowFactory.sortByTitle(rs);
    data.clear();
    for (final Stream s : rs) {
        data.add(s);
    }
    model.fireTableDataChanged();
}
Also used : Stream(com.ramussoft.pb.Stream)

Example 49 with Stream

use of com.ramussoft.pb.Stream in project ramus by Vitaliy-Yakovchuk.

the class StreamsEditDialog method getFindPanel.

private RowFindPanel getFindPanel() {
    if (findPanel == null) {
        findPanel = new RowFindPanel() {

            @Override
            public boolean find(final String text, final boolean wordsOrder) {
                return find(-1, text, wordsOrder);
            }

            @Override
            public boolean findNext(final String text, final boolean wordsOrder) {
                return find(jTable.getSelectedRow(), text, wordsOrder);
            }

            private boolean find(final int selectedIndex, final String text, final boolean wordsOrder) {
                for (int i = selectedIndex + 1; i < data.size(); i++) {
                    final Stream stream = (Stream) data.get(i);
                    if (select(text, wordsOrder, i, stream))
                        return true;
                }
                for (int i = 0; i < selectedIndex; i++) {
                    final Stream stream = (Stream) data.get(i);
                    if (select(text, wordsOrder, i, stream))
                        return true;
                }
                return false;
            }

            private boolean select(final String text, final boolean wordsOrder, final int i, final Stream stream) {
                if (RowSetClass.isStartSame(stream, text, wordsOrder)) {
                    jTable.changeSelection(i, 0, false, false);
                    return true;
                }
                return false;
            }
        };
        ResourceLoader.setJComponentsText(findPanel);
    }
    return findPanel;
}
Also used : Stream(com.ramussoft.pb.Stream) RowFindPanel(com.ramussoft.pb.frames.components.RowFindPanel)

Example 50 with Stream

use of com.ramussoft.pb.Stream in project ramus by Vitaliy-Yakovchuk.

the class SectorRowsEditor method findStreamByName.

public Stream findStreamByName(final String name) {
    if ("".equals(name))
        return null;
    final Vector<Row> streams = dataPlugin.getRecChilds(dataPlugin.getBaseStream(), true);
    final int l = streams.size();
    for (int i = 0; i < l; i++) {
        final Stream s = (Stream) streams.get(i);
        if (name.equals(s.getName()) && !s.isEmptyName())
            return s;
    }
    return null;
}
Also used : Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row)

Aggregations

Stream (com.ramussoft.pb.Stream)51 Row (com.ramussoft.pb.Row)30 Function (com.ramussoft.pb.Function)21 Sector (com.ramussoft.pb.Sector)18 ByteArrayOutputStream (java.io.ByteArrayOutputStream)15 NSector (com.ramussoft.pb.data.negine.NSector)14 Vector (java.util.Vector)13 InputStream (java.io.InputStream)11 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)10 ByteArrayInputStream (java.io.ByteArrayInputStream)10 Crosspoint (com.ramussoft.pb.Crosspoint)9 NFunction (com.ramussoft.pb.data.negine.NFunction)9 OutputStream (java.io.OutputStream)7 NStream (com.ramussoft.pb.data.negine.NStream)6 ArrayList (java.util.ArrayList)6 FloatPoint (com.dsoft.pb.types.FloatPoint)4 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)4 MovingFunction (com.ramussoft.pb.idef.visual.MovingFunction)4 IOException (java.io.IOException)4 FRectangle (com.dsoft.pb.types.FRectangle)3