package bluej.pkgmgr.target;

import java.io.File;
import java.io.IOException;

import bluej.editor.Editor;
import bluej.editor.EditorWatcher;
import bluej.pkgmgr.Package;
import bluej.prefmgr.PrefMgr;
import bluej.prefmgr.PrefMgrDialog;
import threadchecker.OnThread;
import threadchecker.Tag;


| A target in a package that can be edited as text | | @author Michael Cahill | public abstract class EditableTarget extends Target implements EditorWatcher{ protected Editor editor; protected EditableTarget(Package pkg, String name) { super(pkg, name); }
| @return the name of the (text) file this target corresponds to. | protected abstract File getSourceFile();
| @return the editor object associated with this target | public abstract Editor getEditor();
| Ensure that the source file of this target is up-to-date (i.e. | that any possible unsaved changes in an open editor window are | saved). | public void ensureSaved() throws IOException { if (editor != null) { editor.save(); } }
| Called to open the editor for this target | @OnThread(Tag.FXPlatform) public void open() { Editor editor = getEditor(); if (editor == null) getPackage().showError("error-open-source"); else{ editor.setEditorVisible(true, false); } }
| Close the editor for this target. | protected void close() { getEditor().close(); }
| Return true if this editor has been opened at some point since this project was opened. | public boolean editorOpen() { return (editor!=null); } | | Called by Editor when a file is changed | public void modificationEvent(Editor editor) { }
| | Called by Editor when a file is saved | public void saveEvent(Editor editor) { }
| | Called by Editor when a file is closed | public void closeEvent(Editor editor) { }
| | Called by Editor when a breakpoint is been set/cleared | public String breakpointToggleEvent(int lineNo, boolean set) { return null; } public void clearAllBreakpoints() { } @Override public void showPreferences(int paneIndex) { PrefMgrDialog.showDialog(getPackage().getProject(), paneIndex); } }
top, use, map, abstract class EditableTarget

.   EditableTarget
.   getSourceFile
.   getEditor
.   ensureSaved
.   open
.   close
.   editorOpen
.   modificationEvent
.   saveEvent
.   closeEvent
.   breakpointToggleEvent
.   clearAllBreakpoints
.   showPreferences




112 neLoCode + 18 LoComm