My RCP app provides content through the CommonNavigator to the ProjectExplorer view. It provides a node whose children are resources which exist in various places on the file system inside the project, similar to how JDT or other toolkits provide a container that provides access to library resources, etc.
When a file is created on the file system inside the project, by a program external to eclipse, I detect it with an IResourceChangeListener and invoke
refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor())
on the resource, and the file appears automatically in the file tree of ProjectExplorer, in the node corresponding to its actual place on the file system. But it doesn't appear under the custom node that I contributed to the CommonNavigator, unless I manually refresh the tree from the UI.
I worked around the problem somewhat by getting a reference to the ProjectExplorer view, and calling refresh() on its CommonViewer instance. The problem with this is that the entire tree is refreshed, collapsing all nodes. But when they're re-expanded the new file shows up in my custom node as desired. I tried calling refresh(theResource) on the CommonViewer, but that has no effect.
Is there any way to cause the file to be added automatically to my custom node when it's created from outside eclipse, just as it's added to its regular place in the file tree?
UPDATE: I implemented an ICommonviewerMapper, which I set on the viewer so that it reports the mapping of model objects to Tree items. With this class I call viewer.refresh(item), where item is the Tree item that the viewer indicated to the mapper is mapped to the model object that I'm updating. In my case, the model object is an IContainer instance to which the ContentProvider adds IFile instances as children (it's one of these files that is being created outside of eclipse, which I want the viewer to show).
So I'm calling viewer.refresh() with the Tree element that is a container to which the ContentProvider will add as a child the file that was created, and still the viewer takes no action. The ContentProvider's getChildren() method is not called after refresh is invoked on the viewer. The viewer seems to be ignoring the invocation of refresh with a Tree item that I know exists in the viewer.
Related
In Lazarus, there are 2 different kinds of tab elements (cf. Free Pascal docs):
TPageControl
TPageControl is a multi-page component that provides a container to hold a variety of controls per page.
TTabControl
It is a tabbed container component which looks identical to a TPageControl. However, there is a fundamental difference because the control always shows the same page whichever tab is selected. In fact, it containts only a single page. The idea behind this concept is illustrated best by an editor or viewer for text files: When the TabControl contains a TMemo then the individual tabs refer to the files loaded into the memo; whenever the active tab changes another file is loaded into the (same) memo.
In this sense, JavaFX TabPanes are quite similar to TPageControls, but I rather want to replicate a TTabControl. I know I could in fact programmatically create a new Tab(), but I want to visually design it in SceneBuilder.
Is there maybe a way to load a separate .fxml file into a new Tab() element which is then added to the TabPane? (And how could I then access a tab's children?)
I chose the easiest approach: Implementing a head-less TabPane to detect when the user switches between tabs. The elements that appear to the user as the “tab content” are actually placed outside the TabPane, and their content is dynamically changed whenever the tab is switched.
I want to change the appearance of project explorer view in eclipse by changing the default file/folder icons for my custom plugin resources. I am aware of Decorators - https://eclipse.org/articles/Article-Decorators/decorators.html , But how can I change the existing icons itself inspite of just putting an overlay or underlay image?
Also I don't want to create a new view , just want to reuse the project explorer with my icons.
The main icon used is taken from the default editor used for the file as defined by the org.eclipse.ui.editors extension point.
If you defining new file types and editors you can specify the icon, but you can't override the icon for existing types and editors.
To modify existing project explorer content first add a org.eclipse.ui.navigator.viewer extension point. Under that add a viewerContentBinding element with the id org.eclipse.ui.navigator.ProjectExplorer (that's the id of the standard Eclipse project explorer view).
Under that add a (includes) with a contentExtension element. The pattern identifies the IDs of navigator content to include and can contain wildcards, e.g. com.example.mycontent.*.
Next define a org.eclipse.ui.navigator.navigatorContent extension point with a navigatorContent element. Make sure the id you provide matches the above pattern. Set the content and label providers. If the content provider implements IPipelinedTreeContentProvider it will allow you to modify existing content (possibly wrapping things like IFolder inside classes your label provider understands). You'll also need to define triggerPoints to identify the items for which your content provider should be called.
It may be useful/necessary to suppress standard navigator content. You can do this by specifying an override element under navigatorContent with the policy InvokeAlwaysRegardlessOfSuppressedExt and id org.eclipse.ui.navigator.resourceContent.
I am working in the java swings application and in the application we have the front menu that contain the list of the other button and the drop down menus. in the application we have the various events that are associated to one another and leads to the opening of the various frames. i want to get the list of the parents through which the particular page is open as i am right now using parent-of-parent but that will give me reference to the two level above the hierarchy but not the entire list. please help...
I am creating an application that converts files from xml to pptx. The user will drag items from a JTree to a JList to create the slide. I have managed to get everything working but the JList seems to disappear after the drop. I know the drop is received because of print statements, and that it's not null. The JList is still there I believe, because I can print the items in the array. Through testing, I think that something is wrong in the custom DefaultListModel I have created. It is not calling an update/redraw/revalidate after the drop for some reason, or has released its action listeners because I notice that the getSize and getElementAt methods stop getting called after the drop. It does however draw correctly if I add items to the ListModel on app init.
I've been looking through all the documentation on ListModels and TransferHandlers but have not been able to get the List to display after the drop. Is my model missing an Override or not handling listeners in some way?
Full source:
http://code.google.com/p/app4args/
Possible problematic file:
http://code.google.com/p/app4args/source/browse/trunk/src/edu/gatech/app4args/utils/CustomListModel.java
To recreate:
Download latest release/source & example xml file from downloads section of project site
Run app, choose File > Import, browse to example xml file
Create new slide: Slide > New Slide, choose Standard (any works)
Drag JTree item from Library to a List in Slide Content View
List does not update, clicking on it or elsewhere in the app and back on the list will make it disappear
Thanks
Turns out I was overriding methods in CustomListModel that were relevant to the updating of how to draw the content of a list. I removed these and reworked a few things and it is correctly drawing now.
I'm currently developing an application that will allow people to download the files from the online FTP repository, I have it connecting perfectly with Apache Commons, My only trouble is making a JTable out of it.
I know how to create a JTree, My problem is adding the nodes when they are called (Someone presses the plus icon, Load files in sub directory)
Also determining whether they are leafs... I'm sorry, I'm so lost at the moment!
If it were me, i'd remove the plus button, and just load sub directories when you get tree will expand events.
So What you could do, is populate the top level node, with a Stub node under it, and show the tree with the top level node, non-expanded. When the user expands it, you will get the tree will expand event. Look at the child, and see if it's a Stub node. If it is remove it, and use apache commons to load the children, populating each one, and each one with it's own stub node.
What is a stub node? Just a node that somehow tells you that this node is a placeholder. It means that you haven't tried to load children yet. Most likely this Node class will be a special class called StubNode or something. Of course you only need to add Stub nodes to directories, not files, as you won't be expanding files.
http://www.java2s.com/Tutorial/Java/0240__Swing/TreeWillExpandListener.htm