Dear friends I'm new of vaadin and I would want to use wizard add-on in my vaadin application.
Now my trouble is that I don't have a fix number of steps. I try to explain in a better way, I have the following optionGroup
Then when i choose fixed size I don't have a problem because I can do this
// instantiate the Wizard
Wizard wizard = new Wizard();
// add some steps that implement the WizardStep interface
wizard.addStep(new FirstStep());
wizard.addStep(new SecondStep());
wizard.addStep(new ThirdStep());
wizard.addStep(new FourthStep());
while when i choose the dynamic size, I don't know the exact number of step, but is the user that while running the wizard can add additional step or not.
Is this possible with the wizard add-on?
Yes it is possible to add/remove steps while running the wizard.
wizard.addStep(...)
wizard.removeStep(...)
You can see here in this demo:
http://teemu.virtuallypreinstalled.com/wizards-for-vaadin/#intro
Source code:
https://github.com/tehapo/WizardsForVaadin/tree/master/wizards-for-vaadin-demo/src/main/java/org/vaadin/teemu/wizards
I have made a eclipse RCP application, everything is working fine but i recently noticed the Refractor option in menu. I would like to get rid of it. I have the following in ActionBarAdvisor.java:
#Override
protected void fillMenuBar(IMenuManager menu) {
menu.add(createFile());
menu.add(createEdit());
menu.add(createNavigate());
menu.add(createProject());
menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
menu.add(createWindow());
menu.add(createHelp());
}
The above functions add actions to menu as:
edit.add(undoAct);
and also undoAct is defined as:
private IWorkbenchAction undoAction
makeActions function has contents as:
#Override
protected void makeActions(IWorkbenchWindow window) {
undoAction = ActionFactory.UNDO.create(window);
undoAction.setText("Undo Menu");
register(undoAction);
}
I found a suggestion which said to use hideActionSets to hide the menu. But I could not hide the entire menu but just its actions!
Remove "File, edit,...etc" menus from Eclipse RCP application
How to remove Refractor option now?
Thank you.
You can use activities, as described here.
First, you will need to find the ID of the menu:
Use the Plug-In Spy
The first way is to use the Plug-In Spy. Press alt-shift-F2 and click on a
menu item or toolbar button that you want to be hidden. If there is an ID
string under the heading "active action definition identifier" then you are
in luck. This item has been added using the Command Extension and you can
use this ID as the pattern argument for the Activities Extension. But not
all items that have been added using the Command Extension present their ID
string to the plug-in spy.
As a side note, the ID strings are period separated. For instance the ID for
a button might be "org.eclipse.ui.navigate.backwardHistory". Regular
expressions use the period to stand for any character. Luckily the period
used as a wild card matches with actual period characters so you don't need
to escape them if you don't want to. I find it makes it a bit easier to read
if they are not escaped and it is highly unlikely it will cause any
ambiguous matches.
Use the Plug-In Registry and plugin.xml files
The second way is to use the Plug-In Registry. You can open this view by
going to:
Window/Show View.../Other/Plug-in Development/Plug-In Registry
What you would like to do is to try to get a couple pieces of information:
a) the plugin that is contributing the UI element
b) information about what kind of extension the plugin is using to create
the UI element
If there is a very unique word associated with the UI element or its tool
tip then you can use this in the Plug-In Registry's filter field to try to
nail down which plug-in is contributing the UI element. The filter field is
not a very powerful tool so it can be a bit frustrating to use. It does not
allow wildcards and does not match space characters.
When you track down which plug-in is contributing the UI element then you
open the the plug-in in question from the Plug-Ins view which is found
grouped with the Package Explorer in the Plug-in Development perspective.
Then go to the Extensions tab and search for the ID string which can usually
be found in either a usage of the Command or ActionSet extension. If the UI
element is added using an ActionSet then you prefix the plug-in ID to UI ID
in the pattern argument given to the Activities Extension. For example
org.eclipse.ui.actionsets.foo becomes the pattern
org.eclipse.ui/org.eclipse.ui.actionsets.foo.
Then create a new Activity which will never be activated and a corresponding activityPatternBinding with the id you found in the last step. It will look like this in your plugin.xml:
<extension point="org.eclipse.ui.activities">
<activity id="myActivity" name="MenuHidingActivity">
<enabledWhen>
<with variable="activePartId">
<equals value="nonExistentPartId"></equals>
</with>
</enabledWhen>
</activity>
<activityPatternBinding activityId="myActivity" pattern="menuItemID">
</activityPatternBinding>
</extension>
I have a Liferay project with Vaadin portlet.
I want to add icon to my buttons.
Button search = new Button("Search");
search.setIcon(new ThemeResource("img/silk/add.png"));
But dont know where i gonna put it? Now i put it in docroot directory.
UPDATE
No i try this.
Button search = new Button("Search");
search.setIcon(new ThemeResource("LifeRayVaadin-portlet/icons/add.png"));
But when i redeploy project in console get
09:34:05,773 WARN [404_jsp:109] /html/VAADIN/themes/liferay/LifeRayVaadin-portlet/icons/add.png
So your portlet is looking for the icons in /html/VAADIN/themes/liferay/LifeRayVaadin-portlet/icons/add.png.
You could create a directory icons under VAADIN and call:
search.setIcon(new ThemeResource("../../icons/add.png"));
ThemeResource without any path will look for the file in VAADIN/themes/yourtheme/ path and thus ../../ will get you (in this case) to /VAADIN/. I personally would never hardcode the name of a theme or a portlet in a project, because when it changes you have to go through every reference and change them.
You can put your images in $PORTLET-NAME/docroot/icons directory and call them using the Path
/$PORTLET-NAME$/icons/add.png
in your case it will be
Button search = new Button("Search");
search.setIcon(new ThemeResource("/$PORLTET-NAME$/icons/add.png"));
I have an Eclipse RCP application with a sort of three column layout:
The editor area is at the extreme right. Now, when you get an IPageLayout to work with, the editor area is already added in. That's fine: we add area B to the left of the editor, and area A to the left of B, and the layout is exactly what we need.
The issue is that when you move the sash between A and B, views A and B change without resizing the editor area (good;) but when you move the other sash between B and the editor area, all three views are resized; the layout manager acts to maintain the ratio of the widths of A and B, and that's not what we want. We want the user to be able to move each sash independently, and have it influence only the two views it touches.
It seems like the root cause of this is that the editor is in place when you get your IPageView, and therefore you have to position the IFolderLayouts relative to it. If you could position the editor relative to B, instead, then resize would do the right thing.
So my questions:
Is there any way to tell the IPageView to position the editor relative to a view, instead of the other way around?
Barring that, is there any other way to influence the layout algorithm, like writing some kind of layout manager?
I know of no way to alter the layout tree of IPageLayout in Eclipse 3.x. In Eclipse 4.2, however, the Application Model can be changed dynamically at runtime.
So, if you would consider migrating your application to Eclipse 4, this solution could be an option. To keep the original application and UI code as untouched as possible, this solution will
take full advantage of the compatibility layer of Eclipse 4 to create an Application Model from the Eclipse 3 based RCP application. There is no need to create an Application Model or alter the UI code of the application.
rearrange the editor area's layout after the application is active. This is done by creating an addon class in a separate plugin.
allow easy migration to more Eclipse 4 functionality in the future: Should you decide to build an own Application Model, you can just unhook the addon plugin.
I started with the regular RCP Mail template of Eclipse 3 and altered the perspective to recreate the problem. This is the Perspective class I used in my test application:
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;
public class Perspective implements IPerspectiveFactory {
public static final String ID = "wag.perspective";
public void createInitialLayout(IPageLayout layout) {
String editorArea = layout.getEditorArea();
layout.setEditorAreaVisible(true);
layout.addStandaloneView(AView.ID, false, IPageLayout.LEFT,
0.25f, editorArea);
layout.addStandaloneView(BView.ID, false, IPageLayout.LEFT,
0.25f, editorArea);
layout.getViewLayout(AView.ID).setCloseable(false);
layout.getViewLayout(BView.ID).setCloseable(false);
}
}
It basically creates the scenario you described: a three column layout where one sash effects all three parts and the other one only two.
I then proceeded to migrate the application and alter the Application Model.
Migrate the Eclipse 3 based RCP application to Eclipse 4
There are online tutorials available for this process. I found Eclipse 4.1: Run your 3.x RCP in 4.1 and Eclipse 4 and the Compatibility Layer - Tutorial to be very helpful.
I recommend including the org.eclipse.e4.tools.emf.liveeditor and its required plug-ins in your product dependencies. With the live editor, you can take a look at the Application Model that is created by the compatibility layer.
Once the application starts, thet sashes will still behave the same way. Open the live editor on your application window and take a look at your model.
You can see that the PartSashContainer including the placeholder for the AView contains another PartSashContainer. Moving the sash between AView and that container will update the rest of the layout tree, while moving the sash between BView and the editor does not effect other parts of the layout.
You could now drag the placeholder for the AView to the container where the BView and the editor are located. This would instantly create the effect you desire: The sashes will only affect their direct neighbours. But these changes will only be saved in one's own runtime workspace. Something else is needed to alter the layout structure automatically.
Altering the Application Model at runtime
Since I didn't want to touch the original code if possible, I created another plugin to make a contribution to the Application Model.
Create a Plug-In Project without an Activator without using a template.
Add an Addon class: select New->Other->Eclipse 4->Classes->New Addon Class
Add a Model Fragment: select New->Other-Eclipse 4->Model->New Model Fragment. Open the created fragment.e4xmi file and add a Model Fragment. For the Element Id, put org.eclipse.e4.legacy.ide.application (this is the standard id of legacy applications) and for the Featurename addons. Add an Addon to the Model Fragment. Enter an ID and set the Class URI to your addon class.
Now add your fragment.e4xmi to your org.eclipse.e4.workbench.model extension point:
<extension
id="id1"
point="org.eclipse.e4.workbench.model">
<fragment
uri="fragment.e4xmi">
</fragment>
</extension>
Add your contribution plugin to the dependencies of your application product. When you start your application and look at the model with the live editor, you should see your Addon listed in the model.
Now we can implement the Addon. This is the code of my Addon class:
package wag.contribution.addons;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
public class LayoutSorter {
#Inject private IEventBroker broker;
private EventHandler handler;
// The part IDs we are interested in, sorted in the sequence they should be
// shown
private static List<String> PART_IDS = Arrays.asList(new String[] {
"wag.aView", "wag.bView", "org.eclipse.ui.editorss" });
// Listen to the e4 core service's event broker to find the magical time
// when the application is created and try to sort the layout.
#PostConstruct
void hookListeners(final MApplication application,
final EModelService service) {
if (handler == null) {
handler = new EventHandler() {
// Try to sort the layout. Unsubscribe from event broker if
// successful.
#Override
public void handleEvent(Event event) {
try {
sort(application, service);
// sort did finish: stop listening to the broker.
broker.unsubscribe(handler);
} catch (Exception e) {
// Something went wrong, the application model was not ready yet.
// Keep on listening.
}
}
};
// Subscribe "ServiceEvent.MODIFIED" to grab the application.STARTED
// event. Does anybody know how to do this in a better way?
broker.subscribe("org/osgi/framework/ServiceEvent/MODIFIED",
handler);
}
}
private void sort(MApplication application, EModelService service) {
// find all placeholders
List<MPlaceholder> placeholders = service.findElements(application,
null, MPlaceholder.class, null);
// only keep the ones we are interested in
for (int i = placeholders.size() - 1; i > -1; i--) {
if (!PART_IDS.contains(placeholders.get(i).getElementId())) {
placeholders.remove(i);
}
}
// find the parents of the placeholders
List<MElementContainer<MUIElement>> parents = new ArrayList<>(
placeholders.size());
for (MPlaceholder placeholder : placeholders) {
parents.add(placeholder.getParent());
}
// find the parent that is "deepest down" in the tree
MElementContainer<MUIElement> targetParent = null;
for (MElementContainer<MUIElement> parent : parents) {
for (MUIElement child : parent.getChildren()) {
if (parents.contains(child)) {
continue;
}
targetParent = parent;
}
}
// move all parts to the target parent
if (targetParent != null) {
for (int i = 0; i < placeholders.size(); i++) {
if (targetParent != placeholders.get(i).getParent()) {
service.move(placeholders.get(i), targetParent, i);
}
}
}
}
#PreDestroy
void unhookListeners() {
if (handler != null) {
// in case it wasn't unhooked earlier
broker.unsubscribe(handler);
}
}
}
(Please note that the code above is a bit of a hack because it is only really suited for this specific problem.)
After a restart, the application should now behave in the desired way. Take a look at the Application Model to see your changes.
One thing to be aware of is that local changes are saved in the runtime workspace in the file .metadata\.plugins\org.eclipse.e4.workbench\workbench.xmi if saving is switched on, so for recreating the unaltered model for testing this file has to be deleted.
I don't think, it's possible to achieve exactly what you want (so the answers to your questions would be 1. no, 2. no). But there it a 3rd alternative, which IMO behaves quite nicely.
When trying in Eclipse: Start with viewA on left and Editor on right. Then when you drag viewB to the right side of viewA, you get the (wrong) setup you describe. But then you drag it to the left part of the Editor, then you get different configuration, where dragging right sash behaves as you want. Dragging of left sash resizes viewA and Editor and MOVES viewB.
I would say that the code to achieve this would be:
IFolderLayout areaA = layout.createFolder("A", IPageLayout.LEFT, 0.33f, editorArea);
IFolderLayout areaB = layout.createFolder("B", IPageLayout.LEFT, 0.5f, editorArea);
Currently in IntelliJ, if I right-click a package in the Project pane, I can see things such as:
new > Java class
new > File
new > Package
I want to add some new menu items in the 'new' context menu such as Interface and Enum. Does anyone know how to do this?
I've been playing around in the Settings > Menus and Toolbars without any luck.
Edit: The funny thing is if I right click a package and choose New > Edit File Templates..., I can see the template for an Interface and in the description it actually says:
This is a built-in template used by IDEA each time you create a new Java interface, by selecting New | Interface from the popup menu in one of the project views.
Unless I need to look at a different pane other than Project, I can't seem to find any context menu that lets me choose New > Interface as suggested by the above description.
New | Java Class, Create New Class dialog appears, in this dialog you can choose Kind between one of the following:
Class
Interface
Enum
Annotation
(tested with IDEA 9.0.3)
If you want Interface directly in the New list, then you have to add new template in Settings | File Templates, name it something like Java Interface and copy the contents of the Interface template into this one.
Also you can create a shortcut to save some secs.
Alt+Ctr+S -> Keymap -> in search box type 'create new' and select Java class and then assign any shortcut like Ctrl+N.
It's under the New Java Class menu.
Yes its available in Class menu : New--> Java class --> Interface .
create a package and then select create new class from that select interface and give a name.
enter image description here
then; you need to import the references files.