Search in sources :

Example 6 with XMLRectangle

use of com.twinsoft.convertigo.beans.common.XMLRectangle in project convertigo by convertigo.

the class CreateTagNameFromSelectionZoneAction method run.

public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        final ProjectExplorerView explorerView = getProjectExplorerView();
        IWorkbenchPart wpart = getActivePart();
        if ((explorerView != null) && (wpart != null) && (wpart instanceof ConnectorEditor)) {
            ConnectorEditor connectorEditor = (ConnectorEditor) wpart;
            ConnectorEditorPart connectorEditorPart = connectorEditor.getConnectorEditorPart();
            AbstractConnectorComposite connectorComposite = connectorEditorPart.getConnectorComposite();
            if ((connectorComposite != null) && (connectorComposite instanceof JavelinConnectorComposite)) {
                final Javelin javelin = ((JavelinConnectorComposite) connectorComposite).getJavelin();
                ScreenClass currentScreenClass = ((JavelinConnector) connectorEditorPart.getConnector()).getCurrentScreenClass();
                Engine.theApp.fireObjectDetected(new EngineEvent(currentScreenClass));
                final ScreenClassTreeObject lastDetectedScreenClassTreeObject = explorerView.getLastDetectedScreenClassTreeObject();
                if (lastDetectedScreenClassTreeObject != null) {
                    final ScreenClass lastDetectedScreenClass = (ScreenClass) lastDetectedScreenClassTreeObject.getObject();
                    final TagName tagName = new TagName();
                    final InputDialog dlg = new InputDialog(shell, "New TagName", "Please enter a tag name :", "_configure_a_tag_name_", null);
                    if (dlg.open() == Window.OK) {
                        display.asyncExec(new Runnable() {

                            public void run() {
                                try {
                                    String name = dlg.getValue();
                                    Rectangle zone = javelin.getSelectionZone();
                                    tagName.setTagName(StringUtils.normalize(name));
                                    tagName.setSelectionScreenZone(new XMLRectangle(zone.x, zone.y, zone.width, zone.height));
                                    tagName.setSelectionAttribute(javelin.getCharAttribute(zone.x, zone.y));
                                    tagName.setSelectionType("");
                                    tagName.hasChanged = true;
                                    tagName.bNew = true;
                                    lastDetectedScreenClass.addExtractionRule(tagName);
                                    explorerView.reloadTreeObject(lastDetectedScreenClassTreeObject);
                                } catch (Exception e) {
                                    ConvertigoPlugin.logException(e, "Unable to create screen class from selection zone!");
                                }
                                javelin.setSelectionZone(new Rectangle(0, 0, 0, 0));
                            }
                        });
                    } else {
                        javelin.setSelectionZone(new Rectangle(0, 0, 0, 0));
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to create screen class from selection zone!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) InputDialog(org.eclipse.jface.dialogs.InputDialog) TagName(com.twinsoft.convertigo.beans.common.TagName) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) AbstractConnectorComposite(com.twinsoft.convertigo.eclipse.editors.connector.AbstractConnectorComposite) JavelinConnectorComposite(com.twinsoft.convertigo.eclipse.editors.connector.JavelinConnectorComposite) Rectangle(java.awt.Rectangle) XMLRectangle(com.twinsoft.convertigo.beans.common.XMLRectangle) Javelin(com.twinsoft.twinj.Javelin) Cursor(org.eclipse.swt.graphics.Cursor) ConnectorEditor(com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor) ConnectorEditorPart(com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditorPart) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) Shell(org.eclipse.swt.widgets.Shell) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ScreenClassTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject) XMLRectangle(com.twinsoft.convertigo.beans.common.XMLRectangle) EngineEvent(com.twinsoft.convertigo.engine.EngineEvent) Display(org.eclipse.swt.widgets.Display)

Example 7 with XMLRectangle

use of com.twinsoft.convertigo.beans.common.XMLRectangle in project convertigo by convertigo.

the class JavelinAttributeEditor method setPropertyValueFromSelectionZone.

/**
 * Sets the property according to the current selected zone.
 * @param databaseObject
 * @param connector
 * @param setter
 */
