Skip to content

Commit

Permalink
Merge pull request #291 from ImpulseAdventure/pconti-17b39
Browse files Browse the repository at this point in the history
278 - GuiSlice builder 0.17.b38 - Text problem
  • Loading branch information
Pconti31 authored Feb 20, 2025
2 parents fa40894 + d30766d commit d5171a1
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 43 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,29 @@ You will need to select "Allow Anyway" to continue.

## Release History

### Bug Fixes for 0.17.b39

- Bug Fix 278 - GuiSlice builder 0.17.b38 - Text problem

The new feature "Text is a Variable?" support that nadjet09 added has caused some confusion amoung our users.
It's caused users to actually place quotes inside the text string while laying out their UI.
They do this because if "Text is a Variable?"=true they get compiler errors for undefined variable.

In an effort to clear things up it's been changed to ""Wrap Quotes around text?"
with a default of true since its very rare for users to need variables or defines to set text.
Now if users set this value to false a WARNING message will also popup:

WARNING: Turning this to false
means no quotes will be output
during code generation.
Are you sure?

I Have also renamed the windows setup exe to drop the current version number at the end.
So now it will always be builder-win.exe this is because every time I run a new version
Norton anti-virus makes me play twenty questions with it before I can actually do a new install.
Hopefully I will only have to this once now...


### Enhancements for 0.17.b38

