From 255f054eda4881a8a47717184d7366bee77a2c3e Mon Sep 17 00:00:00 2001 From: Chris Aniszczyk Date: Sun, 11 May 2008 20:23:23 +0000 Subject: 231411: [picasso] Picasso should run as a deployed bundle https://bugs.eclipse.org/bugs/show_bug.cgi?id=231411 --- .../.settings/org.eclipse.jdt.core.prefs | 56 ++++++++++++- .../.settings/org.eclipse.jdt.ui.prefs | 50 +++++++++++ .../.settings/org.eclipse.pde.prefs | 15 ++++ .../org.eclipse.pde.picasso/META-INF/MANIFEST.MF | 11 +-- .../org.eclipse.pde.picasso/build.properties | 3 +- .../org.eclipse.pde.picasso/plugin.properties | 1 + picasso/plugins/org.eclipse.pde.picasso/plugin.xml | 8 +- .../eclipse/pde/internal/picasso/Activator.java | 93 +++++++++------------ .../eclipse/pde/internal/picasso/DebugStartup.java | 6 -- .../org/eclipse/pde/internal/picasso/Options.java | 97 ++++++++++++++++++++++ 10 files changed, 269 insertions(+), 71 deletions(-) create mode 100644 picasso/plugins/org.eclipse.pde.picasso/.settings/org.eclipse.jdt.ui.prefs create mode 100644 picasso/plugins/org.eclipse.pde.picasso/.settings/org.eclipse.pde.prefs create mode 100644 picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/Options.java (limited to 'picasso/plugins/org.eclipse.pde.picasso') diff --git a/picasso/plugins/org.eclipse.pde.picasso/.settings/org.eclipse.jdt.core.prefs b/picasso/plugins/org.eclipse.pde.picasso/.settings/org.eclipse.jdt.core.prefs index 85fd9ac..bddc388 100644 --- a/picasso/plugins/org.eclipse.pde.picasso/.settings/org.eclipse.jdt.core.prefs +++ b/picasso/plugins/org.eclipse.pde.picasso/.settings/org.eclipse.jdt.core.prefs @@ -1,7 +1,61 @@ -#Sun May 04 14:13:33 CDT 2008 +#Fri May 09 20:26:33 EDT 2008 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=ignore org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.3 diff --git a/picasso/plugins/org.eclipse.pde.picasso/.settings/org.eclipse.jdt.ui.prefs b/picasso/plugins/org.eclipse.pde.picasso/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000..9c5c3ab --- /dev/null +++ b/picasso/plugins/org.eclipse.pde.picasso/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,50 @@ +#Fri May 09 20:27:59 EDT 2008 +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=false +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=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_to_enhanced_for_loop=false +sp_cleanup.format_source_code=false +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=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=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=true +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=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=true +sp_cleanup.remove_private_constructors=true +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=true +sp_cleanup.remove_unnecessary_nls_tags=true +sp_cleanup.remove_unused_imports=true +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=true +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=true +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 diff --git a/picasso/plugins/org.eclipse.pde.picasso/.settings/org.eclipse.pde.prefs b/picasso/plugins/org.eclipse.pde.picasso/.settings/org.eclipse.pde.prefs new file mode 100644 index 0000000..735c481 --- /dev/null +++ b/picasso/plugins/org.eclipse.pde.picasso/.settings/org.eclipse.pde.prefs @@ -0,0 +1,15 @@ +#Fri May 09 20:27:56 EDT 2008 +compilers.incompatible-environment=1 +compilers.p.build=1 +compilers.p.deprecated=1 +compilers.p.missing-packages=2 +compilers.p.no-required-att=0 +compilers.p.not-externalized-att=1 +compilers.p.unknown-attribute=1 +compilers.p.unknown-class=1 +compilers.p.unknown-element=1 +compilers.p.unknown-resource=1 +compilers.p.unresolved-ex-points=0 +compilers.p.unresolved-import=0 +compilers.use-project=true +eclipse.preferences.version=1 diff --git a/picasso/plugins/org.eclipse.pde.picasso/META-INF/MANIFEST.MF b/picasso/plugins/org.eclipse.pde.picasso/META-INF/MANIFEST.MF index db66e57..8b9e757 100644 --- a/picasso/plugins/org.eclipse.pde.picasso/META-INF/MANIFEST.MF +++ b/picasso/plugins/org.eclipse.pde.picasso/META-INF/MANIFEST.MF @@ -1,13 +1,14 @@ Manifest-Version: 1.0 +Bundle-Activator: org.eclipse.pde.internal.picasso.Activator +Bundle-ActivationPolicy: lazy +Bundle-Copyright: %bundleCopyright +Bundle-Localization: plugin Bundle-ManifestVersion: 2 Bundle-Name: %bundleName +Bundle-RequiredExecutionEnvironment: J2SE-1.4 Bundle-SymbolicName: org.eclipse.pde.picasso;singleton:=true Bundle-Vendor: %bundleVendor Bundle-Version: 1.0.0.qualifier -Bundle-Activator: org.eclipse.pde.internal.picasso.Activator +Export-Package: org.eclipse.pde.internal.picasso;x-internal:="true" Require-Bundle: org.eclipse.ui;bundle-version="[3.3.0,4.0.0)", org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)" -Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.4 -Export-Package: org.eclipse.pde.internal.picasso;x-internal:="true" -Bundle-Localization: plugin diff --git a/picasso/plugins/org.eclipse.pde.picasso/build.properties b/picasso/plugins/org.eclipse.pde.picasso/build.properties index bc3b0f2..a3128bf 100644 --- a/picasso/plugins/org.eclipse.pde.picasso/build.properties +++ b/picasso/plugins/org.eclipse.pde.picasso/build.properties @@ -4,4 +4,5 @@ bin.includes = META-INF/,\ .,\ plugin.xml,\ plugin.properties,\ - about.html + about.html,\ + .options diff --git a/picasso/plugins/org.eclipse.pde.picasso/plugin.properties b/picasso/plugins/org.eclipse.pde.picasso/plugin.properties index 4debfd0..98ac276 100644 --- a/picasso/plugins/org.eclipse.pde.picasso/plugin.properties +++ b/picasso/plugins/org.eclipse.pde.picasso/plugin.properties @@ -1,3 +1,4 @@ #Properties file for org.eclipse.pde.picasso +bundleCopyright=Copyright (c) 2008 IBM Corporation and others. bundleName = PDE Picasso (Incubation) bundleVendor = Eclipse.org \ No newline at end of file diff --git a/picasso/plugins/org.eclipse.pde.picasso/plugin.xml b/picasso/plugins/org.eclipse.pde.picasso/plugin.xml index 1c8ec7d..4069759 100644 --- a/picasso/plugins/org.eclipse.pde.picasso/plugin.xml +++ b/picasso/plugins/org.eclipse.pde.picasso/plugin.xml @@ -1,11 +1,7 @@ - - - + + - diff --git a/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/Activator.java b/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/Activator.java index 9107fc3..43db712 100644 --- a/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/Activator.java +++ b/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/Activator.java @@ -10,70 +10,59 @@ *******************************************************************************/ package org.eclipse.pde.internal.picasso; -import org.eclipse.core.runtime.Platform; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Properties; + +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.eclipse.ui.progress.UIJob; +import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; /** - * The activator class controls the plug-in life cycle + * The Activator controls the plug-in life cycle. */ public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "org.eclipse.pde.picasso"; //$NON-NLS-1$ - public static final String OPTION_ID_PAINT = "paint"; //$NON-NLS-1$ - public static final String OPTION_ID_PAINT_EXTRA_COMPOSITE_MARGIN = "paint/extraCompositeMargin"; //$NON-NLS-1$ - public static final String OPTION_ID_PAINT_TOOL_TIP = "paint/toolTip"; //$NON-NLS-1$ - - // The shared instance - private static Activator plugin; - - /** - * The constructor - */ - public Activator() { + private Job createJob(Options options) { + boolean toolTip = options.getToolTip(); + int extraCompositeMargin = options.getExtraCompositeMargin(); + Job job = new ListenerJob(Messages.ListenerJob_name, extraCompositeMargin, toolTip); + return job; } - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - - String paintOption = getDebugOption(OPTION_ID_PAINT); - if (Boolean.parseBoolean(paintOption) == false) return; - String paintToolTipOption = getDebugOption(OPTION_ID_PAINT_TOOL_TIP); - boolean toolTip = Boolean.parseBoolean(paintToolTipOption); - String paintExtraCompositeMarginOption = getDebugOption(OPTION_ID_PAINT_EXTRA_COMPOSITE_MARGIN); - int extraCompositeMargin = Integer.parseInt(paintExtraCompositeMarginOption); - UIJob job = new ListenerJob(Messages.ListenerJob_name, extraCompositeMargin, toolTip); - job.schedule(); - } + private Properties loadOptionProperties() throws IOException { + Properties properties = new Properties(); + Bundle bundle = getBundle(); + URL entry = bundle.getEntry(".options"); //$NON-NLS-1$ + InputStream stream = null; - private String getDebugOption(String option) { - return Platform.getDebugOption(PLUGIN_ID + '/' + option); + try { + stream = entry.openStream(); + properties.load(stream); + } finally { + if (stream != null) { + stream.close(); + } + } + + return properties; } - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - - // TODO we should remove those crazy listeners + private void scheduleJob() throws IOException { + Properties properties = loadOptionProperties(); + Options options = new Options(properties); + boolean paint = options.getPaint(); + if (paint == false) return; + Job job = createJob(options); + job.schedule(); } - /** - * Returns the shared instance - * - * @return the shared instance + /* (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) */ - public static Activator getDefault() { - return plugin; + public void start(BundleContext context) throws Exception { + super.start(context); + scheduleJob(); } -} +} \ No newline at end of file diff --git a/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/DebugStartup.java b/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/DebugStartup.java index a1ae9fe..ca3cf07 100644 --- a/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/DebugStartup.java +++ b/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/DebugStartup.java @@ -13,13 +13,7 @@ package org.eclipse.pde.internal.picasso; import org.eclipse.ui.IStartup; public class DebugStartup implements IStartup { - - public DebugStartup() {} - public void earlyStartup() { // do nothing } - - - } diff --git a/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/Options.java b/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/Options.java new file mode 100644 index 0000000..c1ef6ef --- /dev/null +++ b/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/Options.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.pde.internal.picasso; + +import java.util.Properties; + +import org.eclipse.core.runtime.Platform; + +public class Options extends Object { + public static final String PLUGIN_ID = "org.eclipse.pde.picasso"; //$NON-NLS-1$ + public static final String OPTION_ID_PAINT = "paint"; //$NON-NLS-1$ + public static final String OPTION_ID_PAINT_EXTRA_COMPOSITE_MARGIN = "paint/extraCompositeMargin"; //$NON-NLS-1$ + public static final String OPTION_ID_PAINT_TOOL_TIP = "paint/toolTip"; //$NON-NLS-1$ + + private Properties properties; + + public Options(Properties properties) { + super(); + this.properties = properties; + } + + private String createOptionKey(String option) { + return Options.PLUGIN_ID + '/' + option; + } + + private boolean getBooleanOption(String option, boolean defaultValue) { + String value = getOption(option); + boolean result = value != null ? Boolean.parseBoolean(value) : defaultValue; + return result; + } + + private boolean getBooleanOptionDefault(String option, boolean defaultValue) { + String key = createOptionKey(option); + String value = System.getProperty(key); + boolean result; + + if (value != null) { + result = Boolean.parseBoolean(value); + } else { + String propertyValue = properties.getProperty(option); + result = propertyValue != null ? Boolean.parseBoolean(propertyValue) : defaultValue; + } + + return result; + } + + public int getExtraCompositeMargin() { + int defaultValue = getIntegerOptionDefault(Options.OPTION_ID_PAINT_EXTRA_COMPOSITE_MARGIN, 0); + int value = getIntegerOption(Options.OPTION_ID_PAINT_EXTRA_COMPOSITE_MARGIN, defaultValue); + return value; + } + + private int getIntegerOption(String option, int defaultValue) { + String value = getOption(option); + int result = value != null ? Integer.parseInt(value) : defaultValue; + return result; + } + + private int getIntegerOptionDefault(String option, int defaultValue) { + String key = createOptionKey(option); + String value = System.getProperty(key); + int result; + + if (value != null) { + result = Integer.parseInt(value); + } else { + String propertyValue = properties.getProperty(option); + result = propertyValue != null ? Integer.parseInt(propertyValue) : defaultValue; + } + return result; + } + + private String getOption(String option) { + String key = createOptionKey(option); + return Platform.getDebugOption(key); + } + + public boolean getPaint() { + boolean defaultValue = getBooleanOptionDefault(Options.OPTION_ID_PAINT, false); + boolean value = getBooleanOption(Options.OPTION_ID_PAINT, defaultValue); + return value; + } + + public boolean getToolTip() { + boolean defaultValue = getBooleanOptionDefault(Options.OPTION_ID_PAINT_TOOL_TIP, false); + boolean value = getBooleanOption(Options.OPTION_ID_PAINT_TOOL_TIP, defaultValue); + return value; + } +} -- cgit v1.2.3