public static void setPropertyValueFromSelectionZone(DatabaseObject databaseObject, Connector connector, Method propertySetter) {
    if (connector == null) {
        throw new IllegalArgumentException("The connector object is null");
    }
    JavelinConnector jTmp = null;
    try {
        jTmp = (JavelinConnector) connector;
    } catch (ClassCastException e) {
        throw new IllegalArgumentException("The connector object is not a iJavelin");
    }
    XMLRectangle zone = jTmp.getSelectionZone();
    if (zone.width < 1)
        return;
    int att = jTmp.javelin.getCharAttribute(zone.x, zone.y);
    try {
        propertySetter.invoke(databaseObject, new Object[] { Integer.valueOf(att) });
    } catch (Throwable e) {
        String message = "Error : " + e.getMessage();
        ConvertigoPlugin.logException(e, message);
    }
}
Also used : JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) XMLRectangle(com.twinsoft.convertigo.beans.common.XMLRectangle)

Example 8 with XMLRectangle

use of com.twinsoft.convertigo.beans.common.XMLRectangle in project convertigo by convertigo.

the class JavelinAttributeEditor method getSelectionZoneValue.

/**
 * Gets the value to put in the property according to the current selected zone.
 * @param databaseObject
 * @param connector
 * @param setter
 */
public static Object getSelectionZoneValue(DatabaseObject databaseObject, Connector connector, Method propertySetter) {
    if (connector == null) {
        throw new IllegalArgumentException("The connector object is null");
    }
    JavelinConnector jTmp = null;
    try {
        jTmp = (JavelinConnector) connector;
    } catch (ClassCastException e) {
        throw new IllegalArgumentException("The connector object is not a iJavelin");
    }
    XMLRectangle zone = jTmp.getSelectionZone();
    if (zone.width < 1)
        return null;
    int att = jTmp.javelin.getCharAttribute(zone.x, zone.y);
    return Integer.valueOf(att);
}
Also used : JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) XMLRectangle(com.twinsoft.convertigo.beans.common.XMLRectangle)

Example 9 with XMLRectangle

use of com.twinsoft.convertigo.beans.common.XMLRectangle in project convertigo by convertigo.

the class Nptui method removeBlocksFromWindow.

/**
 * Remove blocks corresponding to a window, described by coordinates, from the block factory.
 * Copy blocks inside the window to the myPanel block, remove definitively blocks from the window border.
 *
 * @param blockFactory : the block factory
 * @param blockBefore : the block just before the blocks corresponding to the window in the block factory, search begins from this block.
 * @param column : the column of the window's top left corner
 * @param line : the line of the window's top left corner
 * @param width : the window's width
 * @param heigth : the window's height
 * @param myPanel : the block representing the window
 * @param dom : the DOM
 */
private void removeBlocksFromWindow(BlockFactory blockFactory, Block blockBefore, int column, int line, int width, int heigth, Block myPanel, Document dom) {
    if (blockBefore == null) {
        // the block to delete is the first of the block factory (no block before)
        // set blockBefore to the block factory's first block
        blockBefore = blockFactory.getFirstBlock();
    }
    Block curBlock = blockBefore;
    Block blockToRemove = null;
    XMLRectangle laScreenZone = new XMLRectangle(column, line, width, heigth);
    do {
        if (!curBlock.type.equals("panel")) {
            if (isBlockInScreenZone(curBlock, laScreenZone)) {
                // if the block is in the panel
                if (!isBlockInBorder(curBlock, laScreenZone)) {
                    // if the block is not in the border
                    // clone the block and add the clone to the window
                    Block clone = null;
                    try {
                        clone = (Block) curBlock.clone();
                    } catch (CloneNotSupportedException e) {
                        Engine.logBeans.trace("Block from a window not clonable : " + curBlock.toString() + "\n" + "Remove it from block factory.");
                    }
                    if (clone != null)
                        myPanel.addOptionalChildren(clone);
                }
                // in both cases (block in the border or not) remove the block from the block factory
                blockToRemove = curBlock;
                curBlock = blockFactory.getPreviousBlock(curBlock);
                blockFactory.removeBlock(blockToRemove);
            }
        }
    } while ((curBlock = blockFactory.getNextBlock(curBlock)) != null);
}
Also used : XMLRectangle(com.twinsoft.convertigo.beans.common.XMLRectangle) Block(com.twinsoft.convertigo.beans.core.Block)

