Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 96306 Details for
Bug 168069
Rework the compiler preferences page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch
168069.patch (text/plain), 118.85 KB, created by
Michael Rennie
on 2008-04-16 14:42:57 EDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Michael Rennie
Created:
2008-04-16 14:42:57 EDT
Size:
118.85 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.doc.user >Index: contexts_PDE.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.doc.user/contexts_PDE.xml,v >retrieving revision 1.48 >diff -u -r1.48 contexts_PDE.xml >--- contexts_PDE.xml 12 Apr 2008 11:37:06 -0000 1.48 >+++ contexts_PDE.xml 16 Apr 2008 18:40:04 -0000 >@@ -695,6 +695,11 @@ > <topic label="Dependencies page" href="guide/pde_manifest_dependencies.htm"/> > <topic label="Extension point schema" href="guide/pde_schema.htm"/> > </context> >+ <context id="project_selection_dialog"> >+ <description>This dialog is used to select a plugin project to configure specific settings for.</description> >+ <topic href="guide/tools/preference_pages/compilers.htm" label="Compilers Preferences"/> >+ <topic href="guide/tools/preference_pages/plugin_compiler.htm" label="Plug-in Compiler Preferences"/> >+ </context> > <context id="java_attribute_wizard_page"> > <description>This wizard allows you to create a new Java class or select an existing one.</description> > </context> >#P org.eclipse.pde.core >Index: src/org/eclipse/pde/internal/core/PreferenceInitializer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PreferenceInitializer.java,v >retrieving revision 1.6 >diff -u -r1.6 PreferenceInitializer.java >--- src/org/eclipse/pde/internal/core/PreferenceInitializer.java 14 Apr 2008 14:19:52 -0000 1.6 >+++ src/org/eclipse/pde/internal/core/PreferenceInitializer.java 16 Apr 2008 18:40:05 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * Copyright (c) 2005, 2007 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 >@@ -13,8 +13,11 @@ > import java.util.Locale; > import org.eclipse.core.runtime.Platform; > import org.eclipse.core.runtime.Preferences; >-import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; >+import org.eclipse.core.runtime.preferences.*; > import org.eclipse.pde.core.plugin.TargetPlatform; >+import org.eclipse.pde.internal.core.builders.CompilerFlags; >+import org.eclipse.pde.internal.core.natures.PDE; >+import org.osgi.service.prefs.BackingStoreException; > > public class PreferenceInitializer extends AbstractPreferenceInitializer { > >@@ -40,5 +43,33 @@ > > preferences.setDefault(ICoreConstants.TARGET_PLATFORM_REALIZATION, TargetPlatform.getDefaultLocation().equals(TargetPlatform.getLocation())); > >+ //set defaults for compiler preferences in org.eclipse.pde pref node, not org.eclipse.pde.core >+ IEclipsePreferences prefs = new DefaultScope().getNode(PDE.PLUGIN_ID); >+ prefs.putInt(CompilerFlags.P_UNRESOLVED_IMPORTS, CompilerFlags.ERROR); >+ prefs.putInt(CompilerFlags.P_UNRESOLVED_EX_POINTS, CompilerFlags.ERROR); >+ prefs.putInt(CompilerFlags.P_NO_REQUIRED_ATT, CompilerFlags.ERROR); >+ prefs.putInt(CompilerFlags.P_UNKNOWN_ELEMENT, CompilerFlags.WARNING); >+ prefs.putInt(CompilerFlags.P_UNKNOWN_ATTRIBUTE, CompilerFlags.WARNING); >+ prefs.putInt(CompilerFlags.P_DEPRECATED, CompilerFlags.WARNING); >+ prefs.putInt(CompilerFlags.P_UNKNOWN_CLASS, CompilerFlags.WARNING); >+ prefs.putInt(CompilerFlags.P_DISCOURAGED_CLASS, CompilerFlags.WARNING); >+ prefs.putInt(CompilerFlags.P_UNKNOWN_RESOURCE, CompilerFlags.WARNING); >+ prefs.putInt(CompilerFlags.P_UNKNOWN_IDENTIFIER, CompilerFlags.WARNING); >+ prefs.putInt(CompilerFlags.P_NOT_EXTERNALIZED, CompilerFlags.IGNORE); >+ prefs.putInt(CompilerFlags.P_BUILD, CompilerFlags.WARNING); >+ prefs.putInt(CompilerFlags.P_INCOMPATIBLE_ENV, CompilerFlags.WARNING); >+ prefs.putInt(CompilerFlags.P_MISSING_EXPORT_PKGS, CompilerFlags.IGNORE); >+ prefs.putInt(CompilerFlags.P_MISSING_BUNDLE_CLASSPATH_ENTRIES, CompilerFlags.WARNING); >+ >+ prefs.putBoolean(CompilerFlags.S_CREATE_DOCS, false); >+ prefs.put(CompilerFlags.S_DOC_FOLDER, "doc"); //$NON-NLS-1$ >+ prefs.putInt(CompilerFlags.S_OPEN_TAGS, CompilerFlags.WARNING); >+ >+ prefs.putInt(CompilerFlags.F_UNRESOLVED_PLUGINS, CompilerFlags.WARNING); >+ prefs.putInt(CompilerFlags.F_UNRESOLVED_FEATURES, CompilerFlags.WARNING); >+ try { >+ prefs.flush(); >+ } catch (BackingStoreException e) { >+ } > } > } >Index: src/org/eclipse/pde/internal/core/PDECore.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDECore.java,v >retrieving revision 1.107 >diff -u -r1.107 PDECore.java >--- src/org/eclipse/pde/internal/core/PDECore.java 5 Feb 2008 16:25:52 -0000 1.107 >+++ src/org/eclipse/pde/internal/core/PDECore.java 16 Apr 2008 18:40:05 -0000 >@@ -18,7 +18,8 @@ > import org.eclipse.core.runtime.*; > import org.eclipse.jdt.launching.JavaRuntime; > import org.eclipse.pde.core.plugin.IPluginModelBase; >-import org.eclipse.pde.internal.core.builders.*; >+import org.eclipse.pde.internal.core.builders.FeatureRebuilder; >+import org.eclipse.pde.internal.core.builders.PluginRebuilder; > import org.eclipse.pde.internal.core.schema.SchemaRegistry; > import org.eclipse.update.configurator.ConfiguratorUtils; > import org.osgi.framework.BundleContext; >@@ -217,7 +218,6 @@ > public void start(BundleContext context) throws Exception { > super.start(context); > fBundleContext = context; >- CompilerFlags.initializeDefaults(); > fJavaElementChangeListener = new JavaElementChangeListener(); > fJavaElementChangeListener.start(); > fPluginRebuilder = new PluginRebuilder(); >Index: src/org/eclipse/pde/internal/core/builders/CompilerFlags.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/CompilerFlags.java,v >retrieving revision 1.9 >diff -u -r1.9 CompilerFlags.java >--- src/org/eclipse/pde/internal/core/builders/CompilerFlags.java 26 Mar 2008 16:11:21 -0000 1.9 >+++ src/org/eclipse/pde/internal/core/builders/CompilerFlags.java 16 Apr 2008 18:40:05 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 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 >@@ -16,83 +16,67 @@ > import org.eclipse.core.runtime.preferences.*; > import org.eclipse.pde.internal.core.natures.PDE; > import org.osgi.service.prefs.BackingStoreException; >-import org.osgi.service.prefs.Preferences; > >+/** >+ * Class used to handle compiler related preferences. >+ * >+ * @noextend This class is not intended to be subclassed by clients. >+ */ > public class CompilerFlags { >- public static final int ERROR = 0; > >+ /** >+ * Compiler flag options as integers >+ */ >+ public static final int ERROR = 0; > public static final int WARNING = 1; >- > public static final int IGNORE = 2; > >- public static final int MARKER = 0; >- >- public static final int BOOLEAN = 1; >- >- public static final int STRING = 2; >- >+ /** >+ * categories of flags >+ */ > public static final int PLUGIN_FLAGS = 0; >- > public static final int SCHEMA_FLAGS = 1; >- > public static final int FEATURE_FLAGS = 2; >- > public static final int SITE_FLAGS = 3; > >- // Project or Instance preferences >- public static final String USE_PROJECT_PREF = "compilers.use-project"; //$NON-NLS-1$ >- >- // Manifest compiler flags >+ /** >+ * plugin preferences >+ */ > public static final String P_UNRESOLVED_IMPORTS = "compilers.p.unresolved-import"; //$NON-NLS-1$ >- > public static final String P_UNRESOLVED_EX_POINTS = "compilers.p.unresolved-ex-points"; //$NON-NLS-1$ >- > public static final String P_UNKNOWN_ELEMENT = "compilers.p.unknown-element"; //$NON-NLS-1$ >- > public static final String P_UNKNOWN_ATTRIBUTE = "compilers.p.unknown-attribute"; //$NON-NLS-1$ >- > public static final String P_UNKNOWN_CLASS = "compilers.p.unknown-class"; //$NON-NLS-1$ >- >- public static final String P_DISCOURAGED_CLASS = "compilers.p.discouraged-class"; //$NON-NLS-1$ >- > public static final String P_UNKNOWN_RESOURCE = "compilers.p.unknown-resource"; //$NON-NLS-1$ >- > public static final String P_UNKNOWN_IDENTIFIER = "compilers.p.unknown-identifier"; //$NON-NLS-1$ >- >+ public static final String P_DISCOURAGED_CLASS = "compilers.p.discouraged-class"; //$NON-NLS-1$ > public static final String P_NO_REQUIRED_ATT = "compilers.p.no-required-att"; //$NON-NLS-1$ >- > public static final String P_NOT_EXTERNALIZED = "compilers.p.not-externalized-att"; //$NON-NLS-1$ >- > public static final String P_BUILD = "compilers.p.build"; //$NON-NLS-1$ >- > public static final String P_INCOMPATIBLE_ENV = "compilers.incompatible-environment"; //$NON-NLS-1$ >- > public static final String P_MISSING_EXPORT_PKGS = "compilers.p.missing-packages"; //$NON-NLS-1$ >- > public static final String P_DEPRECATED = "compilers.p.deprecated"; //$NON-NLS-1$ >- > public static final String P_MISSING_BUNDLE_CLASSPATH_ENTRIES = "compilers.p.missing-bundle-classpath-entries"; //$NON-NLS-1$ > >+ /** >+ * schema preferences >+ */ > public static final String S_CREATE_DOCS = "compilers.s.create-docs"; //$NON-NLS-1$ >- > public static final String S_DOC_FOLDER = "compilers.s.doc-folder"; //$NON-NLS-1$ >- > public static final String S_OPEN_TAGS = "compilers.s.open-tags"; //$NON-NLS-1$ > >+ /** >+ * feature preferences >+ */ > public static final String F_UNRESOLVED_PLUGINS = "compilers.f.unresolved-plugins"; //$NON-NLS-1$ >- > public static final String F_UNRESOLVED_FEATURES = "compilers.f.unresolved-features"; //$NON-NLS-1$ > >- private static final String[][] fFlags = { {P_UNRESOLVED_IMPORTS, P_INCOMPATIBLE_ENV, P_UNRESOLVED_EX_POINTS, P_NO_REQUIRED_ATT, P_UNKNOWN_ELEMENT, P_UNKNOWN_ATTRIBUTE, P_DEPRECATED, P_UNKNOWN_CLASS, P_DISCOURAGED_CLASS, P_UNKNOWN_RESOURCE, P_UNKNOWN_IDENTIFIER, P_NOT_EXTERNALIZED, P_BUILD, P_MISSING_EXPORT_PKGS, P_MISSING_BUNDLE_CLASSPATH_ENTRIES}, {S_CREATE_DOCS, S_DOC_FOLDER, S_OPEN_TAGS}, {F_UNRESOLVED_PLUGINS, F_UNRESOLVED_FEATURES}}; >- >- public static int getFlagType(String flagId) { >- if (flagId.equals(S_CREATE_DOCS)) >- return BOOLEAN; >- if (flagId.equals(S_DOC_FOLDER)) >- return STRING; >- return MARKER; >- } >- >+ /** >+ * Returns the value for the requested preference, or 0 if there was a problem getting the preference value >+ * @param project to use as a project specific settings scope, or null >+ * @param flagId the id of the preference to retrieve >+ * @return the value for the given preference id >+ */ > public static int getFlag(IProject project, String flagId) { > try { > return Integer.parseInt(getString(project, flagId)); >@@ -101,129 +85,26 @@ > } > } > >+ /** >+ * Returns the boolean preference denoted by the flag id (preference id) >+ * @param project to use as a project specific settings scope, or null >+ * @param flagId the id of the preference to retrieve >+ * @return the boolean value for the given preference id >+ */ > public static boolean getBoolean(IProject project, String flagId) { > return Boolean.valueOf(getString(project, flagId)).booleanValue(); > } > > /** >- * >- * @param project >- * project to use PROJECT,INSTANCE,DEFAULT scope or null to use >- * only INSTANCE,DEFAULT scope >- * @param flagId >- * @return value or "" >+ * Returns the string preference for the given preference id >+ * @param project to use as a project specific settings scope, or null >+ * @param flagId the id of the preference to retrieve >+ * @return preference value or an empty string, never <code>null</code> > */ > public static String getString(IProject project, String flagId) { > IPreferencesService service = Platform.getPreferencesService(); > IScopeContext[] contexts = project == null ? null : new IScopeContext[] {new ProjectScope(project)}; >- return service.getString(PDE.PLUGIN_ID, flagId, "", //$NON-NLS-1$ >- project == null ? null : contexts); >- } >- >- public static int getDefaultFlag(String flagId) { >- return new DefaultScope().getNode(PDE.PLUGIN_ID).getInt(flagId, 0); >- } >- >- public static String getDefaultString(String flagId) { >- return new DefaultScope().getNode(PDE.PLUGIN_ID).get(flagId, ""); //$NON-NLS-1$ >- } >- >- public static boolean getDefaultBoolean(String flagId) { >- return new DefaultScope().getNode(PDE.PLUGIN_ID).getBoolean(flagId, false); >- } >- >- public static void setFlag(String flagId, int value) { >- if (getDefaultFlag(flagId) == value) >- new InstanceScope().getNode(PDE.PLUGIN_ID).remove(flagId); >- else >- new InstanceScope().getNode(PDE.PLUGIN_ID).putInt(flagId, value); >- } >- >- public static void setFlag(IProject project, String flagId, int value) { >- setString(project, flagId, Integer.toString(value)); >- } >- >- public static void setBoolean(String flagId, boolean value) { >- if (getDefaultBoolean(flagId) == value) >- new InstanceScope().getNode(PDE.PLUGIN_ID).remove(flagId); >- else >- new InstanceScope().getNode(PDE.PLUGIN_ID).putBoolean(flagId, value); >- } >- >- public static void setBoolean(IProject project, String flagId, boolean value) { >- setString(project, flagId, Boolean.toString(value)); >- } >- >- public static void setString(String flagId, String value) { >- if (getDefaultString(flagId).equals(value)) >- new InstanceScope().getNode(PDE.PLUGIN_ID).remove(flagId); >- else >- new InstanceScope().getNode(PDE.PLUGIN_ID).put(flagId, value); >- } >- >- /** >- * Sets preference on PROJECT scope >- * >- * @param project >- * @param flagId >- * @param value >- */ >- public static void setString(IProject project, String flagId, String value) { >- if (project == null) >- return; >- Preferences preferences = new ProjectScope(project).getNode(PDE.PLUGIN_ID); >- preferences.put(flagId, value); >- try { >- preferences.flush(); >- } catch (BackingStoreException bse) { >- } >- } >- >- /** >- * Clears preference from Project scope >- * >- * @param project >- * @param flagId >- */ >- public static void clear(IProject project, String flagId) { >- if (project == null) >- return; >- Preferences preferences = new ProjectScope(project).getNode(PDE.PLUGIN_ID); >- preferences.remove(flagId); >- try { >- preferences.flush(); >- } catch (BackingStoreException bse) { >- } >- } >- >- public static void initializeDefaults() { >- Preferences node = new DefaultScope().getNode(PDE.PLUGIN_ID); >- node.putInt(P_UNRESOLVED_IMPORTS, ERROR); >- node.putInt(P_UNRESOLVED_EX_POINTS, ERROR); >- node.putInt(P_NO_REQUIRED_ATT, ERROR); >- node.putInt(P_UNKNOWN_ELEMENT, WARNING); >- node.putInt(P_UNKNOWN_ATTRIBUTE, WARNING); >- node.putInt(P_DEPRECATED, WARNING); >- node.putInt(P_UNKNOWN_CLASS, WARNING); >- node.putInt(P_DISCOURAGED_CLASS, WARNING); >- node.putInt(P_UNKNOWN_RESOURCE, WARNING); >- node.putInt(P_UNKNOWN_IDENTIFIER, WARNING); >- node.putInt(P_NOT_EXTERNALIZED, IGNORE); >- node.putInt(P_BUILD, WARNING); >- node.putInt(P_INCOMPATIBLE_ENV, WARNING); >- node.putInt(P_MISSING_EXPORT_PKGS, IGNORE); >- node.putInt(P_MISSING_BUNDLE_CLASSPATH_ENTRIES, WARNING); >- >- node.putBoolean(S_CREATE_DOCS, false); >- node.put(S_DOC_FOLDER, "doc"); //$NON-NLS-1$ >- node.putInt(S_OPEN_TAGS, WARNING); >- >- node.putInt(F_UNRESOLVED_PLUGINS, WARNING); >- node.putInt(F_UNRESOLVED_FEATURES, WARNING); >- } >- >- public static String[] getFlags(int group) { >- return fFlags[group]; >+ return service.getString(PDE.PLUGIN_ID, flagId, "", project == null ? null : contexts); //$NON-NLS-1$ > } > > /** >#P org.eclipse.pde.ui >Index: src/org/eclipse/pde/internal/ui/preferences/CompilersConfigurationTab.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/preferences/CompilersConfigurationTab.java >diff -N src/org/eclipse/pde/internal/ui/preferences/CompilersConfigurationTab.java >--- src/org/eclipse/pde/internal/ui/preferences/CompilersConfigurationTab.java 15 Apr 2008 15:18:01 -0000 1.12 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,480 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 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.ui.preferences; >- >-import java.util.*; >-import java.util.List; >-import org.eclipse.core.resources.*; >-import org.eclipse.core.runtime.*; >-import org.eclipse.core.runtime.jobs.Job; >-import org.eclipse.jface.dialogs.*; >-import org.eclipse.jface.dialogs.Dialog; >-import org.eclipse.pde.internal.core.builders.CompilerFlags; >-import org.eclipse.pde.internal.core.natures.PDE; >-import org.eclipse.pde.internal.ui.PDEPlugin; >-import org.eclipse.pde.internal.ui.PDEUIMessages; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.events.*; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.layout.GridLayout; >-import org.eclipse.swt.widgets.*; >- >-/** >- * A configuration block used to modify PDE compiler settings. Can be used as a preference page (a null project) >- * or as a property page (applicable to plugin projects). >- */ >-public class CompilersConfigurationTab { >- >- private Set fBuilders = new HashSet(); >- >- private Set fChangedControls = new HashSet(); >- >- private Composite fFeaturePage; >- >- private List fFlagControls; >- >- private Composite fPluginPage; >- >- private Composite fSchemaPage; >- >- private Shell fShell; >- >- // The size of label array must match CompilerFlag.fFlags >- private static final String[][] fLabels = { {PDEUIMessages.compilers_p_unresolved_import, PDEUIMessages.CompilersConfigurationTab_incompatEnv, PDEUIMessages.compilers_p_unresolved_ex_points, PDEUIMessages.compilers_p_no_required_att, PDEUIMessages.compilers_p_unknown_element, PDEUIMessages.compilers_p_unknown_attribute, PDEUIMessages.compilers_p_deprecated, PDEUIMessages.compilers_p_unknown_class, PDEUIMessages.compilers_p_discouraged_class, PDEUIMessages.compilers_p_unknown_resource, PDEUIMessages.compilers_p_unknown_identifier, PDEUIMessages.compilers_p_not_externalized_att, PDEUIMessages.CompilersConfigurationTab_buildPropertiesErrors, PDEUIMessages.compilers_p_exported_pkgs, PDEUIMessages.CompilersConfigurationTab_missingBundleClasspathEntries}, >- {PDEUIMessages.compilers_s_create_docs, PDEUIMessages.compilers_s_doc_folder, PDEUIMessages.compilers_s_open_tags}, {PDEUIMessages.compilers_f_unresolved_plugins, PDEUIMessages.compilers_f_unresolved_features}, {}}; >- >- /** >- * The backing project may be <code>null</code> >- */ >- private IProject project; >- >- /** >- * Constructor >- * @param project >- */ >- public CompilersConfigurationTab(IProject project) { >- this.project = project; >- } >- >- /** >- * Adds the specified control to a listing of controls that have changes >- * @param control >- */ >- private void addChangedConrol(Control control) { >- String flagId = (String) control.getData(); >- boolean doAdd = false; >- if (control instanceof Combo) { >- int newIndex = ((Combo) control).getSelectionIndex(); >- int oldIndex = CompilerFlags.getFlag(project, flagId); >- doAdd = (newIndex != oldIndex); >- } else if (control instanceof Button) { >- boolean newValue = ((Button) control).getSelection(); >- boolean oldValue = CompilerFlags.getBoolean(project, flagId); >- doAdd = oldValue != newValue; >- } else if (control instanceof Text) { >- String newValue = ((Text) control).getText(); >- String oldValue = CompilerFlags.getString(project, flagId); >- doAdd = !newValue.equals(oldValue); >- } >- if (doAdd) >- fChangedControls.add(control); >- else if (fChangedControls.contains(control)) >- fChangedControls.remove(control); >- } >- >- /** >- * @see org.eclipse.jface.preference.PreferencePage#createContents(Composite) >- */ >- public Control createContents(Composite parent) { >- fShell = parent.getShell(); >- >- Composite container = new Composite(parent, SWT.NULL); >- GridLayout layout = new GridLayout(); >- container.setLayout(layout); >- >- fFlagControls = new ArrayList(); >- SelectionListener listener = new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- addChangedConrol((Control) e.widget); >- } >- }; >- >- ModifyListener mlistener = new ModifyListener() { >- public void modifyText(ModifyEvent e) { >- addChangedConrol((Control) e.widget); >- } >- }; >- >- String[] choices = new String[] {PDEUIMessages.CompilersConfigurationBlock_error, PDEUIMessages.CompilersConfigurationBlock_warning, PDEUIMessages.CompilersConfigurationBlock_ignore}; // >- >- if (project != null) { // property page >- try { >- if (project.hasNature(PDE.PLUGIN_NATURE)) { >- fPluginPage = createPage(container, PDEUIMessages.CompilersConfigurationBlock_plugins, CompilerFlags.PLUGIN_FLAGS, choices); >- } >- } catch (CoreException ce) { >- } >- } else { // preference page >- TabFolder folder = new TabFolder(container, SWT.NONE); >- GridData gd = new GridData(GridData.FILL_BOTH); >- folder.setLayoutData(gd); >- >- fPluginPage = createPage(folder, PDEUIMessages.CompilersConfigurationBlock_plugins, CompilerFlags.PLUGIN_FLAGS, choices); >- fSchemaPage = createPage(folder, PDEUIMessages.CompilersConfigurationBlock_schemas, CompilerFlags.SCHEMA_FLAGS, choices); >- fFeaturePage = createPage(folder, PDEUIMessages.CompilersConfigurationBlock_features, CompilerFlags.FEATURE_FLAGS, choices); >- } >- >- for (int i = 0; i < fFlagControls.size(); i++) { >- Control control = (Control) fFlagControls.get(i); >- if (control instanceof Combo) { >- ((Combo) control).addSelectionListener(listener); >- } else if (control instanceof Button) { >- ((Button) control).addSelectionListener(listener); >- } else if (control instanceof Text) { >- ((Text) control).addModifyListener(mlistener); >- } >- } >- Dialog.applyDialogFont(parent); >- return container; >- } >- >- /** >- * Creates a preference element for the given flag and choices >- * @param page >- * @param flagId >- * @param choices >- * @return a new pref control >- */ >- private Control createFlag(Composite page, String flagId, String[] choices) { >- Control control = null; >- if (CompilerFlags.getFlagType(flagId) == CompilerFlags.MARKER) { >- Label label = new Label(page, SWT.NULL); >- label.setText(getFlagLabel(flagId)); >- label.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, true, false)); >- Combo combo = new Combo(page, SWT.READ_ONLY); >- combo.setLayoutData(new GridData(SWT.END, SWT.TOP, false, false)); >- combo.setItems(choices); >- combo.select(CompilerFlags.getFlag(project, flagId)); >- control = combo; >- } else if (CompilerFlags.getFlagType(flagId) == CompilerFlags.BOOLEAN) { >- Button button = new Button(page, SWT.CHECK); >- button.setText(getFlagLabel(flagId)); >- button.setSelection(CompilerFlags.getBoolean(project, flagId)); >- GridData gd = new GridData(); >- gd.horizontalSpan = 2; >- button.setLayoutData(gd); >- control = button; >- } else if (CompilerFlags.getFlagType(flagId) == CompilerFlags.STRING) { >- Label label = new Label(page, SWT.NULL); >- label.setText(getFlagLabel(flagId)); >- Text text = new Text(page, SWT.SINGLE | SWT.BORDER); >- text.setText(CompilerFlags.getString(project, flagId)); >- GridData gd = new GridData(GridData.FILL_HORIZONTAL); >- gd.widthHint = 50; >- text.setLayoutData(gd); >- >- new Label(page, SWT.NULL).setLayoutData(new GridData()); >- GridData sgd = new GridData(); >- Label slabel = new Label(page, SWT.NULL); >- slabel.setText(PDEUIMessages.CompilersConfigurationBlock_label); >- sgd.horizontalSpan = 2; >- slabel.setLayoutData(sgd); >- >- control = text; >- } >- control.setData(flagId); >- return control; >- } >- >- /** >- * Returns the corresponding flag label given the id >- * @param flagId >- * @return the label for the flag with the given id >- */ >- private String getFlagLabel(String flagId) { >- for (int i = 0; i < fLabels.length; i++) { >- String[] flags = CompilerFlags.getFlags(i); >- for (int j = 0; j < flags.length; j++) { >- if (flags[j].equals(flagId)) { >- return fLabels[i][j]; >- } >- } >- } >- return ""; //$NON-NLS-1$ >- } >- >- /** >- * Creates a new page in the parent tab folder >- * @param folder >- * @param name the name of the tab >- * @param index the index of the message to use for the tab >- * @param choices the listing of choices >- * @return a new page in the parent tab folder >- */ >- private Composite createPage(Composite parent, String name, int index, String[] choices) { >- Composite page = new Composite(parent, SWT.NONE); >- page.setLayout(new GridLayout(2, false)); >- page.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >- >- if (parent instanceof TabFolder) { >- TabItem tab = new TabItem((TabFolder) parent, SWT.NONE); >- tab.setText(name); >- tab.setControl(page); >- } >- >- createVerticalSpacer(page, 1); >- Label label = new Label(page, SWT.NULL); >- String labelText; >- if (index == CompilerFlags.SCHEMA_FLAGS) { >- labelText = PDEUIMessages.CompilersConfigurationBlock_altlabel; >- } else { >- labelText = PDEUIMessages.CompilersConfigurationBlock_label; >- } >- label.setText(labelText); >- GridData gd = new GridData(SWT.BEGINNING, SWT.TOP, true, false); >- gd.horizontalSpan = 2; >- label.setLayoutData(gd); >- createVerticalSpacer(page, 1); >- String[] flagIds = CompilerFlags.getFlags(index); >- for (int i = 0; i < flagIds.length; i++) { >- Control control = createFlag(page, flagIds[i], choices); >- fFlagControls.add(control); >- } >- return page; >- } >- >- /** >- * Creates a vertical spacer for separating components. If applied to a >- * <code>GridLayout</code>, this method will automatically span all of the columns of the parent >- * to make vertical space >- * >- * @param parent the parent composite to add this spacer to >- * @param numlines the number of vertical lines to make as space >- */ >- public static void createVerticalSpacer(Composite parent, int numlines) { >- Label lbl = new Label(parent, SWT.NONE); >- GridData gd = new GridData(GridData.FILL_HORIZONTAL); >- Layout layout = parent.getLayout(); >- if (layout instanceof GridLayout) { >- gd.horizontalSpan = ((GridLayout) parent.getLayout()).numColumns; >- } >- gd.heightHint = numlines; >- lbl.setLayoutData(gd); >- } >- >- /** >- * Performs a full build of the workspace >- */ >- private void doFullBuild() { >- Job buildJob = new Job(PDEUIMessages.CompilersConfigurationBlock_building) { >- public boolean belongsTo(Object family) { >- return ResourcesPlugin.FAMILY_MANUAL_BUILD == family; >- } >- >- protected IStatus run(IProgressMonitor monitor) { >- try { >- IProject[] projects = null; >- if (project == null) { >- projects = PDEPlugin.getWorkspace().getRoot().getProjects(); >- } else { >- projects = new IProject[] {project}; >- } >- monitor.beginTask("", projects.length * 2); //$NON-NLS-1$ >- for (int i = 0; i < projects.length; i++) { >- IProject projectToBuild = projects[i]; >- if (!projectToBuild.isOpen()) >- continue; >- if (projectToBuild.hasNature(PDE.PLUGIN_NATURE)) { >- if (fBuilders.contains(PDE.MANIFEST_BUILDER_ID)) >- projectToBuild.build(IncrementalProjectBuilder.FULL_BUILD, PDE.MANIFEST_BUILDER_ID, null, new SubProgressMonitor(monitor, 1)); >- else >- monitor.worked(1); >- if (fBuilders.contains(PDE.SCHEMA_BUILDER_ID)) >- projectToBuild.build(IncrementalProjectBuilder.FULL_BUILD, PDE.SCHEMA_BUILDER_ID, null, new SubProgressMonitor(monitor, 1)); >- else >- monitor.worked(1); >- } else if (projectToBuild.hasNature(PDE.FEATURE_NATURE)) { >- if (fBuilders.contains(PDE.FEATURE_BUILDER_ID)) >- projectToBuild.build(IncrementalProjectBuilder.FULL_BUILD, PDE.FEATURE_BUILDER_ID, null, new SubProgressMonitor(monitor, 2)); >- } else { >- monitor.worked(2); >- } >- } >- } catch (CoreException e) { >- return e.getStatus(); >- } catch (OperationCanceledException e) { >- return Status.CANCEL_STATUS; >- } finally { >- monitor.done(); >- } >- return Status.OK_STATUS; >- } >- }; >- buildJob.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule()); >- buildJob.setUser(true); >- buildJob.schedule(); >- } >- >- /** >- * @see org.eclipse.jface.preference.PreferencePage#performDefaults() >- */ >- public void performDefaults() { >- fChangedControls.clear(); >- for (int i = 0; i < fFlagControls.size(); i++) { >- boolean hasChange = false; >- Control control = (Control) fFlagControls.get(i); >- String flagId = (String) control.getData(); >- if (control instanceof Combo) { >- if (project != null) >- hasChange = CompilerFlags.getFlag(project, flagId) != CompilerFlags.getDefaultFlag(flagId); >- else >- hasChange = ((Combo) control).getSelectionIndex() != CompilerFlags.getDefaultFlag(flagId); >- ((Combo) control).select(CompilerFlags.getDefaultFlag(flagId)); >- } else if (control instanceof Button) { >- if (project != null) >- hasChange = CompilerFlags.getBoolean(project, flagId) != CompilerFlags.getDefaultBoolean(flagId); >- else >- hasChange = ((Button) control).getSelection() != CompilerFlags.getDefaultBoolean(flagId); >- ((Button) control).setSelection(CompilerFlags.getDefaultBoolean(flagId)); >- } else if (control instanceof Text) { >- if (project != null) >- hasChange = !CompilerFlags.getString(project, flagId).equals(CompilerFlags.getDefaultString(flagId)); >- else >- hasChange = ((Text) control).getText() != CompilerFlags.getDefaultString(flagId); >- ((Text) control).setText(CompilerFlags.getDefaultString(flagId)); >- } >- if (hasChange) >- fChangedControls.add(control); >- } >- } >- >- /** >- * Applies the changes settings (if any), and requests a full build (if needed) >- * @param enabled >- * @return the success of the operation >- */ >- public boolean performOk(boolean enabled) { >- Set changedControls = fChangedControls; >- if (!enabled) { >- // fChangedControls is not a valid change. >- // The change is the difference between values in >- // PROJECT,INSTANCE,DEFAULT >- // and INSTANCE,DEFAULT scopes. >- changedControls = new HashSet(); >- for (Iterator iter = fFlagControls.iterator(); iter.hasNext();) { >- Control control = (Control) iter.next(); >- String flagId = (String) control.getData(); >- if (!CompilerFlags.getString(project, flagId).equals(CompilerFlags.getString(null, flagId))) { >- changedControls.add(control); >- break; >- } >- } >- } >- boolean build = false; >- if (changedControls.size() > 0) { >- String title; >- String message; >- if (project != null) { >- title = PDEUIMessages.CompilersConfigurationBlock_rebuild_title; >- message = PDEUIMessages.CompilersConfigurationBlock_rebuild_message; >- } else { >- title = PDEUIMessages.CompilersConfigurationBlock_rebuild_many_title; >- message = PDEUIMessages.CompilersConfigurationBlock_rebuild_many_message; >- >- } >- >- MessageDialog dialog = new MessageDialog(fShell, title, null, message, MessageDialog.QUESTION, new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL}, 2); >- int res = dialog.open(); >- >- if (res == 2) { >- return false; >- } else if (res == 0) { >- build = true; >- } >- } >- if (project != null && enabled != CompilerFlags.getBoolean(project, CompilerFlags.USE_PROJECT_PREF)) { >- if (enabled) { >- CompilerFlags.setBoolean(project, CompilerFlags.USE_PROJECT_PREF, true); >- } else { >- CompilerFlags.clear(project, CompilerFlags.USE_PROJECT_PREF); >- } >- } >- if (changedControls.size() > 0) { >- fBuilders = new HashSet(); >- for (Iterator iter = changedControls.iterator(); iter.hasNext();) { >- Control control = (Control) iter.next(); >- String flagId = (String) control.getData(); >- if (control instanceof Combo) { >- int index = ((Combo) control).getSelectionIndex(); >- if (project == null) { >- CompilerFlags.setFlag(flagId, index); >- } >- } else if (control instanceof Button) { >- boolean value = ((Button) control).getSelection(); >- if (project == null) { >- CompilerFlags.setBoolean(flagId, value); >- } >- } else if (control instanceof Text) { >- String value = ((Text) control).getText(); >- if (project == null) { >- CompilerFlags.setString(flagId, value); >- } >- } >- if (control.getParent().equals(fPluginPage)) >- fBuilders.add(PDE.MANIFEST_BUILDER_ID); >- else if (control.getParent().equals(fSchemaPage)) >- fBuilders.add(PDE.SCHEMA_BUILDER_ID); >- else if (control.getParent().equals(fFeaturePage)) { >- fBuilders.add(PDE.FEATURE_BUILDER_ID); >- fBuilders.add(PDE.SITE_BUILDER_ID); >- } >- } >- if (project == null) { >- CompilerFlags.save(); >- } >- } >- if (project != null) { >- for (Iterator iter = fFlagControls.iterator(); iter.hasNext();) { >- Control control = (Control) iter.next(); >- String flagId = (String) control.getData(); >- if (control instanceof Combo) { >- int index = ((Combo) control).getSelectionIndex(); >- if (enabled) { >- CompilerFlags.setFlag(project, flagId, index); >- } else { >- CompilerFlags.clear(project, flagId); >- } >- } else if (control instanceof Button) { >- boolean value = ((Button) control).getSelection(); >- if (enabled) { >- CompilerFlags.setBoolean(project, flagId, value); >- } else { >- CompilerFlags.clear(project, flagId); >- } >- } else if (control instanceof Text) { >- String value = ((Text) control).getText(); >- if (enabled) { >- CompilerFlags.setString(project, flagId, value); >- } else { >- CompilerFlags.clear(project, flagId); >- } >- } >- } >- } >- >- if (build && fBuilders.size() > 0) { >- doFullBuild(); >- } >- >- fChangedControls.clear(); >- return true; >- } >-} >Index: src/org/eclipse/pde/internal/ui/preferences/CompilersPreferencePage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/CompilersPreferencePage.java,v >retrieving revision 1.31 >diff -u -r1.31 CompilersPreferencePage.java >--- src/org/eclipse/pde/internal/ui/preferences/CompilersPreferencePage.java 16 Jan 2008 17:08:15 -0000 1.31 >+++ src/org/eclipse/pde/internal/ui/preferences/CompilersPreferencePage.java 16 Apr 2008 18:40:08 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 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 >@@ -10,28 +10,44 @@ > *******************************************************************************/ > package org.eclipse.pde.internal.ui.preferences; > >-import org.eclipse.jface.dialogs.Dialog; >+import java.util.HashMap; >+import java.util.HashSet; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.jdt.core.*; >+import org.eclipse.jface.dialogs.IDialogConstants; > import org.eclipse.jface.preference.PreferencePage; >-import org.eclipse.pde.internal.ui.IHelpContextIds; >-import org.eclipse.pde.internal.ui.PDEUIMessages; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Control; >+import org.eclipse.pde.internal.core.natures.PDE; >+import org.eclipse.pde.internal.ui.*; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.*; > import org.eclipse.ui.*; >+import org.eclipse.ui.dialogs.PreferencesUtil; >+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; > >+/** >+ * Allows PDE compiler preferences to be set >+ */ > public class CompilersPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { > >- private CompilersConfigurationTab configurationBlock; >+ public static final String NO_LINK = "PropertyAndPreferencePage.nolink"; //$NON-NLS-1$ >+ >+ private PDECompilersConfigurationBlock fBlock = null; >+ private Link link = null; >+ >+ private HashMap fPageData = null; > > /** > * > */ > public CompilersPreferencePage() { > super(); >- setDescription(PDEUIMessages.CompilersPreferencePage_desc); >- // only used when page is shown programatically >+ // only used when page is shown programmatically > setTitle(PDEUIMessages.CompilersPreferencePage_title); >- >- configurationBlock = new CompilersConfigurationTab(null); > } > > /* >@@ -40,44 +56,100 @@ > * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) > */ > protected Control createContents(Composite parent) { >- Control result = configurationBlock.createContents(parent); >- Dialog.applyDialogFont(result); >- return result; >+ Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0); >+ link = new Link(comp, SWT.NONE); >+ link.setLayoutData(new GridData(GridData.END, GridData.CENTER, true, false)); >+ link.setFont(comp.getFont()); >+ link.setText(PDEUIMessages.CompilersPreferencePage_configure_project_specific_settings); >+ link.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ HashSet set = new HashSet(); >+ try { >+ IJavaProject[] projects = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects(); >+ IProject project = null; >+ for (int i = 0; i < projects.length; i++) { >+ project = projects[i].getProject(); >+ try { >+ if (project.hasNature(PDE.PLUGIN_NATURE) && fBlock.hasProjectSpecificSettings(project)) { >+ set.add(projects[i]); >+ } >+ } catch (CoreException ce) { >+ //do nothing ignore the project >+ } >+ } >+ } catch (JavaModelException jme) { >+ //ignore >+ } >+ ProjectSelectionDialog psd = new ProjectSelectionDialog(getShell(), set); >+ if (psd.open() == IDialogConstants.OK_ID) { >+ HashMap data = new HashMap(); >+ data.put(NO_LINK, Boolean.TRUE); >+ PreferencesUtil.createPropertyDialogOn(getShell(), ((IJavaProject) psd.getFirstResult()).getProject(), "org.eclipse.pde.internal.ui.properties.compilersPropertyPage", //$NON-NLS-1$ >+ new String[] {"org.eclipse.pde.internal.ui.properties.compilersPropertyPage"}, data).open(); //$NON-NLS-1$ >+ } >+ } >+ }); >+ fBlock = new PDECompilersConfigurationBlock(null, (IWorkbenchPreferenceContainer) getContainer()); >+ fBlock.createControl(comp); >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IHelpContextIds.COMPILERS_PREFERENCE_PAGE); >+ return comp; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.DialogPage#dispose() >+ */ >+ public void dispose() { >+ if (fBlock != null) { >+ fBlock.dispose(); >+ } >+ super.dispose(); > } > >- /* >- * @see PreferencePage#createControl(Composite) >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) > */ >- public void createControl(Composite parent) { >- super.createControl(parent); >- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.COMPILERS_PREFERENCE_PAGE); >+ public void init(IWorkbench workbench) { > } > >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.preference.PreferencePage#performCancel() > */ >- public void init(IWorkbench workbench) { >+ public boolean performCancel() { >+ fBlock.performCancel(); >+ return super.performCancel(); > } > >- /* >- * @see PreferencePage#performDefaults() >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.preference.PreferencePage#performOk() >+ */ >+ public boolean performOk() { >+ fBlock.performOK(); >+ return super.performOk(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.preference.PreferencePage#performApply() >+ */ >+ protected void performApply() { >+ fBlock.performApply(); >+ super.performApply(); >+ } >+ >+ /** >+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults() > */ > protected void performDefaults() { >- configurationBlock.performDefaults(); >+ fBlock.performDefaults(); > super.performDefaults(); > } > >- /* >- * @see IPreferencePage#performOk() >+ /** >+ * @see org.eclipse.jface.preference.PreferencePage#applyData(java.lang.Object) > */ >- public boolean performOk() { >- if (!configurationBlock.performOk(true)) { >- getContainer().updateButtons(); >- return false; >+ public void applyData(Object data) { >+ if (data instanceof HashMap) { >+ fPageData = (HashMap) data; >+ link.setVisible(!Boolean.TRUE.equals(fPageData.get(NO_LINK))); > } >- return super.performOk(); > } >- > } >Index: src/org/eclipse/pde/internal/ui/PDEUIMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java,v >retrieving revision 1.367 >diff -u -r1.367 PDEUIMessages.java >--- src/org/eclipse/pde/internal/ui/PDEUIMessages.java 9 Apr 2008 04:01:02 -0000 1.367 >+++ src/org/eclipse/pde/internal/ui/PDEUIMessages.java 16 Apr 2008 18:40:08 -0000 >@@ -91,6 +91,18 @@ > > public static String OrganizeManifestsProcessor_rootMessage; > >+ public static String PDECompilersConfigurationBlock_general; >+ >+ public static String PDECompilersConfigurationBlock_references; >+ >+ public static String PDECompilersConfigurationBlock_setting_changed_project; >+ >+ public static String PDECompilersConfigurationBlock_settings_changed; >+ >+ public static String PDECompilersConfigurationBlock_settings_changed_all; >+ >+ public static String PDECompilersConfigurationBlock_usage; >+ > public static String PDEWizardNewFileCreationPage_errorMsgStartsWithDot; > > public static String CommandComposerPart_formTitle; >@@ -1895,17 +1907,14 @@ > public static String SiteHTML_loadError; > > // >- >- public static String CompilersConfigurationBlock_error; >- public static String CompilersConfigurationBlock_warning; >- public static String CompilersConfigurationBlock_ignore; > public static String CompilersConfigurationBlock_plugins; > public static String CompilersConfigurationBlock_schemas; > public static String CompilersConfigurationBlock_features; > public static String CompilersConfigurationBlock_label; > public static String CompilersConfigurationBlock_altlabel; > >- public static String CompilersPreferencePage_desc; >+ public static String CompilersPreferencePage_configure_project_specific_settings; >+ > public static String CompilersPreferencePage_title; > > public static String CompilersPropertyPage_useworkspacesettings_change; >Index: src/org/eclipse/pde/internal/ui/IPreferenceConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/IPreferenceConstants.java,v >retrieving revision 1.24 >diff -u -r1.24 IPreferenceConstants.java >--- src/org/eclipse/pde/internal/ui/IPreferenceConstants.java 16 Jan 2008 17:08:37 -0000 1.24 >+++ src/org/eclipse/pde/internal/ui/IPreferenceConstants.java 16 Apr 2008 18:40:07 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 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 >@@ -10,8 +10,18 @@ > *******************************************************************************/ > package org.eclipse.pde.internal.ui; > >+/** >+ * Listing of constants used in PDE preferences >+ * >+ * @noimplement This interface is not intended to be implemented by clients. >+ */ > public interface IPreferenceConstants { > >+ //compiler options >+ public static final String VALUE_ERROR = "Error"; //$NON-NLS-1$ >+ public static final String VALUE_WARNING = "Warning"; //$NON-NLS-1$ >+ public static final String VALUE_IGNORE = "Ignore"; //$NON-NLS-1$ >+ > // Main preference page > public static final String PROP_SHOW_OBJECTS = "Preferences.MainPage.showObjects"; //$NON-NLS-1$ > public static final String VALUE_USE_IDS = "useIds"; //$NON-NLS-1$ >Index: src/org/eclipse/pde/internal/ui/pderesources.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties,v >retrieving revision 1.983 >diff -u -r1.983 pderesources.properties >--- src/org/eclipse/pde/internal/ui/pderesources.properties 14 Apr 2008 14:19:52 -0000 1.983 >+++ src/org/eclipse/pde/internal/ui/pderesources.properties 16 Apr 2008 18:40:08 -0000 >@@ -55,6 +55,12 @@ > ToggleLinkWithEditorAction_label = Lin&k with Editor > ToggleLinkWithEditorAction_toolTip = Link with Editor > ToggleLinkWithEditorAction_description = Link with active editorPDEMultiPageContentOutline.SortingAction.label = Sort >+PDECompilersConfigurationBlock_general=General >+PDECompilersConfigurationBlock_references=References >+PDECompilersConfigurationBlock_setting_changed_project=Compiler settings have changed. A rebuild of the project is required for the changes to take effect.\n\nRebuild {0} now? >+PDECompilersConfigurationBlock_settings_changed=Settings Changed >+PDECompilersConfigurationBlock_settings_changed_all=Compiler settings have changed. A full build is required for the changes to take effect.\n\nDo a full build now? >+PDECompilersConfigurationBlock_usage=Usage > PDEMultiPageContentOutline_SortingAction_label = Sort > PDEMultiPageContentOutline_SortingAction_tooltip = Sort > PDEMultiPageContentOutline_SortingAction_description = Sorts elements in the outline >@@ -1436,9 +1442,6 @@ > > ############## > >-CompilersConfigurationBlock_error=Error >-CompilersConfigurationBlock_warning=Warning >-CompilersConfigurationBlock_ignore=Ignore > CompilersConfigurationBlock_plugins=&Plug-ins > CompilersConfigurationBlock_schemas=&Schemas > CompilersConfigurationBlock_features=&Features and Update Sites >@@ -1457,10 +1460,10 @@ > CompCSCreationOperation_introduction=Introduction > CompilersConfigurationBlock_altlabel=Select the following compiler options: > >-CompilersPreferencePage_desc=Options for manifest compilers > CompCSTaskGroupDetails_Type=Type*: > CompCSTaskGroupDetails_Name=Name*: > CompCSTaskDetails_SkipLabel=This task is optional >+CompilersPreferencePage_configure_project_specific_settings=<A>Configure Project Specific Settings...</A> > CompilersPreferencePage_title=Plug-in Compiler > CompCSMasterTreeSection_addTask=Add Task > CompCSTaskGroupDetails_Choice=Choice >Index: src/org/eclipse/pde/internal/ui/IHelpContextIds.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/IHelpContextIds.java,v >retrieving revision 1.41 >diff -u -r1.41 IHelpContextIds.java >--- src/org/eclipse/pde/internal/ui/IHelpContextIds.java 6 Mar 2008 19:46:33 -0000 1.41 >+++ src/org/eclipse/pde/internal/ui/IHelpContextIds.java 16 Apr 2008 18:40:07 -0000 >@@ -24,6 +24,7 @@ > public static final String IMPLICIT_PLUGINS_PREFERENCE_PAGE = PREFIX + "implicit_plugins_preference_page"; //$NON-NLS-1$ > public static final String LAUNCHING_ARGS_PREFERENCE_PAGE = PREFIX + "launching_args_preference_page"; //$NON-NLS-1$ > public static final String COMPILERS_PREFERENCE_PAGE = PREFIX + "compilers_preference_page"; //$NON-NLS-1$ >+ public static final String PROJECT_SELECTION_DIALOG = PREFIX + "project_selection_dialog"; //$NON-NLS-1$ > public static final String TARGET_ENVIRONMENT_PREFERENCE_PAGE = PREFIX + "target_environment_preference_page"; //$NON-NLS-1$ > public static final String TARGET_PLATFORM_PREFERENCE_PAGE = PREFIX + "target_platform_preference_page"; //$NON-NLS-1$ > >Index: src/org/eclipse/pde/internal/ui/properties/CompilersPropertyPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/properties/CompilersPropertyPage.java,v >retrieving revision 1.11 >diff -u -r1.11 CompilersPropertyPage.java >--- src/org/eclipse/pde/internal/ui/properties/CompilersPropertyPage.java 25 Feb 2008 17:59:15 -0000 1.11 >+++ src/org/eclipse/pde/internal/ui/properties/CompilersPropertyPage.java 16 Apr 2008 18:40:08 -0000 >@@ -10,31 +10,35 @@ > *******************************************************************************/ > package org.eclipse.pde.internal.ui.properties; > >+import java.util.HashMap; > import org.eclipse.core.resources.IProject; >-import org.eclipse.jface.dialogs.ControlEnableState; > import org.eclipse.jface.dialogs.Dialog; >-import org.eclipse.pde.internal.core.builders.CompilerFlags; >-import org.eclipse.pde.internal.ui.IHelpContextIds; >-import org.eclipse.pde.internal.ui.PDEUIMessages; >-import org.eclipse.pde.internal.ui.preferences.CompilersConfigurationTab; >+import org.eclipse.pde.internal.ui.*; >+import org.eclipse.pde.internal.ui.preferences.CompilersPreferencePage; >+import org.eclipse.pde.internal.ui.preferences.PDECompilersConfigurationBlock; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.SelectionAdapter; > import org.eclipse.swt.events.SelectionEvent; > import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.*; > import org.eclipse.ui.PlatformUI; >-import org.eclipse.ui.dialogs.PreferencesUtil; > import org.eclipse.ui.dialogs.PropertyPage; >+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; > > /** > * The PDE manifest compiler options property page for plugin projects > */ > public class CompilersPropertyPage extends PropertyPage { > >- private ControlEnableState blockEnableState; >- private CompilersConfigurationTab configurationBlock; >- private Control configurationBlockControl; >+ /** >+ * The data map passed when showing the page >+ */ >+ private HashMap fPageData = null; >+ >+ /** >+ * The control block >+ */ >+ private PDECompilersConfigurationBlock fBlock = null; > > /** > * If project specific settings are being used or not >@@ -52,54 +56,45 @@ > * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) > */ > protected Control createContents(Composite parent) { >- configurationBlock = new CompilersConfigurationTab(getProject()); >- Composite composite = new Composite(parent, SWT.NONE); >- GridLayout layout = new GridLayout(); >- layout.marginHeight = 0; >- layout.marginWidth = 0; >- layout.numColumns = 2; >- composite.setLayout(layout); >- >- fProjectSpecific = new Button(composite, SWT.CHECK); >+ Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0); >+ Composite tcomp = SWTFactory.createComposite(comp, 2, 1, GridData.FILL_HORIZONTAL, 0, 0); >+ fProjectSpecific = new Button(tcomp, SWT.CHECK); > fProjectSpecific.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, true, false)); > fProjectSpecific.setText(PDEUIMessages.CompilersPropertyPage_useprojectsettings_label); > fProjectSpecific.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { >- updateEnableState(); >- } >- }); >- >- fWorkspaceLink = new Link(composite, SWT.NONE); >- fWorkspaceLink.setText(PDEUIMessages.CompilersPropertyPage_useworkspacesettings_change); >- fWorkspaceLink.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- String id = "org.eclipse.pde.ui.CompilersPreferencePage"; //$NON-NLS-1$ >- PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String[] {id}, null).open(); >+ boolean psp = fProjectSpecific.getSelection(); >+ fBlock.useProjectSpecificSettings(psp); >+ if (fWorkspaceLink != null) { >+ fWorkspaceLink.setEnabled(!psp); >+ } > } > }); > >- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); >- data.horizontalSpan = 2; >- >- configurationBlockControl = configurationBlock.createContents(composite); >- configurationBlockControl.setLayoutData(data); >- >- boolean useProjectSettings = CompilerFlags.getBoolean(getProject(), CompilerFlags.USE_PROJECT_PREF); >- >- fProjectSpecific.setSelection(useProjectSettings); >- fWorkspaceLink.setEnabled(!useProjectSettings); >+ if (offerLink()) { >+ fWorkspaceLink = new Link(tcomp, SWT.NONE); >+ fWorkspaceLink.setText(PDEUIMessages.CompilersPropertyPage_useworkspacesettings_change); >+ fWorkspaceLink.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ HashMap data = new HashMap(); >+ data.put(CompilersPreferencePage.NO_LINK, Boolean.TRUE); >+ SWTFactory.showPreferencePage("org.eclipse.pde.ui.CompilersPreferencePage", data); //$NON-NLS-1$ >+ } >+ }); >+ } > >- updateEnableState(); >- Dialog.applyDialogFont(composite); >- return composite; >- } >+ fBlock = new PDECompilersConfigurationBlock(getProject(), (IWorkbenchPreferenceContainer) getContainer()); >+ fBlock.createControl(comp); > >- /* >- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) >- */ >- public void createControl(Composite parent) { >- super.createControl(parent); >- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.COMPILERS_PROPERTY_PAGE); >+ boolean ps = fBlock.hasProjectSpecificSettings(getProject()); >+ fProjectSpecific.setSelection(ps); >+ fBlock.useProjectSpecificSettings(ps); >+ if (fWorkspaceLink != null) { >+ fWorkspaceLink.setEnabled(!ps); >+ } >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IHelpContextIds.COMPILERS_PROPERTY_PAGE); >+ Dialog.applyDialogFont(comp); >+ return comp; > } > > /** >@@ -109,51 +104,60 @@ > return (IProject) getElement().getAdapter(IProject.class); > } > >- /* >- * @see org.eclipse.jface.preference.IPreferencePage#performDefaults() >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.preference.PreferencePage#performCancel() > */ >- protected void performDefaults() { >- if (useProjectSettings()) { >- fProjectSpecific.setSelection(false); >- updateEnableState(); >- configurationBlock.performDefaults(); >- } >- super.performDefaults(); >+ public boolean performCancel() { >+ fBlock.performCancel(); >+ return super.performCancel(); > } > >- /* >- * @see org.eclipse.jface.preference.IPreferencePage#performOk() >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.preference.PreferencePage#performOk() > */ > public boolean performOk() { >- if (!configurationBlock.performOk(useProjectSettings())) { >- getContainer().updateButtons(); >- return false; >- } >+ fBlock.performOK(); > return super.performOk(); > } > > /** >- * Updates the enabled state of the controls based on the project specific settings >+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults() > */ >- private void updateEnableState() { >- if (useProjectSettings()) { >- if (blockEnableState != null) { >- fWorkspaceLink.setEnabled(false); >- blockEnableState.restore(); >- blockEnableState = null; >- } >- } else { >- if (blockEnableState == null) { >- fWorkspaceLink.setEnabled(true); >- blockEnableState = ControlEnableState.disable(configurationBlockControl); >- } >- } >+ protected void performDefaults() { >+ fBlock.performDefaults(); >+ super.performDefaults(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.preference.PreferencePage#performApply() >+ */ >+ protected void performApply() { >+ fBlock.performApply(); >+ super.performApply(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.DialogPage#dispose() >+ */ >+ public void dispose() { >+ fBlock.dispose(); >+ super.dispose(); > } > > /** >- * @return if project specific settings are being configured >+ * @return true if the link should be shown, false otherwise > */ >- private boolean useProjectSettings() { >- return fProjectSpecific.getSelection(); >+ private boolean offerLink() { >+ return fPageData == null || !Boolean.TRUE.equals(fPageData.get(CompilersPreferencePage.NO_LINK)); >+ } >+ >+ /** >+ * @see org.eclipse.jface.preference.PreferencePage#applyData(java.lang.Object) >+ */ >+ public void applyData(Object data) { >+ if (data instanceof HashMap) { >+ fPageData = (HashMap) data; >+ fWorkspaceLink.setVisible(!Boolean.TRUE.equals(fPageData.get(CompilersPreferencePage.NO_LINK))); >+ } > } > } >Index: src/org/eclipse/pde/internal/ui/preferences/ProjectSelectionDialog.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/preferences/ProjectSelectionDialog.java >diff -N src/org/eclipse/pde/internal/ui/preferences/ProjectSelectionDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/preferences/ProjectSelectionDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,185 @@ >+/******************************************************************************* >+ * 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.ui.preferences; >+ >+import java.util.HashSet; >+import java.util.Set; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.*; >+import org.eclipse.jdt.core.*; >+import org.eclipse.jdt.ui.*; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.dialogs.IDialogSettings; >+import org.eclipse.jface.viewers.*; >+import org.eclipse.pde.internal.core.natures.PDE; >+import org.eclipse.pde.internal.ui.*; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.dialogs.SelectionStatusDialog; >+ >+/** >+ * A dialog for selecting a project to configure project specific settings for >+ * >+ * @since 1.0.0 >+ */ >+public class ProjectSelectionDialog extends SelectionStatusDialog { >+ >+ class ApiJavaElementContentProvider extends StandardJavaElementContentProvider { >+ public Object[] getChildren(Object element) { >+ if (element instanceof IJavaModel) { >+ IJavaModel model = (IJavaModel) element; >+ HashSet set = new HashSet(); >+ try { >+ IJavaProject[] projects = model.getJavaProjects(); >+ for (int i = 0; i < projects.length; i++) { >+ if (projects[i].getProject().hasNature(PDE.PLUGIN_NATURE)) { >+ set.add(projects[i]); >+ } >+ } >+ } catch (JavaModelException jme) { >+ //ignore >+ } catch (CoreException ce) { >+ //ignore >+ } >+ return set.toArray(); >+ } >+ return super.getChildren(element); >+ } >+ } >+ >+ // the visual selection widget group >+ private TableViewer fTableViewer; >+ private Set fProjectsWithSpecifics; >+ >+ // sizing constants >+ private final static int SIZING_SELECTION_WIDGET_HEIGHT = 250; >+ private final static int SIZING_SELECTION_WIDGET_WIDTH = 300; >+ >+ private final static String DIALOG_SETTINGS_SHOW_ALL = "ProjectSelectionDialog.show_all"; //$NON-NLS-1$ >+ >+ /** >+ * The filter for the viewer >+ */ >+ private ViewerFilter fFilter; >+ >+ /** >+ * Constructor >+ * @param parentShell >+ * @param projectsWithSpecifics >+ */ >+ public ProjectSelectionDialog(Shell parentShell, Set projectsWithSpecifics) { >+ super(parentShell); >+ setTitle("Project Specific Configuration"); >+ setMessage("&Select the project to configure:"); >+ fProjectsWithSpecifics = projectsWithSpecifics; >+ >+ fFilter = new ViewerFilter() { >+ public boolean select(Viewer viewer, Object parentElement, Object element) { >+ return fProjectsWithSpecifics.contains(element); >+ } >+ }; >+ } >+ >+ /* (non-Javadoc) >+ * Method declared on Dialog. >+ */ >+ protected Control createDialogArea(Composite parent) { >+ // page group >+ Composite composite = (Composite) super.createDialogArea(parent); >+ >+ Font font = parent.getFont(); >+ composite.setFont(font); >+ >+ createMessageArea(composite); >+ >+ fTableViewer = new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); >+ fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { >+ public void selectionChanged(SelectionChangedEvent event) { >+ doSelectionChanged(((IStructuredSelection) event.getSelection()).toArray()); >+ } >+ }); >+ fTableViewer.addDoubleClickListener(new IDoubleClickListener() { >+ public void doubleClick(DoubleClickEvent event) { >+ okPressed(); >+ } >+ }); >+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); >+ data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT; >+ data.widthHint = SIZING_SELECTION_WIDGET_WIDTH; >+ fTableViewer.getTable().setLayoutData(data); >+ >+ fTableViewer.setLabelProvider(new JavaElementLabelProvider()); >+ fTableViewer.setContentProvider(new ApiJavaElementContentProvider()); >+ fTableViewer.setComparator(new JavaElementComparator()); >+ fTableViewer.getControl().setFont(font); >+ >+ Button checkbox = SWTFactory.createCheckButton(composite, "Show only &projects with project specific settings", null, false, 1); >+ checkbox.addSelectionListener(new SelectionListener() { >+ public void widgetSelected(SelectionEvent e) { >+ updateFilter(((Button) e.widget).getSelection()); >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ updateFilter(((Button) e.widget).getSelection()); >+ } >+ }); >+ IDialogSettings dialogSettings = PDEPlugin.getDefault().getDialogSettings(); >+ boolean doFilter = !dialogSettings.getBoolean(DIALOG_SETTINGS_SHOW_ALL) && !fProjectsWithSpecifics.isEmpty(); >+ checkbox.setSelection(doFilter); >+ updateFilter(doFilter); >+ >+ IJavaModel input = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()); >+ fTableViewer.setInput(input); >+ >+ doSelectionChanged(new Object[0]); >+ Dialog.applyDialogFont(composite); >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.PROJECT_SELECTION_DIALOG); >+ return composite; >+ } >+ >+ /** >+ * Handles the change in selection of the viewer and updates the status of the dialog at the same time >+ * @param objects >+ */ >+ private void doSelectionChanged(Object[] objects) { >+ if (objects.length != 1) { >+ updateStatus(new Status(IStatus.ERROR, PDEPlugin.getPluginId(), "")); //$NON-NLS-1$ >+ setSelectionResult(null); >+ } else { >+ updateStatus(new Status(IStatus.OK, PDEPlugin.getPluginId(), "")); //$NON-NLS-1$ >+ setSelectionResult(objects); >+ } >+ } >+ >+ /** >+ * Updates the viewer filter based on the selection of the 'show project with...' button >+ * @param selected >+ */ >+ protected void updateFilter(boolean selected) { >+ if (selected) { >+ fTableViewer.addFilter(fFilter); >+ } else { >+ fTableViewer.removeFilter(fFilter); >+ } >+ PDEPlugin.getDefault().getDialogSettings().put(DIALOG_SETTINGS_SHOW_ALL, !selected); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.dialogs.SelectionStatusDialog#computeResult() >+ */ >+ protected void computeResult() { >+ } >+} >Index: src/org/eclipse/pde/internal/ui/PixelConverter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/PixelConverter.java >diff -N src/org/eclipse/pde/internal/ui/PixelConverter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/PixelConverter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,43 @@ >+/******************************************************************************* >+ * 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.ui; >+ >+ >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.swt.graphics.FontMetrics; >+import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.widgets.Control; >+ >+public class PixelConverter { >+ >+ private FontMetrics fFontMetrics; >+ >+ public PixelConverter(Control control) { >+ GC gc = new GC(control); >+ gc.setFont(control.getFont()); >+ fFontMetrics= gc.getFontMetrics(); >+ gc.dispose(); >+ } >+ >+ /** >+ * @see DialogPage#convertHorizontalDLUsToPixels >+ */ >+ public int convertHorizontalDLUsToPixels(int dlus) { >+ return Dialog.convertHorizontalDLUsToPixels(fFontMetrics, dlus); >+ } >+ >+ /** >+ * @see DialogPage#convertWidthInCharsToPixels >+ */ >+ public int convertWidthInCharsToPixels(int chars) { >+ return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars); >+ } >+} >Index: src/org/eclipse/pde/internal/ui/SWTFactory.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/SWTFactory.java >diff -N src/org/eclipse/pde/internal/ui/SWTFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/SWTFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,545 @@ >+/******************************************************************************* >+ * 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.ui; >+ >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.jface.dialogs.IDialogConstants; >+import org.eclipse.jface.resource.JFaceResources; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.ui.dialogs.PreferencesUtil; >+import org.eclipse.ui.forms.widgets.ExpandableComposite; >+import org.eclipse.ui.forms.widgets.SharedScrolledComposite; >+ >+/** >+ * Factory class to create some SWT resources. >+ * >+ * @since 3.4.0 >+ */ >+public class SWTFactory { >+ >+ /** >+ * Returns a width hint for a button control. >+ */ >+ public static int getButtonWidthHint(Button button) { >+ button.setFont(JFaceResources.getDialogFont()); >+ PixelConverter converter = new PixelConverter(button); >+ int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); >+ return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); >+ } >+ >+ /** >+ * Sets width and height hint for the button control. >+ * <b>Note:</b> This is a NOP if the button's layout data is not >+ * an instance of <code>GridData</code>. >+ * >+ * @param the button for which to set the dimension hint >+ */ >+ public static void setButtonDimensionHint(Button button) { >+ Assert.isNotNull(button); >+ Object gd = button.getLayoutData(); >+ if (gd instanceof GridData) { >+ ((GridData) gd).widthHint = getButtonWidthHint(button); >+ ((GridData) gd).horizontalAlignment = GridData.FILL; >+ } >+ } >+ >+ /** >+ * Creates a check box button using the parents' font >+ * >+ * @param parent the parent to add the button to >+ * @param label the label for the button >+ * @param image the image for the button >+ * @param checked the initial checked state of the button >+ * @param hspan the horizontal span to take up in the parent composite >+ * @return a new checked button set to the initial checked state >+ */ >+ public static Button createCheckButton(Composite parent, String label, Image image, boolean checked, int hspan) { >+ Button button = new Button(parent, SWT.CHECK); >+ button.setFont(parent.getFont()); >+ button.setSelection(checked); >+ if (image != null) { >+ button.setImage(image); >+ } >+ if (label != null) { >+ button.setText(label); >+ } >+ GridData gd = new GridData(); >+ gd.horizontalSpan = hspan; >+ button.setLayoutData(gd); >+ setButtonDimensionHint(button); >+ return button; >+ } >+ >+ /** >+ * Creates and returns a new push button with the given >+ * label and/or image. >+ * >+ * @param parent parent control >+ * @param label button label or <code>null</code> >+ * @param image image of <code>null</code> >+ * @return a new push button >+ */ >+ public static Button createPushButton(Composite parent, String label, Image image) { >+ Button button = new Button(parent, SWT.PUSH); >+ button.setFont(parent.getFont()); >+ if (image != null) { >+ button.setImage(image); >+ } >+ if (label != null) { >+ button.setText(label); >+ } >+ GridData gd = new GridData(); >+ button.setLayoutData(gd); >+ SWTFactory.setButtonDimensionHint(button); >+ return button; >+ } >+ >+ /** >+ * Creates and returns a new push button with the given >+ * label and/or image. >+ * >+ * @param parent parent control >+ * @param label button label or <code>null</code> >+ * @param image image of <code>null</code> >+ * @param fill the alignment for the new button >+ * @return a new push button >+ */ >+ public static Button createPushButton(Composite parent, String label, Image image, int fill) { >+ Button button = new Button(parent, SWT.PUSH); >+ button.setFont(parent.getFont()); >+ if (image != null) { >+ button.setImage(image); >+ } >+ if (label != null) { >+ button.setText(label); >+ } >+ GridData gd = new GridData(fill); >+ button.setLayoutData(gd); >+ SWTFactory.setButtonDimensionHint(button); >+ return button; >+ } >+ >+ /** >+ * Creates and returns a new radio button with the given >+ * label. >+ * >+ * @param parent parent control >+ * @param label button label or <code>null</code> >+ * @return a new radio button >+ */ >+ public static Button createRadioButton(Composite parent, String label) { >+ Button button = new Button(parent, SWT.RADIO); >+ button.setFont(parent.getFont()); >+ if (label != null) { >+ button.setText(label); >+ } >+ GridData gd = new GridData(); >+ button.setLayoutData(gd); >+ SWTFactory.setButtonDimensionHint(button); >+ return button; >+ } >+ >+ /** >+ * Creates a new label widget >+ * >+ * @param parent the parent composite to add this label widget to >+ * @param text the text for the label >+ * @param hspan the horizontal span to take up in the parent composite >+ * @return the new label >+ */ >+ public static Label createLabel(Composite parent, String text, int hspan) { >+ Label l = new Label(parent, SWT.NONE); >+ l.setFont(parent.getFont()); >+ l.setText(text); >+ GridData gd = new GridData(GridData.FILL_HORIZONTAL); >+ gd.horizontalSpan = hspan; >+ gd.grabExcessHorizontalSpace = false; >+ l.setLayoutData(gd); >+ return l; >+ } >+ >+ /** >+ * Creates a new label widget >+ * >+ * @param parent the parent composite to add this label widget to >+ * @param text the text for the label >+ * @param font the font for the label >+ * @param hspan the horizontal span to take up in the parent composite >+ * @return the new label >+ */ >+ public static Label createLabel(Composite parent, String text, Font font, int hspan) { >+ Label l = new Label(parent, SWT.NONE); >+ l.setFont(font); >+ l.setText(text); >+ GridData gd = new GridData(GridData.FILL_HORIZONTAL); >+ gd.horizontalSpan = hspan; >+ l.setLayoutData(gd); >+ return l; >+ } >+ >+ /** >+ * Creates a wrapping label >+ * >+ * @param parent the parent composite to add this label to >+ * @param text the text to be displayed in the label >+ * @param hspan the horizontal span that label should take up in the parent composite >+ * @param wrapwidth the width hint that the label should wrap at >+ * @return a new label that wraps at a specified width >+ */ >+ public static Label createWrapLabel(Composite parent, String text, int hspan, int wrapwidth) { >+ Label l = new Label(parent, SWT.NONE | SWT.WRAP); >+ l.setFont(parent.getFont()); >+ l.setText(text); >+ GridData gd = new GridData(GridData.FILL_HORIZONTAL); >+ gd.horizontalSpan = hspan; >+ gd.widthHint = wrapwidth; >+ l.setLayoutData(gd); >+ return l; >+ } >+ >+ /** >+ * Creates a wrapping label >+ * >+ * @param parent the parent composite to add this label to >+ * @param text the text to be displayed in the label >+ * @param hspan the horizontal span that label should take up in the parent composite >+ * @return a new label that wraps at a specified width >+ */ >+ public static Label createWrapLabel(Composite parent, String text, int hspan) { >+ Label l = new Label(parent, SWT.NONE | SWT.WRAP); >+ l.setFont(parent.getFont()); >+ l.setText(text); >+ GridData gd = new GridData(GridData.BEGINNING); >+ gd.horizontalSpan = hspan; >+ l.setLayoutData(gd); >+ return l; >+ } >+ >+ /** >+ * Creates a scrolled composite >+ * >+ * @param parent the parent to add to >+ * @param columns the number of columns for the composite >+ * @param hspan the horizontal span to take up in the parent >+ * @param marginwidth the width of the margins >+ * @param marginheight the height of the margins >+ * @return a new scrolled composite >+ */ >+ public static SharedScrolledComposite createScrolledComposite(Composite parent, int columns, int hspan, int marginwidth, int marginheight) { >+ SharedScrolledComposite comp = new SharedScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL) {}; >+ GridLayout layout = new GridLayout(columns, false); >+ layout.marginHeight = marginheight; >+ layout.marginWidth = marginwidth; >+ comp.setLayout(layout); >+ GridData gd = new GridData(GridData.FILL_BOTH); >+ gd.horizontalSpan = hspan; >+ comp.setLayoutData(gd); >+ comp.setExpandHorizontal(true); >+ comp.setExpandVertical(true); >+ return comp; >+ } >+ >+ /** >+ * Creates an ExpandibleComposite widget >+ * >+ * @param parent the parent to add this widget to >+ * @param style the style for ExpandibleComposite expanding handle, and layout >+ * @param label the label for the widget >+ * @param hspan how many columns to span in the parent >+ * @param fill the fill style for the widget >+ * Can be one of <code>GridData.FILL_HORIZONAL</code>, <code>GridData.FILL_BOTH</code> or <code>GridData.FILL_VERTICAL</code> >+ * @return a new ExpandibleComposite widget >+ */ >+ public static ExpandableComposite createExpandibleComposite(Composite parent, String label, int hspan, int fill) { >+ ExpandableComposite ex = new ExpandableComposite(parent, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT); >+ ex.setText(label); >+ ex.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); >+ GridData gd = new GridData(fill); >+ gd.horizontalSpan = hspan; >+ gd.grabExcessHorizontalSpace = true; >+ ex.setLayoutData(gd); >+ return ex; >+ } >+ >+ /** >+ * Creates a new text widget >+ * >+ * @param parent the parent composite to add this text widget to >+ * @param hspan the horizontal span to take up on the parent composite >+ * @return the new text widget >+ * >+ */ >+ public static Text createSingleText(Composite parent, int hspan) { >+ Text t = new Text(parent, SWT.SINGLE | SWT.BORDER); >+ t.setFont(parent.getFont()); >+ GridData gd = new GridData(GridData.FILL_HORIZONTAL); >+ gd.horizontalSpan = hspan; >+ t.setLayoutData(gd); >+ return t; >+ } >+ >+ /** >+ * Creates a new text widget >+ * >+ * @param parent the parent composite to add this text widget to >+ * @param style the style bits for the text widget >+ * @param hspan the horizontal span to take up on the parent composite >+ * @param fill the fill for the grid layout >+ * @return the new text widget >+ */ >+ public static Text createText(Composite parent, int style, int hspan, int fill) { >+ Text t = new Text(parent, style); >+ t.setFont(parent.getFont()); >+ GridData gd = new GridData(fill); >+ gd.horizontalSpan = hspan; >+ t.setLayoutData(gd); >+ return t; >+ } >+ >+ /** >+ * Creates a new text widget >+ * >+ * @param parent the parent composite to add this text widget to >+ * @param style the style bits for the text widget >+ * @param hspan the horizontal span to take up on the parent composite >+ * @return the new text widget >+ */ >+ public static Text createText(Composite parent, int style, int hspan) { >+ Text t = new Text(parent, style); >+ t.setFont(parent.getFont()); >+ GridData gd = new GridData(GridData.FILL_HORIZONTAL); >+ gd.horizontalSpan = hspan; >+ t.setLayoutData(gd); >+ return t; >+ } >+ >+ /** >+ * Creates a new text widget >+ * >+ * @param parent the parent composite to add this text widget to >+ * @param style the style bits for the text widget >+ * @param hspan the horizontal span to take up on the parent composite >+ * @param width the desired width of the text widget >+ * @param height the desired height of the text widget >+ * @param fill the fill style for the widget >+ * @return the new text widget >+ */ >+ public static Text createText(Composite parent, int style, int hspan, int width, int height, int fill) { >+ Text t = new Text(parent, style); >+ t.setFont(parent.getFont()); >+ GridData gd = new GridData(fill); >+ gd.horizontalSpan = hspan; >+ gd.widthHint = width; >+ gd.heightHint = height; >+ t.setLayoutData(gd); >+ return t; >+ } >+ >+ /** >+ * Creates a Group widget >+ * >+ * @param parent the parent composite to add this group to >+ * @param text the text for the heading of the group >+ * @param columns the number of columns within the group >+ * @param hspan the horizontal span the group should take up on the parent >+ * @param fill the style for how this composite should fill into its parent >+ * @return the new group >+ */ >+ public static Group createGroup(Composite parent, String text, int columns, int hspan, int fill) { >+ Group g = new Group(parent, SWT.NONE); >+ g.setLayout(new GridLayout(columns, false)); >+ g.setText(text); >+ g.setFont(parent.getFont()); >+ GridData gd = new GridData(fill); >+ gd.horizontalSpan = hspan; >+ g.setLayoutData(gd); >+ return g; >+ } >+ >+ /** >+ * Creates a composite that uses the parent's font and has a grid layout >+ * >+ * @param parent the parent to add the composite to >+ * @param columns the number of columns the composite should have >+ * @param hspan the horizontal span the new composite should take up in the parent >+ * @param fill the fill style of the composite {@link GridData} >+ * @return a new composite with a grid layout >+ */ >+ public static Composite createComposite(Composite parent, int columns, int hspan, int fill) { >+ Composite g = new Composite(parent, SWT.NONE); >+ g.setLayout(new GridLayout(columns, false)); >+ g.setFont(parent.getFont()); >+ GridData gd = new GridData(fill); >+ gd.horizontalSpan = hspan; >+ gd.grabExcessHorizontalSpace = true; >+ g.setLayoutData(gd); >+ return g; >+ } >+ >+ /** >+ * Creates a composite that uses the parent's font and has a grid layout >+ * >+ * @param parent the parent to add the composite to >+ * @param font the font to use for this composite >+ * @param columns the number of columns the composite should have >+ * @param hspan the horizontal span the new composite should take up in the parent >+ * @param fill the fill style of the composite {@link GridData} >+ * @return a new composite with a grid layout >+ */ >+ public static Composite createComposite(Composite parent, Font font, int columns, int hspan, int fill) { >+ Composite g = new Composite(parent, SWT.NONE); >+ g.setLayout(new GridLayout(columns, false)); >+ g.setFont(font); >+ GridData gd = new GridData(fill); >+ gd.horizontalSpan = hspan; >+ gd.grabExcessHorizontalSpace = true; >+ g.setLayoutData(gd); >+ return g; >+ } >+ >+ /** >+ * Creates a composite that uses the parent's font and has a grid layout >+ * >+ * @param parent the parent to add the composite to >+ * @param columns the number of columns the composite should have >+ * @param hspan the horizontal span the new composite should take up in the parent >+ * @param fill the fill style of the composite {@link GridData} >+ * @param style the style of the composite >+ * @return a new composite with a grid layout >+ */ >+ public static Composite createComposite(Composite parent, int columns, int hspan, int fill, int style) { >+ Composite g = new Composite(parent, style); >+ g.setLayout(new GridLayout(columns, false)); >+ g.setFont(parent.getFont()); >+ GridData gd = new GridData(fill); >+ gd.horizontalSpan = hspan; >+ gd.grabExcessHorizontalSpace = true; >+ g.setLayoutData(gd); >+ return g; >+ } >+ >+ /** >+ * Creates a vertical spacer for separating components. If applied to a >+ * <code>GridLayout</code>, this method will automatically span all of the columns of the parent >+ * to make vertical space >+ * >+ * @param parent the parent composite to add this spacer to >+ * @param numlines the number of vertical lines to make as space >+ */ >+ public static void createVerticalSpacer(Composite parent, int numlines) { >+ Label lbl = new Label(parent, SWT.NONE); >+ GridData gd = new GridData(GridData.FILL_HORIZONTAL); >+ Layout layout = parent.getLayout(); >+ if (layout instanceof GridLayout) { >+ gd.horizontalSpan = ((GridLayout) parent.getLayout()).numColumns; >+ } >+ gd.heightHint = numlines; >+ lbl.setLayoutData(gd); >+ } >+ >+ /** >+ * Creates a horizontal spacer for separating components >+ * >+ * @param comp >+ * @param numlines >+ */ >+ public static void createHorizontalSpacer(Composite comp, int numlines) { >+ Label lbl = new Label(comp, SWT.NONE); >+ GridData gd = new GridData(GridData.FILL_HORIZONTAL); >+ gd.horizontalSpan = numlines; >+ lbl.setLayoutData(gd); >+ } >+ >+ /** >+ * Creates a Composite widget >+ * >+ * @param parent the parent composite to add this composite to >+ * @param columns the number of columns within the composite >+ * @param hspan the horizontal span the composite should take up on the parent >+ * @param fill the style for how this composite should fill into its parent >+ * @param marginwidth the width of the margin to place on the sides of the composite (default is 5, specified by GridLayout) >+ * @param marginheight the height of the margin to place o the top and bottom of the composite >+ * @return the new composite >+ */ >+ public static Composite createComposite(Composite parent, int columns, int hspan, int fill, int marginwidth, int marginheight) { >+ Composite g = new Composite(parent, SWT.NONE); >+ GridLayout layout = new GridLayout(columns, false); >+ layout.marginWidth = marginwidth; >+ layout.marginHeight = marginheight; >+ g.setLayout(layout); >+ g.setFont(parent.getFont()); >+ GridData gd = new GridData(fill); >+ gd.horizontalSpan = hspan; >+ g.setLayoutData(gd); >+ return g; >+ } >+ >+ /** >+ * This method is used to make a combo box >+ * >+ * @param parent the parent composite to add the new combo to >+ * @param style the style for the Combo >+ * @param hspan the horizontal span to take up on the parent composite >+ * @param fill how the combo will fill into the composite >+ * Can be one of <code>GridData.FILL_HORIZONAL</code>, <code>GridData.FILL_BOTH</code> or <code>GridData.FILL_VERTICAL</code> >+ * @param items the item to put into the combo >+ * @return a new Combo instance >+ */ >+ public static Combo createCombo(Composite parent, int style, int hspan, int fill, String[] items) { >+ Combo c = new Combo(parent, style); >+ c.setFont(parent.getFont()); >+ GridData gd = new GridData(fill); >+ gd.horizontalSpan = hspan; >+ c.setLayoutData(gd); >+ if (items != null) { >+ c.setItems(items); >+ } >+ c.select(0); >+ return c; >+ } >+ >+ /** >+ * This method is used to make a combo box with a default fill style of GridData.FILL_HORIZONTAL >+ * >+ * @param parent the parent composite to add the new combo to >+ * @param style the style for the Combo >+ * @param hspan the horizontal span to take up on the parent composite >+ * @param items the item to put into the combo >+ * @return a new Combo instance >+ */ >+ public static Combo createCombo(Composite parent, int style, int hspan, String[] items) { >+ Combo c = new Combo(parent, style); >+ c.setFont(parent.getFont()); >+ GridData gd = new GridData(GridData.FILL_HORIZONTAL); >+ gd.horizontalSpan = hspan; >+ c.setLayoutData(gd); >+ if (items != null) { >+ c.setItems(items); >+ } >+ c.select(0); >+ return c; >+ } >+ >+ /** >+ * This method allows us to open the preference dialog on the specific page, in this case the perspective page >+ * >+ * @param id the id of preference page to show >+ * @param page the actual page to show >+ */ >+ public static void showPreferencePage(String id, Object data) { >+ PreferencesUtil.createPreferenceDialogOn(PDEPlugin.getActiveWorkbenchShell(), id, new String[] {id}, data).open(); >+ } >+} >Index: src/org/eclipse/pde/internal/ui/preferences/PDECompilersConfigurationBlock.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/preferences/PDECompilersConfigurationBlock.java >diff -N src/org/eclipse/pde/internal/ui/preferences/PDECompilersConfigurationBlock.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/preferences/PDECompilersConfigurationBlock.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,912 @@ >+/******************************************************************************* >+ * 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.ui.preferences; >+ >+import com.ibm.icu.text.MessageFormat; >+import java.util.*; >+import java.util.List; >+import org.eclipse.core.resources.*; >+import org.eclipse.core.runtime.*; >+import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.core.runtime.preferences.*; >+import org.eclipse.jface.dialogs.IDialogSettings; >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.jface.resource.JFaceResources; >+import org.eclipse.pde.internal.core.builders.CompilerFlags; >+import org.eclipse.pde.internal.core.natures.PDE; >+import org.eclipse.pde.internal.ui.*; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.ScrolledComposite; >+import org.eclipse.swt.events.*; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.ui.forms.events.ExpansionAdapter; >+import org.eclipse.ui.forms.events.ExpansionEvent; >+import org.eclipse.ui.forms.widgets.ExpandableComposite; >+import org.eclipse.ui.preferences.*; >+import org.osgi.service.prefs.BackingStoreException; >+ >+/** >+ * A configuration block for setting PDE compiler preferences >+ * >+ * @since 3.4 >+ */ >+public class PDECompilersConfigurationBlock { >+ >+ /** >+ * Provides data information for created controls >+ */ >+ protected static class ControlData { >+ private Key key; >+ private String[] values; >+ >+ /** >+ * Constructor >+ * @param key >+ * @param values >+ */ >+ public ControlData(Key key, String[] values) { >+ this.key = key; >+ this.values = values; >+ } >+ >+ public Key getKey() { >+ return key; >+ } >+ >+ public String getValue(boolean selection) { >+ int index = selection ? 0 : 1; >+ return values[index]; >+ } >+ >+ public String getValue(int index) { >+ return values[index]; >+ } >+ >+ public int getSelection(String value) { >+ if (value != null) { >+ for (int i = 0; i < values.length; i++) { >+ if (value.equals(values[i])) { >+ return i; >+ } >+ } >+ } >+ return values.length - 1; // assume the last option is the least severe >+ } >+ } >+ >+ /** >+ * Provides management for changed/stored values for a given preference key >+ */ >+ protected static class Key { >+ >+ private String qualifier; >+ private String key; >+ >+ /** >+ * Constructor >+ * @param qualifier >+ * @param key >+ */ >+ public Key(String qualifier, String key) { >+ this.qualifier = qualifier; >+ this.key = key; >+ } >+ >+ /** >+ * Returns the {@link IEclipsePreferences} node for the given context and {@link IWorkingCopyManager} >+ * @param context >+ * @param manager >+ * @return the {@link IEclipsePreferences} node or <code>null</code> >+ */ >+ private IEclipsePreferences getNode(IScopeContext context, IWorkingCopyManager manager) { >+ IEclipsePreferences node = context.getNode(qualifier); >+ if (manager != null) { >+ return manager.getWorkingCopy(node); >+ } >+ return node; >+ } >+ >+ /** >+ * Returns the value stored in the {@link IEclipsePreferences} node from the given context and working copy manager >+ * @param context >+ * @param manager >+ * @return the value from the {@link IEclipsePreferences} node or <code>null</code> >+ */ >+ public String getStoredValue(IScopeContext context, IWorkingCopyManager manager) { >+ IEclipsePreferences node = getNode(context, manager); >+ if (node != null) { >+ return node.get(key, null); >+ } >+ return null; >+ } >+ >+ /** >+ * Returns the stored value of this {@link IEclipsePreferences} node using a given lookup order, and allowing the >+ * top scope to be ignored >+ * @param lookupOrder >+ * @param ignoreTopScope >+ * @param manager >+ * @return the value from the {@link IEclipsePreferences} node or <code>null</code> >+ */ >+ public String getStoredValue(IScopeContext[] lookupOrder, boolean ignoreTopScope, IWorkingCopyManager manager) { >+ for (int i = ignoreTopScope ? 1 : 0; i < lookupOrder.length; i++) { >+ String value = getStoredValue(lookupOrder[i], manager); >+ if (value != null) { >+ return value; >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * Sets the value of this key >+ * @param context >+ * @param value >+ * @param manager >+ */ >+ public void setStoredValue(IScopeContext context, String value, IWorkingCopyManager manager) { >+ IEclipsePreferences node = getNode(context, manager); >+ if (value != null) { >+ node.put(key, value); >+ } else { >+ node.remove(key); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see java.lang.Object#toString() >+ */ >+ public String toString() { >+ return qualifier + '/' + key; >+ } >+ } >+ >+ /** >+ * Returns a new {@link Key} for the {@link PDEPlugin} preference store >+ * @param key >+ * @return the new {@link Key} for the {@link PDEPlugin} preference store >+ */ >+ protected final static Key getPDEPrefKey(String key) { >+ return new Key(PDE.PLUGIN_ID, key); >+ } >+ >+ //unresolved >+ private static final Key KEY_P_UNRESOLVED_IMPORTS = getPDEPrefKey(CompilerFlags.P_UNRESOLVED_IMPORTS); >+ private static final Key KEY_P_UNRESOLVED_EX_POINTS = getPDEPrefKey(CompilerFlags.P_UNRESOLVED_EX_POINTS); >+ private static final Key KEY_F_UNRESOLVED_PLUGINS = getPDEPrefKey(CompilerFlags.F_UNRESOLVED_PLUGINS); >+ private static final Key KEY_F_UNRESOLVED_FEATURES = getPDEPrefKey(CompilerFlags.F_UNRESOLVED_FEATURES); >+ >+ //unknown elements >+ private static final Key KEY_P_UNKNOWN_ELEMENT = getPDEPrefKey(CompilerFlags.P_UNKNOWN_ELEMENT); >+ private static final Key KEY_P_UNKNOWN_ATTRIBUTE = getPDEPrefKey(CompilerFlags.P_UNKNOWN_ATTRIBUTE); >+ private static final Key KEY_P_UNKNOWN_CLASS = getPDEPrefKey(CompilerFlags.P_UNKNOWN_CLASS); >+ private static final Key KEY_P_UNKNOWN_RESOURCE = getPDEPrefKey(CompilerFlags.P_UNKNOWN_RESOURCE); >+ private static final Key KEY_P_UNKNOWN_IDENTIFIER = getPDEPrefKey(CompilerFlags.P_UNKNOWN_IDENTIFIER); >+ >+ //general >+ private static final Key KEY_P_DISCOURAGED_CLASS = getPDEPrefKey(CompilerFlags.P_DISCOURAGED_CLASS); >+ private static final Key KEY_P_NO_REQUIRED_ATT = getPDEPrefKey(CompilerFlags.P_NO_REQUIRED_ATT); >+ private static final Key KEY_P_BUILD = getPDEPrefKey(CompilerFlags.P_BUILD); >+ private static final Key KEY_P_NOT_EXTERNALIZED = getPDEPrefKey(CompilerFlags.P_NOT_EXTERNALIZED); >+ private static final Key KEY_P_INCOMPATIBLE_ENV = getPDEPrefKey(CompilerFlags.P_INCOMPATIBLE_ENV); >+ private static final Key KEY_P_MISSING_EXPORT_PKGS = getPDEPrefKey(CompilerFlags.P_MISSING_EXPORT_PKGS); >+ private static final Key KEY_P_DEPRECATED = getPDEPrefKey(CompilerFlags.P_DEPRECATED); >+ private static final Key KEY_P_MISSING_BUNDLE_CLASSPATH_ENTRIES = getPDEPrefKey(CompilerFlags.P_MISSING_BUNDLE_CLASSPATH_ENTRIES); >+ private static final Key KEY_S_CREATE_DOCS = getPDEPrefKey(CompilerFlags.S_CREATE_DOCS); >+ private static final Key KEY_S_DOC_FOLDER = getPDEPrefKey(CompilerFlags.S_DOC_FOLDER); >+ private static final Key KEY_S_OPEN_TAGS = getPDEPrefKey(CompilerFlags.S_OPEN_TAGS); >+ >+ private static String[] SEVERITIES = {IPreferenceConstants.VALUE_ERROR, IPreferenceConstants.VALUE_WARNING, IPreferenceConstants.VALUE_IGNORE}; >+ >+ private static Key[] fgAllKeys = {KEY_F_UNRESOLVED_FEATURES, KEY_F_UNRESOLVED_PLUGINS, KEY_P_BUILD, KEY_P_DEPRECATED, KEY_P_DISCOURAGED_CLASS, KEY_P_INCOMPATIBLE_ENV, KEY_P_MISSING_BUNDLE_CLASSPATH_ENTRIES, KEY_P_MISSING_EXPORT_PKGS, KEY_P_NO_REQUIRED_ATT, KEY_P_NOT_EXTERNALIZED, KEY_P_UNKNOWN_ATTRIBUTE, KEY_P_UNKNOWN_CLASS, KEY_P_UNKNOWN_ELEMENT, KEY_P_UNKNOWN_IDENTIFIER, KEY_P_UNKNOWN_RESOURCE, KEY_P_UNRESOLVED_EX_POINTS, KEY_P_UNRESOLVED_IMPORTS, KEY_S_CREATE_DOCS, KEY_S_DOC_FOLDER, KEY_S_OPEN_TAGS}; >+ >+ /** >+ * Constant representing the {@link IDialogSettings} section for this block >+ */ >+ private static final String SETTINGS = "pde_compiler_errorwarnings_block"; //$NON-NLS-1$ >+ >+ /** >+ * The context of settings locations to search for values in >+ */ >+ private IScopeContext[] fLookupOrder = null; >+ >+ /** >+ * The project this block is working on settings for. Only applies in the >+ * case of project specific settings >+ */ >+ private IProject fProject = null; >+ >+ /** >+ * the working copy manager to work with settings >+ */ >+ private IWorkingCopyManager fManager = null; >+ >+ /** >+ * The main composite for the configuration block, used for enabling/disabling the block >+ */ >+ private Composite fMainComp = null; >+ >+ /** >+ * Stored old fProject specific settings. >+ */ >+ private IdentityHashMap fOldProjectSettings = null; >+ >+ /** >+ * Map of controls to the tab they appear on. Allows for optimizing which builders >+ * are used if changes are made >+ */ >+ private HashMap fControlMap = new HashMap(3); >+ >+ /** >+ * Listing of all of the {@link ExpandableComposite}s in the block >+ */ >+ private ArrayList fExpComps = new ArrayList(); >+ >+ /** >+ * Flag used to know if the page needs saving or not >+ */ >+ private boolean fDirty = false; >+ >+ /** >+ * counter to know how many times we have prompted users' to rebuild >+ */ >+ private int fRebuildcount = 0; >+ >+ /** >+ * Set of builders to use when building if there are changes >+ */ >+ private HashSet fBuilders = new HashSet(4); >+ >+ /** >+ * The parent this block has been added to >+ */ >+ private Composite fParent = null; >+ >+ /** >+ * Default selection listener for combo and check controls >+ */ >+ private SelectionListener selectionlistener = new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ if (e.widget instanceof Combo) { >+ Combo combo = (Combo) e.widget; >+ ControlData data = (ControlData) combo.getData(); >+ data.key.setStoredValue(fLookupOrder[0], Integer.toString(combo.getSelectionIndex()), fManager); >+ fDirty = true; >+ fRebuildcount = 0; >+ } else if (e.widget instanceof Button) { >+ Button button = (Button) e.widget; >+ ControlData data = (ControlData) button.getData(); >+ data.key.setStoredValue(fLookupOrder[0], Boolean.toString(button.getSelection()), fManager); >+ fDirty = true; >+ fRebuildcount = 0; >+ } >+ addBuilder((Control) e.widget); >+ } >+ }; >+ >+ /** >+ * Default modify listener for text controls >+ */ >+ private ModifyListener modifylistener = new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ if (e.widget instanceof Text) { >+ Text text = (Text) e.widget; >+ ControlData data = (ControlData) text.getData(); >+ data.key.setStoredValue(fLookupOrder[0], text.getText().trim(), fManager); >+ fDirty = true; >+ fRebuildcount = 0; >+ } >+ } >+ }; >+ >+ /** >+ * Constructor >+ * @param project >+ * @param container >+ */ >+ public PDECompilersConfigurationBlock(IProject project, IWorkbenchPreferenceContainer container) { >+ fProject = project; >+ if (fProject != null) { >+ fLookupOrder = new IScopeContext[] {new ProjectScope(fProject), new InstanceScope(), new DefaultScope()}; >+ } else { >+ fLookupOrder = new IScopeContext[] {new InstanceScope(), new DefaultScope()}; >+ } >+ if (container == null) { >+ fManager = new WorkingCopyManager(); >+ } else { >+ fManager = container.getWorkingCopyManager(); >+ } >+ if (fProject == null || hasProjectSpecificSettings(fProject)) { >+ fOldProjectSettings = null; >+ } else { >+ fOldProjectSettings = new IdentityHashMap(); >+ for (int i = 0; i < fgAllKeys.length; i++) { >+ fOldProjectSettings.put(fgAllKeys[i], fgAllKeys[i].getStoredValue(fLookupOrder, false, fManager)); >+ } >+ } >+ } >+ >+ /** >+ * returns if this block has fProject specific settings >+ * @param fProject >+ * @return true if there are fProject specific settings, false otherwise >+ */ >+ public boolean hasProjectSpecificSettings(IProject project) { >+ if (project != null) { >+ IScopeContext projectContext = new ProjectScope(project); >+ for (int i = 0; i < fgAllKeys.length; i++) { >+ if (fgAllKeys[i].getStoredValue(projectContext, fManager) != null) { >+ return true; >+ } >+ } >+ } >+ return false; >+ } >+ >+ /** >+ * Sets using project specific settings >+ * @param enable >+ */ >+ public void useProjectSpecificSettings(boolean enable) { >+ boolean disabled = fOldProjectSettings == null; >+ if (enable != disabled && fProject != null) { >+ if (enable) { >+ for (int i = 0; i < fgAllKeys.length; i++) { >+ fgAllKeys[i].setStoredValue(fLookupOrder[0], (String) fOldProjectSettings.get(fgAllKeys[i]), fManager); >+ } >+ fOldProjectSettings = null; >+ updateControls(); >+ } else { >+ fOldProjectSettings = new IdentityHashMap(); >+ String old = null; >+ for (int i = 0; i < fgAllKeys.length; i++) { >+ old = fgAllKeys[i].getStoredValue(fLookupOrder, false, fManager); >+ fOldProjectSettings.put(fgAllKeys[i], old); >+ fgAllKeys[i].setStoredValue(fLookupOrder[0], null, fManager); >+ } >+ } >+ } >+ fDirty = true; >+ enableControl(fMainComp, enable); >+ } >+ >+ /** >+ * Updates all of the registered {@link Control}s on the page. >+ * Registration implies that the {@link Control} was added to the map >+ * fControlMap >+ */ >+ private void updateControls() { >+ HashSet controls = null; >+ Control control = null; >+ for (Iterator iter = fControlMap.keySet().iterator(); iter.hasNext();) { >+ controls = (HashSet) fControlMap.get(iter.next()); >+ if (controls == null) { >+ continue; >+ } >+ for (Iterator iter2 = controls.iterator(); iter2.hasNext();) { >+ control = (Control) iter2.next(); >+ if (control instanceof Combo) { >+ Combo combo = (Combo) control; >+ ControlData data = (ControlData) combo.getData(); >+ int index = 0; >+ try { >+ index = Integer.parseInt(data.key.getStoredValue(fLookupOrder, false, fManager)); >+ } catch (Exception e) { >+ //set the default if something goes wrong >+ index = Integer.parseInt(data.key.getStoredValue(fLookupOrder, true, fManager)); >+ } >+ combo.select(data.getSelection(SEVERITIES[index])); >+ } else if (control instanceof Button) { >+ Button button = (Button) control; >+ ControlData data = (ControlData) button.getData(); >+ button.setSelection(Boolean.valueOf(data.key.getStoredValue(fLookupOrder, false, fManager)).booleanValue()); >+ } else if (control instanceof Text) { >+ Text text = (Text) control; >+ ControlData data = (ControlData) text.getData(); >+ text.setText(data.key.getStoredValue(fLookupOrder, false, fManager)); >+ } >+ } >+ } >+ } >+ >+ /** >+ * recursive method to enable/disable all of the controls on the main page >+ * @param ctrl >+ * @param enabled >+ */ >+ private void enableControl(Control ctrl, boolean enabled) { >+ ctrl.setEnabled(enabled); >+ if (ctrl instanceof Composite) { >+ Composite comp = (Composite) ctrl; >+ Control[] children = comp.getChildren(); >+ for (int i = 0; i < children.length; i++) { >+ enableControl(children[i], enabled); >+ } >+ } >+ } >+ >+ /** >+ * Creates the control in the parent control >+ * >+ * @param parent the parent control >+ */ >+ public Control createControl(Composite parent) { >+ fParent = parent; >+ fMainComp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0); >+ TabFolder folder = null; >+ if (fProject == null) { >+ SWTFactory.createVerticalSpacer(parent, 1); >+ folder = new TabFolder(fMainComp, SWT.NONE); >+ GridData gd = new GridData(GridData.FILL_BOTH); >+ gd.heightHint = 375; >+ gd.widthHint = 400; >+ folder.setLayoutData(gd); >+ } >+ >+ Composite main = (folder == null ? fMainComp : folder); >+ //plugins page >+ createPage(CompilerFlags.PLUGIN_FLAGS, main, PDEUIMessages.CompilersConfigurationBlock_plugins, PDEUIMessages.CompilersConfigurationBlock_label); >+ >+ if (fProject == null) { >+ //the sharing property page does not use these two tabs >+ //schema page >+ createPage(CompilerFlags.SCHEMA_FLAGS, main, PDEUIMessages.CompilersConfigurationBlock_schemas, PDEUIMessages.CompilersConfigurationBlock_altlabel); >+ >+ //features / sites page >+ createPage(CompilerFlags.FEATURE_FLAGS, main, PDEUIMessages.CompilersConfigurationBlock_features, PDEUIMessages.CompilersConfigurationBlock_label); >+ } >+ restoreExpansionState(); >+ return fMainComp; >+ } >+ >+ /** >+ * Creates a tab page parented in the folder >+ * @param kind >+ * @param folder >+ * @param name >+ * @param description >+ * @return a new composite to act as the page for a tab >+ */ >+ private Composite createPage(int kind, Composite folder, String name, String description) { >+ Composite page = SWTFactory.createComposite(folder, 1, 1, GridData.FILL_BOTH); >+ Composite parent = page; >+ if (fProject == null) { >+ TabItem tab = new TabItem((TabFolder) folder, SWT.NONE); >+ tab.setText(name); >+ tab.setControl(page); >+ parent = SWTFactory.createComposite(page, 2, 1, GridData.FILL_BOTH); >+ } >+ SWTFactory.createWrapLabel(parent, description, 2); >+ SWTFactory.createVerticalSpacer(parent, 1); >+ switch (kind) { >+ case CompilerFlags.PLUGIN_FLAGS : { >+ ScrolledComposite scomp = createScrolledComposite(parent, 1); >+ Composite sbody = SWTFactory.createComposite(scomp, 1, 1, GridData.FILL_BOTH); >+ scomp.setContent(sbody); >+ //General >+ Composite client = createExpansibleComposite(sbody, PDEUIMessages.PDECompilersConfigurationBlock_general); >+ initializeComboControls(client, new String[] {PDEUIMessages.compilers_p_no_required_att, PDEUIMessages.CompilersConfigurationTab_buildPropertiesErrors, PDEUIMessages.CompilersConfigurationTab_incompatEnv, PDEUIMessages.compilers_p_exported_pkgs, PDEUIMessages.CompilersConfigurationTab_missingBundleClasspathEntries}, new Key[] {KEY_P_NO_REQUIRED_ATT, KEY_P_BUILD, KEY_P_INCOMPATIBLE_ENV, KEY_P_MISSING_EXPORT_PKGS, KEY_P_MISSING_BUNDLE_CLASSPATH_ENTRIES}, CompilerFlags.PLUGIN_FLAGS); >+ //Usage >+ client = createExpansibleComposite(sbody, PDEUIMessages.PDECompilersConfigurationBlock_usage); >+ initializeComboControls(client, new String[] {PDEUIMessages.compilers_p_unresolved_import, PDEUIMessages.compilers_p_unresolved_ex_points, PDEUIMessages.compilers_p_deprecated, PDEUIMessages.compilers_p_not_externalized_att}, new Key[] {KEY_P_UNRESOLVED_IMPORTS, KEY_P_UNRESOLVED_EX_POINTS, KEY_P_DEPRECATED, KEY_P_NOT_EXTERNALIZED}, CompilerFlags.PLUGIN_FLAGS); >+ //References >+ client = createExpansibleComposite(sbody, PDEUIMessages.PDECompilersConfigurationBlock_references); >+ initializeComboControls(client, new String[] {PDEUIMessages.compilers_p_unknown_element, PDEUIMessages.compilers_p_unknown_attribute, PDEUIMessages.compilers_p_unknown_class, PDEUIMessages.compilers_p_discouraged_class, PDEUIMessages.compilers_p_unknown_resource, PDEUIMessages.compilers_p_unknown_identifier}, new Key[] {KEY_P_UNKNOWN_ELEMENT, KEY_P_UNKNOWN_ATTRIBUTE, KEY_P_UNKNOWN_CLASS, KEY_P_DISCOURAGED_CLASS, KEY_P_UNKNOWN_RESOURCE, KEY_P_UNKNOWN_IDENTIFIER,}, CompilerFlags.PLUGIN_FLAGS); >+ >+ break; >+ } >+ case CompilerFlags.SCHEMA_FLAGS : { >+ createCheckControl(parent, PDEUIMessages.compilers_s_create_docs, KEY_S_CREATE_DOCS, CompilerFlags.SCHEMA_FLAGS); >+ Composite comp = SWTFactory.createComposite(parent, 2, 2, GridData.FILL_HORIZONTAL, 0, 0); >+ createTextControl(comp, PDEUIMessages.compilers_s_doc_folder, KEY_S_DOC_FOLDER, CompilerFlags.SCHEMA_FLAGS); >+ SWTFactory.createVerticalSpacer(parent, 1); >+ initializeComboControls(parent, new String[] {PDEUIMessages.compilers_s_open_tags}, new Key[] {KEY_S_OPEN_TAGS}, CompilerFlags.SCHEMA_FLAGS); >+ break; >+ } >+ case CompilerFlags.FEATURE_FLAGS : { >+ initializeComboControls(parent, new String[] {PDEUIMessages.compilers_f_unresolved_features, PDEUIMessages.compilers_f_unresolved_plugins}, new Key[] {KEY_F_UNRESOLVED_FEATURES, KEY_F_UNRESOLVED_PLUGINS}, CompilerFlags.FEATURE_FLAGS); >+ break; >+ } >+ } >+ return page; >+ } >+ >+ /** >+ * Creates a set of combo boxes for the given string/ key pairs >+ * @param composite >+ * @param labels >+ * @param keys >+ * @param tabkind >+ */ >+ private void initializeComboControls(Composite composite, String[] labels, Key[] keys, int tabkind) { >+ for (int i = 0, max = labels.length; i < max; i++) { >+ createComboControl(composite, labels[i], keys[i], tabkind); >+ } >+ } >+ >+ /** >+ * Creates a checkbox button control in the parent >+ * @param parent >+ * @param label >+ * @param key >+ * @param tabkind >+ */ >+ private void createCheckControl(Composite parent, String label, Key key, int tabkind) { >+ Button button = SWTFactory.createCheckButton(parent, label, null, false, 2); >+ ControlData data = new ControlData(key, new String[] {Boolean.toString(false)}); >+ button.setData(data); >+ button.setSelection(Boolean.valueOf(data.key.getStoredValue(fLookupOrder, false, fManager)).booleanValue()); >+ button.addSelectionListener(selectionlistener); >+ Integer mapkey = new Integer(tabkind); >+ HashSet controls = (HashSet) fControlMap.get(mapkey); >+ if (controls == null) { >+ controls = new HashSet(8); >+ fControlMap.put(mapkey, controls); >+ } >+ controls.add(button); >+ } >+ >+ /** >+ * Disposes the controls from this page >+ */ >+ public void dispose() { >+ fMainComp.getParent().dispose(); >+ fExpComps.clear(); >+ fControlMap.clear(); >+ } >+ >+ /** >+ * Creates a {@link Label} | {@link Combo} control. The combo is initialized from the given {@link Key} >+ * @param parent >+ * @param label >+ * @param key >+ * @param tabkind >+ */ >+ protected void createComboControl(Composite parent, String label, Key key, int tabkind) { >+ Label lbl = new Label(parent, SWT.NONE); >+ GridData gd = new GridData(GridData.BEGINNING, GridData.CENTER, true, false); >+ lbl.setLayoutData(gd); >+ lbl.setText(label); >+ Combo combo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY); >+ gd = new GridData(GridData.END, GridData.CENTER, false, false); >+ ControlData data = new ControlData(key, SEVERITIES); >+ combo.setData(data); >+ combo.setItems(SEVERITIES); >+ combo.addSelectionListener(selectionlistener); >+ int index = 0; >+ try { >+ index = Integer.parseInt(key.getStoredValue(fLookupOrder, false, fManager)); >+ } catch (Exception e) { >+ //set the default if something goes wrong >+ index = Integer.parseInt(key.getStoredValue(fLookupOrder, true, fManager)); >+ } >+ combo.select(data.getSelection(SEVERITIES[index])); >+ Integer mapkey = new Integer(tabkind); >+ HashSet controls = (HashSet) fControlMap.get(mapkey); >+ if (controls == null) { >+ controls = new HashSet(8); >+ fControlMap.put(mapkey, controls); >+ } >+ controls.add(combo); >+ } >+ >+ /** >+ * Creates a new text control on the parent for the given pref key >+ * @param parent >+ * @param label >+ * @param key >+ * @param tabkind >+ */ >+ private void createTextControl(Composite parent, String label, Key key, int tabkind) { >+ SWTFactory.createLabel(parent, label, 1); >+ Text text = SWTFactory.createSingleText(parent, 1); >+ ControlData data = new ControlData(key, new String[0]); >+ text.setData(data); >+ text.setText(data.key.getStoredValue(fLookupOrder, false, fManager)); >+ text.addModifyListener(modifylistener); >+ Integer mapkey = new Integer(tabkind); >+ HashSet controls = (HashSet) fControlMap.get(mapkey); >+ if (controls == null) { >+ controls = new HashSet(8); >+ fControlMap.put(mapkey, controls); >+ } >+ controls.add(text); >+ } >+ >+ /** >+ * Creates a scrolled composite >+ * @param parent >+ * @param columns >+ * @return a new scrolled composite >+ */ >+ protected ScrolledComposite createScrolledComposite(Composite parent, int columns) { >+ ScrolledComposite scomp = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL); >+ scomp.setExpandHorizontal(true); >+ scomp.setExpandVertical(true); >+ scomp.setLayout(new GridLayout(1, false)); >+ scomp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >+ scomp.addListener(SWT.Resize, new Listener() { >+ public void handleEvent(Event event) { >+ handleExpand(getScrollingParent(event.widget)); >+ } >+ }); >+ return scomp; >+ } >+ >+ /** >+ * Creates an {@link ExpandableComposite} with a client composite and a default grid layout >+ * @param parent >+ * @param title >+ * @return a new expandable composite >+ */ >+ private Composite createExpansibleComposite(Composite parent, String title) { >+ ExpandableComposite ecomp = SWTFactory.createExpandibleComposite(parent, title, 1, GridData.FILL_HORIZONTAL); >+ ecomp.addExpansionListener(new ExpansionAdapter() { >+ public void expansionStateChanged(ExpansionEvent e) { >+ Object obj = e.getSource(); >+ handleExpand(getScrollingParent(obj)); >+ } >+ }); >+ ecomp.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); >+ fExpComps.add(ecomp); >+ Composite client = SWTFactory.createComposite(ecomp, 2, 1, GridData.FILL_BOTH); >+ ecomp.setClient(client); >+ return client; >+ } >+ >+ /** >+ * Returns the scrolling parent for the given ExpandibleComposite object >+ * @param obj >+ * @return the scrolling parent of the given object or <code>null</code> if there isn't one >+ */ >+ private ScrolledComposite getScrollingParent(Object obj) { >+ if (obj instanceof ExpandableComposite) { >+ ExpandableComposite ecomp = (ExpandableComposite) obj; >+ Composite parent = ecomp.getParent(); >+ while (parent != null && !(parent instanceof ScrolledComposite)) { >+ parent = parent.getParent(); >+ } >+ if (parent != null) { >+ return (ScrolledComposite) parent; >+ } >+ } >+ if (obj instanceof ScrolledComposite) { >+ return (ScrolledComposite) obj; >+ } >+ return null; >+ } >+ >+ /** >+ * Handles one of the expandable composites being expanded >+ */ >+ private void handleExpand(ScrolledComposite composite) { >+ if (composite == null) { >+ return; >+ } >+ try { >+ composite.setRedraw(false); >+ Composite c = (Composite) composite.getContent(); >+ if (c == null) { >+ return; >+ } >+ Point newSize = c.computeSize(SWT.DEFAULT, SWT.DEFAULT); >+ composite.setMinSize(newSize); >+ c.layout(true); >+ } finally { >+ composite.setRedraw(true); >+ } >+ } >+ >+ /** >+ * Saves all of the changes on the page >+ */ >+ public void performOK() { >+ save(); >+ persistExpansionState(); >+ } >+ >+ /** >+ * Directly applies all of the changes on the page >+ */ >+ public void performApply() { >+ save(); >+ } >+ >+ /** >+ * Performs the save operation on the working cop manager >+ */ >+ private void save() { >+ if (fDirty) { >+ try { >+ ArrayList changes = new ArrayList(); >+ collectChanges(fLookupOrder[0], changes); >+ if (changes.size() > 0) { >+ if (fRebuildcount < 1) { >+ fRebuildcount++; >+ fManager.applyChanges(); >+ String message = PDEUIMessages.PDECompilersConfigurationBlock_settings_changed_all; >+ if (fProject != null) { >+ message = MessageFormat.format(PDEUIMessages.PDECompilersConfigurationBlock_setting_changed_project, new String[] {fProject.getName()}); >+ } >+ if (MessageDialog.openQuestion(fParent.getShell(), PDEUIMessages.PDECompilersConfigurationBlock_settings_changed, message)) { >+ doFullBuild(); >+ } >+ } >+ } >+ fDirty = false; >+ } catch (BackingStoreException bse) { >+ PDEPlugin.log(bse); >+ } >+ } >+ } >+ >+ /** >+ * Collects the keys that have changed on the page into the specified list >+ * @param changes the {@link List} to collect changed keys into >+ */ >+ private void collectChanges(IScopeContext context, List changes) { >+ Key key = null; >+ String origval = null, newval = null; >+ boolean complete = fOldProjectSettings == null && fProject != null; >+ for (int i = 0; i < fgAllKeys.length; i++) { >+ key = fgAllKeys[i]; >+ origval = key.getStoredValue(context, null); >+ newval = key.getStoredValue(context, fManager); >+ if (newval == null) { >+ if (origval != null) { >+ changes.add(key); >+ } else if (complete) { >+ key.setStoredValue(context, key.getStoredValue(fLookupOrder, true, fManager), fManager); >+ changes.add(key); >+ } >+ } else if (!newval.equals(origval)) { >+ changes.add(key); >+ } >+ } >+ } >+ >+ /** >+ * Cancels all of the changes on the page >+ */ >+ public void performCancel() { >+ persistExpansionState(); >+ } >+ >+ /** >+ * Reverts all of the settings back to their defaults >+ */ >+ public void performDefaults() { >+ String defval = null; >+ for (int i = 0; i < fgAllKeys.length; i++) { >+ defval = fgAllKeys[i].getStoredValue(fLookupOrder, true, fManager); >+ fgAllKeys[i].setStoredValue(fLookupOrder[0], defval, fManager); >+ } >+ updateControls(); >+ fDirty = true; >+ fRebuildcount = 0; >+ } >+ >+ /** >+ * Stores the expansion state of the composites >+ */ >+ private void persistExpansionState() { >+ IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS); >+ for (int i = 0; i < fExpComps.size(); i++) { >+ settings.put(Integer.toString(i), ((ExpandableComposite) fExpComps.get(i)).isExpanded()); >+ } >+ } >+ >+ /** >+ * Restores the expansion state of the composites in this block. >+ * If there are no settings, than the first composite is expanded by default >+ */ >+ private void restoreExpansionState() { >+ IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(SETTINGS); >+ if (settings != null) { >+ for (int i = 0; i < fExpComps.size(); i++) { >+ ((ExpandableComposite) fExpComps.get(i)).setExpanded(settings.getBoolean(Integer.toString(i))); >+ } >+ } else { >+ ((ExpandableComposite) fExpComps.get(0)).setExpanded(true); >+ } >+ } >+ >+ /** >+ * Adds the associated builder for the tab this control lives on. Lookups are done using >+ * hash codes for constant time containment checks >+ * @param control >+ */ >+ private void addBuilder(Control control) { >+ HashSet controls = null; >+ Integer key = null; >+ for (Iterator iter = fControlMap.keySet().iterator(); iter.hasNext();) { >+ key = (Integer) iter.next(); >+ controls = (HashSet) fControlMap.get(key); >+ if (controls == null) { >+ continue; >+ } >+ if (controls.contains(control)) { >+ switch (key.intValue()) { >+ case CompilerFlags.PLUGIN_FLAGS : { >+ fBuilders.add(PDE.MANIFEST_BUILDER_ID); >+ break; >+ } >+ case CompilerFlags.SCHEMA_FLAGS : { >+ fBuilders.add(PDE.SCHEMA_BUILDER_ID); >+ break; >+ } >+ case CompilerFlags.FEATURE_FLAGS : >+ case CompilerFlags.SITE_FLAGS : { >+ fBuilders.add(PDE.FEATURE_BUILDER_ID); >+ break; >+ } >+ } >+ return; >+ } >+ } >+ } >+ >+ /** >+ * Performs a full build of the workspace >+ */ >+ private void doFullBuild() { >+ Job buildJob = new Job(PDEUIMessages.CompilersConfigurationBlock_building) { >+ public boolean belongsTo(Object family) { >+ return ResourcesPlugin.FAMILY_MANUAL_BUILD == family; >+ } >+ >+ protected IStatus run(IProgressMonitor monitor) { >+ try { >+ IProject[] projects = null; >+ if (fProject == null) { >+ projects = PDEPlugin.getWorkspace().getRoot().getProjects(); >+ } else { >+ projects = new IProject[] {fProject}; >+ } >+ monitor.beginTask("", projects.length * 2); //$NON-NLS-1$ >+ for (int i = 0; i < projects.length; i++) { >+ IProject projectToBuild = projects[i]; >+ if (!projectToBuild.isOpen()) >+ continue; >+ if (projectToBuild.hasNature(PDE.PLUGIN_NATURE)) { >+ if (fBuilders.contains(PDE.MANIFEST_BUILDER_ID)) >+ projectToBuild.build(IncrementalProjectBuilder.FULL_BUILD, PDE.MANIFEST_BUILDER_ID, null, new SubProgressMonitor(monitor, 1)); >+ else >+ monitor.worked(1); >+ if (fBuilders.contains(PDE.SCHEMA_BUILDER_ID)) >+ projectToBuild.build(IncrementalProjectBuilder.FULL_BUILD, PDE.SCHEMA_BUILDER_ID, null, new SubProgressMonitor(monitor, 1)); >+ else >+ monitor.worked(1); >+ } else if (projectToBuild.hasNature(PDE.FEATURE_NATURE)) { >+ if (fBuilders.contains(PDE.FEATURE_BUILDER_ID)) >+ projectToBuild.build(IncrementalProjectBuilder.FULL_BUILD, PDE.FEATURE_BUILDER_ID, null, new SubProgressMonitor(monitor, 2)); >+ } else { >+ monitor.worked(2); >+ } >+ } >+ } catch (CoreException e) { >+ return e.getStatus(); >+ } catch (OperationCanceledException e) { >+ return Status.CANCEL_STATUS; >+ } finally { >+ monitor.done(); >+ } >+ return Status.OK_STATUS; >+ } >+ }; >+ buildJob.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule()); >+ buildJob.setUser(true); >+ buildJob.schedule(); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 168069
:
86986
|
86993
|
89533
|
96306
|
96320
|
96486