File Selection from List in a Wizard page - eclipse

I have a Wizard page which gets a list of IFile. I want to show the user the list and select one file from the list. Then the Wizard returns the selected file.
Is there a standard file chooser that I can use instead of building from scratch in the createControl() of the WizardPage? (Maybe something like table view list with scrollbar to show the list.)

There is FilteredResourcesSelectionDialog that is a popup displaying any resource wanted, eventually with pre-loaded regexp, allowing to search for file, and you give him a root directory :
You call getResult() to retrieve selection as Object[].
If you want to do just a wizard that does that, then I would do it this way.
If it's a list include in a wizard that does other things, then just list all the files and create a org.eclipse.swt.widgets.List

Though there is no ready-to-use FileViewer or the like, you can use a TableViewer with a WorkbenchLabelProvider to show the list of files.
IFile[] files = ...
TableViewer fileViewer = new TableViewer( parent );
fileViewer.setInput( files );
fileViewer.setContentProvider( ArrayContentProvider.getInstance() );
fileViewer.setLabelProvider( new WorkbenchLabelProvider() );
This will create a single-selection table (viewer) that displays the files from the files array.
If multi-selection or further styles apply, use new TableViewer( parent, SWT.MULTI | ... ) to create the viewer.
If the list of files need to be sorted by name or type, you can use the ResourceComparator from the org.eclipse.ui.ide plug-in.
fileViewer.setComparator( new ResourceComparator( ResourceComparator.NAME ) );
If you don't want the extra plug-in dependency or need to sort by another criteria, it may still be used as a template.

Related

Vala Gtk Folder selection

I'm creating a simple GTK+ based application in Vala, which should be able to select a folder and then list the files inside it.
I've been able to select a single file using the Gtk.FileChooserDialog but I haven't found how to select a folder instead of a file.
Is there any way to tell the Gtk.FileChooserDialog that folders can be selected or is there any other widget to select folders?
Set the action property.
filechooser.action = FileChooserAction.SELECT_FOLDER;

Cannot add a third content field

