Customizing oxygen eclipse

Post here questions and problems related to editing and publishing DITA content.
mu258770
Posts: 157
Joined: Mon Aug 18, 2014 4:11 pm

Customizing oxygen eclipse

Post by mu258770 »

Hi Alex,

We have customized XML menu in oxygen eclipse by creating a plugin, taking oxygen-sample-eclipse-plugin as base. In this we have used an extension point and an implementation class.

My query is, taking this as base can we customize the eclipse containing oxygen by removing some unwanted menu items. We need to remove "Run" menu from the oxygen eclipse. But we do not know how we get the extension point of the same and whether we can use the same way of java coding which we used for XML menu customization for this. Like for XML menu, we know the function as "customizeActionsContributedToDocumentMenu" for getting all the actions included in the menu.

So is there a way that we get the extension class names also which we can use for customizing other menus.

Regards,
Shabeer
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: Customizing oxygen eclipse

Post by alex_jitianu »

Hello,

Using Oxygen extensions points you can only customize menus that are contributed by Oxygen. The Run menu is contributed by a different Eclipse plugin. I think you should read about the Eclipse Rich Client Platform and how to create Rich Client Applications with it. The idea is that you are developing the plugin in an Eclipse distribution that comes with a lot of plugins meant to help you during the development process. The user though should receive a stripped down application that contains only the plugins intended for him.

Best regards,
Alex
mu258770
Posts: 157
Joined: Mon Aug 18, 2014 4:11 pm

Re: Customizing oxygen eclipse

Post by mu258770 »

Hi Alex,

Thanks for your reply!

I have one more query regarding XML menu customization in eclipse.

We have removed all unwanted sub-menu items and toolbar items of XML menu from the oxygen eclipse using the plugin
except the validation one which contains "XSV, Saxon- EE, MSXML-4.0, MSXML.NET, LIBXML".
We have removed all items using its ID which we got from plugin Menu Spy key (This we can get by pressing Alt+ Shift +F2 from eclipse and by clicking on submenu, we will get the ID). But we are not able to use this method for the above mentioned toolbar items. Please let us know the IDs of these items or the way to find these so that we can remove those as of now as these we are currently not using.

Thanks in advance!

Regards,
Shabeer
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: Customizing oxygen eclipse

Post by alex_jitianu »

Hi Shabeer,

Unfortunately that item lacks an ID. I can't really say why... You'll have to rely on the iAction.getText(). The text of this item is Validate/Custom_validation. I'll register an issue to add an ID for this item and you will get notified when we do it. This way you will be able to update your filtering code to also look at the ID.

Best regards,
Alex
mu258770
Posts: 157
Joined: Mon Aug 18, 2014 4:11 pm

Re: Customizing oxygen eclipse

Post by mu258770 »

Hi Alex,

I have tried using getText() method for removing the specified item, but I am not able to. Please see the below code I have used:

Code: Select all

        if (iAction != null && "Validate/Custom_validation".equals(iAction.getText())) {
             iterator.remove();
           }
I have also tried with just "Validate" as text and just "Custom Validation" as text. But these also not worked.

Please let me know the way forward.

Regards,
Shabeer
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: Customizing oxygen eclipse

Post by alex_jitianu »

Hi Shabeer,

Please try this:

Code: Select all


if (iAction != null && "Validate/Custom_validation".equals(iAction.getId())) {
iterator.remove();
}
Best regards,
Alex
mu258770
Posts: 157
Joined: Mon Aug 18, 2014 4:11 pm

Re: Customizing oxygen eclipse

Post by mu258770 »

Hi Alex,

This one also not working

Please suggest me some other way.

Regards,
Shabeer
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: Customizing oxygen eclipse

Post by alex_jitianu »

Hi Shabeer,

From the previous messages I understand that you were able to filter other toolbar items, right? If that's the case I suggest logging each item like this:

Code: Select all

public List<IAction> customizeActionsContributedToDocumentToolbar(
List<IAction> actions) {
for (Iterator iterator2 = actions.iterator(); iterator2.hasNext();) {
IAction iAction = (IAction) iterator2.next();

if (iAction != null) {
System.out.println(
"Action |" + iAction.getText()
+ "| id |" + iAction.getId()
+ "| defID " + iAction.getActionDefinitionId()
+ " menu " + iAction.getMenuCreator());
}
}
return actions;
}
Instead of using System.out.println() like in the the code above I suggest appending to a file on disk. After seeing the log you should be able to identify what uniquely identifies the entries you want to remove.

Best regards,
Alex
mu258770
Posts: 157
Joined: Mon Aug 18, 2014 4:11 pm

