I'm developing an Eclipse product. I have defined two different perspective, edit and debug. In the toolbar of the debug perspective i placed a set of buttons to guide the debug process flow(e.g. step over, step into, etc..). I used the eclipse command to implement the logic. Below the fragment of pluxin.xml where i declare the toolbar command.
<toolbar
id=".."
label="Debug navigation command">
....
<command
commandId="org.eclipse.debug.ui.commands.Terminate"
disabledIcon="icons/16x16/stop_disabled.ico"
icon="icons/16x16/stop.ico"
label="Terminate"
style="push"
tooltip="Terminate">
<visibleWhen
checkEnabled="false">
<with
variable="activeWorkbenchWindow.activePerspective">
<equals
value="org.xvr.xvrengine.perspective.debug">
</equals>
</with>
</visibleWhen>
</command>
</toolbar>
The problem is that while all the other icons associated to the command org.eclipse.debug.ui.commands.Terminate are updated by eclipse(active only when the process is selected in the debug view), the command i define is not updated. The editor updates the command icon if i change perspective and then switch back to the debug perspective.
How can i update the command icon? is possible to use the default eclipse icon? if i leave the "icon" entry empty the toolbar is filled with the command label.
thanks
There are 2 places where you can control the enabled state of your command.
in org.eclipse.ui.handlers, you can
associate your handler with your
command and provide an enabledWhen
core expression. See
http://wiki.eclipse.org/Command_Core_Expressions
and
http://wiki.eclipse.org/Platform_Expression_Framework
While your handler is active, its
enabled state reflects in the
command. Most handlers subclass
org.eclipse.core.commands.AbstractHandler.
As your handler updates its state
using
org.eclipse.core.commands.AbstractHandler.setBaseEnabled(boolean)
that enabled state will be reflected
in the UI
.
Sorry, but it is not clear for me what you want to achieve. If you would like to create a debugger, I suggest reusing the existing framework for that, see http://eclipse.org/articles/Article-Debugger/how-to.html and http://eclipse.org/articles/Article-Launch-Framework/launch.html
In this case you get automatically the debug frameworks icons, that are updated correspondingly.
Otherwise you might consult http://blog.eclipse-tips.com/2009/02/commands-part-5-authentication-in-rcp.html for ideas of dynamic command handling.
Update: Alternative answer:
You could use fireEvent(new DebugEvent(this, DebugEvent.RESUME, detail)); as described in the end of the following Eclipse Corner article: http://eclipse.org/articles/Article-Debugger/how-to.html
This is described in the part Debug Events. I believe, that is close to what you need.
Related
As the title says I'm wondering whether Eclipse RCP 4 provides any built in cut/copy/paste handlers which can be linked to the org.eclipse.ui.edit.cut, org.eclipse.ui.edit.copy and org.eclipse.ui.edit.paste commands?
I appreciate that that a custom handler may be needed for some SWT widgets or more complex use cases with cut/copy/paste operations, but I can't help but feel I'm trying to re-invent the wheel to copy some text from one component and paste in into another.
If there aren't any built in cut/copy/paste handlers, are there any well documented examples of how to do this? I understand how to use the clipboard.getContents and clipboard.setContents methods, but have found this starts to become non-trivial when trying to find out what text was selected when the copy command is invoked and which component has focus and whether its read only when the paste command is invoked.
I've looked at this StackOverflow question but it doesn't explain whether there any built in handlers or offer any guidance on writing my own handlers.
For a 3.x compatibilty mode Eclipse 4 application these commands are defined as:
<command
name="%command.cut.name"
description="%command.cut.description"
categoryId="org.eclipse.ui.category.edit"
id="org.eclipse.ui.edit.cut"
defaultHandler="org.eclipse.ui.internal.handlers.WidgetMethodHandler:cut" />
<command
name="%command.copy.name"
description="%command.copy.description"
categoryId="org.eclipse.ui.category.edit"
id="org.eclipse.ui.edit.copy"
defaultHandler="org.eclipse.ui.internal.handlers.WidgetMethodHandler:copy" />
<command
name="%command.paste.name"
description="%command.paste.description"
categoryId="org.eclipse.ui.category.edit"
id="org.eclipse.ui.edit.paste"
defaultHandler="org.eclipse.ui.internal.handlers.WidgetMethodHandler:paste" />
So they all use org.eclipse.ui.internal.handlers.WidgetMethodHandler as the default handler which is used when no other handler is active.
This handler uses reflection to look for the method name cut, copy or paste in the currently focussed SWT Widget and calls that method if it is found.
For a pure e4 application there is no default definition of cut/copy/paste commands and the WidgetMethodHandler is not available. SWT controls will continue to support cut/copy/paste but there is no other support.
You can put text in the clipboard using something like:
Clipboard clipboard = new Clipboard(Display.getCurrent());
clipboard.setContents(new Object [] {"Text for clipboard"},
new Transfer [] {TextTransfer.getInstance()});
clipboard.dispose()
and get text from the clipboard with:
Clipboard clipboard = new Clipboard(Display.getCurrent());
String text = (String)clipboard.getContents(TextTransfer.getInstance());
clipboard.dispose()
We are using Installer 6.1.6.
Today we support SQL server authentication and I wish to add a new ability of Windows authentication mode.
Our database configuration is set as configuration form and I want to add a new combo-box form component which will include the 2 server authentications options.
Is it possible to define the combo-box's Windows Authentication option with a condition expression for Windows OS only? (it doesn't make sense to display it for Linux users)
Some of the form components are "username" & "password". In case the user chooses the windows authentication mode these fields aren't relevant anymore. Is it possible to conceal them in that case?
Is the combo-box option could lead to a conflict when running the installer with a quite mode? Is it set the 1st option as a default?
Is it possible to define the combo-box's Windows Authentication option
with a condition expression for Windows OS only? (it doesn't make
sense to display it for Linux users)
You can set the "Drop-down list entries" property of the "Drop-down list" form component to an installer variable that contains a string array:
${installer:authenticationOptions}
In the pre-activation script of the form, you can set the variable with code like:
List<String> options = new ArrayList<>();
options.add("One");
options.add("Two");
if (Util.isWindows()) {
options.add("Three");
}
context.setVariable("authenticationOptions", options.toArray(new String[0]));
Some of the form components are "username" & "password". In case the
user chooses the windows authentication mode these fields aren't
relevant anymore. Is it possible to conceal them in that case?
Yes, by disabling the components in the "Selection change script" property with code like this:
// to disable
formEnvironment.getFormComponentById("123").setEnabled(!selectedItem.equals("Windows authentication"));
// or to hide
formEnvironment.getFormComponentById("123").setVisible(!selectedItem.equals("Windows authentication"));
Is the combo-box option could lead to a conflict when running the installer
with a quite mode?
By default, the first index is selected. This is configurable with the "Initially selected index" property of the "Drop-down list" form component.
Alternative solution:
I would consider using "Single radio button" form components for your authentication options. They are all bound to the same variable name in order to form a group and have the same effect as a drop-down list. With the "Visibility script" property you can hide some options depending on the OS, for example with
Util.isWindows()
and option is only visible on Windows. With the "Coupled form components" tab in the configuration area, you can select other form components that are disabled or enabled depending on the selection.
I am working on eclipse form based editor. I have given support of handling of Undo Redo and dirty flag to my editor.Both of these feature working fine for single instances of plugin. Problem is coming when i open it with 2 or more files (2 or more instances of eclipse plugin). Now, undo redo starts working weird. They work only for instances that is opened at last.
for eg: Suppose my editor supports '.xeb' file. if i open test1.xeb and test2.xeb files one by one using with my editor. then undo redo only works for instances that is opened for test2.xeb file. If i switch back to other instances, then undo redo of first instance gets appear.
i have below entries in my editor's plugin.xml:
<plugin><extension
point="org.eclipse.ui.editors">
<editor
class="Testeditor"
default="true"
extensions="xeb"
icon="icons/sample.gif"
id="testeditor"
name="editor">
</editor>
</plugin>
i debugged the code and found that this weird behavior is happening due to handling of global action in wrong way.I used below code to set global action handler:
public void setUndoRedoActionHandlers() {
final IActionBars actionBars = getEditorSite().getActionBars();
actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(),
mUndoAction);
actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(),
mRedoAction);
actionBars.updateActionBars();
}
i went through some links related to this issue. but couldn't understood the concept to implement this behavior.
http://wiki.eclipse.org/FAQ_How_do_I_find_out_what_view_or_editor_is_selected%3F
http://wiki.eclipse.org/FAQ_How_do_I_hook_into_global_actions,_such_as_Copy_and_Delete%3F
Can any one look into this issue. Thanks in advance.
only override the setFocus() method of MultiPageEditorPart in you editor class and call the appropriate method of setting the global action handler,like this way:
#Override
public void setFocus() {
switch (getActivePage()) {
case 0:
pageOne.setUndoRedoActionHandlers();
break;
case 1:
pageTwo.setUndoRedoActionHandlers();
break;
}
super.setFocus();
}
I have an Eclipse Editor plugin associated with .xxx filetype, how can I detect when the user switches from a document to another?
I mean when a user switches from a tab with graph1.xxx to another opened tab with graph2.xxx
I would add an IPartListener (or IPartListener2) event listener to the PartService of the Active Workbench Window, and listen for the various changes. Something similar to the following code could be used (if you register the listener inside your editor code, you should get the workbench window through the inherited methods):
Workbench.getInstance().getActiveWorkbenchWindow()
.getPartService().addPartListener(new IPartListener2() { ... }
Be careful, that both Editors and Views are parts, so some notification will be unnecessary for your job.
I have a RCP applicaton from which I need to show a GEF Editor in a modal "dialog". But since the editor framework seems to be tightly coupled to the use of a workbench window etc I need to find a why to open a new workbench window (with its own WorkbenchWindowAdvisor etc) so that I can open my GEF editor within this workbench window. Once I get this workbenchWindow opened I will set the style of the WorkbenchWindow's shell to be application modal.
I have done this in a customer project using the following components:
A static class with a method openNewWindow(String type, ...). This is the method you call to open a new window. The type argument specifies the wanted type of window.
The class looks up the specified type via a new extension point to get an ILocalWorkbenchWindowAdvisor and the initial perspective ID.
It then saves the information in global variables and calls IWorkbench.openWorkbenchWindow(perspectiveID, ...)
In ApplicationWorkbenchAdvisor.createWorkbenchWindowAdvisor(...) a new advisor is create based on the saved ILocalWorkbenchWindowAdvisor - the returned advisor basically delegates all the postWindowCreate(...), etc to the same methods in ILocalWorkbenchWindowAdvisor...
If no ILocalWorkbenchWindowAdvisor is saved - which is the case for the very first window to be opened - the type "mainWindow" is looked up and used...
It works pretty well and let all parts of the project add new windows as needed.
Use the command "org.eclipse.ui.window.newWindow" to open a new window. In your WorkbenchWindowAdvisor.preWindowOpen(), set the shell style on the IWorkbenchWindowConfigurer to be application modal. You can also hide the coolbar, menu and status bars, so it looks more like a dialog than a window.