ECMA48,
/**
- * Synonym for ECMA48
+ * Synonym for ECMA48.
*/
XTERM
}
// Fall through...
case ECMA48:
backend = new ECMA48Backend(this, null, null);
+ break;
+ default:
+ throw new IllegalArgumentException("Invalid backend type: "
+ + backendType);
}
TApplicationImpl();
}
// secondary thread locks again. When it gives up, we have the
// single lock back.
boolean oldLock = unlockHandleEvent();
- assert (oldLock == true);
+ assert (oldLock);
while (secondaryEventReceiver != null) {
synchronized (primaryEventHandler) {
*
* @param path path of selected file
* @return the result of the new file open box
+ * @throws IOException if java.io operation throws
*/
public final String fileOpenBox(final String path) throws IOException {
* @param path path of selected file
* @param type one of the Type constants
* @return the result of the new file open box
+ * @throws IOException if java.io operation throws
*/
public final String fileOpenBox(final String path,
final TFileOpenBox.Type type) throws IOException {
*
* @return mnemonic string
*/
- public final MnemonicString getMnemonic() {
+ public MnemonicString getMnemonic() {
return mnemonic;
}
*
* @return if true, this is checked
*/
- public final boolean isChecked() {
+ public boolean isChecked() {
return checked;
}
*
* @param checked new checked value.
*/
- public final void setChecked(final boolean checked) {
+ public void setChecked(final boolean checked) {
this.checked = checked;
}
*
* @param path new path to list files for
*/
- public void setPath(String path) {
+ public void setPath(final String path) {
this.path = new File(path);
reflow();
}
* @param index index into files
* @return the line to draw
*/
- private String renderFile(int index) {
+ private String renderFile(final int index) {
File file = files.get(index);
String name = file.getName();
if (name.length() > 20) {
* true if this item was just expanded from a mouse click or keypress.
*/
@Override
- public void onExpand() {
+ public final void onExpand() {
// System.err.printf("onExpand() %s\n", file);
if (file == null) {
assert (file.isDirectory());
setExpandable(true);
- if ((isExpanded() == false) || (isExpandable() == false)) {
+ if (!isExpanded() || !isExpandable()) {
getTreeView().reflow();
return;
}
* @throws IllegalArgumentException if this function is called
*/
@Override
- public final TTreeItem addChild(final String text, final boolean expanded) {
+ public final TTreeItem addChild(final String text,
+ final boolean expanded) throws IllegalArgumentException {
+
throw new IllegalArgumentException("Do not call addChild(), use onExpand() instead");
}
*
* @param view root TTreeView
* @param text text for this item
+ * @throws IOException if a java.io operation throws
*/
public TDirectoryTreeItem(final TTreeView view,
final String text) throws IOException {
* @param view root TTreeView
* @param text text for this item
* @param expanded if true, have it expanded immediately
+ * @throws IOException if a java.io operation throws
*/
public TDirectoryTreeItem(final TTreeView view, final String text,
final boolean expanded) throws IOException {
* @param expanded if true, have it expanded immediately
* @param openParents if true, expand all paths up the root path and
* return the root path entry
+ * @throws IOException if a java.io operation throws
*/
public TDirectoryTreeItem(final TTreeView view, final String text,
final boolean expanded, final boolean openParents) throws IOException {
File rootFile = new File(text);
rootFile = rootFile.getCanonicalFile();
- if (openParents == true) {
+ if (openParents) {
setExpanded(true);
// Go up the directory tree
} else {
// This is a relative path. We got here because openParents was
// false.
- assert (openParents == false);
+ assert (!openParents);
setText(rootFile.getName());
}
onExpand();
- if (openParents == true) {
+ if (openParents) {
TDirectoryTreeItem childFile = this;
Collections.reverse(parentFiles);
for (String p: parentFiles) {
* TFileOpenBox can be called for either Open or Save actions.
*/
public enum Type {
+ /**
+ * Button will be labeled "Open".
+ */
OPEN,
+
+ /**
+ * Button will be labeled "Save".
+ */
SAVE
}
* directory, then
*
* @param newFilename the filename to check and return
+ * @throws IOException of a java.io operation throws
*/
private void checkFilename(final String newFilename) throws IOException {
File newFile = new File(newFilename);
* @param application the TApplication that manages this window
* @param path path of selected file
* @param type one of the Type constants
+ * @throws IOException of a java.io operation throws
*/
public TFileOpenBox(final TApplication application, final String path,
final Type type) throws IOException {
&& (mouse.getX() < getWidth() - 1)
) {
// Recompute value based on new box position
- value = (rightValue - leftValue) * (mouse.getX()) / (getWidth() - 3) + leftValue;
+ value = (rightValue - leftValue)
+ * (mouse.getX()) / (getWidth() - 3) + leftValue;
return;
}
inScroll = false;
/**
* My buttons.
*/
- List<TButton> buttons;
+ private List<TButton> buttons;
/**
* Message boxes have these possible results.
*
* @param expanded new value
*/
- public final void setExpanded(boolean expanded) {
+ public final void setExpanded(final boolean expanded) {
this.expanded = expanded;
}
*
* @param expandable new value
*/
- public final void setExpandable(boolean expandable) {
+ public final void setExpandable(final boolean expandable) {
this.expandable = expandable;
}
*
* @param invisible new value
*/
- public final void setInvisible(boolean invisible) {
+ public final void setInvisible(final boolean invisible) {
this.invisible = invisible;
}
*
* @param selected new value
*/
- public final void setSelected(boolean selected) {
+ public final void setSelected(final boolean selected) {
this.selected = selected;
}
*
* @param selectable new value
*/
- public final void setSelectable(boolean selectable) {
+ public final void setSelectable(final boolean selectable) {
this.selectable = selectable;
}
this.prefix = prefix;
array.add(this);
- if ((getChildren().size() == 0) || (expanded == false)) {
+ if ((getChildren().size() == 0) || !expanded) {
return array;
}
/**
* Get the horizontal scrollbar. This is used by TTreeItem.draw(), and
* potentially subclasses.
+ *
+ * @return the horizontal scrollbar
*/
public final THScroller getHScroller() {
return hScroller;
* If true, move the window to put the selected item in view. This
* normally only happens once after setting treeRoot.
*/
- public boolean centerWindow = false;
+ private boolean centerWindow = false;
/**
* The action to perform when the user selects an item.
* @param treeRoot ultimate root of tree
* @param centerWindow if true, move the window to put the root in view
*/
- public void setTreeRoot(final TTreeItem treeRoot, final boolean centerWindow) {
+ public void setTreeRoot(final TTreeItem treeRoot,
+ final boolean centerWindow) {
+
this.treeRoot = treeRoot;
this.centerWindow = centerWindow;
}
if (item == selectedItem) {
foundSelectedRow = true;
}
- if (foundSelectedRow == false) {
+ if (!foundSelectedRow) {
selectedRow++;
}
int lineWidth = item.getText().length()
- + item.getPrefix().length() + 4;
+ + item.getPrefix().length() + 4;
if (lineWidth > maxLineWidth) {
maxLineWidth = lineWidth;
}
* @param mouse mouse button release event
*/
@Override
- public void onMouseUp(TMouseEvent mouse) {
+ public void onMouseUp(final TMouseEvent mouse) {
// Pass to children
super.onMouseDown(mouse);
return;
}
- if ((mouse.isMouse1()) &&
- (inScroll) &&
- (mouse.getY() > 0) &&
- (mouse.getY() < getHeight() - 1)
+ if ((mouse.isMouse1())
+ && (inScroll)
+ && (mouse.getY() > 0)
+ && (mouse.getY() < getHeight() - 1)
) {
// Recompute value based on new box position
- value = (bottomValue - topValue) * (mouse.getY()) / (getHeight() - 3) + topValue;
+ value = (bottomValue - topValue)
+ * (mouse.getY()) / (getHeight() - 3) + topValue;
return;
}
}
/**
- * Comparison operator sorts on:
+ * Comparison operator. For various subclasses it sorts on:
* <ul>
* <li>tabOrder for TWidgets</li>
* <li>z for TWindows</li>
* @param y row relative to parent
* @param width width of tree view
* @param height height of tree view
+ * @return the new tree view
*/
public final TTreeView addTreeView(final int x, final int y,
final int width, final int height) {
* @param width width of tree view
* @param height height of tree view
* @param action action to perform when an item is selected
+ * @return the new tree view
*/
public final TTreeView addTreeView(final int x, final int y,
final int width, final int height, final TAction action) {
*
* @param path path of selected file
* @return the result of the new file open box
+ * @throws IOException if a java.io operation throws
*/
public final String fileOpenBox(final String path) throws IOException {
return getApplication().fileOpenBox(path);
* @param path path of selected file
* @param type one of the Type constants
* @return the result of the new file open box
+ * @throws IOException if a java.io operation throws
*/
public final String fileOpenBox(final String path,
final TFileOpenBox.Type type) throws IOException {
* @param y row relative to parent
* @param width width of text area
* @param height height of text area
+ * @return the new directory list
*/
public final TDirectoryList addDirectoryList(final String path, final int x,
final int y, final int width, final int height) {
* @param width width of text area
* @param height height of text area
* @param action action to perform when an item is selected
+ * @return the new directory list
*/
public final TDirectoryList addDirectoryList(final String path, final int x,
final int y, final int width, final int height, final TAction action) {
public String getRawLabel() {
return rawLabel;
}
-
+
/**
* Public constructor.
*
* a window
*/
@Override
- public boolean onMenu(TMenuEvent menu) {
+ public boolean onMenu(final TMenuEvent menu) {
if (menu.getId() == TMenu.MID_OPEN_FILE) {
try {
String filename = fileOpenBox(".");
String EOL = System.getProperty("line.separator");
try {
- while(scanner.hasNextLine()) {
+ while (scanner.hasNextLine()) {
fileContents.append(scanner.nextLine() + EOL);
}
new DemoTextWindow(this, filename,
* @param backendType one of the TApplication.BackendType values
* @throws Exception if TApplication can't instantiate the Backend.
*/
- public DemoApplication(BackendType backendType) throws Exception {
+ public DemoApplication(final BackendType backendType) throws Exception {
super(backendType);
addAllWidgets();
}
* Public constructor.
*
* @param parent the main application
+ * @throws IOException if a java.io operation throws
*/
- public DemoTreeViewWindow(TApplication parent) throws IOException {
+ public DemoTreeViewWindow(final TApplication parent) throws IOException {
super(parent, "Tree View", 0, 0, 44, 16, TWindow.RESIZABLE);
// Load the treeview with "stuff"
* @param resize resize event
*/
@Override
- public void onResize(TResizeEvent resize) {
+ public void onResize(final TResizeEvent resize) {
if (resize.getType() == TResizeEvent.Type.WIDGET) {
// Resize the text field
treeView.setWidth(resize.getWidth() - 4);
Cell lCell = screen.logical[cursorX][cursorY];
gr.setColor(attrToForegroundColor(lCell));
switch (cursorStyle) {
+ default:
+ // Fall through...
case UNDERLINE:
gr.fillRect(xPixel, yPixel + textHeight - 2,
textWidth, 2);
SwingScreen.this.frame.resizeToScreen();
SwingScreen.this.frame.setVisible(true);
}
- } );
+ });
} catch (Exception e) {
e.printStackTrace();
}
* @param label menu item label
* @return the new menu item
*/
- public final TMenuItem addItem(final int id, final String label) {
+ public TMenuItem addItem(final int id, final String label) {
assert (id >= 1024);
return addItemInternal(id, label, null);
}
* @param key global keyboard accelerator
* @return the new menu item
*/
- public final TMenuItem addItem(final int id, final String label,
+ public TMenuItem addItem(final int id, final String label,
final TKeypress key) {
assert (id >= 1024);
* (inclusive).
* @return the new menu item
*/
- public final TMenuItem addDefaultItem(final int id) {
+ public TMenuItem addDefaultItem(final int id) {
assert (id >= 0);
assert (id < 1024);
/**
* Convenience function to add a menu separator.
*/
- public final void addSeparator() {
+ public void addSeparator() {
int newY = getChildren().size() + 1;
assert (newY < getHeight());
* denoted by prefixing a letter with "&", e.g. "&File"
* @return the new sub-menu
*/
- public final TSubMenu addSubMenu(final String title) {
+ public TSubMenu addSubMenu(final String title) {
int newY = getChildren().size() + 1;
assert (newY < getHeight());
* Returns true if the mouse is currently on the menu item.
*
* @param mouse mouse event
+ * @return if true then the mouse is currently on this item
*/
private boolean mouseOnMenuItem(final TMouseEvent mouse) {
if ((mouse.getY() == 0)
}
}
- /**
- * Handle mouse button presses.
- *
- * @param event mouse button press event
- */
- /* TODO: this was commented out in d-tui, why?
- @Override
- public void onMouseDown(final TMouseEvent event) {
- if ((mouseOnMenuItem(event)) && (event.mouse1)) {
- dispatch();
- return;
- }
- }
- */
-
/**
* Handle mouse button releases.
*
}
/**
- * Set or unset a toggle. value is 'true' for set ('h'), false for reset
- * ('l').
+ * Set or unset a toggle.
+ *
+ * @param value true for set ('h'), false for reset ('l')
*/
private void setToggle(final boolean value) {
boolean decPrivateModeFlag = false;
collect(ch);
}
if (ch == 0x5C) {
- if ((collectBuffer.length() > 0) &&
- (collectBuffer.charAt(collectBuffer.length() - 1) == 0x1B)
+ if ((collectBuffer.length() > 0)
+ && (collectBuffer.charAt(collectBuffer.length() - 1) == 0x1B)
) {
toGround();
}
collect(ch);
}
if (ch == 0x5C) {
- if ((collectBuffer.length() > 0) &&
- (collectBuffer.charAt(collectBuffer.length() - 1) == 0x1B)
+ if ((collectBuffer.length() > 0)
+ && (collectBuffer.charAt(collectBuffer.length() - 1) == 0x1B)
) {
toGround();
}
/**
* Read function runs on a separate thread.
*/
- public void run() {
+ public final void run() {
boolean utf8 = false;
boolean done = false;