Lines 19-25
Link Here
|
19 |
* |
19 |
* |
20 |
*************************************************************/ |
20 |
*************************************************************/ |
21 |
|
21 |
|
22 |
|
|
|
23 |
package com.sun.star.wizards.table; |
22 |
package com.sun.star.wizards.table; |
24 |
|
23 |
|
25 |
import com.sun.star.awt.FontDescriptor; |
24 |
import com.sun.star.awt.FontDescriptor; |
Lines 28-35
Link Here
|
28 |
import com.sun.star.awt.XItemListener; |
27 |
import com.sun.star.awt.XItemListener; |
29 |
import com.sun.star.awt.XListBox; |
28 |
import com.sun.star.awt.XListBox; |
30 |
import com.sun.star.awt.XTextComponent; |
29 |
import com.sun.star.awt.XTextComponent; |
|
|
30 |
import com.sun.star.beans.PropertyChangeEvent; |
31 |
import com.sun.star.beans.UnknownPropertyException; |
32 |
import com.sun.star.beans.XPropertyChangeListener; |
31 |
import com.sun.star.beans.XPropertySet; |
33 |
import com.sun.star.beans.XPropertySet; |
32 |
import com.sun.star.lang.EventObject; |
34 |
import com.sun.star.lang.EventObject; |
|
|
35 |
import com.sun.star.lang.WrappedTargetException; |
33 |
import com.sun.star.uno.Exception; |
36 |
import com.sun.star.uno.Exception; |
34 |
import com.sun.star.uno.UnoRuntime; |
37 |
import com.sun.star.uno.UnoRuntime; |
35 |
import com.sun.star.wizards.common.Desktop; |
38 |
import com.sun.star.wizards.common.Desktop; |
Lines 38-51
Link Here
|
38 |
import com.sun.star.wizards.db.TableDescriptor; |
41 |
import com.sun.star.wizards.db.TableDescriptor; |
39 |
import com.sun.star.wizards.ui.UIConsts; |
42 |
import com.sun.star.wizards.ui.UIConsts; |
40 |
import com.sun.star.wizards.ui.UnoDialog; |
43 |
import com.sun.star.wizards.ui.UnoDialog; |
|
|
44 |
import java.util.logging.Level; |
45 |
import java.util.logging.Logger; |
41 |
|
46 |
|
42 |
public class FieldFormatter implements XItemListener |
47 |
public class FieldFormatter implements XItemListener, XPropertyChangeListener |
43 |
{ |
48 |
{ |
44 |
|
49 |
|
|
|
50 |
private static final String COLUMN = "Column"; |
45 |
TableWizard CurUnoDialog; |
51 |
TableWizard CurUnoDialog; |
46 |
TableDescriptor curTableDescriptor; |
52 |
TableDescriptor curTableDescriptor; |
47 |
Object oColumnDescriptorModel; |
53 |
Object oColumnDescriptorModel; |
48 |
XTextComponent txtfieldname; |
|
|
49 |
XListBox xlstFieldNames; |
54 |
XListBox xlstFieldNames; |
50 |
XButton btnplus; |
55 |
XButton btnplus; |
51 |
XButton btnminus; |
56 |
XButton btnminus; |
Lines 55-61
Link Here
|
55 |
String TOGGLEBUTTONS = "toggleButtons"; |
60 |
String TOGGLEBUTTONS = "toggleButtons"; |
56 |
String ADDFIELDNAME = "addFieldName"; |
61 |
String ADDFIELDNAME = "addFieldName"; |
57 |
String REMOVEFIELDNAME = "removeFieldName"; |
62 |
String REMOVEFIELDNAME = "removeFieldName"; |
58 |
String MODIFYFIELDNAME = "modifyFieldName"; |
|
|
59 |
String[] fieldnames; |
63 |
String[] fieldnames; |
60 |
String suntitled; |
64 |
String suntitled; |
61 |
Integer IFieldFormatStep; |
65 |
Integer IFieldFormatStep; |
Lines 155-181
Link Here
|
155 |
8, sfieldinfo, 0, 158, 27, IFieldFormatStep, new Short(curtabindex++), 165 |
159 |
8, sfieldinfo, 0, 158, 27, IFieldFormatStep, new Short(curtabindex++), 165 |
156 |
}); |
160 |
}); |
157 |
|
161 |
|
158 |
|
|
|
159 |
CurUnoDialog.insertLabel("lblFieldName", |
160 |
new String[] |
161 |
{ |
162 |
PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH |
163 |
}, |
164 |
new Object[] |
165 |
{ |
166 |
UIConsts.INTEGERS[8], sFieldName, 158, 39, IFieldFormatStep, new Short(curtabindex++), 94 |
167 |
}); |
168 |
|
169 |
txtfieldname = CurUnoDialog.insertTextField("txtfieldname", MODIFYFIELDNAME, this, |
170 |
new String[] |
171 |
{ |
172 |
PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, "Text", PropertyNames.PROPERTY_WIDTH |
173 |
}, |
174 |
new Object[] |
175 |
{ |
176 |
UIConsts.INTEGER_12, "HID:WIZARDS_HID_DLGTABLE_COLNAME", 274, 37, IFieldFormatStep, new Short(curtabindex++), PropertyNames.EMPTY_STRING, 50 |
177 |
}); |
178 |
txtfieldname.addTextListener(CurUnoDialog); |
179 |
CurUnoDialog.getPeerConfiguration().setAccessibleName(btnplus, sbtnplushelptext); |
162 |
CurUnoDialog.getPeerConfiguration().setAccessibleName(btnplus, sbtnplushelptext); |
180 |
CurUnoDialog.getPeerConfiguration().setAccessibleName(btnminus, sbtnminushelptext); |
163 |
CurUnoDialog.getPeerConfiguration().setAccessibleName(btnminus, sbtnminushelptext); |
181 |
} |
164 |
} |
Lines 191-201
Link Here
|
191 |
}, // PropertyNames.PROPERTY_HELPURL |
174 |
}, // PropertyNames.PROPERTY_HELPURL |
192 |
new Object[] |
175 |
new Object[] |
193 |
{ |
176 |
{ |
194 |
85, 158, 49, IFieldFormatStep, new Short(curtabindex++), 166, 50 |
177 |
93, 158, 39, IFieldFormatStep, new Short(curtabindex++), 166, 50 |
195 |
}); //, "HID:WIZARDS_HID_DLGTABLE_COLMODIFIER" |
178 |
}); //, "HID:WIZARDS_HID_DLGTABLE_COLMODIFIER" |
196 |
curTableDescriptor = _curTableDescriptor; |
179 |
curTableDescriptor = _curTableDescriptor; |
197 |
Helper.setUnoPropertyValue(oColumnDescriptorModel, PropertyNames.ACTIVE_CONNECTION, _curTableDescriptor.DBConnection); |
180 |
Helper.setUnoPropertyValue(oColumnDescriptorModel, PropertyNames.ACTIVE_CONNECTION, _curTableDescriptor.DBConnection); |
198 |
txtfieldname.setMaxTextLen((short) this.curTableDescriptor.getMaxColumnNameLength()); |
|
|
199 |
} |
181 |
} |
200 |
else |
182 |
else |
201 |
{ |
183 |
{ |
Lines 237-242
Link Here
|
237 |
|
219 |
|
238 |
public void addFieldName() |
220 |
public void addFieldName() |
239 |
{ |
221 |
{ |
|
|
222 |
|
240 |
String snewfieldname = Desktop.getUniqueName(xlstFieldNames.getItems(), suntitled, PropertyNames.EMPTY_STRING); |
223 |
String snewfieldname = Desktop.getUniqueName(xlstFieldNames.getItems(), suntitled, PropertyNames.EMPTY_STRING); |
241 |
short icount = xlstFieldNames.getItemCount(); |
224 |
short icount = xlstFieldNames.getItemCount(); |
242 |
if (CurUnoDialog.verifyfieldcount(icount)) |
225 |
if (CurUnoDialog.verifyfieldcount(icount)) |
Lines 293-300
Link Here
|
293 |
} |
276 |
} |
294 |
else |
277 |
else |
295 |
{ |
278 |
{ |
296 |
Helper.setUnoPropertyValue(UnoDialog.getModel(txtfieldname), "Text", PropertyNames.EMPTY_STRING); |
|
|
297 |
Helper.setUnoPropertyValue(UnoDialog.getModel(btnminus), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(benable)); |
279 |
Helper.setUnoPropertyValue(UnoDialog.getModel(btnminus), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(benable)); |
|
|
280 |
|
298 |
CurUnoDialog.setcompleted(TableWizard.SOFIELDSFORMATPAGE, benable); |
281 |
CurUnoDialog.setcompleted(TableWizard.SOFIELDSFORMATPAGE, benable); |
299 |
} |
282 |
} |
300 |
Helper.setUnoPropertyValue(UnoDialog.getModel(btnminus), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(benable)); |
283 |
Helper.setUnoPropertyValue(UnoDialog.getModel(btnminus), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(benable)); |
Lines 302-333
Link Here
|
302 |
CurUnoDialog.repaintDialogStep(); |
285 |
CurUnoDialog.repaintDialogStep(); |
303 |
} |
286 |
} |
304 |
|
287 |
|
305 |
public void modifyFieldName() |
|
|
306 |
{ |
307 |
String newfieldname = txtfieldname.getText(); |
308 |
String oldfieldname = xlstFieldNames.getSelectedItem(); |
309 |
if (!newfieldname.equals(oldfieldname)) |
310 |
{ |
311 |
if (curTableDescriptor.modifyColumnName(oldfieldname, newfieldname)) |
312 |
{ |
313 |
Object oColumn = Helper.getUnoPropertyValue(oColumnDescriptorModel, "Column"); |
314 |
Helper.setUnoPropertyValue(oColumn, PropertyNames.PROPERTY_NAME, newfieldname); |
315 |
FieldDescription curfielddescription = (FieldDescription) CurUnoDialog.fielditems.get(oldfieldname); |
316 |
CurUnoDialog.fielditems.remove(oldfieldname); |
317 |
curfielddescription.setName(newfieldname); |
318 |
CurUnoDialog.fielditems.put(newfieldname, curfielddescription); |
319 |
String[] fieldnames = xlstFieldNames.getItems(); |
320 |
short ipos = xlstFieldNames.getSelectedItemPos(); |
321 |
fieldnames[ipos] = newfieldname; |
322 |
Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), PropertyNames.STRING_ITEM_LIST, fieldnames); |
323 |
Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), PropertyNames.SELECTED_ITEMS, new short[] |
324 |
{ |
325 |
ipos |
326 |
}); |
327 |
} |
328 |
} |
329 |
} |
330 |
|
331 |
public void shiftFieldNameUp() |
288 |
public void shiftFieldNameUp() |
332 |
{ |
289 |
{ |
333 |
short ipos = xlstFieldNames.getSelectedItemPos(); |
290 |
short ipos = xlstFieldNames.getSelectedItemPos(); |
Lines 374-384
Link Here
|
374 |
|
331 |
|
375 |
public boolean updateColumnofColumnDescriptor() |
332 |
public boolean updateColumnofColumnDescriptor() |
376 |
{ |
333 |
{ |
377 |
Object oColumn = Helper.getUnoPropertyValue(oColumnDescriptorModel, "Column"); |
334 |
Object oColumn = Helper.getUnoPropertyValue(oColumnDescriptorModel, COLUMN); |
378 |
XPropertySet xColPropertySet = UnoRuntime.queryInterface(XPropertySet.class, oColumn); |
335 |
XPropertySet xColPropertySet = UnoRuntime.queryInterface(XPropertySet.class, oColumn); |
379 |
if (xColPropertySet != null) |
336 |
if (xColPropertySet != null) |
380 |
{ |
337 |
{ |
381 |
curTableDescriptor.modifyColumn(txtfieldname.getText(), xColPropertySet); |
338 |
try |
|
|
339 |
{ |
340 |
curTableDescriptor.modifyColumn((String) xColPropertySet.getPropertyValue(PropertyNames.PROPERTY_NAME), xColPropertySet); |
341 |
} |
342 |
catch (UnknownPropertyException ex) |
343 |
{ |
344 |
Logger.getLogger(FieldFormatter.class.getName()).log(Level.SEVERE, null, ex); |
345 |
} |
346 |
catch (WrappedTargetException ex) |
347 |
{ |
348 |
Logger.getLogger(FieldFormatter.class.getName()).log(Level.SEVERE, null, ex); |
349 |
} |
382 |
return true; |
350 |
return true; |
383 |
} |
351 |
} |
384 |
return false; |
352 |
return false; |
Lines 390-398
Link Here
|
390 |
XPropertySet xNewPropertySet = curTableDescriptor.clonePropertySet(_ColumnName, _xColumn); |
358 |
XPropertySet xNewPropertySet = curTableDescriptor.clonePropertySet(_ColumnName, _xColumn); |
391 |
if (xNewPropertySet != null) |
359 |
if (xNewPropertySet != null) |
392 |
{ |
360 |
{ |
393 |
Helper.setUnoPropertyValue(oColumnDescriptorModel, "Column", xNewPropertySet); |
361 |
try |
|
|
362 |
{ |
363 |
xNewPropertySet.addPropertyChangeListener(PropertyNames.PROPERTY_NAME, this); |
364 |
} |
365 |
catch (UnknownPropertyException ex) |
366 |
{ |
367 |
Logger.getLogger(FieldFormatter.class.getName()).log(Level.SEVERE, null, ex); |
368 |
} |
369 |
catch (WrappedTargetException ex) |
370 |
{ |
371 |
Logger.getLogger(FieldFormatter.class.getName()).log(Level.SEVERE, null, ex); |
372 |
} |
373 |
Helper.setUnoPropertyValue(oColumnDescriptorModel, COLUMN, xNewPropertySet); |
394 |
} |
374 |
} |
395 |
txtfieldname.setText(_ColumnName); |
|
|
396 |
} |
375 |
} |
397 |
|
376 |
|
398 |
public XPropertySet clonePropertySet(XPropertySet _xPropertySet) |
377 |
public XPropertySet clonePropertySet(XPropertySet _xPropertySet) |
Lines 426-429
Link Here
|
426 |
{ |
405 |
{ |
427 |
// TODO Auto-generated method stub |
406 |
// TODO Auto-generated method stub |
428 |
} |
407 |
} |
|
|
408 |
|
409 |
public void propertyChange(PropertyChangeEvent pce) |
410 |
{ |
411 |
String newfieldname = (String) pce.NewValue; |
412 |
String oldfieldname = xlstFieldNames.getSelectedItem(); |
413 |
if (!newfieldname.equals(oldfieldname) && curTableDescriptor.modifyColumnName(oldfieldname, newfieldname)) |
414 |
{ |
415 |
FieldDescription curfielddescription = (FieldDescription) CurUnoDialog.fielditems.get(oldfieldname); |
416 |
CurUnoDialog.fielditems.remove(oldfieldname); |
417 |
curfielddescription.setName(newfieldname); |
418 |
CurUnoDialog.fielditems.put(newfieldname, curfielddescription); |
419 |
String[] currentFieldNames = xlstFieldNames.getItems(); |
420 |
short ipos = xlstFieldNames.getSelectedItemPos(); |
421 |
currentFieldNames[ipos] = newfieldname; |
422 |
Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), PropertyNames.STRING_ITEM_LIST, currentFieldNames); |
423 |
Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), PropertyNames.SELECTED_ITEMS, new short[] |
424 |
{ |
425 |
ipos |
426 |
}); |
427 |
} |
428 |
} |
429 |
} |
429 |
} |