use of org.applause.lang.applauseDsl.DataSource in project applause by applause.
the class DataSourceCallImpl method setDatasource.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setDatasource(DataSource newDatasource) {
DataSource oldDatasource = datasource;
datasource = newDatasource;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ApplauseDslPackage.DATA_SOURCE_CALL__DATASOURCE, oldDatasource, datasource));
}
use of org.applause.lang.applauseDsl.DataSource in project applause by applause.
the class DefaultListScreenClassExtensions method resourceType.
public Entity resourceType(final Screen it) {
DataSourceCall _datasource = it.getDatasource();
DataSource _datasource_1 = _datasource.getDatasource();
Entity _resourceType = _datasource_1.getResourceType();
return _resourceType;
}
use of org.applause.lang.applauseDsl.DataSource in project applause by applause.
the class DefaultListScreenEditActionCompiler method deleteMethod.
public DataSourceAccessMethod deleteMethod(final Screen it) {
DataSourceCall _datasource = it.getDatasource();
DataSource _datasource_1 = _datasource.getDatasource();
EList<DataSourceAccessMethod> _methods = _datasource_1.getMethods();
final Function1<DataSourceAccessMethod, Boolean> _function = new Function1<DataSourceAccessMethod, Boolean>() {
public Boolean apply(final DataSourceAccessMethod it) {
RESTSpecification _restSpecification = it.getRestSpecification();
RESTVerb _verb = _restSpecification.getVerb();
boolean _equals = Objects.equal(_verb, RESTVerb.DELETE);
return Boolean.valueOf(_equals);
}
};
Iterable<DataSourceAccessMethod> _filter = IterableExtensions.<DataSourceAccessMethod>filter(_methods, _function);
DataSourceAccessMethod _head = IterableExtensions.<DataSourceAccessMethod>head(_filter);
return _head;
}
use of org.applause.lang.applauseDsl.DataSource 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;
}
use of org.applause.lang.applauseDsl.DataSource in project applause by applause.
the class DefaultDetailsScreenClassExtensions method resourceType.
public Entity resourceType(final Screen it) {
DataSourceCall _datasource = it.getDatasource();
DataSource _datasource_1 = _datasource.getDatasource();
Entity _resourceType = _datasource_1.getResourceType();
return _resourceType;
}
Aggregations