How to customize EclipseChe menus and plugins - eclipse-che

I would like to do customization as below in Eclipse Che.
Please share the reference information such as sample etc.
Addition of original menu
Would like to add items in right-click menu of the project and header menu of Eclipse Che.
Call of extended-plugin processing from added menu
From the menu added in 1., would like to call the processing of plugin created originally.
Would like to apply the plugin extended in 2. in Eclipse Che.

Here is an example for adding toolbar, you can add your menu using the same example.
Please look into this page https://www.eclipse.org/che/docs/assemblies/sdk-actions/index.html
#Extension(title = "Sample Actions Extension", version = "1.0.0")
public class SampleActionsExtensions {
#Inject
public SampleActionsExtensions(HelloWorldAction helloWorldAction, ActionManager actionManager) {
actionManager.registerAction("helloWorldAction", helloWorldAction);
actionManager.registerAction("helloWorldActionWithIcon", helloWorldActionWithIcon);
/...
DefaultActionGroup sampleGroup = new DefaultActionGroup("Sample actions", true, actionManager);
sampleGroup.add(helloWorldAction);
// add sample group after help menu entry
DefaultActionGroup mainMenu = (DefaultActionGroup)actionManager.getAction(GROUP_MAIN_MENU);
mainMenu.add(sampleGroup);
// add the sample group to the beginning of the toolbar as well
DefaultActionGroup toolbar = (DefaultActionGroup)actionManager.getAction(IdeActions.GROUP_MAIN_TOOLBAR);
toolbar.add(helloWorldActionWithIcon);
/...
}
}

Related

GIO: How to enable a GMenuItem? GMenu enable / disable

Problem
I create a GMenuModel and set is as application app menu.
However, the items in the app are disabled.
Q: How do I enable them?
Code
GMenuModel * createMenu(){
GMenu * menu = g_menu_new();
g_menu_append(menu, "Item1", "item1_action1");
return (GMenuModel*)menu;
}
...
GMenuModel * menu = createMenu(GTK_APPLICATION(app));
gtk_application_set_app_menu(GTK_APPLICATION(app), (GMenuModel*)menu);
g_object_unref (menu);
GActionEntry actions[] = {
{"item1_action1", exampleAction, NULL, NULL, NULL}
};
g_action_map_add_action_entries(G_ACTION_MAP(app),actions, 1, NULL);
Your problem: The menu items are not connected to existing actions.
Your solution: Set the correct detailed_action when creating the menu item. (it is missing the prefix app.).
Code
GMenuModel * createMenu(){
GMenu * menu = g_menu_new();
g_menu_append(menu, "Item1", "app.item1_action1");
return (GMenuModel*)menu;
}
How to figure this out?
Run your app with the inspector: GTK_DEBUG=interactive ./a.out
Double click any item to open its properties.
Choose Actions from the combo box. That is, the ones you register with g_action_map_add_action_entries!
See the column Prefix showing app.
g_action_map_add_action_entries(G_ACTION_MAP(app),...) registers actions for the app. Therefore it adds an app prefix to the action names.
So in your menu creation you need to use the full name (ie app.item1_action1) as detailed_action name.
Be aware of the Prefix column, that says app

Akeneo category tree UI locale override

I have an Akeneo 2.3 running with 10 locales. 1 of the locales is our customised one called ab_AB.
When viewing the category tree in Settings -> Categories UI or when assigning product to categories UI, the category's label is displayed according to the locale of the logged-in user.
I would like to display the category's label value from ab_AB locale instead of the logged-in user's locale.
I have looked into /vendor/akeneo/pim-community-dev/src/Pim/Bundle/EnrichBundle/Resources/views/CategoryTree for hints of what to extend/override but not quite sure what to make of it.
To sum up what happens: the tree is generated by calling CategoryTreeController::childrenAction. The rendered twig view will format the categories using the Twig function children_response, defined in the CategoryExtension.
To set your own locale, you need to override this extension in your project (extend the class and redefine the class parameter pim_enrich.twig.category_extension.class) and override the protected method getLabel as follows:
protected function getLabel(
CategoryInterface $category,
$withCount = false,
$includeSub = false,
$relatedEntity = 'product'
) {
$category->setLocale('ab_AB');
return parent::getLabel($category, $withCount, $includeSub, $relatedEntity);
}
I successfully tested it with locale fr_FR while my PIM was in English. Category labels were then in French, both in the Settings → Categories menu and the category filter of the product grid.

