How to distinguish wizards in Eclipse RCP? - eclipse

We have an Eclipse IDE application on 3.x that uses various newWizards to allow the user to create different files. Although these files differ slightly contentwise, the structure of the wizards is quite similar.
Thus, a sound object-oriented approach would be to instantiate different wizards from the same class and initialize them with different data.
Problem:
To decide what wizard needs which data we need a way to distinguish the different already instantiated wizards (e.g during the call to the init method of the wizard).
Is there any way to do so? It would e.g. help if somebody knows a way to get the wizard's id defined in the extension point from within the instantiated wizard.

If your wizard implements IExecutableExtension, it will be passed the configuration element that represents the extension for which it is created.
You can also use extension factories in that you specify a type that implements IExecutableExtensionFactory.
The interface allows you to control how the instances provided to extension-points (wizards in your case) are created.
Extension example:
<extension point="org.eclipse.ui.wizards">
<newWizard
name="..."
class="com.example.WizardFactory">
</newWizard>
Note that the extension factory may also implement IExecutableExtension to gain access to extension attributes before creating the extension's executable class.

Related

Flutter override a Class in a package

I am currently working on two Flutter apps that share about 90% of their functionality. Because of this, I have built most of the code as a library, and then have the two projects set up to import that library. I can then plug in two different CMS instances, and different Firebase services ... super-efficient.
The problem I have is that my library code has certain references that I would need to override in my projects to allow for bespoke menu items, theme settings etc.
A good example is a MenuItem enum that is used throughout my library code for navigation and routing etc. It builds the entire app structure off a list of these MenuItem types. I need to define a MenuItem enum for both of my projects, but the error I get is a conflict between the project and the library.
{MenuItem menuItem}
The argument type 'MenuItem (where MenuItem is defined in /Users/xx/Documents/dev/xx Creative/dev/AR_Trails_app/ar_trails_app/lib/utils/menu_items.dart)' can't be assigned to the parameter type 'MenuItem (where MenuItem is defined in /Users/xx/Documents/dev/xx Creative/dev/AR_Trails_Lib/weald_ar_trails/lib/utils/menu_items.dart)'.dartargument_type_not_assignable
menu_items.dart(7, 6): MenuItem is defined in /Users/xx/Documents/dev/xx Creative/dev/AR_Trails_app/ar_trails_app/lib/utils/menu_items.dart
menu_items.dart(8, 6): MenuItem is defined in /Users/xx/Documents/dev/xx Creative/dev/AR_Trails_Lib/weald_ar_trails/lib/utils/menu_items.dart
I know that there is an option to use dependency_overrides in Dart but this is for overriding the entire library I think: https://dart.dev/tools/pub/dependencies#dependency-overrides
How can I do this but for just one file? Or maybe two or three?
UPDATE:
To be clear on the use-case here: my file menu_items.dart is in the library package, and it is used throughout to build the navigation and drawer etc. But it is only used in the library. What I need to do is override that file in each project so that the reference the library uses is the project's local version and NOT the one that is being referenced in the library. I thought that if I used as a path reference to the file like ../../utils/menu_items, and mirrored that in my project, it might use the local project version. It doesn't.

Is it possible to use spring-data-rest-webmvc without an actual Repository?