I'm kinda new to typo, so maybe I am just missing something.
I'm trying to add a third content field to Typo3 4.5.
What I've done so far.
Edit my template and added a new block
Added the block via TemplatVoila > Update Mapping > Modify DS / TO with Element Preset "Page-Content Elements [Pos.: 0]
Mapped it to the new block in the template
But I am missing something as the new field isn't showing up in the Page edit screen.
EDIT: I've found the Block in the "Edit page properties" but how to show it on standard edit screen?
Any added content area will appear automatically in your TV-View-module. So if you dont see it in there, then
you may have duplicate fields names
wrong column positions
or the existing template is using a »beLayout«-section, which shows only the first two content areas (see example in reference http://docs.typo3.org/typo3cms/extensions/templavoila/ExtTemplavoila/StaticDataStructures/ExampleForBelayout/Index.html)
The TemplaVoila template is split into TS (TemplaVoilà Template Object) and DS (TemplaVoilà Data Structure) records, may you paste the content of the field „Data Structure XML“ of the DS record here? In there are all necessary information.
The two template files should be located in your general storage folder, your TypoScript root file should be there as well.

bugzilla: how to create custom field in advanced search to search custom field created through admin

I know that Bugzilla 3.0 and up supports the creation of custom fields for your bugs and that this can be done through admin.
My question was, is there any way that I would be able to create a custom field in the advanced search that would be able to search for the bugs that had the values from that custom field.
I know the current bugzilla supported solution is to use the boolean search under custom search which is on the advanced search page, but I would like to create my own custom field.
The current modifications I have done so far have been through the form.tmpl file under the custom folder which is a copy of the default folder. I have managed to play around with the default fields, but no luck in creating a custom field.
Source: http://www.bugzilla.org/docs/2.18/html/cust-templates.html
I found another source: http://mozilla.6506.n7.nabble.com/Adding-Custom-Field-drop-downs-to-Advanced-Search-Page-td80291.html
That somewhat directed me towards understanding how to solve the issue. As of now, it appears I need to go to the search.pm file under bugzilla folder which is responsible for the queries that generate the reports for the searches. This is described in the file itself, and the https://wiki.mozilla.org/Bugzilla:Search.pm source.
yes, you can manage custom bugzilla fields through Search.pm file, which is inside the Bugzilla folder.
for that, you need to push the custom select fields into the legal fields array and loop through that,
my #legal_fields = (<enter whatever legal fields, you have with the comma seperator>);
push(#legal_fields, map { $_->name } #select_fields);
foreach my $field ($params->param()) {
if (lsearch(\#legal_fields, $field) != -1) {
push(#specialchart, [$field, "anyexact",
join(',', $params->param($field))]);
}
}
select_fields array should contains your custom fields. and legal_fields contains your legal fields.

Zend Framework Dynamically added fields of a form and populate

I have been attempting to create a form where a user can simply press a button and the form will add a new field for the user to use. I have 2 of these dynamically added field types.
Firstly a field where a user can upload files, by pressing the add button another field is pasted underneath the current field and is ready for use.
I have followed an old guide on how to get this done with a bit of ajax and jQuery.
This guide to be exact: http://www.jeremykendall.net/2009/01/19/dynamically-adding-elements-to-zend-form/
As you can see it's from 2009 and a bit outdated yet it still works under the current Zend Framework version 1.11.11
The problem however arises now that i want an edit / update version of the form. I need to populate it's fields but first of all i need to create enough fields for the data to be stored in. So when there's 3 files that have been uploaded it should create 2 additional fields and place the 3 file names in these fields ready to be edited and updated. Simply using $form->populate($stuff) is not going to work
I just have no idea how to accomplish this and the tutorial on dynamically added fields only goes as far as the addAction and not how to create the editAction under these conditions.
Is there any tutorial out there on how to create and manage forms such as these? I'm sure i am not the only one who's had the idea to builds these kind of forms?
I can add my code if there's a request for it but it's the same as the example from the guide, just a different set of elements in the form.
Adding a small example of it's use.
A user adds an item with 3 files, these files are uploaded along with a filename so in the database it appears like this : File_Id : '1' , File_Name : 'SomeFile' , File_location : 'somewhere/on/my/pc/SomeFile.txt'.
Now the user realizes he forgot a file or wants to delete a file from that list, he goes to the edit page and here i want the form to display the previously added filenames. So if there's 3 files it shows 3 and when there's 2 it shows 2 etc. How do i build a form to dynamically add fields based on the number of uploaded files and then populate them?
Any advice on how to handle this is well appreciated :)
You can make use of the semi-magic setXxx() methods of the form.
Inside the form:
public function setFiles($files) {
foreach ($files as $file) {
$this->addElement(/* add a file element */);
//do other stuff, like decorators to show the file name, etc.
}
}
In your controller:
$files = $model->getFiles();
$form = new Form_EditFiles(array('files' => $files));
By passing an array with key files you will make the form try to call the method named setFiles(), which you have conveniently provided above.
This should push you in the right direction, or so I hope at least.
If I understand you correctly you want to populate file upload fields, which is not possible because of security reasons.
Edit:
You can add Elements inside of the Controller via $form->addElement() (basicly just like the $this->addElement() statements in the Tutorial)

How to add content control in a Word 2007 document using OpenXML

I want to create a word 2007 document without using object model. So I would prefer to create it using open xml format. So far I have been able to create the document. Now I want to add a content control in it and map it to xml. Can anybody guide me regarding the same???
Anoop,
You said that you are able to creat the document using OpenXmlSdk. With that assumption, you can use the following code to create the content control to add to the Wordprocessing.Body element of your Document.
//praragraph to be added to the rich text content control
Run run = new Run(new Text("Insert any text Here") { Space = StaticTextConstants.Preserve });
Paragraph paragraph = new Paragraph(run);
SdtProperties sdtPr = new SdtProperties(
new Alias { Val = "MyContentCotrol" },
new Tag { Val = "_myContentControl" });
SdtContentBlock sdtCBlock = new SdtContentBlock(paragraph);
SdtBlock sdtBlock = new SdtBlock(sdtPr, sdtCBlock);
//add this content control to the body of the word document
WordprocessingDocument wDoc = WordprocessingDocument.Open(path, true); //path is where your word 2007 file is
Body mBody = wDoc.MainDocumentPart.Document.Body;
mBody.AppendChild(sdtBlock);
wDoc.MainDocumentPart.Document.Save();
wDoc.Dispose();
I hope this answers a part of your question. I did not understand what you ment by "Map it to XML". Did you mean to say you want to create CustomXmlBlock and add the ContentControl to it?
Have a look for the Word Content Control Toolkit on www.codeplex.com.
Here is a very brief explanation on how to do what you are attempting.
You need to have access to the developer tab on the Word ribbon. To get this working click on the Office (Round thingy) in the top left hand corner and Select Word Options at the bottom of the menu. On the first options page there is a checkbox to show the developer toolbar.
Use the developer toolbar to add the Content controls you want on the page. Click the properties button in the Content controls section of the developer bar and set the name and tag properties (I stick to naming the name and tag fields with the same name).
Save and close the word document.
Open the Content control toolkit and then open your document with the toolkit. Use the left hand pain to create some custom xml to link to your controls.
Now use the bind view to drag and drop the mappings between your custom xml and the custom controls that are displayed in the right panel of the toolkit.
You can use the openxml sdk 1.0 or 2.0 (still in ctp) to open your word document in code and access the custom xml file that is contained as part of the word document.
If you want to have a look at how your word document looks as xml. Make a copy of your word document and then rename it to say "a.zip". Double click on the zip file and then navigate the folder structure. The main content of the word document is held under the word folder in a file called "document.xml". The custom xml part of the document is held under the customXml folder and is generally found in the file named "item1.xml".
I hope this brief explanation get you up and running.