Search in sources :

Example 6 with UIComponentMemberConfiguration

use of org.applause.lang.applauseDsl.UIComponentMemberConfiguration in project applause by applause.

the class DefaultDetailsScreenModuleFileCompiler method detailsConfig.

public UIComponentMemberConfiguration detailsConfig(final ScreenListItemCell it) {
    EList<UIComponentMemberConfiguration> _configurations = it.getConfigurations();
    final Function1<UIComponentMemberConfiguration, Boolean> _function = new Function1<UIComponentMemberConfiguration, Boolean>() {

        public Boolean apply(final UIComponentMemberConfiguration it) {
            UIComponentMemberCall _type = it.getType();
            UIComponentMemberDeclaration _component = _type.getComponent();
            String _name = _component.getName();
            boolean _equals = Objects.equal(_name, "details");
            return Boolean.valueOf(_equals);
        }
    };
    UIComponentMemberConfiguration _findFirst = IterableExtensions.<UIComponentMemberConfiguration>findFirst(_configurations, _function);
    return _findFirst;
}
Also used : Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) UIComponentMemberConfiguration(org.applause.lang.applauseDsl.UIComponentMemberConfiguration) UIComponentMemberCall(org.applause.lang.applauseDsl.UIComponentMemberCall) UIComponentMemberDeclaration(org.applause.lang.applauseDsl.UIComponentMemberDeclaration)

Example 7 with UIComponentMemberConfiguration

use of org.applause.lang.applauseDsl.UIComponentMemberConfiguration in project applause by applause.

the class DefaultListScreenModuleFileCompiler method compileModule.

public CharSequence compileModule(final Screen it) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("#import \"");
    String _screenHeaderFileName = this._defaultListScreenClassExtensions.screenHeaderFileName(it);
    _builder.append(_screenHeaderFileName, "");
    _builder.append("\"");
    _builder.newLineIfNotEmpty();
    _builder.append("#import \"");
    Entity _resourceType = this._defaultListScreenClassExtensions.resourceType(it);
    String _entityDataAccessCategoryHeaderFileName = this._dataAccessClassExtensions.entityDataAccessCategoryHeaderFileName(_resourceType);
    _builder.append(_entityDataAccessCategoryHeaderFileName, "");
    _builder.append("\"");
    _builder.newLineIfNotEmpty();
    _builder.append("#import \"");
    Screen _targetNavigationScreen = this._defaultListScreenClassExtensions.targetNavigationScreen(it);
    String _screenHeaderFileName_1 = this._defaultListScreenClassExtensions.screenHeaderFileName(_targetNavigationScreen);
    _builder.append(_screenHeaderFileName_1, "");
    _builder.append("\"");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("@interface ");
    String _controllerClassName = this._defaultListScreenClassExtensions.controllerClassName(it);
    _builder.append(_controllerClassName, "");
    _builder.append(" ()");
    _builder.newLineIfNotEmpty();
    _builder.append("@property(nonatomic, strong) NSMutableArray *items;\t\t");
    _builder.newLine();
    _builder.append("@end");
    _builder.newLine();
    _builder.newLine();
    _builder.append("@implementation ");
    String _controllerClassName_1 = this._defaultListScreenClassExtensions.controllerClassName(it);
    _builder.append(_controllerClassName_1, "");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("static NSString *kCellIdentifier = @\"");
    DataSourceCall _datasource = it.getDatasource();
    DataSource _datasource_1 = _datasource.getDatasource();
    Entity _resourceType_1 = _datasource_1.getResourceType();
    String _typeName = this._typeExtensions.typeName(_resourceType_1);
    _builder.append(_typeName, "");
    _builder.append("Cell\";");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("- (id)initWithStyle:(UITableViewStyle)style");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("self = [super initWithStyle:style];");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("if (self) {");
    _builder.newLine();
    {
        String _title = it.getTitle();
        boolean _notEquals = (!Objects.equal(_title, null));
        if (_notEquals) {
            _builder.append("\t\t");
            _builder.append("self.title = @\"");
            String _title_1 = it.getTitle();
            _builder.append(_title_1, "		");
            _builder.append("\";");
            _builder.newLineIfNotEmpty();
        }
    }
    _builder.append("\t\t");
    _builder.append("// register table view cell");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:kCellIdentifier];");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("[self.tableView setDelegate:self];;");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("// refresh control");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("self.refreshControl = [[UIRefreshControl alloc] init];");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("[self.refreshControl addTarget:self action:@selector(refresh) forControlEvents:UIControlEventValueChanged];");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.newLine();
    _builder.append("\t\t");
    CharSequence _compileActionButtons = this._defaultListScreenActionCompiler.compileActionButtons(it);
    _builder.append(_compileActionButtons, "		");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("return self;");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("- (void)viewDidLoad");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("[super viewDidLoad];");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("[self reload];");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("- (void)didReceiveMemoryWarning");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("[super didReceiveMemoryWarning];");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("#pragma mark - Table view data source");
    _builder.newLine();
    _builder.newLine();
    _builder.append("- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("return [self.items count];");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier forIndexPath:indexPath];");
    _builder.newLine();
    _builder.append("    ");
    _builder.newLine();
    _builder.append("\t");
    Entity _resourceType_2 = this._defaultListScreenClassExtensions.resourceType(it);
    String _typeName_1 = this._typeExtensions.typeName(_resourceType_2);
    _builder.append(_typeName_1, "	");
    _builder.append(" *item = self.items[(NSUInteger) indexPath.row];");
    _builder.newLineIfNotEmpty();
    {
        Iterable<UIComponentMemberConfiguration> _configurations = this._defaultListScreenClassExtensions.configurations(it);
        for (final UIComponentMemberConfiguration it_1 : _configurations) {
            _builder.append("\t");
            CharSequence _compileConfiguration = this.compileConfiguration(it_1);
            _builder.append(_compileConfiguration, "	");
            _builder.newLineIfNotEmpty();
        }
    }
    _builder.newLine();
    _builder.append("    ");
    _builder.append("return cell;");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("#pragma mark - Table view delegate");
    _builder.newLine();
    _builder.newLine();
    _builder.append("- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    Entity _resourceType_3 = this._defaultListScreenClassExtensions.resourceType(it);
    String _typeName_2 = this._typeExtensions.typeName(_resourceType_3);
    _builder.append(_typeName_2, "	");
    _builder.append(" *item = self.items[(NSUInteger) indexPath.row];");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("[self onEditItem:item];");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    {
        boolean _supportsDeleteAction = this._defaultListScreenEditActionCompiler.supportsDeleteAction(it);
        if (_supportsDeleteAction) {
            CharSequence _compileCommitEditing = this._defaultListScreenEditActionCompiler.compileCommitEditing(it);
            _builder.append(_compileCommitEditing, "");
            _builder.newLineIfNotEmpty();
        }
    }
    _builder.newLine();
    _builder.append("#pragma mark - Data access");
    _builder.newLine();
    _builder.newLine();
    _builder.append("- (void)refresh");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("[self reload];");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("- (void)reload");
    _builder.newLine();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("[");
    Entity _resourceType_4 = this._defaultListScreenClassExtensions.resourceType(it);
    String _typeName_3 = this._typeExtensions.typeName(_resourceType_4);
    _builder.append(_typeName_3, "	");
    _builder.append(" ");
    DataSourceAccessMethod _restMethod = this._defaultListScreenClassExtensions.restMethod(it);
    String _name = _restMethod.getName();
    _builder.append(_name, "	");
    _builder.append(":^(NSArray *items, NSError *error)");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("[self.refreshControl endRefreshing];");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("if (error) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("[[[UIAlertView alloc] initWithTitle:NSLocalizedString(@\"Error\", nil)");
    _builder.newLine();
    _builder.append("\t\t\t\t\t\t\t\t\t\t");
    _builder.append("message:[error localizedDescription]");
    _builder.newLine();
    _builder.append("\t\t\t\t\t\t\t\t\t   ");
    _builder.append("delegate:nil");
    _builder.newLine();
    _builder.append("\t\t\t\t\t\t\t  ");
    _builder.append("cancelButtonTitle:nil");
    _builder.newLine();
    _builder.append("\t\t\t\t\t\t\t  ");
    _builder.append("otherButtonTitles:NSLocalizedString(@\"OK\", nil), nil] show];");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("else {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("self.items = [NSMutableArray arrayWithArray:items];");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("[self.tableView reloadData];");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}];");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("#pragma mark - Actions");
    _builder.newLine();
    _builder.newLine();
    CharSequence _compileActionMethods = this._defaultListScreenActionCompiler.compileActionMethods(it);
    _builder.append(_compileActionMethods, "");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("@end");
    _builder.newLine();
    return _builder;
}
Also used : Entity(org.applause.lang.applauseDsl.Entity) DataSourceCall(org.applause.lang.applauseDsl.DataSourceCall) DataSourceAccessMethod(org.applause.lang.applauseDsl.DataSourceAccessMethod) Screen(org.applause.lang.applauseDsl.Screen) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) UIComponentMemberConfiguration(org.applause.lang.applauseDsl.UIComponentMemberConfiguration) DataSource(org.applause.lang.applauseDsl.DataSource)

Example 8 with UIComponentMemberConfiguration

use of org.applause.lang.applauseDsl.UIComponentMemberConfiguration in project applause by applause.

the class DefaultDetailsScreenModuleFileCompiler method entryElementName.

public String entryElementName(final ScreenListItemCell it) {
    UIComponentMemberConfiguration _detailsConfig = this.detailsConfig(it);
    Expression _value = _detailsConfig.getValue();
    String _evaluateExpression = this._expressionExtensions.evaluateExpression(_value);
    String _firstLower = StringExtensions.toFirstLower(_evaluateExpression);
    String _plus = (_firstLower + "Element");
    return _plus;
}
Also used : Expression(org.applause.lang.applauseDsl.Expression) UIComponentMemberConfiguration(org.applause.lang.applauseDsl.UIComponentMemberConfiguration)

Example 9 with UIComponentMemberConfiguration

use of org.applause.lang.applauseDsl.UIComponentMemberConfiguration in project applause by applause.

the class DefaultDetailsScreenModuleFileCompiler method configurations.

public Iterable<UIComponentMemberConfiguration> configurations(final Screen it) {
    EList<ScreenSection> _sections = it.getSections();
    final Function1<ScreenSection, ScreenSectionItems> _function = new Function1<ScreenSection, ScreenSectionItems>() {

        public ScreenSectionItems apply(final ScreenSection it) {
            ScreenSectionItems _items = it.getItems();
            return _items;
        }
    };
    List<ScreenSectionItems> _map = ListExtensions.<ScreenSection, ScreenSectionItems>map(_sections, _function);
    final Function1<ScreenSectionItems, EList<ScreenListItemCell>> _function_1 = new Function1<ScreenSectionItems, EList<ScreenListItemCell>>() {

        public EList<ScreenListItemCell> apply(final ScreenSectionItems it) {
            EList<ScreenListItemCell> _items = it.getItems();
            return _items;
        }
    };
    List<EList<ScreenListItemCell>> _map_1 = ListExtensions.<ScreenSectionItems, EList<ScreenListItemCell>>map(_map, _function_1);
    Iterable<ScreenListItemCell> _flatten = Iterables.<ScreenListItemCell>concat(_map_1);
    final Function1<ScreenListItemCell, EList<UIComponentMemberConfiguration>> _function_2 = new Function1<ScreenListItemCell, EList<UIComponentMemberConfiguration>>() {

        public EList<UIComponentMemberConfiguration> apply(final ScreenListItemCell it) {
            EList<UIComponentMemberConfiguration> _configurations = it.getConfigurations();
            return _configurations;
        }
    };
    Iterable<EList<UIComponentMemberConfiguration>> _map_2 = IterableExtensions.<ScreenListItemCell, EList<UIComponentMemberConfiguration>>map(_flatten, _function_2);
    Iterable<UIComponentMemberConfiguration> _flatten_1 = Iterables.<UIComponentMemberConfiguration>concat(_map_2);
    return _flatten_1;
}
Also used : ScreenListItemCell(org.applause.lang.applauseDsl.ScreenListItemCell) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) ScreenSectionItems(org.applause.lang.applauseDsl.ScreenSectionItems) ScreenSection(org.applause.lang.applauseDsl.ScreenSection) EList(org.eclipse.emf.common.util.EList) UIComponentMemberConfiguration(org.applause.lang.applauseDsl.UIComponentMemberConfiguration)

Aggregations

UIComponentMemberConfiguration (org.applause.lang.applauseDsl.UIComponentMemberConfiguration)9 Expression (org.applause.lang.applauseDsl.Expression)4 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)4 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)4 ScreenListItemCell (org.applause.lang.applauseDsl.ScreenListItemCell)2 ScreenSection (org.applause.lang.applauseDsl.ScreenSection)2 ScreenSectionItems (org.applause.lang.applauseDsl.ScreenSectionItems)2 UIComponentMemberCall (org.applause.lang.applauseDsl.UIComponentMemberCall)2 UIComponentMemberDeclaration (org.applause.lang.applauseDsl.UIComponentMemberDeclaration)2 EList (org.eclipse.emf.common.util.EList)2 DataSource (org.applause.lang.applauseDsl.DataSource)1 DataSourceAccessMethod (org.applause.lang.applauseDsl.DataSourceAccessMethod)1 DataSourceCall (org.applause.lang.applauseDsl.DataSourceCall)1 Entity (org.applause.lang.applauseDsl.Entity)1 Screen (org.applause.lang.applauseDsl.Screen)1