protected void disableCells() { workingSetMode.setEnabled(false); workingSetName.setEnabled(false); description.setEnabled(false); filterPanel.setEnabled(false); notes.setEnabled(false); people.disable(); }
protected void clearCells() { managerHTML.setText(""); dateCreatedHTML.setText(""); // workingSetMode.setEnabled(true); // workingSetMode.setSelectedIndex(0); // workingSetName.setEnabled(true); filterPanel.setFilter(new AssessmentFilter()); workingSetName.setText(""); description.setEnabled(true); description.setText(""); notes.setEnabled(true); notes.setText(""); people.enable(); people.clearItemsInList(); }
private void savePublicWorkingSet(final WorkingSetData currentWorkingSet, final int saveMode) { final String name = currentWorkingSet.getWorkingSetName(); currentWorkingSet.setFilter(filterPanel.getFilter()); if (id == null) { WorkingSetCache.impl.addToPublicWorkingSets( currentWorkingSet, new GenericCallback<String>() { public void onFailure(Throwable caught) { Info.display( "ERROR", "Error saving working set " + name + ".", "Please" + " try saving again."); } public void onSuccess(String arg0) { id = currentWorkingSet.getId(); WSStore.getStore().update(); ClientUIContainer.bodyContainer.tabManager.panelManager.workingSetHierarchy .setCurrentlySelected(id); if (saveMode == SAVE) { Info.display( new InfoConfig("Successful Save", "Successfully saved working set " + name)); manager.workingSetBrowser.setEditWorkingSetTab(); } else if (saveMode == SAVEANDEXIT) { Info.display( new InfoConfig("Successful Save", "Successfully saved working set " + name)); manager.workingSetBrowser.setManagerTab(); } else { manager.workingSetBrowser.setEditTaxaTab(); manager.workingSetOptionsPanel.forceRefreshTaxaList( WorkingSetOptionsPanel.ADDBROWSE); } enableSaveButtons(true); } }); } else if (AuthorizationCache.impl.hasRight( SimpleSISClient.currentUser, AuthorizableObject.WRITE, WorkingSetCache.impl.getCurrentWorkingSet())) { WorkingSetCache.impl.editWorkingSet( currentWorkingSet, new GenericCallback<String>() { public void onFailure(Throwable caught) { Info.display( "ERROR", "Error saving working set " + name + ".", "Please" + " try saving again."); } public void onSuccess(String arg0) { WSStore.getStore().update(); ClientUIContainer.bodyContainer.tabManager.panelManager.workingSetHierarchy .setCurrentlySelected(id); if (saveMode == SAVE) { Info.display( new InfoConfig("Successful Save", "Successfully saved working set " + name)); } else if (saveMode == SAVEANDEXIT) { Info.display( new InfoConfig("Successful Save", "Successfully saved working set " + name)); manager.workingSetBrowser.setManagerTab(); } else { manager.workingSetBrowser.setEditTaxaTab(); manager.workingSetOptionsPanel.forceRefreshTaxaList( WorkingSetOptionsPanel.ADDBROWSE); } enableSaveButtons(true); } }); } else { WindowUtils.errorAlert("You do not have permissions to edit this working set."); enableSaveButtons(true); } }
private void savePrivateWorkingSet(final WorkingSetData currentWorkingSet, final int saveMode) { final String name = currentWorkingSet.getWorkingSetName(); AssessmentFilter filter = filterPanel.getFilter(); currentWorkingSet.setFilter(filter); if (id == null) { WorkingSetCache.impl.addToPrivateWorkingSets( currentWorkingSet, new GenericCallback<String>() { public void onFailure(Throwable caught) { Info.display( "ERROR", "Error saving working set " + name + ".", "Please" + " try saving again."); enableSaveButtons(true); } public void onSuccess(String arg0) { id = currentWorkingSet.getId(); WSStore.getStore().update(); ClientUIContainer.bodyContainer.tabManager.panelManager.workingSetHierarchy .setCurrentlySelected(id); if (saveMode == SAVE) { Info.display( new InfoConfig("Successful Save", "Successfully saved working set " + name)); manager.workingSetBrowser.setEditWorkingSetTab(); } else if (saveMode == SAVEANDEXIT) { Info.display( new InfoConfig("Successful Save", "Successfully saved working set " + name)); manager.workingSetBrowser.setManagerTab(); } else { manager.workingSetBrowser.setEditTaxaTab(); manager.workingSetOptionsPanel.forceRefreshTaxaList( WorkingSetOptionsPanel.ADDBROWSE); } enableSaveButtons(true); } }); } else { WorkingSetCache.impl.editWorkingSet( currentWorkingSet, new GenericCallback<String>() { public void onFailure(Throwable caught) { Info.display( "ERROR", "Error saving working set " + name + ".", "Please" + " try saving again."); enableSaveButtons(true); } public void onSuccess(String arg0) { id = currentWorkingSet.getId(); WSStore.getStore().update(); ClientUIContainer.bodyContainer.tabManager.panelManager.workingSetHierarchy .setCurrentlySelected(id); if (saveMode == SAVE) { Info.display( new InfoConfig("Successful Save", "Successfully saved working set " + name)); } else if (saveMode == SAVEANDEXIT) { Info.display( new InfoConfig("Successful Save", "Successfully saved working set " + name)); manager.workingSetBrowser.setManagerTab(); } else { manager.workingSetBrowser.setEditTaxaTab(); manager.workingSetOptionsPanel.forceRefreshTaxaList( WorkingSetOptionsPanel.ADDBROWSE); } enableSaveButtons(true); } }); } }
private void save(final int saveMode) { enableSaveButtons(false); String date = dateCreatedHTML.getText(); String manager = managerHTML.getText(); String descriptionText = XMLUtils.clean(description.getText()); String notesText = XMLUtils.clean(notes.getText()); final String name = XMLUtils.clean(workingSetName.getText()); final String errorFilter = filterPanel.checkValidity(); // CHECK TO MAKE SURE FIELDS ARE ENTERED IN if (name == null || name.trim().equals("")) { WindowUtils.errorAlert("Please enter a working set name."); enableSaveButtons(true); return; } if (errorFilter != null) { WindowUtils.errorAlert(errorFilter); } else if (descriptionText == null || descriptionText.trim().equals("")) { WindowUtils.errorAlert("Please enter a working set description."); enableSaveButtons(true); return; } else if (workingSetMode.getSelectedIndex() != PRIVATEINDEX && workingSetMode.getSelectedIndex() != PUBLICINDEX) { WindowUtils.errorAlert("Please select the working set type."); enableSaveButtons(true); return; } // HAVEN'T SAVED BEFORE if (id == null) { final WorkingSetData currentWorkingSet = new WorkingSetData(); currentWorkingSet.setDate(date); currentWorkingSet.setCreator(manager); currentWorkingSet.setDescription(descriptionText); currentWorkingSet.setNotes(notesText); currentWorkingSet.setWorkingSetName(name); currentWorkingSet.setMode(workingSetMode.getItemText(workingSetMode.getSelectedIndex())); currentWorkingSet.setPeople(people.getItemsInList()); currentWorkingSet.setFilter(filterPanel.getFilter()); if (currentWorkingSet.getMode().equalsIgnoreCase(WorkingSetData.PRIVATE)) { savePrivateWorkingSet(currentWorkingSet, saveMode); workingSetMode.setEnabled(false); } else { savePublicWorkingSet(currentWorkingSet, saveMode); workingSetMode.setEnabled(false); } // this.manager.workingSetHierarchy.update(); WSStore.getStore().update(); } // ALREADY HAVE BEEN SAVED BEFORE, REALLY EDITTING else { final WorkingSetData currentWorkingSet = (WorkingSetData) WorkingSetCache.impl.getWorkingSets().get(id); if (currentWorkingSet != null) { currentWorkingSet.setDescription(descriptionText); currentWorkingSet.setNotes(notesText); currentWorkingSet.setWorkingSetName(name); currentWorkingSet.setPeople(people.getItemsInList()); currentWorkingSet.setFilter(filterPanel.getFilter()); String mode = currentWorkingSet.getMode(); String newMode = workingSetMode.getItemText(workingSetMode.getSelectedIndex()); if (!mode.equalsIgnoreCase(newMode)) { // CHANGING TO PRIVATE if (newMode.equalsIgnoreCase(WorkingSetData.PRIVATE)) { WindowUtils.confirmAlert( "Warning", "Changing a working set from public to private creates" + " a copy of the working set into your private directory but does not" + " delete the working set out of the public directory.", new Listener<MessageBoxEvent>() { public void handleEvent(MessageBoxEvent be) { if (be.getType() == Events.Close) { if (be.getButtonClicked().getType().equals(MessageBox.OK)) { savePublicToPrivateWorkingSet(currentWorkingSet, saveMode); } } } }); } // CHANGING TO PUBLIC if (newMode.equalsIgnoreCase(WorkingSetData.PRIVATE)) { WindowUtils.confirmAlert( "Warning", "Changing a working set from private to public will allow your " + "working set to be viewed by other people.", new Listener<MessageBoxEvent>() { public void handleEvent(MessageBoxEvent be) { if (be.getType() == Events.Close) { if (be.getButtonClicked().getType().equals(MessageBox.OK)) { savePrivateToPublicWorkingSet(currentWorkingSet, saveMode); } } } }); } } else if (currentWorkingSet.getMode().equalsIgnoreCase(WorkingSetData.PRIVATE)) savePrivateWorkingSet(currentWorkingSet, saveMode); else savePublicWorkingSet(currentWorkingSet, saveMode); } } }