mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12:09 +10:00
default focus on text when editing JLabel
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -211,16 +211,7 @@ public class Label extends AbstractComponent<Void> {
|
||||
@Override
|
||||
public void setControlPoint(Point point, int index) {
|
||||
this.point.setLocation(point);
|
||||
}
|
||||
|
||||
@EditableProperty(defaultable = false)
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public Color getColor() {
|
||||
@@ -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.
@@ -116,12 +116,20 @@ public class PropertyEditorDialog extends ButtonDialog {
|
||||
editorPanel.add(createDefaultCheckBox(property), gbc);
|
||||
}
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user