use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource in project convertigo by convertigo.
the class NgxUIComponentTreeObject method getNamedSourceSelector.
@Override
public NamedSourceSelector getNamedSourceSelector() {
return new NamedSourceSelector() {
@Override
Object thisTreeObject() {
return NgxUIComponentTreeObject.this;
}
@Override
protected List<String> getPropertyNamesForSource(Class<?> c) {
List<String> list = new ArrayList<String>();
UIComponent object = getObject();
if (object instanceof UIDynamicTabButton) {
if (ProjectTreeObject.class.isAssignableFrom(c) || MobileApplicationTreeObject.class.isAssignableFrom(c) || NgxApplicationComponentTreeObject.class.isAssignableFrom(c) || NgxPageComponentTreeObject.class.isAssignableFrom(c)) {
list.add("tabpage");
}
} else if (object instanceof UIDynamicMenuItem) {
if (ProjectTreeObject.class.isAssignableFrom(c) || MobileApplicationTreeObject.class.isAssignableFrom(c) || NgxApplicationComponentTreeObject.class.isAssignableFrom(c) || NgxPageComponentTreeObject.class.isAssignableFrom(c)) {
list.add("itempage");
}
} else if (object instanceof UIDynamicAnimate) {
if (ProjectTreeObject.class.isAssignableFrom(c) || MobileApplicationTreeObject.class.isAssignableFrom(c) || NgxApplicationComponentTreeObject.class.isAssignableFrom(c) || NgxPageComponentTreeObject.class.isAssignableFrom(c) || NgxUIComponentTreeObject.class.isAssignableFrom(c)) {
list.add("identifiable");
}
} else if (object instanceof UIDynamicInvoke) {
if (ProjectTreeObject.class.isAssignableFrom(c) || MobileApplicationTreeObject.class.isAssignableFrom(c) || NgxApplicationComponentTreeObject.class.isAssignableFrom(c) || NgxUIComponentTreeObject.class.isAssignableFrom(c)) {
list.add("stack");
}
} else if (object instanceof UIUseShared) {
if (ProjectTreeObject.class.isAssignableFrom(c) || MobileApplicationTreeObject.class.isAssignableFrom(c) || NgxApplicationComponentTreeObject.class.isAssignableFrom(c) || NgxUIComponentTreeObject.class.isAssignableFrom(c)) {
list.add("sharedcomponent");
}
} else if (object instanceof UIDynamicInfiniteScroll) {
if (ProjectTreeObject.class.isAssignableFrom(c) || MobileApplicationTreeObject.class.isAssignableFrom(c) || NgxApplicationComponentTreeObject.class.isAssignableFrom(c) || NgxPageComponentTreeObject.class.isAssignableFrom(c) || NgxUIComponentTreeObject.class.isAssignableFrom(c)) {
list.add("scrollaction");
}
} else if (object instanceof UIDynamicElement) {
if (ProjectTreeObject.class.isAssignableFrom(c) || SequenceTreeObject.class.isAssignableFrom(c) || ConnectorTreeObject.class.isAssignableFrom(c)) {
list.add("requestable");
}
if (ProjectTreeObject.class.isAssignableFrom(c) || MobileApplicationTreeObject.class.isAssignableFrom(c) || NgxApplicationComponentTreeObject.class.isAssignableFrom(c) || NgxPageComponentTreeObject.class.isAssignableFrom(c)) {
list.add("page");
}
if (ProjectTreeObject.class.isAssignableFrom(c) || ConnectorTreeObject.class.isAssignableFrom(c) || DesignDocumentTreeObject.class.isAssignableFrom(c) || DesignDocumentViewTreeObject.class.isAssignableFrom(c)) {
list.add("fsview");
}
}
return list;
}
@Override
protected boolean isNamedSource(String propertyName) {
UIComponent object = getObject();
if (object instanceof UIDynamicTab) {
return "tabpage".equals(propertyName);
} else if (object instanceof UIDynamicMenuItem) {
return "itempage".equals(propertyName);
} else if (object instanceof UIDynamicAnimate) {
return "identifiable".equals(propertyName);
} else if (object instanceof UIDynamicInvoke) {
return "stack".equals(propertyName);
} else if (object instanceof UIUseShared) {
return "sharedcomponent".equals(propertyName);
} else if (object instanceof UIDynamicInfiniteScroll) {
return "scrollaction".equals(propertyName);
} else if (object instanceof UIDynamicElement) {
return "requestable".equals(propertyName) || "fsview".equals(propertyName) || "page".equals(propertyName);
}
return false;
}
@Override
public boolean isSelectable(String propertyName, Object nsObject) {
UIComponent object = getObject();
if (object instanceof UIDynamicTabButton) {
if ("tabpage".equals(propertyName)) {
if (nsObject instanceof PageComponent) {
return (((PageComponent) nsObject).getProject().equals(object.getProject()));
}
}
} else if (object instanceof UIDynamicMenuItem) {
if ("itempage".equals(propertyName)) {
if (nsObject instanceof PageComponent) {
return (((PageComponent) nsObject).getProject().equals(object.getProject()));
}
}
} else if (object instanceof UIDynamicAnimate) {
if ("identifiable".equals(propertyName)) {
UIDynamicAnimate uda = (UIDynamicAnimate) object;
if (nsObject instanceof UIElement) {
UIElement ue = (UIElement) nsObject;
if (hasSameScriptComponent(uda, ue)) {
return !ue.getIdentifier().isEmpty();
}
}
}
} else if (object instanceof UIDynamicInvoke) {
if ("stack".equals(propertyName)) {
return nsObject instanceof UIActionStack;
}
} else if (object instanceof UIUseShared) {
if ("sharedcomponent".equals(propertyName)) {
return nsObject instanceof UISharedComponent;
}
} else if (object instanceof UIDynamicInfiniteScroll) {
if ("scrollaction".equals(propertyName)) {
if (nsObject instanceof UIDynamicAction) {
UIDynamicAction uida = (UIDynamicAction) nsObject;
if (uida.getProject().equals(object.getProject())) {
if (uida.getIonBean().getName().equals("CallSequenceAction")) {
return true;
}
if (uida.getIonBean().getName().equals("FullSyncViewAction")) {
return true;
}
}
}
}
} else if (object instanceof UIDynamicElement) {
if ("requestable".equals(propertyName)) {
UIDynamicElement cc = (UIDynamicElement) object;
if (cc.getIonBean().getName().equals("CallSequenceAction")) {
return nsObject instanceof Sequence;
}
if (cc.getIonBean().getName().equals("CallFullSyncAction")) {
return nsObject instanceof FullSyncConnector;
}
if (cc.getIonBean().getName().equals("FullSyncSyncAction")) {
return nsObject instanceof FullSyncConnector;
}
if (cc.getIonBean().getName().equals("FullSyncViewAction")) {
return nsObject instanceof DesignDocument;
}
if (cc.getIonBean().getName().equals("FullSyncPostAction")) {
return nsObject instanceof FullSyncConnector;
}
if (cc.getIonBean().getName().equals("FullSyncGetAction")) {
return nsObject instanceof FullSyncConnector;
}
if (cc.getIonBean().getName().equals("FullSyncDeleteAction")) {
return nsObject instanceof FullSyncConnector;
}
if (cc.getIonBean().getName().equals("FullSyncPutAttachmentAction")) {
return nsObject instanceof FullSyncConnector;
}
if (cc.getIonBean().getName().equals("FullSyncDeleteAttachmentAction")) {
return nsObject instanceof FullSyncConnector;
}
if (cc.getIonBean().getName().equals("FSImage")) {
return nsObject instanceof FullSyncConnector;
}
if (cc.getIonBean().getName().equals("AutoScrollComponent")) {
return nsObject instanceof Sequence;
}
}
if ("fsview".equals(propertyName)) {
UIDynamicElement cc = (UIDynamicElement) object;
if (cc.getIonBean().getName().equals("FullSyncViewAction")) {
return nsObject instanceof String;
}
if (cc.getIonBean().getName().equals("AutoScrollComponent")) {
return nsObject instanceof DesignDocument || nsObject instanceof String;
}
}
if ("page".equals(propertyName)) {
if (nsObject instanceof PageComponent) {
return (((PageComponent) nsObject).getProject().equals(object.getProject()));
}
}
}
return false;
}
@Override
protected void handleSourceCleared(String propertyName) {
// nothing to do
}
@Override
protected void handleSourceRenamed(String propertyName, String oldName, String newName) {
if (isNamedSource(propertyName)) {
boolean hasBeenRenamed = false;
Object oValue = getPropertyValue(propertyName);
String pValue;
if (oValue instanceof MobileSmartSourceType) {
MobileSmartSourceType sst = (MobileSmartSourceType) oValue;
pValue = sst.getSmartValue();
} else {
pValue = (String) oValue;
}
String _pValue = pValue;
if (pValue != null && (pValue.startsWith(oldName + ".") || pValue.equals(oldName))) {
_pValue = newName + pValue.substring(oldName.length());
if (!pValue.equals(_pValue)) {
UIComponent object = getObject();
if (object instanceof UIDynamicTab) {
if ("tabpage".equals(propertyName)) {
((UIDynamicTab) object).setTabPage(_pValue);
hasBeenRenamed = true;
}
} else if (object instanceof UIDynamicMenuItem) {
if ("itempage".equals(propertyName)) {
((UIDynamicMenuItem) object).setItemPage(_pValue);
hasBeenRenamed = true;
}
} else if (object instanceof UIDynamicAnimate) {
if ("identifiable".equals(propertyName)) {
((UIDynamicAnimate) object).setIdentifiable(_pValue);
hasBeenRenamed = true;
}
} else if (object instanceof UIDynamicInvoke) {
if ("stack".equals(propertyName)) {
((UIDynamicInvoke) object).setSharedActionQName(_pValue);
hasBeenRenamed = true;
}
} else if (object instanceof UIUseShared) {
if ("sharedcomponent".equals(propertyName)) {
((UIUseShared) object).setSharedComponentQName(_pValue);
hasBeenRenamed = true;
}
} else if (object instanceof UIDynamicInfiniteScroll) {
if ("scrollaction".equals(propertyName)) {
((UIDynamicInfiniteScroll) object).setScrollAction(_pValue);
hasBeenRenamed = true;
}
} else if (object instanceof UIDynamicElement) {
if ("requestable".equals(propertyName)) {
((UIDynamicElement) object).getIonBean().setPropertyValue("requestable", new MobileSmartSourceType(_pValue));
hasBeenRenamed = true;
}
if ("fsview".equals(propertyName)) {
((UIDynamicElement) object).getIonBean().setPropertyValue("fsview", new MobileSmartSourceType(_pValue));
hasBeenRenamed = true;
}
if ("page".equals(propertyName)) {
((UIDynamicElement) object).getIonBean().setPropertyValue("page", new MobileSmartSourceType(_pValue));
hasBeenRenamed = true;
}
} else if (object instanceof UIText) {
if ("textValue".equals(propertyName)) {
((UIText) object).setTextSmartType(new MobileSmartSourceType(_pValue));
hasBeenRenamed = true;
}
}
}
}
if (hasBeenRenamed) {
hasBeenModified(true);
viewer.refresh();
ConvertigoPlugin.projectManager.getProjectExplorerView().updateTreeObject(NgxUIComponentTreeObject.this);
// refresh editors (e.g labels in combobox)
getDescriptors();
TreeObjectEvent treeObjectEvent = new TreeObjectEvent(NgxUIComponentTreeObject.this, propertyName, pValue, _pValue);
ConvertigoPlugin.projectManager.getProjectExplorerView().fireTreeObjectPropertyChanged(treeObjectEvent);
}
}
}
@Override
protected void refactorSmartSources(Class<?> c, String oldName, String newName) {
try {
// A project has been renamed
if (ProjectTreeObject.class.isAssignableFrom(c)) {
UIComponent object = getObject();
for (java.beans.PropertyDescriptor pd : CachedIntrospector.getBeanInfo(object).getPropertyDescriptors()) {
if (pd.getPropertyType().equals(MobileSmartSourceType.class)) {
String propertyName = pd.getName();
Object oValue = getPropertyValue(propertyName);
MobileSmartSourceType msst = (MobileSmartSourceType) oValue;
MobileSmartSource mss = msst.getSmartSource();
boolean hasBeenChanged = false;
if (mss != null) {
if (oldName.equals(mss.getProjectName())) {
mss.setProjectName(newName);
msst.setSmartValue(mss.toJsonString());
hasBeenChanged = true;
}
}
if (hasBeenChanged) {
Object nValue = getPropertyValue(propertyName);
hasBeenModified(true);
viewer.refresh();
ConvertigoPlugin.projectManager.getProjectExplorerView().updateTreeObject(NgxUIComponentTreeObject.this);
// refresh editors (e.g labels in combobox)
getDescriptors();
TreeObjectEvent treeObjectEvent = new TreeObjectEvent(NgxUIComponentTreeObject.this, propertyName, oValue, nValue);
ConvertigoPlugin.projectManager.getProjectExplorerView().fireTreeObjectPropertyChanged(treeObjectEvent);
}
}
}
}
} catch (Exception e) {
// TODO: handle exception
}
}
};
}
use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource in project convertigo by convertigo.
the class NgxPickerComposite method getSmartSourceString.
public String getSmartSourceString() {
try {
Filter filter = getFilter();
String projectName = currentMC.getProject().getName();
MobileSmartSource cmss = MobileSmartSource.valueOf(currentSource);
String input = cmss == null ? "" : cmss.getInput();
String path = getModelPath();
String searchPath = "root";
int index = path.indexOf(searchPath);
if (index != -1) {
path = path.substring(index + searchPath.length());
}
SourceModel model = MobileSmartSource.emptyModel(filter);
model.setCustom(t_custom.getText());
model.setPrefix(t_prefix.getText());
model.setSuffix(t_suffix.getText());
model.setUseCustom(b_custom.getSelection());
model.setSourceData(getModelData());
model.setPath(path);
JSONObject jsonModel = model.toJson();
// System.out.println(jsonModel.toString(1));
MobileSmartSource nmss = new MobileSmartSource(filter, projectName, input, jsonModel);
// System.out.println(nmss.toJsonString(1));
return nmss.toJsonString();
} catch (Exception e) {
return "";
}
}
use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource in project convertigo by convertigo.
the class NgxPickerComposite method initTreeSelection.
private void initTreeSelection(TreeViewer treeViewer, Object object) {
if (treeViewer != null) {
if (object == null) {
TreeItem[] treeItems = treeViewer.getTree().getItems();
if (treeItems.length > 0) {
object = treeItems[0].getData();
}
}
StructuredSelection structuredSelection = null;
if (object != null) {
structuredSelection = new StructuredSelection(object);
}
MobileSmartSource cs = MobileSmartSource.valueOf(currentSource);
if (treeViewer.equals(checkboxTreeViewer)) {
checkboxTreeViewer.expandAll();
if (cs != null) {
checkedList.clear();
fillCheckedList(null, cs.getSources());
if (checkedList.size() > 0) {
structuredSelection = new StructuredSelection(checkedList.get(0));
}
}
if (checkedList.isEmpty() && structuredSelection != null) {
checkedList.add((TVObject) structuredSelection.getFirstElement());
}
checkboxTreeViewer.setSelection(structuredSelection);
updateGrayChecked();
} else if (treeViewer.equals(modelTreeViewer)) {
modelTreeViewer.refresh();
if (cs != null) {
String modelPath = cs.getModelPath();
if (!modelPath.isEmpty()) {
modelTreeViewer.expandAll();
TVObject tvo = findModelItem(null, modelPath.replaceAll("\\?\\.", "."));
if (tvo != null) {
modelTreeViewer.collapseAll();
modelTreeViewer.expandToLevel(tvo, 0);
modelTreeViewer.setSelection(new StructuredSelection(tvo));
} else {
modelTreeViewer.collapseAll();
modelTreeViewer.expandToLevel(1);
}
}
}
}
if (cs != null) {
if (treeViewer.equals(checkboxTreeViewer)) {
checkedList.clear();
fillCheckedList(null, cs.getSources());
updateGrayChecked();
updateTexts(cs);
} else {
if (lastSelected.equals(firstSelected)) {
updateTexts(cs);
} else {
updateTexts();
}
}
} else {
updateTexts();
}
}
}
use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource in project convertigo by convertigo.
the class NgxPickerComposite method setCurrentInput.
public void setCurrentInput(Object selected, String source) {
if (isUpdating)
return;
currentMC = null;
setWidgetsEnabled(true);
if (selected instanceof NgxComponentTreeObject) {
UIComponent uic = null;
if (selected instanceof NgxPageComponentTreeObject) {
currentMC = ((NgxPageComponentTreeObject) selected).getObject();
} else if (selected instanceof NgxUIComponentTreeObject) {
uic = ((NgxUIComponentTreeObject) selected).getObject();
// currentMC = uic.getPage() != null ? uic.getPage() : (uic.getMenu() != null ? uic.getMenu() : uic.getApplication());
currentMC = currentMC == null ? uic.getPage() : currentMC;
currentMC = currentMC == null ? uic.getMenu() : currentMC;
currentMC = currentMC == null ? uic.getSharedAction() : currentMC;
currentMC = currentMC == null ? uic.getSharedComponent() : currentMC;
currentMC = currentMC == null ? uic.getApplication() : currentMC;
}
if (currentMC == null) {
resetViewers();
} else {
if (!currentMC.equals(checkboxTreeViewer.getInput())) {
resetViewers();
checkboxTreeViewer.setInput(currentMC);
initTreeSelection(checkboxTreeViewer, null);
}
MobileSmartSource cs = MobileSmartSource.valueOf(source);
if (cs != null) {
NgxPickerContentProvider contentProvider = (NgxPickerContentProvider) checkboxTreeViewer.getContentProvider();
if (isParentDialog) {
// when dbo's property edition
contentProvider.setSelectedDbo(uic);
}
ToolItem buttonToSelect = btnSequence;
currentSource = source;
Filter filter = cs.getFilter();
if (Filter.Sequence.equals(filter)) {
buttonToSelect = btnSequence;
}
if (Filter.Database.equals(filter)) {
buttonToSelect = btnDatabase;
}
if (Filter.Action.equals(filter)) {
buttonToSelect = btnAction;
}
if (Filter.Shared.equals(filter)) {
buttonToSelect = btnShared;
}
if (Filter.Iteration.equals(filter)) {
buttonToSelect = btnIteration;
}
if (Filter.Form.equals(filter)) {
buttonToSelect = btnForm;
}
if (Filter.Global.equals(filter)) {
buttonToSelect = btnGlobal;
}
buttonToSelect.notifyListeners(SWT.Selection, null);
}
}
updateMessage();
} else {
resetViewers();
updateMessage();
}
}
use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource in project convertigo by convertigo.
the class NgxPickerComposite method makeUI.
private void makeUI(Composite parent) {
parent.setLayout(new GridLayout(1, false));
parent.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
SelectionListener listener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
final NgxPickerContentProvider contentProvider = (NgxPickerContentProvider) checkboxTreeViewer.getContentProvider();
if (contentProvider != null) {
btnSequence.setSelection(false);
btnDatabase.setSelection(false);
btnAction.setSelection(false);
btnShared.setSelection(false);
btnIteration.setSelection(false);
btnForm.setSelection(false);
btnGlobal.setSelection(false);
ToolItem button = (ToolItem) e.widget;
button.setSelection(true);
if (btnSequence.getSelection()) {
contentProvider.setFilterBy(Filter.Sequence);
} else if (btnDatabase.getSelection()) {
contentProvider.setFilterBy(Filter.Database);
} else if (btnAction.getSelection()) {
contentProvider.setFilterBy(Filter.Action);
} else if (btnShared.getSelection()) {
contentProvider.setFilterBy(Filter.Shared);
} else if (btnIteration.getSelection()) {
contentProvider.setFilterBy(Filter.Iteration);
} else if (btnForm.getSelection()) {
contentProvider.setFilterBy(Filter.Form);
} else if (btnGlobal.getSelection()) {
contentProvider.setFilterBy(Filter.Global);
}
modelTreeViewer.setInput(null);
checkboxTreeViewer.getTree().removeAll();
checkboxTreeViewer.refresh();
initTreeSelection(checkboxTreeViewer, null);
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
};
SelectionListener c_listener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean isCustom = b_custom.getSelection();
boolean doSetCustomText = false;
if (isParentDialog) {
MobileSmartSource cs = MobileSmartSource.valueOf(currentSource);
if (cs != null && cs.getModel() != null && cs.getModel().getCustom().isEmpty()) {
doSetCustomText = true;
}
} else {
doSetCustomText = true;
}
if (doSetCustomText) {
MobileSmartSource nmss = MobileSmartSource.valueOf(getSmartSourceString());
if (nmss != null) {
if (isCustom && !t_custom.getEnabled()) {
t_custom.setText(nmss.getModel().computeValue());
}
if (!isCustom && t_custom.getEnabled()) {
t_custom.setText("");
}
}
}
t_custom.setEnabled(isCustom);
t_prefix.setEnabled(!isCustom);
t_data.setEnabled(!isCustom);
t_suffix.setEnabled(!isCustom);
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
};
headerComposite = new Composite(parent, SWT.NONE);
headerComposite.setLayout(SwtUtils.newGridLayout(2, false, 0, 0, 0, 0));
headerComposite.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 1, 1));
ToolBar toolbar = new ToolBar(headerComposite, SWT.NONE);
int btnStyle = SWT.CHECK;
Image image = null;
btnSequence = new ToolItem(toolbar, btnStyle);
try {
image = ConvertigoPlugin.getDefault().getIconFromPath("/com/twinsoft/convertigo/beans/core/images/sequence_color_16x16.png", BeanInfo.ICON_COLOR_16x16);
} catch (Exception e) {
btnSequence.setText("SQ");
}
btnSequence.setImage(image);
btnSequence.setToolTipText("Show Sequence Sources");
btnSequence.addSelectionListener(listener);
btnSequence.setSelection(true);
btnDatabase = new ToolItem(toolbar, btnStyle);
try {
image = ConvertigoPlugin.getDefault().getIconFromPath("/com/twinsoft/convertigo/beans/connectors/images/fullsyncconnector_color_16x16.png", BeanInfo.ICON_COLOR_16x16);
} catch (Exception e) {
btnDatabase.setText("FS");
}
btnDatabase.setImage(image);
btnDatabase.setToolTipText("Show FullSync Databases Sources");
btnDatabase.addSelectionListener(listener);
btnAction = new ToolItem(toolbar, btnStyle);
try {
image = ConvertigoPlugin.getDefault().getIconFromPath("/com/twinsoft/convertigo/beans/ngx/components/images/uicustomaction_color_16x16.png", BeanInfo.ICON_COLOR_16x16);
} catch (Exception e) {
btnAction.setText("AC");
}
btnAction.setImage(image);
btnAction.setToolTipText("Show Action Sources");
btnAction.addSelectionListener(listener);
btnShared = new ToolItem(toolbar, btnStyle);
try {
image = ConvertigoPlugin.getDefault().getIconFromPath("/com/twinsoft/convertigo/beans/ngx/components/images/uisharedcomponent_color_16x16.png", BeanInfo.ICON_COLOR_16x16);
} catch (Exception e) {
btnShared.setText("SH");
}
btnShared.setImage(image);
btnShared.setToolTipText("Show Shared component Sources");
btnShared.addSelectionListener(listener);
btnIteration = new ToolItem(toolbar, btnStyle);
try {
image = ConvertigoPlugin.getDefault().getIconFromPath("/com/twinsoft/convertigo/beans/steps/images/iterator_16x16.png", BeanInfo.ICON_COLOR_16x16);
} catch (Exception e) {
btnIteration.setText("IT");
}
btnIteration.setImage(image);
btnIteration.setToolTipText("Show Iterators on current page Sources");
btnIteration.addSelectionListener(listener);
btnForm = new ToolItem(toolbar, btnStyle);
try {
image = ConvertigoPlugin.getDefault().getIconFromPath("/com/twinsoft/convertigo/beans/ngx/components/images/uiform_color_16x16.png", BeanInfo.ICON_COLOR_16x16);
} catch (Exception e) {
btnForm.setText("FM");
}
btnForm.setImage(image);
btnForm.setToolTipText("Show Forms on current page Sources");
btnForm.addSelectionListener(listener);
btnGlobal = new ToolItem(toolbar, btnStyle);
try {
image = ConvertigoPlugin.getDefault().getIconFromPath("/com/twinsoft/convertigo/beans/ngx/components/dynamic/images/setglobalaction_color_16x16.png", BeanInfo.ICON_COLOR_16x16);
} catch (Exception e) {
btnGlobal.setText("GS");
}
btnGlobal.setImage(image);
btnGlobal.setToolTipText("Show Global Shared objects");
btnGlobal.addSelectionListener(listener);
message = new Label(headerComposite, SWT.NONE);
message.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
SashForm treesSashForm = new SashForm(parent, SWT.NONE);
treesSashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
checkboxTreeViewer = new CheckboxTreeViewer(treesSashForm, SWT.BORDER | SWT.SINGLE);
checkboxTreeViewer.setContentProvider(new NgxPickerContentProvider());
checkboxTreeViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
Object element = event.getElement();
if (element instanceof TVObject) {
if (btnIteration.getSelection() || btnForm.getSelection() || btnGlobal.getSelection()) {
checkboxTreeViewer.setChecked(element, !event.getChecked());
return;
}
TVObject tvoChecked = (TVObject) element;
if (event.getChecked())
checkedList.add(tvoChecked);
else
checkedList.remove(tvoChecked);
updateGrayChecked();
updateTexts();
}
}
});
checkboxTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
Object selected = ((IStructuredSelection) event.getSelection()).getFirstElement();
if (selected instanceof TVObject && !selected.equals(lastSelected)) {
TVObject tvoSelected = (TVObject) selected;
lastSelected = selected;
if (firstSelected == null) {
firstSelected = selected;
}
checkedList.clear();
checkedList.add(tvoSelected);
modelTreeViewer.setInput(null);
updateModel(tvoSelected);
updateGrayChecked();
updateTexts();
}
}
});
modelTreeViewer = new TreeViewer(treesSashForm, SWT.BORDER);
modelTreeViewer.setContentProvider(new NgxPickerContentProvider());
modelTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
Object selected = ((IStructuredSelection) event.getSelection()).getFirstElement();
if (selected instanceof TVObject) {
updateTexts();
}
}
});
treesSashForm.setWeights(new int[] { 1, 1 });
Composite sourceComposite = new Composite(parent, SWT.NONE);
sourceComposite.setLayout(new GridLayout(2, false));
sourceComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
if (isParentDialog) {
l_source = new Label(sourceComposite, SWT.NONE);
((Label) l_source).setText(" SOURCE ");
} else {
l_source = new Button(sourceComposite, SWT.NONE);
((Button) l_source).setText(" SOURCE ");
l_source.setToolTipText("Drag me on a Ngx UI component in the project tree to bind this source to an UI component property");
}
Composite dataComposite = new Composite(sourceComposite, SWT.NONE);
dataComposite.setLayout(new GridLayout(2, false));
dataComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
Label l_prefix = new Label(dataComposite, SWT.NONE);
l_prefix.setText("Prefix");
t_prefix = new Text(dataComposite, SWT.BORDER);
t_prefix.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
Label l_data = new Label(dataComposite, SWT.NONE);
l_data.setText("Data");
t_data = new Text(dataComposite, SWT.BORDER | SWT.READ_ONLY);
t_data.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
Label l_suffix = new Label(dataComposite, SWT.NONE);
l_suffix.setText("Suffix");
t_suffix = new Text(dataComposite, SWT.BORDER);
t_suffix.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
b_custom = new Button(dataComposite, SWT.CHECK);
b_custom.setText("Custom");
b_custom.addSelectionListener(c_listener);
t_custom = new Text(dataComposite, SWT.BORDER);
t_custom.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
t_custom.setEnabled(false);
// Add DND support
boolean dragEnabled = !isParentDialog;
if (dragEnabled) {
Transfer[] dragTransfers = new Transfer[] { MobileSourceTransfer.getInstance() };
int operations = DND.DROP_COPY | DND.DROP_MOVE;
DragSourceAdapter dragAdapter = new DragSourceAdapter() {
@Override
public void dragStart(DragSourceEvent event) {
try {
String jsonString = getSmartSourceString();
if (jsonString != null && !jsonString.isEmpty()) {
event.doit = true;
MobileSourceTransfer.getInstance().setMobileSource(new MobileSource(jsonString));
}
} catch (Exception e) {
ConvertigoPlugin.logException(e, "Cannot drag");
}
}
};
DragSource source = null;
source = new DragSource(modelTreeViewer.getTree(), operations);
source.setTransfer(dragTransfers);
source.addDragListener(dragAdapter);
source = new DragSource(l_source, operations);
source.setTransfer(dragTransfers);
source.addDragListener(dragAdapter);
}
}
Aggregations