use of com.twinsoft.convertigo.engine.parsers.triggers.ITriggerOwner in project convertigo by convertigo.
the class StatementTreeObject method treeObjectRemoved.
@Override
public void treeObjectRemoved(TreeObjectEvent treeObjectEvent) {
super.treeObjectRemoved(treeObjectEvent);
// Avoid the cast between "UnloadedProjectTreeObject" and "DatabaseObjectTreeObject
if (!(treeObjectEvent.getSource() instanceof UnloadedProjectTreeObject)) {
DatabaseObjectTreeObject treeObject = (DatabaseObjectTreeObject) treeObjectEvent.getSource();
DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
Statement statement = getObject();
boolean change = false;
// Case this is a screen class
if (databaseObject instanceof ScreenClass) {
ScreenClassTreeObject sto = (ScreenClassTreeObject) treeObjectEvent.getSource();
String screenClassName = StringUtils.normalize(databaseObject.getName());
// ScreenClass and Statement must have the same connector!
if (statement.getConnector().equals(sto.getConnectorTreeObject().getObject())) {
if (statement instanceof ITriggerOwner) {
ITriggerOwner ito = (ITriggerOwner) statement;
AbstractTrigger atrigger = ito.getTrigger().getTrigger();
if (atrigger instanceof ScreenClassTrigger) {
ScreenClassTrigger sct = (ScreenClassTrigger) atrigger;
List<String> screenClasses = sct.getScreenClasses();
for (int i = 0; i < screenClasses.size(); i++) {
if (screenClasses.get(i).equals(screenClassName)) {
screenClasses.remove(i);
change = true;
}
}
// Add default root screen class if all have been removed
if (screenClasses.isEmpty()) {
IScreenClassContainer<?> iscc = (IScreenClassContainer<?>) sto.getConnectorTreeObject().getObject();
String defaultScreenClassName = StringUtils.normalize(iscc.getDefaultScreenClass().getName());
screenClasses.add(defaultScreenClassName);
change = true;
}
if (change)
ito.setTrigger(new TriggerXMLizer(sct));
}
}
}
}
if (change)
try {
hasBeenModified(true);
ConvertigoPlugin.getDefault().getProjectExplorerView().refreshTreeObject(this);
} catch (Exception e) {
ConvertigoPlugin.logWarning(e, "Could not refresh in tree ScHandlerStatement \"" + statement.getName() + "\" !");
}
}
}
use of com.twinsoft.convertigo.engine.parsers.triggers.ITriggerOwner in project convertigo by convertigo.
the class StatementTreeObject method handlesBeanNameChanged.
protected void handlesBeanNameChanged(TreeObjectEvent treeObjectEvent) {
DatabaseObjectTreeObject treeObject = (DatabaseObjectTreeObject) treeObjectEvent.getSource();
DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
Object oldValue = treeObjectEvent.oldValue;
Object newValue = treeObjectEvent.newValue;
Statement statement = getObject();
boolean change = false;
if (databaseObject instanceof ScreenClass) {
String oldScreenClassName = StringUtils.normalize((String) oldValue);
String newScreenClassName = StringUtils.normalize((String) newValue);
// ScreenClass and Statement must have the same connector!
if (statement.getConnector().equals(databaseObject.getConnector())) {
// Modify screenclass handlers name
if (statement instanceof ScHandlerStatement) {
ScHandlerStatement scHandlerStatement = (ScHandlerStatement) statement;
if (scHandlerStatement.getNormalizedScreenClassName().equals(oldScreenClassName)) {
String handlerType = scHandlerStatement.getHandlerType();
String beanName = "on" + newScreenClassName + handlerType;
try {
scHandlerStatement.setName(beanName);
scHandlerStatement.setNormalizedScreenClassName(newScreenClassName);
change = true;
} catch (EngineException e) {
ConvertigoPlugin.logWarning(e, "Could not rename ScHandlerStatement from \"" + scHandlerStatement.getName() + "\" to \"" + beanName + "\" !");
}
}
}
if (statement instanceof ITriggerOwner) {
ITriggerOwner ito = (ITriggerOwner) statement;
AbstractTrigger atrigger = ito.getTrigger().getTrigger();
if (atrigger instanceof ScreenClassTrigger) {
ScreenClassTrigger sct = (ScreenClassTrigger) atrigger;
List<String> screenClasses = sct.getScreenClasses();
for (int i = 0; i < screenClasses.size(); i++) if (screenClasses.get(i).equals(oldScreenClassName) && (change = true))
screenClasses.set(i, newScreenClassName);
if (change)
ito.setTrigger(new TriggerXMLizer(sct));
}
}
}
} else // Case of connector rename
if (databaseObject instanceof SiteClipperConnector) {
if (statement instanceof ContinueWithSiteClipperStatement) {
boolean isLocalProject = statement.getProject().equals(databaseObject.getProject());
boolean isSameValue = ((ContinueWithSiteClipperStatement) statement).getSiteClipperConnectorName().equals(oldValue);
if (isSameValue && isLocalProject) {
((ContinueWithSiteClipperStatement) statement).setSiteClipperConnectorName((String) newValue);
hasBeenModified(true);
viewer.refresh();
// refresh editors (e.g labels in combobox)
getDescriptors();
}
}
}
if (statement instanceof CallFunctionStatement && databaseObject.getClass().equals(FunctionStatement.class) && ((FunctionStatement) databaseObject).getParentTransaction().equals(statement.getParentTransaction())) {
CallFunctionStatement callfunction = (CallFunctionStatement) statement;
if (callfunction.getFunctionName().equals(oldValue) && (change = true))
callfunction.setFunctionName(newValue.toString());
}
if (change)
try {
hasBeenModified(true);
ConvertigoPlugin.getDefault().getProjectExplorerView().refreshTreeObject(this);
} catch (Exception e) {
ConvertigoPlugin.logWarning(e, "Could not refresh in tree ScHandlerStatement \"" + statement.getName() + "\" !");
}
}
Aggregations