Re: Customizing oxygen eclipse

Post by mu258770 »

Hi Alex,

I have tried the method you have suggested, but was unsuccessful.

I have one other query,
In XML menu, I am able to remove Validate cached option from the XML menu bar using the ID "com.oxygenxml.editor.validate.cached", but I am not able to remove the same from the toolbar. In toolbar all validate related options are bundled together into one. Can't I remove only one or two items from the group. If possible, please tell me the way forward.

Thanks in advance!

Regards,
Shabeer
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: Customizing oxygen eclipse

Post by alex_jitianu »

Hi Shabeer,
I have tried the method you have suggested, but was unsuccessful.
I personally tried this code with an Author 16.1 and it worked:

Code: Select all

	@Override
public List<IAction> customizeActionsContributedToDocumentToolbar(List<IAction> actions) {
for (Iterator iterator2 = actions.iterator(); iterator2.hasNext();) {
IAction iAction = (IAction) iterator2.next();
if (iAction != null) {
if ("Validate/Custom_validation".equals(iAction.getId())) {
iterator2.remove();
}
}
}
return actions;
}
Can you tell me if in your case customizeActionsContributedToDocumentToolbar() is being called at all? Were you able to filter any other toolbar actions?
In XML menu, I am able to remove Validate cached option from the XML menu bar using the ID "com.oxygenxml.editor.validate.cached", but I am not able to remove the same from the toolbar. In toolbar all validate related options are bundled together into one. Can't I remove only one or two items from the group. If possible, please tell me the way forward.
Unfortunately not. This type of drop down actions have a menu creator and from the SWT API alone you can't alter in any way the created menu. I will add a feature request for a new API that will intercept the menu creation. Until we introduce this API I can offer this solution. What you can do is remove the drop down menu all together and keep just the Validate action (you're actually adding a chameleon action that delegates to the validation one), like this:

Code: Select all

	@Override
public List<IAction> customizeActionsContributedToDocumentToolbar(List<IAction> actions) {
IAction validateAction = null;
for (Iterator iterator2 = actions.iterator(); iterator2.hasNext();) {
IAction iAction = (IAction) iterator2.next();
if (iAction != null) {
if ("Validate/Custom_validation".equals(iAction.getId())) {
iterator2.remove();
} else if ("Validate/Validation".equals(iAction.getId())) {
validateAction = iAction;
iterator2.remove();
}
}
}

final IAction va = validateAction;
actions.add(new Action(validateAction.getText(), validateAction.getImageDescriptor()) {
@Override
public void run() {
va.run();
}
});
return actions;
}
Best regards,
Alex
mu258770
Posts: 157
Joined: Mon Aug 18, 2014 4:11 pm

Re: Customizing oxygen eclipse

Post by mu258770 »

Hi Alex,

Thanks for the quick response again!

My eclipse version is 4.3 and Oxygen is Oxygen author 16.0.
Can you tell me if in your case customizeActionsContributedToDocumentToolbar() is being called at all? Were you able to filter any other toolbar actions?
I am able to remove other XML toolbar entries. I am only facing problem with removing the Custom validation complete list and removing validate cached from drop down list of Validate.

I have tried both codes you have provided and are not working.
The second code is creating some error in the oxygen eclipse while launching after creating and placing the plugin in dropins. Please find the error log details:

Code: Select all

java.lang.NullPointerException
   at com.sdk.samples.customizations.eclipse.CustomActionBarContributorCustomizer.customizeActionsContributedToDocumentToolbar(CustomActionBarContributorCustomizer.java:90)
   at com.oxygenxml.editor.editors.eb.contributeToToolBar(Unknown Source)
   at org.eclipse.ui.part.EditorActionBarContributor.init(EditorActionBarContributor.java:168)
   at org.eclipse.ui.editors.text.TextEditorActionContributor.init(TextEditorActionContributor.java:159)
   at org.eclipse.ui.part.EditorActionBarContributor.init(EditorActionBarContributor.java:146)
   at org.eclipse.ui.internal.EditorReference.createEditorActionBars(EditorReference.java:443)
   at org.eclipse.ui.internal.EditorReference.initialize(EditorReference.java:355)
   at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:306)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
   at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:877)
   at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:857)
   at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:119)
   at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:333)
   at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:254)
   at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
   at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:102)
   at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:71)
   at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:53)
   at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:129)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:949)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:633)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700)
   at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685)
   at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.showTab(StackRenderer.java:1147)
   at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.postProcess(LazyStackRenderer.java:96)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:649)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700)
   at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685)
   at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:62)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:645)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$6.run(PartRenderingEngine.java:526)
   at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:511)
   at org.eclipse.e4.ui.workbench.renderers.swt.ElementReferenceRenderer.createWidget(ElementReferenceRenderer.java:61)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:949)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:633)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700)
   at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685)
   at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:62)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:645)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700)
   at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685)
   at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:62)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:645)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700)
   at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685)
   at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:62)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:645)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700)
   at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685)
   at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:62)
   at org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveRenderer.processContents(PerspectiveRenderer.java:59)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:645)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700)
   at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685)
   at org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveStackRenderer.showTab(PerspectiveStackRenderer.java:103)
   at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.postProcess(LazyStackRenderer.java:96)
   at org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveStackRenderer.postProcess(PerspectiveStackRenderer.java:77)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:649)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700)
   at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685)
   at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:62)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:645)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700)
   at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685)
   at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:62)
   at org.eclipse.e4.ui.workbench.renderers.swt.WBWRenderer.processContents(WBWRenderer.java:581)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:645)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700)
   at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1042)
   at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
   at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140)
   at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611)
   at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
   at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
   at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
   at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
   at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
   at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
   at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
