@Override public void onSourceTabSelected() { context.setEditionMode(DataModelerContext.EditionMode.SOURCE_MODE); if (context.isParsed() && context.isEditorChanged()) { // If there are changes in the ui the source must be regenerated on server side. view.showLoading(); modelerService .call( new RemoteCallback<GenerationResult>() { @Override public void callback(GenerationResult result) { view.hideBusyIndicator(); setSource(result.getSource()); updateSource(result.getSource()); context.setEditionStatus(DataModelerContext.EditionStatus.NO_CHANGES); dataModelerWBContext.setActiveContext(context); } }, new DataModelerErrorCallback(Constants.INSTANCE.modelEditor_loading_error())) .updateSource( getSource(), versionRecordManager.getCurrentPath(), context.getDataObject()); } else { if (!isOverviewTabSelected()) { context.setEditionStatus(DataModelerContext.EditionStatus.NO_CHANGES); } updateSource(javaSourceEditor.getContent()); dataModelerWBContext.setActiveContext(context); } }
@OnFocus public void onFocus() { if (!loading && context != null) { dataModelerWBContext.setActiveContext(context); showDataModellerDocks(); } }
@Override public void onEditTabSelected() { boolean doParsing = false; if (context.isSourceChanged()) { // if there has been changes in the source we should try to parse the file and build the data // object again. doParsing = true; } else if (context.isNotParsed()) { // uncommon case, the file wasn't parsed yet. doParsing = true; } if (doParsing) { view.showLoading(); // If there are changes in the source, we must try to parse the file. modelerService .call( new RemoteCallback<GenerationResult>() { @Override public void callback(GenerationResult result) { view.hideBusyIndicator(); if (result.hasErrors()) { showParseErrorsDialog( Constants.INSTANCE.modelEditor_message_file_parsing_errors(), true, result.getErrors(), new Command() { @Override public void execute() { // return to the source tab setSelectedTab(EDITABLE_SOURCE_TAB); context.setParseStatus(DataModelerContext.ParseStatus.PARSE_ERRORS); updateEditorView(null); context.setDataObject(null); context.setEditionMode(DataModelerContext.EditionMode.SOURCE_MODE); dataModelerWBContext.setActiveContext(context); } }); } else { // ok, we can reload the editor tab. context.setParseStatus(DataModelerContext.ParseStatus.PARSED); updateEditorView(result.getDataObject()); context.setEditionStatus(DataModelerContext.EditionStatus.NO_CHANGES); context.setDataObject(result.getDataObject()); context.setObjectProperty(null); context.setEditionMode(DataModelerContext.EditionMode.GRAPHICAL_MODE); view.setContext(context); cleanSystemMessages(getCurrentMessageType()); dataModelerWBContext.setActiveContext(context); } } }, new DataModelerErrorCallback(Constants.INSTANCE.modelEditor_loading_error())) .updateDataObject( context.getDataObject(), getSource(), versionRecordManager.getCurrentPath()); } else { // no changes in the source tab if (!isOverviewTabSelected()) { context.setEditionStatus(DataModelerContext.EditionStatus.NO_CHANGES); } if (context.isParseErrors()) { // there are parse errors, the editor tab couldn't be loaded. (errors are already // published) showParseErrorsDialog( Constants.INSTANCE.modelEditor_message_file_parsing_errors(), false, null, new Command() { @Override public void execute() { context.setEditionMode(DataModelerContext.EditionMode.SOURCE_MODE); dataModelerWBContext.setActiveContext(context); setSelectedTab(EDITABLE_SOURCE_TAB); } }); } else { context.setEditionMode(DataModelerContext.EditionMode.GRAPHICAL_MODE); dataModelerWBContext.setActiveContext(context); } } }
@Override public void onOverviewSelected() { context.setEditionMode(DataModelerContext.EditionMode.SOURCE_MODE); dataModelerWBContext.setActiveContext(context); }