repo-reorg-2020: moved sts4-relevant spring-ide bundles from https://github.com/spring-projects/spring-ide/releases/tag/REPO-REORG-2020 into sts4 repo
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.springframework.ide.eclipse.boot.restart</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,7 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
@@ -0,0 +1,59 @@
|
||||
eclipse.preferences.version=1
|
||||
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
|
||||
sp_cleanup.add_default_serial_version_id=true
|
||||
sp_cleanup.add_generated_serial_version_id=false
|
||||
sp_cleanup.add_missing_annotations=true
|
||||
sp_cleanup.add_missing_deprecated_annotations=true
|
||||
sp_cleanup.add_missing_methods=false
|
||||
sp_cleanup.add_missing_nls_tags=false
|
||||
sp_cleanup.add_missing_override_annotations=true
|
||||
sp_cleanup.add_missing_override_annotations_interface_methods=true
|
||||
sp_cleanup.add_serial_version_id=false
|
||||
sp_cleanup.always_use_blocks=true
|
||||
sp_cleanup.always_use_parentheses_in_expressions=false
|
||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_functional_interfaces=false
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=false
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
sp_cleanup.insert_inferred_type_arguments=false
|
||||
sp_cleanup.make_local_variable_final=true
|
||||
sp_cleanup.make_parameters_final=false
|
||||
sp_cleanup.make_private_fields_final=true
|
||||
sp_cleanup.make_type_abstract_if_missing_method=false
|
||||
sp_cleanup.make_variable_declarations_final=false
|
||||
sp_cleanup.never_use_blocks=false
|
||||
sp_cleanup.never_use_parentheses_in_expressions=true
|
||||
sp_cleanup.on_save_use_additional_actions=true
|
||||
sp_cleanup.organize_imports=false
|
||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
|
||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||
sp_cleanup.remove_private_constructors=true
|
||||
sp_cleanup.remove_redundant_type_arguments=false
|
||||
sp_cleanup.remove_trailing_whitespaces=true
|
||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
|
||||
sp_cleanup.remove_unnecessary_casts=false
|
||||
sp_cleanup.remove_unnecessary_nls_tags=false
|
||||
sp_cleanup.remove_unused_imports=false
|
||||
sp_cleanup.remove_unused_local_variables=false
|
||||
sp_cleanup.remove_unused_private_fields=true
|
||||
sp_cleanup.remove_unused_private_members=false
|
||||
sp_cleanup.remove_unused_private_methods=true
|
||||
sp_cleanup.remove_unused_private_types=true
|
||||
sp_cleanup.sort_members=false
|
||||
sp_cleanup.sort_members_all=false
|
||||
sp_cleanup.use_anonymous_class_creation=false
|
||||
sp_cleanup.use_blocks=false
|
||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||
sp_cleanup.use_lambda=true
|
||||
sp_cleanup.use_parentheses_in_expressions=false
|
||||
sp_cleanup.use_this_for_non_static_field_access=false
|
||||
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
||||
sp_cleanup.use_this_for_non_static_method_access=false
|
||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||
@@ -0,0 +1,17 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-SymbolicName: org.springframework.ide.eclipse.boot.restart;singleton:=true
|
||||
Bundle-Version: 4.8.1.qualifier
|
||||
Bundle-Vendor: Pivotal Inc
|
||||
Bundle-Name: Spring Boot Devtools Easy Restart
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.ui.console,
|
||||
org.eclipse.debug.ui;bundle-version="3.9.0",
|
||||
org.eclipse.ui.workbench.texteditor;bundle-version="3.9.0",
|
||||
org.springframework.ide.eclipse.boot.launch,
|
||||
org.springframework.ide.eclipse.boot
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Bundle-Activator: org.springframework.ide.eclipse.boot.restart.RestartPlugin
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Automatic-Module-Name: org.springframework.ide.eclipse.boot.restart
|
||||
@@ -0,0 +1,6 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml,\
|
||||
icons/
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 555 B |
33
eclipse-extensions/org.springframework.ide.eclipse.boot.restart/plugin.xml
Executable file
33
eclipse-extensions/org.springframework.ide.eclipse.boot.restart/plugin.xml
Executable file
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
<extension
|
||||
id="org.springframework.ide.eclipse.boot.restart.consolePage"
|
||||
point="org.eclipse.ui.console.consolePageParticipants">
|
||||
<consolePageParticipant
|
||||
class="org.springframework.ide.eclipse.boot.restart.RestartConsolePageParticipant"
|
||||
id="org.springframework.ide.eclipse.boot.restart.consolePage.consolePageParticipant">
|
||||
<enablement>
|
||||
<instanceof
|
||||
value="org.eclipse.debug.internal.ui.views.console.ProcessConsole">
|
||||
</instanceof></enablement>
|
||||
</consolePageParticipant>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.commands">
|
||||
<command
|
||||
name="Trigger Restart"
|
||||
categoryId="org.eclipse.debug.ui.category.run"
|
||||
description="Restart Spring Boot Application"
|
||||
id="org.springframework.ide.eclipse.boot.restart.commands.restart">
|
||||
</command>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.bindings">
|
||||
<key
|
||||
commandId="org.springframework.ide.eclipse.boot.restart.commands.restart"
|
||||
contextId="org.eclipse.debug.ui.console"
|
||||
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
|
||||
sequence="M1+R"/>
|
||||
</extension>
|
||||
</plugin>
|
||||
53
eclipse-extensions/org.springframework.ide.eclipse.boot.restart/pom.xml
Executable file
53
eclipse-extensions/org.springframework.ide.eclipse.boot.restart/pom.xml
Executable file
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot.ide</groupId>
|
||||
<artifactId>org.springframework.boot.ide</artifactId>
|
||||
<version>4.8.1-SNAPSHOT</version>
|
||||
<relativePath>../../eclipse-distribution/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>org.springframework.ide.eclipse</groupId>
|
||||
<artifactId>org.springframework.ide.eclipse.boot.restart</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.eclipse.tycho</groupId>
|
||||
<artifactId>tycho-source-plugin</artifactId>
|
||||
<version>${tycho-version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>plugin-source</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>plugin-source</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.eclipse.tycho</groupId>
|
||||
<artifactId>tycho-p2-plugin</artifactId>
|
||||
<version>${tycho-version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>second-generate-p2-metadata</id>
|
||||
<goals>
|
||||
<goal>p2-metadata</goal>
|
||||
</goals>
|
||||
<phase>verify</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,109 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="org.eclipse.m2e.maveneclipse" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.schema plugin="org.eclipse.m2e.maveneclipse" id="org.eclipse.m2e.maveneclipse.facetconfigprovider" name="Facet Config Provider for maven-eclipse-plugin"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter description of this extension point.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<element name="extension">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.element />
|
||||
</appinfo>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence minOccurs="1" maxOccurs="unbounded">
|
||||
<element ref="facetconfigprovider"/>
|
||||
</sequence>
|
||||
<attribute name="point" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="id" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="name" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="facetconfigprovider">
|
||||
<complexType>
|
||||
<attribute name="facetid" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="class" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute kind="java" basedOn=":org.eclipse.m2e.maveneclipse.handler.additionalprojectfacets.FacetConfigProvider"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="since"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter the first release in which this extension point appears.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="examples"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter extension point usage example here.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="apiinfo"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter API information here.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="implementation"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter information about supplied implementation of this extension point.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
|
||||
</schema>
|
||||
@@ -0,0 +1,135 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Phil Webb - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.eclipse.boot.restart;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Date;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
|
||||
import org.eclipse.debug.core.model.IProcess;
|
||||
import org.eclipse.debug.internal.ui.views.console.ProcessConsole;
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.ui.texteditor.IUpdate;
|
||||
import org.springframework.ide.eclipse.boot.core.BootPropertyTester;
|
||||
import org.springframework.ide.eclipse.boot.launch.BootLaunchConfigurationDelegate;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class RestartAction extends Action implements IUpdate {
|
||||
|
||||
private static final String[] CLASSPATH_PREFIX = { "-classpath ", "-cp " };
|
||||
|
||||
private ProcessConsole console;
|
||||
|
||||
public RestartAction(ProcessConsole console) {
|
||||
super("Trigger Restart");
|
||||
setToolTipText("Trigger devtools-based Restart of Spring Boot Application");
|
||||
setImageDescriptor(RestartPluginImages
|
||||
.getImageDescriptor(RestartConstants.IMG_RESTART_ICON));
|
||||
this.console = console;
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void update() {
|
||||
boolean bootProject = false;
|
||||
boolean devtools = false;
|
||||
boolean running = !this.console.getProcess().isTerminated();
|
||||
|
||||
try {
|
||||
IProcess process = this.console.getProcess();
|
||||
ILaunchConfiguration launchConfiguration = process.getLaunch().getLaunchConfiguration();
|
||||
if (launchConfiguration!=null) {
|
||||
ILaunchConfigurationType type = launchConfiguration.getType();
|
||||
if (type!=null) {
|
||||
ILaunchConfigurationDelegate delegate = type.getDelegate();
|
||||
|
||||
bootProject = delegate instanceof BootLaunchConfigurationDelegate;
|
||||
|
||||
IProject project = BootLaunchConfigurationDelegate.getProject(launchConfiguration);
|
||||
devtools = BootPropertyTester.hasDevtools(project);
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
setEnabled(running & bootProject & devtools);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!this.console.getProcess().isTerminated()) {
|
||||
IProcess process = this.console.getProcess();
|
||||
String commandLine = process
|
||||
.getAttribute("org.eclipse.debug.core.ATTR_CMDLINE");
|
||||
String classPath = getClassPath(commandLine);
|
||||
File folder = getFolder(classPath);
|
||||
if (folder != null) {
|
||||
writeTriggerFile(new File(folder, ".reloadtrigger"));
|
||||
System.out.println(folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getClassPath(String commandLine) {
|
||||
for (String prefix : CLASSPATH_PREFIX) {
|
||||
int startIndex = commandLine.indexOf(prefix);
|
||||
if (startIndex != -1) {
|
||||
return commandLine.substring(startIndex + prefix.length()).trim();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private File getFolder(String classPath) {
|
||||
if (classPath == null) {
|
||||
return null;
|
||||
}
|
||||
int index = classPath.indexOf(File.pathSeparator);
|
||||
String element = (index == -1 ? classPath : classPath.substring(0, index));
|
||||
if ("".equals(element)) {
|
||||
return null;
|
||||
}
|
||||
File file = new File(element);
|
||||
if (file.isDirectory() && file.exists()) {
|
||||
return file;
|
||||
}
|
||||
return (index == -1 ? null : getFolder(classPath.substring(index + 1)));
|
||||
}
|
||||
|
||||
private void writeTriggerFile(File file) {
|
||||
try {
|
||||
OutputStream outputStream = new FileOutputStream(file);
|
||||
try {
|
||||
Date date = new Date();
|
||||
String content = date.toString() + " " + date.getTime();
|
||||
outputStream.write(content.getBytes());
|
||||
}
|
||||
finally {
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new IllegalStateException("Unable to write trigger file", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
this.console = null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Phil Webb - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.eclipse.boot.restart;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.debug.core.DebugEvent;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.IDebugEventSetListener;
|
||||
import org.eclipse.debug.core.model.IProcess;
|
||||
import org.eclipse.debug.internal.ui.DebugUIPlugin;
|
||||
import org.eclipse.debug.internal.ui.views.console.ProcessConsole;
|
||||
import org.eclipse.jface.action.IToolBarManager;
|
||||
import org.eclipse.ui.console.IConsole;
|
||||
import org.eclipse.ui.console.IConsoleConstants;
|
||||
import org.eclipse.ui.console.IConsolePageParticipant;
|
||||
import org.eclipse.ui.contexts.IContextActivation;
|
||||
import org.eclipse.ui.contexts.IContextService;
|
||||
import org.eclipse.ui.handlers.IHandlerActivation;
|
||||
import org.eclipse.ui.handlers.IHandlerService;
|
||||
import org.eclipse.ui.part.IPageBookViewPage;
|
||||
import org.eclipse.ui.part.IPageSite;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class RestartConsolePageParticipant implements IConsolePageParticipant,
|
||||
IDebugEventSetListener {
|
||||
|
||||
private static final String DEBUG_CONTEXT_ID = "org.eclipse.debug.ui.console"; //$NON-NLS-1$;
|
||||
|
||||
// See ProcessConsolePageParticipant
|
||||
|
||||
private IPageBookViewPage page;
|
||||
|
||||
private ProcessConsole console;
|
||||
|
||||
private RestartAction restart;
|
||||
|
||||
private IContextActivation activatedContext;
|
||||
|
||||
private IHandlerActivation activatedHandler;
|
||||
|
||||
private RestartHandler restartHandler;
|
||||
|
||||
public void init(IPageBookViewPage page, IConsole console) {
|
||||
init(page, (ProcessConsole) console);
|
||||
}
|
||||
|
||||
private void init(IPageBookViewPage page, ProcessConsole console) {
|
||||
this.restart = new RestartAction(console);
|
||||
this.page = page;
|
||||
this.console = console;
|
||||
this.restartHandler = new RestartHandler();
|
||||
DebugPlugin.getDefault().addDebugEventListener(this);
|
||||
configureToolBar(page.getSite().getActionBars().getToolBarManager());
|
||||
}
|
||||
|
||||
private void configureToolBar(IToolBarManager manager) {
|
||||
manager.prependToGroup(IConsoleConstants.LAUNCH_GROUP, this.restart);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
DebugPlugin.getDefault().removeDebugEventListener(this);
|
||||
if (this.restart != null) {
|
||||
this.restart.dispose();
|
||||
this.restart = null;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public Object getAdapter(Class adapter) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void activated() {
|
||||
IPageSite site = this.page.getSite();
|
||||
if (this.activatedContext == null && this.activatedHandler == null) {
|
||||
IHandlerService handlerService = (IHandlerService) site
|
||||
.getService(IHandlerService.class);
|
||||
IContextService contextService = (IContextService) site
|
||||
.getService(IContextService.class);
|
||||
this.activatedContext = contextService.activateContext(DEBUG_CONTEXT_ID);
|
||||
this.activatedHandler = handlerService
|
||||
.activateHandler("org.springframework.ide.eclipse.boot.restart."
|
||||
+ "commands.restart", this.restartHandler); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void deactivated() {
|
||||
IPageSite site = this.page.getSite();
|
||||
IHandlerService handlerService = (IHandlerService) site
|
||||
.getService(IHandlerService.class);
|
||||
IContextService contextService = (IContextService) site
|
||||
.getService(IContextService.class);
|
||||
handlerService.deactivateHandler(this.activatedHandler);
|
||||
contextService.deactivateContext(this.activatedContext);
|
||||
this.activatedContext = null;
|
||||
this.activatedHandler = null;
|
||||
}
|
||||
|
||||
public void handleDebugEvents(DebugEvent[] events) {
|
||||
for (int i = 0; i < events.length; i++) {
|
||||
DebugEvent event = events[i];
|
||||
if (event.getSource().equals(getProcess())) {
|
||||
DebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
RestartAction action = RestartConsolePageParticipant.this.restart;
|
||||
if (action != null) {
|
||||
action.update();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected IProcess getProcess() {
|
||||
return (this.console != null ? this.console.getProcess() : null);
|
||||
}
|
||||
|
||||
private class RestartHandler extends AbstractHandler {
|
||||
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||
restart.run();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Phil Webb - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.eclipse.boot.restart;
|
||||
|
||||
public interface RestartConstants {
|
||||
|
||||
public static final String PLUGIN_ID = "org.springframework.ide.eclipse.boot.restart"; //$NON-NLS-1$;
|
||||
|
||||
String IMG_RESTART_ICON = "IMG_RESTART_ICON"; //$NON-NLS-1$
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Phil Webb - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.eclipse.boot.restart;
|
||||
|
||||
import org.eclipse.jface.resource.ImageRegistry;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
|
||||
public class RestartPlugin extends AbstractUIPlugin {
|
||||
|
||||
@Override
|
||||
protected ImageRegistry createImageRegistry() {
|
||||
return RestartPluginImages.initializeImageRegistry();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Phil Webb - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.eclipse.boot.restart;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import org.eclipse.core.runtime.FileLocator;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.resource.ImageRegistry;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.osgi.framework.Bundle;
|
||||
|
||||
public class RestartPluginImages {
|
||||
|
||||
private static ImageRegistry imageRegistry;
|
||||
|
||||
private static String ICONS_PATH = "$nl$/icons/full/"; //$NON-NLS-1$
|
||||
|
||||
private static void declareImages() {
|
||||
declareRegistryImage(RestartConstants.IMG_RESTART_ICON, ICONS_PATH
|
||||
+ "refresh_tab.png"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private final static void declareRegistryImage(String key, String path) {
|
||||
ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor();
|
||||
Bundle bundle = Platform.getBundle(RestartConstants.PLUGIN_ID);
|
||||
URL url = null;
|
||||
if (bundle != null) {
|
||||
url = FileLocator.find(bundle, new Path(path), null);
|
||||
if (url != null) {
|
||||
desc = ImageDescriptor.createFromURL(url);
|
||||
}
|
||||
}
|
||||
imageRegistry.put(key, desc);
|
||||
}
|
||||
|
||||
public static ImageRegistry getImageRegistry() {
|
||||
if (imageRegistry == null) {
|
||||
initializeImageRegistry();
|
||||
}
|
||||
return imageRegistry;
|
||||
}
|
||||
|
||||
public synchronized static boolean isInitialized() {
|
||||
return imageRegistry != null;
|
||||
}
|
||||
|
||||
public synchronized static ImageRegistry initializeImageRegistry() {
|
||||
if (imageRegistry == null) {
|
||||
imageRegistry = new ImageRegistry(PlatformUI.getWorkbench().getDisplay());
|
||||
declareImages();
|
||||
}
|
||||
return imageRegistry;
|
||||
}
|
||||
|
||||
public static Image getImage(String key) {
|
||||
return getImageRegistry().get(key);
|
||||
}
|
||||
|
||||
public static ImageDescriptor getImageDescriptor(String key) {
|
||||
return getImageRegistry().getDescriptor(key);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user