Example 10 with XMLRectangle

use of com.twinsoft.convertigo.beans.common.XMLRectangle in project convertigo by convertigo.

the class Subfile method execute.

/**
 * Applies the extraction rule to the current iJavelin object.
 *
 * @param javelin the Javelin object.
 * @param block the current block to analyze.
 * @param blockFactory the block context of the current block.
 *
 * @return an ExtractionRuleResult object containing the result of
 * the query.
 */
public JavelinExtractionRuleResult execute(iJavelin javelin, Block block, BlockFactory blockFactory, org.w3c.dom.Document dom) {
    // save the screenZone so that we can restore it after the extraction of tableCUA
    XMLRectangle oldScreenZone = getSelectionScreenZone();
    XMLVector<XMLVector<Object>> oldColumns = getColumns();
    JavelinExtractionRuleResult xrs = new JavelinExtractionRuleResult();
    Block downRightBlock, topLeftBlock, blockTmp, newBlock, topActionBlock;
    int columnDataLastCharEast, columnDataLastCharWest, dataLastLine;
    int subfileMarkerLine;
    // attributes of the field of action in the table
    int actionLength = 0;
    int actionColumn = 0;
    // int actionColumnAttributes = 0;
    boolean actionColumnExists = false;
    Block lastField = null;
    boolean screenZoneSet = false;
    StringTokenizer st = new StringTokenizer(endString, ",", false);
    ArrayList<String> token = new ArrayList<String>(st.countTokens());
    // if screen zone has been set, use it...
    if (oldScreenZone.x != -1 || oldScreenZone.y != -1 || oldScreenZone.height != -1 || oldScreenZone.width != -1) {
        screenZoneSet = true;
    }
    // for each string
    while (st.hasMoreTokens()) {
        token.add((String) st.nextToken());
    }
    try {
        // search of the endString among the blocks of the blockFactory
        if (token.contains(block.getText().trim()) && JavelinUtils.isSameAttribute(block.attribute, endStringAttribute) && block.line >= subFileDetectionStartLine) {
            WindowedBlockManager windowedBlockManager = new WindowedBlockManager(blockFactory);
            Engine.logBeans.trace("Searching the end block in a panel.");
            if (!windowedBlockManager.searchPanel(block)) {
                xrs.hasMatched = false;
                xrs.newCurrentBlock = block;
                return xrs;
            }
            // this line of code was not commented. I believe this was to prevent SubFile rule to be run twice. I prefer to set the xrs.newCurrentBlock
            // to the correct value. This also corrects the bug that prevented the delete blocks rule to act on the subfile marker as it was marked
            // as bFinal to true.
            // !!!!!!!!!!!!!!!!!!!!!!!!!!!!
            // !! block.bFinal = true;   !!
            // !!!!!!!!!!!!!!!!!!!!!!!!!!!!
            subfileMarkerLine = block.line;
            // if endString = "+" -> special case (Non-CUA but we can try to define the subfile)
            if (block.getText().equals("+")) {
                /**
                 * CASE "+" in the last row, in the last column
                 */
                downRightBlock = block;
                dataLastLine = downRightBlock.line;
                // as '+' is on same line as the alst row of data , add one line to subFileMarkerLine
                subfileMarkerLine++;
                // do not include marker block in data
                downRightBlock = windowedBlockManager.getPreviousBlockInPanel(block);
                Engine.logBeans.trace("Down Right Block = " + downRightBlock.getText());
                block.line = block.line + 1;
            } else // if endString != "+" (most common case)
            {
                // we look for a block directly above the endString
                downRightBlock = windowedBlockManager.getPreviousBlockInPanel(block);
                Engine.logBeans.trace("Down Right Block = " + downRightBlock.toString());
                while (downRightBlock != null && downRightBlock.line == block.line) {
                    downRightBlock = windowedBlockManager.getPreviousBlockInPanel(downRightBlock);
                    Engine.logBeans.trace("New Down Right Block = " + downRightBlock.toString());
                }
                dataLastLine = downRightBlock.line;
            }
            // if previous block do not contain any text, we give up creation of the table
            if (downRightBlock.length == 0) {
                Engine.logBeans.info("Give up subfile creation => Down Right Block length is 0 : " + downRightBlock.toString());
                xrs.hasMatched = false;
                xrs.newCurrentBlock = block;
                return xrs;
            }
            if ((block.column + block.getText().length()) <= (downRightBlock.column + downRightBlock.getText().length()))
                columnDataLastCharEast = downRightBlock.column + downRightBlock.getText().length();
            else
                columnDataLastCharEast = block.column + block.getText().length();
            // we move to west and search for the last block on the line (last row)
            blockTmp = downRightBlock;
            while (windowedBlockManager.getWestBlock(blockTmp) != null && windowedBlockManager.getWestBlock(blockTmp).line == dataLastLine) {
                blockTmp = windowedBlockManager.getWestBlock(blockTmp);
            }
            Engine.logBeans.trace("last block on the line (west) = " + blockTmp.toString());
            columnDataLastCharWest = blockTmp.column;
            // we check if action column exists
            if (blockTmp.type.equalsIgnoreCase("field")) {
                actionColumnExists = true;
                actionLength = blockTmp.length;
                actionColumn = blockTmp.column;
            // actionColumnAttributes = blockTmp.attribute;
            } else // maybe action column exists but not on this line
            {
                List<Block> blockField = windowedBlockManager.getBlocksByType("field");
                for (Block blockF : blockField) {
                    Engine.logBeans.trace("block field found = " + blockF.toString());
                    if (lastField == null) {
                        if (blockF.column <= blockTmp.column && blockF.line < blockTmp.line) {
                            lastField = blockF;
                        }
                    } else {
                        if (blockF.line > lastField.line || blockF.column > lastField.column) {
                            lastField = blockF;
                        }
                    }
                }
            }
            // an action column, it can happen that it doesn't have a title
            if (actionColumnExists) {
                // if we are in the action column
                Engine.logBeans.trace("+++ action column exists +++");
                if (columnDataLastCharWest > blockTmp.column) {
                    columnDataLastCharWest = blockTmp.column;
                }
                topLeftBlock = null;
            } else {
                // we are in a data column
                Engine.logBeans.trace("Searching title row in data column : " + blockTmp.getText());
                while ((windowedBlockManager.getNorthBlock(blockTmp) != null) && (!JavelinUtils.isSameAttribute(windowedBlockManager.getNorthBlock(blockTmp).attribute, titleRowAttribute))) {
                    blockTmp = windowedBlockManager.getNorthBlock(blockTmp);
                    Engine.logBeans.trace("Moving to north block : " + blockTmp.getText());
                }
                // check if the last field is in the data
                if (lastField == null || lastField.line < blockTmp.line) {
                    Engine.logBeans.trace("---actionColumnDoesNotExists");
                    blockTmp = windowedBlockManager.getNorthBlock(blockTmp);
                    while (windowedBlockManager.getWestBlock(blockTmp) != null) {
                        blockTmp = windowedBlockManager.getWestBlock(blockTmp);
                        Engine.logBeans.trace("Moving to west block : " + blockTmp.getText());
                        if (columnDataLastCharWest > blockTmp.column) {
                            columnDataLastCharWest = blockTmp.column;
                        }
                    }
                    topLeftBlock = blockTmp;
                    Engine.logBeans.trace("Top Left Block = " + (topLeftBlock == null ? "null" : topLeftBlock.getText()));
                } else {
                    Engine.logBeans.trace("+++ action column exists +++");
                    actionColumnExists = true;
                    if (columnDataLastCharWest > lastField.column) {
                        columnDataLastCharWest = lastField.column;
                    }
                    blockTmp = lastField;
                    topLeftBlock = null;
                }
            }
            if (actionColumnExists) {
                // we search the bottom of the title rows (but maybe action column doesn't have a title)
                while (// while north block of blocktmp not null
                (windowedBlockManager.getNorthBlock(blockTmp) != null) && // and north block of blocktmp is not same attribute as titlerow
                (!JavelinUtils.isSameAttribute(windowedBlockManager.getNorthBlock(blockTmp).attribute, titleRowAttribute)) && (!JavelinUtils.isSameAttribute(windowedBlockManager.getNorthBlock(blockTmp).attribute, actionLineAttribute))) {
                    // and north block of blocktmp is not same attribute as actionsline
                    Engine.logBeans.trace("Wrong title line found (" + blockTmp.line + ") ... keep searching...");
                    blockTmp = windowedBlockManager.getNorthBlock(blockTmp);
                }
                // is north block of blocktmp the first title block of first column ?
                if (// if north block of blocktmp not null
                (windowedBlockManager.getNorthBlock(blockTmp) != null) && // and north block of blocktmp has titlerow attribute
                (JavelinUtils.isSameAttribute(windowedBlockManager.getNorthBlock(blockTmp).attribute, titleRowAttribute)) && (goodTitleLine(windowedBlockManager, windowedBlockManager.getNorthBlock(blockTmp)))) {
                    // and north bolck of blocktmp is on a good title line
                    // blocktmp is the last top data block of the first column
                    Engine.logBeans.trace("Top of the action column= " + blockTmp.toString());
                    topActionBlock = blockTmp;
                } else {
                    // action column is not filled until top, blocktmp is not the last top line of data
                    // or action column doesn't have a title
                    Block actiontop = blockTmp;
                    // Searching a title block
                    blockTmp = windowedBlockManager.getEastBlock(blockTmp);
                    blockTmp = windowedBlockManager.getNorthBlock(blockTmp);
                    // look for a title block of the second column
                    while (// while north block of blocktmp not null
                    windowedBlockManager.getNorthBlock(blockTmp) != null && // and north block of blocktmp is the same attribute as titlerow
                    JavelinUtils.isSameAttribute(windowedBlockManager.getNorthBlock(blockTmp).attribute, titleRowAttribute)) {
                        Engine.logBeans.trace("Wrong title line found (" + blockTmp.line + ") ... keep searching...");
                        blockTmp = windowedBlockManager.getNorthBlock(blockTmp);
                    }
                    if (blockTmp == null) {
                        Engine.logBeans.info("Give up subfile creation => Looking for title block : blockTmp is null, no more block to test.");
                        xrs.hasMatched = false;
                        xrs.newCurrentBlock = block;
                        return xrs;
                    } else {
                        if (// if blocktmp has same attribute as titlerow
                        JavelinUtils.isSameAttribute(blockTmp.attribute, titleRowAttribute) && (goodTitleLine(windowedBlockManager, blockTmp))) {
                            // and blocktmp is on a good title line
                            Engine.logBeans.trace("Top of the action column= " + actiontop.toString());
                            topActionBlock = actiontop;
                        } else {
                            Engine.logBeans.info("Give up subfile creation => blockTmp is not of title attribute or is not on a good title line : " + blockTmp.toString());
                            xrs.hasMatched = false;
                            xrs.newCurrentBlock = block;
                            return xrs;
                        }
                    }
                }
                // go one column to the east of top action line block, and one block to the north
                blockTmp = windowedBlockManager.getEastBlock(topActionBlock);
                blockTmp = windowedBlockManager.getNorthBlock(blockTmp);
                // block tmp is the first down title block of second column
                // or another column if there is no data on the east of top action line block
                Block firstTitleBlock = blockTmp;
                // go to the first row of the title rows (if many)
                while (windowedBlockManager.getNorthBlock(blockTmp) != null && JavelinUtils.isSameAttribute(windowedBlockManager.getNorthBlock(blockTmp).attribute, titleRowAttribute) && blockTmp.line - windowedBlockManager.getNorthBlock(blockTmp).line == 1) blockTmp = windowedBlockManager.getNorthBlock(blockTmp);
                // we check if action column has a title
                while (// while no more block is on the top
                topActionBlock != null && // and the title row is not found
                !JavelinUtils.isSameAttribute(topActionBlock.attribute, titleRowAttribute) && // and an action line is not found (we suppose that the title row must be under the actions line)
                !JavelinUtils.isSameAttribute(topActionBlock.attribute, actionLineAttribute)) topActionBlock = windowedBlockManager.getNorthBlock(topActionBlock);
                if (topActionBlock != null && JavelinUtils.isSameAttribute(topActionBlock.attribute, titleRowAttribute)) {
                    Engine.logBeans.trace("Action column has a title");
                    topLeftBlock = topActionBlock;
                } else {
                    // we arrived on the top of the screen or on the actions line
                    Engine.logBeans.trace("Action column does not have a title");
                    Engine.logBeans.trace("Value of the first block of the title row : " + blockTmp.toString());
                    newBlock = new Block();
                    newBlock.column = actionColumn;
                    newBlock.length = actionLength;
                    newBlock.line = firstTitleBlock.line;
                    newBlock.attribute = titleRowAttribute;
                    newBlock.setText("A");
                    newBlock.bRender = false;
                    Engine.logBeans.trace("Creation of the title block of the action column : " + newBlock.toString());
                    // maybe firstTitleBlock is not the second column title, look to the west to see if there are other titles
                    while (windowedBlockManager.getWestBlock(firstTitleBlock) != null) firstTitleBlock = windowedBlockManager.getWestBlock(firstTitleBlock);
                    // now firstTitleBlock is the second column title, can insert the created block after its preceding block
                    Engine.logBeans.trace("Insert new title block after : " + windowedBlockManager.getPreviousBlock(firstTitleBlock).toString());
                    windowedBlockManager.insertBlock(newBlock, windowedBlockManager.getPreviousBlock(firstTitleBlock));
                    Engine.logBeans.trace("Next of the new Block : " + windowedBlockManager.getNextBlock(newBlock).toString());
                    // if getNextBlock(newBlock) and newBlock are not on the same line, we've inserted the new block in the wrong place
                    if (windowedBlockManager.getNextBlock(newBlock).line != newBlock.line) {
                        Engine.logBeans.trace("The new block and its next block are not on the same line. Trying to insert it on the right place.");
                        Block newBlockTmp = newBlock;
                        while (windowedBlockManager.getNextBlock(newBlockTmp).line != newBlock.line) {
                            newBlockTmp = windowedBlockManager.getNextBlock(newBlockTmp);
                        }
                        Engine.logBeans.trace("The previous block of the right place is : " + newBlockTmp.toString());
                        windowedBlockManager.removeBlock(newBlock);
                        windowedBlockManager.insertBlock(newBlock, newBlockTmp);
                    }
                    topLeftBlock = newBlock;
                }
            }
            // Engine.logBeans.trace("---topLeftBlock.attribute="+ topLeftBlock.attribute);
            if (topLeftBlock != null && downRightBlock != null && goodTitleLine(windowedBlockManager, topLeftBlock) && topLeftBlock.line != 0 && JavelinUtils.isSameAttribute(topLeftBlock.attribute, titleRowAttribute)) {
                // We search the first row of data, to give to super.execute method
                Block topLeftDataRow = topLeftBlock;
                while (windowedBlockManager.getNextBlock(topLeftDataRow) != null && windowedBlockManager.getNextBlock(topLeftDataRow).line == topLeftBlock.line) {
                    topLeftDataRow = windowedBlockManager.getNextBlock(topLeftDataRow);
                }
                topLeftDataRow = windowedBlockManager.getNextBlock(topLeftDataRow);
                // Set line of actions and finding columns of the table
                if (actionColumnExists) {
                    setColumnSelection(0);
                    int checkAction = extractActionsLine(windowedBlockManager, topLeftBlock);
                    if (checkAction == 0)
                        setColumnSelection(-1);
                    else
                        setLineActions(checkAction);
                } else
                    setColumnSelection(-1);
                columnTitleWest = javelin.getScreenWidth();
                columnTitleEast = 0;
                setColumns(createTitleColumns(windowedBlockManager, topLeftBlock, downRightBlock.line, columnDataLastCharEast));
                Engine.logBeans.trace("##### Columns: " + getColumns());
                XMLRectangle mySelectionScreenZone = new XMLRectangle(Math.min(columnDataLastCharWest, columnTitleWest), topLeftBlock.line + 1, (Math.max(columnDataLastCharEast, columnTitleEast) - topLeftBlock.column) + 1, subfileMarkerLine - topLeftBlock.line - 1);
                if (screenZoneSet)
                    setSelectionScreenZone(oldScreenZone);
                else
                    setSelectionScreenZone(mySelectionScreenZone);
                // set the offset to 1 this will result in the table to be shifted up one line
                if (actionColumnExists)
                    this.setOffset(2);
                else
                    this.setOffset(1);
                // removing the subfile blocks from their panel.
                Block panel = windowedBlockManager.getPanel();
                if (panel != null) {
                    Engine.logBeans.trace("SelectionScreenZone: " + getSelectionScreenZone().toString());
                    for (Block panelChildBlock : new ArrayList<Block>(panel.getOptionalBlockChildren())) {
                        Engine.logBeans.trace("Trying to remove from Panel: " + panelChildBlock.toString());
                        if (// data line
                        getSelectionScreenZone().contains(panelChildBlock.column, panelChildBlock.line, panelChildBlock.length, 1) || (JavelinUtils.isSameAttribute(panelChildBlock.attribute, actionLineAttribute) && panelChildBlock.line < getSelectionScreenZone().y && panelChildBlock.line >= getSelectionScreenZone().y + getLineActions())) {
                            // action line
                            panel.removeOptionalChildren(panelChildBlock);
                            Engine.logBeans.trace("Removed.");
                        }
                    }
                }
                Engine.logBeans.trace("columnDataLastCharWest=" + columnDataLastCharWest + "; topLeftBlock-line=" + topLeftBlock.line + "; downright-col= " + columnDataLastCharEast + "; downright-line= " + downRightBlock.line);
                xrs = super.execute(javelin, topLeftDataRow, blockFactory, dom);
                table.setOptionalAttribute("subfile", "true");
                table.setOptionalAttribute("titleheight", Integer.toString(titleHeight + 1));
                setSelectionScreenZone(oldScreenZone);
                setColumns(oldColumns);
                // block still contains the end of sub file marker .. set the newCurrentBlock to this block
                xrs.newCurrentBlock = block;
                return xrs;
            } else {
                Engine.logBeans.info("Give up subfile creation => Down Right Block is null              				: " + downRightBlock.toString());
                Engine.logBeans.info("                         OR Top Left Block is null or not of title attribute 	: " + (topLeftBlock == null ? "null" : topLeftBlock.toString()));
                xrs.hasMatched = false;
                xrs.newCurrentBlock = block;
                return xrs;
            }
        } else {
            xrs.hasMatched = false;
            xrs.newCurrentBlock = block;
            return xrs;
        }
    } catch (NullPointerException e) {
        Engine.logBeans.error("NullPointerException while executing the Subfile extraction rule", e);
        xrs.hasMatched = false;
        xrs.newCurrentBlock = blockFactory.getLastBlock();
        return xrs;
    }
}
Also used : XMLVector(com.twinsoft.convertigo.beans.common.XMLVector) ArrayList(java.util.ArrayList) StringTokenizer(java.util.StringTokenizer) JavelinExtractionRuleResult(com.twinsoft.convertigo.beans.extractionrules.JavelinExtractionRuleResult) XMLRectangle(com.twinsoft.convertigo.beans.common.XMLRectangle) Block(com.twinsoft.convertigo.beans.core.Block)

