In my view I have a StyledText on which I want to open the default eclipse find/replace-dialog (The one that appears in the editor on Ctlr+F).
Therefore I want to instantiate and run the FindReplaceAction but my problem is that this action needs a ResourceBundle as a parameter and I have no idea what this is used for and where I can get it from...
I wonder whether this is actually the way to accomplish this functionality or if there is a way to register my view (that implements IFindReplaceTarget) globally in eclipse to recieve the Ctrl+F shortcut for opening the dialog
You should be able to participate in the standard Find/Replace code by having your view respond to a request for the IFindReplaceTarget in the getAdapter method of your main ViewPart class and setting up the find and replace action.
The adapter is something like:
#SuppressWarnings("unchecked")
#Override
public <T> T getAdapter(Class<T> required) {
if (IFindReplaceTarget.class.equals(required)) {
return (T) ... your find replace target class
}
... other adapters
}
Note: Older versions of Eclipse don't use Generics for this method.
Set up the FindReplaceAction with something like:
ResourceBundle bundle = ResourceBundle.getBundle("my.package.Messages");
FindReplaceAction findReplaceAction = new FindReplaceAction(bundle, "find_replace_action_", this);
findReplaceAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_FIND_AND_REPLACE);
IActionBars actionBars = getViewSite().getActionBars();
actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), findReplaceAction);
The resource bundle needs a Messages.properties file with contents like:
find_replace_action_label=&Find/Replace...
find_replace_action_tooltip=Find/Replace
find_replace_action_image=
find_replace_action_description=Find/Replace
Related
I'm trying to implement a chat app using stfalcon's ChatKit library. I've followed the docs in their repo, but there are things I'm not sure I'm getting right.
First, I created a new activity called DialogsListActivity, and copied the xml in the activity's xml file.
From here I first copied the xml part to the activity's xml file.
Next comes the adapter setup. I copied the given code after the OnCreate method, including the last line (dialogsListView.setAdapter(dialogsListAdapter);) as the last line in OnCreate. The whole activity now looks like this:
ListView dialogsListView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dialogs_list);
dialogsListView.setAdapter(dialogsListAdapter);
}
DialogsListAdapter dialogsListAdapter = new DialogsListAdapter<>(dialogs, new ImageLoader() {
#Override
public void loadImage(ImageView imageView, String url) {
//If you using another library - write here your way to load image
Picasso.with(DialogsListActivity.this).load(url).into(imageView);
}
});
}
Questions:
is this the right place to put the adapter in?
is it ok to put set the dialogsListView as an attribute and defining it inside OnCreate()?
the dialogs from new DialogsListAdapter gets a Cannot resolve symbol 'dialogs' message.
the new ImageLoader() from same place gets a Class 'Anonymous class derived from ImageLoader' must either be declared abstract or implement abstract method 'loadImage(ImageView, String, Object)' in 'ImageLoader'
What am I missing there?
For the IDialog and IUser implementation I created the classes DefaultDialog and Author, and copied the given code. As I expected, the 'symbols' returned by the methods 'cannot be defined'. Where should they be defined and how?
Next in the tutorial is the Data management section which I think would set those values.
I already downloaded the sample project and tried to look inside, but I cannot find the public class DefaultDialog that implements IDialog or anything similar. Plus, I got pretty lost trying to understand the library from that sample project.
Any help would be much appreciated.
Thanks in advance.
I am writing a react native application and I want to use some of the static layouts (for Android) I have from my old application.
I looked at https://facebook.github.io/react-native/docs/native-components-ios.html and wrote a few classes (MyViewManager.java and MyView.java).
I want to be able to use the static layouts I have for MyView.java.
I went through the facebook's react native code on github.
I could not find an appropriate method like setContentView(R.layout.myview). I was wondering if anybody tried this and this will work.
Can someone please help me with this problem?
You can try out something like
The layout inflater will inflate given xml file and put it as a child of this(second argument in inflate), which is MyLayoutView.
See the definition of inflate and change arguments as per customization required.
public class MyManyViewsManager extends ViewGroupManager<MyLayoutView> {
}
class MyLayoutView extends FrameLayout {
init() {
rootItem = (ViewGroup) LayoutInflater.from(getContext()).inflate(R.layout.xmlfilename, this, true);
}
}
I am creating an RCP application using Eclipse 4.4.1 with the Compatibility Layer (migration from 3.x to 4.x). I have defined menus in the application model. Menus are displaying properly when the application is launched for the first time, but restarting the application is hiding the menu bar completely and only showing the toolbar.
Why might no menus be displaying when the RCP Application is restored?
This sounds like this bug here that I just recently myself encountered:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=388808
Personally, the workaround in the bug report did not exactly work for me (it may for you however). What did work for me was based off of the final post here by Karl Puperze, (slightly modified):
https://www.eclipse.org/forums/index.php/t/446433/
public class ForceMainMenuProcessor
{
#Execute
public void execute(#Optional MApplication application, #Optional EModelService modelService)
{
MTrimmedWindow window = (MTrimmedWindow)
modelService.find("<id of your main trimmed window>", application);
if (window == null || window.getMainMenu() != null)
{ return; }
final MMenu mainMenu = modelService.createModelElement(MMenu.class);
mainMenu.setElementId("org.eclipse.ui.main.menu");
window.setMainMenu(mainMenu);
}
}
From that, the last steps were to make sure I defined (with no content) a menu in the main e4xmi file that had the org.eclipse.ui.main.menu id, then defined a fragment that contained the menu contents.
To the plugin.xml, added to the org.eclipse.e4.workbench.model extension point a fragment that pointed to the .e4xmi model fragment that was just created and set the 'apply' to always.
Finally, to the same extension point, added a processor and pointed it to the class above. beforefragment was true and apply was always.
The e4xmi files were still used to define the menu, but in code, because of the defined processor above, the menu is forced to appear regardless of whatever persistent state was saved in the workspace. I ended up with this solution after already splitting the menu into a separate model fragment, so I am not sure if that part of the solution is definitely required, but most certainly defining the processor is.
Using Play 2.1.0, I have a Java controller with an action responsible to render arbitrary html views.
For example:
class HtmlClientViews extends Controller {
public static void getView(String viewName) {
return ok(/*How to render the view programmatically?*/)
}
}
And in my views I have a view named account.html.scala.
I have a route like:
GET /htmlclient/*viewName controllers.HtmlClientViews.getView(viewName)
If I make a request like /htmlclient/account.html I want to render the view named account.html.scala
I haven't tried yet to use Java reflection mechanisms for this, but would like to know what is the most effective way to achieve this.
You can do it with:
reflections, like in Play Authenticate usage sample, there it's used for selecting different view depending on detected language
If you have known number of views you can use simple switch statement in controller to return view a,b,c or d.
Also as in case no. 2 - you can use matching statement in the view to include sub-view depending on some variable.
I am using chrriis.dj.nativeswing.swtimpl.components.JWebBrowser in my swing application to open web page.
The page is going to show "Facebook Authentication" page and I want to prevent user from inputting some other URL other than I specify and also Forward and Back buttons should be visible but not has no affect.
So following functions are applicable for my goal
setButtonBarVisible(false);
setLocationBarVisible(false);
Once user completes the authentication I will handle the locationChanged event.
#Override
public void locationChanged(WebBrowserNavigationEvent arg0) {
System.out.println("locationChanged!");
....
}
}
I think what you want is a custom decorator. Check the demo application, under "JWebBrowser > Custom Decorator".
In your case, you could create a new decorator class, as an adapted copy of DefaultWebBrowserDecorator or a subclass with appropriate override.
You would also have to decide if this decorator is to be used only by one instance of the JWebBrowser or all instances (like child popups, etc.)