nadjet09 Completed "Text is a Variable?" support. This will let user choose to output text
Expand Down
2 changes: 1 addition & 1 deletion builder/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repositories {
mainClassName = "builder.Builder"
applicationName = "GUIslice"
archivesBaseName = 'builder'
project.version = '0.17.b38'
project.version = '0.17.b39'

processResources {
from("src/main/java/") {
Expand Down
1 change: 0 additions & 1 deletion builder/package/templates/graphics.t
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ $<CALLBACK>
<KEYPAD_CB_CASE>
case $<COM-002>:
gslc_ElemXKeyPadInputGet(pGui, $<COM-019>, pvData);
gslc_PopupHide(&m_gui);
break;
<STOP>
<KEYPAD_CONFIG_NUM>
Expand Down
1 change: 0 additions & 1 deletion builder/package/templates/linux.t
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ $<CALLBACK>
<KEYPAD_CB_CASE>
case $<COM-002>:
gslc_ElemXKeyPadInputGet(pGui, $<COM-019>, pvData);
gslc_PopupHide(&m_gui);
break;
<STOP>
<KEYPAD_CONFIG_NUM>
Expand Down
2 changes: 1 addition & 1 deletion builder/scripts/setup_template.iss
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ DisableWelcomePage=no
DisableProgramGroupPage=yes
LicenseFile=..\\..\\docs\\LICENSE.txt
OutputDir=.
OutputBaseFilename=builder-win-${applicationVersion}
OutputBaseFilename=builder-win
SetupIconFile=..\\tmp\\windows\\GUIsliceBuilder\\guislicebuilder.ico
Compression=lzma
SolidCompression=yes
Expand Down
2 changes: 1 addition & 1 deletion builder/src/main/java/builder/Builder.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public class Builder extends JDesktopPane {
private static final long serialVersionUID = 1L;

/** The Constant VERSION. */
public static final String VERSION = "0.17.b38";
public static final String VERSION = "0.17.b39";

/** The Constant VERSION_NO is for save and restore of user preferences. */
public static final String VERSION_NO = "-16";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,10 @@ static public StringBuilder process(CodeGenerator cg, TemplateManager tm, String
*/
String text = m.getText();

if (m.isStringEnabled() && text.length() >= 2) {
// Remove first and last character
map.put(TEXT_MACRO, m.getText());
} else {
if (m.isQuotesEnabled() || text.length() >= 2) {
map.put(TEXT_MACRO, CodeUtils.createLiteral(font, "\"", m.getText()));
} else {
map.put(TEXT_MACRO, m.getText());
}
outputLines = tm.expandMacros(template, map);
tm.codeWriter(sBd, outputLines);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ static public StringBuilder process(CodeGenerator cg, TemplateManager tm, String
*/
String text = m.getText();

if (m.isStringEnabled() && text.length() >= 2) { // check if text is string or variable name to decide whether to
if (m.isQuotesEnabled()) { // check if text is string or variable name to decide whether to
// use the "" or not.
map.put(TEXT_MACRO, m.getText());
} else {
map.put(TEXT_MACRO, CodeUtils.createLiteral(font, "\"", m.getText()));
} else {
map.put(TEXT_MACRO, m.getText());
}

outputLines = tm.expandMacros(template, map);
Expand Down
82 changes: 66 additions & 16 deletions builder/src/main/java/builder/models/TextModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class TextModel extends WidgetModel {
/** The Property Index Constants. */
static private final int PROP_FONT = 7;
static private final int PROP_TEXT = 8;
static private final int PROP_TXT_VAR_EN = 9;
static private final int PROP_TXT_QUOTES_EN = 9;
// static private final int PROP_UTF8 = 9;
static private final int PROP_TEXT_SZ = 10;
static private final int PROP_TEXT_ALIGN = 11;
Expand All @@ -81,7 +81,7 @@ public class TextModel extends WidgetModel {

/** The Property Defaults */
static public final String DEF_TEXT = "";
static public final Boolean DEF_TXT_VAR_EN = Boolean.FALSE;
static public final Boolean DEF_TXT_QUOTES_EN = Boolean.TRUE;
static public final Boolean DEF_UTF8 = Boolean.FALSE;
static public final Integer DEF_TEXT_SZ = Integer.valueOf(0);
static public final String DEF_TEXT_ALIGN = FontTFT.ALIGN_LEFT;
Expand Down Expand Up @@ -161,7 +161,7 @@ protected void initProperties()

initProp(PROP_FONT, JTextField.class, "TXT-200", Boolean.FALSE,"Font",ff.getDefFontName());
initProp(PROP_TEXT, String.class, "TXT-201", Boolean.FALSE,"Text",DEF_TEXT);
initProp(PROP_TXT_VAR_EN, Boolean.class, "COM-021", Boolean.FALSE,"Text is a Variable?",DEF_TXT_VAR_EN);
initProp(PROP_TXT_QUOTES_EN, Boolean.class, "TXT-214", Boolean.FALSE,"Wrap Quotes around text?", DEF_TXT_QUOTES_EN);

// initProp(PROP_UTF8, Boolean.class, "TXT-203", Boolean.FALSE,"UTF-8?",DEF_UTF8);

Expand All @@ -183,7 +183,7 @@ protected void initProperties()
/**
* getEditorAt
*
* @see builder.models.WidgetModel#getEditorAt(int)
* @see WidgetModel#getEditorAt(int)
*/
@Override
public TableCellEditor getEditorAt(int row) {
Expand All @@ -197,7 +197,7 @@ public TableCellEditor getEditorAt(int row) {
/**
* getRendererAt
*
* @see builder.models.WidgetModel#getRendererAt(int)
* @see WidgetModel#getRendererAt(int)
*/
@Override
public TableCellRenderer getRendererAt(int row) {
Expand All @@ -224,10 +224,24 @@ public void setFont(String fontName) {
/**
* setValueAt
*
* @see javax.swing.table.AbstractTableModel#setValueAt(java.lang.Object, int, int)
* @see javax.swing.table.AbstractTableModel#setValueAt(Object, int, int)
*/
@Override
public void setValueAt(Object value, int row, int col) {
if (row == PROP_TXT_QUOTES_EN) {
if (value instanceof Boolean) {
if (!((Boolean) value).booleanValue()) {
String msg = String.format("WARNING: Turning this to false\nmeans no quotes will be output\nduring code generation.\nAre you sure?");
if (JOptionPane.showConfirmDialog(null,
msg,
"Continue?",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) {
return;
}
}
}
}
if (row == PROP_TEXT_SZ) {
try {
int size = Integer.parseInt((String) value);
Expand All @@ -252,7 +266,7 @@ public void setValueAt(Object value, int row, int col) {
/**
* changeValueAt
*
* @see builder.models.WidgetModel#changeValueAt(java.lang.Object, int)
* @see WidgetModel#changeValueAt(Object, int)
*/
@Override
public void changeValueAt(Object value, int row) {
Expand Down Expand Up @@ -311,7 +325,7 @@ public void changeValueAt(Object value, int row) {
/**
* setFontReadOnly
*
* @see builder.models.WidgetModel#setFontReadOnly()
* @see WidgetModel#setFontReadOnly()
*/
@Override
public void setFontReadOnly() {
Expand Down Expand Up @@ -347,7 +361,7 @@ public boolean useFlash() {
/**
* getWidth
*
* @see builder.models.WidgetModel#getWidth()
* @see WidgetModel#getWidth()
*/
/*
public int getWidth() {
Expand All @@ -361,7 +375,7 @@ public int getWidth() {
/**
* getHeight
*
* @see builder.models.WidgetModel#getHeight()
* @see WidgetModel#getHeight()
*/
/*
public int getHeight() {
Expand Down Expand Up @@ -418,8 +432,8 @@ public boolean isFrameEnabled() {
return ((Boolean) data[PROP_FRAME_EN][PROP_VAL_VALUE]).booleanValue();
}

public boolean isStringEnabled() {
return ((Boolean) data[PROP_TXT_VAR_EN][PROP_VAL_VALUE]).booleanValue();
public boolean isQuotesEnabled() {
return ((Boolean) data[PROP_TXT_QUOTES_EN][PROP_VAL_VALUE]).booleanValue();
}
/**
* Gets the alignment.
Expand Down Expand Up @@ -563,7 +577,7 @@ public String removeInvalidChars(String s) {
*
* changeThemeColors
*
* @see builder.models.WidgetModel#changeThemeColors(builder.themes.GUIsliceTheme)
* @see WidgetModel#changeThemeColors(GUIsliceTheme)
*/
@Override
public void changeThemeColors(GUIsliceTheme theme) {
Expand Down Expand Up @@ -597,13 +611,49 @@ public void changeThemeColors(GUIsliceTheme theme) {
* Signals that an I/O exception has occurred.
* @throws ClassNotFoundException
* the class not found exception
* @see builder.models.WidgetModel#readModel(java.io.ObjectInputStream, java.lang.String)
* @see WidgetModel#readModel(ObjectInputStream, String)
*/
@Override
public void readModel(ObjectInputStream in, String widgetType)
throws IOException, ClassNotFoundException {
super.readModel(in, widgetType);
if (((String)data[PROP_TEXT_ALIGN][PROP_VAL_VALUE]).toLowerCase().equals("left"))
// super.readModel(in, widgetType);
// System.out.println("===== WM readModel() ========");
if (widgetType != null)
this.widgetType = widgetType;
bSendEvents = in.readBoolean();
// System.out.println("bSendEvents: " + bSendEvents);
int rows = in.readInt();
String metaID = null;
Object objectData = null;
int row;
// System.out.println("WM rows: " + rows);
boolean bVariable = false;

for (int i = 0; i < rows; i++) {
metaID = (String) in.readObject();
objectData = in.readObject();
if (metaID.equals("COM-021")) { // is text variable
// reverse boolean so that a true outputs quote marks
if (((Boolean) objectData).booleanValue()) {
bVariable = false;
} else {
bVariable = true;
}
row = mapMetaIDtoProperty("TXT-214"); // new value of meta-id
data[row][PROP_VAL_VALUE] = Boolean.valueOf(bVariable);
continue;
}
row = mapMetaIDtoProperty(metaID);
if (row >= 0) {
data[row][PROP_VAL_VALUE] = objectData;

// System.out.println(data[row][PROP_VAL_NAME].toString() + ": " +
// data[row][PROP_VAL_VALUE].toString() + " mapped to row " + row);

}
}

if (((String)data[PROP_TEXT_ALIGN][PROP_VAL_VALUE]).toLowerCase().equals("left"))
data[PROP_TEXT_ALIGN][PROP_VAL_VALUE] = FontTFT.ALIGN_LEFT;
else if (((String)data[PROP_TEXT_ALIGN][PROP_VAL_VALUE]).toLowerCase().equals("right"))
data[PROP_TEXT_ALIGN][PROP_VAL_VALUE] = FontTFT.ALIGN_RIGHT;
Expand Down
Loading

0 comments on commit d5171a1

Please sign in to comment.