default focus on text when editing JLabel

This commit is contained in:
bancika
2017-01-05 10:35:20 +01:00
parent 23d702eeb5
commit 53f09e6143
6 changed files with 31 additions and 19 deletions
@@ -23,7 +23,7 @@ import org.diylc.core.annotations.EditableProperty;
@ComponentDescriptor(name = "Label", author = "Branislav Stojkovic", category = "Misc",
description = "User defined label", instanceNamePrefix = "L", zOrder = IDIYComponent.TEXT, flexibleZOrder = true,
stretchable = false, bomPolicy = BomPolicy.NEVER_SHOW)
public class Label extends AbstractComponent<Void> {
public class Label extends AbstractComponent<String> {
public static String DEFAULT_TEXT = "Double click to edit text";
@@ -213,15 +213,6 @@ public class Label extends AbstractComponent<Void> {
this.point.setLocation(point);
}
@EditableProperty(defaultable = false)
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
@EditableProperty
public Color getColor() {
return color;
@@ -260,11 +251,14 @@ public class Label extends AbstractComponent<Void> {
return super.getName();
}
@EditableProperty(name="Text", defaultable = false)
@Override
public Void getValue() {
return null;
public String getValue() {
return text;
}
@Override
public void setValue(Void value) {}
public void setValue(String value) {
this.text = value;
}
}
@@ -145,7 +145,7 @@ public class V1FileParser implements IOldFileParser {
if (color != null) {
label.setColor(color);
}
label.setText(valueAttr);
label.setValue(valueAttr);
label.setHorizontalAlignment(HorizontalAlignment.LEFT);
label.setVerticalAlignment(VerticalAlignment.CENTER);
label.setControlPoint(convertV1CoordinatesToV3Point(referencePoint, x1Attr, y1Attr), 0);
@@ -671,7 +671,7 @@ public class V1FileParser implements IOldFileParser {
Label titleLabel = new Label();
titleLabel.setColor(Color.blue);
titleLabel.setFontSize(24);
titleLabel.setText(project.getTitle());
titleLabel.setValue(project.getTitle());
titleLabel.setHorizontalAlignment(HorizontalAlignment.CENTER);
titleLabel.setControlPoint(
new Point(CalcUtils.roundToGrid(x + boardWidth / 2, V1_GRID_SPACING), CalcUtils.roundToGrid(
@@ -680,7 +680,7 @@ public class V1FileParser implements IOldFileParser {
Label creditsLabel = new Label();
creditsLabel.setFontSize(16);
creditsLabel.setText(project.getAuthor());
creditsLabel.setValue(project.getAuthor());
creditsLabel.setHorizontalAlignment(HorizontalAlignment.CENTER);
creditsLabel.setControlPoint(
new Point(CalcUtils.roundToGrid(x + boardWidth / 2, V1_GRID_SPACING), CalcUtils.roundToGrid(
Binary file not shown.
@@ -117,11 +117,19 @@ public class PropertyEditorDialog extends ButtonDialog {
}
}
// Make value field focused
if (property.getName().equalsIgnoreCase("value")) {
componentToFocus = editor;
}
// Make value field focused
try {
if (componentToFocus == null && property.getGetter().getName().equalsIgnoreCase("getValue")) {
componentToFocus = editor;
}
} catch (Exception e1) {
LOG.warn("Could not determine editor component to focus", e1);
}
gbc.gridy++;
}
@@ -48,4 +48,10 @@ public class StringEditor extends JTextField {
setBackground(oldBg);
property.setValue(getText());
}
@Override
public boolean requestFocusInWindow() {
selectAll();
return super.requestFocusInWindow();
}
}
+4
View File
@@ -1522,6 +1522,10 @@
<changeType>NEW_FEATURE</changeType>
<description>Mirror selection horizontally and vertically</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Default focus on "Text" field for label</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Consolidated popup menu items with "Edit" menu</description>