I am working on a eclipse rcp application where I am using TableViewer component on a wizard page. I was able to add editing support to the table columns and was able to save the data on the viewer object. Does this edit get saved to actual data? if yes how can I get this updated data within my application to do further processing?
Assuming you are using org.eclipse.jface.viewers.EditingSupport to provide cell editors for the table.
The EditingSupport.setValue method is responsible for setting the new value in the original object provided by the content provider.
To validate values you will either have to write your own CellEditor or use a class derived from one of the existing call editors such as TextCellEditor and overriding appropriate methods.
Related
I'm generating a report using itext and creating bookmarks in the report. I would like the PDF to open with the bookmark section expanded. I can modify the properties of the document AFTER generation so that this occurs, but the PDF is generated by a batch process, so I want to add this into the generation.
I've tried using addViewerPreference(PdfName, PdfObject) but cannot seem to get this setting to work. I am able to use it to set other initial properties, but not this one.
I'm guessing that either that property isn't supported at all, or is not supported in the version of itext I'm using. I'm still using 2.1.7.
Rookie question that I'm not having much luck with. In my e4 RCP application, I have a couple of instances where I create an object in a wizard that should then appear in one of my views.
The desired behavior is similar to how the eclipse Package Explorer View updates after a new project is created.
I was thinking I could just grab the view from the partService and run my own update method:
MPart ingredientsView = partService.showPart("com.personal.recipes.part.ingredientsview", PartState.ACTIVATE);
IngredientsView iv = (IngredientsView) ingredientsView.getObject();
iv.updateView();
While this works in other places, when called from a wizard 'partService' is null and the app NPE's out.
So what is the proscribed method of forcing e4 views to update after modifying their contents?
EDIT:
I tried to use the ContextInjectionFactory like #greg-449 showed in his answer, but I'm uncertain where to place it in my code, or how to define the context. I'm launching the wizard from a toolbar button, and placed the following code in my handler:
#Execute
public void execute(Shell shell) {
IEclipseContext context = EclipseContextFactory.create();
IWizard ingredientWizard = ContextInjectionFactory.make(IngredientWizard.class, context);
WizardDialog wizardDialog = new WizardDialog(shell, ingredientWizard);
wizardDialog.open();
}
However, when I tried to get the part service with #Inject EPartService partService; I got an InjectionException saying no error was found.
Once injection is available, using the EventBroker looks like the way to go.
enter code hereThe best way to update a view is to use a model for the content of the view. Your wizard seems to allow editing or creating ingredients. When you perform the finish of your wizard you are probably modifying some ingredient data. The ingredient model should be informed of these changes. If the view uses a content provider that observes this model is will update automatically when the model sees the update (this is the observer pattern).
How this works depends on the nature of your data. You could use the PropertyChange-Support in Java.
To do so let the content provider implement the org.eclipse.jface.util.IPropertyChangeListener interface and fire property change events when the data is changed.
UPDATE
My ContentProvider implements the property change interface. Whenever a property change event is received the viewer is refreshed(asynchronously). All my persistence operations are handled by data managers similar to Fowler's the table data gateway pattern but sometimes for more than one table. The data manager fires the property change event. This way the UI (wizard) does not need to know about persistence
Injection is only done on objects that the application model knows about. So it is not done on Wizards or Dialogs unless you do it 'manually' using ContextInjectionFactory when you create the dialog:
IWizard wizard = ContextInjectionFactory.make(YourWizardClass.class, eclipseContext);
WizardDialog dialog = new WizardDialog(shell, wizard);
This will do injection on your wizard class giving you access to the EPartService.
You could also use the 'event broker' (IEventBroker) to broadcast an event to anything that is interested rather than finding your specific view.
I created a TableViewer in JFace.
Later on I iterate through the UI-Tree and have only access to the SWT-API-Level objects.
In the case of the TableViewer it is the Table.
From the table, I need then a link to the TableViewer.
Does any one know how to do this?
#Martti is right. Not possible directly via the viewer API.
For cases, where I need to get to the viewer from the control, I usually add viewer.getControl().setData(Viewer.class.getName(), viewer); - I can then later retrieve the viewer again with viewer.getControl().getData(Viewer.class.getName();
I prefer this method to keeping a separate Map<Control, Viewer>, as this is automatically cleaned up :-)
Not possible. Keeping a reference to created viewer is the only way.
In my application,I am working on WPF with MVVM design pattern doing validations through Enterprise Library using configuration file.
I want to validate my grid cell values through enterprise library configuration file.In my view model I have an objservalble collection property that is bound to the datagrid in a view.
Then,I want to validate one of my cell value for range validation using enterprise library..But I am not finding any proper way to do the same.I don't want to use any custom validator rather want to achieve with the enterprise library configuration file only.
Actually while adding a validation to datagrid column we are binding like:-
<xa:ValidatorRule RulesetName="NameOfRuleset" SourceType="{x:Type vm:ViewModelType}" SourcePropertyName="NameOfProperty" ValidationSpecificationSource="Configuration" ValidatesOnTargetUpdated="True" />
But as in this case my view model will not have a property specifically for this field rather it has collection,so i am stucked on how to do the same,
Can anyone please guide me how to achieve the same.Please let me know if my explanation is not clear enough.
Found a solution for the same.
Created a one more class for my collection & in configuration file as well as in view I am refering to that class type only instead of refering to my viewmodel.
Reason why I created new class is I am using Entity framework & i cannot refer to DAL layer in my UI but I can refer to my own type in view.
In this way it solved my problem of adding validation rules to the datagrid that is binded to the collection.
Incase anybody needs sample code,let me know I can provide the same.
I am facing a strange issue!!
I have a set of property page with same storage file.
The scenario is as follow..
For the first time opening the properties by right clicking on the project, list of property pages are viewed. I click on the first property page and make changes then apply the changes to the file.
Now I select the second page, it shows the changes that were applied from the first page.
But now without closing the properties i go back to first page and make changes then apply the changes.
Then again I go to second page it wont show the updated data. The changes that were applied are not viewed until I close the properties and reopen then by right clicking on the project.
My question is
"Is there any way to reflect changes on the pages without closing the properties??"
I appreciate your valuable time you will give for reading and replying..
Plz help
Your problem seems to just absent of reliable model which can notify problem.
If the properties are related IProject.
You should use ScopedPreferenceStore as model.
IScopeContenxt scope = new ProjectScope(myProject);
IPreferenceStore store =
new ScopedPreferenceStore(scope, "myProperties(qualifier)");
IPreferenceStore can manipulate primitive data, default value. And it support property change event. You can create multiple instances of IPreferenceStore, If they have same scope and qualifier then automatically synchronized. So individual page can retrive input model without coupling.