This is my show() method for UsersController
import views.html.*;
public static Result show(Long id)
{
User user = User.findById(id);
return ok(views.html.users.show.render(user));
}
However, IntelliJ marks show as red and cannot find the symbol.
I already did activator compile and is target folder already has object show.template.scala.
Can anyone help me figure out what the problem is and how to fix it?
Should be something like. Note the return type.
public static Result show(Long id) {
User user = User.findById(id);
return ok(views.html.users.show.render(user));
}
Also make sure you add this to you your routes file and ensure the the show.scala.html file is in a "/views/users" folder.
I used to have the same problem every time that i created a new view in Eclipse. My solution was to refresh eclipse files with "play eclipse". In this case i think you have to find the way to make idea recognize the files (maybe "activator idea"?)
Related
i changed a BaseViewManager.java file inside of react-native to make resource-id available thru react-native. the thing is that no matter what i do, nothing takes effect, even if i put typos in the .java files. my colleague told me it's probably because the .java is not being built.
so how to build the react-native .java files??
i tried npm start of course but nothing took any effect.
and this is the code that i want to change
#ReactProp(name = PROP_TEST_ID)
public void setTestId(T view, String testId) {
view.setTag(R.id.react_test_id, testId);
// temporarily set the tag and keyed tags to avoid end to end test regressions
view.setTag(testId);
}
#ReactProp(name = PROP_NATIVE_ID)
public void setNativeId(T view, String nativeId) {
view.setTag(R.id.view_tag_native_id, nativeId);
ReactFindViewUtil.notifyViewRendered(view);
}
You have to build React Native from source. Here is tutorial for that: https://reactnative.dev/contributing/how-to-build-from-source I tried it and it works :)
I am developing plugin of graph that use the objects in the current file that open. If I change the file that open, I want the graph will update.
Now, I am using setFocus() method in my class that extends ViewPart, and update the graph in every call to this function.
This is not what I want, I want to update the graph only when the resource change.
I found this link:
link to similar question
This is like my question, but there is no answer
I need to put the following code in the activator.java file of my plugin?:
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IResourceChangeListener listener = new IResourceChangeListener() {
public void resourceChanged(IResourceChangeEvent event) {
System.out.println("Something changed!");
}
};
workspace.addResourceChangeListener(listener);
//... some time later one ...
workspace.removeResourceChangeListener(listener);
If I need to add this code, where to put it? In which method to put it in the activator.java file?
If not, what I need to do?
Set up the listener in the view part createPartControl.
The activator is not a suitable place to set up listeners as it is only run when some other code in the plugin runs.
I am making a program for computer surveillance at the moment.
It's for a competition in my country Croatia(InfoKup).
I have several options for sending command to another PC, but I
want to make the possibility for the command extension for people
who know Java. So I want to make the user be able to add some of his
custom commands for the program. For example something like
Minecraft mods. I know it is possible, but how would I go about
doing that.
Any help would be greatly appreciated. My code on GitHub:GitHub
Don't mind the stream thing.
It's something my friend is experimenting with.
EDIT: e.g.
Currently I have the possibility to send popups to another PC. What if the extension maker knew the code to send cmd commands and wants to add that function. He makes an extension and puts it in the extension folder. Voila we have a new possibility.
EDIT 2:
Don't be so harsh on me pls :). Thx for the dynamic class loading tip. I have been looking into that, and it looks promising.
Basically what I want to have possible is the user to drop the "mod/extension/whatever" in the "mod/extension/whatever" folder, and the program would load it and put all of the buttons declared in the class in to the GUI, and with them the function. I think I'm getting the hang of this, but any tips would be helpful.
e.g.
package sth.sth;
import blah.blah.*;
public class ClassSTH extends SchoolarButton{
public ClassSTH(String params){
super(params);
}
#Override
public void OnClick(){
doStuff();
}
}
EDIT:
The problem is easily solvable using Java Reflection! I wish someone posted that as an answer befpre blatanty downvoting a question because pf a GitHub link that was there to prpve that I've actually done something.
This kind of thing can be accomplished by using Java Reflection!
How to load and invoke a method on an external jar:
File f = new File("plugin.jar");
URLClassLoader cl = new URLClassLoader(new URL[]{f.toURI().toURL(), null});
Class<?> clazz = cl.loadClass("epicurus.Client");
Method main = clazz.getMethod("main", String[].class);
main.invoke(null, new Object[]{new String[]{}});
I am developing a eclipse plugin. I need to open my prespective when we open the eclipse at first time. Any ways to achieve this? i guess some listener must be available but could not trace out.
We can open a prespective after eclipse start using PlatformUI.getWorkbench().showPrespective(<prespective id>)
Similarly is there a way to open the prespective on eclipse startup, so that our desired prespective gets opened when starting the eclipse.
You can use the org.eclipse.ui.startup extension point in your plugin. When the plugin is activated, check/set a preference to decide if you want to switch perspectives and then schedule a UIJob do do it.
Implement the extension point. Some class in the plugin needs implements org.eclipse.ui.IStartup. The activator class is fine in this case. Particularly, since you don't need anything in the earlyStartup method.
In the start method, make the decision to switch and schedule it:
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
final boolean switchPerpective = processPluginUpgrading();
if (switchPerpective) {
final IWorkbench workbench = PlatformUI.getWorkbench();
new UIJob("Switching perspectives"){
#Override
public IStatus runInUIThread(IProgressMonitor monitor) {
try {
workbench.showPerspective(perspectiveId, workbench.getActiveWorkbenchWindow());
} catch (WorkbenchException e) {
return new Status(IStatus.ERROR,PLUGIN_ID,"Error while switching perspectives", e);
}
return Status.OK_STATUS;
}}
.run(new NullProgressMonitor());
}
}
Use the preference store to keep data for your decision logic. In this implementation, the perspective is switched once per workspace whenever the plugin is upgraded. The data recorded in the preference store will allow a future version to have a difference policy. It uses the getPreferenceStore from AbstractUIPlugin so it is scoped per workspace. If you want to use other scopes, see the FAQ.
private Boolean processPluginUpgrading() {
final Version version = getDefault().getBundle().getVersion();
final IPreferenceStore preferenceStore = getDefault().getPreferenceStore();
final String preferenceName = "lastVersionActivated";
final String lastVersionActivated = preferenceStore.getString(preferenceName);
final boolean upgraded =
"".equals(lastVersionActivated)
|| (version.compareTo(new Version(lastVersionActivated)) > 0);
preferenceStore.setValue(preferenceName, version.toString());
return upgraded;
}
One thing I am doing to open my custom perspective in my plugin is to configure it in config.ini in eclipe's installation folder as below:
-perspective <my perspective id>
and it is working fine. I got this information from Lars Vogel's tutorial, which you can find here. Hope this helps.
Other way:
org.eclipse.ui.IPerspectiveRegistry.setDefaultPerspective(id) this sets default perspective to the given id. API Docs for the same.
Go to
D:\{MyTestSpace}\eclipse\features\myCustom.plugin.feature_3.1.0.201607220552
you can see feature.xml under plugin tag you get the id.
Use this id in config.ini which you can find under
D:\{MyTestSpace}\eclipse\configuration
As
-perspective <myCustum.plugin>
I am trying to create a console that would work as a shell for a custom programming language. It would be very similar to the pydev interactive console.
Currently, my RCP uses the basic TextConsole and is connected to the shell via pipes so it just displays whatever the shell displays and if the user enters anything in the RCP console, the same is written in the shell.
I want to be able to do a bit more such as move the caret position, add events for up and down arrow keys etc. I believe to do that I need to add a StyledText widget to the console which is done via the ConsoleViewer.
So my question is, that is there any way for me to either override the TextConsole's ConsoleViewer or if I were to extend TextConsole and create my own, then how do I link it with the launch configuration (the one that connects the shell via pipes)?
Also, to get the current default console I use DebugUITools.getConsole(process).
I'm sorry if I haven't put all the information needed; it is a bit difficult to explain. I am happy to add more information.
An idea...
From what I understand I can create a TextConsolePage from the TextConsole using createPage(ConsoleView). Once I have the page I can set the viewer via setViewer(viewer). Here I thought if I create my own viewer (which will have the appropriate stylewidget) then that could be a lead. The only problem is that the viewer needs a Composite and I can't seem to figure out where to get that from.
Why don't you just follow what PyDev does (if you're able to cope with the EPL license)?
The relevant code may be found at:
https://github.com/aptana/Pydev/tree/ad4fd3512c899b73264e4ee981be0c4b69ed5b27/plugins/org.python.pydev/src_dltk_console
https://github.com/aptana/Pydev/tree/ad4fd3512c899b73264e4ee981be0c4b69ed5b27/plugins/org.python.pydev.debug/src_console
So I thought I would answer this myself as I was finally able to accomplish the console. It still is a working prototype but I guess as you keep adding things, you can clean up the code more and more. For my current purposes this is how it worked.
If you want the short version, then I basically mimicked the ProcessConsole provided by Eclipse as that is what I needed: a console in which I can connect a process but since the ProcessConsole is internal, I like to avoid extending those classes.
Following is an outline of the classes I used to achieve interaction with my console. I am not going to give the pretext as to where MyConsole was created. Basically, instead of using DebugUITools.getConsole(myProcess), I used my own myProcess.getConsole() method. MyProcess extends RuntimeProcess.
class MyConsole extends IOConsole {
private IOConsoleInputStream fInput;
private IOConsoleOutputStream fOutput;
private IStreamsProxy fStreamsProxy;
private ConsoleHistory history;
//This is to remember the caret position after the prompt
private int caretAtPrompt;
/* in the console so when you need to replace the command on up and down
* arrow keys you have the position.
* I just did a caretAtPrompt += String.Length wherever string was
* appended to the console. Mainly in the streamlistener and
* InputJob unless you specifically output something to the output
* stream.
*/
//In the constructor you assign all the above fields. Below are some
//to point out.
//fInput = getInputStream();
// fStreamsProxy = process.getStreamsProxy();
// fOutput = newOutputStream();
//We must override the following method to get access to the caret
#Override
public IPageBookViewPage createPage(IConsoleView view) {
return new MyConsolePage(this, view);
}
//After this I followed the ProcessConsole and added the
//InputJob and StreamListener
//defined in there.
}
class MyConsolePage extends TextConsolePage {
//Not much in this class, just override the createViewer
// to return MyConsoleViewer
}
class MyConsoleViewer extends TextConsoleViewer {
//This is the most important class and most of the work is done here
//Again I basically copied everything from IOConsoleViewer and then
//updated whatever I needed
//I added a VerifyKeyListener for the up and down arrow
//keys for the console history
MyConsoleViewer (Composite parent, MyConsole console) {
//I have omitted a lot of code as it was too much to put up,
//just highlighted a few
getTextWidget().addVerifyKeyListener(new MyKeyChecker());
}
class MyKeyChecker implements VerifyKeyListener {...}
}
This is the code for ProcessConsole.
This is the code for IOConsoleViewer.
The ConsoleHistory class I created just had a doubly linked string list to save all the commands the user entered. Quite a simple class to create.
Once you look at the Eclipse classes (ProcessConsole and IOConsoleViewer) it is actually all quite self explanatory. I haven't put in much code here because there is quite a bit. But hopefully this gives some direction as I was completely lost when I started.
I am happy to answer questions though and add more specific code if anyone asks.