how can I load a joomla module as a link?

this is my problem...
I have some of images and links that I want to load different joomla modules when user click on them.
mean each hyperlink can load another module|position
thanks all
In case that you just want to call a module's content from a url the following answer will help you.
If you just want to show / hide a module in the same page you could use something similar to my previous answer: Joomla 3 Show different modules on same position depending on toggler
Joomla provides the functionality to call a specific file of the active template by adding the tmpl=FILENAME key/value to the url's query string.
All built-in templates have a component.php file if user wants to load the template with the component only. You could check the following link for more details: Adding print pop-up functionality to a component.
You could do something similar to only show the modules that you want to load.
You could copy the component.php to a new file (I have used custom.php) and added the following php code in the <body> ... </body> part.
<?php
$jinput = JFactory::getApplication()->input;
$selectedPosition = $jinput->getString("position", "");
$selectedModule = $jinput->getString("module", "");
$selectedModuleTitle = $jinput->getString("title");
if($selectedPosition !== "") {
$modules = JModuleHelper::getModules($selectedPosition);
foreach ($modules as $module) {
echo JModuleHelper::renderModule($module);
}
} elseif ($selectedModule !== "") {
$module = JModuleHelper::getModule($selectedModule, $selectedModuleTitle);
echo JModuleHelper::renderModule($module);
}
?>
So with a similar way as loadposition / loadmodule works you could call the new template file using:
index.php?tmpl=custom&position=MODULE_POSITION
or
index.php?tmpl=custom&module=MODULE_TYPE
or
index.php?tmpl=custom&module=MODULE_TYPE&title=MODULE_TITLE
Optionally if you want to load the module with a specific style, you could pass it to the second paramter of the renderModule method like:
echo JModuleHelper::renderModule($module, array("style" => "xhtml"));
Hope this helps

How to show a module that is used in many tabs in DotNetNuke

