icons of tree items in eclipse trees - java

Is there a way to do the following ?
I have a tree item icon which is for example :
http://cdn1.iconfinder.com/data/icons/DarkGlass_Reworked/128x128/actions/contents.png
and when a certain action occurs I want to add a flag on it ( the flag is an icon which will be place on it)
if the flag is the right mark so it should be like
http://store2.up-00.com/June12/yk105816.png
Simply, can I add image on image on an action ?
Note: I know I can do this in another way to change between the two images upon action.. but I'll have to do a loooot of work on paint of PS.
sorry for the links of images as as a new user I can't post images

What you want to achieve is called a decorator in Eclipse platform.
You can find a detailed description with example on this page: http://www.eclipse.org/articles/Article-Decorators/decorators.html
Check also the following stackoverflow question:
How to set the color of an Eclipse/RCP decorator?
How to remove a previously added decorator on a resource?
Hope this helps.

You can combine several images on the fly by using or subclassing org.eclipse.jface.resource.CompositeImageDescriptor.

Related

how to limit the reorder in draglinearlayout (need some idea!)

i want to use draglinearlayout to do drag and drop action. See the link in Github https://github.com/justasm/DragLinearLayout
This source library allow user to drag those view added by the AddDragView(View,(View) findViewById(R.id.controller)).
In my draglinearlayout, i have various views (cannot drag) and many dragView. i want to limit the drag action across the normal view(cannot be drag). That mean if i try to drag the dragView across those normal view, it should detect it and stop my action.
Do I need to override which part of the source codes??
I have search for google using keyword 'draglinearlayout', but there are only few of relevant website and i cannot found what i want!!!
I guess the easiest way is to remove your elements non-draggable from the DragLinearLayout and put it in a separate LinearLayout. I honestly don't think it is possible otherwhise.
Also you can't override some parts of the code ( like the ontouch events ) otherwhise it will cancel the draglinearlayout effect.
If you can't find what you want you can also open a new issue on the related github.
Because of addDragView(...) is actually addView(...) followed by setViewDraggable(...)
Try to use
layout.addView(view);
layout.setViewDraggable(view, view); // only if you want it dragable
instead of
layout.addDragView(imageView, imageView);

JavaFX 2.2 Remove Pagination's selected page label

I want to remove the Selected page label (see image below) of the Pagination control.
After digging into caspian.css I wasn't able to find any clue about how to do that. By code I also didn't find any method to remove (or eventually hide) this label.
Is there a way to do that in JavaFX without re-implementing the whole control ?
Use -fx-page-information-visible
It's described within these links:
http://docs.oracle.com/javafx/2/ui_controls/pagination.htm
https://docs.oracle.com/javase/8/javafx/user-interface-tutorial/pagination.htm#JFXUI459
https://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html#pagination
I couldn't find a way either to hide just the label, but would it help to hide the whole button?
.number-button:selected{
-fx-opacity: 0;
}
That would hide the current selected button.
It's not what you actually wanted but maybe it can help you.

Making Java button dynamically?

I am new to Java and I am working on a project where depending on number of files in a directory,
buttons will be created respectively. Each button will have a customized right click context menu.
How can I achieve this or is this feasible?
I just want to know the approach to do this.
The approach that you may try:
While you iterate your directory/file list (or other process that will determine the button creation), you can generate (create an instance of) a new button (JButton), I assume you know how to use new, and put it on your form / panel.
However, most of the time, layout would become an annoying issue here.
Thus, you may try to use MigLayout to handle this.
It will help you a lot in putting your stuffs in a tidy and convenient way.
Try this approach and when you have a specific coding-part question, you can try to search the existing solution in SO (StackOverflow) or if it doesn't exist, you can ask that specific code-related question.
Hope it helps.

Formatting JEditorPane's cursor, tooltips, links

Right now, I'm using Java Swing to create a JEditorPane primarily for its ability to have hyperlinks. I've successfully been able to display links and have them execute behavior upon a click, but I'm running into a few problems with formatting.
How can I set the cursor so that it normally is an arrow, but changes to a text cursor when hovering over text? (In essence, the behavior a cursor has within a web browser). I tried
EditorPane.setCursor(new Cursor(Cursor.TEXT_CURSOR))
but that made it a text cursor everywhere, even when not hovering over text. Right now, hovering over a link shows a pointer hand; I'd like to maintain that functionality as well.
What is the best way to show tooltips or mouseover text when hovering over a link? I tried modifying the title attribute of the link but nothing showed up.
I was trying to implement links to skip down to a subsection of the page, much like http://en.wikipedia.org/wiki/Xkcd#History would take you directly to the History subsection of Wikipedia's xkcd page. How can I do this?
An answer to any of these would be great (and multiple would be awesome xP). Thanks a lot for your help!
As you said one can simply give answers to a single point as well, let me try one by one, here is the answer for your last Point 3
Just provide an id to your tag like this
<h1><a id = "top"></a>First Line</h1>
Now somewhere in the bottom of your page write this :
<p>Return to TOP</p>
Clicking this link, you will reach the above area of the PAGE.
Points 1 & 2 may be addressed using the approach mentioned here. In particular, the view/model conversion methods will let you condition setCursor() and getToolTipText(), respectively.
You can get source from here http://java-sl.com/JEditorPaneStructureTool.html
It shows how to obtain text view bounds. First you get caret position for current mouse poiunter using viewToModel() method. Then go down the Views tree achieving leaf view and calcualte it's bounds. See this http://java-sl.com/tip_view_rectangle.html
If your mouse pointer in the view's rectangle then your mouse over text.
You can check whether the text in caret position is link and show your tooltip.
Use this http://java-sl.com/tip_links_in_editable.html to see how to detect whether mouse is over link.
Point 3.rd is answered by #nIcE cOw

Working in java image

I will explain my question clearly.
I need to zoom in/zoom out the world map.
When I click on the particular country in map, control should redirected to new page with respective the country.
I dont have any idea about this in java. Please explain the steps to acheive the above task.
As the question is quite general, here is a general answer: Zooming often means, that you want to display a certain percentage of somethin, and not the whole, where your size of the displayed will not change.
But in your case it seems more like a "find a mouse click in a polygon" thing. So you have to add a selection/click listener to whatever widgets you use (Swt? swing? ....?) where you change what your program renders.
It sounds like you may be trying to reinvent the wheel. Google etc have already solved this problem rather well. It might be better to incorporate an existing solution into your application. Have a look at GoogleEarth inside Java Swing.

Categories

Resources