Search in sources :

Example 1 with RouteFullsyncEvent

use of com.twinsoft.convertigo.beans.mobile.components.RouteFullsyncEvent in project convertigo by convertigo.

the class MobileRouteEventComponentTreeObject method getNamedSourceSelector.

@Override
public NamedSourceSelector getNamedSourceSelector() {
    return new NamedSourceSelector() {

        @Override
        Object thisTreeObject() {
            return MobileRouteEventComponentTreeObject.this;
        }

        @Override
        protected List<String> getPropertyNamesForSource(Class<?> c) {
            List<String> list = new ArrayList<String>();
            if (getObject() instanceof RouteEventComponent) {
                if (ProjectTreeObject.class.isAssignableFrom(c) || SequenceTreeObject.class.isAssignableFrom(c) || ConnectorTreeObject.class.isAssignableFrom(c)) {
                    list.add("source");
                }
            }
            return list;
        }

        @Override
        protected boolean isNamedSource(String propertyName) {
            if (getObject() instanceof RouteEventComponent) {
                return "source".equals(propertyName);
            }
            return false;
        }

        @Override
        public boolean isSelectable(String propertyName, Object nsObject) {
            if (getObject() instanceof RouteEventComponent) {
                if ("source".equals(propertyName)) {
                    RouteEventComponent rec = getObject();
                    if (rec instanceof RouteSequenceEvent) {
                        return nsObject instanceof Sequence;
                    }
                    if (rec instanceof RouteFullsyncEvent) {
                        return nsObject instanceof FullSyncConnector;
                    }
                }
            }
            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;
                String pValue = (String) getPropertyValue(propertyName);
                if (pValue != null && pValue.startsWith(oldName)) {
                    String _pValue = newName + pValue.substring(oldName.length());
                    if (!pValue.equals(_pValue)) {
                        if (getObject() instanceof RouteEventComponent) {
                            if ("source".equals(propertyName)) {
                                ((RouteEventComponent) getObject()).setSource(_pValue);
                                hasBeenRenamed = true;
                            }
                        }
                    }
                }
                if (hasBeenRenamed) {
                    hasBeenModified(true);
                    ConvertigoPlugin.projectManager.getProjectExplorerView().updateTreeObject(MobileRouteEventComponentTreeObject.this);
                    // refresh editors (e.g labels in combobox)
                    getDescriptors();
                    TreeObjectEvent treeObjectEvent = new TreeObjectEvent(MobileRouteEventComponentTreeObject.this, propertyName, "", "");
                    ConvertigoPlugin.projectManager.getProjectExplorerView().fireTreeObjectPropertyChanged(treeObjectEvent);
                }
            }
        }
    };
}
Also used : RouteSequenceEvent(com.twinsoft.convertigo.beans.mobile.components.RouteSequenceEvent) RouteFullsyncEvent(com.twinsoft.convertigo.beans.mobile.components.RouteFullsyncEvent) ArrayList(java.util.ArrayList) Sequence(com.twinsoft.convertigo.beans.core.Sequence) FullSyncConnector(com.twinsoft.convertigo.beans.connectors.FullSyncConnector) TreeObjectEvent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeObjectEvent) RouteEventComponent(com.twinsoft.convertigo.beans.mobile.components.RouteEventComponent)

Aggregations

FullSyncConnector (com.twinsoft.convertigo.beans.connectors.FullSyncConnector)1 Sequence (com.twinsoft.convertigo.beans.core.Sequence)1 RouteEventComponent (com.twinsoft.convertigo.beans.mobile.components.RouteEventComponent)1 RouteFullsyncEvent (com.twinsoft.convertigo.beans.mobile.components.RouteFullsyncEvent)1 RouteSequenceEvent (com.twinsoft.convertigo.beans.mobile.components.RouteSequenceEvent)1 TreeObjectEvent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeObjectEvent)1 ArrayList (java.util.ArrayList)1