Disable eclipse plugins programmatically - eclipse-plugin

I want to create my own update system and during update I need to remove some plugins but they are in use - how to disable it programmatically?

Get a BundleContext via the bundle activator of the plugin that should stop the other plugin/bundle and do something like:
for (Bundle bundle: bundleContext.getBundles()) {
if ("my.bundle.symbolic.name".equals(bundle.getSymbolicName())) {
bundle.stop();
break;
}
}
See also Bundle.stop(int options)

Related

How to customize WAR plugin in subproject in Gradle build script (Kotlin)

I create a Gradle project with several sub-modules, and one module needs war plugin, I just want to customize the web app directory, but the code does not work:
apply {
plugin("war")
plugin("org.gretty")
}
// cannot work
tasks.getByName("war") {
from("src/main/webfiles")
}
// cannot work either
tasks.war {
webAppDirName = "src/main/webfiles"
}
//... other code
This is how I code in the sub-project subproject.gradle.kts file, How to solve this? Thanks for any help!
Solved with the code:
configure<WarPluginConvention>{
webAppDirName = "src/main/webfiles"
}

How to enable Safari App Extension programmatically?

I'm developing a Safari App Extension inside a macOS app. When a user installs this app, the extension is added to Safari, but it's disabled by default. We can detect the state of extension by using SFSafariExtensionManager class via its getStateOfSafariExtension method.
Now I want to enable the extension state programmatically if it is disabled. How can I achieve that?
Or do anyone have any idea where the preferences / app extensions settings are stored in macOS?
You can create a button such as "Open extension preferences" to show Safari preferences directly for your extension then the user could enable it.
The code for your app:
import SafariServices
func enableExtension () {
SFSafariApplication.showPreferencesForExtension(withIdentifier: YOUR_EXTENSION_IDENTIFIER) { (error) in
NSLog("Error \(String(describing: error))")
}
}
SFSafariApplication could be used in Cocoa app only (not extension).

Prestashop 1.7.1 - Register a new hook

I am trying to display a top banner in my theme (which is not the default classic one).
Specifically I modify header.tpl to include this (as in classic theme):
{block name='header_banner'}
<div class="header-banner">
{hook h='displayBanner'}
</div>
{/block}
But displayBanner does not appear as a valid hook to attach modules to it.
Do I have to register the hook somewhere else? If so, which would be the code?
This question further elaborates this one.
Thanks,
Registering hooks happens in a modules install method.
You can do the following for example in your module:
public function install()
{
$installed = (parent::install() && $this->registerHook('displayBanner'));
if ( $installed ) {
return true;
} else {
$this->uninstall();
return false;
}
}
then uninstall and reinstall your module.
You need to add your new hook into a theme.yml and set up the module on it, and after that just reset your theme to default Design->Theme & Logo->Reset to defaults.
theme.yml
hooks:
modules_to_hook:
displayBanner:
- your_module_name
example
Caveat: after resetting your theme will look like it is set up in the theme.yml file. If you have done any changes in the theme appearance from admin panel and didn't include it in theme.yml they gonna be lost.

Adding PatternMatchListener to Eclipse Console in which stage of View Lifecycle

I am developing an Eclipse plug-in which will be triggered by a specific pattern string found (e.g., stack trace) in the default console opened in Eclipse and will show some notification in a custom view. I know how add the listener to the available consoles.But I am not sure in which phase of Eclipse View life cycle I need to add the listener. Currently I am adding in createPartControl which is not what I want, because it forces to me to open the view manually to perform the binding the listener with the consoles.
public void createPartControl(Composite parent) {
//got the default console from ConsolePlugin
TextConsole tconsole=(TextConsole)defaultConsole;
tconsole.addPatternMatchListener(new IPatternMatchListener() {
// implementation codes goes here
}
}
Any help will be appreciated.

MVC4 Internet Application template bundle enabled by default?

I am using Mvc 4 project from Internet Application template. Why bundle feature does not enabled by default or am I missing something?
There is no such methods like this in Mvc4 as mentioned by other post:
BundleTable.Bundles.RegisterTemplateBundles();
BundleTable.Bundles.EnableDefaultBundles();
Update: This how to enable bundle in debug mode
BundleTable.EnableOptimizations = true;
after registering bundles.
Bundles are registered and enabled by default. When you run in Release mode (debug="false") in your web.config the #Script.Render helper will concatenate and minify the resources into a single file. If you run in Debug mode then each script will be rendered separately.
I run into a similiar issue and my solution is this:
public class bundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
// bundle as usual
#if(!DEBUG)
BundleTable.EnableOptimizations = true;
#endif
}
}
This way, when I launch it in Release mode, it does minification and bundling but if I launch it in Debug mode, it doesn't.