Skip to content

Commit 31d6cd4

Browse files
committed
minor changes - e.g. user tooltips on scripts list
1 parent 0abb5e9 commit 31d6cd4

File tree

5 files changed

+76
-35
lines changed

5 files changed

+76
-35
lines changed

com.opendoorlogistics.core/src/com/opendoorlogistics/core/AppConstants.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ final public class AppConstants {
1818

1919
public static final int APP_VERSION_MAJOR = 1;
2020

21-
public static final int APP_VERSION_MINOR = 1;
21+
public static final int APP_VERSION_MINOR = 2;
2222

23-
public static final int APP_VERSION_REVISION = 7;
23+
public static final int APP_VERSION_REVISION = 0;
2424

2525
public static final String SHAPEFILES_DIRECTORY = "data" + File.separator + "shapefiles" + File.separator;
2626

com.opendoorlogistics.core/src/com/opendoorlogistics/core/tables/io/PoiIO.java

+44-23
Original file line numberDiff line numberDiff line change
@@ -155,29 +155,8 @@ private static void exportTable(Sheet sheet, ODLTableReadOnly table,int firstOut
155155
Row row = sheet.createRow(firstOutputRow + 1 + srcRow);
156156
for (int col = 0; col < nc; col++) {
157157
Cell cell = row.createCell(col);
158-
switch(table.getColumnType(col)){
159-
case LONG:
160-
case DOUBLE:
161-
Number dVal = (Number)table.getValueAt(srcRow, col);
162-
if(dVal!=null){
163-
cell.setCellValue(dVal.doubleValue());
164-
}else{
165-
cell.setCellValue((String)null);
166-
}
167-
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
168-
break;
169-
default:
170-
String sval = TableUtils.getValueAsString(table, srcRow, col);
171-
if (sval != null) {
172-
if (sval.length() >= MAX_CHAR_COUNT_IN_EXCEL_CELL) {
173-
nbOversized++;
174-
}
175-
cell.setCellValue(sval.toString());
176-
} else {
177-
cell.setCellValue((String) null);
178-
}
179-
cell.setCellType(Cell.CELL_TYPE_STRING);
180-
break;
158+
if(saveElementToCell(table, srcRow, col, cell)==SaveElementResult.OVERSIZED){
159+
nbOversized++;
181160
}
182161

183162
}
@@ -187,6 +166,48 @@ private static void exportTable(Sheet sheet, ODLTableReadOnly table,int firstOut
187166
report.log(getOversizedWarningMessage(nbOversized, table.getName()));
188167
}
189168
}
169+
170+
public enum SaveElementResult{
171+
OK,
172+
OVERSIZED
173+
}
174+
175+
/**
176+
* @param table
177+
* @param row
178+
* @param col
179+
* @param cell
180+
* @param nbOversized
181+
* @return
182+
*/
183+
public static SaveElementResult saveElementToCell(ODLTableReadOnly table, int row, int col, Cell cell) {
184+
boolean oversized=false;
185+
switch(table.getColumnType(col)){
186+
case LONG:
187+
case DOUBLE:
188+
Number dVal = (Number)table.getValueAt(row, col);
189+
if(dVal!=null){
190+
cell.setCellValue(dVal.doubleValue());
191+
}else{
192+
cell.setCellValue((String)null);
193+
}
194+
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
195+
break;
196+
default:
197+
String sval = TableUtils.getValueAsString(table, row, col);
198+
if (sval != null) {
199+
if (sval.length() >= MAX_CHAR_COUNT_IN_EXCEL_CELL) {
200+
oversized=true;
201+
}
202+
cell.setCellValue(sval.toString());
203+
} else {
204+
cell.setCellValue((String) null);
205+
}
206+
cell.setCellType(Cell.CELL_TYPE_STRING);
207+
break;
208+
}
209+
return oversized? SaveElementResult.OVERSIZED : SaveElementResult.OK;
210+
}
190211

191212
public static String getOversizedWarningMessage(int nbOversized, String tableName) {
192213
String s = "Found " + nbOversized + " cell(s) in table \"" + tableName + "\" longer than maximum Excel cell length ("

com.opendoorlogistics.studio/src/com/opendoorlogistics/studio/LoadedDatastore.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.opendoorlogistics.core.tables.decorators.datastores.ListenerDecorator;
3030
import com.opendoorlogistics.core.tables.decorators.datastores.UndoRedoDecorator;
3131
import com.opendoorlogistics.core.tables.io.PoiIO;
32+
import com.opendoorlogistics.core.tables.io.PoiIO.SaveElementResult;
3233
import com.opendoorlogistics.core.tables.memory.ODLDatastoreImpl;
3334
import com.opendoorlogistics.core.tables.utils.DatastoreComparer;
3435
import com.opendoorlogistics.core.tables.utils.TableFlagUtils;
@@ -166,11 +167,14 @@ private void updateWorkbookWithModifications(Workbook wb,ExecutionReport report)
166167
cell = row.createCell(col);
167168
}
168169

169-
String sval =TableUtils.getValueAsString(newTable, iRow, col);
170-
if(sval!=null && sval.length()>PoiIO.MAX_CHAR_COUNT_IN_EXCEL_CELL){
170+
if(PoiIO.saveElementToCell(newTable, iRow, col, cell) == SaveElementResult.OVERSIZED){
171171
nbOversized++;
172172
}
173-
cell.setCellValue(sval);
173+
// String sval =TableUtils.getValueAsString(newTable, iRow, col);
174+
// if(sval!=null && sval.length()>PoiIO.MAX_CHAR_COUNT_IN_EXCEL_CELL){
175+
// nbOversized++;
176+
// }
177+
// cell.setCellValue(sval);
174178
}
175179
}
176180

com.opendoorlogistics.studio/src/com/opendoorlogistics/studio/scripts/list/ScriptNode.java

+15
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,19 @@ int getDepth(){
194194
}
195195
return ret;
196196
}
197+
198+
public String getTooltip(boolean isRunnable){
199+
if(option!=null && option.getEditorLabel()!=null && option.getEditorLabel().length()>0){
200+
return option.getEditorLabel();
201+
}
202+
203+
String name = getDisplayName();
204+
if (isAvailable() == false) {
205+
return "The format of this script is incorrect and it cannot be loaded.";
206+
} else if (isRunnable) {
207+
return "Press the icon to run " + name + " or double click on its name to edit the option.";
208+
} else {
209+
return "Double click on the option's name to edit it.";
210+
}
211+
}
197212
}

