@CanExecute public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART) MDirtyable dirtyable) { if (dirtyable == null) { return false; } return dirtyable.isDirty(); }
@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); } }