The question may sound funny but I think this should be possible.
What I want is to use a repository that is purely custom but is exposed just like a Repository. This service would have methods to get, save, delete and list objects where the data could be from any arbitrary source.
Looking through the code, I think it should be possible since methods are accessed using CrudMethods and RepositoryInvoker. I belief this requires an implementation of RepositoryFactoryInformation that will be discovered by Repositories. I started experimenting a bit and it looks like a full-blown spring-data-noop module.
Am I on the right track or is there an easier way to accomplish this?
I've ended up writing spring-data-custom to create fully customized spring-data repositories, allowing custom code to be used with spring-data-rest etc.
Enable custom repositories (#EnableCustomRepositories)
Annotate eligible entities (#Custom)
Create a repository (extend CustomRepository<T, ID>)
Add custom behavior:
Let repository extend a new interface with the Custom suffix
Create an implementation of the new interface with the Impl prefix
Add one or more CRUD methods named findOne, save, findAll, delete (see DefaultCrudMethods)
Add query methods annotated with #Query
Export repository using spring-data-rest
(copied from README)
As #wwadge correctly mentioned, spring-data-keyvalue is an alternative. Repositories have to implement KeyValueAdapter, e.g. MapKeyValueAdapter.
The easier way is to use spring-data-keyvalue project which does what you are trying to do.

Using only part of a class from a different target

I just created a new target for the Lite version of my app. The Lite app only uses part of a base class that I have in the main app, ie it won't need to use an option that requires it to import 4 or 5 files.
My question is, from a design perspective, what is the best way to handle this so that my Lite version can only use the part of the class that it needs? Obviously, one solution is I just import those 4 unnecessary files into Lite build phase, and just use the whole class (even the parts it doesn't need). This seems inefficient though. I know I can do an ifndef to block those files from being imported if the Lite version is running, but how do I block out the code in the class from also not being picked up by the compiler?
Would a better way just be to have my Lite version create a subclass of the Base class that only uses the options it needs? But then I believe, would I still need to import those unnecessary files?
Just a bit confused about this, first time I've ever created another target that utilizes code from the main target. Any help appreciate thanks.
Put the common/lite functionality in a super class. Heavy functionality in the sub-class.
As another answer points out, you can handle this by putting the lite functionality in a subclass and the full functionality in a superclass.
Another option is to use a single class, and add the full functionality in an Objective-C category. Essentially, you can define methods in the category to supplement – or replace – methods in the base implementation.
Unlike a subclass, however, methods defined in a category can't invoke super to get the base class's functionality. super still refers to the base class's superclass, whether that's NSObject, UIDocument, or what have you – not the implementation without the category.
The advantage is that you only have one class name, so the code which instantiates your class (or classes) doesn't need to use something like #ifdef to switch classes and #includes depending on whether you're building the lite or full version.

Netbeans: using GUI Builder on regular Java class file

I'm using Netbeans. When I create a Java class, I sometimes want to change it to be a GUI component so that I can visually edit it using the GUI Builder.
What is the necessary step to transform a regular Java class to a GUI component so that Netbeans would recognize it and allow me to use GUI Builder ? (i.e. switch between Source and Design)
NetBeans' Gui builder, Matisse, works off a .form xml file located adjacent to the source file. Matisse creates and maintains the .form file and the code generator creates/updates methods in the java source to reflect changes to the form.
Unfortunately, there is no support in NetBeans for free-form GUI construction.
The closest I've seen is FormGenerator. It's a contributed NetBeans module that adds a right click action to .java files that will attempt to generate a .form file from the .java source. It's very limited, but it's better than nothing. It works best if you've followed the coding style employed by Matisse.
http://netbeans.org/projects/contrib/downloads/download/Readme.txt
http://netbeans.org/projects/contrib/downloads/download/FormGeneratorModule.zip
To add a class to the Palette, all that's needed is for your class to conform to the Java Beans model. That is, your class must:
be serializable
have a public, no-argument constructor.
All fields that have getter and setter methods that are named properly, i.e.:
int count
int getCount()
void setCount(int c)
should by default be recognized as a property.
For a finer control of what properties should and should not be exposed to the GUI Builder, you can associate your class with an implementation of the BeanInfo interface. See this Sun tutorial for more details.
However, NetBeans has several tools to help you in designing a custom bean. You can create new beans using the built-in templates available in the new file dialog, under the "JavaBeans Objects" folder.
This tutorial will guide you through creating an Image Bean.
What you could do is create one from scratch, design it as you wish, and then look at the generated code to understand how you can modify your existing class.
Try to use properties (Java bean!) for properties which should be changed from the ui designer and look here for more info.

Is there a tool to convert my GWT RemoteServiceServlet into the correct Service and ServiceAsync interfaces?

I'm working on a GWT project and I find it very tedious to have to add a function to my servlet, then copy and paste the function signature into my Service interface, then copy and paste it into my ServiceAsync interface and change the return parameter to be a callback. Is there a tool or a setting where I can just add public methods to my class and they can get copied into the other interfaces? Even if its not automatic it would be nice to be able to select specific methods and have them copied automatically.
I'm using eclipse and ideally it would update my interface each time I save implementation since thats when it checks my code and complains that my changes break the interface.
If you add the method to your *Service interface, then Eclipse can auto-generate the method ("Add unimplemented methods...") in your *ServiceImpl servlet, which you can then just fill in. Also, if you've got the Google Eclipse plugin installed, it will underline the new method in your *Service interface and complain that it's not in the *ServiceAsync. It might have a CTRL + 1 option to generate it in that interface as well.
You don't really need a tool. Just factor out the many RPC methods by just one method that takes a Request/Response. all you need to do is create subclasses of Request/Response and you don't need to think about adding new methods in the 2 interfaces.
You can use Google Guice on the server side to map the incomming request to a class handling the call... or you could use a visitor approach to forward the incoming request to the code handling the request (without resorting on a big instanceof construct).
Instantiations WindowBuilder GWT Designer does exactly what you are looking for.
The RemoteService Wizard will create all three files at the same time as well as keep them in sync as you make changes.
http://www.instantiations.com/windowbuilder/gwtdesigner/index.html
FWIW - I am only a user/purchaser of this product. I am not employed or in any other way related to Instantiations.