com.opendoorlogistics.studio/src/com/opendoorlogistics/studio/scripts/list/ScriptsTree.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,14 @@ public String getToolTipText(MouseEvent e) {
110110
TreePath path = tree.getPathForLocation(e.getX(), e.getY());
111111
if (path != null && path.getLastPathComponent() != null) {
112112
ScriptNode node = (ScriptNode) path.getLastPathComponent();
113-
if (node.isAvailable() == false) {
114-
return "The format of this script is incorrect and it cannot be loaded.";
115-
} else if (ScriptNode.isRunnable(node,scriptUIManager)) {
116-
return "Press the button to run " + node.getFile().getName() + " or double click on its name to edit the script.";
117-
} else {
118-
return "Double click on the script's name to edit it.";
119-
}
113+
return node.getTooltip(ScriptNode.isRunnable(node,scriptUIManager));
114+
// if (node.isAvailable() == false) {
115+
// return "The format of this script is incorrect and it cannot be loaded.";
116+
// } else if (ScriptNode.isRunnable(node,scriptUIManager)) {
117+
// return "Press the button to run " + node.getFile().getName() + " or double click on its name to edit the script.";
118+
// } else {
119+
// return "Double click on the script's name to edit it.";
120+
// }
120121
}
121122

122123
return null;

0 commit comments

Comments
 (0)