use of com.twinsoft.convertigo.engine.EngineEvent in project convertigo by convertigo.
the class CreateScreenClassFromSelectionZoneAction method run.
public void run() {
Display display = Display.getDefault();
Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
Shell shell = getParentShell();
shell.setCursor(waitCursor);
try {
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)) {
Javelin javelin = ((JavelinConnectorComposite) connectorComposite).getJavelin();
ScreenClass currentScreenClass = ((JavelinConnector) connectorEditorPart.getConnector()).getCurrentScreenClass();
Engine.theApp.fireObjectDetected(new EngineEvent(currentScreenClass));
ScreenClassTreeObject lastDetectedScreenClassTreeObject = explorerView.getLastDetectedScreenClassTreeObject();
if (lastDetectedScreenClassTreeObject != null) {
Rectangle zone = javelin.getSelectionZone();
String strZone = javelin.getString(zone.x, zone.y, zone.width);
ScreenClass lastDetectedScreenClass = (ScreenClass) lastDetectedScreenClassTreeObject.getObject();
JavelinScreenClass screenClass = new JavelinScreenClass();
screenClass.priority = lastDetectedScreenClass.priority + 1;
screenClass.hasChanged = true;
screenClass.bNew = true;
lastDetectedScreenClass.add(screenClass);
FindString fs = new FindString();
fs.setString(strZone);
fs.setX(zone.x);
fs.setY(zone.y);
fs.hasChanged = true;
fs.bNew = true;
// Determine whether there is the same attribute for each character
boolean isSameAttribute = true;
int attribute = javelin.getCharAttribute(zone.x, zone.y);
for (int i = 1; (i < zone.width) && isSameAttribute; i++) {
isSameAttribute = JavelinUtils.isSameAttribute(attribute, javelin.getCharAttribute(zone.x + i, zone.y));
}
fs.setAttribute(isSameAttribute ? attribute : -1);
screenClass.addCriteria(fs);
explorerView.reloadTreeObject(lastDetectedScreenClassTreeObject);
Engine.theApp.fireObjectDetected(new EngineEvent(screenClass));
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();
}
}
use of com.twinsoft.convertigo.engine.EngineEvent 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();
}
}
use of com.twinsoft.convertigo.engine.EngineEvent in project convertigo by convertigo.
the class BaseRule method fireEvents.
public void fireEvents() {
if (Engine.isStudioMode()) {
Engine.theApp.fireObjectDetected(new EngineEvent(this));
if (getConnector().isDebugging()) {
Engine.logSiteClipper.trace("(BaseRule) Step reached before applying rule \"" + getName() + "\".");
Engine.theApp.fireStepReached(new EngineEvent(this));
}
}
}
use of com.twinsoft.convertigo.engine.EngineEvent in project convertigo by convertigo.
the class ConnectorEditorPartWrap method checkEventSource.
private boolean checkEventSource(EventObject event) {
boolean isSourceFromConnector = false;
if (event instanceof RequestableEngineEvent) {
RequestableEngineEvent requestableEvent = (RequestableEngineEvent) event;
String connectorName = requestableEvent.getConnectorName();
if (connectorName != null) {
if (connectorName.equals(connector.getName()) && requestableEvent.getProjectName().equals(connector.getProject().getName())) {
isSourceFromConnector = true;
}
}
} else if (event instanceof EngineEvent) {
Object ob = ((EngineEvent) event).getSource();
if (ob instanceof DatabaseObject) {
try {
String projectName = ((DatabaseObject) ob).getProject().getName();
String connectorName = ((DatabaseObject) ob).getConnector().getName();
if (connectorName.equals(connector.getName()) && projectName.equals(connector.getProject().getName())) {
isSourceFromConnector = true;
}
} catch (Exception e) {
}
}
}
return isSourceFromConnector;
}
Aggregations