ISaveParticipant saveParticipant = new MySaveParticipant(); try { ISavedState lastState = ResourcesPlugin.getWorkspace().addSaveParticipant(Activator.PLUGIN_ID, saveParticipant); } catch (CoreException e1) { // TODO Auto-generated catch block e1.printStackTrace(); }
public void prepareToSave(ISaveContext context) throws CoreException { try { FileOutputStream os = new FileOutputStream(s_fname, true); os.write("testing 6666".getBytes()); os.flush(); os.close(); } catch (Exception e) { e.printStackTrace(); } } @Override public void saving(ISaveContext context) throws CoreException { DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); try { FileOutputStream os = new FileOutputStream(s_fname, true); String message = "testing 1234" + dateFormat.format(new Date()) + "\n"; os.write(message.getBytes()); switch (context.getKind()) { case ISaveContext.FULL_SAVE: message = "Full Save" + dateFormat.format(new Date()) + "\n"; os.write(message.getBytes()); break; case ISaveContext.PROJECT_SAVE: message = "Project Save" + dateFormat.format(new Date()) + "\n"; os.write(message.getBytes()); break; case ISaveContext.SNAPSHOT: message ="Snapshot Save" + dateFormat.format(new Date()) + "\n"; os.write(message.getBytes()); break; } os.flush(); os.close(); } catch (Exception e) { e.printStackTrace(); } }