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",
|
@ComponentDescriptor(name = "Label", author = "Branislav Stojkovic", category = "Misc",
|
||||||
description = "User defined label", instanceNamePrefix = "L", zOrder = IDIYComponent.TEXT, flexibleZOrder = true,
|
description = "User defined label", instanceNamePrefix = "L", zOrder = IDIYComponent.TEXT, flexibleZOrder = true,
|
||||||
stretchable = false, bomPolicy = BomPolicy.NEVER_SHOW)
|
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";
|
public static String DEFAULT_TEXT = "Double click to edit text";
|
||||||
|
|
||||||
@@ -211,16 +211,7 @@ public class Label extends AbstractComponent<Void> {
|
|||||||
@Override
|
@Override
|
||||||
public void setControlPoint(Point point, int index) {
|
public void setControlPoint(Point point, int index) {
|
||||||
this.point.setLocation(point);
|
this.point.setLocation(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(defaultable = false)
|
|
||||||
public String getText() {
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setText(String text) {
|
|
||||||
this.text = text;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
public Color getColor() {
|
public Color getColor() {
|
||||||
@@ -260,11 +251,14 @@ public class Label extends AbstractComponent<Void> {
|
|||||||
return super.getName();
|
return super.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name="Text", defaultable = false)
|
||||||
@Override
|
@Override
|
||||||
public Void getValue() {
|
public String getValue() {
|
||||||
return null;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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) {
|
if (color != null) {
|
||||||
label.setColor(color);
|
label.setColor(color);
|
||||||
}
|
}
|
||||||
label.setText(valueAttr);
|
label.setValue(valueAttr);
|
||||||
label.setHorizontalAlignment(HorizontalAlignment.LEFT);
|
label.setHorizontalAlignment(HorizontalAlignment.LEFT);
|
||||||
label.setVerticalAlignment(VerticalAlignment.CENTER);
|
label.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
label.setControlPoint(convertV1CoordinatesToV3Point(referencePoint, x1Attr, y1Attr), 0);
|
label.setControlPoint(convertV1CoordinatesToV3Point(referencePoint, x1Attr, y1Attr), 0);
|
||||||
@@ -671,7 +671,7 @@ public class V1FileParser implements IOldFileParser {
|
|||||||
Label titleLabel = new Label();
|
Label titleLabel = new Label();
|
||||||
titleLabel.setColor(Color.blue);
|
titleLabel.setColor(Color.blue);
|
||||||
titleLabel.setFontSize(24);
|
titleLabel.setFontSize(24);
|
||||||
titleLabel.setText(project.getTitle());
|
titleLabel.setValue(project.getTitle());
|
||||||
titleLabel.setHorizontalAlignment(HorizontalAlignment.CENTER);
|
titleLabel.setHorizontalAlignment(HorizontalAlignment.CENTER);
|
||||||
titleLabel.setControlPoint(
|
titleLabel.setControlPoint(
|
||||||
new Point(CalcUtils.roundToGrid(x + boardWidth / 2, V1_GRID_SPACING), CalcUtils.roundToGrid(
|
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();
|
Label creditsLabel = new Label();
|
||||||
creditsLabel.setFontSize(16);
|
creditsLabel.setFontSize(16);
|
||||||
creditsLabel.setText(project.getAuthor());
|
creditsLabel.setValue(project.getAuthor());
|
||||||
creditsLabel.setHorizontalAlignment(HorizontalAlignment.CENTER);
|
creditsLabel.setHorizontalAlignment(HorizontalAlignment.CENTER);
|
||||||
creditsLabel.setControlPoint(
|
creditsLabel.setControlPoint(
|
||||||
new Point(CalcUtils.roundToGrid(x + boardWidth / 2, V1_GRID_SPACING), CalcUtils.roundToGrid(
|
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);
|
editorPanel.add(createDefaultCheckBox(property), gbc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make value field focused
|
|
||||||
if (property.getName().equalsIgnoreCase("value")) {
|
if (property.getName().equalsIgnoreCase("value")) {
|
||||||
componentToFocus = editor;
|
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++;
|
gbc.gridy++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,4 +48,10 @@ public class StringEditor extends JTextField {
|
|||||||
setBackground(oldBg);
|
setBackground(oldBg);
|
||||||
property.setValue(getText());
|
property.setValue(getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requestFocusInWindow() {
|
||||||
|
selectAll();
|
||||||
|
return super.requestFocusInWindow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1522,6 +1522,10 @@
|
|||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>Mirror selection horizontally and vertically</description>
|
<description>Mirror selection horizontally and vertically</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</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>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>Consolidated popup menu items with "Edit" menu</description>
|
<description>Consolidated popup menu items with "Edit" menu</description>
|
||||||
|
|||||||
Reference in New Issue
Block a user