use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.
the class ComponentExplorerComposite method addLabelEx.
private void addLabelEx(Component component, boolean bSelected) {
String category = component.getGroup();
if ("".equals(category)) {
composite = composites[0];
} else {
for (int i = 0; i < items.length; i++) {
if (items[i].getText().equals(category)) {
composite = composites[i];
}
}
}
final CLabel label = new CLabel(composite, SWT.NONE);
Image image = null;
try {
image = ConvertigoPlugin.getDefault().getIconFromPath(component.getImagePath(), BeanInfo.ICON_COLOR_32x32);
} catch (Exception e) {
}
label.setImage(image);
label.setText(component.getLabel());
label.setAlignment(SWT.LEFT);
label.setToolTipText(RegexpUtils.removeTag.matcher(getShortDescription(component)).replaceAll(""));
label.setCursor(handCursor);
label.setLayoutData(new RowData());
objectsMap.put(label, component);
if (bSelected) {
currentSelectedObject = label;
}
// DND support for Mobile palette
if (wizardPage == null) {
Transfer[] types = new Transfer[] { PaletteSourceTransfer.getInstance() };
int operations = DND.DROP_COPY | DND.DROP_MOVE;
DragSource source = new DragSource(label, operations);
source.setTransfer(types);
source.addDragListener(new DragSourceAdapter() {
@Override
public void dragStart(DragSourceEvent event) {
try {
if (currentSelectedObject != null && !currentSelectedObject.isDisposed()) {
currentSelectedObject.setForeground(label.getForeground());
currentSelectedObject.setBackground(label.getBackground());
}
currentSelectedObject = label;
currentSelectedObject.setForeground(FOREGROUND_SELECTED_COLOR);
currentSelectedObject.setBackground(BACKGROUND_SELECTED_COLOR);
Component c = (Component) objectsMap.get(label);
DatabaseObject dbo = ComponentManager.createBeanFromHint(c);
if (dbo != null) {
String sXml = ClipboardAction.dnd.copy(dbo);
if (sXml != null) {
event.doit = true;
PaletteSourceTransfer.getInstance().setPaletteSource(new PaletteSource(sXml));
}
} else {
throw new Exception("Invalid database object : null");
}
} catch (Exception e) {
ConvertigoPlugin.logException(e, "Cannot drag");
}
}
});
}
label.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
CLabel label = (CLabel) e.getSource();
if (currentSelectedObject == label)
return;
if (currentSelectedObject != null && !currentSelectedObject.isDisposed()) {
currentSelectedObject.setForeground(label.getForeground());
currentSelectedObject.setBackground(label.getBackground());
}
currentSelectedObject = (CLabel) e.getSource();
ConvertigoPlugin.logDebug("currentSelectedObject: '" + currentSelectedObject.getText() + "'.");
currentSelectedObject.setForeground(FOREGROUND_SELECTED_COLOR);
currentSelectedObject.setBackground(BACKGROUND_SELECTED_COLOR);
Component currentSelectedComponent = getCurrentSelectedComponent();
if (currentSelectedComponent != null) {
updateHelpText(currentSelectedComponent);
}
}
@Override
public void mouseDoubleClick(MouseEvent e) {
currentSelectedObject = (CLabel) e.getSource();
if (wizardPage != null) {
wizardPage.setPageComplete(true);
((ComponentExplorerWizardPage) wizardPage).showNextPage();
}
}
});
ConvertigoPlugin.logDebug("Loaded '" + component.getLabel() + "'.");
}
use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.
the class LearnScreenClassWizard method performFinish.
public boolean performFinish() {
String screenClassName = null;
String criteriaName = null;
XPath criteria = null;
try {
DatabaseObject parentObject = page2.getParentObject();
if (parentObject != null) {
// create new screen class
htmlScreenClass = new HtmlScreenClass();
if (htmlScreenClass != null) {
screenClassName = page2.getScreenClassName();
if (!StringUtils.isNormalized(screenClassName))
throw new EngineException("Screenclass name is not normalized : \"" + screenClassName + "\".");
htmlScreenClass.setName(screenClassName);
htmlScreenClass.hasChanged = true;
htmlScreenClass.priority = parentObject.priority + 1;
parentObject.add(htmlScreenClass);
ConvertigoPlugin.logInfo("New screen class named '" + screenClassName + "' has been added!");
Engine.logBeans.debug("New screen class named '" + screenClassName + "' has been added!", null);
}
if (htmlScreenClass != null) {
criteria = new XPath();
if (criteria != null) {
criteriaName = criteria.getName();
criteria.hasChanged = true;
try {
htmlScreenClass.add(criteria);
ConvertigoPlugin.logInfo("New criteria named '" + criteriaName + "' has been added!");
Engine.logBeans.debug("New criteria named '" + criteriaName + "' has been added!", null);
} catch (EngineException e) {
throw e;
}
}
}
}
} catch (EngineException e) {
String message = "Unable to create new screenclass class!";
ConvertigoPlugin.logException(e, message);
}
return true;
}
use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.
the class ComponentInfoWizardPage method dialogChanged.
private void dialogChanged(boolean increment) {
DatabaseObject dbo = ((ComponentExplorerWizardPage) getWizard().getPage("ComponentExplorerWizardPage")).getCreatedBean();
if (dbo != null) {
String name = getBeanName();
if (name.length() == 0) {
updateStatus("Name must be specified");
return;
}
if (!StringUtils.isNormalized(name)) {
updateStatus("Name must be normalized.\nDon't start with number and don't use non ASCII caracters.");
return;
}
Matcher m = Pattern.compile("\\d+$").matcher("");
boolean sameName;
do {
sameName = false;
try {
dbo.setName(name);
} catch (ObjectWithSameNameException e) {
if (!increment) {
updateStatus("Name already used by siblings");
return;
}
sameName = true;
m.reset(name);
if (m.find()) {
name = name.substring(0, m.start()) + (Integer.parseInt(m.group()) + 1);
} else {
name = name + "_1";
}
setBeanName(name);
} catch (EngineException e) {
updateStatus("Name could not be set on bean");
return;
} catch (NullPointerException e) {
updateStatus("New Bean has not been instanciated");
return;
}
} while (sameName);
}
updateStatus(null);
}
use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.
the class SharedComponentWizard method computeSharedComponentName.
private void computeSharedComponentName() {
DatabaseObject firstDbo = getFirstInList();
String dbo_qname = sizeOfList() > 1 ? firstDbo.getParent().getQName() + "_Group" : firstDbo.getQName();
String app_qname = ((UIComponent) firstDbo).getApplication().getQName();
dbo_qname = dbo_qname.replace(app_qname + ".", "");
shared_comp_name = StringUtils.normalize(dbo_qname);
}
use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.
the class SharedComponentWizard method doFinish.
private void doFinish(IProgressMonitor monitor) throws CoreException {
UISharedRegularComponent uisc = null;
UIUseShared uius = null;
try {
if (page1 != null) {
shared_comp_name = page1.getSharedComponentName();
keep_original = page1.keepComponent();
}
if (page2 != null) {
dlg_map = page2.getVariableMap();
}
// Create shared component
uisc = createSharedComponent();
monitor.setTaskName("SharedComponent created");
monitor.worked(1);
// Create UseShared
uius = createUseShared(uisc.getQName());
monitor.setTaskName("UseShared component created");
monitor.worked(1);
// Disable or Remove selected databaseObject(s)
for (DatabaseObject dbo : objectList) {
UIComponent uic = (UIComponent) dbo;
if (keep_original) {
uic.setEnabled(false);
uic.hasChanged = true;
} else {
MobileComponent mc = (MobileComponent) uic.getParent();
if (mc instanceof ApplicationComponent) {
ApplicationComponent parent = (ApplicationComponent) mc;
parent.remove(uic);
parent.hasChanged = true;
} else if (mc instanceof PageComponent) {
PageComponent parent = (PageComponent) mc;
parent.remove(uic);
parent.hasChanged = true;
} else if (mc instanceof UIComponent) {
UIComponent parent = (UIComponent) mc;
parent.remove(uic);
parent.hasChanged = true;
}
}
}
// Set newBean to new shared component
newBean = uisc;
} catch (Exception e) {
try {
if (uisc != null) {
uisc.getParent().remove(uisc);
}
if (uius != null) {
uius.getParent().remove(uius);
}
} catch (Exception ex) {
}
String message = "Unable to create a new object from class '" + this.className + "'.";
ConvertigoPlugin.logException(e, message);
newBean = null;
}
}
Aggregations