Please let me know how can I proceed.

Regards,
Shabeer
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: Customizing oxygen eclipse

Post by alex_jitianu »

Hi,

The exception is probably because the validate action is not identified and my code doesn't cover that case (like I said in my situation I'm able to find it). Just add a NULL test:

Code: Select all


if (validateAction != null) {
final IAction va = validateAction;
actions.add(new Action(validateAction.getText(), validateAction.getImageDescriptor()) {
@Override
public void run() {
va.run();
}
});
}
Could you test with an version 16.1 Author plugin and tell me if it works? Have you tried to log the ID, definitionID and text of all the actions received on customizeActionsContributedToDocumentToolbar()? Can you send me that list?

How do

Best regards,
Alex
mu258770
Posts: 157
Joined: Mon Aug 18, 2014 4:11 pm

Re: Customizing oxygen eclipse

Post by mu258770 »

Hi Alex,
Could you test with an version 16.1 Author plugin and tell me if it works?
I have tested the code in author 16.1 and it worked!

But I need this to work in 16.0. Please let me know what changes I can do to make it work in AUTHOR 16.0.
Have you tried to log the ID, definitionID and text of all the actions received on customizeActionsContributedToDocumentToolbar()?
I have tried this, but it didn't work!

Regards,
Shabeer
mu258770
Posts: 157
Joined: Mon Aug 18, 2014 4:11 pm

Re: Customizing oxygen eclipse

Post by mu258770 »

Hi Alex,

Thank you for the offline reply!

Now, by using the code provided, I am able to list all the IDs required to a file. So now I could remove Custom validation option using the description "Custom Validation" and I could remove validate list from toolbar .

Also I am able to get separate validate icon in the toolbar. But I need one more option "Check Well-formedness" also in the toolbar. If possible I need to get the tooltip for these icons and arrange the icons same as in the XML menu bar. How can I achieve these.

Thanks a lot in advance!

Regards,
Shabeer
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: Customizing oxygen eclipse

Post by alex_jitianu »

Hi Shabeer,

You can intercept the Check Wellformed action from the menu and add it in the toolbar (luckily the customize menu callback comes first). Like this:

Code: Select all

public class CustomActionBarContributorCustomizer extends ActionBarContributorCustomizer {
IAction wellformed = null;
@Override
public List<IAction> customizeActionsContributedToDocumentMenu(
List<IAction> actions) {
for (IAction iAction : actions) {
if (iAction != null) {
if ("com.oxygenxml.editor.wellform".equals(iAction.getActionDefinitionId())) {
wellformed = iAction;
break;
}
}
}
return actions;
}

@Override
public List<IAction> customizeActionsContributedToDocumentToolbar(List<IAction> actions) {
IAction validateAction = null;
for (Iterator iterator2 = actions.iterator(); iterator2.hasNext();) {
IAction iAction = (IAction) iterator2.next();
if (iAction != null) {

if ("Validate/Custom_validation".equals(iAction.getId()) || "Custom Validation".equals(iAction.getDescription())) {
iterator2.remove();
} else if ("Validate/Validation".equals(iAction.getId()) || "Validate".equals(iAction.getDescription())) {
validateAction = iAction;
iterator2.remove();
}
}
}

if (validateAction != null) {
final IAction va = validateAction;
actions.add(new Action(validateAction.getText(), validateAction.getImageDescriptor()) {
@Override
public void run() {
va.run();
}
});
}

if (wellformed != null) {
actions.add(new Action(wellformed.getText(), wellformed.getImageDescriptor()) {
@Override
public void run() {
wellformed.run();
}
});
}
return actions;
}

@Override
public void customizeAuthorPageInternalCoolbar(CoolBar arg0,
WSAuthorEditorPage arg1) {}
}
mu258770
Posts: 157
Joined: Mon Aug 18, 2014 4:11 pm