We are new to DNN and we plan to add a product module that is in charge of adding, editing, deleting, listing, and showing the details of the products.
We have written a UserControl named ProductsList.ascx, which has AddProducts.ascx and ShowPrdoctDetail.ascx defined in it, using Host => Extensions => ProductsList => Module Definition => Add Module Control.
In admin mode,we have created a page and dragged the module in it, so that the admin of the site can add, edit, delete, and see the details of each product.
Also there is a slideshow in the homepage that shows the latest products.In addition, the products are shown in the menu.
Now, we want to redirect user to the product detail page (ShowPrdoctDetail.ascx in our case) whenever he/she clicked the product shown in slideshow or in menu.
We are aware of Globals.NavigateUrl() method, but it needs tabid and mid to redirect to a specific page and module and in DNN every added page by admin will get different tabid and mid.
Since in DNN, admin can create many pages and add this module to them, we have no idea that what tabid and mid we should pass to Globals.NavigateUrl() in order to navigate user to product details page (ShowPrdoctDetail.ascx) when user clicked on a specific product in menu or slideshow.
Any kind of help is highly appreciated.
Try save current tabid to DB when adding product detail module into page. And with ProductId, you can grab tabid of product detail, and use it to redirect to correct page.
The way I would tackle this is to create another Module Definition for the details module and give it a Friendly name like "Product Details" and add the ShowProductDetail.ascx module control as the default view of this new module definition.
Then you can drag that new module onto a page for your product details page.
In your main Product Admin module, you can create a setting view with a dropdown list that contains a list of all tabs (pages) that the "Product Details" module on.
You can use the following method to get the list of tabs in the portal that has an instance of the module:
private List<TabInfo> GetAllModuleTabsbyModuleName(string friendlyName)
{
List<TabInfo> results = new List<TabInfo>();
Dictionary<int, int> dups = new Dictionary<int, int>();
ModuleController mc = new ModuleController();
ArrayList oModules = mc.GetModulesByDefinition(base.PortalId, friendlyName);
TabController tc = new TabController();
TabCollection oTabs = tc.GetTabsByPortal(base.PortalId);
foreach (ModuleInfo oModule in oModules)
{
foreach (KeyValuePair<int, TabInfo> oTab in oTabs)
{
if (oTab.Key == oModule.TabID && !dups.ContainsKey(oModule.TabID))
{
results.Add(oTab.Value);
dups.Add(oModule.TabID, oModule.TabID);
}
}
}
return results;
}
You can bind that to the dropdown list options and an administrator could select the page that will be redirected when a product is clicked on the main module.
ddlProdDetailsTab.DataSource = GetAllModuleTabsbyModuleName("Product Details");
ddlProdDetailsTab.DataValueField = "TabID";
ddlProdDetailsTab.DataTextField = "TabName";
ddlProdDetailsTab.DataBind();
So from the settings, you know the TabId you want to redirect to, then you need the moduleId and you can create the redirect using NavigateUrl().
var pdTab = TabController.Instance.GetTab(Convert.ToInt32(Settings["ProductDetailTabId"]), PortalId);
var pdModule = pdTab.Modules.Cast<ModuleInfo>().FirstOrDefault(m => m.ModuleName == "Product Details");
var productLink = Globals.NavigateURL(pdTab.TabId, "", "mid=" + pdModule.ModuleId, "productId=" + productId);

Removing a fMath image properties dialog in ckeditor

I am a bit stuck with this so it would be great if you could help.
I am using Drupal 7 and Ckeditor 4.3. I am developing a site which has fmath equation editor integrated.
I have disabled the image button, as I don't want end users being able to upload their own images. On the other hand, users can use fMath to insert equations. The way fMath handles equation insertion is by inserting a img tag.
When users double click this image or when they right click over the image, they access the image properties dialog, where they can change source url of the image and few other things. On the url input text, they could change the source of the image so that they could insert their own images on the page, which is something I don't want.
The have been working with two different unsuccessful approaches until now trying to solve this problem:
Removing elements from the dialog, as the URL input text on the dialog (and the alt text as well).
Trying to disable the dialog itself.
I'd like to use a custom plugin to accomplish the desired behavior as I have different CKeditor profiles in Drupal.
I haven't been successful. Do you know how could I handle this undesirable behavior?
Ok, I ended up with something like this in the plugin.js file:
CKEDITOR.plugins.add( 'custom_doubleclick',
{
init: function( editor )
{
// First part, dialogDefinition allow us to remove the
// "Link" and "Advanced" tabs on the dialog
CKEDITOR.on( 'dialogDefinition', function( ev ) {
var dialogName = ev.data.name;
var dialogDefinition = ev.data.definition;
if ( dialogName == 'image' ) {
dialogDefinition.removeContents( 'Link' );
dialogDefinition.removeContents( 'advanced' );
}
});
// Second part, it disables the textUrl and txtAlt input text boxes
editor.on( 'dialogShow', function( ev ) {
var dialog = ev.data;
var dialogName = dialog.getName();
if ( dialogName == 'image' ) {
//var dialog = CKEDITOR.dialog.getCurrent();
// Get a reference to the Link Info tab.
console.log(dialog)
dialog.getContentElement( 'info','txtUrl' ).disable();
dialog.getContentElement( 'info','txtAlt' ).disable();
}
});
}
});
As you can see I didn't disable the dialog itself, but the non useful elements. I hope this can help to someone else.

Resources