List of usage examples for org.eclipse.jface.dialogs MessageDialog WARNING
int WARNING
To view the source code for org.eclipse.jface.dialogs MessageDialog WARNING.
Click Source Link
From source file:org.bbaw.pdr.ae.backup.commands.CreateEmptyDBHandler.java
License:Open Source License
@Override public final Object execute(final ExecutionEvent event) throws ExecutionException { if (!_urChecker.isUserGuest()) { Shell activeShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(activeShell); try {//from w ww . j a va 2 s .c o m dialog.run(true, true, new IRunnableWithProgress() { @Override public void run(final IProgressMonitor monitor) { monitor.beginTask("Delete Data from Database and create new and empty Databases", HUNDRED); boolean backupSuccessfull = false; UIJob job = new UIJob("Feedbackup") { @Override public IStatus runInUIThread(final IProgressMonitor monitor) { IWorkbench workbench = PlatformUI.getWorkbench(); Display display = workbench.getDisplay(); Shell shell = new Shell(display); String message = NLMessages.getString("Handler_empty_db_warning"); message += "\n" + NLMessages.getString("Handler_empty_db_warning2"); MessageDialog messageDialog = new MessageDialog(shell, NLMessages.getString("Handler_empty_db_title"), null, message, MessageDialog.INFORMATION, new String[] { NLMessages.getString("Handler_yes"), //$NON-NLS-1$ NLMessages.getString("Handler_no") }, //$NON-NLS-1$ 1); _messageReturnCode = messageDialog.open(); return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); try { job.join(); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } monitor.worked(TEN); if (_messageReturnCode == 0) { job = new UIJob("Feedbackup") { @Override public IStatus runInUIThread(final IProgressMonitor monitor) { IWorkbench workbench = PlatformUI.getWorkbench(); Display display = workbench.getDisplay(); Shell shell = new Shell(display); String message = NLMessages.getString("WriteLocalBackupHandler_warning0"); //$NON-NLS-1$ message += NLMessages.getString("WriteLocalBackupHandler_warning1"); //$NON-NLS-1$ MessageDialog messageDialog = new MessageDialog(shell, NLMessages.getString("WriteLocalBackupHandler_title"), null, //$NON-NLS-1$ message, MessageDialog.WARNING, new String[] { NLMessages.getString("Handler_yes"), //$NON-NLS-1$ NLMessages.getString("Handler_no") }, //$NON-NLS-1$ 1); _messageReturnCode = messageDialog.open(); return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); try { job.join(); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } monitor.worked(TEN); if (_messageReturnCode == 0) { job = new UIJob("Feedbackup") { @Override public IStatus runInUIThread(final IProgressMonitor monitor) { IWorkbench workbench = PlatformUI.getWorkbench(); Display display = workbench.getDisplay(); Shell shell = new Shell(display); DirectoryDialog directoryDialog = new DirectoryDialog(shell); directoryDialog.setFilterPath("/"); //$NON-NLS-1$ directoryDialog.setMessage( NLMessages.getString("WriteLocalBackupHandler_message")); //$NON-NLS-1$ directoryDialog .setText(NLMessages.getString("WriteLocalBackupHandler_title2")); //$NON-NLS-1$ _selectedDirectory = directoryDialog.open(); return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); try { job.join(); } catch (InterruptedException e1) { e1.printStackTrace(); } monitor.worked(TEN); if (_selectedDirectory != null) { IDBManager dbm = Facade.getInstanz().getDBManager(); try { dbm.writeToLocalBackup(_selectedDirectory); monitor.worked(FIFTY); backupSuccessfull = true; job = new UIJob("Feedbackup") { @Override public IStatus runInUIThread(final IProgressMonitor monitor) { IWorkbench workbench = PlatformUI.getWorkbench(); Display display = workbench.getDisplay(); Shell shell = new Shell(display); String info = NLMessages .getString("Commands_message_local_backup_success"); MessageDialog infoDialog = new MessageDialog(shell, NLMessages.getString("Commands_title_local_backup_success"), null, info, MessageDialog.INFORMATION, new String[] { NLMessages.getString("Handler_ok") }, 0); //$NON-NLS-1$ infoDialog.open(); return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); try { job.join(); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } monitor.worked(TEN); } catch (Exception e) { backupSuccessfull = false; showBackupErrorDialog(); e.printStackTrace(); } } } if (new UserRichtsChecker().isUserPDRAdmin() || backupSuccessfull) { IDBManager dbm = Facade.getInstanz().getDBManager(); try { dbm.createEmptyDB("person"); monitor.worked(TEN); dbm.createEmptyDB("aspect"); monitor.worked(TEN); dbm.createEmptyDB("reference"); monitor.worked(TEN); IPdrIdService idService = Facade.getInstanz().getIdService(); try { idService.clearAllUpdateStates(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { idService.setUpdateTimeStamp(AEConstants.FIRST_EVER_UPDATE_TIMESTAMP); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { idService.clearAllUpdateStates(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } job = new UIJob("Feedbackup") { @Override public IStatus runInUIThread(final IProgressMonitor monitor) { Facade.getInstanz().refreshAllData(); IWorkbench workbench = PlatformUI.getWorkbench(); Display display = workbench.getDisplay(); Shell shell = new Shell(display); String info = NLMessages.getString("Handler_empty_db_successful"); MessageDialog infoDialog = new MessageDialog(shell, NLMessages.getString("Handler_empty_db_successful"), null, info, MessageDialog.INFORMATION, new String[] { NLMessages.getString("Handler_ok") }, 0); //$NON-NLS-1$ infoDialog.open(); return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); monitor.worked(TEN); } catch (Exception e) { showEmptyErrorDialog(); e.printStackTrace(); } } } monitor.done(); } }); } catch (InvocationTargetException e) { showEmptyErrorDialog(); e.printStackTrace(); } catch (InterruptedException e) { showEmptyErrorDialog(); e.printStackTrace(); } } else { MessageDialog.openInformation(HandlerUtil.getActiveWorkbenchWindow(event).getShell(), NLMessages.getString("Commandsr_guest_user"), NLMessages.getString("Commandsr_guest_user_denied")); //$NON-NLS-1$ } return null; }
From source file:org.bbaw.pdr.ae.backup.commands.LoadConfigBackupHandler.java
License:Open Source License
/** execute method. * @param event to be executed./*www .j ava 2s . c om*/ * @throws ExecutionException ee. * @return null. */ public final Object execute(final ExecutionEvent event) throws ExecutionException { if (_urChecker.mayEditConfig()) { String message = NLMessages.getString("Commands_load_config_backup_warning1"); message += "\n\n" + NLMessages.getString("Commands_load_config_backup_warning2"); MessageDialog messageDialog = new MessageDialog(HandlerUtil.getActiveWorkbenchWindow(event).getShell(), NLMessages.getString("Commands_load_config_backup_warning3"), null, message, MessageDialog.WARNING, new String[] { NLMessages.getString("Handler_yes"), NLMessages.getString("Handler_no") }, 1); //$NON-NLS-1$ //$NON-NLS-2$ if (messageDialog.open() == 0) { DirectoryDialog directoryDialog = new DirectoryDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); directoryDialog.setFilterPath("/"); //$NON-NLS-1$ directoryDialog.setMessage(NLMessages.getString("LoadLocalBackupHandler_message")); //$NON-NLS-1$ directoryDialog.setText(NLMessages.getString("LoadLocalBackupHandler_title2")); //$NON-NLS-1$ String selectedDirectory = directoryDialog.open(); if (selectedDirectory != null) { // System.out.println(selectedDirectory + " was selected."); //$NON-NLS-1$ _configFacade.loadLocalConfigBackup(selectedDirectory); String info = NLMessages.getString("Commands_message_load_config_backup_success"); MessageDialog infoDialog = new MessageDialog( HandlerUtil.getActiveWorkbenchWindow(event).getShell(), NLMessages.getString("Commands_load_config_backup_successful_title"), null, info, MessageDialog.INFORMATION, new String[] { NLMessages.getString("Handler_ok") }, 0); //$NON-NLS-1$ infoDialog.open(); } } } else { MessageDialog.openInformation(HandlerUtil.getActiveWorkbenchWindow(event).getShell(), NLMessages.getString("Commandsr_guest_user"), NLMessages.getString("Commandsr_guest_user_denied")); //$NON-NLS-1$ } return null; }
From source file:org.bbaw.pdr.ae.backup.commands.LoadLocalBackupHandler.java
License:Open Source License
/** execute method. * @param event to be executed./* w w w . j a v a2s . c o m*/ * @throws ExecutionException ee. * @return null. */ public final Object execute(final ExecutionEvent event) throws ExecutionException { if (!_urChecker.isUserGuest()) { String message = NLMessages.getString("LoadLocalBackupHandler_warning0"); message += NLMessages.getString("LoadLocalBackupHandler_warning1"); MessageDialog messageDialog = new MessageDialog(HandlerUtil.getActiveWorkbenchWindow(event).getShell(), NLMessages.getString("LoadLocalBackupHandler_title"), null, message, MessageDialog.WARNING, new String[] { NLMessages.getString("Handler_yes"), NLMessages.getString("Handler_no") }, 1); if (messageDialog.open() == 0) { DirectoryDialog directoryDialog = new DirectoryDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); directoryDialog.setFilterPath("/"); //$NON-NLS-1$ directoryDialog.setMessage(NLMessages.getString("LoadLocalBackupHandler_message")); directoryDialog.setText(NLMessages.getString("LoadLocalBackupHandler_title2")); final String selectedDirectory = directoryDialog.open(); if (selectedDirectory != null) { // System.out.println(selectedDirectory + " was selected."); //$NON-NLS-1$ final IDBManager dbm = Facade.getInstanz().getDBManager(); final ProgressMonitorDialog dialog = new ProgressMonitorDialog(new Shell()); dialog.setCancelable(false); try { dialog.run(true, true, new IRunnableWithProgress() { @Override public void run(final IProgressMonitor monitor) { monitor.beginTask("Load Local Backup", 100); // if (monitor.isCanceled()) // { // return Status.CANCEL_STATUS; // } dbm.loadLocalBackup(selectedDirectory, monitor); monitor.done(); } }); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench() .getService(IHandlerService.class); try { handlerService.executeCommand("org.bbaw.pdr.ae.base.commands.RefreshFromDB", null); //$NON-NLS-1$ } catch (ExecutionException e) { e.printStackTrace(); } catch (NotDefinedException e) { e.printStackTrace(); } catch (NotEnabledException e) { e.printStackTrace(); } catch (NotHandledException e) { e.printStackTrace(); } } } } else { MessageDialog.openInformation(HandlerUtil.getActiveWorkbenchWindow(event).getShell(), NLMessages.getString("Commandsr_guest_user"), NLMessages.getString("Commandsr_guest_user_denied")); //$NON-NLS-1$ } return null; }
From source file:org.bbaw.pdr.ae.backup.commands.WriteConfigBackupHandler.java
License:Open Source License
/** execute method. * @param event to be executed./*w w w . jav a2 s . c om*/ * @throws ExecutionException ee. * @return null. */ public final Object execute(final ExecutionEvent event) throws ExecutionException { String message = NLMessages.getString("Commands_write_config_backup_message_directory"); MessageDialog messageDialog = new MessageDialog(HandlerUtil.getActiveWorkbenchWindow(event).getShell(), NLMessages.getString("WriteLocalBackupHandler_title"), null, //$NON-NLS-1$ message, MessageDialog.WARNING, new String[] { NLMessages.getString("Handler_yes"), NLMessages.getString("Handler_no") }, 1); //$NON-NLS-1$ //$NON-NLS-2$ if (messageDialog.open() == 0) { DirectoryDialog directoryDialog = new DirectoryDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); directoryDialog.setFilterPath("/"); //$NON-NLS-1$ directoryDialog.setMessage(NLMessages.getString("WriteLocalBackupHandler_message")); //$NON-NLS-1$ directoryDialog.setText(NLMessages.getString("WriteLocalBackupHandler_title2")); //$NON-NLS-1$ String selectedDirectory = directoryDialog.open(); if (selectedDirectory != null) { try { _configFacade.writeToLocalConfigBackup(selectedDirectory); String info = NLMessages.getString("Commands_message_write_config_backup_success"); MessageDialog infoDialog = new MessageDialog( HandlerUtil.getActiveWorkbenchWindow(event).getShell(), NLMessages.getString("Commands_write_config_backup_successful_title"), null, info, MessageDialog.INFORMATION, new String[] { NLMessages.getString("Handler_ok") }, 0); //$NON-NLS-1$ infoDialog.open(); } catch (Exception e) { e.printStackTrace(); String info = NLMessages.getString("Handler_backup_config_error"); MessageDialog infoDialog = new MessageDialog( HandlerUtil.getActiveWorkbenchWindow(event).getShell(), NLMessages.getString("Handler_backup_error_title"), null, info, MessageDialog.INFORMATION, new String[] { NLMessages.getString("Handler_ok") }, 0); //$NON-NLS-1$ infoDialog.open(); return Status.OK_STATUS; } } } return null; }
From source file:org.bbaw.pdr.ae.backup.commands.WriteLocalBackupHandler.java
License:Open Source License
/** execute method. * @param event to be executed.//from w w w .j a v a 2 s . c om * @throws ExecutionException ee. * @return null. */ public final Object execute(final ExecutionEvent event) throws ExecutionException { String message = NLMessages.getString("WriteLocalBackupHandler_warning0"); //$NON-NLS-1$ message += NLMessages.getString("WriteLocalBackupHandler_warning1"); //$NON-NLS-1$ MessageDialog messageDialog = new MessageDialog(new Shell(PlatformUI.getWorkbench().getDisplay()), NLMessages.getString("WriteLocalBackupHandler_title"), null, //$NON-NLS-1$ message, MessageDialog.WARNING, new String[] { NLMessages.getString("Handler_yes"), NLMessages.getString("Handler_no") }, 1); //$NON-NLS-1$ //$NON-NLS-2$ if (messageDialog.open() == 0) { DirectoryDialog directoryDialog = new DirectoryDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); directoryDialog.setFilterPath("/"); //$NON-NLS-1$ directoryDialog.setMessage(NLMessages.getString("WriteLocalBackupHandler_message")); //$NON-NLS-1$ directoryDialog.setText(NLMessages.getString("WriteLocalBackupHandler_title2")); //$NON-NLS-1$ final String selectedDirectory = directoryDialog.open(); if (selectedDirectory != null) { Job job = new Job("Backup") { @Override protected IStatus run(final IProgressMonitor monitor) { IDBManager dbm = Facade.getInstanz().getDBManager(); try { dbm.writeToLocalBackup(selectedDirectory); _successfull = true; UIJob job = new UIJob("Backup Information") { @Override public IStatus runInUIThread(final IProgressMonitor monitor) { IWorkbench workbench = PlatformUI.getWorkbench(); Display display = workbench.getDisplay(); Shell shell = new Shell(display); String info = NLMessages.getString("Commands_message_local_backup_success"); MessageDialog infoDialog = new MessageDialog(shell, NLMessages.getString("Commands_title_local_backup_success"), null, //$NON-NLS-1$ info, MessageDialog.INFORMATION, new String[] { NLMessages.getString("Handler_ok") }, 0); //$NON-NLS-1$ infoDialog.open(); return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); } catch (Exception e) { UIJob job = new UIJob("Backup Information") { @Override public IStatus runInUIThread(final IProgressMonitor monitor) { IWorkbench workbench = PlatformUI.getWorkbench(); Display display = workbench.getDisplay(); Shell shell = new Shell(display); String info = NLMessages.getString("Handler_backup_error"); MessageDialog infoDialog = new MessageDialog(shell, NLMessages.getString("Handler_backup_error_title"), null, info, MessageDialog.INFORMATION, new String[] { NLMessages.getString("Handler_ok") }, 0); //$NON-NLS-1$ infoDialog.open(); return Status.CANCEL_STATUS; } }; job.setUser(true); job.schedule(); e.printStackTrace(); } if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } return Status.CANCEL_STATUS; } }; job.setUser(true); job.schedule(); } } // System.out.println("write local bakcu2 " + _successfull); return new Boolean(_successfull); }
From source file:org.bbaw.pdr.ae.collections.commands.SaveClipboardHandler.java
License:Open Source License
@Override public final Object execute(final ExecutionEvent event) throws ExecutionException { PDRCollection coll = CollectionsFacade.getInstance().getClipboard(); if (coll != null) { String message = "Save and Write Clipboard to File"; IWorkbench workbench = PlatformUI.getWorkbench(); Display display = workbench.getDisplay(); Shell shell = new Shell(display); MessageDialog messageDialog = new MessageDialog(shell, message, null, //$NON-NLS-1$ message, MessageDialog.INFORMATION, new String[] { NLMessages.getString("Handler_yes"), NLMessages.getString("Handler_no") }, 1); //$NON-NLS-1$ //$NON-NLS-2$ if (messageDialog.open() == 0) { IFileSaveHandling fileHandling = CommonExtensions.getFileSaveAndLoadFactory() .createFileSaveHandling(); String selectedDirectory = null; SimpleDateFormat dateFormate = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); String fileName = coll.getName() + dateFormate.format(Facade.getInstanz().getCurrentDate()); coll.setName(fileName);/*from w w w. j ava 2 s . c om*/ fileName += ".xml"; if (fileHandling.isLocalFileSystem()) { String lastLoc = Platform.getPreferencesService().getString(CommonActivator.PLUGIN_ID, "LAST_EXPORT_DIR", null, null); selectedDirectory = fileHandling.createFileSaveDialog(shell, fileName, lastLoc, message, message); } else { selectedDirectory = AEConstants.TEMP_DOWNLOAD_DIR + AEConstants.FS; } if (selectedDirectory != null) { CommonActivator.getDefault().getPreferenceStore().setValue("LAST_EXPORT_DIR", selectedDirectory); CollectionXMLProcessor xmlProc = new CollectionXMLProcessor(); String xml = null; try { xml = xmlProc.writeToXML(coll); } catch (XMLStreamException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { selectedDirectory = selectedDirectory + AEConstants.FS + fileName; // File f; // f = new File(selectedDirectory); Writer out = new OutputStreamWriter(new FileOutputStream(selectedDirectory), "UTF-8"); try { out.write(xml); } finally { out.close(); } String info = "Save and Write Clipboard to File Successful"; MessageDialog infoDialog = new MessageDialog(shell, info, null, info, MessageDialog.INFORMATION, new String[] { NLMessages.getString("Handler_ok") }, 0); //$NON-NLS-1$ infoDialog.open(); if (!fileHandling.isLocalFileSystem()) { fileHandling.createFileDownloadDialog(selectedDirectory + fileName, fileName, message, "Click link to download exported Collection"); } } catch (Exception e) { e.printStackTrace(); String info = "Save and Write Clipboard to File Unsuccessful"; MessageDialog infoDialog = new MessageDialog(shell, info, null, info, MessageDialog.WARNING, new String[] { NLMessages.getString("Handler_ok") }, 0); //$NON-NLS-1$ infoDialog.open(); } } } } return null; }
From source file:org.bbaw.pdr.ae.config.editor.view.ConfigEditor.java
License:Open Source License
@Override protected final Control createDialogArea(final Composite parent) { _mainSashForm = new SashForm(parent, SWT.HORIZONTAL | SWT.BORDER); _mainSashForm.setLayoutData(new GridData()); ((GridData) _mainSashForm.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) _mainSashForm.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _mainSashForm.getLayoutData()).grabExcessVerticalSpace = true; ((GridData) _mainSashForm.getLayoutData()).verticalAlignment = SWT.FILL; if (AEVIEWConstants.IS_SMALL_MONITOR_DIMENSION) { ((GridData) _mainSashForm.getLayoutData()).minimumHeight = 320; } else {/*from www .ja v a 2s. com*/ ((GridData) _mainSashForm.getLayoutData()).minimumHeight = 470; } ((GridData) _mainSashForm.getLayoutData()).minimumWidth = 800; _leftComposite = new Composite(_mainSashForm, SWT.NONE); _leftComposite.setLayoutData(new GridData()); ((GridData) _leftComposite.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) _leftComposite.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _leftComposite.getLayoutData()).grabExcessVerticalSpace = true; ((GridData) _leftComposite.getLayoutData()).verticalAlignment = SWT.FILL; _leftComposite.setLayout(new GridLayout()); ((GridLayout) _leftComposite.getLayout()).numColumns = 5; ((GridLayout) _leftComposite.getLayout()).makeColumnsEqualWidth = false; Label currentProv = new Label(_leftComposite, SWT.NONE); currentProv.setLayoutData(new GridData()); currentProv.setText("Currently used classification provider"); ((GridData) currentProv.getLayoutData()).horizontalSpan = 2; currentProvText = new Text(_leftComposite, SWT.READ_ONLY); currentProvText.setLayoutData(new GridData()); currentProvText.setText(_semanticProvider); ((GridData) currentProvText.getLayoutData()).horizontalSpan = 2; Button providerChange = new Button(_leftComposite, SWT.PUSH); providerChange.setLayoutData(new GridData()); ((GridData) providerChange.getLayoutData()).horizontalAlignment = SWT.RIGHT; providerChange.setImage(_imageReg.get(IconsInternal.PREFERENCES)); providerChange.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { ArrayList<Parameterization> parameters = new ArrayList<Parameterization>(); IParameter iparam = null; // get the command from plugin.xml IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); ICommandService cmdService = (ICommandService) window.getService(ICommandService.class); Command cmd = cmdService.getCommand("org.eclipse.ui.window.preferences"); // get the parameter try { iparam = cmd.getParameter("preferencePageId"); } catch (NotDefinedException e1) { e1.printStackTrace(); } Parameterization params = new Parameterization(iparam, "org.bbaw.pdr.ae.view.main.preferences.AspectPage"); parameters.add(params); // build the parameterized command ParameterizedCommand pc = new ParameterizedCommand(cmd, parameters.toArray(new Parameterization[parameters.size()])); // execute the command try { IHandlerService handlerService = (IHandlerService) window.getService(IHandlerService.class); handlerService.executeCommand(pc, null); } catch (ExecutionException e) { e.printStackTrace(); } catch (NotDefinedException e) { e.printStackTrace(); } catch (NotEnabledException e) { e.printStackTrace(); } catch (NotHandledException e) { e.printStackTrace(); } _semanticProvider = Platform.getPreferencesService().getString(CommonActivator.PLUGIN_ID, "PRIMARY_SEMANTIC_PROVIDER", AEConstants.CLASSIFICATION_AUTHORITY, null).toUpperCase(); //$NON-NLS-1$; currentProvText.setText(_semanticProvider); } }); // SelectionListener Label prov = new Label(_leftComposite, SWT.NONE); prov.setLayoutData(new GridData()); prov.setText(NLMessages.getString("Preference_select_primary_semantic_provider")); _providerCombo = new Combo(_leftComposite, SWT.BORDER | SWT.READ_ONLY); _providerCombo.setLayoutData(new GridData()); if (_configFacade.getConfigs() == null) { } for (String s : _configFacade.getConfigs().keySet()) { _providerCombo.add(s); } _providerCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { _datatypeDesc = _configFacade.getConfigs() .get(_providerCombo.getItem(_providerCombo.getSelectionIndex())); checkAndCompleteConfig(_datatypeDesc); _treeViewer.setInput(_datatypeDesc); if (_deleteConfigButton != null) { _deleteConfigButton.setEnabled(_userRichtsChecker.mayEditConfig()); } loadConfigData(null); } }); if (_userRichtsChecker.mayEditConfig()) { _deleteConfigButton = new Button(_leftComposite, SWT.PUSH); _deleteConfigButton.setText(NLMessages.getString("Config_delete")); _deleteConfigButton.setToolTipText(NLMessages.getString("Config_delete_tooltip")); _deleteConfigButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { IWorkbench workbench = PlatformUI.getWorkbench(); Display display = workbench.getDisplay(); Shell shell = new Shell(display); String message = NLMessages.getString("Config_delete_warning1"); message += NLMessages.getString("Config_delete_warning2"); MessageDialog messageDialog = new MessageDialog(shell, NLMessages.getString("Config_delete_configuration"), null, message, MessageDialog.WARNING, new String[] { NLMessages.getString("Config_delete"), //$NON-NLS-1$ NLMessages.getString("Config_cancel") }, //$NON-NLS-1$ 1); if (messageDialog.open() == 0) { _configFacade.getConfigs() .remove(_providerCombo.getItem(_providerCombo.getSelectionIndex())); _cfgManager.deleteConfig( _providerCombo.getItem(_providerCombo.getSelectionIndex()).toLowerCase()); _cfgManager.deleteConfig( _providerCombo.getItem(_providerCombo.getSelectionIndex()).toUpperCase()); _datatypeDesc = null; _treeViewer.setInput(null); _treeViewer.refresh(); _providerCombo.setEnabled(true); _newButton.setEnabled(true); _providerCombo.removeAll(); for (String s : _configFacade.getConfigs().keySet()) { _providerCombo.add(s); } _providerCombo.select(0); _deleteConfigButton.setEnabled(false); } } }); _deleteConfigButton.pack(); _newButton = new Button(_leftComposite, SWT.PUSH); _newButton.setText(NLMessages.getString("Config_new")); _newButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { // createNewConfig(providerText.getText().trim().toUpperCase(), // newProviderCombo.getItem(newProviderCombo.getSelectionIndex())); IWorkbench workbench = PlatformUI.getWorkbench(); Display display = workbench.getDisplay(); Shell shell = new Shell(display); CreateConfigDialog dialog = new CreateConfigDialog(shell, ConfigEditor.this); dialog.open(); if (_newConfiguration != null) { CommonActivator.getDefault().getPreferenceStore().setValue("PRIMARY_SEMANTIC_PROVIDER", //$NON-NLS-1$ _newConfiguration.getProvider()); //$NON-NLS-1$ CommonActivator.getDefault().getPreferenceStore().setValue("PRIMARY_TAGGING_PROVIDER", //$NON-NLS-1$ _newConfiguration.getProvider()); //$NON-NLS-1$ CommonActivator.getDefault().getPreferenceStore().setValue("PRIMARY_RELATION_PROVIDER", //$NON-NLS-1$ _newConfiguration.getProvider()); _providerCombo.add(_newConfiguration.getProvider(), 0); _providerCombo.select(0); _providerCombo.setEnabled(false); _datatypeDesc = _newConfiguration; checkAndCompleteConfig(_datatypeDesc); _treeViewer.setInput(_datatypeDesc); _treeViewer.refresh(); _providerCombo.setEnabled(false); currentProvText.setText(_newConfiguration.getProvider()); if (_newButton != null) { _newButton.setEnabled(false); } _newConfiguration = null; } } }); _newButton.pack(); } else { Label blancLabel = new Label(_leftComposite, SWT.NONE); blancLabel.setText(""); //$NON-NLS-1$ blancLabel.setLayoutData(new GridData()); ((GridData) blancLabel.getLayoutData()).horizontalSpan = 2; } Tree tree = new Tree(_leftComposite, SWT.BORDER); tree.setLayoutData(new GridData()); ((GridData) tree.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tree.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tree.getLayoutData()).grabExcessVerticalSpace = true; ((GridData) tree.getLayoutData()).verticalAlignment = SWT.FILL; ((GridData) tree.getLayoutData()).horizontalSpan = 5; _treeViewer = new TreeViewer(tree); TreeColumn column = new TreeColumn(_treeViewer.getTree(), SWT.NONE); column.setWidth(450); column.setResizable(true); column.setText("Column 1"); //$NON-NLS-1$ int operations = DND.DROP_COPY | DND.DROP_MOVE; Transfer[] transferTypes = new Transfer[] { ConfigTransfer.getInstance() }; if (_userRichtsChecker.mayEditConfig()) { _treeViewer.addDragSupport(operations, transferTypes, new ConfigDragListener(_treeViewer)); _treeViewer.addDropSupport(operations, transferTypes, new ConfigDropListner(_treeViewer)); } _treeViewer.setContentProvider(new ConfigTreeContentProvider(true, _markupTemplateEditor != null, true)); _treeViewer.setLabelProvider(new ConfigTreeLabelProvider()); _treeViewer.setSorter(new ConfigTreeSorter()); _treeViewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(final DoubleClickEvent event) { if (event.getSelection() instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); Object obj = selection.getFirstElement(); ConfigTreeNode tn = (ConfigTreeNode) obj; if (tn.hasChildren()) { _treeViewer.setExpandedState(tn, !_treeViewer.getExpandedState(tn)); } } } }); _treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); Object obj = selection.getFirstElement(); ConfigTreeNode tn = (ConfigTreeNode) obj; loadConfigData(tn); } }); // public void doubleClick(final DoubleClickEvent event) // { // IStructuredSelection selection = (IStructuredSelection) // event.getSelection(); // Object obj = ((IStructuredSelection) // selection).getFirstElement(); // TreeNode tn = (TreeNode) obj; // loadValues(tn.getConfigData()); // } // }); // }// leftComposite _leftComposite.layout(); // leftComposite.pack(); _rightComposite = new Composite(_mainSashForm, SWT.NONE); _rightComposite.setLayoutData(new GridData()); ((GridData) _rightComposite.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) _rightComposite.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _rightComposite.getLayoutData()).grabExcessVerticalSpace = true; ((GridData) _rightComposite.getLayoutData()).verticalAlignment = SWT.FILL; _rightComposite.setLayout(new GridLayout()); ((GridLayout) _rightComposite.getLayout()).numColumns = 3; ((GridLayout) _rightComposite.getLayout()).makeColumnsEqualWidth = false; _rightComposite.layout(); // rightComposite.pack(); _mainSashForm.setWeights(new int[] { 3, 3 }); // mainSashForm.pack(); // mainComposite boolean found = false; for (String s : _providerCombo.getItems()) { if (s.equals(_semanticProvider)) { _providerCombo.select(_providerCombo.indexOf(_semanticProvider)); _datatypeDesc = _configFacade.getConfigs() .get(_providerCombo.getItem(_providerCombo.getSelectionIndex())); found = true; break; } } if (!found) { _providerCombo.select(0); _semanticProvider = _providerCombo.getItem(0); _datatypeDesc = _configFacade.getConfigs().get(_semanticProvider); } checkAndCompleteConfig(_datatypeDesc); _treeViewer.setInput(_datatypeDesc); parent.pack(); return parent; }
From source file:org.bbaw.pdr.ae.control.core.preferences.AEVersionPage.java
License:Open Source License
private boolean checkRestart() { String message = "It is requiered to restart the Archiv-Editor in order to activate changes. \n\nDo you want to restart the Archiv-Editor now?"; MessageDialog messageDialog = new MessageDialog(null, "Restart Archiv-Editor", null, message, MessageDialog.WARNING, new String[] { "Restart", NLMessages.getString("Handler_cancel") }, 0); if (messageDialog.open() == 0) { IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench() .getService(IHandlerService.class); try {/*from w ww.j a v a 2 s . co m*/ handlerService.executeCommand("org.eclipse.ui.file.restartWorkbench", null); //$NON-NLS-1$ } catch (ExecutionException e) { e.printStackTrace(); } catch (NotDefinedException e) { e.printStackTrace(); } catch (NotEnabledException e) { e.printStackTrace(); } catch (NotHandledException e) { e.printStackTrace(); } } return true; }
From source file:org.bbaw.pdr.ae.repositoryconnection.commands.ModifyRepositoryConnectionHandler.java
License:Open Source License
@Override public final Object execute(final ExecutionEvent event) throws ExecutionException { if (!_urChecker.isUserGuest()) { // System.out.println("number of persons " + // dbCon.getDBNumberOfDocs("person")); // System.out.println("number of aspect " + // dbCon.getDBNumberOfDocs("aspect")); // System.out.println("number of reference " + // dbCon.getDBNumberOfDocs("reference")); // FIXME !!! true raus if (!_facade.getDBManager().dbIsEmpty()) { String message = NLMessages.getString("Command_empty_db_requiered"); MessageDialog messageDialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), NLMessages.getString("Command_modify_repository_connection"), null, message, MessageDialog.WARNING, new String[] { NLMessages.getString("Command_backup_and_empty"), NLMessages.getString("Handler_cancel") }, 1);//from w w w .ja v a2 s . co m if (messageDialog.open() == 0) { IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench() .getService(IHandlerService.class); try { handlerService.executeCommand("org.bbaw.pdr.ae.backup.commands.CreateEmptyDB", null); //$NON-NLS-1$ } catch (ExecutionException e) { e.printStackTrace(); } catch (NotDefinedException e) { e.printStackTrace(); } catch (NotEnabledException e) { e.printStackTrace(); } catch (NotHandledException e) { e.printStackTrace(); } } else { return null; } } else { int repoInstanceID = Platform.getPreferencesService().getInt(CommonActivator.PLUGIN_ID, "REPOSITORY_ID", AEConstants.REPOSITORY_ID, null); // Activator.getDefault().getPreferenceStore().getInt("REPOSITORY_ID"); int projectID = Platform.getPreferencesService().getInt(CommonActivator.PLUGIN_ID, "PROJECT_ID", AEConstants.PROJECT_ID, null); // Activator.getDefault().getPreferenceStore().getInt("PROJECT_ID"); RepositoryLogin dialog = new RepositoryLogin(HandlerUtil.getActiveWorkbenchWindow(event).getShell(), false); dialog.open(); if (repoInstanceID != Platform.getPreferencesService().getInt(CommonActivator.PLUGIN_ID, "REPOSITORY_ID", AEConstants.REPOSITORY_ID, null) || projectID != Platform.getPreferencesService().getInt(CommonActivator.PLUGIN_ID, "PROJECT_ID", AEConstants.PROJECT_ID, null)) { IWorkbench w = PlatformUI.getWorkbench(); // get the window (which is a IServiceLocator) if (w != null) { IWorkbenchWindow window = w.getActiveWorkbenchWindow(); // get the service ISourceProviderService service = (ISourceProviderService) window .getService(ISourceProviderService.class); boolean canSynch = true; String url = Platform.getPreferencesService().getString(CommonActivator.PLUGIN_ID, "REPOSITORY_URL", AEConstants.REPOSITORY_URL, null); repoInstanceID = Platform.getPreferencesService().getInt(CommonActivator.PLUGIN_ID, "REPOSITORY_ID", AEConstants.REPOSITORY_ID, null); // Activator.getDefault().getPreferenceStore().getInt("REPOSITORY_ID"); projectID = Platform.getPreferencesService().getInt(CommonActivator.PLUGIN_ID, "PROJECT_ID", AEConstants.PROJECT_ID, null); // Activator.getDefault().getPreferenceStore().getInt("PROJECT_ID"); AEVersionProvider aeVersionProvider = (AEVersionProvider) service .getSourceProvider(AEPluginIDs.SOURCE_PARAMETER_AE_ADVANCED_VERSION); if (url == null || "".equals(url.trim()) || "xxx".equals(url) || repoInstanceID == 0 || projectID == 0) { canSynch = false; } aeVersionProvider.setCanSynchronize(canSynch); } // project settings changed _facade.setCurrentUser(null); IUserManager userManager = _facade.getUserManager(); userManager.clearLastUsers(); userManager.verifyOrCreateUsers(); LoginDialog loginDialog = new LoginDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), true); loginDialog.focusOkButton(); loginDialog.open(); } } } else { MessageDialog.openInformation(HandlerUtil.getActiveWorkbenchWindow(event).getShell(), NLMessages.getString("Commandsr_guest_user"), //$NON-NLS-1$ NLMessages.getString("Commandsr_guest_user_denied")); } return null; }
From source file:org.bbaw.pdr.ae.view.concurrences.view.ConcurrenceHeadView.java
License:Open Source License
@Override public final void createPartControl(final Composite parent) { parent.setLayout(new GridLayout()); _facade.addObserver(this); _mainSashForm = new SashForm(parent, SWT.HORIZONTAL); _mainSashForm.setLayoutData(new GridData()); ((GridData) _mainSashForm.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _mainSashForm.getLayoutData()).verticalAlignment = SWT.FILL; ((GridData) _mainSashForm.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) _mainSashForm.getLayoutData()).grabExcessVerticalSpace = true; _leftComposite = new Composite(_mainSashForm, SWT.NONE); _leftComposite.setLayout(new GridLayout()); ((GridLayout) _leftComposite.getLayout()).numColumns = 1; ((GridLayout) _leftComposite.getLayout()).makeColumnsEqualWidth = false; _leftComposite.setLayoutData(new GridData()); ((GridData) _leftComposite.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _leftComposite.getLayoutData()).verticalAlignment = SWT.FILL; ((GridData) _leftComposite.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) _leftComposite.getLayoutData()).grabExcessVerticalSpace = true; _leftGroup = new Group(_leftComposite, SWT.NONE); _leftGroup.setText(NLMessages.getString("View_select_criteria_comparision")); _leftGroup.setLayout(new GridLayout()); ((GridLayout) _leftGroup.getLayout()).numColumns = 11; ((GridLayout) _leftGroup.getLayout()).makeColumnsEqualWidth = false; _leftGroup.setLayoutData(new GridData()); ((GridData) _leftGroup.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _leftGroup.getLayoutData()).verticalAlignment = SWT.FILL; ((GridData) _leftGroup.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) _leftGroup.getLayoutData()).grabExcessVerticalSpace = true; Label nameLabel = new Label(_leftGroup, SWT.NONE); nameLabel.setText(NLMessages.getString("View_name")); nameLabel.setLayoutData(new GridData()); Button nameButton = new Button(_leftGroup, SWT.CHECK); nameButton.setLayoutData(new GridData()); nameButton.addSelectionListener(new SelectionAdapter() { @Override/*from w w w. j a va 2 s .c o m*/ public void widgetSelected(final SelectionEvent event) { _compareName = !_compareName; } }); Label birthLabel = new Label(_leftGroup, SWT.NONE); birthLabel.setText("Birth"); birthLabel.setLayoutData(new GridData()); ((GridData) birthLabel.getLayoutData()).horizontalIndent = 12; Button birthButton = new Button(_leftGroup, SWT.CHECK); birthButton.setLayoutData(new GridData()); birthButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { _compareBirth = !_compareBirth; } }); Label deathLabel = new Label(_leftGroup, SWT.NONE); deathLabel.setText("Death"); deathLabel.setLayoutData(new GridData()); ((GridData) deathLabel.getLayoutData()).horizontalIndent = 12; Button deathButton = new Button(_leftGroup, SWT.CHECK); deathButton.setLayoutData(new GridData()); deathButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { _compareDeath = !_compareDeath; } }); Label descLabel = new Label(_leftGroup, SWT.NONE); descLabel.setText("Description"); descLabel.setLayoutData(new GridData()); ((GridData) descLabel.getLayoutData()).horizontalIndent = 12; Button descButton = new Button(_leftGroup, SWT.CHECK); descButton.setLayoutData(new GridData()); descButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { _compareDesc = !_compareDesc; } }); Label fuzzyLabel = new Label(_leftGroup, SWT.NONE); fuzzyLabel.setText(NLMessages.getString("View_fuzzy")); fuzzyLabel.setLayoutData(new GridData()); ((GridData) fuzzyLabel.getLayoutData()).horizontalIndent = 12; Button fuzzyButton = new Button(_leftGroup, SWT.CHECK); fuzzyButton.setLayoutData(new GridData()); fuzzyButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { _compareFuzzy = !_compareFuzzy; } }); _searchButton = new Button(_leftGroup, SWT.PUSH); _searchButton.setLayoutData(new GridData()); _searchButton.setText(NLMessages.getString("View_search")); _searchButton.setEnabled(_facade.getCurrentPerson() != null); _searchButton.setToolTipText(NLMessages.getString("View_search_concurrences_tooltip")); _searchButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { _personQuery = new PdrQuery(); _personQuery.setType(1); _personQuery.setCriterias(new Vector<Criteria>()); Criteria c; Person currentPerson = _facade.getCurrentPerson(); if (_compareName && currentPerson.getBasicPersonData() != null && currentPerson.getBasicPersonData().getComplexNames() != null) { for (ComplexName cn : currentPerson.getBasicPersonData().getComplexNames()) { if (cn.getForeName() != null && cn.getForeName().trim().length() > 0) { c = new Criteria(); c.setType("tagging"); //$NON-NLS-1$ c.setFuzzy(_compareFuzzy); c.setOperator("OR"); //$NON-NLS-1$ c.setCrit0("ALL"); //$NON-NLS-1$ c.setCrit1("ALL"); //$NON-NLS-1$ c.setSearchText(cn.getForeName().trim()); _personQuery.getCriterias().add(c); } if (cn.getSurName() != null && cn.getSurName().trim().length() > 0) { c = new Criteria(); c.setType("tagging"); //$NON-NLS-1$ c.setFuzzy(_compareFuzzy); c.setOperator("OR"); //$NON-NLS-1$ c.setCrit0("ALL"); //$NON-NLS-1$ c.setSearchText(cn.getSurName().trim()); _personQuery.getCriterias().add(c); } } } if (_compareBirth && currentPerson.getBasicPersonData() != null && currentPerson.getBasicPersonData().getBeginningOfLife() != null) { PdrDate birth = currentPerson.getBasicPersonData().getBeginningOfLife(); c = new Criteria(); c.setType("date"); //$NON-NLS-1$ c.setOperator("AND"); //$NON-NLS-1$ c.setCrit0("biographicalData"); //$NON-NLS-1$ if (_compareFuzzy) { c.setDateFrom(new PdrDate(birth.getYear(), 1, 1)); c.setDateTo(new PdrDate(birth.getYear(), 12, 31)); } else { c.setDateFrom(new PdrDate(birth.getYear(), birth.getMonth(), 1)); c.setDateTo(new PdrDate(birth.getYear(), birth.getMonth(), 31)); } _personQuery.getCriterias().add(c); } if (_compareDeath && currentPerson.getBasicPersonData() != null && currentPerson.getBasicPersonData().getEndOfLife() != null) { PdrDate death = currentPerson.getBasicPersonData().getEndOfLife(); c = new Criteria(); c.setType("date"); //$NON-NLS-1$ c.setOperator("AND"); //$NON-NLS-1$ c.setCrit0("biographicalData"); //$NON-NLS-1$ if (_compareFuzzy) { c.setDateFrom(new PdrDate(death.getYear(), 1, 1)); c.setDateTo(new PdrDate(death.getYear(), 12, 31)); } else { c.setDateFrom(new PdrDate(death.getYear(), death.getMonth(), 1)); c.setDateTo(new PdrDate(death.getYear(), death.getMonth(), 31)); } _personQuery.getCriterias().add(c); } if (_compareDesc && currentPerson.getBasicPersonData() != null && currentPerson.getBasicPersonData().getDescriptions() != null) { c = new Criteria(); c.setType("tagging"); //$NON-NLS-1$ c.setOperator("AND"); //$NON-NLS-1$ c.setFuzzy(_compareFuzzy); c.setCrit0("principalDescription"); //$NON-NLS-1$ String search = ""; for (String s : currentPerson.getBasicPersonData().getDescriptions()) { search += s + " "; } c.setSearchText(search); _personQuery.getCriterias().add(c); } _personTableViewer.setContentProvider(new PersonVectorContentProvider()); _personTableViewer.setLabelProvider(new TableLabelProvider()); _personTableViewer.setComparator(new PdrObjectViewComparator()); UIJob job = new UIJob("search") { @Override public IStatus runInUIThread(final IProgressMonitor monitor) { try { Vector<Person> persons = null; persons = _mainSearcher.searchPersons(_personQuery, monitor); if (persons != null && !persons.isEmpty()) { for (Person p : persons) { if (p.getPdrId().equals(_facade.getCurrentPerson().getPdrId())) { persons.remove(p); break; } } } _personTableViewer.setInput(persons); } catch (Exception e) { e.printStackTrace(); } if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); _personTableViewer.refresh(); } }); _personTableViewer = new TableViewer(_leftGroup, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); _personTableViewer.setContentProvider(new PersonVectorContentProvider()); _personTableViewer.setLabelProvider(new TableLabelProvider()); Table table = _personTableViewer.getTable(); table.setHeaderVisible(true); table.setLinesVisible(true); table.setLayoutData(new GridData()); ((GridData) table.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) table.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) table.getLayoutData()).verticalAlignment = SWT.FILL; ((GridData) table.getLayoutData()).grabExcessVerticalSpace = true; ((GridData) table.getLayoutData()).horizontalSpan = 11; String[] titles = { "Name", "ID" }; //$NON-NLS-1$ //$NON-NLS-2$ int[] bounds = { 200, 180 }; for (int i = 0; i < titles.length; i++) { TableViewerColumn column = new TableViewerColumn(_personTableViewer, SWT.NONE); column.getColumn().setText(titles[i]); column.getColumn().setWidth(bounds[i]); column.getColumn().setResizable(true); column.getColumn().setMoveable(true); column.getColumn().addSelectionListener(getSelectionAdapter(_personTableViewer, column.getColumn(), i)); } _personTableViewer.setComparator(new PdrObjectViewComparator()); _personTableViewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(final DoubleClickEvent event) { ISelection selection = _personTableViewer.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); Person selectedP = (Person) obj; // System.out.println("selected person: " + selectedP.getPdrId().toString()); //$NON-NLS-1$ if (selectedP != null) { if (!selectedP.isAspectsLoaded()) { try { _mainSearcher.searchAspectsByRelatedObject(selectedP, null); } catch (ParseException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } } _facade.setConcurringPerson(selectedP); _mergeButtonRight.setEnabled(true); _mergeButtonLeft.setEnabled(true); _setConcurrence.setEnabled(true); } }); _leftGroup.layout(); _leftButtonComposite = new Composite(_leftComposite, SWT.NONE); _leftButtonComposite.setLayout(new GridLayout()); ((GridLayout) _leftButtonComposite.getLayout()).numColumns = 2; ((GridLayout) _leftButtonComposite.getLayout()).makeColumnsEqualWidth = false; _leftButtonComposite.setLayoutData(new GridData()); _mergeButtonLeft = new Button(_leftButtonComposite, SWT.PUSH); _mergeButtonLeft.setText(NLMessages.getString("View_concurrence_merge_left")); _mergeButtonLeft.setToolTipText(NLMessages.getString("View_concurrence_merge_left_tooltip")); _mergeButtonLeft.setLayoutData(new GridData()); ((GridData) _mergeButtonLeft.getLayoutData()).horizontalAlignment = SWT.RIGHT; _mergeButtonLeft.setEnabled(false); _mergeButtonLeft.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { String message = NLMessages.getString("View_concurrence_merge_left_warning"); message += "\n\n"; //$NON-NLS-1$ message += NLMessages.getString("View_concurrence_merge_left_warning2"); message += NLMessages.getString("View_lb_lb_current_person") + _facade.getCurrentPerson().getDisplayName(); message += NLMessages.getString("View_lb_lb_concurring_person") + _facade.getConcurringPerson().getDisplayName(); message += NLMessages.getString("View_lb_not_undoable"); MessageDialog messageDialog = new MessageDialog(_parentShell, "Merge Persons Info", null, //$NON-NLS-1$ message, MessageDialog.WARNING, new String[] { NLMessages.getString("View_merge"), "Cancel" }, 1); int returnCode = messageDialog.open(); if (returnCode == 0) { Person p = null; Person oldcurrentPerson = _facade.getCurrentPerson(); try { p = _concurrenceManager.mergePerson(_facade.getConcurringPerson(), _facade.getCurrentPerson()); } catch (XMLStreamException e1) { e1.printStackTrace(); } catch (Exception e1) { e1.printStackTrace(); } try { _facade.savePerson(p); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } IDBManager dbm = _facade.getDBManager(); try { dbm.delete(oldcurrentPerson.getPdrId(), "person"); //$NON-NLS-1$ } catch (Exception e) { e.printStackTrace(); } //$NON-NLS-1$ //$NON-NLS-2$ _facade.deletePersonFromAllPersons(oldcurrentPerson); _facade.setConcurringPerson(null); _facade.refreshAllData(); } } }); // SelectionListener _setConcurrence = new Button(_leftButtonComposite, SWT.PUSH); _setConcurrence.setText(NLMessages.getString("View_concurrence_set")); _setConcurrence.setToolTipText(NLMessages.getString("View_concurrence_set_tooltip")); _setConcurrence.setLayoutData(new GridData()); ((GridData) _setConcurrence.getLayoutData()).horizontalAlignment = SWT.RIGHT; _setConcurrence.setEnabled(false); _setConcurrence.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { Person p = _concurrenceManager.setConcurrence(_facade.getCurrentPerson(), _facade.getConcurringPerson().getPdrId()); try { _facade.savePerson(p); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } IDBManager dbm = _facade.getDBManager(); p = _concurrenceManager.setConcurrence(_facade.getConcurringPerson(), _facade.getCurrentPerson().getPdrId()); try { _facade.savePerson(p); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { dbm.saveToDB(p); } catch (XMLStreamException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } }); // SelectionListener _rightComposite = new Composite(_mainSashForm, SWT.NONE); _rightComposite.setLayout(new GridLayout()); ((GridLayout) _rightComposite.getLayout()).numColumns = 1; ((GridLayout) _rightComposite.getLayout()).makeColumnsEqualWidth = true; _rightComposite.setLayoutData(new GridData()); ((GridData) _rightComposite.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _rightComposite.getLayoutData()).verticalAlignment = SWT.FILL; ((GridData) _rightComposite.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) _rightComposite.getLayoutData()).grabExcessVerticalSpace = true; _rightGroup = new Group(_rightComposite, SWT.NONE); _rightGroup.setText(NLMessages.getString("View_similar_person")); _rightGroup.setLayout(new GridLayout()); ((GridLayout) _rightGroup.getLayout()).numColumns = 1; ((GridLayout) _rightGroup.getLayout()).makeColumnsEqualWidth = true; _rightGroup.setLayoutData(new GridData()); ((GridData) _rightGroup.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _rightGroup.getLayoutData()).verticalAlignment = SWT.FILL; ((GridData) _rightGroup.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) _rightGroup.getLayoutData()).grabExcessVerticalSpace = true; _concurringPersonText = new Text(_rightGroup, SWT.MULTI | SWT.V_SCROLL | SWT.READ_ONLY); _concurringPersonText.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); _concurringPersonText.setLayoutData(new GridLayout()); _concurringPersonText.setLayoutData(new GridData()); ((GridData) _concurringPersonText.getLayoutData()).verticalAlignment = SWT.FILL; ((GridData) _concurringPersonText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) _concurringPersonText.getLayoutData()).grabExcessVerticalSpace = true; ((GridData) _concurringPersonText.getLayoutData()).horizontalAlignment = SWT.FILL; _concurringPersonText.pack(); _rightGroup.layout(); _rightButtonComposite = new Composite(_rightComposite, SWT.NONE); _rightButtonComposite.setLayout(new GridLayout()); ((GridLayout) _rightButtonComposite.getLayout()).numColumns = 2; ((GridLayout) _rightButtonComposite.getLayout()).makeColumnsEqualWidth = false; _rightButtonComposite.setLayoutData(new GridData()); _mergeButtonRight = new Button(_rightButtonComposite, SWT.PUSH); _mergeButtonRight.setText(NLMessages.getString("View_concurrence_merge_right")); _mergeButtonRight.setToolTipText(NLMessages.getString("View_concurrence_merge_right_tooltip")); _mergeButtonRight.setLayoutData(new GridData()); _mergeButtonRight.setEnabled(false); ((GridData) _mergeButtonRight.getLayoutData()).horizontalAlignment = SWT.RIGHT; _mergeButtonRight.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { String message = NLMessages.getString("View_concurrence_merge_right_warning"); message += "\n\n"; //$NON-NLS-1$ message += NLMessages.getString("View_concurrence_merge_right_warning2"); message += NLMessages.getString("View_lb_lb_current_person") + _facade.getCurrentPerson().getDisplayName(); message += NLMessages.getString("View_lb_lb_concurring_person") + _facade.getConcurringPerson().getDisplayName(); message += NLMessages.getString("View_lb_not_undoable"); MessageDialog messageDialog = new MessageDialog(_parentShell, "Merge Persons Info", null, //$NON-NLS-1$ message, MessageDialog.WARNING, new String[] { NLMessages.getString("View_merge"), "Cancel" }, 1); //$NON-NLS-2$ int returnCode = messageDialog.open(); if (returnCode == 0) { Person p = null; try { p = _concurrenceManager.mergePerson(_facade.getCurrentPerson(), _facade.getConcurringPerson()); } catch (XMLStreamException e1) { e1.printStackTrace(); } catch (Exception e1) { e1.printStackTrace(); } try { _facade.savePerson(p); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } IDBManager dbm = _facade.getDBManager(); p = _facade.getConcurringPerson(); try { dbm.delete(p.getPdrId(), "person"); //$NON-NLS-1$ } catch (Exception e) { e.printStackTrace(); } //$NON-NLS-1$ //$NON-NLS-2$ _facade.deletePersonFromAllPersons(p); _facade.setConcurringPerson(null); _facade.refreshAllData(); } } }); // SelectionListener _mainSashForm.setWeights(new int[] { 1, 1 }); }