@Override protected void okPressed() { if (textFile.getText().length() == 0 || scopeCombo.getSelectionIndex() < 0) { MessageDialog.openWarning( getShell(), Messages.GenerateReportDialog_5, Messages.GenerateReportDialog_6); return; } List<Integer> rootElements = new ArrayList<Integer>(0); rootElements.add(getRootElement()); if (getRootElements() != null) rootElements.addAll(Arrays.asList(getRootElements())); IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); boolean dontShow = preferenceStore.getBoolean(PreferenceConstants.SHOW_REPORT_VALIDATION_WARNING); IValidationService vService = ServiceFactory.lookupValidationService(); boolean validationsExistant = false; for (Integer scopeId : rootElements) { if (vService.getValidations(scopeId, (Integer) null).size() > 0) { validationsExistant = true; break; } } if (!dontShow && validationsExistant) { MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion( getParentShell(), Messages.GenerateReportDialog_5, Messages.GenerateReportDialog_21, Messages.GenerateReportDialog_23, dontShow, preferenceStore, PreferenceConstants.SHOW_REPORT_VALIDATION_WARNING); preferenceStore.setValue( PreferenceConstants.SHOW_REPORT_VALIDATION_WARNING, dialog.getToggleState()); if (!(dialog.getReturnCode() == IDialogConstants.OK_ID || dialog.getReturnCode() == IDialogConstants.YES_ID)) { return; } } String f = textFile.getText(); chosenReportType = reportTypes[comboReportType.getSelectionIndex()]; chosenOutputFormat = chosenReportType.getOutputFormats()[comboOutputFormat.getSelectionIndex()]; chosenReportType.setReportFile(textReportTemplateFile.getText()); // This just appends the chosen report's extension if the existing // suffix does not match. Could be enhanced. if (!f.endsWith(chosenOutputFormat.getFileSuffix())) { f += "." + chosenOutputFormat.getFileSuffix(); // $NON-NLS-1$ } outputFile = new File(f); resetScopeCombo(); super.okPressed(); }
@Override public void doSave(IProgressMonitor monitor) { monitor.beginTask(Messages.AttachmentEditor_1, IProgressMonitor.UNKNOWN); boolean isNew = attachment.getDbId() == null; Set<INoteChangedListener> listener = attachment.getListener(); SaveNote command = new SaveNote(attachment); try { command = getCommandService().executeCommand(command); attachment = (Attachment) command.getAddition(); huiComposite.dispose(); huiComposite = new HitroUIComposite(parent, false); huiComposite.createView( attachment.getEntity(), true, true, new String[] {}, false, ServiceFactory.lookupValidationService() .getPropertyTypesToValidate(attachment.getEntity(), attachment.getDbId()), Activator.getDefault() .getPreferenceStore() .getBoolean(PreferenceConstants.USE_VALIDATION_GUI_HINTS)); parent.layout(); // file-data is immutable, just save new file-data if (isNew) { AttachmentFileCreationFactory.createAttachmentFile( attachment, FileUtils.readFileToByteArray(new File(attachment.getFilePath()))); } } catch (Exception e) { LOG.error("Error while saving file", e); // $NON-NLS-1$ ExceptionUtil.log(e, Messages.AttachmentEditor_3); } monitor.done(); attachment.getListener().addAll(listener); isModelModified = false; firePropertyChange(IEditorPart.PROP_DIRTY); attachment.getEntity().addChangeListener(this.modelListener); setPartName(attachment.getTitel()); attachment.fireChange(); }
@Override protected void okPressed() { try { if (textFile.getText().length() == 0 || scopeCombo.getSelectionIndex() < 0) { MessageDialog.openWarning( getShell(), Messages.GenerateReportDialog_5, Messages.GenerateReportDialog_6); return; } List<Integer> scopeIds = new ArrayList<Integer>(0); if (getRootElement() != null) { scopeIds.add(getRootElement()); } if (getRootElements() != null) { for (Integer scopeId : getRootElements()) { if (scopeId != null) { scopeIds.add(scopeId); } } } IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); boolean dontShow = preferenceStore.getBoolean(PreferenceConstants.SHOW_REPORT_VALIDATION_WARNING); IValidationService vService = ServiceFactory.lookupValidationService(); boolean validationsExistant = false; for (Integer scopeId : scopeIds) { if (vService.getValidations(scopeId, (Integer) null).size() > 0) { validationsExistant = true; break; } } if (!dontShow && validationsExistant) { MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion( getParentShell(), Messages.GenerateReportDialog_5, Messages.GenerateReportDialog_21, Messages.GenerateReportDialog_23, dontShow, preferenceStore, PreferenceConstants.SHOW_REPORT_VALIDATION_WARNING); preferenceStore.setValue( PreferenceConstants.SHOW_REPORT_VALIDATION_WARNING, dialog.getToggleState()); if (!(dialog.getReturnCode() == IDialogConstants.OK_ID || dialog.getReturnCode() == IDialogConstants.YES_ID)) { return; } } String f = textFile.getText(); if (reportTemplates.length > 0) { chosenReportMetaData = reportTemplates[comboReportType.getSelectionIndex()]; } else { showNoReportsExistant(); return; } chosenOutputFormat = getDepositService() .getOutputFormat( chosenReportMetaData.getOutputFormats()[comboOutputFormat.getSelectionIndex()]); // This just appends the chosen report's extension if the existing // suffix does not match. Could be enhanced. if (!f.endsWith(chosenOutputFormat.getFileSuffix())) { f += "." + chosenOutputFormat.getFileSuffix(); // $NON-NLS-1$ } String currentPath = setupDirPath(); if (useDefaultFolder) { Activator.getDefault() .getPreferenceStore() .setValue(PreferenceConstants.DEFAULT_FOLDER_REPORT, currentPath); } currentPath = getOldTemplateFolderPath(); outputFile = new File(f); } catch (Exception e) { LOG.error("Error while creating report.", e); MessageDialog.openError(getShell(), "Error", "An error occurred while creating report."); return; } super.okPressed(); }