Re: Customizing oxygen eclipse

Post by mu258770 »

Hi team,

I have a query which is a little generic type. For the XML menu customization, we have created the plugin and it is working fine. But the plugin version is SNAPSHOT 1.0. The same is coming in the plugin name also. We need to change that version to 1.0.

Please let us know how we can change SNAPSHOT 1.0 to 1.0?If I directly change, I am getting error.

Also after creating the plugin, in manifest "built-by" term is coming with my system login id. How we can change this or remove the same?

Thanks in advance!

Best Regards,
Shabeer
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: Customizing oxygen eclipse

Post by alex_jitianu »

Hi Shabeer,
Please let us know how we can change SNAPSHOT 1.0 to 1.0?If I directly change, I am getting error.
I understand that you tried changing the version directly oxygen-sample-eclipse-plugin\pom.xml? If you just add a new version tag instead of modifying the parent one, it should work:

Code: Select all

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.sdk.samples</groupId>
<artifactId>my.project</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<name>oXygen Sample Eclipse Extension</name>
<version>1.0.3</version>
Maven also has a release plugin that is intended to be used when you want to make an official release.
Also after creating the plugin, in manifest "built-by" term is coming with my system login id. How we can change this or remove the same?
Edit /oxygen-sample-eclipse-plugin/META-INF/MANIFEST.MF and set "Built-By" to the desired value.

Best regards,
Alex
mu258770
Posts: 157
Joined: Mon Aug 18, 2014 4:11 pm

Re: Customizing oxygen eclipse

Post by mu258770 »

Hi team,

I have a query related to XML menu customization in oxygen 16.1 eclipse plugin.

We have done the customization for removing some XML menu items and added it in the order which we need based on the code which was provided by you.

Please see the below code in which we are adding Format and Indent option to XML toolbar(we have only included just the portion where we are adding the format and indent in the GUI)

Code: Select all


    //Adding Format and Indent to XML toolbar
if (formatIndent != null) {
actions.add(new Action(formatIndent.getText(),formatIndent.getImageDescriptor()) {
@Override
public void run() {
formatIndent.run();
}
});
}
But one problem is there with the code that the added "format and indent" item is always enabled in the menu. It is not checking the context. For example, Format and Indent should not be enabled in Author mode. But it is enabled.

Can we change this behaviour. Is there a way to fix this?

Regards,
Shabeer
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: Customizing oxygen eclipse

Post by Radu »

Hi Shabeer,

I'm not exactly sure how you obtain the original formatIndent but have you tried adding a property changed listener to it and when the action becomes disabled/enabled to also disable/enable your wrapper action? Again, why are you wrapping it in your own action instead of adding directly the original action?

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
mu258770
Posts: 157
Joined: Mon Aug 18, 2014 4:11 pm

Re: Customizing oxygen eclipse

Post by mu258770 »

Hi Radu,

In our customized oxygen we wanted to remove one of the item from the validation group in the toolbar. For this we have removed the validation group from the toolbar and kept the required validation items separate by using the similar above code, as Alex suggested.

But by doing this, the items which are there after validation group in toolbar are coming before validation. This completely changes the order of the toolbar items. So by using below code, we have taken the action of the item, say "Format and Indent", and added back to the toolbar using the code which we shared in the last mail.

Code: Select all

   if (com.oxygenxml.editor.prettyPrint.equals(iAction.getActionDefinitionId())) {
formatIndent = iAction;
iterator2.remove();
}
Now we got the proper order, but it is not getting disabled when it should be.

This is the issue we are facing.

Regards,
Shabeer
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: Customizing oxygen eclipse

Post by Radu »

Hi,

Just to update this thread, in Oxygen 17 some of the actions in the list received on the customizeActionsContributedToDocumentToolbar callback implement a special type of API interface called com.oxygenxml.editor.editors.IDropDownMenuAction allowing you to filter actions from it.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: Customizing oxygen eclipse

Post by Radu »

Hi Shabeer,

If you cannot easily upgrade to Oxygen 17.0:

You said something like:
So by using below code, we have taken the action of the item, say "Format and Indent", and added back to the toolbar using the code which we shared in the last mail.
So did you add a wrapper action over the original action? Or did you follow by advice of adding the action directly or of adding a property changed listener to the original action in order to also enable/disable the proxy action?

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply