Search in sources :

Example 6 with Screen

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

the class ScreensValidationTestHelper method hasDataSource.

public void hasDataSource(final CharSequence sequence) {
    try {
        final Model model = this._parseHelper.parse(sequence);
        EList<NamedElement> _elements = model.getElements();
        Iterable<Screen> _filter = Iterables.<Screen>filter(_elements, Screen.class);
        final Screen screen = IterableExtensions.<Screen>head(_filter);
        DataSourceCall _datasource = screen.getDatasource();
        Assert.assertNotNull(_datasource);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : DataSourceCall(org.applause.lang.applauseDsl.DataSourceCall) Screen(org.applause.lang.applauseDsl.Screen) Model(org.applause.lang.applauseDsl.Model) NamedElement(org.applause.lang.applauseDsl.NamedElement)

Example 7 with Screen

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

the class ScreensValidationTestHelper method hasTitle.

public void hasTitle(final CharSequence sequence, final String expectedTitle) {
    try {
        final Model model = this._parseHelper.parse(sequence);
        EList<NamedElement> _elements = model.getElements();
        NamedElement _head = IterableExtensions.<NamedElement>head(_elements);
        final Screen screen = ((Screen) _head);
        String _title = screen.getTitle();
        Assert.assertNotNull(_title);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : Screen(org.applause.lang.applauseDsl.Screen) Model(org.applause.lang.applauseDsl.Model) NamedElement(org.applause.lang.applauseDsl.NamedElement)

Example 8 with Screen

use of org.applause.lang.applauseDsl.Screen 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 9 with Screen

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

the class DefaultListScreenActionCompiler method compileActionMethod.

private CharSequence compileActionMethod(final UIAction it) {
    CharSequence _xifexpression = null;
    UIActionSpecification _action = it.getAction();
    if ((_action instanceof UIActionNavigateAction)) {
        CharSequence _switchResult = null;
        UIActionSpecification _action_1 = it.getAction();
        ActionVerb _actionVerb = ((UIActionNavigateAction) _action_1).getActionVerb();
        final ActionVerb _switchValue = _actionVerb;
        boolean _matched = false;
        if (!_matched) {
            if (Objects.equal(_switchValue, ActionVerb.ADD)) {
                _matched = true;
                Screen _screen = this._defaultListScreenClassExtensions.screen(it);
                CharSequence _compileActionMethod_AddItem = this.compileActionMethod_AddItem(_screen);
                _switchResult = _compileActionMethod_AddItem;
            }
        }
        if (!_matched) {
            if (Objects.equal(_switchValue, ActionVerb.EDIT)) {
                _matched = true;
                Screen _screen_1 = this._defaultListScreenClassExtensions.screen(it);
                CharSequence _compileActionMethod_EditItem = this.compileActionMethod_EditItem(_screen_1);
                _switchResult = _compileActionMethod_EditItem;
            }
        }
        _xifexpression = _switchResult;
    }
    return _xifexpression;
}
Also used : UIActionNavigateAction(org.applause.lang.applauseDsl.UIActionNavigateAction) ActionVerb(org.applause.lang.applauseDsl.ActionVerb) Screen(org.applause.lang.applauseDsl.Screen) UIActionSpecification(org.applause.lang.applauseDsl.UIActionSpecification)

Example 10 with Screen

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

the class ScreensValidationTestHelper method isValidScreen.

public void isValidScreen(final CharSequence sequence) {
    try {
        final Model model = this._parseHelper.parse(sequence);
        EList<NamedElement> _elements = model.getElements();
        NamedElement _head = IterableExtensions.<NamedElement>head(_elements);
        final Screen screen = ((Screen) _head);
        String _name = screen.getName();
        Assert.assertNotNull(_name);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : Screen(org.applause.lang.applauseDsl.Screen) Model(org.applause.lang.applauseDsl.Model) NamedElement(org.applause.lang.applauseDsl.NamedElement)

Aggregations

Screen (org.applause.lang.applauseDsl.Screen)11 Entity (org.applause.lang.applauseDsl.Entity)3 Model (org.applause.lang.applauseDsl.Model)3 NamedElement (org.applause.lang.applauseDsl.NamedElement)3 UIActionNavigateAction (org.applause.lang.applauseDsl.UIActionNavigateAction)3 UIActionSpecification (org.applause.lang.applauseDsl.UIActionSpecification)3 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)3 ActionVerb (org.applause.lang.applauseDsl.ActionVerb)2 DataSourceCall (org.applause.lang.applauseDsl.DataSourceCall)2 DataSource (org.applause.lang.applauseDsl.DataSource)1 DataSourceAccessMethod (org.applause.lang.applauseDsl.DataSourceAccessMethod)1 ScreenKind (org.applause.lang.applauseDsl.ScreenKind)1 ScreenListItemCell (org.applause.lang.applauseDsl.ScreenListItemCell)1 UIAction (org.applause.lang.applauseDsl.UIAction)1 UIComponentMemberConfiguration (org.applause.lang.applauseDsl.UIComponentMemberConfiguration)1 EObject (org.eclipse.emf.ecore.EObject)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)1 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)1