I'm using gwtupload lib for uploading file(s) in my GWT project. https://code.google.com/p/gwtupload/wiki/GwtUpload_GettingStarted
Case: I've 3 - 4 MultiUploader on same page. Its uploading fine. But when I try to upload same file in other component its not allowing. I figured out that if we click on remove button maintained by gwtupload. Its allow to upload same file on other component. So how to fire remove button click. Check image attached below.
This behavior is in this way by design, gwtupload prevents uploading the same file-name if it was successful previously in any instance of uploaders.
You can disable the default feature just calling the avoidRepeatFiles method though.
MultiUploader uploader1 = new MultiUploader();
uploader1.avoidRepeatFiles(false);
After digging down source code of gwtupload. I found the solution. If you want to have multiple SingleUploader or MultiUploader on same page. You need to change below lines and need to create .jar file of gwtupload.
private static HashSet<String> fileDone = new HashSet<String>();
private static HashSet<String> fileUploading = new HashSet<String>();
private static List<String> fileQueue = new ArrayList<String>();
to (Remove static)
private HashSet<String> fileDone = new HashSet<String>();
private HashSet<String> fileUploading = new HashSet<String>();
private List<String> fileQueue = new ArrayList<String>();
in File Uploader.java located in package gwtupload.client
Related
NOTE: I'm casting a wider net than Unity Answers, my original question can be found here.
I've created a ProTools CueSheet importer. It uses OnPostprocessAllAssets() to detect a files in the project that have a .cuesheet extension. It then runs those cuesheet files through my parser. This generates a ScriptableObject which is then turned into an asset via Database.CreateAsset().
The problem is, this leaves me with two files, the original cuesheet and the newly generated asset. Is there any way I can generate the asset in such as way that the original cuesheet acts as the asset, the same way textures or FBX files do?
public class CueSheetPostProcessor : AssetPostprocessor {
static string extension = ".cuesheet";
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) {
foreach (string assetPath in importedAssets) {
if (assetPath.EndsWith(extension, StringComparison.OrdinalIgnoreCase)) {
string newPath = assetPath + ".asset";
Session session = CueImporter.Load(assetPath);
AssetDatabase.CreateAsset(session, newPath);
AssetDatabase.SaveAssets();
}
}
}
}
I would create a PropertyDrawer for the Serializable class CueSheet such that it accepts the .cueSheet TextAsset or path to the .cueSheet file and create an instance of the class CueSheet and assign it or modify it.
Rather than create a new asset, have you tried using AssetDatabase.AddObjectToAsset instead? An file in Assets can "hold" multiple assets and multiple asset types. When importing a .fbx, the output in the project inspector is several things: a GameObject tree (ie, a prefab), some models, maybe a rig, and so on. All these are "contained" in the processed .fbx
Is it possible in eclipse to add a tag field
private static final String TAG = "MyClass";
automatically to each newly create class. Not a big deal to type it but having this automatically added would definitely increase my adding log info discipline ...
Thanks
Yes, it is possible
Go to Window - Preferrences
So newly created files will have this line.
But it will be more useful if you make
then in code just print mytag and press Ctrl + Space
Some improvement. You can use "enclosing_type" variable in your tag:
private static final String TAG = "${enclosing_type}";
I'm trying to figure out how to import an Eclipse project from an archive file (a .zip) programmatically - I want to do the same thing the import wizard does, but automatically (re-importing the same project regularly using the wizard is starting to feel really long-winded). I've found some related questions (e.g. Programmatically importing an existing project into Eclipse), but I can't figure out how to get the same sort of thing working for the .zip import.
My current thinking is as follows: if I can get a project description from the .zip somehow, then I can programmatically create the project (as per the referenced question). From there, I'm hoping I can:
Create a ZipLeveledStructureProvider (http://javasourcecode.org/html/open-source/eclipse/eclipse-3.5.2/org/eclipse/ui/internal/wizards/datatransfer/ZipLeveledStructureProvider.java.html) for the .zip file.
Run an ImportOperation (http://javasourcecode.org/html/open-source/eclipse/eclipse-3.5.2/org/eclipse/ui/wizards/datatransfer/ImportOperation.java.html) to import the contents of the .zip into the created project.
Does this make any sense? (If not, what should I be doing please?) If so, how should I be going about getting a project description from the .zip?
For what it's worth, this seems to work (pre-tidying):
IWorkspace workspace = this.project.getWorkspace();
IProjectDescription newProjectDescription = workspace.newProjectDescription(projectName);
IProject newProject = workspace.getRoot().getProject(projectName);
newProject.create(newProjectDescription, null);
newProject.open(null);
zipFile = new ZipFile(workspace.getRoot().getLocation() + "/" + projectName + ".zip");
IOverwriteQuery overwriteQuery = new IOverwriteQuery() {
public String queryOverwrite(String file) { return ALL; }
};
ZipLeveledStructureProvider provider = new ZipLeveledStructureProvider(zipFile);
List<Object> fileSystemObjects = new ArrayList<Object>();
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
fileSystemObjects.add((Object)entries.nextElement());
}
ImportOperation importOperation = new ImportOperation(newProject.getFullPath(), new ZipEntry(projectName), provider, overwriteQuery, fileSystemObjects);
importOperation.setCreateContainerStructure(false);
importOperation.run(new NullProgressMonitor());
Im using Wicket 1.5 and I need to build a component with a FileUploadField to load an image.
I need an Ajax behaviour to make a preview of image after selected it (without submiting the entire form).
Searching on Google, I found this Event that match when I select the file:
AjaxEventBehavior choose = new AjaxEventBehavior("onChange"){
private static final long serialVersionUID = 1L;
#Override
protected void onEvent(AjaxRequestTarget target) {
Request request = RequestCycle.get().getRequest();
}
};
What I need is the stream of image to put in a little panel that required:
byte[] imgBytes
And obviously I need the same stream to fill a PropertyModel for DB storing.
Thanks
You need to use either AjaxFormSubmitBehavior (will submit the entire form on the given event) or AjaxFormComponentUpdatingBehavior (will submit only the one form component. I'm not sure whether the latter works with file uploads, just give it a try. You can always use the former.
In the model of your FileUploadField you will find a (list of) FileUpload - look at the methods you get, there are input streams and other things available so you can do pretty much anything with the data.
I want to write an eclipse plugin to show the actual value of the message code. The values are to be loaded from the given resource bundle. Only classes of the resource bundle will be available. So I require to load the resource bundle class which is declared in the current file. These class files will be in the classes folder or in a jar file in the lib folder. Is there any way to load the classes dynamically from the eclipse plugin? Thanks in advance
An Example how to get a externalized string from a message.properties file
private static final String BUNDLE_NAME = "de.stackoverflow.package.messages"; //$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
RESOURCE_BUNDLE.getString(key);
Every plugin does have a bundle object where you can load the files of a plugin. The Bundle object should contain every information you want to use.
Have a look at the Bundle class. There is the following method:
public Class loadClass(String name) throws ClassNotFoundException;
To get the bundle from your plugin:
Activator.getDefault().getBundle()
Hope this help
Manu