@Inject public void setSelection(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) Contact contact) { if (contact != null) { if (dirtyable.isDirty()) { MessageDialog dialog = new MessageDialog( detailComposite.getShell(), "Save vCard", null, "The current vCard has been modified. Save changes?", MessageDialog.CONFIRM, new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}, 0); dialog.create(); ThemeUtil.applyDialogStyles(engine, dialog.getShell()); if (dialog.open() == Window.OK) { ParameterizedCommand saveCommand = commandService.createCommand("contacts.save", Collections.EMPTY_MAP); handlerService.executeHandler(saveCommand); } } updatePartTitle(contact); } else { uiItem.setLabel("Details"); } dirtyable.setDirty(false); if (!detailComposite.isDisposed()) { detailComposite.update(contact); } }
@Persist public void doSave(@Optional IProgressMonitor monitor) throws IOException, InterruptedException { if (monitor == null) { monitor = new NullProgressMonitor(); } monitor.beginTask("Saving contact details to vCard...", 16); Contact originalContact = detailComposite.getOriginalContact(); Contact modifiedContact = detailComposite.getModifiedContact(); saveAsVCard(modifiedContact, modifiedContact.getSourceFile()); originalContact.setCity(modifiedContact.getCity()); Thread.sleep(50); monitor.worked(1); originalContact.setCompany(modifiedContact.getCompany()); Thread.sleep(50); monitor.worked(1); originalContact.setCountry(modifiedContact.getCountry()); Thread.sleep(50); monitor.worked(1); originalContact.setEmail(modifiedContact.getEmail()); Thread.sleep(50); monitor.worked(1); originalContact.setFirstName(modifiedContact.getFirstName()); Thread.sleep(50); monitor.worked(1); originalContact.setJobTitle(modifiedContact.getJobTitle()); Thread.sleep(50); monitor.worked(1); originalContact.setLastName(modifiedContact.getLastName()); Thread.sleep(50); monitor.worked(1); originalContact.setMiddleName(modifiedContact.getMiddleName()); Thread.sleep(50); monitor.worked(1); originalContact.setMobile(modifiedContact.getMobile()); Thread.sleep(50); monitor.worked(1); originalContact.setNote(modifiedContact.getNote()); Thread.sleep(50); monitor.worked(1); originalContact.setPhone(modifiedContact.getPhone()); Thread.sleep(50); monitor.worked(1); originalContact.setState(modifiedContact.getState()); Thread.sleep(50); monitor.worked(1); originalContact.setStreet(modifiedContact.getStreet()); Thread.sleep(50); monitor.worked(1); originalContact.setTitle(modifiedContact.getTitle()); Thread.sleep(50); monitor.worked(1); originalContact.setWebPage(modifiedContact.getWebPage()); Thread.sleep(50); monitor.worked(1); originalContact.setZip(modifiedContact.getZip()); Thread.sleep(50); monitor.worked(1); updatePartTitle(originalContact); monitor.done(); dirtyable.setDirty(false); }