use of com.twinsoft.convertigo.beans.core.ScreenClass in project convertigo by convertigo.
the class DatabaseObjectTreeObject method getPropertyValue.
public Object getPropertyValue(Object id) {
if (id == null)
return null;
DatabaseObject databaseObject = getObject();
String propertyName = (String) id;
if (propertyName.equals(P_TYPE))
return databaseObjectBeanDescriptor.getDisplayName();
else if (propertyName.equals(P_JAVA_CLASS))
return databaseObject.getClass().getName();
else if (propertyName.equals(P_NAME))
return databaseObject.getName();
else if (propertyName.equals(P_QNAME))
return databaseObject.getQName();
else if (propertyName.equals(P_PRIORITY))
return Long.toString(databaseObject.priority);
else if (propertyName.equals(P_DEPTH)) {
if (databaseObject instanceof ScreenClass)
return Integer.toString(((ScreenClass) databaseObject).getDepth());
else
return org.apache.commons.lang3.StringUtils.countMatches(databaseObject.getQName(), '.');
} else if (propertyName.equals(P_EXPORTED)) {
return databaseObject.getProject().getInfoForProperty("exported");
} else if (propertyName.equals(P_MIN_VERSION)) {
return databaseObject.getProject().getMinVersion();
} else {
try {
java.beans.PropertyDescriptor databaseObjectPropertyDescriptor = getPropertyDescriptor(propertyName);
if (databaseObjectPropertyDescriptor == null) {
return null;
}
Class<?> pec = databaseObjectPropertyDescriptor.getPropertyEditorClass();
Method getter = databaseObjectPropertyDescriptor.getReadMethod();
Object compilablePropertySourceValue = databaseObject.getCompilablePropertySourceValue(propertyName);
Object value;
if (compilablePropertySourceValue == null) {
Object[] args = {};
value = getter.invoke(databaseObject, args);
} else {
value = compilablePropertySourceValue;
}
boolean done = false;
if (value instanceof String) {
PropertyDescriptor propertyDescriptor = findPropertyDescriptor(id);
if (propertyDescriptor instanceof DynamicComboBoxPropertyDescriptor) {
DynamicComboBoxPropertyDescriptor pd = (DynamicComboBoxPropertyDescriptor) propertyDescriptor;
value = pd.setValue((String) value);
done = true;
}
}
if (done) {
// do nothing
} else if (value instanceof Boolean) {
value = ((Boolean) value).booleanValue() ? Integer.valueOf(0) : Integer.valueOf(1);
} else if ((pec != null) && (PropertyWithTagsEditor.class.isAssignableFrom(pec) || Enum.class.isAssignableFrom(pec))) {
if (!(value instanceof Integer)) {
if (PropertyWithTagsEditorAdvance.class.isAssignableFrom(pec)) {
Method getTags = pec.getMethod("getTags", new Class[] { DatabaseObjectTreeObject.class, String.class });
String[] tags = (String[]) getTags.invoke(null, new Object[] { this, propertyName });
int i;
for (i = 0; i < tags.length; i++) {
if (tags[i].equals(value)) {
value = Integer.valueOf(i);
break;
}
}
// if we did not find our string in the tag list set value to index 0
if (i == tags.length) {
value = Integer.valueOf(0);
String message = "Incorrect property \"" + propertyName + "\" value for the object \"" + databaseObject.getName() + "\".";
ConvertigoPlugin.logWarning(message);
}
} else if (Enum.class.isAssignableFrom(pec)) {
value = Integer.valueOf(((Enum<?>) value).ordinal());
} else if (StringComboBoxPropertyDescriptor.class.isAssignableFrom(pec)) {
// nothing to do: value is a string
}
}
if ((EmulatorTechnologyEditor.class.equals(pec))) {
Method getEmulatorClassNames = pec.getDeclaredMethod("getEmulatorClassNames", new Class[] { DatabaseObjectTreeObject.class });
String[] emulatorClassNames = (String[]) getEmulatorClassNames.invoke(null, new Object[] { this });
for (int i = 0; i < emulatorClassNames.length; i++) {
if (emulatorClassNames[i].equals(value)) {
value = Integer.valueOf(i);
break;
}
}
}
// else simply return the combo index
} else if (value instanceof Number) {
value = ((Number) value).toString();
}
// Get property's nillable value
if (Boolean.TRUE.equals(databaseObjectPropertyDescriptor.getValue("nillable"))) {
try {
Boolean isNull = ((INillableProperty) databaseObject).isNullProperty(propertyName);
PropertyDescriptor pd = findPropertyDescriptor(propertyName);
if ((pd != null) && (pd instanceof DataOrNullPropertyDescriptor)) {
((DataOrNullPropertyDescriptor) pd).setNullProperty(isNull);
if (isNull) {
// Overrides value by fake one used by property editor
if (value instanceof String)
value = "<value is null>";
if (value instanceof XMLVector) {
XMLVector<Object> xmlv = new XMLVector<Object>();
xmlv.add("null");
value = xmlv;
}
}
}
} catch (Exception e) {
String message = "Error while trying to retrieve 'isNull' attribute of property \"" + propertyName + "\" for the object \"" + databaseObject.getName() + "\".";
ConvertigoPlugin.logException(e, message);
}
}
// Check for property normalized value if needed
if (Boolean.TRUE.equals(databaseObjectPropertyDescriptor.getValue(DatabaseObject.PROPERTY_XMLNAME))) {
// Ignore compilable property source value
if (compilablePropertySourceValue == null) {
if (value instanceof String) {
if (!XMLUtils.checkName(value.toString())) {
String message = "Property \"" + propertyName + "\" value for the object \"" + databaseObject.getName() + "\" isn't XML compliant.";
ConvertigoPlugin.logError(message, Boolean.TRUE);
}
}
}
}
return value;
} catch (Exception e) {
String message = "Error while trying to retrieve property \"" + propertyName + "\" value for the object \"" + databaseObject.getName() + "\".";
ConvertigoPlugin.logException(e, message);
return null;
}
}
}
use of com.twinsoft.convertigo.beans.core.ScreenClass in project convertigo by convertigo.
the class ConnectorEditorPart method objectDetected.
public void objectDetected(EngineEvent engineEvent) {
if (!checkEventSource(engineEvent))
return;
final Object source = engineEvent.getSource();
getDisplay().syncExec(() -> {
if (source instanceof ScreenClass) {
lastDetectedScreenClass = (ScreenClass) source;
labelLastDetectedScreenClass.setText(lastDetectedScreenClass.getName());
compositeOutputFooter.layout();
}
if (bDebug) {
String message = MessageFormat.format("The following database object has been detected: \"{0}\"\n", new Object[] { ((DatabaseObject) source).getName() });
try {
ConvertigoPlugin.getDefault().debugConsoleStream.write(message);
} catch (IOException e) {
}
}
});
}
use of com.twinsoft.convertigo.beans.core.ScreenClass in project convertigo by convertigo.
the class JavelinConnectorComposite method goToCurrentScreenClass.
/**
* Highlight the current screen class in tree view
*/
public void goToCurrentScreenClass() {
synchronized (connector) {
ScreenClass screenClass = ((JavelinConnector) connector).getCurrentScreenClass();
fireObjectSelected(new CompositeEvent(screenClass));
if (connector.isLearning()) {
if (bHandlerOpened) {
closeScreenClassHandler("redetect");
}
openScreenClassHandler(true);
getJavelin().requestFocus();
}
}
}
use of com.twinsoft.convertigo.beans.core.ScreenClass in project convertigo by convertigo.
the class JavelinConnectorComposite method keyPressed.
public void keyPressed(java.awt.event.KeyEvent keyEvent) {
ScreenClass currentScreenClass = null;
JavelinConnector javelinConnector = (JavelinConnector) connector;
// Learning mode
if (javelinConnector.isLearning()) {
synchronized (javelinConnector) {
currentScreenClass = javelinConnector.getCurrentScreenClass();
}
synchronized (this) {
char c = keyEvent.getKeyChar();
// Avoiding handle null key char
if (c == 0x0)
return;
if (Character.isLetterOrDigit(c) || c == ' ') {
keysBuffer += c;
} else {
String doActionName = findActionName(javelinConnector.emulatorID, keyEvent);
if (doActionName != null) {
if (learnScreenClass == null) {
learnScreenClass = currentScreenClass;
} else if (!learnScreenClass.equals(currentScreenClass)) {
if (javelinConnector.isAccumulating()) {
closeScreenClassHandler();
openScreenClassHandler(false);
closeScreenClassHandler("accumulate");
} else {
closeScreenClassHandler("redetect");
}
// learnScreenClass =
// projectExplorerView.getLastDetectedScreenClass();
learnScreenClass = currentScreenClass;
openScreenClassHandler(true);
}
// videotex)
if (bDoAction && (javelinConnector.emulatorID == 1)) {
long rightNow = new java.util.Date().getTime();
writeLine("javelin.waitSync(" + (rightNow - doActionTime) + ");");
bDoAction = false;
}
// Flushing alphanumeric buffer
if (keysBuffer.length() != 0) {
writeLine("javelin.send(\"" + keysBuffer + "\");");
keysBuffer = "";
}
// Writing emulator action
writeLine("javelin.doAction(\"" + doActionName + "\");");
bDoAction = true;
doActionTime = new java.util.Date().getTime();
}
}
}
}
}
use of com.twinsoft.convertigo.beans.core.ScreenClass in project convertigo by convertigo.
the class HttpTriggerScreenClassEditorComposite method initialize.
/**
* This method initializes this
*/
private void initialize() {
ScreenClassTrigger trigger = (parent.getTrigger() instanceof ScreenClassTrigger) ? (ScreenClassTrigger) parent.getTrigger() : null;
scrClass_label = new Label(this, SWT.NONE);
scrClass_label.setText("Screen classes");
scrClass_list = new List(this, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
java.util.List<HtmlScreenClass> scList = getScreenClassList();
java.util.List<String> items = new ArrayList<String>();
for (ScreenClass sc : scList) {
String scName = sc.getName();
scrClass_list.add(scName);
if (trigger != null) {
if (trigger.getScreenClasses().contains(scName)) {
items.add(scName);
}
}
}
scrClass_list.setSelection(items.toArray(new String[items.size()]));
GridData gridData2 = new GridData();
gridData2.horizontalAlignment = GridData.FILL;
gridData2.verticalAlignment = GridData.FILL;
gridData2.grabExcessHorizontalSpace = true;
scrClass_list.setLayoutData(gridData2);
scrClass_list.setSize(400, 250);
}
Aggregations