use of com.codename1.rad.models.Property.Name in project CodenameOne by codenameone.
the class TimelineEditor method cloneCurrentTimeline.
// </editor-fold>//GEN-END:initComponents
private Timeline cloneCurrentTimeline() {
Timeline t = (Timeline) res.getImage(name);
AnimationObject[] arr = new AnimationObject[t.getAnimationCount()];
for (int iter = 0; iter < arr.length; iter++) {
arr[iter] = t.getAnimation(iter);
}
Timeline nt = Timeline.createTimeline(getValue(duration), arr, new com.codename1.ui.geom.Dimension(getValue(width), getValue(height)));
nt.setPause(t.isPause());
nt.setTime(t.getTime());
return nt;
}
use of com.codename1.rad.models.Property.Name in project CodenameOne by codenameone.
the class TimelineEditor method removeAnimationObjectActionPerformed.
// GEN-LAST:event_addAnimationObjectActionPerformed
private void removeAnimationObjectActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_removeAnimationObjectActionPerformed
Timeline t = (Timeline) res.getImage(name);
AnimationObject[] animations = new AnimationObject[t.getAnimationCount() - 1];
int offset = 0;
for (int iter = 0; iter < t.getAnimationCount(); iter++) {
if (iter != animationObjectList.getSelectedRow()) {
animations[offset] = t.getAnimation(iter);
offset++;
}
}
((AnimationObjectTableModel) animationObjectList.getModel()).remove(animationObjectList.getSelectedRow());
Timeline nt = Timeline.createTimeline(getValue(duration), animations, new com.codename1.ui.geom.Dimension(getValue(width), getValue(height)));
nt.setPause(t.isPause());
setImage(nt);
animationObjectList.clearSelection();
duplicateObject.setEnabled(false);
moveDown.setEnabled(false);
moveUp.setEnabled(false);
removeAnimationObject.setEnabled(false);
}
use of com.codename1.rad.models.Property.Name in project CodenameOne by codenameone.
the class UserInterfaceEditor method applyThemePreview.
private void applyThemePreview(String name) {
if (name.indexOf('@') > -1) {
FileInputStream f = null;
try {
String[] t = name.split("@");
f = new FileInputStream(t[0]);
Resources r = Resources.open(f);
if (r.getTheme(t[1]) != null) {
Accessor.setTheme(r.getTheme(t[1]));
} else {
Accessor.setTheme(r.getTheme(r.getThemeResourceNames()[0]));
}
} catch (IOException ex) {
ex.printStackTrace();
} finally {
try {
f.close();
} catch (Exception ex) {
}
}
} else {
Accessor.setTheme(res.getTheme(name));
}
}
use of com.codename1.rad.models.Property.Name in project CodenameOne by codenameone.
the class UserInterfaceEditor method appendComponentXMLBody.
private static void appendComponentXMLBody(com.codename1.ui.Container containerInstance, com.codename1.ui.Component cmp, StringBuilder build, EditableResources res, String indent) {
if (isPropertyModified(cmp, PROPERTY_LAYOUT_CONSTRAINT) || (cmp.getParent() != null && cmp.getParent().getLayout() instanceof com.codename1.ui.layouts.BorderLayout)) {
if (cmp.getParent() != null && cmp != containerInstance && cmp.getClientProperty("%base_form%") == null) {
com.codename1.ui.layouts.Layout l = cmp.getParent().getLayout();
if (l instanceof com.codename1.ui.layouts.BorderLayout) {
build.append(indent);
build.append("<layoutConstraint value=\"");
build.append((String) l.getComponentConstraint(cmp));
build.append("\" />\n");
} else {
if (l instanceof com.codename1.ui.table.TableLayout) {
build.append(indent);
com.codename1.ui.table.TableLayout.Constraint con = (com.codename1.ui.table.TableLayout.Constraint) l.getComponentConstraint(cmp);
build.append("<layoutConstraint row=\"");
build.append(getInt("row", con.getClass(), con));
build.append("\" column=\"");
build.append(getInt("column", con.getClass(), con));
build.append("\" height=\"");
build.append(getInt("height", con.getClass(), con));
build.append("\" width=\"");
build.append(getInt("width", con.getClass(), con));
build.append("\" align=\"");
build.append(getInt("align", con.getClass(), con));
build.append("\" spanHorizontal=\"");
build.append(getInt("spanHorizontal", con.getClass(), con));
build.append("\" valign=\"");
build.append(getInt("valign", con.getClass(), con));
build.append("\" spanVertical=\"");
build.append(getInt("spanVertical", con.getClass(), con));
build.append("\" />\n");
}
}
}
}
// don't persist children of subclasses like Table etc.
if (cmp.getClass() == com.codename1.ui.Container.class || cmp instanceof com.codename1.ui.Form || cmp instanceof com.codename1.ui.ComponentGroup) {
com.codename1.ui.Container cnt = (com.codename1.ui.Container) cmp;
if (cnt instanceof com.codename1.ui.Form) {
cnt = ((com.codename1.ui.Form) cnt).getContentPane();
}
for (int iter = 0; iter < cnt.getComponentCount(); iter++) {
persistToXML(containerInstance, cnt.getComponentAt(iter), build, res, indent);
}
}
if (cmp instanceof com.codename1.ui.List && !(cmp instanceof com.codename1.components.RSSReader)) {
com.codename1.ui.List lst = (com.codename1.ui.List) cmp;
for (int iter = 0; iter < lst.getModel().getSize(); iter++) {
Object o = lst.getModel().getItemAt(iter);
appendMapOrString(o, build, indent, res);
}
}
if (isPropertyModified(cmp, PROPERTY_CUSTOM)) {
for (String propName : cmp.getPropertyNames()) {
if (isCustomPropertyModified(cmp, propName) && !propName.startsWith("$")) {
build.append(indent);
build.append("<custom name=\"");
build.append(propName);
Class type = getPropertyCustomType(cmp, propName);
Object value = cmp.getPropertyValue(propName);
if (value == null) {
build.append("\" />\n");
continue;
}
if (type.isArray()) {
// 2d array
if (type.getComponentType().isArray()) {
build.append("\" type=\"");
build.append(type.getComponentType().getComponentType().getName());
build.append("\" array=\"true\" dimensions=\"2");
} else {
build.append("\" type=\"");
build.append(type.getComponentType().getName());
build.append("\" array=\"true\" dimensions=\"1");
}
} else {
build.append("\" type=\"");
build.append(type.getName());
}
build.append("\" ");
if (type == String.class) {
build.append("value=\"");
build.append(xmlize((String) value));
build.append("\" />\n");
continue;
}
if (type == String[].class) {
build.append(">\n");
String[] result = (String[]) value;
for (int i = 0; i < result.length; i++) {
build.append(indent);
build.append(" ");
build.append("<str>");
build.append(xmlize(result[i]));
build.append("</str>\n");
}
build.append(indent);
build.append("</custom>\n");
continue;
}
if (type == String[][].class) {
String[][] result = (String[][]) value;
build.append(">\n");
for (int i = 0; i < result.length; i++) {
build.append(indent);
build.append(" ");
build.append("<arr>");
for (int j = 0; j < result[i].length; j++) {
build.append(indent);
build.append(" ");
build.append("<str>");
build.append(xmlize(result[i][j]));
build.append("</str>\n");
}
build.append(indent);
build.append(" ");
build.append("</arr>\n");
}
build.append(indent);
build.append("</custom>\n");
continue;
}
if (type == Integer.class) {
build.append("value=\"");
build.append(((Number) value).intValue());
build.append("\" />\n");
continue;
}
if (type == Long.class) {
build.append("value=\"");
build.append(((Number) value).longValue());
build.append("\" />\n");
continue;
}
if (type == Double.class) {
build.append("value=\"");
build.append(((Number) value).doubleValue());
build.append("\" />\n");
continue;
}
if (type == Date.class) {
build.append("value=\"");
build.append(((Date) value).getTime());
build.append("\" />\n");
continue;
}
if (type == Float.class) {
build.append("value=\"");
build.append(((Number) value).floatValue());
build.append("\" />\n");
continue;
}
if (type == Byte.class) {
build.append("value=\"");
build.append(((Number) value).byteValue());
build.append("\" />\n");
continue;
}
if (type == Boolean.class) {
build.append("value=\"");
build.append(((Boolean) value).booleanValue());
build.append("\" />\n");
continue;
}
if (type == com.codename1.ui.Image[].class) {
com.codename1.ui.Image[] result = (com.codename1.ui.Image[]) value;
build.append(">\n");
for (int i = 0; i < result.length; i++) {
build.append(indent);
build.append(" ");
if (result[i] == null) {
build.append("<str/>\n");
} else {
String id = res.findId(result[i]);
if (id == null) {
build.append("<str/>\n");
} else {
build.append("<str>");
build.append(xmlize(id));
build.append("</str>\n");
}
}
}
build.append(indent);
build.append("</custom>\n");
continue;
}
if (type == com.codename1.ui.Image.class) {
com.codename1.ui.Image result = (com.codename1.ui.Image) value;
String id = res.findId(result);
if (id != null) {
build.append("value=\"");
build.append(xmlize(id));
}
build.append("\" />\n");
continue;
}
if (type == com.codename1.ui.Container.class) {
build.append("value=\"");
build.append(xmlize(((com.codename1.ui.Container) value).getName()));
build.append("\" />\n");
continue;
}
if (type == com.codename1.ui.list.CellRenderer.class) {
com.codename1.ui.list.GenericListCellRenderer g = (com.codename1.ui.list.GenericListCellRenderer) value;
if (g.getSelectedEven() == null) {
build.append(" selectedRenderer=\"");
build.append(xmlize(g.getSelected().getName()));
build.append("\" unselectedRenderer=\"");
build.append(xmlize(g.getUnselected().getName()));
build.append("\" ");
} else {
build.append(" selectedRenderer=\"");
build.append(xmlize(g.getSelected().getName()));
build.append("\" unselectedRenderer=\"");
build.append(xmlize(g.getUnselected().getName()));
build.append(" selectedRendererEven=\"");
build.append(xmlize(g.getSelectedEven().getName()));
build.append("\" unselectedRendererEven=\"");
build.append(xmlize(g.getUnselectedEven().getName()));
build.append("\" ");
}
build.append("\" />\n");
continue;
}
if (type == Object[].class) {
build.append(">\n");
Object[] arr = (Object[]) value;
for (int iter = 0; iter < arr.length; iter++) {
Object o = arr[iter];
appendMapOrString(o, build, indent, res);
}
build.append(indent);
build.append("</custom>\n");
continue;
}
// none of the above then its a char
build.append("value=\"");
build.append(xmlize("" + ((Character) value).charValue()));
build.append("\" />\n");
}
}
}
}
use of com.codename1.rad.models.Property.Name in project CodenameOne by codenameone.
the class EditableResources method remove.
public void remove(final String name) {
if (overrideResource != null) {
overrideResource.remove(name);
return;
}
final Object removedObject = getResourceObject(name);
final byte type = getResourceType(name);
pushUndoable(new UndoableEdit() {
@Override
protected String performAction() {
setResource(name, type, null);
return name;
}
@Override
protected String performUndo() {
setResource(name, type, removedObject);
return name;
}
});
}
Aggregations