Bug 14368 Create getter and setter insert code into read-only file
1. Create a class C as follow: package jp1; public class C { private int id; } 2. Close it and mark it as read only 3. Reopen it and you should not be able to modify anything 4. From the outline view, select "id - int" and right mouse click and select "Create getter and setter". 5. The class becomes package jp1; public class C { private int id; /** * Gets the id. * @return Returns a int */ public int getId() { return id; } /** * Sets the id. * @param id The id to set */ public void setId(int id) { this.id = id; } } and the editor is dirty, but you cannot save it until clear the read-only flag.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/OrganizeImportsAction.java
} else {
			runOnMultiple(cus, true);
		}
	}
	private void runOnMultiple(final ICompilationUnit[] cus, final boolean doResolve) {
		try {
			String message= ActionMessages.getString("OrganizeImportsAction.multi.status.description"); 
			final MultiStatus status= new MultiStatus(JavaUI.ID_PLUGIN, Status.OK, message, null);
			
			ProgressMonitorDialog dialog= new ProgressMonitorDialog(getShell());
			dialog.run(false, true, new IRunnableWithProgress() {
				public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
					doRunOnMultiple(cus, status, doResolve, monitor);
				}
			});
			if (!status.isOK()) {
				String title= ActionMessages.getString("OrganizeImportsAction.multi.status.title"); 
				ProblemDialog.open(getShell(), title, null, status);
			}
		} catch (InvocationTargetException e) {
			ExceptionHandler.handle(e, getShell(), ActionMessages.getString("OrganizeImportsAction.error.title"), ActionMessages.getString("OrganizeImportsAction.error.message")); 
		} catch (InterruptedException e) {
			
		}		
		
	}
	
	private void doRunOnMultiple(ICompilationUnit[] cus, MultiStatus status, boolean doResolve, IProgressMonitor monitor) throws InterruptedException {
	
		final class OrganizeImportError extends Error {