com.smartgwt.client.util.BooleanCallback Java Examples
The following examples show how to use
com.smartgwt.client.util.BooleanCallback.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SubscriptionListGrid.java From SensorWebClient with GNU General Public License v2.0 | 6 votes |
protected ClickHandler createDeleteHandler(final ListGridRecord ruleRecord) { return new ClickHandler() { @Override public void onClick(ClickEvent event) { boolean subscribed = ruleRecord.getAttributeAsBoolean(SUBSCRIBED).booleanValue(); if (subscribed) { SC.say(i18n.deleteOnlyWhenUnsubbscribed()); } else { SC.ask(i18n.deleteSubscriptionQuestion(), new BooleanCallback() { @Override public void execute(Boolean value) { if (value) { String role = getLoggedInUserRole(); String uuid = ruleRecord.getAttribute(UUID); getMainEventBus().fireEvent(new DeleteRuleEvent(currentSession(), uuid, role)); removeData(ruleRecord); } } }); } } }; }
Example #2
Source File: ImportPresenter.java From proarc with GNU General Public License v3.0 | 6 votes |
private void ingest(String batchId, String parentId, final BooleanCallback call) { ImportBatchDataSource dsBatch = ImportBatchDataSource.getInstance(); DSRequest dsRequest = new DSRequest(); dsRequest.setPromptStyle(PromptStyle.DIALOG); dsRequest.setPrompt(i18n.ImportWizard_UpdateItemsStep_Ingesting_Title()); Record update = new Record(); update.setAttribute(ImportBatchDataSource.FIELD_ID, batchId); update.setAttribute(ImportBatchDataSource.FIELD_PARENT, parentId); update.setAttribute(ImportBatchDataSource.FIELD_STATE, ImportBatchDataSource.State.INGESTING.name()); dsBatch.updateData(update, new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { if (RestConfig.isStatusOk(response)) { Record[] records = response.getData(); if (records != null && records.length > 0) { importContext.setBatch(new BatchRecord(records[0])); call.execute(true); return; } } call.execute(false); } }, dsRequest); }
Example #3
Source File: DocumentDetailsPanel.java From document-management-software with GNU Lesser General Public License v3.0 | 6 votes |
public void onSave() { if (validate()) { try { // Check if the user has changed the extension and warn him if (!originalExtension.equalsIgnoreCase(Util.getExtension(document.getFileName()))) { LD.ask(I18N.message("filename"), I18N.message("extchangewarn"), new BooleanCallback() { @Override public void execute(Boolean value) { if (value) saveDocument(); } }); } else { saveDocument(); } } catch (Throwable t) { SC.warn(t.getMessage()); } } }
Example #4
Source File: DigitalObjectChildrenEditor.java From proarc with GNU General Public License v3.0 | 6 votes |
private void save() { if (originChildren == null) { return ; } Record[] rs = childrenListGrid.getOriginalResultSet().toArray(); String[] childPids = ClientUtils.toFieldValues(rs, RelationDataSource.FIELD_PID); relationDataSource.reorderChildren(digitalObject, childPids, new BooleanCallback() { @Override public void execute(Boolean value) { if (value != null && value) { originChildren = null; updateReorderUi(false); StatusView.getInstance().show(i18n.SaveAction_Done_Msg()); } } }); }
Example #5
Source File: AllRulesListGrid.java From SensorWebClient with GNU General Public License v2.0 | 6 votes |
protected Canvas createDeleteRuleButton(final ListGridRecord record) { IButton deleteButton = new IButton(i18n.delete()); deleteButton.setShowDown(false); deleteButton.setShowRollOver(false); deleteButton.setLayoutAlign(CENTER); deleteButton.setPrompt(i18n.deleteThisRule()); deleteButton.setHeight(16); deleteButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { SC.ask(i18n.reallyDeleteRule(), new BooleanCallback() { public void execute(Boolean value) { if (value) { String uuid = record.getAttribute(UUID); String userRole = getLoggedInUser(); DeleteRuleEvent deleteRuleEvent = new DeleteRuleEvent(currentSession(), uuid, userRole); EventBus.getMainEventBus().fireEvent(deleteRuleEvent); } } }); } }); return deleteButton; }
Example #6
Source File: RelationDataSource.java From proarc with GNU General Public License v3.0 | 6 votes |
public void addChild(String parentPid, String[] pid, final BooleanCallback call) { if (pid == null || pid.length < 1) { throw new IllegalArgumentException("Missing PID!"); } if (parentPid == null || parentPid.isEmpty()) { throw new IllegalArgumentException("Missing parent PID!"); } DSRequest dsRequest = new DSRequest(); Record update = new Record(); update.setAttribute(RelationDataSource.FIELD_PARENT, parentPid); update.setAttribute(RelationDataSource.FIELD_PID, pid); addData(update, new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { if (!RestConfig.isStatusOk(response)) { call.execute(false); return; } call.execute(true); } }, dsRequest); }
Example #7
Source File: OwnRulesListGrid.java From SensorWebClient with GNU General Public License v2.0 | 6 votes |
private Canvas createDeleteRuleButtonm(final ListGridRecord ruleRecord) { IButton deleteButton = new IButton(i18n.delete()); deleteButton.setShowDown(false); deleteButton.setShowRollOver(false); deleteButton.setLayoutAlign(Alignment.CENTER); deleteButton.setPrompt(i18n.deleteThisRule()); deleteButton.setHeight(16); deleteButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { SC.ask(i18n.reallyDeleteRule(), new BooleanCallback() { public void execute(Boolean value) { if (value) { String uuid = ruleRecord.getAttribute(UUID); String userRole = getLoggedInUserRole(); EventBus.getMainEventBus().fireEvent(new DeleteRuleEvent(currentSession(), uuid, userRole)); } } }); } }); return deleteButton; }
Example #8
Source File: Options.java From document-management-software with GNU Lesser General Public License v3.0 | 6 votes |
private void showContextMenu() { Menu contextMenu = new Menu(); MenuItem delete = new MenuItem(); delete.setTitle(I18N.message("ddelete")); delete.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() { public void onClick(MenuItemClickEvent event) { LD.ask(I18N.message("question"), I18N.message("confirmdelete"), new BooleanCallback() { @Override public void execute(Boolean value) { if (value) { onDelete(); } } }); } }); contextMenu.setItems(delete); contextMenu.showContextMenu(); }
Example #9
Source File: RelationDataSource.java From proarc with GNU General Public License v3.0 | 6 votes |
public void removeChild(String parentPid, String[] pid, final BooleanCallback call) { if (pid == null || pid.length < 1) { throw new IllegalArgumentException("Missing PID!"); } if (parentPid == null || parentPid.isEmpty()) { throw new IllegalArgumentException("Missing parent PID!"); } Record update = new Record(); update.setAttribute(RelationDataSource.FIELD_PARENT, parentPid); update.setAttribute(RelationDataSource.FIELD_PID, pid); DSRequest dsRequest = new DSRequest(); dsRequest.setData(update); // prevents removeData to drop other than primary key attributes removeData(update, new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { if (!RestConfig.isStatusOk(response)) { call.execute(false); return; } call.execute(true); } }, dsRequest); }
Example #10
Source File: BarcodeTemplatesPanel.java From document-management-software with GNU Lesser General Public License v3.0 | 6 votes |
private void showContextMenu() { Menu contextMenu = new Menu(); MenuItem clean = new MenuItem(); clean.setTitle(I18N.message("ddelete")); clean.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() { public void onClick(MenuItemClickEvent event) { LD.ask(I18N.message("question"), I18N.message("confirmdelete"), new BooleanCallback() { @Override public void execute(Boolean value) { if (value) { patternsGrid.removeData(patternsGrid.getSelectedRecord()); } } }); } }); contextMenu.setItems(clean); contextMenu.showContextMenu(); }
Example #11
Source File: FolderTemplatesPanel.java From document-management-software with GNU Lesser General Public License v3.0 | 6 votes |
private void showContextMenu() { Menu contextMenu = new Menu(); MenuItem clean = new MenuItem(); clean.setTitle(I18N.message("ddelete")); clean.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() { public void onClick(MenuItemClickEvent event) { LD.ask(I18N.message("question"), I18N.message("confirmdelete"), new BooleanCallback() { @Override public void execute(Boolean value) { if (value) { grid.removeData(grid.getSelectedRecord()); } } }); } }); contextMenu.setItems(clean); contextMenu.showContextMenu(); }
Example #12
Source File: ImportBatchChooser.java From proarc with GNU General Public License v3.0 | 6 votes |
private void resetImportFolder(final BatchRecord batch) { ImportBatchDataSource.State state = batch.getState(); final BooleanCallback callback = new BooleanCallback() { @Override public void execute(Boolean value) { if (value != null && value) { handler.itemReset(); } } }; if (state == ImportBatchDataSource.State.INGESTING_FAILED) { callback.execute(true); } else { askForBatchReload(callback, batch); } }
Example #13
Source File: ImportBatchItemEditor.java From proarc with GNU General Public License v3.0 | 6 votes |
public void save() { if (originChildren == null) { return ; } Record[] rs = getRecords(); if (RelationDataSource.equals(originChildren, rs)) { updateWidgetsOnSave(sourceWidget); return ; } String[] childPids = ClientUtils.toFieldValues(rs, RelationDataSource.FIELD_PID); RelationDataSource relationDataSource = RelationDataSource.getInstance(); DigitalObject root = DigitalObject.create(batchRecord); relationDataSource.reorderChildren(root, childPids, new BooleanCallback() { @Override public void execute(Boolean value) { if (value != null && value) { updateWidgetsOnSave(sourceWidget); StatusView.getInstance().show(i18n.SaveAction_Done_Msg()); } else { updateWidgetsOnSave(null); } } }); }
Example #14
Source File: ValueMapDataSource.java From proarc with GNU General Public License v3.0 | 6 votes |
public void initOnStart(final BooleanCallback callback) { if (cache == null) { cache = new ResultSet(this); cache.addDataArrivedHandler(new DataArrivedHandler() { @Override public void onDataArrived(DataArrivedEvent event) { if (cache.allRowsCached()) { callback.execute(Boolean.TRUE); } } }); cache.get(0); } else { cache.invalidateCache(); cache.get(0); } }
Example #15
Source File: LocalizationDataSource.java From proarc with GNU General Public License v3.0 | 6 votes |
public void initOnStart(final BooleanCallback callback) { if (cache == null) { cache = new ResultSet(this); cache.addDataArrivedHandler(new DataArrivedHandler() { @Override public void onDataArrived(DataArrivedEvent event) { if (cache.allRowsCached()) { callback.execute(Boolean.TRUE); } } }); cache.get(0); } else { cache.invalidateCache(); cache.get(0); } }
Example #16
Source File: SaveAction.java From proarc with GNU General Public License v3.0 | 6 votes |
/** * Saves savable object. * <pre><code> ask strategy states T ASK validate, (IfValidAsk, IfYesSave | IfNoDone) | (IfInvalidAsk, IfReallyYesSave | IfNoDone) T IGNORE ask, (IfYesSave | IfNoDone) T RUN validate, (IfValidAsk, IfYesSave | IfNoDone) | IfInvalidDone F ASK validate, IfValidSave | (IfInvalidAsk, IfYesSave | IfNoDone) F IGNORE save F RUN validate, IfValidSave | IfInvalidDone </code></pre> * * @param savable object implementing save * @param saveCallback listener to get save result * @param ask ask user before the save * @param strategy validation strategy */ public static void saveTask(Savable savable, BooleanCallback saveCallback, boolean ask, SaveValidation strategy, ClientMessages i18n) { BooleanCallback saveIfYes = new SaveIfYes(savable, saveCallback); BooleanCallback runIfValid = getRunIfValid(savable, saveCallback, ask, saveIfYes, strategy, i18n); if (strategy == SaveValidation.IGNORE) { if (ask) { askSave(saveIfYes, i18n); } else { savable.save(saveCallback); } } else { savable.validate(runIfValid); } }
Example #17
Source File: EmailAccountFiltersPanel.java From document-management-software with GNU Lesser General Public License v3.0 | 6 votes |
private void showContextMenu() { Menu contextMenu = new Menu(); MenuItem delete = new MenuItem(); delete.setTitle(I18N.message("ddelete")); delete.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() { public void onClick(MenuItemClickEvent event) { LD.ask(I18N.message("question"), I18N.message("confirmdelete"), new BooleanCallback() { @Override public void execute(Boolean value) { if (value) { list.removeSelectedData(); changedHandler.onChanged(null); } } }); } }); contextMenu.setItems(delete); contextMenu.showContextMenu(); }
Example #18
Source File: DeviceManager.java From proarc with GNU General Public License v3.0 | 6 votes |
private void saveImpl(final BooleanCallback callback) { Record update = new Record(valuesManager.getValues()); update = ClientUtils.normalizeData(update); updatingDevice = true; DeviceDataSource.getInstance().updateData(update, new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { updatingDevice = false; boolean status = RestConfig.isStatusOk(response); if (status) { StatusView.getInstance().show(i18n.SaveAction_Done_Msg()); Record[] data = response.getData(); if (data != null && data.length == 1) { Record deviceRecord = data[0]; setDescription(deviceRecord); } } callback.execute(status); } }); }
Example #19
Source File: MenuRightsPanel.java From document-management-software with GNU Lesser General Public License v3.0 | 6 votes |
/** * Prepares the context menu * * @return the context menu */ private Menu setupContextMenu() { Menu contextMenu = new Menu(); MenuItem deleteItem = new MenuItem(); deleteItem.setTitle(I18N.message("ddelete")); deleteItem.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() { public void onClick(MenuItemClickEvent event) { ListGridRecord[] selection = list.getSelectedRecords(); if (selection == null || selection.length == 0) return; LD.ask(I18N.message("question"), I18N.message("confirmdelete"), new BooleanCallback() { @Override public void execute(Boolean value) { if (value) { list.removeSelectedData(); } } }); } }); contextMenu.setItems(deleteItem); return contextMenu; }
Example #20
Source File: SaveAction.java From proarc with GNU General Public License v3.0 | 6 votes |
private static BooleanCallback getRunIfValid( final Savable savable, final BooleanCallback saveCallback, final boolean ask, final BooleanCallback saveIfYes, final SaveValidation strategy, final ClientMessages i18n) { final BooleanCallback runOnValid = new BooleanCallback() { @Override public void execute(Boolean valid) { if (valid != null && valid) { if (ask) { askSave(saveIfYes, i18n); } else { savable.save(saveCallback); } } else if (strategy == SaveValidation.ASK) { askIgnoreValidation(saveIfYes, i18n); } else { saveCallback.execute(Boolean.FALSE); } } }; return runOnValid; }
Example #21
Source File: DigitalObjectFormValidateAction.java From proarc with GNU General Public License v3.0 | 6 votes |
private void validateMods() { progress.setProgress(index, length); final Record record = digitalObjects[index]; DigitalObject dobj = DigitalObject.create(record); validator.setShowFetchPrompt(false); validator.edit(dobj, new BooleanCallback() { @Override public void execute(Boolean value) { if (value != null && value) { consumeValidation(record, validator.isValidDigitalObject()); } else { // unknown validity } ++index; // Scheduler is not necessary as fetch operations // run asynchronously ValidateTask.this.execute(); } }); }
Example #22
Source File: RelationDataSource.java From proarc with GNU General Public License v3.0 | 5 votes |
public void moveChild(final String pid, final String oldParentPid, final String parentPid, final BooleanCallback call) { moveChild(new String[] {pid}, oldParentPid, parentPid, call); }
Example #23
Source File: RelationDataSource.java From proarc with GNU General Public License v3.0 | 5 votes |
/** * Fetches relations of parent object and update caches to notify widgets. * @param parentPid PID of parent object * @param callback the callback to run on finish */ public final void updateCaches(String parentPid, final BooleanCallback callback) { Criteria criteria = new Criteria(RelationDataSource.FIELD_ROOT, parentPid); criteria.addCriteria(RelationDataSource.FIELD_PARENT, parentPid); fetchData(criteria, new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { request.setOperationType(DSOperationType.UPDATE); updateCaches(response, request); callback.execute(Boolean.TRUE); } }); }
Example #24
Source File: SaveAction.java From proarc with GNU General Public License v3.0 | 5 votes |
private static void askSave(final BooleanCallback result, ClientMessages i18n) { SC.ask(i18n.SaveAction_Ask_Msg(), new BooleanCallback() { @Override public void execute(Boolean value) { result.execute(value); } }); }
Example #25
Source File: ModsCustomEditor.java From proarc with GNU General Public License v3.0 | 5 votes |
/** * Loads a digital object into the given MODS custom form according to object's model. * * @param digitalObject digital object * @param loadCallback listens to load status */ public void edit(DigitalObject digitalObject, BooleanCallback loadCallback) { this.digitalObject = digitalObject; metadata = null; activeEditor = getCustomForm(digitalObject.getModel()); if (activeEditor != null) { ClientUtils.setMembers(widget, warning, activeEditor); loadCustom(activeEditor, digitalObject, loadCallback); } else { widget.setMembers(); } }
Example #26
Source File: WorkflowJobsEditor.java From proarc with GNU General Public License v3.0 | 5 votes |
public void onSave(WorkflowJobFormView jobFormView) { final DynamicForm vm = jobFormView.getJobValues(); if (vm.validate()) { view.setExpectUpdateOperation(true); DSRequest req = new DSRequest(); req.setWillHandleError(true); vm.saveData(new DSCallback() { @Override public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) { boolean statusOk = RestConfig.isStatusOk(dsResponse); if (statusOk) { StatusView.getInstance().show(i18n.SaveAction_Done_Msg()); //view.refreshState(); // invalidate the task cache as it may contain an outdated job name //DSResponse resetCache = new DSResponse(); //resetCache.setInvalidateCache(true); //resetCache.setOperationType(DSOperationType.UPDATE); // WorkflowTaskDataSource.getInstance().updateCaches(resetCache); jobFormView.refresh(); } else if (RestConfig.isConcurrentModification(dsResponse)) { SC.ask(i18n.SaveAction_ConcurrentErrorAskReload_Msg(), new BooleanCallback() { @Override public void execute(Boolean value) { if (value != null && value) { view.editSelection(); } } }); } else { ErrorHandler.warn(dsResponse, dsRequest); } vm.focus(); } }, req); } }
Example #27
Source File: ModsMultiEditor.java From proarc with GNU General Public License v3.0 | 5 votes |
public void save(BooleanCallback callback) { callback = wrapSaveCallback(callback); if (activeEditor == modsCustomEditor) { saveCustomData(callback); } else if (activeEditor == modsBatchEditor) { saveBatchData(callback); } else if (activeEditor == catalogBrowser) { saveCatalogData(callback); } else if (activeEditor == modsSourceEditor) { saveXmlData(callback); } else { callback.execute(Boolean.TRUE); } }
Example #28
Source File: ModsXmlEditor.java From proarc with GNU General Public License v3.0 | 5 votes |
private void saveImpl(final BooleanCallback callback, String newXml) { ModsCustomDataSource.getInstance().saveXmlDescription(digitalObject, newXml, timestamp, new DescriptionSaveHandler() { @Override protected void onSave(DescriptionMetadata dm) { super.onSave(dm); refresh(false); callback.execute(Boolean.TRUE); } @Override protected void onError() { super.onError(); callback.execute(Boolean.FALSE); } @Override protected void onValidationError() { // Do not ignore XML validation! String msg = i18n.SaveAction_IgnoreRemoteInvalid_Msg(getValidationMessage()); SC.ask(i18n.SaveAction_Title(), msg, value -> { // save again if (value != null && value) { ModsCustomDataSource.getInstance().saveXmlDescription(digitalObject, newXml, timestamp, this, true); } }); } }); }
Example #29
Source File: ModsBatchEditor.java From proarc with GNU General Public License v3.0 | 5 votes |
public void execute(BooleanCallback taskDoneCallback) { this.taskDoneCallback = taskDoneCallback; index = 0; length = -1; stop = false; execute(); }
Example #30
Source File: DigitalObjectParentEditor.java From proarc with GNU General Public License v3.0 | 5 votes |
private void save() { if (chooser.isChanged()) { final Record newParent = chooser.getSelectedParent(); String parentPid = chooser.getSelectedParentPid(); String oldParentPid = chooser.getOldParentPid(); final RelationDataSource ds = RelationDataSource.getInstance(); String[] pids = DigitalObject.toPidArray(digitalObjects); BooleanCallback saveCallback = new BooleanCallback() { @Override public void execute(Boolean value) { if (value != null && value) { chooser.onSave(newParent); StatusView.getInstance().show(i18n.SaveAction_Done_Msg()); ds.fireRelationChange(digitalObjects[0].getPid()); place.goTo(new DigitalObjectManagerPlace()); } // else refresh? } }; if (oldParentPid == null && parentPid != null) { ds.addChild(parentPid, pids, saveCallback); } else if (oldParentPid != null && parentPid == null) { ds.removeChild(oldParentPid, pids, saveCallback); } else { ds.moveChild(pids, oldParentPid, parentPid, saveCallback); } } }