use of com.codename1.designer.ImageMultiEditor in project CodenameOne by codenameone.
the class EditableResources method getResourceEditor.
public JComponent getResourceEditor(String name, ResourceEditorView view) {
byte magic = getResourceType(name);
switch(magic) {
case MAGIC_IMAGE:
case MAGIC_IMAGE_LEGACY:
Image i = getImage(name);
if (getResourceObject(name) instanceof MultiImage) {
ImageMultiEditor tl = new ImageMultiEditor(this, name, view);
tl.setImage((MultiImage) getResourceObject(name));
return tl;
}
if (i instanceof Timeline) {
TimelineEditor tl = new TimelineEditor(this, name, view);
tl.setImage((Timeline) i);
return tl;
}
if (i.isSVG()) {
MultiImageSVGEditor img = new MultiImageSVGEditor(this, name);
img.setImage(i);
return img;
}
ImageRGBEditor img = new ImageRGBEditor(this, name, view);
img.setImage(i);
return img;
case MAGIC_TIMELINE:
TimelineEditor tl = new TimelineEditor(this, name, view);
tl.setImage((Timeline) getImage(name));
return tl;
case MAGIC_THEME:
case MAGIC_THEME_LEGACY:
ThemeEditor theme = new ThemeEditor(this, name, getTheme(name), view);
return theme;
case MAGIC_FONT:
case MAGIC_FONT_LEGACY:
case MAGIC_INDEXED_FONT_LEGACY:
FontEditor fonts = new FontEditor(this, getFont(name), name);
return fonts;
case MAGIC_DATA:
DataEditor data = new DataEditor(this, name);
return data;
case MAGIC_UI:
UserInterfaceEditor uie = new UserInterfaceEditor(name, this, view.getProjectGeneratorSettings(), view);
return uie;
case MAGIC_L10N:
// we are cheating this isn't a theme but it should work since
// this is a hashtable that will include the nested locales
L10nEditor l10n = new L10nEditor(this, name);
return l10n;
default:
throw new IllegalArgumentException("Unrecognized magic number: " + Integer.toHexString(magic & 0xff));
}
}
use of com.codename1.designer.ImageMultiEditor in project CodenameOne by codenameone.
the class AddResourceDialog method addResource.
public String addResource(EditableResources res, ResourceEditorView view) {
// "Image", "Animation", "Font", "Theme", "Data", "Localization (L10N)"
String newName = name.getText();
for (String r : res.getResourceNames()) {
if (r.equalsIgnoreCase(newName)) {
JOptionPane.showMessageDialog(this, "A resource called: " + newName + " already exists\nYou must delete the resource first.", "Add Resource", JOptionPane.ERROR_MESSAGE);
return null;
}
}
switch(type.getSelectedIndex()) {
case // image
IMAGE:
ImageRGBEditor imageEditor = new ImageRGBEditor(res, name.getText(), view);
imageEditor.selectFile();
view.setSelectedResource(name.getText());
break;
case MULTI_IMAGE:
ImageMultiEditor multiImageEditor = new ImageMultiEditor(res, name.getText(), view);
view.setSelectedResource(name.getText());
break;
case TIMELINE:
new TimelineEditor(res, name.getText(), view);
view.setSelectedResource(name.getText());
break;
case // animation
ANIMATION:
TimelineEditor.selectFile(view, res, name.getText());
/*ImageEditor animationEditor = new ImageEditor(res, name.getText());
animationEditor.setAnimation(true);
animationEditor.selectFile(view);*/
break;
case // font
FONT:
new FontEditor(res, new EditorFont(com.codename1.ui.Font.createSystemFont(com.codename1.ui.Font.FACE_SYSTEM, com.codename1.ui.Font.STYLE_PLAIN, com.codename1.ui.Font.SIZE_MEDIUM), null, "Arial-plain-12", true, RenderingHints.VALUE_TEXT_ANTIALIAS_ON, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,;:!@/\\*()[]{}|#$%^&<>?'\"+- "), name.getText()).createFont();
view.setSelectedResource(name.getText());
break;
case // theme
THEME:
res.setTheme(name.getText(), new Hashtable());
view.setSelectedResource(name.getText());
// ResourceEditorView.expandAndSelect(tree, name.getText());
break;
case // data
DATA:
DataEditor dataEditor = new DataEditor(res, name.getText());
dataEditor.selectDataFile(view);
view.setSelectedResource(name.getText());
break;
case // localization
LOCALIZATION:
Hashtable h = new Hashtable();
Hashtable local = new Hashtable();
local.put("cancel", "Cancel");
local.put("ok", "OK");
local.put("menu", "Menu");
local.put("select", "Select");
local.put("edit", "Edit");
h.put("en", local);
res.setL10N(name.getText(), h);
view.setSelectedResource(name.getText());
// ResourceEditorView.expandAndSelect(tree, name.getText());
break;
case UI:
UserInterfaceEditor uiEditor = new UserInterfaceEditor(name.getText(), res, view.getProjectGeneratorSettings(), view);
view.setSelectedResource(name.getText());
break;
}
return name.getText();
}
Aggregations