Exemplo n.º 1
0
 @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();
 }