I have an eclipse plugin which configures a set of resources as a customized project and runs it. I have added run and debug choices to "Run As" and "Debug As" menus and also shortcuts in the tool bar. So when I put mouse over "Run As", I have two submenus:
Run on Server
My Customized project
I can click on "My customized project" and everything runs as desired.
However after I ran it once, I no longer have "My customized project" as a "Run As" submenus, it's gone. "Run on Server" is also gone and instead I have an "XSL Transformation" there.
I found a post with similar question here:
http://www.sigasi.com/content/run-menu-item-strangely-disappearing-context-menu
but his solution won't work for me. I already have the extension point defined.
Does anyone have an idea why this happens?
UPDATE:
I think I know where exactly the problem is but I still have no solution.
I have the following code when a customized project is finished running:
IJobManager manager = Job.getJobManager();
manager.addJobChangeListener(new JobChangeAdapter() {
#Override
public void done(final IJobChangeEvent event) {
if (event.getJob().getName() == "Processing with selected modules" && event.getResult() == Status.OK_STATUS) {
Display.getDefault().syncExec(new Runnable() {
#Override
public void run() {
actionExport.setEnabled(true);
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("customized.output");
} catch (CoreException e) {
e.printStackTrace();
}
}
});
manager.removeJobChangeListener(this);
}
}
});
the line PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("customized.output"); is the source of the problem. I just want to switch to another view when the project finishes to show the result. There will be no problem with disappearing "Run As" submenu if I remove this line. But I want to show the view after running a project. Anyone has any clue about it?
Related
I have encountered a problem when using the the addCommand() method of the Form class along with the Native theme - other themes work fine. See the following example:
Form hi = new Form("Hi World");
hi.addComponent(new Label("Hi World"));
// with native theme - can't click on the first command in the list
hi.addCommand(new Command("Dummy1") {
public void actionPerformed(ActionEvent ev) {
Dialog.show("Dummy1 Clicked!", "You clicked the Dummy1", "OK", null);
}
});
hi.addCommand(new Command("Dummy2") {
public void actionPerformed(ActionEvent ev) {
Dialog.show("Dummy2 Clicked!", "You clicked the Dummy2", "OK", null);
}
});
hi.show();
When I create an application using the code above, a click on the second command ("Dummy2") produces the expected Dialog, but a click on the first command ("Dummy1") does nothing.
This only happens when using the Native theme. If I switch to Flat Blue, then clicking on either command produces the expected Dialog.
This behavior happens both on the Simulator and on a real Android device (don't know about iOS).
Fyi, my toolchain is NetBeans IDE v8.2, Java 1.8.0_25, with the CodenameOne plugin v3.6.0.
Has anyone else seen this? Am I missing something? If so, is there a workaround?
If the element is very narrow and very close to the top the click might be misinterpreted as a click out of bounds or on the status bar area. You need to set the styling of the SideCommand to have a sensible default as this element is very application specific. Otherwise touches might be lost.
I tried styling the SideCommand but it didn't seem to help. What worked for me was to define a style for TitleArea and simply uncheck Derived for the Padding settings (I left them all set to 0px).
I have no idea why this works - I would have thought that the derived values would have been zero in any case.
Can we make a button using SWT in eclipse that can refresh our Project made in eclipse ? if yes then how ? thank you in advance .
You'll have to write a plugin to create your button and hook it where you need (see . then,
Button button = ...
button.addSelectionListener(new SelectionAdapter() {
#Override
public void widgetSelection(SelectionEvent e) {
ResourcePlugin.getWorkspace().getRoot().getProject("myProject").refreshLocal(IResource.DEPTH_INFINITE, null);
}
}
See also https://wiki.eclipse.org/FAQ_When_should_I_use_refreshLocal%3F
However, there is already the "Refresh" context menu in Project Explorer for that. I don't really get why a new button would help. Also, if you know that you sometimes need to refresh a project, why don't you do it anyway when you detect it can be useful without requiring user to click on a button?
I am trying to launch an external application for testing using UISpec4J.
Here are the questions and their answers I referred so far:
How to automate a swing java web start application which runs clicking a link into a web application, which is automated with Selenium WebDriver?
Getting all windows using UISpec4J
UISpec4J Capturing modal dialog, before the trigger finish
my.exe referred below is a Java application wrapped in exe using some tool. Internally it uses the jars and is Java GUI application.
This executable launches a splash screen first, then a dialog to choose where you want to connect to and after that main window is shown. Unless I can automate where I can connect to I won't get main window.
Based on these questions I have come up with following code fragments:
this.setAdapter(new UISpecAdapter() {
#Override
public Window getMainWindow() {
return WindowInterceptor.run(new Trigger() {
#Override
public void run() throws Exception {
// running jnlp by netx launcher
Runtime.getRuntime().exec("C:\\my.exe");
Thread.sleep(10000);
}
});
}
});
In the approach above I simple get "No window was shown" error.
this.setAdapter(new UISpecAdapter() {
#Override
public Window getMainWindow() {
final Window[] result = new Window[1];
WindowInterceptor
.init(new Trigger() {
#Override
public void run() throws Exception {
Runtime.getRuntime().exec("C:\\my.exe");
//Thread.sleep(10000);
}
})
//.processTransientWindow()
.process(new WindowHandler() {
public Trigger process(Window window) throws Exception {
result[0] = window;
return Trigger.DO_NOTHING;
}
})
.run();
return result[0];
}
});
In the second approach above, I still get "No window shown" error AND control never reaches to overriden "process" method.
I referred to http://www.uispec4j.org/reports/apidocs/org/uispec4j/interception/WindowInterceptor.html and recommended approach is to use init to capture modal dialog is init\process sequence.
To capture non-modal it is recommended that we should use following:
Window window = WindowInterceptor.run(panel.getButton("open").triggerClick());
But I have NO idea where and how I am supposed to call it..
From the first question I referred, mentioned above, we should be able to do that because the answer to it mentions launching jnlp application which is external application.
I tried with jre 6 update 0 and I can at least run test. In java update 37, from the third question I referred above, I get abstract method not implemented error.
What am I doing wrong? Any idea?
I am using latest UISpec4J package - version 2.4.
Thanks in advance,
-Neel.
I'm very new to UISpec4J but I'm guessing it needs to run in the same JVM in order to intercept and interact with the GUI components. When you start the exe file with exec, it will create a new process and a new, separate JVM. That'll not work, if I understand UISpec4J correctly.
Regarding the non-modal example, the documentation says "You would retrieve the window from within the test...", so in a setup method or in a test should work.
eclipse (3.7) does provide a nice abstract class Job for running tasks in a separate jobs. Using this opens a dialog with three buttons, "Run in Background", "Chancel" and "Details".
Is there any implementation or even a simple setting to remove the button "Run in Background" (and the checkbox "Always run in background")? Or do I have to provide my own implementation for this?
Update - Workaround
A co-worker had an idea, this workaround seems to be a good alternative.
new ProgressMonitorDialog(this.getPage().getShell()).run(true, true, new IRunnableWithProgress() {
#Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("Konfiguration speichern...", IProgressMonitor.UNKNOWN);
// Do something here
}
});
The dialog is display by the Eclipse progress manager org.eclipse.ui.internal.progress.ProgressManager. It is not really practical to replace this.
The dialog is not displayed at all if setUser(false) is called on the Job.
I have a custom Eclipse plugin I am working on. It has a CustomerExplorer View(Part) that effectively replaces the 'Project Explorer' and it has a number of MultiPageEditorParts, each has a XML editor and a Form editor, both modifying the same configuration file. The XML editor is a TextEditor. The form and the XML are linked and each updates the other whenever there is a pageChange().
My problem lies in the external modification of files opened in my Eclipse plugin. If I edit a file in an external editor and then load it (from CustomerExplorer View), upon switching to the XML tab I will recieve the message:
"Resource is out of sync with the file system: '/example/example.xml'.
Press 'F5' or select File > Refresh to refresh the file.
I am familiar with this error from using Eclipse and usually simply pushing F5, right clicking the file in question and choosing refresh or choosing File > Refresh from the menu bar usually solves it. However, in this case F5 does nothing, File > Refresh is greyed out and right clicking on the file (in my custom view), the context menu does not contain 'refresh'. I have tried opening the 'Project Explorer' view, where 'Refresh' is available in the context menu, but this does nothing.
From reading around I have been led to understand that these resources should be refreshed by eclipse but they are not. Any pointers as to why?
Hard to say exactly what is happening here, but you may need to explicitly add the action set for refreshing resources to your custom view.
Another way of solving your issue might be to track change to the file an update your view when there is one:
ResourcesPlugin.getWorkspace().addResourceChangeListener(new MyResourceTracker(), IResourceChangeEvent.POST_CHANGE);
With something like that:
public class MyResourceTrackerimplements IResourceChangeListener {
#Override
public void resourceChanged(final IResourceChangeEvent ev) {
if (ev.getDelta() != null) {
try {
ev.getDelta().accept(new IResourceDeltaVisitor() {
#Override
public boolean visit(final IResourceDelta delta)
throws CoreException {
// TODO do something
return true;
}
});
} catch (CoreException e) {
// TODO
}
}
}
}