use of com.codename1.ui.util.UIBuilderOverride in project CodenameOne by codenameone.
the class ImageRGBEditor method findImageUseImpl.
private static void findImageUseImpl(com.codename1.ui.Image resourceValue, Vector users, EditableResources res, JLabel borderPreview) {
for (String themeName : res.getThemeResourceNames()) {
Hashtable theme = res.getTheme(themeName);
for (Object key : theme.keySet()) {
Object value = theme.get(key);
if (value instanceof com.codename1.ui.Image) {
if (value.equals(resourceValue)) {
addToUsers((String) key, users);
}
}
if (value instanceof Border) {
Border b = (Border) value;
// BORDER_TYPE_IMAGE
if (Accessor.getType(b) == Accessor.TYPE_IMAGE || Accessor.getType(b) == Accessor.TYPE_IMAGE_HORIZONTAL || Accessor.getType(b) == Accessor.TYPE_IMAGE_VERTICAL) {
com.codename1.ui.Image[] images = Accessor.getImages(b);
for (int i = 0; i < images.length; i++) {
if (images[i] == resourceValue) {
addToUsers((String) key, users);
if (borderPreview != null && borderPreview.getIcon() == null) {
int borderWidth = Math.max(100, b.getMinimumWidth());
int borderHeight = Math.max(100, b.getMinimumHeight());
com.codename1.ui.Image img = com.codename1.ui.Image.createImage(borderWidth, borderHeight);
com.codename1.ui.Label l = new com.codename1.ui.Label("Preview");
l.getStyle().setBorder(b);
l.setSize(new com.codename1.ui.geom.Dimension(borderWidth, borderHeight));
l.paintComponent(img.getGraphics());
CodenameOneImageIcon icon = new CodenameOneImageIcon(img, borderWidth, borderHeight);
borderPreview.setIcon(icon);
}
}
}
}
}
}
}
// check if a timeline is making use of said image and replace it
for (String image : res.getImageResourceNames()) {
com.codename1.ui.Image current = res.getImage(image);
if (current instanceof com.codename1.ui.animations.Timeline) {
com.codename1.ui.animations.Timeline time = (com.codename1.ui.animations.Timeline) current;
for (int iter = 0; iter < time.getAnimationCount(); iter++) {
com.codename1.ui.animations.AnimationObject o = time.getAnimation(iter);
if (AnimationAccessor.getImage(o) == resourceValue) {
addToUsers(image, users);
}
}
}
}
// check if a UI resource is making use of the image
UIBuilderOverride builder = new UIBuilderOverride();
for (String uiResource : res.getUIResourceNames()) {
com.codename1.ui.Container c = builder.createContainer(res, uiResource);
if (ResourceEditorView.findImageInContainer(c, resourceValue)) {
addToUsers(uiResource, users);
}
}
}
use of com.codename1.ui.util.UIBuilderOverride in project CodenameOne by codenameone.
the class L10nEditor method syncWithUIActionPerformed.
// GEN-LAST:event_editHTMLActionPerformed
private void syncWithUIActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_syncWithUIActionPerformed
Accessor.setResourceBundle(null);
final Map<String, String> allKeys = new HashMap<String, String>();
com.codename1.ui.plaf.UIManager original = com.codename1.ui.plaf.UIManager.getInstance();
Accessor.setUIManager(new com.codename1.ui.plaf.ProtectedUIManager() {
public String localize(String key, String defaultValue) {
if (key != null && key.length() > 0 && defaultValue != null && defaultValue.length() > 0) {
allKeys.put(key, defaultValue);
}
return super.localize(key, defaultValue);
}
});
UIBuilderOverride o = new UIBuilderOverride();
for (String resources : res.getUIResourceNames()) {
o.createContainer(res, resources);
}
Accessor.setUIManager(original);
for (String currentKey : allKeys.keySet()) {
if (!keys.contains(currentKey)) {
keys.add(currentKey);
for (Object locale : localeList) {
res.setLocaleProperty(localeName, (String) locale, currentKey, allKeys.get(currentKey));
}
}
}
initTable();
}
Aggregations