How do I force the eclipse Outline View to request a new ContentOutlinePage? - eclipse-rcp

I have an editor which can supply two different ContentOutlinePages to the outline, depending on the user's choice.
However, when I change the ContentOutlinePage to be displayed, I have to close and reopen the Outline View to see any changes. I understand that the Outline View requests a new ContentOutlinePage when the editor is activated, but is there a way to force it to request a new page at any other time?
I tried just calling
activePage.activate(editor);
where activePage is the active workbench page and editor ist the editor that is currently being displayed, but that didn't work.

Rather than have two content pages you could have one page that can show both of your outlines. To do this you cannot extend the normal ContentOutlinePage, instead you need a class like this:
public class MyContentOutlinePage extends Page
implements IContentOutlinePage, ISelectionChangedListener
The amount of code in the standard ContentOutlinePage is quite small so it is not much extra work to implement a page which meets your needs.
Update:
You would have one top level control containing the SashForm and TreeViewer and always return the top control in getControl(). You would hide either the SashForm or TreeViewer depending on which you want to show.
The top level control could be something like PageBook or a Composite using StackLayout.

Related

TreeView instead of WebView?

Once createTreeView() has created a TreeView instance, the reveal() takes your derived implementation of TreeItem. The reveal() does not take a ViewColumn as does the WebView[Panel]. The only way the vscode extension API can specify a ViewColumn is either a ExtHostTestEditor which implements the TextEditor interface, and the WebView. So do all custom editors have to be implemented with WebView? Are TreeView(s) only for activity bar side views?
It seems odd, since there is the admonition to not use WebView(s) since they are so heavy weight. Plus there is additional effort to make the WebView's look-and-feel match the editor. The vscode-json-editor uses a WebView and I haven't found any custom editors that do not use a WebView. Validating the WebView approach would help avoid going down a whole host of rabbit holes. Thank you.
These types of views have different use cases. Here's a quick overview of each VS Code 1.28:
TreeView
TreeViews can be shown in the side bar, such as in the explorer or source control section. Tree views use a data driver api where VS Code controls the presentation. This means that you get a lot for free but that you cannot fully customize the behavior of a tree view.
Use a tree view if you want to add an additional data view. A good example of a tree view would be a custom file explorer, showing the outline of an editor, or presenting a list of resources.
WebView
Webviews can be shown in an editor. They can contain any sort of html content but you are entirely responsible for the user experience of this content.
Use a webview if you need a custom user experience or need to present a completely custom view of data.

How to mimic Eclipse Preferences Windows in Delphi 2010 IDE

I'm new to Delphi. I really wanted to build a Preferences Windows in my company legacy system (which uses 'Delphi 2010' today) just like Eclipse's.
I could already mimic almost all the items:
Divided the whole screen in 3 panels (one at the left, one at the right and one at the bottom),
On TTreeView inside the left panel, and one TScrollBox on the panel of the right to be able to scroll things if they don't fit on the window for any reason (low monitor resolution or too much options). Even used a TSplitter between panel on the right and the panel on the left.
Here's what I could get:
My doubt is: what should I do to be able to load multiple options once an item inside the TreeView is selected? What delphi component should I use to mimic all this info in the right panel?
Make a frame for each page. This is kind of a "sub-form" that you can design visually. Create and destroy them at runtime in the appropriate event-handlers of the tree view.
Use a TPageControl. Add a TTabSheet for each group of controls you plan to have — one for each item in the tree control. Set TabVisible := False for each sheet to keep the tabs from appearing at the top of the page control. Each time an item in the tree control is selected, make the corresponding tab sheet visible by setting the page control's ActivePage property. Put controls on the sheets according to the preferences associated with that sheet's category.

Displaying only one panel at once

