use of org.apache.pivot.wtk.TextArea in project pivot by apache.
the class BXMLExplorer method displayLoadException.
static void displayLoadException(Throwable exception, Window window) {
String message = exception.getClass().getName();
TextArea body = null;
String bodyText = exception.getMessage();
if (bodyText != null && bodyText.length() > 0) {
body = new TextArea();
body.setText(bodyText);
body.setEditable(false);
}
Alert.alert(MessageType.ERROR, message, null, body, window, null);
}
use of org.apache.pivot.wtk.TextArea in project pivot by apache.
the class Pivot841 method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
TextArea textArea = new TextArea();
textArea.setText("abcxyz");
final ParagraphListener paragraphListener = new ParagraphListener.Adapter() {
@Override
public void textInserted(Paragraph paragraph, int index, int count) {
System.out.println("Text inserted\n\tparagraph content: '" + paragraph.getCharacters() + "" + "'\n\tindex: " + index + "\n\tcount: " + count);
}
@Override
public void textRemoved(Paragraph paragraph, int index, int count) {
System.out.println("Text removed\n\tparagraph content: '" + paragraph.getCharacters() + "'\n\tindex: " + index + "\n\tcount: " + count);
}
};
textArea.getParagraphs().get(0).getParagraphListeners().add(paragraphListener);
textArea.getTextAreaContentListeners().add(new TextAreaContentListener() {
@Override
public void paragraphInserted(TextArea textAreaArgument, int index) {
Paragraph paragraph = textAreaArgument.getParagraphs().get(index);
System.out.println("Paragraph inserted\n\tparagraph content: '" + paragraph.getCharacters() + "'\n\tindex: " + index);
paragraph.getParagraphListeners().add(paragraphListener);
}
});
Window window = new Window(textArea);
window.open(display);
}
use of org.apache.pivot.wtk.TextArea in project pivot by apache.
the class TableViewTest2 method startup.
@Override
public void startup(final Display display, final Map<String, String> properties) throws Exception {
BXMLSerializer bxmlSerializer = new BXMLSerializer();
System.out.println("Double Click on Table elements to open the Row Editor");
window = (Window) bxmlSerializer.readObject(TableViewTest2.class, "table_view_test2.bxml");
tableView = (TableView) bxmlSerializer.getNamespace().get("tableView");
menu = (Window) bxmlSerializer.readObject(TableViewTest2.class, "context_menus.bxml");
tableView.setMenuHandler(new ContextMenusSampleMenuHandlerAdapter());
System.out.println("Right Click on Table elements to display Contextual Menu: " + menu);
TableViewRowEditor tableViewRowEditor = new TableViewRowEditor();
tableViewRowEditor.setEditEffect(CardPaneSkin.SelectionChangeEffect.HORIZONTAL_SLIDE);
tableView.setRowEditor(tableViewRowEditor);
TextArea textArea = new TextArea();
textArea.setTextKey("value");
tableViewRowEditor.getCellEditors().put("value", textArea);
window.open(display);
}
use of org.apache.pivot.wtk.TextArea in project pivot by apache.
the class TextAreaSkinParagraphView method paint.
public void paint(Graphics2D graphics) {
TextArea textArea = (TextArea) textAreaSkin.getComponent();
int selectionStart = textArea.getSelectionStart();
int selectionLength = textArea.getSelectionLength();
Span selectionRange = new Span(selectionStart, selectionStart + selectionLength - 1);
int paragraphOffset = paragraph.getOffset();
Span characterRange = new Span(paragraphOffset, paragraphOffset + paragraph.getCharacters().length() - 1);
if (selectionLength > 0 && characterRange.intersects(selectionRange)) {
boolean focused = textArea.isFocused();
boolean editable = textArea.isEditable();
// Determine the selected and unselected areas
Area selection = textAreaSkin.getSelection();
Area selectedArea = selection.createTransformedArea(AffineTransform.getTranslateInstance(-x, -y));
Area unselectedArea = new Area();
unselectedArea.add(new Area(new Rectangle2D.Float(0, 0, width, height)));
unselectedArea.subtract(new Area(selectedArea));
// Paint the unselected text
Graphics2D unselectedGraphics = (Graphics2D) graphics.create();
unselectedGraphics.clip(unselectedArea);
paint(unselectedGraphics, focused, editable, false);
unselectedGraphics.dispose();
// Paint the selected text
Graphics2D selectedGraphics = (Graphics2D) graphics.create();
selectedGraphics.clip(selectedArea);
paint(selectedGraphics, focused, editable, true);
selectedGraphics.dispose();
} else {
paint(graphics, textArea.isFocused(), textArea.isEditable(), false);
}
}
use of org.apache.pivot.wtk.TextArea in project pivot by apache.
the class TextAreaSkin method layout.
@SuppressWarnings("unused")
@Override
public void layout() {
TextArea textArea = (TextArea) getComponent();
int width = getWidth();
int breakWidth = (wrapText) ? Math.max(width - margin.getWidth(), 0) : Integer.MAX_VALUE;
int y = margin.top;
int lastY = 0;
int lastHeight = 0;
int rowOffset = 0;
int index = 0;
for (TextAreaSkinParagraphView paragraphView : paragraphViews) {
paragraphView.setBreakWidth(breakWidth);
paragraphView.setX(margin.left);
paragraphView.setY(y);
lastY = y;
y += paragraphView.getHeight();
lastHeight = paragraphView.getHeight();
paragraphView.setRowOffset(rowOffset);
rowOffset += paragraphView.getRowCount();
index++;
}
updateSelection();
caretX = caret.x;
if (textArea.isFocused()) {
scrollCharacterToVisible(textArea.getSelectionStart());
showCaret(textArea.getSelectionLength() == 0);
} else {
showCaret(false);
}
}
Aggregations