List of usage examples for org.eclipse.jface.dialogs MessageDialog openQuestion
public static boolean openQuestion(Shell parent, String title, String message)
From source file:ch.elexis.core.ui.contacts.preferences.BezugsKontaktSettings.java
License:Open Source License
@Override protected Control createContents(Composite parent) { updateExistingEntriesIds.clear();/*from w w w .j a va 2 s .c om*/ Composite container = new Composite(parent, SWT.NULL); container.setLayout(new GridLayout(1, false)); Group group = new Group(container, SWT.NONE); group.setLayout(new GridLayout(1, false)); group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); group.setText(Messages.Bezugskontakt_Definition); Composite composite = new Composite(group, SWT.NONE); GridData gd_composite = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gd_composite.heightHint = 300; composite.setLayoutData(gd_composite); TableColumnLayout tcl_composite = new TableColumnLayout(); composite.setLayout(tcl_composite); tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION); tableViewer.setContentProvider(ArrayContentProvider.getInstance()); tableBezugsKontaktRelations = tableViewer.getTable(); tableBezugsKontaktRelations.setHeaderVisible(true); tableBezugsKontaktRelations.setLinesVisible(true); if (allowEditing) { Menu menu = new Menu(tableBezugsKontaktRelations); tableBezugsKontaktRelations.setMenu(menu); MenuItem mntmAddBezugsKontaktRelation = new MenuItem(menu, SWT.NONE); mntmAddBezugsKontaktRelation.setText(Messages.Bezugskontakt_Add); mntmAddBezugsKontaktRelation.setImage(Images.IMG_NEW.getImage()); mntmAddBezugsKontaktRelation.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { BezugsKontaktRelation bezugsKontaktRelation = new BezugsKontaktRelation("", RelationshipType.AGENERIC, RelationshipType.AGENERIC); tableViewer.add(bezugsKontaktRelation); tableViewer.setSelection(new StructuredSelection(bezugsKontaktRelation)); } }); MenuItem mntmRemoveBezugsKontaktRelation = new MenuItem(menu, SWT.NONE); mntmRemoveBezugsKontaktRelation.setText(Messages.Bezugskontakt_Delete); mntmRemoveBezugsKontaktRelation.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { int selectionsIdx = tableViewer.getTable().getSelectionIndex(); if (selectionsIdx != -1) { boolean ret = MessageDialog.openQuestion(UiDesk.getTopShell(), Messages.Bezugskontakt_ConfirmDelete, Messages.Bezugskontakt_ConfirmDeleteText); if (ret) { tableViewer.getTable().remove(selectionsIdx); } } } }); } TableViewerColumn viewCol = new TableViewerColumn(tableViewer, SWT.NONE); TableColumn col = viewCol.getColumn(); tcl_composite.setColumnData(col, new ColumnWeightData(1, 140)); col.setText(Messages.BezugsKonktat_Reference); col.setToolTipText(Messages.Bezugskontakt_ReferenceTooltip); viewCol.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { BezugsKontaktRelation s = (BezugsKontaktRelation) cell.getElement(); if (s == null) return; cell.setText(s.getName()); } }); viewCol.setEditingSupport(new EditingSupport(tableViewer) { @Override protected void setValue(Object element, Object value) { if (element instanceof BezugsKontaktRelation) { String newName = String.valueOf(value); BezugsKontaktRelation tableData = null; for (TableItem tableItem : tableViewer.getTable().getItems()) { tableData = (BezugsKontaktRelation) tableItem.getData(); if (tableData != null && !tableData.equals(element) && !tableData.getName().isEmpty() && newName.equalsIgnoreCase(tableData.getName())) { MessageDialog.openError(UiDesk.getTopShell(), "", Messages.Bezugskontakt_NameMustBeUnique); return; } } BezugsKontaktRelation bezugsKontaktRelation = (BezugsKontaktRelation) element; if (!bezugsKontaktRelation.getName().equals(newName)) { bezugsKontaktRelation.setName(newName); getViewer().update(bezugsKontaktRelation, null); openConfirmUpdateExistingData(bezugsKontaktRelation); } } } @Override protected Object getValue(Object element) { if (element instanceof BezugsKontaktRelation) { return ((BezugsKontaktRelation) element).getName(); } return null; } @Override protected CellEditor getCellEditor(Object element) { return new TextCellEditor(tableViewer.getTable()); } @Override protected boolean canEdit(Object element) { return allowEditing; } }); viewCol = new TableViewerColumn(tableViewer, SWT.NONE); col = viewCol.getColumn(); tcl_composite.setColumnData(col, new ColumnWeightData(0, 140)); col.setText(Messages.Bezugskontakt_RelationFrom); viewCol.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { BezugsKontaktRelation s = (BezugsKontaktRelation) cell.getElement(); if (s == null) return; cell.setText(LocalizeUtil.getLocaleText(s.getDestRelationType())); } }); viewCol.setEditingSupport(new EditingSupport(tableViewer) { @Override protected void setValue(Object element, Object value) { if (element instanceof BezugsKontaktRelation && value instanceof Integer) { BezugsKontaktRelation bezugsKontaktRelation = (BezugsKontaktRelation) element; RelationshipType[] allRelationshipTypes = RelationshipType.values(); if ((int) value != -1 && !bezugsKontaktRelation.getDestRelationType() .equals(allRelationshipTypes[(int) value])) { bezugsKontaktRelation.setDestRelationType(allRelationshipTypes[(int) value]); getViewer().update(bezugsKontaktRelation, null); openConfirmUpdateExistingData(bezugsKontaktRelation); } } } @Override protected Object getValue(Object element) { if (element instanceof BezugsKontaktRelation) { BezugsKontaktRelation bezugsKontaktRelation = (BezugsKontaktRelation) element; RelationshipType relationshipType = bezugsKontaktRelation.getDestRelationType(); if (relationshipType != null) { return relationshipType.getValue(); } } return 0; } @Override protected CellEditor getCellEditor(Object element) { return new ComboBoxCellEditor(tableViewer.getTable(), BezugsKontaktAuswahl.getBezugKontaktTypes(), SWT.NONE); } @Override protected boolean canEdit(Object element) { return allowEditing; } }); viewCol = new TableViewerColumn(tableViewer, SWT.NONE); col = viewCol.getColumn(); tcl_composite.setColumnData(col, new ColumnWeightData(0, 140)); col.setText(Messages.Bezugskontakt_RelationTo); viewCol.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { BezugsKontaktRelation s = (BezugsKontaktRelation) cell.getElement(); if (s == null) return; cell.setText(LocalizeUtil.getLocaleText(s.getSrcRelationType())); } }); viewCol.setEditingSupport(new EditingSupport(tableViewer) { @Override protected void setValue(Object element, Object value) { if (element instanceof BezugsKontaktRelation && value instanceof Integer) { BezugsKontaktRelation bezugsKontaktRelation = (BezugsKontaktRelation) element; RelationshipType[] allRelationshipTypes = RelationshipType.values(); if ((int) value != -1 && !bezugsKontaktRelation.getSrcRelationType() .equals(allRelationshipTypes[(int) value])) { bezugsKontaktRelation.setSrcRelationType(allRelationshipTypes[(int) value]); getViewer().update(bezugsKontaktRelation, null); openConfirmUpdateExistingData(bezugsKontaktRelation); } } } @Override protected Object getValue(Object element) { if (element instanceof BezugsKontaktRelation) { BezugsKontaktRelation bezugsKontaktRelation = (BezugsKontaktRelation) element; RelationshipType relationshipType = bezugsKontaktRelation.getSrcRelationType(); if (relationshipType != null) { return relationshipType.getValue(); } } return 0; } @Override protected CellEditor getCellEditor(Object element) { return new ComboBoxCellEditor(tableViewer.getTable(), BezugsKontaktAuswahl.getBezugKontaktTypes(), SWT.NONE); } @Override protected boolean canEdit(Object element) { return allowEditing; } }); ; tableViewer .setInput(loadBezugKonkaktTypes(CoreHub.globalCfg.get(Patientenblatt2.CFG_BEZUGSKONTAKTTYPEN, ""))); return container; }
From source file:ch.elexis.core.ui.contacts.preferences.BezugsKontaktSettings.java
License:Open Source License
private void openConfirmUpdateExistingData(BezugsKontaktRelation bezugsKontaktRelation) { if (!updateExistingEntriesIds.contains(bezugsKontaktRelation.getId())) { BezugsKontaktRelation initalBezugKonktaktRelation = getInitalBezugKontakt( bezugsKontaktRelation.getId()); if (initalBezugKonktaktRelation != null) { boolean ret = MessageDialog.openQuestion(UiDesk.getTopShell(), "", Messages.Bezugskontakt_ConfirmUpdateExisting); if (ret) { updateExistingEntriesIds.add(bezugsKontaktRelation.getId()); }/* w ww . j ava 2 s . c o m*/ } } }
From source file:ch.elexis.core.ui.laboratory.preferences.LaborPrefs.java
License:Open Source License
@Override protected void contributeButtons(Composite parent) { ((GridLayout) parent.getLayout()).numColumns++; Button bMappingFrom2_1_7 = new Button(parent, SWT.PUSH); bMappingFrom2_1_7.setText(Messages.LaborPrefs_mappingFrom2_1_7); bMappingFrom2_1_7.addSelectionListener(new SelectionAdapter() { @Override//from w w w . j a va 2 s. c o m public void widgetSelected(SelectionEvent e) { try { // execute the command IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getService(IHandlerService.class); handlerService.executeCommand(CreateMappingFrom2_1_7.COMMANDID, null); } catch (Exception ex) { throw new RuntimeException(CreateMappingFrom2_1_7.COMMANDID, ex); } tableViewer.refresh(); } }); if (CoreHub.acl.request(AccessControlDefaults.LABITEM_MERGE) == true) { ((GridLayout) parent.getLayout()).numColumns++; Button bImportMapping = new Button(parent, SWT.PUSH); bImportMapping.setText(Messages.LaborPrefs_mergeLabItems); bImportMapping.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { // execute the command IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getService(IHandlerService.class); handlerService.executeCommand(CreateMergeLabItemUi.COMMANDID, null); } catch (Exception ex) { throw new RuntimeException(CreateMergeLabItemUi.COMMANDID, ex); } tableViewer.refresh(); } }); } ((GridLayout) parent.getLayout()).numColumns++; Button bImportMapping = new Button(parent, SWT.PUSH); bImportMapping.setText(Messages.LaborPrefs_importLabMapping); bImportMapping.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { // execute the command IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getService(IHandlerService.class); handlerService.executeCommand(CreateImportMappingUi.COMMANDID, null); } catch (Exception ex) { throw new RuntimeException(CreateImportMappingUi.COMMANDID, ex); } tableViewer.refresh(); } }); ((GridLayout) parent.getLayout()).numColumns++; Button bNewItem = new Button(parent, SWT.PUSH); bNewItem.setText(Messages.LaborPrefs_labValue); bNewItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { // execute the command IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getService(IHandlerService.class); handlerService.executeCommand(CreateLabItemUi.COMMANDID, null); } catch (Exception ex) { throw new RuntimeException(CreateLabItemUi.COMMANDID, ex); } tableViewer.refresh(); } }); ((GridLayout) parent.getLayout()).numColumns++; Button bDelItem = new Button(parent, SWT.PUSH); bDelItem.setText(Messages.LaborPrefs_deleteItem); bDelItem.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { IStructuredSelection sel = (IStructuredSelection) tableViewer.getSelection(); Object o = sel.getFirstElement(); if (o instanceof LabItem) { LabItem li = (LabItem) o; if (MessageDialog.openQuestion(getShell(), Messages.LaborPrefs_deleteItem, MessageFormat.format(Messages.LaborPrefs_deleteReallyItem, li.getLabel()))) { if (deleteResults(li)) { deleteMappings(li); li.delete(); tableViewer.remove(li); } else { MessageDialog.openWarning(getShell(), Messages.LaborPrefs_deleteItem, Messages.LaborPrefs_deleteFail); } } } } }); ((GridLayout) parent.getLayout()).numColumns++; Button bDelAllItems = new Button(parent, SWT.PUSH); bDelAllItems.setText(Messages.LaborPrefs_deleteAllItems); bDelAllItems.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (SWTHelper.askYesNo(Messages.LaborPrefs_deleteReallyAllItems, Messages.LaborPrefs_deleteAllExplain)) { Query<LabItem> qbli = new Query<LabItem>(LabItem.class); List<LabItem> items = qbli.execute(); boolean success = true; for (LabItem li : items) { if (deleteResults(li)) { deleteMappings(li); li.delete(); } else { success = false; } } if (!success) { MessageDialog.openWarning(getShell(), Messages.LaborPrefs_deleteAllItems, Messages.LaborPrefs_deleteFail); } tableViewer.refresh(); } } }); if (CoreHub.acl.request(AccessControlDefaults.DELETE_LABITEMS) == false) { bDelAllItems.setEnabled(false); } }
From source file:ch.elexis.core.ui.medication.views.FixMediDisplay.java
License:Open Source License
private void makeActions() { changeMedicationAction = new RestrictedAction(AccessControlDefaults.MEDICATION_MODIFY, Messages.FixMediDisplay_Change) { //$NON-NLS-1$ {/*w ww . j a v a 2s . c o m*/ setImageDescriptor(Images.IMG_EDIT.getImageDescriptor()); setToolTipText(Messages.FixMediDisplay_Modify); //$NON-NLS-1$ } public void doRun() { Prescription pr = getSelection(); if (pr != null) { MediDetailDialog md = new MediDetailDialog(getShell(), pr, true); md.setExecutedFrom(FixMediDisplay.class.getSimpleName()); md.open(); ElexisEventDispatcher.getInstance() .fire(new ElexisEvent(pr, Prescription.class, ElexisEvent.EVENT_UPDATE)); } } }; stopMedicationAction = new RestrictedAction(AccessControlDefaults.MEDICATION_MODIFY, Messages.FixMediDisplay_Stop) { //$NON-NLS-1$ { setImageDescriptor(Images.IMG_REMOVEITEM.getImageDescriptor()); setToolTipText(Messages.FixMediDisplay_StopThisMedicament); //$NON-NLS-1$ } public void doRun() { Prescription pr = getSelection(); if (pr != null) { remove(pr); AcquireLockUi.aquireAndRun(pr, new ILockHandler() { @Override public void lockFailed() { // do nothing } @Override public void lockAcquired() { if (pr.delete()) { pr.setStopReason("Gendert durch " + CoreHub.actUser.getLabel()); } } }); ElexisEventDispatcher.getInstance() .fire(new ElexisEvent(pr, Prescription.class, ElexisEvent.EVENT_UPDATE)); } } }; addDefaultSignatureAction = new Action(Messages.FixMediDisplay_AddDefaultSignature) { { setImageDescriptor(Images.IMG_BOOKMARK_PENCIL.getImageDescriptor()); setToolTipText(Messages.FixMediDisplay_AddDefaultSignature_Tooltip); } @Override public void run() { Prescription pr = getSelection(); if (pr != null) { ArticleDefaultSignatureTitleAreaDialog adtad = new ArticleDefaultSignatureTitleAreaDialog( UiDesk.getTopShell(), pr); adtad.open(); } } }; removeMedicationAction = new RestrictedAction(AccessControlDefaults.DELETE_MEDICATION, Messages.FixMediDisplay_Delete) { //$NON-NLS-1$ { setImageDescriptor(Images.IMG_DELETE.getImageDescriptor()); setToolTipText(Messages.FixMediDisplay_DeleteUnrecoverable); //$NON-NLS-1$ } public void doRun() { Prescription pr = getSelection(); if (pr != null) { if (MessageDialog.openQuestion(getShell(), Messages.FixMediDisplay_DeleteUnrecoverable, Messages.FixMediDisplay_DeleteUnrecoverable)) { remove(pr); AcquireLockUi.aquireAndRun(pr, new ILockHandler() { @Override public void lockFailed() { // do nothing } @Override public void lockAcquired() { pr.remove(); // this does, in fact, remove the medication from the database } }); ElexisEventDispatcher.getInstance() .fire(new ElexisEvent(pr, Prescription.class, ElexisEvent.EVENT_UPDATE)); } } } }; }
From source file:ch.elexis.data.Konsultation.java
License:Open Source License
/** * Creates a new Konsultation object, with an optional initial text. * //from w w w . j av a2 s .c o m * @param initialText * the initial text to be set, or null if no initial text should be set. */ public static void neueKons(final String initialText) { Patient actPatient = ElexisEventDispatcher.getSelectedPatient(); Fall actFall = (Fall) ElexisEventDispatcher.getSelected(Fall.class); if (actFall == null) { if (actPatient == null) { SWTHelper.showError(Messages.getString("GlobalActions.CantCreateKons"), //$NON-NLS-1$ Messages.getString("GlobalActions.DoSelectPatient")); //$NON-NLS-1$ return; } if (actFall == null) { Konsultation k = actPatient.getLetzteKons(false); if (k != null) { actFall = k.getFall(); if (actFall == null) { SWTHelper.showError(Messages.getString("GlobalActions.CantCreateKons"), //$NON-NLS-1$ Messages.getString("GlobalActions.DoSelectCase")); //$NON-NLS-1$ return; } } else { Fall[] faelle = actPatient.getFaelle(); if ((faelle == null) || (faelle.length == 0)) { actFall = actPatient.neuerFall(Fall.getDefaultCaseLabel(), Fall.getDefaultCaseReason(), Fall.getDefaultCaseLaw()); } else { actFall = faelle[0]; } } } } else { if (!actFall.getPatient().equals(actPatient)) { Konsultation lk = actPatient.getLetzteKons(false); if (lk == null) { SWTHelper.showError(Messages.getString("GlobalActions.CantCreateKons"), //$NON-NLS-1$ Messages.getString("GlobalActions.DoSelectCase")); //$NON-NLS-1$ return; } else { actFall = lk.getFall(); } } } if (!actFall.isOpen()) { SWTHelper.showError(Messages.getString("GlobalActions.casclosed"), //$NON-NLS-1$ Messages.getString("GlobalActions.caseclosedexplanation")); //$NON-NLS-1$ return; } Konsultation actLetzte = actFall.getLetzteBehandlung(); if ((actLetzte != null) && actLetzte.getDatum().equals(new TimeTool().toString(TimeTool.DATE_GER))) { if (MessageDialog.openQuestion(Desk.getTopShell(), Messages.getString("GlobalActions.SecondForToday"), //$NON-NLS-1$ Messages.getString("GlobalActions.SecondForTodayQuestion")) == false) { //$NON-NLS-1$ return; } } Konsultation n = actFall.neueKonsultation(); n.setMandant(Hub.actMandant); if (initialText != null) { n.updateEintrag(initialText, false); } if (getDefaultDiagnose() != null) n.addDiagnose(getDefaultDiagnose()); ElexisEventDispatcher.fireSelectionEvent(actFall); ElexisEventDispatcher.fireSelectionEvent(n); }
From source file:ch.hsr.eclipse.cdt.ui.toggle.ToggleFileCreator.java
License:Open Source License
public boolean askUserForFileCreation(final ToggleRefactoringContext context) { if (context.isSettedDefaultAnswer()) { return context.getDefaultAnswer(); }//from w w w . j av a 2 s. com final Container<Boolean> answer = new Container<Boolean>(); Runnable r = new Runnable() { @Override public void run() { Shell shell = UIPlugin.getDefault().getWorkbench().getWorkbenchWindows()[0].getShell(); String functionname; if (context.getDeclaration() != null) { functionname = context.getDeclaration().getRawSignature(); } else { functionname = context.getDefinition().getDeclarator().getRawSignature(); } boolean createnew = MessageDialog.openQuestion(shell, "New Implementation file?", "Create a new file named: " + getNewFileName() + " and move " + functionname + "?"); answer.setObject(createnew); } }; PlatformUI.getWorkbench().getDisplay().syncExec(r); return answer.getObject(); }
From source file:ch.medshare.mediport.MediportOutputter.java
private boolean clientParamsOk(ClientParam param) { if (param == null) { MessageDialog.openError(new Shell(), getDescription(), Messages.getString("MediportOutputter.error.msg.unknownParameter")); //$NON-NLS-1$ return false; }//from ww w . ja v a 2 s . co m String message = null; MPCProperties props = getProperties(); if (props != null) { String serverIp = props.getProperty(ConfigKeys.MEDIPORT_IP); if (MediportMainPrefPage.VALUE_SERVER_URL_TEST.equals(serverIp)) { message = Messages.getString("MediportOutputter.info.testServer"); //$NON-NLS-1$ } else if (MediportMainPrefPage.LBL_SERVER_TEST .equals(prefs.getString(MediportMainPrefPage.MPC_SERVER))) { message = Messages.getString("MediportOutputter.info.test"); //$NON-NLS-1$ } } if (message != null) { return MessageDialog.openQuestion(new Shell(), getDescription(), message + "\n" + Messages.getString("MediportOutputter.question.Fortfahren")); //$NON-NLS-1$ //$NON-NLS-2$ } return true; }
From source file:ch.novcom.elexis.mednet.plugin.ui.preferences.ContactLinkPreferencePage.java
License:Open Source License
@Override protected void contributeButtons(Composite parent) { ((GridLayout) parent.getLayout()).numColumns++; Button bNewItem = new Button(parent, SWT.PUSH); bNewItem.setText(MedNetMessages.ContactLinkPreferences_new); bNewItem.addSelectionListener(new SelectionAdapter() { @Override//from w w w.ja va2s . co m public void widgetSelected(SelectionEvent e) { try { // execute the command IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getService(IHandlerService.class); handlerService.executeCommand(ContactLinkRecordCreate.COMMANDID, null); } catch (Exception ex) { throw new RuntimeException(ContactLinkRecordCreate.COMMANDID, ex); } tableViewer.refresh(); } }); ((GridLayout) parent.getLayout()).numColumns++; Button bDelItem = new Button(parent, SWT.PUSH); bDelItem.setText(MedNetMessages.ContactLinkPreferences_delete); bDelItem.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { IStructuredSelection sel = (IStructuredSelection) tableViewer.getSelection(); Object o = sel.getFirstElement(); if (o instanceof ContactLinkRecord) { ContactLinkRecord li = (ContactLinkRecord) o; if (MessageDialog.openQuestion(getShell(), MedNetMessages.ContactLinkPreferences_delete, MessageFormat.format(MedNetMessages.ContactLinkPreferences_reallyDelete, li.getLabel()))) { if (deleteRecord(li)) { li.removeFromDatabase(); tableViewer.remove(li); } else { MessageDialog.openWarning(getShell(), MedNetMessages.ContactLinkPreferences_delete, MedNetMessages.ContactLinkPreferences_deleteFailed); } } } } }); ((GridLayout) parent.getLayout()).numColumns++; Button bDelAllItems = new Button(parent, SWT.PUSH); bDelAllItems.setText(MedNetMessages.ContactLinkPreferences_deleteAll); bDelAllItems.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (SWTHelper.askYesNo(MedNetMessages.ContactLinkPreferences_deleteAllTitle, MedNetMessages.ContactLinkPreferences_deleteAllExplain)) { Query<ContactLinkRecord> qbli = new Query<ContactLinkRecord>(ContactLinkRecord.class); List<ContactLinkRecord> items = qbli.execute(); boolean success = true; for (ContactLinkRecord li : items) { if (deleteRecord(li)) { li.removeFromDatabase(); } else { success = false; } } if (!success) { MessageDialog.openWarning(getShell(), MedNetMessages.ContactLinkPreferences_deleteAll, MedNetMessages.ContactLinkPreferences_deleteAllFailed); } tableViewer.refresh(); } } }); if (CoreHub.acl.request(AccessControlDefaults.DELETE_LABITEMS) == false) { bDelAllItems.setEnabled(false); } }
From source file:ch.novcom.elexis.mednet.plugin.ui.preferences.DocumentPreferencePage.java
License:Open Source License
@Override protected void contributeButtons(Composite parent) { ((GridLayout) parent.getLayout()).numColumns++; Button bNewItem = new Button(parent, SWT.PUSH); bNewItem.setText(MedNetMessages.DocumentPreferences_new); bNewItem.addSelectionListener(new SelectionAdapter() { @Override//from w w w .j a v a 2s . c o m public void widgetSelected(SelectionEvent e) { try { // execute the command IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getService(IHandlerService.class); handlerService.executeCommand(DocumentSettingRecordCreate.COMMANDID, null); } catch (Exception ex) { throw new RuntimeException(DocumentSettingRecordCreate.COMMANDID, ex); } tableViewer.refresh(); } }); ((GridLayout) parent.getLayout()).numColumns++; Button bDelItem = new Button(parent, SWT.PUSH); bDelItem.setText(MedNetMessages.DocumentPreferences_delete); bDelItem.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { IStructuredSelection sel = (IStructuredSelection) tableViewer.getSelection(); Object o = sel.getFirstElement(); if (o instanceof DocumentSettingRecord) { DocumentSettingRecord li = (DocumentSettingRecord) o; if (MessageDialog.openQuestion(getShell(), MedNetMessages.DocumentPreferences_delete, MessageFormat.format(MedNetMessages.DocumentPreferences_reallyDelete, li.getLabel()))) { if (deleteRecord(li)) { li.delete(); tableViewer.remove(li); } else { MessageDialog.openWarning(getShell(), MedNetMessages.DocumentPreferences_delete, MedNetMessages.DocumentPreferences_deleteFailed); } } } } }); ((GridLayout) parent.getLayout()).numColumns++; Button bDelAllItems = new Button(parent, SWT.PUSH); bDelAllItems.setText(MedNetMessages.DocumentPreferences_deleteAll); bDelAllItems.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (SWTHelper.askYesNo(MedNetMessages.DocumentPreferences_reallyDeleteAll, MedNetMessages.DocumentPreferences_deleteAllExplain)) { Query<DocumentSettingRecord> qbli = new Query<DocumentSettingRecord>( DocumentSettingRecord.class); List<DocumentSettingRecord> items = qbli.execute(); boolean success = true; for (DocumentSettingRecord li : items) { if (deleteRecord(li)) { li.delete(); } else { success = false; } } if (!success) { MessageDialog.openWarning(getShell(), MedNetMessages.DocumentPreferences_deleteAll, MedNetMessages.DocumentPreferences_deleteAllFailed); } tableViewer.refresh(); } } }); if (CoreHub.acl.request(AccessControlDefaults.DELETE_LABITEMS) == false) { bDelAllItems.setEnabled(false); } }
From source file:cl.utfsm.acs.acg.gui.actions.LoadFromCDBActionDelegate.java
License:Open Source License
@Override public void run(IAction action) { if (_window == null) return;/*from ww w. j a v a 2 s.com*/ boolean confirmLoad; confirmLoad = MessageDialog.openQuestion(_window.getShell(), "Load from CDB", "Load contents from the CDB?"); if (!confirmLoad) return; final Display display = _window.getShell().getDisplay(); new Thread(new Runnable() { public void run() { display.syncExec(new Runnable() { public void run() { // Disable all views IViewReference[] views = _window.getActivePage().getViewReferences(); for (int i = 0; i < views.length; i++) { if (views[i].getView(false) instanceof IMyViewPart) ((IMyViewPart) views[i].getView(false)).setEnabled(false); } } }); // Reload information from the CDB AlarmSystemManager.getInstance().loadFromCDB(); display.asyncExec(new Runnable() { public void run() { // Enable all views, and reload their contents IViewReference[] views = _window.getActivePage().getViewReferences(); for (int i = 0; i < views.length; i++) { if (views[i].getView(false) instanceof IMyViewPart) { IMyViewPart view = ((IMyViewPart) views[i].getView(false)); view.setEnabled(true); view.refreshContents(); } } } }); } }).start(); }