Aggregations

XMLRectangle (com.twinsoft.convertigo.beans.common.XMLRectangle)11 JavelinConnector (com.twinsoft.convertigo.beans.connectors.JavelinConnector)7 Block (com.twinsoft.convertigo.beans.core.Block)3 XMLVector (com.twinsoft.convertigo.beans.common.XMLVector)2 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)2 JavelinExtractionRuleResult (com.twinsoft.convertigo.beans.extractionrules.JavelinExtractionRuleResult)2 EngineEvent (com.twinsoft.convertigo.engine.EngineEvent)2 PanelBlockFactory (com.twinsoft.convertigo.beans.common.PanelBlockFactory)1 TabBox (com.twinsoft.convertigo.beans.common.TabBox)1 TagName (com.twinsoft.convertigo.beans.common.TagName)1 ExtractionRule (com.twinsoft.convertigo.beans.core.ExtractionRule)1 ScreenClass (com.twinsoft.convertigo.beans.core.ScreenClass)1 JavelinExtractionRule (com.twinsoft.convertigo.beans.extractionrules.JavelinExtractionRule)1 Nptui (com.twinsoft.convertigo.beans.sna.Nptui)1 AbstractConnectorComposite (com.twinsoft.convertigo.eclipse.editors.connector.AbstractConnectorComposite)1 ConnectorEditor (com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor)1 ConnectorEditorPart (com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditorPart)1 JavelinConnectorComposite (com.twinsoft.convertigo.eclipse.editors.connector.JavelinConnectorComposite)1 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)1 ScreenClassTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject)1