use of com.twinsoft.convertigo.beans.common.TagName 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();
}
}
Aggregations