I'd like to have the effect of one of two panels visible at given time in the same place on the screen. Perhaps I could use the DeckPanel but then in the designer I wouldn't be able to edit the hidden one. Maybe you could recommend a technique?
I've found a solution which works but is not pretty IMHO. Ie. in the code I insert the panel which I want to be visible and remove the panel which I don't want to be visible (from the containing panel).
Just put both panel within another panel and then set their visibility.
Panel mainPanel = new Panel();
Panel subPanel1 = new Panel();
Panel subPanel2 = new Panel();
mainPanel.add(subPanel1);
mainPanel.add(subPanel2);
subPanel1.setVisible(true);
subPanel2.setVisible(false);
And then when you want to see panel 2 you just do this:
subPanel1.setVisible(false);
subPanel2.setVisible(true);
If you want to do this the "right" way, I'd suggest looking into the MVP pattern that GWT team in is suggesting for maintaining large-ish GWT application.
Take a look at possible implementations: mvp4g or gwt-platform. They will take care for you of switching views, as well as maintaining history (the back/forward buttons will work as they should) and many more.
You can go for Tablayoutpanel Need not to maintain your own code .

JavaFX 2 custom popup pane

The JavaFX 2 colour picker has a button that pops up a colour chooser pane like so:
I'd like to do something similar, in that I'd like a custom pane to pop up when the button is clicked on and disappear when something else is clicked (in my case, a few image thumbnails). What would be the best way of achieving this? Should I use a ContextMenu and add a pane to a MenuItem somehow, or is there something else I should look at?
It's kind of difficult to do well with the current JavaFX 2.2 API.
Here are some options.
Use a MenuButton with a graphic set in it's MenuItem
This is the approach taken in Button with popup showed below's executable sample code.
Use a PopupControl
Take a look at how the ColorPicker does this in it's code.
ColorPicker extends PopupControl. You could do this, but not all of the API required to build your own PopupControl is currently public. So, for JavaFX 2.2, you would have to rely on internal com.sun classes which are deprecated and will be replaced by public javafx.scene.control classes in JDK8.
Use a ContextMenu
So, I think your idea to "use a ContextMenu and add a pane to a MenuItem" is probably the best approach for now. You should be able to do this by using a CustomMenuItem or setting a graphic on a normal MenuItem. The ContextMenu has nice relative positioning logic. A ContextMenu can also be triggered by a MenuButton.
Use a Custom Dialog
To do this, display a transparent stage at a location relative to the node.
There is some sample code to get you started which I have temporarily linked here.
The sample code does relative positioning to the sides of the main window, but you could update it to perform positioning relative to the sides of a given node (like the ContextMenu's show method).
Use a Glass Pane
To do this, create a StackPane as your root of your main window. Place your main content pane as the first node in the StackPane and then create a Group as the second node in the stackpane, so that it will layer over the top of the main content. Normally, the top group contains nothing, but when you want to show your popup, place it in the top group and translate it to a location relative to the appropriate node in your main content.
You could look at how the anchor nodes in this demo are used to see how this might be adaptable to your context.
Is there a relevant update for this for JavaFX8?
There is not much difference of relevance for Java 8, in general the options are as outlined in this post based on Java 2.2 functionality. Java 8 does add Dialog and Alert functionality, but those are more targeted at use of dialogs with borders, titles and buttons rather than the kind of functionality desired in the question. Perhaps you might be able to start from the Dialog class and heavily customize it to get something close to what is needed, but you are probably better off starting from a blank stage or PopupControl instead.

Moveable Panels in GWT?

I need some panels in GWT that have moveable functionality. This is so that if you have a series of event-driven panels that have to be displayed on screen, they aren't all directly on top of each other. This can cause problems when you want to compare two different panels or want to close panels in your own order.
I'm currently using PopupPanels which as far as I'm aware, don't have this functionality.
I think what you want is a DialogBox. This class is a movable PopupPanel and has a constructor argument to create it as non modal, meaning if set to non modal mouse/keyboard events outside the panel are not ignored, but passed to the underlying widgets. This allows to open multiple DialogBox at once and being able to click on them or what's under it.
However, these panels can be moved inside the whole browser window and it's not possible to limit the movable area in the browser window. If you want such functionality you might want to look at the http://code.google.com/p/gwt-dnd/ library, which makes it possible to create movable panels inside a specific area.
Does your DialogBox refuse to be moved/dragged around? Make sure you DO NOT add() it into your RootPanel. Just create a new dialog and call show() on it.