diff options
Diffstat (limited to 'jaxb/plugins/org.eclipse.jpt.jaxb.ui/src')
68 files changed, 0 insertions, 9403 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/JptJaxbUiPlugin.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/JptJaxbUiPlugin.java deleted file mode 100644 index 824a4d7507..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/JptJaxbUiPlugin.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2010 Oracle. 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: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jaxb.ui; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.jpt.jaxb.ui.internal.platform.JaxbPlatformUiManagerImpl; -import org.eclipse.jpt.jaxb.ui.platform.JaxbPlatformUiManager; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.eclipse.wst.xml.core.internal.XMLCorePlugin; -import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog; - -/** - * The activator class controls the plug-in life cycle - * - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -@SuppressWarnings("nls") -public class JptJaxbUiPlugin extends AbstractUIPlugin -{ - // The plug-in ID - public static final String PLUGIN_ID = "org.eclipse.jpt.jaxb.ui"; - public static final String PLUGIN_ID_ = PLUGIN_ID + '.'; - - public static final String USER_CATALOG_ID = XMLCorePlugin.USER_CATALOG_ID; //$NON-NLS-1$ - public static final String DEFAULT_CATALOG_ID = XMLCorePlugin.DEFAULT_CATALOG_ID; //$NON-NLS-1$ - public static final String SYSTEM_CATALOG_ID = XMLCorePlugin.SYSTEM_CATALOG_ID; //$NON-NLS-1$ - - // ********** singleton ********** - private static JptJaxbUiPlugin INSTANCE; - - /** - * Returns the singleton Plugin - */ - public static JptJaxbUiPlugin instance() { - return INSTANCE; - } - - public static void log(IStatus status) { - INSTANCE.getLog().log(status); - } - - public static void log(String msg) { - log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, msg, null)); - } - - public static void log(Throwable throwable) { - log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, throwable.getLocalizedMessage(), throwable)); - } - - // ********** Image API ********** - /** - * This gets a .gif from the icons folder. - */ - public static ImageDescriptor getImageDescriptor(String key) { - if (! key.startsWith("icons/")) { - key = "icons/" + key; - } - if (! key.endsWith(".gif")) { - key = key + ".gif"; - } - return imageDescriptorFromPlugin(PLUGIN_ID, key); - } - - /** - * This returns an image for a .gif from the icons folder - */ - //TODO we are using the ImageRegistry here and storing all our icons for the life of the plugin, - //which means until the workspace is closed. This is better than before where we constantly - //created new images. Bug 306437 is about cleaning this up and using Local Resource Managers - //on our views so that closing the JPA perspective would mean our icons are disposed. - public static Image getImage(String key) { - ImageRegistry imageRegistry = instance().getImageRegistry(); - Image image = imageRegistry.get(key); - if (image == null) { - imageRegistry.put(key, getImageDescriptor(key)); - image = imageRegistry.get(key); - } - return image; - } - - - public static JaxbPlatformUiManager getJaxbPlatformUiManager() { - return JaxbPlatformUiManagerImpl.instance(); - } - - - // ********** XMLCorePlugin API ********** - - public ICatalog getDefaultXMLCatalog() { - return XMLCorePlugin.getDefault().getDefaultXMLCatalog(); - } - - // ********** constructors ********** - public JptJaxbUiPlugin() { - super(); - if (INSTANCE != null) { - throw new IllegalStateException(); - } - INSTANCE = this; - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/ClassesGeneratorUi.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/ClassesGeneratorUi.java deleted file mode 100644 index c6db6cfd70..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/ClassesGeneratorUi.java +++ /dev/null @@ -1,164 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2010 Oracle. 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: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.WorkspaceJob; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.jaxb.core.internal.gen.ClassesGeneratorExtensionOptions; -import org.eclipse.jpt.jaxb.core.internal.gen.ClassesGeneratorOptions; -import org.eclipse.jpt.jaxb.core.internal.gen.GenerateJaxbClassesJob; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.jpt.jaxb.ui.internal.wizards.classesgen.ClassesGeneratorWizard; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -/** - * ClassesGeneratorUi - */ -public class ClassesGeneratorUi { - private final IJavaProject javaProject; - private final String schemaPathOrUri; - - // ********** static methods ********** - - public static void generate(IFile xsdFile) { - IJavaProject javaProject = JavaCore.create(xsdFile.getProject()); - if (javaProject == null) { - throw new NullPointerException(); - } - IPath xmlSchema = xsdFile.getProjectRelativePath(); - - new ClassesGeneratorUi(javaProject, xmlSchema.toOSString()).generate(); - } - - // ********** constructors ********** - private ClassesGeneratorUi(IJavaProject javaProject, String schemaPathOrUri) { - super(); - if(javaProject == null || StringTools.stringIsEmpty(schemaPathOrUri)) { - throw new NullPointerException(); - } - this.javaProject = javaProject; - this.schemaPathOrUri = schemaPathOrUri; - } - - // ********** generate ********** - /** - * prompt the user with a wizard - */ - protected void generate() { - ClassesGeneratorWizard wizard = new ClassesGeneratorWizard(this.javaProject, this.schemaPathOrUri); - wizard.setWindowTitle(JptJaxbUiMessages.ClassesGeneratorWizard_title); - WizardDialog dialog = new WizardDialog(this.getCurrentShell(), wizard); - dialog.create(); - int returnCode = dialog.open(); - if (returnCode != Window.OK) { - return; - } - String outputDir = wizard.getDestinationFolder(); - String targetPackage = wizard.getTargetPackage(); - String catalog = wizard.getCatalog(); - boolean usesMoxy = wizard.usesMoxy(); - String[] bindingsFileNames = wizard.getBindingsFileNames(); - ClassesGeneratorOptions generatorOptions = wizard.getGeneratorOptions(); - ClassesGeneratorExtensionOptions generatorExtensionOptions = wizard.getGeneratorExtensionOptions(); - - if(this.displayOverridingClassesWarning(generatorOptions)) { - this.generateJaxbClasses(outputDir, targetPackage, catalog, usesMoxy, bindingsFileNames, generatorOptions, generatorExtensionOptions); - } - } - - // ********** internal methods ********** - - private void generateJaxbClasses( - String outputDir, - String targetPackage, - String catalog, - boolean usesMoxyGenerator, - String[] bindingsFileNames, - ClassesGeneratorOptions generatorOptions, - ClassesGeneratorExtensionOptions generatorExtensionOptions) { - - try { - WorkspaceJob job = new GenerateJaxbClassesJob( - this.javaProject, - this.schemaPathOrUri, - outputDir, - targetPackage, - catalog, - usesMoxyGenerator, - bindingsFileNames, - generatorOptions, - generatorExtensionOptions); - job.schedule(); - } - catch(RuntimeException re) { - JptJaxbUiPlugin.log(re); - - String msg = re.getMessage(); - String message = (msg == null) ? re.toString() : msg; - this.logError(message); - } - } - - private void logError(String message) { - this.displayError(message); - } - - private void displayError(String message) { - MessageDialog.openError( - this.getShell(), - JptJaxbUiMessages.ClassesGeneratorWizard_errorDialogTitle, - message - ); - } - - private Shell getShell() { - Display display = Display.getCurrent(); - Shell shell = (display == null) ? null : display.getActiveShell(); - if(shell == null && display != null) { - Shell[] shells = display.getShells(); - if(shells.length > 0) - shell = shells[0]; - } - return shell; - } - - private boolean isOverridingClasses(ClassesGeneratorOptions generatorOptions) { - if(generatorOptions == null) { - throw new NullPointerException(); - } - if(generatorOptions.showsVersion() || generatorOptions.showsHelp()) { - return false; - } - return true; - } - - private boolean displayOverridingClassesWarning(ClassesGeneratorOptions generatorOptions) { - - if( ! this.isOverridingClasses(generatorOptions)) { - return true; - } - return MessageDialog.openQuestion( - this.getCurrentShell(), - JptJaxbUiMessages.ClassesGeneratorUi_generatingClassesWarningTitle, - JptJaxbUiMessages.ClassesGeneratorUi_generatingClassesWarningMessage); - } - - private Shell getCurrentShell() { - return Display.getCurrent().getActiveShell(); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbJavaCompletionProposalComputer.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbJavaCompletionProposalComputer.java deleted file mode 100644 index 9a8fb04f8e..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbJavaCompletionProposalComputer.java +++ /dev/null @@ -1,185 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.jdt.core.CompletionContext; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; -import org.eclipse.jdt.ui.text.java.IJavaCompletionProposalComputer; -import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; -import org.eclipse.jface.text.contentassist.CompletionProposal; -import org.eclipse.jface.text.contentassist.ICompletionProposal; -import org.eclipse.jpt.common.core.JptCommonCorePlugin; -import org.eclipse.jpt.common.core.internal.utility.PlatformTools; -import org.eclipse.jpt.common.core.internal.utility.jdt.ASTTools; -import org.eclipse.jpt.common.utility.Filter; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.jaxb.core.JaxbProject; -import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin; -import org.eclipse.jpt.jaxb.core.context.java.JavaContextNode; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; - - -public class JaxbJavaCompletionProposalComputer - implements IJavaCompletionProposalComputer { - - public JaxbJavaCompletionProposalComputer() { - super(); - } - - - public void sessionStarted() { - // do nothing - } - - @SuppressWarnings("unchecked") - public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) { - return (context instanceof JavaContentAssistInvocationContext) ? - computeCompletionProposals((JavaContentAssistInvocationContext) context) - : Collections.emptyList(); - } - - /** - * We fail silently here because (it seems) <em>expected</em> exceptions occur - * more frequently than intermittent <em>unexpected</em> exceptions that might - * merit investigation (and a logged stacktrace might be the only hint as - * to what happened). - * <p> - * We will get an <em>expected</em> exception (typically a {@link NullPointerException NPE}) - * here if the user:<ol> - * <li>modifies the Java source file in a way that puts it drastically out - * of sync with the Dali context model (e.g. deleting a field or - * annotation) - * <li>immediately invokes Content Assist (typically <code>Ctrl+Space</code>) - * </ol> - * The AST we build here will be based on the just-modified Java source; but, - * since the user moved quickly and we will not have yet received any Java - * change notification (since we only get a Java change notification when - * the user has paused typing for at least 0.5 seconds), the context model - * will still be based on the unmodified Java source. As the new AST is - * passed down through the context model to the resource model all the code - * expects to find the AST in sync with the model. When this is not the - * case (e.g. a field in the resource model is no longer present in the AST - * because the user has deleted it or modified the code in such a way that - * the parser can no longer detect the field) the model will probably choke - * when it cannot find the corresponding AST node. - * <p> - * It seems reasonable, in these situations, to simply return no completion - * proposals. If the user simply waits a moment and tries again, we will be - * able to successfully calculate some proposals. - * <p> - * ~bjv - */ - private List<ICompletionProposal> computeCompletionProposals(JavaContentAssistInvocationContext context) { - try { - return computeCompletionProposals_(context); - } - catch (Exception ex) { - // JptJaxbCorePlugin.log(ex); // don't log "expected" exceptions (?) - return Collections.emptyList(); - } - } - - private List<ICompletionProposal> computeCompletionProposals_(JavaContentAssistInvocationContext context) { - ICompilationUnit cu = context.getCompilationUnit(); - IFile file = (cu != null) ? getCorrespondingResource(cu) : null; - IContentType contentType = (file != null) ? PlatformTools.getContentType(file) : null; - - if (contentType == null || ! contentType.isKindOf(JptCommonCorePlugin.JAVA_SOURCE_CONTENT_TYPE)) { - return Collections.emptyList(); - } - - JaxbProject jaxbProject = JptJaxbCorePlugin.getJaxbProject(file.getProject()); - if (jaxbProject == null) { - return Collections.emptyList(); - } - - Iterable<? extends JavaContextNode> javaNodes = jaxbProject.getPrimaryJavaNodes(cu); - if (CollectionTools.isEmpty(javaNodes)) { - return Collections.emptyList(); - } - - CompletionContext cc = context.getCoreContext(); - - // the context's "token" is really a sort of "prefix" - it does NOT - // correspond to the "start" and "end" we get below... - char[] prefix = cc.getToken(); - Filter<String> filter = ((prefix == null) ? Filter.Null.<String>instance() : new IgnoreCasePrefixFilter(prefix)); - // the token "start" is the offset of the token's first character - int tokenStart = cc.getTokenStart(); - // the token "end" is the offset of the token's last character (yuk) - int tokenEnd = cc.getTokenEnd(); - if (tokenStart == -1) { // not sure why this happens - see bug 242286 - return Collections.emptyList(); - } - -// System.out.println("prefix: " + ((prefix == null) ? "[null]" : new String(prefix))); -// System.out.println("token start: " + tokenStart); -// System.out.println("token end: " + tokenEnd); -// String source = cu.getSource(); -// String token = source.substring(Math.max(0, tokenStart), Math.min(source.length(), tokenEnd + 1)); -// System.out.println("token: =>" + token + "<="); -// String snippet = source.substring(Math.max(0, tokenStart - 20), Math.min(source.length(), tokenEnd + 21)); -// System.out.println("surrounding snippet: =>" + snippet + "<="); - - // TODO move this parser call into the model... - CompilationUnit astRoot = ASTTools.buildASTRoot(cu); - List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>(); - for (JavaContextNode javaNode : javaNodes) { - for (String proposal : javaNode.getJavaCompletionProposals(context.getInvocationOffset(), filter, astRoot)) { - proposals.add(new CompletionProposal(proposal, tokenStart, tokenEnd - tokenStart + 1, proposal.length())); - } - } - return proposals; - } - - private IFile getCorrespondingResource(ICompilationUnit cu) { - try { - return (IFile) cu.getCorrespondingResource(); - } catch (JavaModelException ex) { - JptJaxbUiPlugin.log(ex); - return null; - } - } - - @SuppressWarnings("unchecked") - public List computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) { - return Collections.emptyList(); - } - - public String getErrorMessage() { - return null; - } - - public void sessionEnded() { - // do nothing - } - - private static class IgnoreCasePrefixFilter implements Filter<String> { - private final char[] prefix; - IgnoreCasePrefixFilter(char[] prefix) { - super(); - this.prefix = prefix; - } - public boolean accept(String s) { - return StringTools.stringStartsWithIgnoreCase(s.toCharArray(), this.prefix); - } - } - -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbMappingImageHelper.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbMappingImageHelper.java deleted file mode 100644 index 12c75d47dc..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JaxbMappingImageHelper.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Oracle. - * 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal; - -import org.eclipse.jpt.jaxb.core.MappingKeys; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.swt.graphics.Image; - -public class JaxbMappingImageHelper -{ -// -// public static Image imageForTypeMapping(String mappingKey) { -// return JptUiPlugin.getImage(iconKeyForTypeMapping(mappingKey)); -// } -// -// public static String iconKeyForTypeMapping(String mappingKey) { -// if (MappingKeys.NULL_TYPE_MAPPING_KEY == mappingKey) { -// return JptUiIcons.NULL_TYPE_MAPPING; -// } -// else if (MappingKeys.ENTITY_TYPE_MAPPING_KEY.equals(mappingKey)) { -// return JptUiIcons.ENTITY; -// } -// else if (MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY.equals(mappingKey)) { -// return JptUiIcons.EMBEDDABLE; -// } -// else if (MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY.equals(mappingKey)) { -// return JptUiIcons.MAPPED_SUPERCLASS; -// } -// return null; -// } - - public static Image imageForAttributeMapping(String mappingKey) { - return JptJaxbUiPlugin.getImage(iconKeyForAttributeMapping(mappingKey)); - } - - public static String iconKeyForAttributeMapping(String mappingKey) { - if (MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY == mappingKey) { - return JptJaxbUiIcons.NULL_ATTRIBUTE_MAPPING; - } - else if (MappingKeys.XML_ANY_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) { - return JptJaxbUiIcons.XML_ANY_ATTRIBUTE; - } - else if (MappingKeys.XML_ANY_ELEMENT_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) { - return JptJaxbUiIcons.XML_ANY_ELEMENT; - } - else if (MappingKeys.XML_ATTRIBUTE_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) { - return JptJaxbUiIcons.XML_ATTRIBUTE; - } - else if (MappingKeys.XML_ELEMENT_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) { - return JptJaxbUiIcons.XML_ELEMENT; - } - else if (MappingKeys.XML_TRANSIENT_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) { - return JptJaxbUiIcons.XML_TRANSIENT; - } - else if (MappingKeys.XML_VALUE_ATTRIBUTE_MAPPING_KEY.equals(mappingKey)) { - return JptJaxbUiIcons.XML_VALUE; - } - //return the JAXB_CONTENT icon instead of null, might as well have an icon if one is not defined - return JptJaxbUiIcons.JAXB_CONTENT; - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiIcons.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiIcons.java deleted file mode 100644 index 13cc8458a0..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiIcons.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2010, 2011 Oracle. 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: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal; - -@SuppressWarnings("nls") -public class JptJaxbUiIcons -{ - // **************** General icons ************************************** - - public static final String JAXB_CONTENT = "full/obj16/jaxb_content"; - public static final String PACKAGE = "full/obj16/package"; - - public static final String PERSISTENT_CLASS = "full/obj16/persistent_class"; - public static final String PERSISTENT_ENUM = "full/obj16/persistent_enum"; - public static final String TRANSIENT_CLASS = "full/obj16/transient_class"; - public static final String REGISTRY = "full/obj16/registry"; - - public static final String PERSISTENT_FIELD = "full/obj16/persistent_field"; - public static final String PERSISTENT_PROPERTY = "full/obj16/persistent_property"; - public static final String ENUM_CONSTANT = "full/obj16/enum_constant"; - - public static final String SCHEMA_GEN = "full/wizban/NewXSD"; - - // **************** Wizard icons ******************************************* - - public static final String SCHEMA_GEN_WIZ_BANNER = "full/wizban/NewXSD"; - public static final String CLASSES_GEN_WIZ_BANNER = "full/wizban/newclass_wiz"; - public static final String JAXB_WIZ_BANNER = "full/wizban/new_jaxb_prj_wiz"; - - - public static final String XML_ANY_ATTRIBUTE = "full/obj16/xml-any-attribute"; - public static final String XML_ANY_ELEMENT = "full/obj16/xml-any-element"; - public static final String XML_ATTRIBUTE = "full/obj16/xml-attribute"; - public static final String XML_ELEMENT = "full/obj16/xml-element"; - public static final String XML_TRANSIENT = "full/obj16/xml-transient"; - public static final String XML_VALUE = "full/obj16/xml-value"; - public static final String NULL_ATTRIBUTE_MAPPING = "full/obj16/null-attribute-mapping"; - -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java deleted file mode 100644 index 753b671958..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java +++ /dev/null @@ -1,181 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2010 Oracle. 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: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal; - -import org.eclipse.osgi.util.NLS; - -/** - * Localized messages used by Dali JAXB UI. - * - * @version 2.3 - */ -public class JptJaxbUiMessages { - - public static String JavaProjectWizardPage_project; - public static String JavaProjectWizardPage_destinationProject; - - // ClassesGenerator - public static String ClassesGeneratorProjectWizardPage_title; - public static String ClassesGeneratorProjectWizardPage_desc; - - public static String ClassesGeneratorWizard_title; - public static String ClassesGeneratorWizard_errorDialogTitle; - public static String ClassesGeneratorWizard_couldNotCreate; - - public static String JaxbContent_label; - - public static String SchemasPage_description; - public static String SchemasPage_revert; - public static String SchemasPage_schemas; - public static String SchemasPage_namespaceColumnLabel; - public static String SchemasPage_locationColumnLabel; - public static String SchemasPage_addButtonLabel; - public static String SchemasPage_editButtonLabel; - public static String SchemasPage_removeButtonLabel; - public static String SchemasPage_addSchemaMessage; - public static String SchemasPage_editSchemaMessage; - public static String SchemasPage_addSchemaDialogTitle; - public static String SchemasPage_editSchemaDialogTitle; - public static String SchemasPage_addSchemaTitle; - public static String SchemasPage_editSchemaTitle; - public static String SchemasPage_locationLabel; - public static String SchemasPage_browseButtonLabel; - public static String SchemasPage_namespaceLabel; - public static String SchemasPage_noNamespaceText; - public static String SchemasPage_schemaUnresolvedMessage; - public static String SchemasPage_duplicateNamespaceMessage; - public static String SchemasPage_noLocationMessage; - public static String SchemasPage_chooseLocationTitle; - - public static String SchemaWizardPage_title; - public static String SchemaWizardPage_desc; - - public static String SchemaWizardPage_xmlCatalogTableTitle; - public static String SchemaWizardPage_xmlCatalogKeyColumn; - public static String SchemaWizardPage_xmlCatalogUriColumn; - - public static String SchemaWizardPage_errorUriCannotBeLocated; - - - public static String ClassesGeneratorWizardPage_title; - public static String ClassesGeneratorWizardPage_desc; - - public static String ClassesGeneratorWizardPage_usesMoxyImplementation; - - public static String ClassesGeneratorWizardPage_catalog; - public static String ClassesGeneratorWizardPage_bindingsFiles; - public static String ClassesGeneratorWizardPage_browseButton; - public static String ClassesGeneratorWizardPage_addButton; - public static String ClassesGeneratorWizardPage_removeButton; - public static String ClassesGeneratorWizardPage_chooseABindingsFile; - public static String ClassesGeneratorWizardPage_chooseACatalog; - - public static String ClassesGeneratorWizardPage_sourceFolderSelectionDialog_title; - public static String ClassesGeneratorWizardPage_chooseSourceFolderDialog_desc; - - public static String ClassesGeneratorWizardPage_jaxbLibrariesNotAvailable; - public static String ClassesGeneratorWizardPage_moxyLibrariesNotAvailable; - - public static String ClassesGeneratorOptionsWizardPage_title; - public static String ClassesGeneratorOptionsWizardPage_desc; - - public static String ClassesGeneratorOptionsWizardPage_proxyGroup; - public static String ClassesGeneratorOptionsWizardPage_noProxy; - public static String ClassesGeneratorOptionsWizardPage_proxy; - public static String ClassesGeneratorOptionsWizardPage_proxyFile; - public static String ClassesGeneratorOptionsWizardPage_chooseAProxyFile; - - public static String ClassesGeneratorOptionsWizardPage_useStrictValidation; - public static String ClassesGeneratorOptionsWizardPage_makeReadOnly; - public static String ClassesGeneratorOptionsWizardPage_suppressPackageInfoGen; - public static String ClassesGeneratorOptionsWizardPage_suppressesHeaderGen; - public static String ClassesGeneratorOptionsWizardPage_target; - public static String ClassesGeneratorOptionsWizardPage_verbose; - public static String ClassesGeneratorOptionsWizardPage_quiet; - - public static String ClassesGeneratorOptionsWizardPage_treatsAsXmlSchema; - public static String ClassesGeneratorOptionsWizardPage_treatsAsRelaxNg; - public static String ClassesGeneratorOptionsWizardPage_treatsAsRelaxNgCompact; - public static String ClassesGeneratorOptionsWizardPage_treatsAsDtd; - public static String ClassesGeneratorOptionsWizardPage_treatsAsWsdl; - public static String ClassesGeneratorOptionsWizardPage_showsVersion; - public static String ClassesGeneratorOptionsWizardPage_showsHelp; - - public static String ClassesGeneratorExtensionOptionsWizardPage_title; - public static String ClassesGeneratorExtensionOptionsWizardPage_desc; - - public static String ClassesGeneratorExtensionOptionsWizardPage_allowExtensions; - public static String ClassesGeneratorExtensionOptionsWizardPage_classpath; - public static String ClassesGeneratorExtensionOptionsWizardPage_additionalArguments; - - public static String ClassesGeneratorUi_generatingEntities; - public static String ClassesGeneratorUi_generatingEntitiesTask; - - public static String ClassesGeneratorUi_generatingClassesWarningTitle; - public static String ClassesGeneratorUi_generatingClassesWarningMessage; - - // SchemaGenerator - public static String SchemaGeneratorWizard_title; - public static String SchemaGeneratorWizard_generatingSchema; - - public static String SchemaGeneratorProjectWizardPage_title; - public static String SchemaGeneratorProjectWizardPage_desc; - - public static String SchemaGeneratorWizardPage_title; - public static String SchemaGeneratorWizardPage_desc; - - public static String SchemaGeneratorWizardPage_shemaLocation; - public static String SchemaGeneratorWizardPage_shema; - public static String SchemaGeneratorWizardPage_packages; - public static String SchemaGeneratorWizardPage_browse; - - public static String SchemaGeneratorWizardPage_chooseSchemaDialogTitle; - - public static String SchemaGeneratorWizardPage_errorNoSchema; - public static String SchemaGeneratorWizardPage_errorNoPackage; - - public static String SchemaGeneratorWizardPage_jaxbLibrariesNotAvailable; - - public static String SchemaGeneratorWizardPage_moxyLibrariesNotAvailable; - - public static String SchemaGeneratorWizard_generateSchemaTask; - - public static String NewSchemaFileWizardPage_errorNotJavaProject; - public static String NewSchemaFileWizardPage_overwriteExistingSchemas; - - - // new project wizard - - public static String JaxbProjectWizard_title; - - public static String JaxbProjectWizard_firstPage_title; - public static String JaxbProjectWizard_firstPage_desc; - - - // facet page - - public static String JaxbFacetWizardPage_title; - public static String JaxbFacetWizardPage_desc; - public static String JaxbFacetWizardPage_platformLabel; - public static String JaxbFacetWizardPage_facetsPageLink; - public static String JaxbFacetWizardPage_jaxbImplementationLabel; - - - private static final String BUNDLE_NAME = "jpt_jaxb_ui"; //$NON-NLS-1$ - private static final Class<?> BUNDLE_CLASS = JptJaxbUiMessages.class; - static { - NLS.initializeMessages(BUNDLE_NAME, BUNDLE_CLASS); - } - - private JptJaxbUiMessages() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/actions/GenerateClassesAction.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/actions/GenerateClassesAction.java deleted file mode 100644 index 526fd69580..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/actions/GenerateClassesAction.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2010 Oracle. 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: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.actions; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jpt.jaxb.ui.internal.ClassesGeneratorUi; - -/** - * GenerateClassesAction - */ -public class GenerateClassesAction extends ObjectAction -{ - - @Override - protected void execute(IFile xsdFile) { - - ClassesGeneratorUi.generate(xsdFile); - } - -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/actions/ObjectAction.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/actions/ObjectAction.java deleted file mode 100644 index 652d75ac58..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/actions/ObjectAction.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2010 Oracle. 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: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.actions; - -import java.util.Iterator; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ITreeSelection; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.actions.ActionDelegate; - -/** - * GenerateEntitiesAction - */ -public abstract class ObjectAction extends ActionDelegate implements IObjectActionDelegate -{ - private ISelection currentSelection; - - public ObjectAction() { - super(); - } - - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - // do nothing - } - - @Override - public void selectionChanged(IAction action, ISelection selection) { - this.currentSelection = selection; - } - - @Override - public void run(IAction action) { - if (this.currentSelection instanceof ITreeSelection) { - for (Iterator<?> stream = ((ITreeSelection) this.currentSelection).iterator(); stream.hasNext(); ) { - this.execute(stream.next()); - } - } - } - - protected void execute(Object selection) { - - if(selection instanceof IFile) { - this.execute((IFile)selection); - } - } - - @SuppressWarnings("unused") - protected void execute(IFile file) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/filters/ContainerFilter.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/filters/ContainerFilter.java deleted file mode 100644 index 5572e0b5fa..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/filters/ContainerFilter.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2010 Oracle. 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: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.filters; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; - -/** - * Filters out all containers i.e. all packages and folders - */ -public class ContainerFilter extends ViewerFilter { - - @Override - public boolean select(Viewer viewer, Object parent, Object element) { - boolean isContainer = element instanceof IContainer; - - if( ! isContainer && element instanceof IJavaElement) { - int type= ((IJavaElement)element).getElementType(); - isContainer = (type == IJavaElement.JAVA_MODEL - || type == IJavaElement.JAVA_PROJECT - || type == IJavaElement.PACKAGE_FRAGMENT - || type ==IJavaElement.PACKAGE_FRAGMENT_ROOT); - } - return ! isContainer; - } - - @Override - public String toString() { - return "Filter out Containers"; //$NON-NLS-1$ - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/filters/EmptyInnerPackageFilter.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/filters/EmptyInnerPackageFilter.java deleted file mode 100644 index e89609ec7a..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/filters/EmptyInnerPackageFilter.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 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 - * Code originate from org.eclipse.jdt.internal.ui.filters - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.filters; - - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; - -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.JavaModelException; - - -/** - * Filters empty non-leaf package fragments - */ -public class EmptyInnerPackageFilter extends ViewerFilter { - - /* - * @see ViewerFilter - */ - public boolean select(Viewer viewer, Object parent, Object element) { - if (element instanceof IPackageFragment) { - IPackageFragment pkg= (IPackageFragment)element; - try { - if (pkg.isDefaultPackage()) - return pkg.hasChildren(); - return !pkg.hasSubpackages() || pkg.hasChildren() || (pkg.getNonJavaResources().length > 0); - } catch (JavaModelException e) { - return false; - } - } - - return true; - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/filters/NonArchiveOrExternalElementFilter.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/filters/NonArchiveOrExternalElementFilter.java deleted file mode 100644 index 9ae95f8b9b..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/filters/NonArchiveOrExternalElementFilter.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2010 Oracle. 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: -* Oracle - initial API and implementation -* -* Code originate from XXXX -*******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.filters; - -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; - -/** - * NonArchiveOrExternalElementFilter - */ -public class NonArchiveOrExternalElementFilter extends ViewerFilter { - - @Override - public boolean select(Viewer viewer, Object parent, Object element) { - if(element instanceof IPackageFragmentRoot) { - IPackageFragmentRoot root= (IPackageFragmentRoot) element; - return !root.isArchive() && !root.isExternal(); - } - return true; - } - - @Override - public String toString() { - return "Filter out: Non-Archive and Non-External"; //$NON-NLS-1$ - } - -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/filters/NonContainerFilter.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/filters/NonContainerFilter.java deleted file mode 100644 index 8fd6e6ac82..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/filters/NonContainerFilter.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2010 Oracle. 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: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.filters; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; - -/** - * Filters out all non Container and all JavaProject - * with name not equals to the given projectName. - */ -public class NonContainerFilter extends ViewerFilter -{ - final private String projectName; - - public NonContainerFilter(String projectName) { - this.projectName = projectName; - } - - @Override - public boolean select(Viewer viewer, Object parent, Object element) { - boolean isContainer = element instanceof IContainer; - int type; - if( ! isContainer && element instanceof IJavaElement) { - type = ((IJavaElement)element).getElementType(); - isContainer = (type == IJavaElement.JAVA_MODEL - || type == IJavaElement.JAVA_PROJECT - || type == IJavaElement.PACKAGE_FRAGMENT - || type ==IJavaElement.PACKAGE_FRAGMENT_ROOT); - } - if(isContainer && (element instanceof IJavaElement)) { - type = ((IJavaElement)element).getElementType(); - if(type == IJavaElement.JAVA_PROJECT) { - String projectName = ((IJavaProject)element).getElementName(); - return projectName.equals(this.projectName); - } - } - return isContainer; - } - - @Override - public String toString() { - return "Filter out Non-Containers"; //$NON-NLS-1$ - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/filters/NonJavaElementFilter.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/filters/NonJavaElementFilter.java deleted file mode 100644 index 0c1a6949bd..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/filters/NonJavaElementFilter.java +++ /dev/null @@ -1,51 +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 - * Code originate from org.eclipse.jdt.internal.ui.filters - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.filters; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IStorage; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; - -import org.eclipse.jdt.core.IJavaElement; - - -/** - * Filters out all non-Java elements, and elements named package-info - */ -public class NonJavaElementFilter extends ViewerFilter { - - static public String FILE_TO_EXCLUDE = "package-info.java"; //$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ - public boolean select(Viewer viewer, Object parent, Object element) { - if (element instanceof IJavaElement) { - return(FILE_TO_EXCLUDE.equals(((IJavaElement)element).getElementName())) ? - false : true; - } - - if (element instanceof IResource) { - IProject project= ((IResource)element).getProject(); - return project == null || !project.isOpen(); - } - - // Exclude all IStorage elements which are neither Java elements nor resources - if (element instanceof IStorage) - return false; - - return true; - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorItemLabelProviderFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorItemLabelProviderFactory.java deleted file mode 100644 index 7734572337..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorItemLabelProviderFactory.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.jaxb21; - -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.ui.jface.ItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.ItemLabelProviderFactory; -import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot; -import org.eclipse.jpt.jaxb.core.context.JaxbEnumConstant; -import org.eclipse.jpt.jaxb.core.context.JaxbPackage; -import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass; -import org.eclipse.jpt.jaxb.core.context.JaxbPersistentEnum; -import org.eclipse.jpt.jaxb.core.context.JaxbPersistentField; -import org.eclipse.jpt.jaxb.core.context.JaxbPersistentProperty; -import org.eclipse.jpt.jaxb.core.context.JaxbRegistry; -import org.eclipse.jpt.jaxb.core.context.JaxbTransientClass; - - -public class GenericJaxb_2_1_NavigatorItemLabelProviderFactory - implements ItemLabelProviderFactory { - - private static GenericJaxb_2_1_NavigatorItemLabelProviderFactory INSTANCE; - - - public static GenericJaxb_2_1_NavigatorItemLabelProviderFactory instance() { - if (INSTANCE == null) { - INSTANCE = new GenericJaxb_2_1_NavigatorItemLabelProviderFactory(); - } - return INSTANCE; - } - - - private GenericJaxb_2_1_NavigatorItemLabelProviderFactory() { - super(); - } - - - public ItemLabelProvider buildItemLabelProvider( - Object item, - DelegatingContentAndLabelProvider contentAndLabelProvider) { - - if (item instanceof JaxbContextRoot) { - return new JaxbContextRootItemLabelProvider((JaxbContextRoot) item, contentAndLabelProvider); - } - else if (item instanceof JaxbPackage) { - return new JaxbPackageItemLabelProvider((JaxbPackage) item, contentAndLabelProvider); - } - else if (item instanceof JaxbRegistry) { - return new JaxbRegistryItemLabelProvider((JaxbRegistry) item, contentAndLabelProvider); - } - else if (item instanceof JaxbPersistentClass) { - return new JaxbPersistentClassItemLabelProvider((JaxbPersistentClass) item, contentAndLabelProvider); - } - else if (item instanceof JaxbPersistentEnum) { - return new JaxbPersistentEnumItemLabelProvider((JaxbPersistentEnum) item, contentAndLabelProvider); - } - else if (item instanceof JaxbTransientClass) { - return new JaxbTransientClassItemLabelProvider((JaxbTransientClass) item, contentAndLabelProvider); - } - else if (item instanceof JaxbPersistentField) { - return new JaxbPersistentFieldItemLabelProvider((JaxbPersistentField) item, contentAndLabelProvider); - } - else if (item instanceof JaxbPersistentProperty) { - return new JaxbPersistentPropertyItemLabelProvider((JaxbPersistentProperty) item, contentAndLabelProvider); - } - else if (item instanceof JaxbEnumConstant) { - return new JaxbEnumConstantItemLabelProvider((JaxbEnumConstant) item, contentAndLabelProvider); - } - return null; - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorTreeItemContentProviderFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorTreeItemContentProviderFactory.java deleted file mode 100644 index 2b053849fb..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorTreeItemContentProviderFactory.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.jaxb21; - -import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProvider; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProviderFactory; -import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot; -import org.eclipse.jpt.jaxb.core.context.JaxbPackage; -import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass; -import org.eclipse.jpt.jaxb.core.context.JaxbPersistentEnum; -import org.eclipse.jpt.jaxb.core.context.JaxbRegistry; - - -public class GenericJaxb_2_1_NavigatorTreeItemContentProviderFactory - implements TreeItemContentProviderFactory { - - private static GenericJaxb_2_1_NavigatorTreeItemContentProviderFactory INSTANCE; - - - public static GenericJaxb_2_1_NavigatorTreeItemContentProviderFactory instance() { - if (INSTANCE == null) { - INSTANCE = new GenericJaxb_2_1_NavigatorTreeItemContentProviderFactory(); - } - return INSTANCE; - } - - - private GenericJaxb_2_1_NavigatorTreeItemContentProviderFactory() { - super(); - } - - - public TreeItemContentProvider buildItemContentProvider( - Object item, - DelegatingContentAndLabelProvider contentAndLabelProvider) { - - DelegatingTreeContentAndLabelProvider treeContentAndLabelProvider = - (DelegatingTreeContentAndLabelProvider) contentAndLabelProvider; - - if (item instanceof JaxbContextRoot) { - return new JaxbContextRootItemContentProvider((JaxbContextRoot) item, treeContentAndLabelProvider); - } - else if (item instanceof JaxbPackage) { - return new JaxbPackageItemContentProvider((JaxbPackage) item, treeContentAndLabelProvider); - } - else if (item instanceof JaxbPersistentClass) { - return new JaxbPersistentClassItemContentProvider((JaxbPersistentClass) item, treeContentAndLabelProvider); - } - else if (item instanceof JaxbPersistentEnum) { - return new JaxbPersistentEnumItemContentProvider((JaxbPersistentEnum) item, treeContentAndLabelProvider); - } - else if (item instanceof JaxbRegistry) { - return new JaxbRegistryItemContentProvider((JaxbRegistry) item, treeContentAndLabelProvider); - } - return null; - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorUi.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorUi.java deleted file mode 100644 index 10da002510..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorUi.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.jaxb21; - -import org.eclipse.jpt.common.ui.jface.ItemLabelProviderFactory; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProviderFactory; -import org.eclipse.jpt.jaxb.ui.navigator.JaxbNavigatorUi; - - -public class GenericJaxb_2_1_NavigatorUi - implements JaxbNavigatorUi { - - private static GenericJaxb_2_1_NavigatorUi INSTANCE; - - - public static GenericJaxb_2_1_NavigatorUi instance() { - if (INSTANCE == null) { - INSTANCE = new GenericJaxb_2_1_NavigatorUi(); - } - return INSTANCE; - } - - - private GenericJaxb_2_1_NavigatorUi() { - super(); - } - - - public TreeItemContentProviderFactory getTreeItemContentProviderFactory() { - return GenericJaxb_2_1_NavigatorTreeItemContentProviderFactory.instance(); - } - - public ItemLabelProviderFactory getItemLabelProviderFactory() { - return GenericJaxb_2_1_NavigatorItemLabelProviderFactory.instance(); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_PlatformUi.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_PlatformUi.java deleted file mode 100644 index 9336abc359..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_PlatformUi.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.jaxb21; - -import org.eclipse.jpt.jaxb.ui.navigator.JaxbNavigatorUi; -import org.eclipse.jpt.jaxb.ui.platform.JaxbPlatformUi; - - -public class GenericJaxb_2_1_PlatformUi - implements JaxbPlatformUi { - - public JaxbNavigatorUi getNavigatorUi() { - return GenericJaxb_2_1_NavigatorUi.instance(); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbContextRootItemContentProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbContextRootItemContentProvider.java deleted file mode 100644 index 4f6a013de8..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbContextRootItemContentProvider.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.jaxb21; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jpt.common.ui.internal.jface.AbstractTreeItemContentProvider; -import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.CollectionAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.CollectionValueModel; -import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot; -import org.eclipse.jpt.jaxb.core.context.JaxbPackage; - - -public class JaxbContextRootItemContentProvider - extends AbstractTreeItemContentProvider<JaxbPackage> { - - public JaxbContextRootItemContentProvider( - JaxbContextRoot rootContext, DelegatingTreeContentAndLabelProvider contentProvider) { - super(rootContext, contentProvider); - } - - - @Override - public JaxbContextRoot getModel() { - return (JaxbContextRoot) super.getModel(); - } - - @Override - public IProject getParent() { - return getModel().getJaxbProject().getProject(); - } - - @Override - protected CollectionValueModel<JaxbPackage> buildChildrenModel() { - return new CollectionAspectAdapter<JaxbContextRoot, JaxbPackage>( - JaxbContextRoot.PACKAGES_COLLECTION, - getModel()) { - - @Override - protected Iterable<JaxbPackage> getIterable() { - return this.subject.getPackages(); - } - }; - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbContextRootItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbContextRootItemLabelProvider.java deleted file mode 100644 index 1fa5c4e31d..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbContextRootItemLabelProvider.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.jaxb21; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; -import org.eclipse.swt.graphics.Image; - - -public class JaxbContextRootItemLabelProvider - extends AbstractItemLabelProvider { - - public JaxbContextRootItemLabelProvider( - JaxbContextRoot rootContextNode, DelegatingContentAndLabelProvider labelProvider) { - - super(rootContextNode, labelProvider); - } - - - @Override - public JaxbContextRoot getModel() { - return (JaxbContextRoot) super.getModel(); - } - - @Override - protected PropertyValueModel<Image> buildImageModel() { - return new StaticPropertyValueModel<Image>(JptJaxbUiPlugin.getImage(JptJaxbUiIcons.JAXB_CONTENT)); - } - - @Override - protected PropertyValueModel<String> buildTextModel() { - return new StaticPropertyValueModel<String>(JptJaxbUiMessages.JaxbContent_label); - } - - @Override - protected PropertyValueModel<String> buildDescriptionModel() { - StringBuilder sb = new StringBuilder(); - sb.append(JptJaxbUiMessages.JaxbContent_label); - sb.append(" - "); //$NON-NLS-1$ - sb.append(getModel().getResource().getFullPath().makeRelative()); - return new StaticPropertyValueModel<String>(sb.toString()); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbEnumConstantItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbEnumConstantItemLabelProvider.java deleted file mode 100644 index 0a839f0d08..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbEnumConstantItemLabelProvider.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.jaxb21; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jaxb.core.context.JaxbEnumConstant; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons; -import org.eclipse.swt.graphics.Image; - - -public class JaxbEnumConstantItemLabelProvider - extends AbstractItemLabelProvider { - - public JaxbEnumConstantItemLabelProvider( - JaxbEnumConstant jaxbEnumConstant, DelegatingContentAndLabelProvider labelProvider) { - - super(jaxbEnumConstant, labelProvider); - } - - - @Override - public JaxbEnumConstant getModel() { - return (JaxbEnumConstant) super.getModel(); - } - - @Override - protected PropertyValueModel<Image> buildImageModel() { - return new StaticPropertyValueModel<Image>(JptJaxbUiPlugin.getImage(JptJaxbUiIcons.ENUM_CONSTANT)); - } - - @Override - protected PropertyValueModel<String> buildTextModel() { - return new StaticPropertyValueModel<String>(getModel().getName()); - } - - @Override - protected PropertyValueModel<String> buildDescriptionModel() { - return new StaticPropertyValueModel<String>(getModel().getName()); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPackageItemContentProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPackageItemContentProvider.java deleted file mode 100644 index 620c6e783e..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPackageItemContentProvider.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.jaxb21; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractTreeItemContentProvider; -import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.CollectionAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.CollectionValueModel; -import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot; -import org.eclipse.jpt.jaxb.core.context.JaxbPackage; -import org.eclipse.jpt.jaxb.core.context.JaxbType; - - -public class JaxbPackageItemContentProvider - extends AbstractTreeItemContentProvider<JaxbType> { - - public JaxbPackageItemContentProvider( - JaxbPackage jaxbPackage, DelegatingTreeContentAndLabelProvider contentProvider) { - - super(jaxbPackage, contentProvider); - } - - - @Override - public JaxbPackage getModel() { - return (JaxbPackage) super.getModel(); - } - - @Override - public JaxbContextRoot getParent() { - return (JaxbContextRoot) getModel().getParent(); - } - - @Override - protected CollectionValueModel<JaxbType> buildChildrenModel() { - return new CollectionAspectAdapter<JaxbContextRoot, JaxbType>( - JaxbContextRoot.TYPES_COLLECTION, getParent()) { - @Override - protected Iterable<JaxbType> getIterable() { - return this.subject.getTypes(getModel()); - } - }; - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPackageItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPackageItemLabelProvider.java deleted file mode 100644 index a275cb7634..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPackageItemLabelProvider.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.jaxb21; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jaxb.core.context.JaxbPackage; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons; -import org.eclipse.swt.graphics.Image; - - -public class JaxbPackageItemLabelProvider - extends AbstractItemLabelProvider { - - public JaxbPackageItemLabelProvider( - JaxbPackage jaxbPackage, DelegatingContentAndLabelProvider labelProvider) { - - super(jaxbPackage, labelProvider); - } - - @Override - public JaxbPackage getModel() { - return (JaxbPackage) super.getModel(); - } - - @Override - protected PropertyValueModel<Image> buildImageModel() { - return new StaticPropertyValueModel<Image>(JptJaxbUiPlugin.getImage(JptJaxbUiIcons.PACKAGE)); - } - - @Override - protected PropertyValueModel<String> buildTextModel() { - return new StaticPropertyValueModel<String>(getModel().getName()); - } - - @Override - protected PropertyValueModel<String> buildDescriptionModel() { - StringBuilder sb = new StringBuilder(); - sb.append(getModel().getName()); - sb.append(" - "); //$NON-NLS-1$ - sb.append(getModel().getResource().getFullPath().makeRelative()); - return new StaticPropertyValueModel<String>(sb.toString()); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentAttributeItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentAttributeItemLabelProvider.java deleted file mode 100644 index efe5f0f7d7..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentAttributeItemLabelProvider.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.jaxb21; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute; -import org.eclipse.jpt.jaxb.ui.internal.JaxbMappingImageHelper; -import org.eclipse.swt.graphics.Image; - - -public abstract class JaxbPersistentAttributeItemLabelProvider - extends AbstractItemLabelProvider { - - public JaxbPersistentAttributeItemLabelProvider( - JaxbPersistentAttribute attribute, DelegatingContentAndLabelProvider labelProvider) { - - super(attribute, labelProvider); - } - - - @Override - public JaxbPersistentAttribute getModel() { - return (JaxbPersistentAttribute) super.getModel(); - } - - @Override - protected PropertyValueModel<Image> buildImageModel() { - return new PropertyAspectAdapter<JaxbPersistentAttribute, Image>( - new String[] {JaxbPersistentAttribute.DEFAULT_MAPPING_KEY_PROPERTY, JaxbPersistentAttribute.MAPPING_PROPERTY}, - getModel()) { - @Override - protected Image buildValue_() { - return JaxbMappingImageHelper.imageForAttributeMapping(this.subject.getMappingKey()); - } - }; - } - - @Override - protected PropertyValueModel<String> buildTextModel() { - StringBuffer sb = new StringBuffer(); - if (getModel().isInherited()) { - sb.append(getModel().getInheritedJavaResourceAttributeOwningTypeName()); - sb.append('.'); - } - sb.append(getModel().getName()); - return new StaticPropertyValueModel<String>(sb.toString()); - } - - @Override - protected PropertyValueModel<String> buildDescriptionModel() { - return new StaticPropertyValueModel<String>(getModel().getName()); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentClassItemContentProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentClassItemContentProvider.java deleted file mode 100644 index dfcf97e383..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentClassItemContentProvider.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.jaxb21; - -import java.util.ArrayList; -import java.util.List; -import org.eclipse.jpt.common.ui.internal.jface.AbstractTreeItemContentProvider; -import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.CollectionAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.CompositeCollectionValueModel; -import org.eclipse.jpt.common.utility.model.value.CollectionValueModel; -import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot; -import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute; -import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass; - - -public class JaxbPersistentClassItemContentProvider - extends AbstractTreeItemContentProvider<JaxbPersistentAttribute> { - - public JaxbPersistentClassItemContentProvider( - JaxbPersistentClass jaxbPersistentClass, DelegatingTreeContentAndLabelProvider contentProvider) { - - super(jaxbPersistentClass, contentProvider); - } - - - @Override - public JaxbPersistentClass getModel() { - return (JaxbPersistentClass) super.getModel(); - } - - @Override - public JaxbContextRoot getParent() { - return (JaxbContextRoot) getModel().getParent(); - } - - @Override - protected CollectionValueModel<JaxbPersistentAttribute> buildChildrenModel() { - List<CollectionValueModel<JaxbPersistentAttribute>> list = new ArrayList<CollectionValueModel<JaxbPersistentAttribute>>(); - list.add(buildAttributesModel()); - list.add(buildInheritedAttributesModel()); - return new CompositeCollectionValueModel<CollectionValueModel<JaxbPersistentAttribute>, JaxbPersistentAttribute>(list); - } - - protected CollectionValueModel<JaxbPersistentAttribute> buildAttributesModel() { - return new CollectionAspectAdapter<JaxbPersistentClass, JaxbPersistentAttribute>( - JaxbPersistentClass.ATTRIBUTES_COLLECTION, getModel()) { - @Override - protected Iterable<JaxbPersistentAttribute> getIterable() { - return this.subject.getAttributes(); - } - }; - } - - protected CollectionValueModel<JaxbPersistentAttribute> buildInheritedAttributesModel() { - return new CollectionAspectAdapter<JaxbPersistentClass, JaxbPersistentAttribute>( - JaxbPersistentClass.INHERITED_ATTRIBUTES_COLLECTION, getModel()) { - @Override - protected Iterable<JaxbPersistentAttribute> getIterable() { - return this.subject.getInheritedAttributes(); - } - }; - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentClassItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentClassItemLabelProvider.java deleted file mode 100644 index d13e1c3664..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentClassItemLabelProvider.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.jaxb21; - -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons; -import org.eclipse.swt.graphics.Image; - - -public class JaxbPersistentClassItemLabelProvider - extends JaxbTypeItemLabelProvider { - - public JaxbPersistentClassItemLabelProvider( - JaxbPersistentClass jaxbPersistentClass, DelegatingContentAndLabelProvider labelProvider) { - - super(jaxbPersistentClass, labelProvider); - } - - @Override - protected PropertyValueModel<Image> buildImageModel() { - return new StaticPropertyValueModel<Image>(JptJaxbUiPlugin.getImage(JptJaxbUiIcons.PERSISTENT_CLASS)); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentEnumItemContentProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentEnumItemContentProvider.java deleted file mode 100644 index 5e7620866e..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentEnumItemContentProvider.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.jaxb21; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractTreeItemContentProvider; -import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.CollectionAspectAdapter; -import org.eclipse.jpt.common.utility.model.value.CollectionValueModel; -import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot; -import org.eclipse.jpt.jaxb.core.context.JaxbEnumConstant; -import org.eclipse.jpt.jaxb.core.context.JaxbPersistentEnum; - - -public class JaxbPersistentEnumItemContentProvider - extends AbstractTreeItemContentProvider<JaxbEnumConstant> { - - public JaxbPersistentEnumItemContentProvider( - JaxbPersistentEnum jaxbPersistentEnum, DelegatingTreeContentAndLabelProvider contentProvider) { - - super(jaxbPersistentEnum, contentProvider); - } - - - @Override - public JaxbPersistentEnum getModel() { - return (JaxbPersistentEnum) super.getModel(); - } - - @Override - public JaxbContextRoot getParent() { - return (JaxbContextRoot) getModel().getParent(); - } - - @Override - protected CollectionValueModel<JaxbEnumConstant> buildChildrenModel() { - return new CollectionAspectAdapter<JaxbPersistentEnum, JaxbEnumConstant>( - JaxbPersistentEnum.ENUM_CONSTANTS_COLLECTION, getModel()) { - @Override - protected Iterable<JaxbEnumConstant> getIterable() { - return this.subject.getEnumConstants(); - } - }; - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentEnumItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentEnumItemLabelProvider.java deleted file mode 100644 index 36e6c40455..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentEnumItemLabelProvider.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.jaxb21; - -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jaxb.core.context.JaxbPersistentEnum; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons; -import org.eclipse.swt.graphics.Image; - - -public class JaxbPersistentEnumItemLabelProvider - extends JaxbTypeItemLabelProvider { - - public JaxbPersistentEnumItemLabelProvider( - JaxbPersistentEnum jaxbEnum, DelegatingContentAndLabelProvider labelProvider) { - - super(jaxbEnum, labelProvider); - } - - @Override - protected PropertyValueModel<Image> buildImageModel() { - return new StaticPropertyValueModel<Image>(JptJaxbUiPlugin.getImage(JptJaxbUiIcons.PERSISTENT_ENUM)); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentFieldItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentFieldItemLabelProvider.java deleted file mode 100644 index d35c840617..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentFieldItemLabelProvider.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.jaxb21; - -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.jaxb.core.context.JaxbPersistentField; - - -public class JaxbPersistentFieldItemLabelProvider - extends JaxbPersistentAttributeItemLabelProvider { - - public JaxbPersistentFieldItemLabelProvider( - JaxbPersistentField jaxbField, DelegatingContentAndLabelProvider labelProvider) { - - super(jaxbField, labelProvider); - } - - - @Override - public JaxbPersistentField getModel() { - return (JaxbPersistentField) super.getModel(); - } - -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentPropertyItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentPropertyItemLabelProvider.java deleted file mode 100644 index 18702e53d1..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentPropertyItemLabelProvider.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.jaxb21; - -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.jaxb.core.context.JaxbPersistentProperty; - - -public class JaxbPersistentPropertyItemLabelProvider - extends JaxbPersistentAttributeItemLabelProvider { - - public JaxbPersistentPropertyItemLabelProvider( - JaxbPersistentProperty jaxbProperty, DelegatingContentAndLabelProvider labelProvider) { - - super(jaxbProperty, labelProvider); - } - - - @Override - public JaxbPersistentProperty getModel() { - return (JaxbPersistentProperty) super.getModel(); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbRegistryItemContentProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbRegistryItemContentProvider.java deleted file mode 100644 index 940db5e8c4..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbRegistryItemContentProvider.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.jaxb21; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractTreeItemContentProvider; -import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider; -import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot; -import org.eclipse.jpt.jaxb.core.context.JaxbElementFactoryMethod; -import org.eclipse.jpt.jaxb.core.context.JaxbRegistry; - - -public class JaxbRegistryItemContentProvider - extends AbstractTreeItemContentProvider<JaxbElementFactoryMethod> { - - public JaxbRegistryItemContentProvider( - JaxbRegistry jaxbRegistry, DelegatingTreeContentAndLabelProvider contentProvider) { - - super(jaxbRegistry, contentProvider); - } - - - @Override - public JaxbRegistry getModel() { - return (JaxbRegistry) super.getModel(); - } - - @Override - public JaxbContextRoot getParent() { - return (JaxbContextRoot) getModel().getParent(); - } - -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbRegistryItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbRegistryItemLabelProvider.java deleted file mode 100644 index 4d897515e1..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbRegistryItemLabelProvider.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.jaxb21; - -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jaxb.core.context.JaxbRegistry; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons; -import org.eclipse.swt.graphics.Image; - - -public class JaxbRegistryItemLabelProvider - extends JaxbTypeItemLabelProvider { - - public JaxbRegistryItemLabelProvider( - JaxbRegistry jaxbRegistry, DelegatingContentAndLabelProvider labelProvider) { - - super(jaxbRegistry, labelProvider); - } - - @Override - protected PropertyValueModel<Image> buildImageModel() { - return new StaticPropertyValueModel<Image>(JptJaxbUiPlugin.getImage(JptJaxbUiIcons.REGISTRY)); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbTransientClassItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbTransientClassItemLabelProvider.java deleted file mode 100644 index 5f79b33805..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbTransientClassItemLabelProvider.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.jaxb21; - -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jaxb.core.context.JaxbTransientClass; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons; -import org.eclipse.swt.graphics.Image; - - -public class JaxbTransientClassItemLabelProvider - extends JaxbTypeItemLabelProvider { - - public JaxbTransientClassItemLabelProvider( - JaxbTransientClass jaxbTransientType, DelegatingContentAndLabelProvider labelProvider) { - - super(jaxbTransientType, labelProvider); - } - - @Override - protected PropertyValueModel<Image> buildImageModel() { - return new StaticPropertyValueModel<Image>(JptJaxbUiPlugin.getImage(JptJaxbUiIcons.TRANSIENT_CLASS)); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbTypeItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbTypeItemLabelProvider.java deleted file mode 100644 index c97eb44550..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbTypeItemLabelProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.jaxb21; - -import org.eclipse.jpt.common.ui.internal.jface.AbstractItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jaxb.core.context.JaxbType; - - -public abstract class JaxbTypeItemLabelProvider - extends AbstractItemLabelProvider { - - protected JaxbTypeItemLabelProvider( - JaxbType jaxbType, DelegatingContentAndLabelProvider labelProvider) { - - super(jaxbType, labelProvider); - } - - @Override - public JaxbType getModel() { - return (JaxbType) super.getModel(); - } - - @Override - protected PropertyValueModel<String> buildTextModel() { - return new StaticPropertyValueModel<String>(getModel().getTypeQualifiedName()); - } - - @Override - protected PropertyValueModel<String> buildDescriptionModel() { - StringBuilder sb = new StringBuilder(); - sb.append(getModel().getFullyQualifiedName()); - sb.append(" - "); //$NON-NLS-1$ - sb.append(getModel().getResource().getFullPath().makeRelative()); - return new StaticPropertyValueModel<String>(sb.toString()); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb22/GenericJaxb_2_2_PlatformUi.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb22/GenericJaxb_2_2_PlatformUi.java deleted file mode 100644 index 3e2ad5efd9..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb22/GenericJaxb_2_2_PlatformUi.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.jaxb22; - -import org.eclipse.jpt.jaxb.ui.internal.jaxb21.GenericJaxb_2_1_NavigatorUi; -import org.eclipse.jpt.jaxb.ui.navigator.JaxbNavigatorUi; -import org.eclipse.jpt.jaxb.ui.platform.JaxbPlatformUi; - - -public class GenericJaxb_2_2_PlatformUi - implements JaxbPlatformUi { - - public JaxbNavigatorUi getNavigatorUi() { - return GenericJaxb_2_1_NavigatorUi.instance(); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/navigator/JaxbNavigatorContentAndLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/navigator/JaxbNavigatorContentAndLabelProvider.java deleted file mode 100644 index c4844b218a..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/navigator/JaxbNavigatorContentAndLabelProvider.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2010 Oracle. - * 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.navigator; - -import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider; - - -public class JaxbNavigatorContentAndLabelProvider - extends DelegatingTreeContentAndLabelProvider { - - public JaxbNavigatorContentAndLabelProvider() { - super(new JaxbNavigatorTreeItemContentProviderFactory(), new JaxbNavigatorItemLabelProviderFactory()); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/navigator/JaxbNavigatorContentProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/navigator/JaxbNavigatorContentProvider.java deleted file mode 100644 index e23922e219..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/navigator/JaxbNavigatorContentProvider.java +++ /dev/null @@ -1,232 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. - * 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.navigator; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent; -import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent; -import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent; -import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent; -import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener; -import org.eclipse.jpt.jaxb.core.JaxbProject; -import org.eclipse.jpt.jaxb.core.JaxbProjectManager; -import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin; -import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.jpt.jaxb.ui.platform.JaxbPlatformUi; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.navigator.ICommonContentExtensionSite; -import org.eclipse.ui.navigator.ICommonContentProvider; - -/** - * This extension of navigator content provider delegates to the platform UI - * (see the org.eclipse.jpt.jaxb.ui.jaxbPlatformUis extension point) for navigator content. - * - * If there is a platform UI for the given project, this content provider will - * provide a root "JAXB Content" node (child of the project), otherwise there - * will be no content. For children of the "JAXB Content" node (or for any other - * sub-node), this provider will delegate to the content provider returned by the - * platform UI implementation. - */ -public class JaxbNavigatorContentProvider - implements ICommonContentProvider { - - private JaxbNavigatorContentAndLabelProvider delegate; - - private final CollectionChangeListener jaxbProjectListener; - - private StructuredViewer viewer; - - - public JaxbNavigatorContentProvider() { - super(); - this.jaxbProjectListener = this.buildJaxbProjectListener(); - JptJaxbCorePlugin.getProjectManager().addCollectionChangeListener(JaxbProjectManager.JAXB_PROJECTS_COLLECTION, this.jaxbProjectListener); - } - - protected CollectionChangeListener buildJaxbProjectListener() { - return new JaxbProjectListener(); - } - - public JaxbNavigatorContentAndLabelProvider getDelegate() { - return this.delegate; - } - - - // **************** IContentProvider implementation ************************ - - public void dispose() { - JptJaxbCorePlugin.getProjectManager().removeCollectionChangeListener(JaxbProjectManager.JAXB_PROJECTS_COLLECTION, this.jaxbProjectListener); - if (this.delegate != null) { - this.delegate.dispose(); - } - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - if (this.delegate != null) { - this.delegate.inputChanged(viewer, oldInput, newInput); - } - this.viewer = (StructuredViewer) viewer; - } - - - // **************** IStructuredContentProvider implementation ************** - - public Object[] getElements(Object inputElement) { - return getChildren(inputElement); - } - - - // **************** ITreeContentProvider implementation ******************** - - public Object getParent(Object element) { - if (this.delegate != null) { - return this.delegate.getParent(element); - } - - return null; - } - - public boolean hasChildren(Object element) { - if (element instanceof IAdaptable) { - IProject project = (IProject) ((IAdaptable) element).getAdapter(IProject.class); - - if (project != null) { - JaxbProject jaxbProject = JptJaxbCorePlugin.getJaxbProject(project); - if (jaxbProject != null) { - JaxbPlatformDescription desc = jaxbProject.getPlatform().getDescription(); - JaxbPlatformUi platformUi = - JptJaxbUiPlugin.getJaxbPlatformUiManager().getJaxbPlatformUi(desc); - - return platformUi != null; - } - } - } - - if (this.delegate != null) { - return this.delegate.hasChildren(element); - } - - return false; - } - - public Object[] getChildren(Object parentElement) { - if (parentElement instanceof IAdaptable) { - IProject project = (IProject) ((IAdaptable) parentElement).getAdapter(IProject.class); - - if (project != null) { - JaxbProject jaxbProject = JptJaxbCorePlugin.getJaxbProject(project); - if (jaxbProject != null) { - JaxbPlatformDescription desc = jaxbProject.getPlatform().getDescription(); - JaxbPlatformUi platformUi = - JptJaxbUiPlugin.getJaxbPlatformUiManager().getJaxbPlatformUi(desc); - - if (platformUi != null) { - return new Object[] {jaxbProject.getContextRoot()}; - } - } - } - } - - if (this.delegate != null) { - return this.delegate.getChildren(parentElement); - } - - return new Object[0]; - } - - - // **************** IMementoAware implementation *************************** - - public void saveState(IMemento memento) { - // no op - } - - public void restoreState(IMemento memento) { - // no op - } - - - // **************** ICommonContentProvider implementation ****************** - - public void init(ICommonContentExtensionSite config) { - if (this.delegate == null) { - JaxbNavigatorLabelProvider labelProvider = (JaxbNavigatorLabelProvider) config.getExtension().getLabelProvider(); - if (labelProvider != null && labelProvider.getDelegate() != null) { - this.delegate = labelProvider.getDelegate(); - } - else { - this.delegate = new JaxbNavigatorContentAndLabelProvider(); - } - } - } - - - // **************** member classes ***************************************** - - private class JaxbProjectListener - implements CollectionChangeListener - { - public void collectionChanged(CollectionChangeEvent event) { - this.refreshViewer(null); - } - public void collectionCleared(CollectionClearEvent event) { - this.refreshViewer(null); - } - public void itemsAdded(CollectionAddEvent event) { - for (Object item : event.getItems()) { - this.refreshViewer(((JaxbProject) item).getProject()); - } - } - public void itemsRemoved(CollectionRemoveEvent event) { - for (Object item : event.getItems()) { - this.refreshViewer(((JaxbProject) item).getProject()); - } - } - - private void refreshViewer(final IProject project) { - if (viewer != null - && viewer.getControl() != null - && !viewer.getControl().isDisposed()) { - // Using job here so that project model update (which also uses - // a job) will complete first - Job refreshJob = new Job("Refresh viewer") { - @Override - protected IStatus run(IProgressMonitor monitor) { - // Using runnable here so that refresh will go on correct thread - viewer.getControl().getDisplay().asyncExec(new Runnable() { - public void run() { - if (project != null) { - viewer.refresh(project); - } - else { - viewer.refresh(); - } - } - }); - return Status.OK_STATUS; - } - }; - if (project != null) { - refreshJob.setRule(project); - } - refreshJob.schedule(); - } - } - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/navigator/JaxbNavigatorItemLabelProviderFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/navigator/JaxbNavigatorItemLabelProviderFactory.java deleted file mode 100644 index ee3b2cbeb3..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/navigator/JaxbNavigatorItemLabelProviderFactory.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2011 Oracle. 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: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.navigator; - -import java.util.HashMap; -import java.util.Map; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.ui.jface.ItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.ItemLabelProviderFactory; -import org.eclipse.jpt.jaxb.core.context.JaxbContextNode; -import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.jpt.jaxb.ui.platform.JaxbPlatformUi; - -public class JaxbNavigatorItemLabelProviderFactory - implements ItemLabelProviderFactory { - - /** - * Exactly *one* of these factories is created for each view that utilizes it. - * Therefore, as we delegate to the platform UI for each project, we should - * maintain the same multiplicity. That is, if there is a delegate for each - * platform UI, we should maintain *one* delegate for each view. - * - * Key: platform description, Value: delegate content provider factory - */ - private final Map<JaxbPlatformDescription, ItemLabelProviderFactory> delegates; - - - public JaxbNavigatorItemLabelProviderFactory() { - super(); - this.delegates = new HashMap<JaxbPlatformDescription, ItemLabelProviderFactory>(); - } - - public ItemLabelProvider buildItemLabelProvider(Object item, DelegatingContentAndLabelProvider contentAndLabelProvider) { - ItemLabelProviderFactory delegate = getDelegate(item); - if (delegate != null) { - return delegate.buildItemLabelProvider(item, contentAndLabelProvider); - } - return null; - } - - - private ItemLabelProviderFactory getDelegate(Object element) { - if (! (element instanceof IAdaptable)) { - return null; - } - - JaxbContextNode contextNode = (JaxbContextNode) ((IAdaptable) element).getAdapter(JaxbContextNode.class); - - if (contextNode == null) { - return null; - } - - JaxbPlatformDescription platformDesc = contextNode.getJaxbProject().getPlatform().getDescription(); - if (delegates.containsKey(platformDesc)) { - return delegates.get(platformDesc); - } - JaxbPlatformUi platformUi = JptJaxbUiPlugin.getJaxbPlatformUiManager().getJaxbPlatformUi(platformDesc); - ItemLabelProviderFactory delegate = - (platformUi == null) ? null : platformUi.getNavigatorUi().getItemLabelProviderFactory(); - delegates.put(platformDesc, delegate); - return delegate; - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/navigator/JaxbNavigatorLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/navigator/JaxbNavigatorLabelProvider.java deleted file mode 100644 index 615a7bac26..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/navigator/JaxbNavigatorLabelProvider.java +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. - * 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.navigator; - -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.navigator.ICommonContentExtensionSite; -import org.eclipse.ui.navigator.ICommonLabelProvider; - -/** - * This extension of navigator label provider delegates to the platform UI - * (see the org.eclipse.jpt.ui.jpaPlatform extension point) for navigator labels. - * - * This label provider provides a label for the root "JPA Content" node provided - * by the content provider (see {@link JaxbNavigatorContentProvider}) and delegates - * to the label provider returned by the platform UI implementation for labels - * for children of the "JPA Content" node (or for any other sub-node). - */ -public class JaxbNavigatorLabelProvider - extends LabelProvider - implements ICommonLabelProvider { - - private JaxbNavigatorContentAndLabelProvider delegate; - - - public JaxbNavigatorLabelProvider() { - super(); - } - - - public JaxbNavigatorContentAndLabelProvider getDelegate() { - return delegate; - } - - - // **************** IBaseLabelProvider implementation ********************** - - @Override - public void addListener(ILabelProviderListener listener) { - if (delegate != null) { - delegate.addListener(listener); - } - super.addListener(listener); - } - - @Override - public void removeListener(ILabelProviderListener listener) { - super.removeListener(listener); - if (delegate != null) { - delegate.removeListener(listener); - } - } - - @Override - public boolean isLabelProperty(Object element, String property) { - if (delegate != null) { - return delegate.isLabelProperty(element, property); - } - - return super.isLabelProperty(element, property); - } - - @Override - public void dispose() { - if (delegate != null) { - delegate.dispose(); - } - super.dispose(); - } - - - // **************** ILabelProvider implementation ************************** - - @Override - public Image getImage(Object element) { - if (delegate != null) { - return delegate.getImage(element); - } - - return super.getImage(element); - } - - @Override - public String getText(Object element) { - if (delegate != null) { - return delegate.getText(element); - } - - return super.getText(element); - } - - - // **************** IDescriptionProvider implementation ******************** - - public String getDescription(Object element) { - if (delegate != null) { - return delegate.getDescription(element); - } - - return super.getText(element); - } - - - // **************** IMementoAware implementation *************************** - - public void saveState(IMemento memento) { - // no op - } - - public void restoreState(IMemento memento) { - // no op - } - - - // **************** ICommonLabelProvider implementation ******************** - - public void init(ICommonContentExtensionSite config) { - if (delegate == null) { - JaxbNavigatorContentProvider contentProvider = (JaxbNavigatorContentProvider) config.getExtension().getContentProvider(); - if (contentProvider != null && contentProvider.getDelegate() != null) { - delegate = contentProvider.getDelegate(); - } - else { - delegate = new JaxbNavigatorContentAndLabelProvider(); - } - } - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/navigator/JaxbNavigatorTreeItemContentProviderFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/navigator/JaxbNavigatorTreeItemContentProviderFactory.java deleted file mode 100644 index 567fbb04f1..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/navigator/JaxbNavigatorTreeItemContentProviderFactory.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2011 Oracle. 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: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.navigator; - -import java.util.HashMap; -import java.util.Map; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProvider; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProviderFactory; -import org.eclipse.jpt.jaxb.core.context.JaxbContextNode; -import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.jpt.jaxb.ui.platform.JaxbPlatformUi; - -public class JaxbNavigatorTreeItemContentProviderFactory - implements TreeItemContentProviderFactory { - - /** - * Exactly *one* of these factories is created for each view that utilizes it. - * Therefore, as we delegate to the platform UI for each project, we should - * maintain the same multiplicity. That is, if there is a delegate for each - * platform UI, we should maintain *one* delegate for each view. - * - * Key: platform id, Value: delegate content provider factory - */ - private Map<JaxbPlatformDescription, TreeItemContentProviderFactory> delegates; - - - public JaxbNavigatorTreeItemContentProviderFactory() { - super(); - this.delegates = new HashMap<JaxbPlatformDescription, TreeItemContentProviderFactory>(); - } - - public TreeItemContentProvider buildItemContentProvider(Object item, DelegatingContentAndLabelProvider contentAndLabelProvider) { - TreeItemContentProviderFactory delegate = getDelegate(item); - if (delegate != null) { - return delegate.buildItemContentProvider(item, contentAndLabelProvider); - } - return null; - } - - - private TreeItemContentProviderFactory getDelegate(Object element) { - if (! (element instanceof IAdaptable)) { - return null; - } - - JaxbContextNode contextNode = (JaxbContextNode) ((IAdaptable) element).getAdapter(JaxbContextNode.class); - - if (contextNode == null) { - return null; - } - - JaxbPlatformDescription platformDesc = contextNode.getJaxbProject().getPlatform().getDescription(); - if (delegates.containsKey(platformDesc)) { - return delegates.get(platformDesc); - } - JaxbPlatformUi platformUi = JptJaxbUiPlugin.getJaxbPlatformUiManager().getJaxbPlatformUi(platformDesc); - TreeItemContentProviderFactory delegate = - (platformUi == null) ? null : platformUi.getNavigatorUi().getTreeItemContentProviderFactory(); - delegates.put(platformDesc, delegate); - return delegate; - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/platform/JaxbPlatformUiConfig.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/platform/JaxbPlatformUiConfig.java deleted file mode 100644 index b9d905d198..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/platform/JaxbPlatformUiConfig.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. 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: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.platform; - -import org.eclipse.jpt.common.core.internal.utility.XPointTools; -import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription; -import org.eclipse.jpt.jaxb.ui.platform.JaxbPlatformUi; - -public class JaxbPlatformUiConfig { - - private String id; - private String pluginId; - private JaxbPlatformDescription jaxbPlatform; - private String className; - private JaxbPlatformUi platformUi; - - - JaxbPlatformUiConfig() { - super(); - } - - - public String getId() { - return this.id; - } - - void setId(String id) { - this.id = id; - } - - public String getPluginId() { - return this.pluginId; - } - - void setPluginId(String pluginId) { - this.pluginId = pluginId; - } - - public JaxbPlatformDescription getJaxbPlatform() { - return this.jaxbPlatform; - } - - void setJaxbPlatform(JaxbPlatformDescription jaxbPlatform) { - this.jaxbPlatform = jaxbPlatform; - } - - public String getClassName() { - return this.className; - } - - void setClassName(String className) { - this.className = className; - } - - public JaxbPlatformUi getPlatformUi() { - if (this.platformUi == null) { - this.platformUi = XPointTools.instantiate( - this.pluginId, JaxbPlatformUiManagerImpl.QUALIFIED_EXTENSION_POINT_ID, - this.className, JaxbPlatformUi.class); - } - return this.platformUi; - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/platform/JaxbPlatformUiManagerImpl.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/platform/JaxbPlatformUiManagerImpl.java deleted file mode 100644 index 9a82bc98d8..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/platform/JaxbPlatformUiManagerImpl.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2011 Oracle. 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: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.platform; - -import static org.eclipse.jpt.common.core.internal.utility.XPointTools.*; -import java.util.ArrayList; -import java.util.List; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jpt.common.core.internal.utility.XPointTools.XPointException; -import org.eclipse.jpt.common.utility.internal.KeyedSet; -import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin; -import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.jpt.jaxb.ui.platform.JaxbPlatformUi; -import org.eclipse.jpt.jaxb.ui.platform.JaxbPlatformUiManager; - -public class JaxbPlatformUiManagerImpl - implements JaxbPlatformUiManager { - - static final String EXTENSION_POINT_ID = "jaxbPlatformUis"; //$NON-NLS-1$ - static final String QUALIFIED_EXTENSION_POINT_ID = JptJaxbUiPlugin.PLUGIN_ID_ + EXTENSION_POINT_ID; //$NON-NLS-1$ - static final String PLATFORM_UI_ELEMENT = "jaxbPlatformUi"; //$NON-NLS-1$ - static final String ID_ATTRIBUTE = "id"; //$NON-NLS-1$ - static final String PLATFORM_ATTRIBUTE = "jaxbPlatform"; //$NON-NLS-1$ - static final String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$ - - - private static final JaxbPlatformUiManagerImpl INSTANCE = new JaxbPlatformUiManagerImpl(); - - - public static JaxbPlatformUiManagerImpl instance() { - return INSTANCE; - } - - - private KeyedSet<String, JaxbPlatformUiConfig> platformUiConfigs; - private KeyedSet<JaxbPlatformDescription, JaxbPlatformUiConfig> platformToUiConfigs; - - - // ********** constructor/initialization ********** - - private JaxbPlatformUiManagerImpl() { - super(); - this.platformUiConfigs = new KeyedSet<String, JaxbPlatformUiConfig>(); - this.platformToUiConfigs = new KeyedSet<JaxbPlatformDescription, JaxbPlatformUiConfig>(); - readExtensions(); - } - - - private void readExtensions() { - final IExtensionRegistry registry = Platform.getExtensionRegistry(); - - final IExtensionPoint xpoint - = registry.getExtensionPoint(JptJaxbUiPlugin.PLUGIN_ID, EXTENSION_POINT_ID); - - if (xpoint == null) { - throw new IllegalStateException(); - } - - List<IConfigurationElement> platformUiConfigs = new ArrayList<IConfigurationElement>(); - - for (IExtension extension : xpoint.getExtensions()) { - for (IConfigurationElement configElement : extension.getConfigurationElements()) { - if (configElement.getName().equals(PLATFORM_UI_ELEMENT)) { - platformUiConfigs.add(configElement); - } - } - } - - for (IConfigurationElement configElement: platformUiConfigs) { - readPlatformUiExtension(configElement); - } - } - - private void readPlatformUiExtension(IConfigurationElement element) { - try { - JaxbPlatformUiConfig platformUiConfig = new JaxbPlatformUiConfig(); - - // plug-in id - platformUiConfig.setPluginId(element.getContributor().getName()); - - // id - platformUiConfig.setId(findRequiredAttribute(element, ID_ATTRIBUTE)); - - if (this.platformUiConfigs.containsKey(platformUiConfig.getId())) { - logDuplicateExtension(QUALIFIED_EXTENSION_POINT_ID, ID_ATTRIBUTE, platformUiConfig.getId()); - throw new XPointException(); - } - - // jaxb platform id - String jaxbPlatformId = findRequiredAttribute(element, PLATFORM_ATTRIBUTE); - JaxbPlatformDescription jaxbPlatform = - JptJaxbCorePlugin.getJaxbPlatformManager().getJaxbPlatform(jaxbPlatformId); - - if (jaxbPlatform == null) { - logInvalidValue(element, PLATFORM_ATTRIBUTE, jaxbPlatformId); - } - - if (this.platformToUiConfigs.containsKey(jaxbPlatform)) { - logDuplicateExtension(QUALIFIED_EXTENSION_POINT_ID, PLATFORM_ATTRIBUTE, jaxbPlatformId); - throw new XPointException(); - } - - platformUiConfig.setJaxbPlatform(jaxbPlatform); - - // class - platformUiConfig.setClassName(findRequiredAttribute(element, CLASS_ATTRIBUTE)); - - this.platformUiConfigs.addItem(platformUiConfig.getId(), platformUiConfig); - this.platformToUiConfigs.addItem(jaxbPlatform, platformUiConfig); - } - catch (XPointException e) { - // Ignore and continue. The problem has already been reported to the user - // in the log. - } - } - - public JaxbPlatformUi getJaxbPlatformUi(JaxbPlatformDescription platformDesc) { - JaxbPlatformUiConfig config = this.platformToUiConfigs.getItem(platformDesc); - return (config == null) ? null : config.getPlatformUi(); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbProjectModel.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbProjectModel.java deleted file mode 100644 index 96fb670b28..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbProjectModel.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.eclipse.jpt.jaxb.ui.internal.properties; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jpt.common.utility.internal.model.value.AspectPropertyValueModelAdapter; -import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent; -import org.eclipse.jpt.common.utility.model.listener.CollectionChangeAdapter; -import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jaxb.core.JaxbProject; -import org.eclipse.jpt.jaxb.core.JaxbProjectManager; -import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin; - -/** - * Treat the JAXB project as an "aspect" of the Eclipse project (IProject); - * but the JAXB project is stored in the JAXB model, not the Eclipse project - * itself.... - * We also need to listen for the JAXB project to be rebuilt if the user - * changes the Eclipse project's JAXB platform (which is stored in the - * Eclipse project's preferences). - */ -class JaxbProjectModel - extends AspectPropertyValueModelAdapter<IProject, JaxbProject> { - - /** - * The JAXB project may also change via another page (notably, the project facets page). - * In that case, the preference change occurs before we actually have another project, - * so we must listen to the projects manager - */ - private final CollectionChangeListener projectManagerListener; - - - JaxbProjectModel(PropertyValueModel<IProject> projectModel) { - super(projectModel); - this.projectManagerListener = buildProjectManagerListener(); - } - - private CollectionChangeListener buildProjectManagerListener() { - return new CollectionChangeAdapter() { - // we are only looking for the project rebuild *add* event here so we can - // determine if the platform has changed. - // the other events are unimportant in this case - @Override - public void itemsAdded(CollectionAddEvent event) { - platformChanged(); - } - }; - } - - void platformChanged() { - this.propertyChanged(); - } - - @Override - protected void engageSubject_() { - JptJaxbCorePlugin.getProjectManager().addCollectionChangeListener( - JaxbProjectManager.JAXB_PROJECTS_COLLECTION, - this.projectManagerListener); - } - - @Override - protected void disengageSubject_() { - JptJaxbCorePlugin.getProjectManager().removeCollectionChangeListener( - JaxbProjectManager.JAXB_PROJECTS_COLLECTION, - this.projectManagerListener); - } - - @Override - protected JaxbProject buildValue_() { - return JptJaxbCorePlugin.getJaxbProject(this.subject); - } -}
\ No newline at end of file diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbProjectPropertiesPage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbProjectPropertiesPage.java deleted file mode 100644 index d9471eee5b..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbProjectPropertiesPage.java +++ /dev/null @@ -1,312 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. 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: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.properties; - -import static org.eclipse.jst.common.project.facet.ui.libprov.LibraryProviderFrameworkUi.createInstallLibraryPanel; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jpt.common.core.internal.utility.ICUStringCollator; -import org.eclipse.jpt.common.ui.internal.properties.JptProjectPropertiesPage; -import org.eclipse.jpt.common.ui.internal.utility.swt.SWTTools; -import org.eclipse.jpt.common.utility.internal.StringConverter; -import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable; -import org.eclipse.jpt.common.utility.internal.model.value.AspectPropertyValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.BufferedWritablePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.CompositeCollectionValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyCollectionValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SetCollectionValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.StaticCollectionValueModel; -import org.eclipse.jpt.common.utility.model.Model; -import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent; -import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener; -import org.eclipse.jpt.common.utility.model.value.CollectionValueModel; -import org.eclipse.jpt.common.utility.model.value.ListValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.jaxb.core.JaxbFacet; -import org.eclipse.jpt.jaxb.core.JaxbProject; -import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin; -import org.eclipse.jpt.jaxb.core.libprov.JaxbLibraryProviderInstallOperationConfig; -import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; -import org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider; -import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate; -import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderOperationConfig; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Group; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; - -/** - * Way more complicated UI than you would think.... - */ -public class JaxbProjectPropertiesPage - extends JptProjectPropertiesPage { - - public static final String PROP_ID = "org.eclipse.jpt.jaxb.ui.jaxbProjectPropertiesPage"; //$NON-NLS-1$ - - private PropertyValueModel<JaxbProject> jaxbProjectModel; - - private BufferedWritablePropertyValueModel<JaxbPlatformDescription> platformModel; - private PropertyChangeListener platformListener; - - /* private */ static final Comparator<String> STRING_COMPARATOR = new ICUStringCollator(); - - // ************ construction ************ - - public JaxbProjectPropertiesPage() { - super(); - } - - - @Override - protected void buildModels() { - this.jaxbProjectModel = new JaxbProjectModel(this.projectModel); - - this.platformModel = this.buildPlatformModel(); - this.platformListener = this.buildPlatformListener(); - } - - - // ***** platform ID model - - private BufferedWritablePropertyValueModel<JaxbPlatformDescription> buildPlatformModel() { - return new BufferedWritablePropertyValueModel<JaxbPlatformDescription>( - new PlatformModel(this.jaxbProjectModel), this.trigger); - } - - private PropertyChangeListener buildPlatformListener(){ - return new PropertyChangeListener() { - public void propertyChanged(PropertyChangeEvent event) { - JaxbProjectPropertiesPage.this.platformChanged((JaxbPlatformDescription) event.getNewValue()); - } - }; - } - - void platformChanged(JaxbPlatformDescription newPlatform) { - if ( ! this.getControl().isDisposed()) { - // handle null, in the case the jpa facet is changed via the facets page, - // the library install delegate is temporarily null - adjustLibraryProviders(); - } - } - - - // ********** LibraryFacetPropertyPage implementation ********** - - @Override - public IProjectFacetVersion getProjectFacetVersion() { - return this.getFacetedProject().getInstalledVersion(JaxbFacet.FACET); - } - - @Override - protected void adjustLibraryProviders() { - LibraryInstallDelegate lid = this.getLibraryInstallDelegate(); - if (lid != null) { - List<JaxbLibraryProviderInstallOperationConfig> jaxbConfigs - = new ArrayList<JaxbLibraryProviderInstallOperationConfig>(); - // add the currently selected one first - JaxbLibraryProviderInstallOperationConfig currentJaxbConfig = null; - LibraryProviderOperationConfig config = lid.getLibraryProviderOperationConfig(); - if (config instanceof JaxbLibraryProviderInstallOperationConfig) { - currentJaxbConfig = (JaxbLibraryProviderInstallOperationConfig) config; - jaxbConfigs.add(currentJaxbConfig); - } - for (ILibraryProvider lp : lid.getLibraryProviders()) { - config = lid.getLibraryProviderOperationConfig(lp); - if (config instanceof JaxbLibraryProviderInstallOperationConfig - && ! config.equals(currentJaxbConfig)) { - jaxbConfigs.add((JaxbLibraryProviderInstallOperationConfig) config); - } - } - for (JaxbLibraryProviderInstallOperationConfig jaxbConfig : jaxbConfigs) { - jaxbConfig.setJaxbPlatform(this.platformModel.getValue()); - } - } - } - - - // ********** page ********** - - @Override - protected void createWidgets(Composite parent) { - buildPlatformGroup(parent); - - Control libraryProviderComposite = createInstallLibraryPanel( - parent, - getLibraryInstallDelegate(), - JptJaxbUiMessages.JaxbFacetWizardPage_jaxbImplementationLabel); - - libraryProviderComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - -// PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, JaxbHelpContextIds.PROPERTIES_JAVA_PERSISTENCE); - } - - @Override - protected void engageListeners() { - super.engageListeners(); - this.platformModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.platformListener); - } - - @Override - public void disengageListeners() { - this.platformModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.platformListener); - super.disengageListeners(); - } - - - // ********** platform group ********** - - private void buildPlatformGroup(Composite composite) { - Group group = new Group(composite, SWT.NONE); - group.setText(JptJaxbUiMessages.JaxbFacetWizardPage_platformLabel); - group.setLayout(new GridLayout()); - group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Combo platformDropDown = this.buildDropDown(group); - SWTTools.bind( - buildPlatformChoicesModel(), - this.platformModel, - platformDropDown, - JAXB_PLATFORM_LABEL_CONVERTER); - - buildFacetsPageLink(group, JptJaxbUiMessages.JaxbFacetWizardPage_facetsPageLink); - } - - /** - * Add the project's JAXB platform if it is not on the list of valid - * platforms. - * <p> - * This is probably only useful if the project is corrupted - * and has a platform that exists in the registry but is not on the - * list of valid platforms for the project's JAXB facet version. - * Because, if the project's JAXB platform is completely invalid, there - * would be no JAXB project! - */ - @SuppressWarnings("unchecked") - private ListValueModel<JaxbPlatformDescription> buildPlatformChoicesModel() { - return new SortedListValueModelAdapter<JaxbPlatformDescription>( - new SetCollectionValueModel<JaxbPlatformDescription>( - new CompositeCollectionValueModel<CollectionValueModel<JaxbPlatformDescription>, JaxbPlatformDescription>( - new PropertyCollectionValueModelAdapter<JaxbPlatformDescription>(this.platformModel), - buildRegistryPlatformsModel())), - JAXB_PLATFORM_COMPARATOR); - } - - private CollectionValueModel<JaxbPlatformDescription> buildRegistryPlatformsModel() { - Iterable<JaxbPlatformDescription> enabledPlatforms = - new FilteringIterable<JaxbPlatformDescription>( - JptJaxbCorePlugin.getJaxbPlatformManager().getJaxbPlatforms()) { - @Override - protected boolean accept(JaxbPlatformDescription o) { - return o.supportsJaxbFacetVersion(getProjectFacetVersion()); - } - }; - return new StaticCollectionValueModel<JaxbPlatformDescription>(enabledPlatforms); - } - - private static final Comparator<JaxbPlatformDescription> JAXB_PLATFORM_COMPARATOR = - new Comparator<JaxbPlatformDescription>() { - public int compare(JaxbPlatformDescription desc1, JaxbPlatformDescription desc2) { - return STRING_COMPARATOR.compare(desc1.getLabel(), desc2.getLabel()); - } - }; - - private static final StringConverter<JaxbPlatformDescription> JAXB_PLATFORM_LABEL_CONVERTER = - new StringConverter<JaxbPlatformDescription>() { - public String convertToString(JaxbPlatformDescription desc) { - return desc.getLabel(); - } - }; - - - // ********** OK/Revert/Apply behavior ********** - - @Override - protected boolean projectRebuildRequired() { - return this.platformModel.isBuffering(); - } - - @Override - protected void rebuildProject() { - // if the JAXB platform is changed, we need to completely rebuild the JAXB project - JptJaxbCorePlugin.getProjectManager().rebuildJaxbProject(getProject()); - } - - @Override - protected BufferedWritablePropertyValueModel<?>[] buildBufferedModels() { - return new BufferedWritablePropertyValueModel[] { - this.platformModel - }; - } - - - // ********** validation ********** - - @Override - protected Model[] buildValidationModels() { - return new Model[] { - platformModel - }; - } - - @Override - protected void performValidation(Map<Integer, ArrayList<IStatus>> statuses) { - /* platform */ - // user is unable to unset the platform, so no validation necessary - - /* library provider */ - super.performValidation(statuses); - } - - - // ********** UI model adapters ********** - - /** - * Treat the JAXB platform as an "aspect" of the JAXB project. - * The platform ID is stored in the project preferences. - * The platform ID does not change for a JAXB project - if the user wants a - * different platform, we build an entirely new JAXB project. - */ - static class PlatformModel - extends AspectPropertyValueModelAdapter<JaxbProject, JaxbPlatformDescription> { - - PlatformModel(PropertyValueModel<JaxbProject> jaxbProjectModel) { - super(jaxbProjectModel); - } - - @Override - protected JaxbPlatformDescription buildValue_() { - return this.subject.getPlatform().getDescription(); - } - - @Override - public void setValue_(JaxbPlatformDescription newPlatform) { - JptJaxbCorePlugin.setJaxbPlatform(this.subject.getProject(), newPlatform); - } - - @Override - protected void engageSubject_() { - // the platform ID does not change - } - - @Override - protected void disengageSubject_() { - // the platform ID does not change - } - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbSchemasPropertiesPage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbSchemasPropertiesPage.java deleted file mode 100644 index eedc507131..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbSchemasPropertiesPage.java +++ /dev/null @@ -1,912 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.properties; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.EventListener; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.dialogs.TitleAreaDialog; -import org.eclipse.jface.dialogs.TrayDialog; -import org.eclipse.jface.layout.TableColumnLayout; -import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.viewers.ColumnViewerToolTipSupport; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.window.ToolTip; -import org.eclipse.jface.window.Window; -import org.eclipse.jpt.common.ui.internal.swt.ColumnAdapter; -import org.eclipse.jpt.common.ui.internal.swt.TableModelAdapter; -import org.eclipse.jpt.common.ui.internal.utility.swt.SWTTools; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable; -import org.eclipse.jpt.common.utility.internal.model.AbstractModel; -import org.eclipse.jpt.common.utility.internal.model.value.AspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.BufferedWritablePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.CollectionPropertyValueModelAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; -import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; -import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelAdapter; -import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent; -import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener; -import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener; -import org.eclipse.jpt.common.utility.model.value.CollectionValueModel; -import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; -import org.eclipse.jpt.common.utility.model.value.WritableCollectionValueModel; -import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; -import org.eclipse.jpt.jaxb.core.JaxbProject; -import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin; -import org.eclipse.jpt.jaxb.core.xsd.XsdUtil; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; -import org.eclipse.jpt.jaxb.ui.internal.wizards.classesgen.SelectFileOrXMLCatalogIdPanel; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.dialogs.PropertyPage; -import org.eclipse.wst.common.uriresolver.internal.URI; -import org.eclipse.wst.xsd.contentmodel.internal.XSDImpl; -import org.eclipse.xsd.XSDSchema; - -/** - * Shows the schemas associated with a JAXB project - */ -public class JaxbSchemasPropertiesPage - extends PropertyPage { - - private static final int SIZING_SELECTION_PANE_WIDTH = 450; - - - protected final WritablePropertyValueModel<IProject> projectModel; - - private final PropertyValueModel<JaxbProject> jaxbProjectModel; - - protected final BufferedWritablePropertyValueModel.Trigger trigger; - - private final SchemasModel schemasModel; - - private final WritableCollectionValueModel<Schema> schemasSelectionModel; - - - public JaxbSchemasPropertiesPage() { - super(); - this.projectModel = new SimplePropertyValueModel<IProject>(); - this.jaxbProjectModel = new JaxbProjectModel(this.projectModel); - this.trigger = new BufferedWritablePropertyValueModel.Trigger(); - this.schemasModel = new SchemasModel(this.jaxbProjectModel, this.trigger); - this.schemasSelectionModel = new SimpleCollectionValueModel<Schema>(); - setDescription(JptJaxbUiMessages.SchemasPage_description); - } - - - protected IProject getProject() { - return this.projectModel.getValue(); - } - - @Override - public final void createControl(Composite parent ) { - super.createControl( parent ); - - Button revertButton = getDefaultsButton(); - - revertButton.setText(JptJaxbUiMessages.SchemasPage_revert); - - GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - Point minButtonSize = revertButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); - gd.widthHint = Math.max(convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH), minButtonSize.x); - revertButton.setLayoutData(gd); - - updateButtons(); - - getShell().layout(true, true); - } - - @Override - protected final Control createContents(Composite parent) { - IAdaptable element = getElement(); - - IProject project = null; - if (element instanceof IProject) { - project = (IProject) element; - } - else { - project = (IProject) Platform.getAdapterManager().loadAdapter(element, IProject.class.getName()); - } - - this.projectModel.setValue(project); - - Composite pageComponent = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginWidth = 0; - layout.marginHeight = 0; - pageComponent.setLayout(layout); - GridData data = new GridData(GridData.FILL_BOTH); - data.widthHint = SIZING_SELECTION_PANE_WIDTH; - pageComponent.setLayoutData(data); - - Label schemasLabel = new Label(pageComponent, SWT.LEFT); - schemasLabel.setText(JptJaxbUiMessages.SchemasPage_schemas); - data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.horizontalSpan = 2; - schemasLabel.setLayoutData(data); - - // create the table composite - Composite tableComposite = new Composite(pageComponent, SWT.NONE); - data = new GridData(SWT.FILL, SWT.FILL, true, true); - data.grabExcessHorizontalSpace = true; - data.grabExcessVerticalSpace = true; - data.widthHint = SIZING_SELECTION_PANE_WIDTH; - tableComposite.setLayoutData(data); - - // create the table - TableViewer schemasTable = new TableViewer(tableComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); - TableModelAdapter.adapt( - new SortedListValueModelAdapter<Schema>(this.schemasModel), - this.schemasSelectionModel, - schemasTable.getTable(), - new SchemaColumnAdapter(), - new SchemaTableLabelProvider()); - ColumnViewerToolTipSupport.enableFor(schemasTable, ToolTip.NO_RECREATE); - schemasTable.getTable().setHeaderVisible(true); - schemasTable.getTable().setToolTipText(null); - - // set the table composite layout (after the table, so that column information is available) - TableColumnLayout tableLayout = new TableColumnLayout(); - tableLayout.setColumnData(schemasTable.getTable().getColumn(0), new ColumnWeightData(15)); - tableLayout.setColumnData(schemasTable.getTable().getColumn(1), new ColumnWeightData(25)); - tableComposite.setLayout(tableLayout); - - // set the table layout data - data = new GridData(GridData.FILL_BOTH); - data.heightHint = schemasTable.getTable().getItemHeight() * 7; - data.widthHint = 200; - schemasTable.getTable().setLayoutData(data); - - createButtonGroup(pageComponent); - - Dialog.applyDialogFont(parent); - - return pageComponent; - } - - protected void createButtonGroup(Composite parent) { - Composite groupComponent = new Composite(parent, SWT.NULL); - GridLayout groupLayout = new GridLayout(); - groupLayout.marginWidth = 0; - groupLayout.marginHeight = 0; - groupComponent.setLayout(groupLayout); - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - groupComponent.setLayoutData(data); - - Button addButton = new Button(groupComponent, SWT.PUSH); - addButton.setText(JptJaxbUiMessages.SchemasPage_addButtonLabel); - addButton.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - addSchema(); - } - }); - setButtonLayoutData(addButton); - - Button editButton = new Button(groupComponent, SWT.PUSH); - editButton.setText(JptJaxbUiMessages.SchemasPage_editButtonLabel); - editButton.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - editSelectedSchema(); - } - }); - SWTTools.controlEnabledState(buildEditEnabledModel(), editButton); - setButtonLayoutData(editButton); - - Button removeButton = new Button(groupComponent, SWT.PUSH); - removeButton.setText(JptJaxbUiMessages.SchemasPage_removeButtonLabel); - removeButton.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - removeSelectedSchemas(); - } - }); - SWTTools.controlEnabledState(buildRemoveEnabledModel(), removeButton); - setButtonLayoutData(removeButton); - } - - - private void addSchema() { - // constructs a dialog for editing the new schema namespace and location - AddEditSchemaDialog dialog = - new AddEditSchemaDialog( - getShell(), - null, - this.schemasModel.getValue()); - - // opens the dialog - just returns if the user cancels it - if (dialog.open() == Window.CANCEL) { - return; - } - - // otherwise, adds the new schema - Schema schema = this.schemasModel.addSchema(dialog.getNamespace(), dialog.getLocation()); - - // select the new schema - this.schemasSelectionModel.setValues(new SingleElementIterable<Schema>(schema)); - } - - private PropertyValueModel<Boolean> buildEditEnabledModel() { - return new CollectionPropertyValueModelAdapter<Boolean>(this.schemasSelectionModel) { - @Override - protected Boolean buildValue() { - return this.collectionModel.size() == 1; - } - }; - } - - private void editSelectedSchema() { - // constructs a dialog for editing the new schema namespace and location - final Schema schema = this.schemasSelectionModel.iterator().next(); - AddEditSchemaDialog dialog = - new AddEditSchemaDialog( - getShell(), - schema, - this.schemasModel.getValue()); - - // opens the dialog - just returns if the user cancels it - if (dialog.open() == Window.CANCEL) { - return; - } - - // otherwise, changes the new schema - schema.setNamespace(dialog.getNamespace()); - schema.setLocation(dialog.getLocation()); - } - - private PropertyValueModel<Boolean> buildRemoveEnabledModel() { - return new CollectionPropertyValueModelAdapter<Boolean>(this.schemasSelectionModel) { - @Override - protected Boolean buildValue() { - return this.collectionModel.size() >= 1; - } - }; - } - - private void removeSelectedSchemas() { - this.schemasModel.removeSchemas(CollectionTools.iterable(this.schemasSelectionModel.iterator())); - } - - private void updateButtons() { - boolean enableApply = isValid(); - boolean enableRevert = true; - - Button applyButton = getApplyButton(); - - if (applyButton != null) { - applyButton.setEnabled(enableApply); - } - - Button revertButton = getDefaultsButton(); - - if (revertButton != null) { - revertButton.setEnabled(enableRevert); - } - } - - - // ********** OK/Revert/Apply behavior ********** - - @Override - public boolean performOk() { - try { - // true=fork; false=uncancellable - this.buildOkProgressMonitorDialog().run(true, false, this.buildOkRunnableWithProgress()); - } - catch (InterruptedException ex) { - return false; - } - catch (InvocationTargetException ex) { - throw new RuntimeException(ex.getTargetException()); - } - - return true; - } - - private IRunnableContext buildOkProgressMonitorDialog() { - return new ProgressMonitorDialog(this.getShell()); - } - - private IRunnableWithProgress buildOkRunnableWithProgress() { - return new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - IWorkspace ws = ResourcesPlugin.getWorkspace(); - try { - // the build we execute in #performOk_() locks the workspace root, - // so we need to use the workspace root as our scheduling rule here - ws.run( - buildOkWorkspaceRunnable(), - ws.getRoot(), - IWorkspace.AVOID_UPDATE, - monitor); - } - catch (CoreException ex) { - throw new InvocationTargetException(ex); - } - } - }; - } - - /* private */ IWorkspaceRunnable buildOkWorkspaceRunnable() { - return new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - performOk_(monitor); - } - }; - } - - void performOk_(IProgressMonitor monitor) throws CoreException { - if (this.schemasModel.hasChanges()) { - this.trigger.accept(); - JptJaxbCorePlugin.getProjectManager().rebuildJaxbProject(getProject()); - getProject().build(IncrementalProjectBuilder.FULL_BUILD, monitor); - } - } - - @Override - protected void performDefaults() { - this.trigger.reset(); - } - - @Override - public void dispose() { - - super.dispose(); - } - - - static class SchemasModel - extends AspectAdapter<JaxbProject> - implements CollectionValueModel<Schema> { - - /** - * The collection of schemas - */ - protected final Collection<Schema> schemas; - - /** - * This is the trigger that indicates whether the buffered value - * should be accepted or reset. - */ - protected final PropertyValueModel<Boolean> triggerHolder; - - /** This listens to the trigger holder. */ - protected final PropertyChangeListener triggerChangeListener; - - - SchemasModel(PropertyValueModel<JaxbProject> subjectHolder, PropertyValueModel<Boolean> triggerHolder) { - super(subjectHolder); - this.schemas = new ArrayList<Schema>(); - this.triggerHolder = triggerHolder; - this.triggerChangeListener = buildTriggerChangeListener(); - } - - - protected PropertyChangeListener buildTriggerChangeListener() { - return new PropertyChangeListener() { - public void propertyChanged(PropertyChangeEvent event) { - triggerChanged(event); - } - }; - } - - protected Collection<Schema> buildSchemas_() { - ArrayList<Schema> schemas = new ArrayList<Schema>(); - for (Map.Entry<String, String> entry : this.subject.getSchemaLibrary().getSchemaLocations().entrySet()) { - schemas.add(new Schema(entry.getKey(), entry.getValue())); - } - return schemas; - } - - public boolean hasChanges() { - return (this.subject == null) ? false : ! this.schemas.equals(buildSchemas_()); - } - - protected void triggerChanged(PropertyChangeEvent event) { - if (hasChanges()) { - if (this.subject != null && ((Boolean) event.getNewValue()).booleanValue()) { - this.accept(); - } else { - this.reset(); - } - } - } - - public void accept() { - Map<String, String> schemaLocations = new HashMap<String, String>(); - for (Schema schema : this.schemas) { - schemaLocations.put(schema.getNamespace(), schema.getLocation()); - } - this.subject.getSchemaLibrary().setSchemaLocations(schemaLocations); - } - - public void reset() { - this.schemas.clear(); - if (this.subject != null) { - this.schemas.addAll(buildSchemas_()); - } - fireCollectionChanged(VALUES, getValue()); - } - - public Schema addSchema(String namespace, String location) { - Schema schema = new Schema(namespace, location); - addItemToCollection(schema, this.schemas, VALUES); - return schema; - } - - public void removeSchemas(Iterable<Schema> schemas) { - removeItemsFromCollection(schemas, this.schemas, VALUES); - } - - - // ************ AspectAdapter impl ************************************ - - @Override - protected String getListenerAspectName() { - return VALUES; - } - - @Override - protected Class<? extends EventListener> getListenerClass() { - return CollectionChangeListener.class; - } - - @Override - protected boolean hasListeners() { - return hasAnyCollectionChangeListeners(VALUES); - } - - @Override - protected void fireAspectChanged(Object oldValue, Object newValue) { - fireCollectionChanged(VALUES, getValue()); - } - - @Override - protected void engageSubject_() { - this.schemas.addAll(buildSchemas_()); - } - - @Override - protected void disengageSubject_() { - this.schemas.clear(); - } - - @Override - protected void engageModels() { - super.engageModels(); - this.triggerHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.triggerChangeListener); - } - - @Override - protected void disengageModels() { - this.triggerHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.triggerChangeListener); - super.disengageModels(); - } - - @Override - protected Collection<Schema> getValue() { - return CollectionTools.collection(iterator()); - } - - - // ************ CollectionValueModel impl ***************************** - - public Iterator<Schema> iterator() { - return this.schemas.iterator(); - } - - public int size() { - return this.schemas.size(); - } - } - - - static class Schema - extends AbstractModel - implements Comparable<Schema> { - - Schema(String namespace, String location) { - super(); - this.namespace = namespace; - this.location = location; - } - - - private String namespace; - final static String NAMESPACE_PROPERTY = "namespace"; - - private String location; - final static String LOCATION_PROPERTY = "location"; - - - String getNamespace() { - return this.namespace; - } - - void setNamespace(String namespace) { - String old = this.namespace; - this.namespace = namespace; - firePropertyChanged(NAMESPACE_PROPERTY, old, namespace); - } - - String getLocation() { - return this.location; - } - - void setLocation(String location) { - String old = this.location; - this.location = location; - firePropertyChanged(LOCATION_PROPERTY, old, location); - } - - public int compareTo(Schema o) { - return this.namespace.compareTo(o.namespace); - } - } - - - static class SchemaColumnAdapter - implements ColumnAdapter<Schema> { - - static final int COLUMN_COUNT = 2; - static final int NAMESPACE_COLUMN = 0; - static final int LOCATION_COLUMN = 1; - - - public int columnCount() { - return COLUMN_COUNT; - } - - public String columnName(int columnIndex) { - switch (columnIndex) { - case NAMESPACE_COLUMN : - return JptJaxbUiMessages.SchemasPage_namespaceColumnLabel; - case LOCATION_COLUMN : - return JptJaxbUiMessages.SchemasPage_locationColumnLabel; - default : - return null; - } - } - - public WritablePropertyValueModel<?>[] cellModels(Schema subject) { - WritablePropertyValueModel<?>[] cellModels = new WritablePropertyValueModel<?>[COLUMN_COUNT]; - cellModels[NAMESPACE_COLUMN] = buildNamespaceCellModel(subject); - cellModels[LOCATION_COLUMN] = buildLocationCellModel(subject); - return cellModels; - } - - private WritablePropertyValueModel<String> buildNamespaceCellModel(Schema subject) { - return new PropertyAspectAdapter<Schema, String>(Schema.NAMESPACE_PROPERTY, subject) { - @Override - protected String buildValue_() { - return this.subject.getNamespace(); - } - }; - } - - private WritablePropertyValueModel<String> buildLocationCellModel(Schema subject) { - return new PropertyAspectAdapter<Schema, String>(Schema.LOCATION_PROPERTY, subject) { - @Override - protected String buildValue_() { - return this.subject.getLocation(); - } - }; - } - } - - - static class SchemaTableLabelProvider - extends LabelProvider - implements ITableLabelProvider { - - public Image getColumnImage(Object element, int columnIndex) { - return null; - } - - public String getColumnText(Object element, int columnIndex) { - switch (columnIndex) { - case SchemaColumnAdapter.NAMESPACE_COLUMN : - return ((Schema) element).getNamespace(); - case SchemaColumnAdapter.LOCATION_COLUMN : - return ((Schema) element).getLocation(); - default : - return null; - } - } - } - - - static class AddEditSchemaDialog - extends TitleAreaDialog { - - private Schema currentSchema; - - private String defaultMessage; - - private final WritablePropertyValueModel<String> location; - - private final WritablePropertyValueModel<String> namespace; - - private XSDSchema resolvedSchema; - - private final Mode mode; - - private Iterable<Schema> allSchemas; - - - public AddEditSchemaDialog(Shell shell, Schema currentSchema, Iterable<Schema> allSchemas) { - super(shell); - this.currentSchema = currentSchema; - this.allSchemas = allSchemas; - this.location = new SimplePropertyValueModel<String>(); - this.namespace = new SimplePropertyValueModel<String>(); - - this.mode = (this.currentSchema == null) ? Mode.ADD : Mode.EDIT; - if (this.mode == Mode.ADD) { - this.defaultMessage = JptJaxbUiMessages.SchemasPage_addSchemaMessage; - this.location.setValue(""); - this.namespace.setValue(""); - } - else { - this.defaultMessage = JptJaxbUiMessages.SchemasPage_editSchemaMessage; - this.location.setValue(currentSchema.getLocation()); - this.namespace.setValue(currentSchema.getNamespace()); - } - } - - - @Override - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - if (this.mode == Mode.ADD) { - newShell.setText(JptJaxbUiMessages.SchemasPage_addSchemaDialogTitle); - } - else { - newShell.setText(JptJaxbUiMessages.SchemasPage_editSchemaDialogTitle); - } - } - - @Override - protected Control createDialogArea(Composite parent) { - Composite dialogArea = (Composite) super.createDialogArea(parent); - - setMessage(this.defaultMessage); - if (this.mode == Mode.ADD) { - setTitle(JptJaxbUiMessages.SchemasPage_addSchemaTitle); - } - else { - setTitle(JptJaxbUiMessages.SchemasPage_editSchemaTitle); - } - - Composite composite = new Composite(dialogArea, SWT.NONE); - composite.setLayout(new GridLayout(3, false)); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Label locationLabel = new Label(composite, SWT.NULL); - locationLabel.setText(JptJaxbUiMessages.SchemasPage_locationLabel); - locationLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); - - final Text locationText = new Text(composite, SWT.SINGLE | SWT.BORDER); - locationText.setText(this.location.getValue()); - locationText.setEditable(false); - locationText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); - this.location.addPropertyChangeListener( - PropertyValueModel.VALUE, - new PropertyChangeListener() { - public void propertyChanged(PropertyChangeEvent event) { - locationText.setText((String) event.getNewValue()); - } - }); - - Button browseButton = new Button(composite, SWT.PUSH); - browseButton.setText(JptJaxbUiMessages.SchemasPage_browseButtonLabel); - browseButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, true, 1, 1)); - browseButton.addSelectionListener( - new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - browseForSchemaLocation(); - } - - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - }); - - Label namespaceLabel = new Label(composite, SWT.NULL); - namespaceLabel.setText(JptJaxbUiMessages.SchemasPage_namespaceLabel); - namespaceLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); - - final Text namespaceText = new Text(composite, SWT.SINGLE | SWT.BORDER); - namespaceText.setText(this.namespace.getValue()); - namespaceText.setEditable(false); - namespaceText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); - this.namespace.addPropertyChangeListener( - PropertyValueModel.VALUE, - new PropertyChangeListener() { - public void propertyChanged(PropertyChangeEvent event) { - String newValue = (String) event.getNewValue(); - String display = (StringTools.stringIsEmpty(newValue)) ? - JptJaxbUiMessages.SchemasPage_noNamespaceText : newValue; - namespaceText.setText(display); - } - }); - - Dialog.applyDialogFont(dialogArea); - - return dialogArea; - } - - @Override - protected boolean isResizable() { - return true; - } - - private void browseForSchemaLocation() { - SchemaLocationDialog dialog = new SchemaLocationDialog(getShell()); - - // opens the dialog - just returns if the user cancels it - if (dialog.open() == Window.CANCEL) { - return; - } - - String location = dialog.getLocation(); - this.location.setValue(location); - - String resolvedUri = XsdUtil.getResolvedUri(null, location); - - XSDSchema schema = XSDImpl.buildXSDModel(resolvedUri); - String newNamespace = (schema == null) ? null : schema.getTargetNamespace(); - this.namespace.setValue(newNamespace); - this.resolvedSchema = schema; - - validate(); - } - - public String getNamespace() { - return this.namespace.getValue(); - } - - public String getLocation() { - return this.location.getValue(); - } - - private void validate() { - if (this.resolvedSchema == null) { - setErrorMessage(JptJaxbUiMessages.SchemasPage_schemaUnresolvedMessage); - } - else if (isDuplicateNamespace()) { - setErrorMessage(JptJaxbUiMessages.SchemasPage_duplicateNamespaceMessage); - } - else if (StringTools.stringIsEmpty(this.location.getValue())) { - setErrorMessage(JptJaxbUiMessages.SchemasPage_noLocationMessage); - } - else { - setErrorMessage(null); - setMessage(this.defaultMessage); - } - getButton(IDialogConstants.OK_ID).setEnabled(getErrorMessage() == null); - } - - private boolean isDuplicateNamespace() { - for (Schema schema : this.allSchemas) { - if ((this.currentSchema != schema) && getNamespace().equals(schema.getNamespace())) { - return true; - } - } - return false; - } - - - private enum Mode { - ADD, - EDIT - } - } - - - static class SchemaLocationDialog - extends TrayDialog { - - private SelectFileOrXMLCatalogIdPanel locationPanel; - - private String location; - - - public SchemaLocationDialog(Shell shell) { - super(shell); - } - - - @Override - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(JptJaxbUiMessages.SchemasPage_chooseLocationTitle); - } - - @Override - protected Control createDialogArea(Composite parent) { - Composite composite = (Composite) super.createDialogArea(parent); - - this.locationPanel = new SelectFileOrXMLCatalogIdPanel(composite, StructuredSelection.EMPTY); - this.locationPanel.setFilterExtensions(new String[] {".xsd"}); - this.locationPanel.update(); - this.locationPanel.setVisibleHelper(true); - - return composite; - } - - @Override - protected boolean isResizable() { - return true; - } - - @Override - protected void okPressed() { - IFile file = this.locationPanel.getFile(); - if (file != null) { - this.location = URI.createPlatformResourceURI(file.getFullPath().toString()).toString(); - } - else { - this.location = this.locationPanel.getXMLCatalogId(); - } - - super.okPressed(); - } - - public String getLocation() { - return this.location; - } - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/ProjectWizardPage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/ProjectWizardPage.java deleted file mode 100644 index 89c3c8ca3e..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/ProjectWizardPage.java +++ /dev/null @@ -1,246 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2010 Oracle. 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: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.wizards; - -import java.util.Iterator; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.jpt.common.utility.internal.ArrayTools; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable; -import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable; -import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; - -/** - * ProjectWizardPage - */ -public class ProjectWizardPage extends WizardPage -{ - private IJavaProject javaProject; - private ProjectGroup projectGroup; - - // ********** static methods ********** - - public static IJavaProject getJavaProjectFromSelection(IStructuredSelection selection) { - if(selection == null) { - return null; - } - Object firstElement = selection.getFirstElement(); - if(firstElement instanceof IJavaProject) { - return (IJavaProject)firstElement; - } - else if(firstElement instanceof IResource) { - IProject project = ((IResource) firstElement).getProject(); - return getJavaProjectFrom(project); - } - else if(firstElement instanceof IJavaElement) { - return ((IJavaElement)firstElement).getJavaProject(); - } - return null; - } - - public static IJavaProject getJavaProjectFrom(IProject project) { - return (IJavaProject)((IJavaElement)((IAdaptable)project).getAdapter(IJavaElement.class)); - } - - // ********** constructor ********** - - public ProjectWizardPage() { - super("Java Project"); //$NON-NLS-1$ - - this.setDescription(JptJaxbUiMessages.ClassesGeneratorProjectWizardPage_desc); - } - - public ProjectWizardPage(IJavaProject javaProject) { - this(); - - this.javaProject = javaProject; - } - - // ********** IDialogPage implementation ********** - - public void createControl(Composite parent) { - this.setPageComplete(false); - this.setControl(this.buildTopLevelControl(parent)); - } - - // ********** intra-wizard methods ********** - - public IJavaProject getJavaProject() { - return this.javaProject; - } - - // ********** internal methods ********** - - private Control buildTopLevelControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new FillLayout()); - this.projectGroup = new ProjectGroup(composite); - Dialog.applyDialogFont(parent); -// PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, HELP_CONTEXT_ID); - return composite; - } - - private void setJavaProject(IJavaProject project) { - this.javaProject = project; - } - - private void projectChanged() { - this.setPageComplete(false); - String projectName = this.projectGroup.getProjectName(); - if( ! StringTools.stringIsEmpty(projectName)) { - - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - this.setJavaProject(JavaCore.create(project)); - this.setPageComplete(true); - } - } - - // ********** project group ********** - - class ProjectGroup { - - private Combo projectCombo; - - - // ********** constructor ********** - - private ProjectGroup(Composite parent) { - super(); - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout(2, false)); - - // Project - this.buildLabel(composite, JptJaxbUiMessages.JavaProjectWizardPage_project); - this.projectCombo = this.buildProjectCombo(composite, this.buildProjectComboSelectionListener()); - this.updateProjectCombo(); - - setPageComplete( ! StringTools.stringIsEmpty(this.getProjectName())); - } - - // ********** listeners ********** - - private SelectionListener buildProjectComboSelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - // nothing special for "default" (double-click?) - this.widgetSelected(event); - } - public void widgetSelected(SelectionEvent event) { - ProjectGroup.this.selectedProjectChanged(); - } - @Override - public String toString() { - return "JavaProjectWizardPage project combo-box selection listener"; //$NON-NLS-1$ - } - }; - } - - // ********** listener callbacks ********** - - void selectedProjectChanged() { - projectChanged(); - } - - // ********** intra-wizard methods ********** - - protected String getProjectName() { - return this.projectCombo.getText(); - } - - // ********** internal methods ********** - - protected void updateProjectCombo() { - - this.projectCombo.removeAll(); - - for (String name : this.getSortedJavaProjectsNames()) { - this.projectCombo.add(name); - } - if(javaProject != null) { - this.projectCombo.select(this.projectCombo.indexOf(javaProject.getProject().getName())); - } - } - - private String[] getSortedJavaProjectsNames() { - return ArrayTools.sort(this.getJavaProjectsNames()); - } - - private String[] getJavaProjectsNames() { - return ArrayTools.array( - new TransformationIterable<IProject, String>(this.getJavaProjects()) { - @Override - protected String transform(IProject project) { - return project.getName(); - } - }, - new String[0]); - } - - private Iterable<IProject> getJavaProjects() { - return new FilteringIterable<IProject>(CollectionTools.collection(this.getProjects())) { - @Override - protected boolean accept(IProject next) { - try { - return next.hasNature(JavaCore.NATURE_ID); - } - catch (CoreException e) { - return false; - } - } - }; - } - - private Iterator<IProject> getProjects() { - return new ArrayIterator<IProject>(ResourcesPlugin.getWorkspace().getRoot().getProjects()); - } - - // ********** UI components ********** - - private Label buildLabel(Composite parent, String text) { - Label label = new Label(parent, SWT.LEFT); - label.setLayoutData(new GridData()); - label.setText(text); - return label; - } - - private Combo buildProjectCombo(Composite parent, SelectionListener listener) { - Combo projectCombo = new Combo(parent, SWT.READ_ONLY); - GridData gridData = new GridData(); - gridData.horizontalAlignment = SWT.FILL; - gridData.grabExcessHorizontalSpace = true; - projectCombo.setLayoutData(gridData); - projectCombo.addSelectionListener(listener); - return projectCombo; - } - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorExtensionOptionsWizardPage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorExtensionOptionsWizardPage.java deleted file mode 100644 index c0300c5825..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorExtensionOptionsWizardPage.java +++ /dev/null @@ -1,186 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2010 Oracle. 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: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.wizards.classesgen; - -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -/** - * ClassesGeneratorExtensionOptionsWizardPage - */ -public class ClassesGeneratorExtensionOptionsWizardPage extends WizardPage -{ - - private ExtensionOptionsComposite additionalArgsComposite; - - // ********** constructor ********** - - protected ClassesGeneratorExtensionOptionsWizardPage() { - super("Classes Generator Extension Options"); //$NON-NLS-1$ - - this.initialize(); - } - - protected void initialize() { - this.setTitle(JptJaxbUiMessages.ClassesGeneratorExtensionOptionsWizardPage_title); - this.setDescription(JptJaxbUiMessages.ClassesGeneratorExtensionOptionsWizardPage_desc); - } - - // ********** UI components ********** - - public void createControl(Composite parent) { - this.setPageComplete(true); - this.setControl(this.buildTopLevelControl(parent)); - } - - private Control buildTopLevelControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout()); - - this.additionalArgsComposite = new ExtensionOptionsComposite(composite); - - return composite; - } - - // ********** intra-wizard methods ********** - - protected boolean allowsExtensions() { - return this.additionalArgsComposite.allowsExtensions(); - } - - protected String getClasspath() { - return this.additionalArgsComposite.getClasspath(); - } - - protected String getAdditionalArgs() { - return this.additionalArgsComposite.getAdditionalArgs(); - } - - // ********** AdditionalArgsComposite ********** - - class ExtensionOptionsComposite { - - private boolean allowsExtensions; - private final Text classpathText; - private final Button allowsExtensionsCheckBox; - - private final Text additionalArgsText; - - // ********** constructor ********** - - private ExtensionOptionsComposite(Composite parent) { - super(); - this.allowsExtensions = false; - - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(1, false); - layout.marginHeight = 0; - layout.marginWidth = 0; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - // TODO PlatformUI.getWorkbench().getHelpSystem().setHelp(this.group, HELP_CONTEXT_ID); - - this.allowsExtensionsCheckBox = this.buildAllowsExtensionsCheckBox(composite, this.buildAllowsExtensionsSelectionListener()); - - // Classpath - Label classpathLabel = new Label(composite, SWT.NONE); - classpathLabel.setText(JptJaxbUiMessages.ClassesGeneratorExtensionOptionsWizardPage_classpath); - GridData gridData = new GridData(); - gridData.verticalIndent = 5; - classpathLabel.setLayoutData(gridData); - this.classpathText = this.buildClasspathText(composite); - - Label additionalArgsLabel = new Label(composite, SWT.NONE); - additionalArgsLabel.setText(JptJaxbUiMessages.ClassesGeneratorExtensionOptionsWizardPage_additionalArguments); - gridData = new GridData(); - gridData.verticalIndent = 5; - additionalArgsLabel.setLayoutData(gridData); - this.additionalArgsText = this.buildAdditionalArgsText(composite); - } - - // ********** UI components ********** - - private Button buildAllowsExtensionsCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = new Button(parent, SWT.CHECK); - GridData gridData = new GridData(); - gridData.verticalIndent = 5; - checkBox.setLayoutData(gridData); - checkBox.setText(JptJaxbUiMessages.ClassesGeneratorExtensionOptionsWizardPage_allowExtensions); - checkBox.setSelection(this.allowsExtensions()); - checkBox.addSelectionListener(listener); - return checkBox; - } - - private Text buildClasspathText(Composite parent) { - Text text = new Text(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); - GridData gridData = new GridData(GridData.FILL_HORIZONTAL); - gridData.horizontalSpan = 1; - gridData.verticalIndent = 1; - gridData.heightHint = text.getLineHeight() * 3; - gridData.grabExcessHorizontalSpace = true; - text.setLayoutData(gridData); - return text; - } - - private Text buildAdditionalArgsText(Composite parent) { - Text text = new Text(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); - GridData gridData = new GridData(GridData.FILL_HORIZONTAL); - gridData.horizontalSpan = 1; - gridData.verticalIndent = 1; - gridData.heightHint = text.getLineHeight() * 10; - gridData.grabExcessHorizontalSpace = true; - text.setLayoutData(gridData); - return text; - } - - // ********** listeners ********** - - private SelectionListener buildAllowsExtensionsSelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - this.widgetSelected(event); - } - public void widgetSelected(SelectionEvent event) { - ExtensionOptionsComposite.this.setAllowsExtensions( - ExtensionOptionsComposite.this.allowsExtensionsCheckBox.getSelection()); - } - }; - } - - // ********** intra-wizard methods ********** - - protected boolean allowsExtensions() { - return this.allowsExtensions; - } - - protected void setAllowsExtensions(boolean allowsExtensions){ - this.allowsExtensions = allowsExtensions; - } - - protected String getClasspath() { - return this.classpathText.getText(); - } - - protected String getAdditionalArgs() { - return this.additionalArgsText.getText(); - } - - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorOptionsWizardPage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorOptionsWizardPage.java deleted file mode 100644 index dfa510aa12..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorOptionsWizardPage.java +++ /dev/null @@ -1,805 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2010 Oracle. 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: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.wizards.classesgen; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -/** - * ClassesGeneratorOptionsWizardPage - */ -public class ClassesGeneratorOptionsWizardPage extends WizardPage -{ - private ProxyOptionsComposite proxyOptionsComposite; - private Options1Composite options1Composite; - private Options2Composite options2Composite; - - // ********** constructor ********** - - protected ClassesGeneratorOptionsWizardPage() { - super("Classes Generator Options"); //$NON-NLS-1$ - - this.initialize(); - } - - protected void initialize() { - this.setTitle(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_title); - this.setDescription(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_desc); - } - - // ********** UI components ********** - - public void createControl(Composite parent) { - this.setPageComplete(true); - this.setControl(this.buildTopLevelControl(parent)); - } - - private Control buildTopLevelControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout()); - - this.proxyOptionsComposite = new ProxyOptionsComposite(composite); - - this.buildOptionsComposites(composite); - - return composite; - } - - private void buildOptionsComposites(Composite parent) { - - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout(2, true)); - - this.options1Composite = new Options1Composite(composite); - - this.options2Composite = new Options2Composite(composite); - } - - // ********** intra-wizard methods ********** - - protected String getProxy() { - return this.proxyOptionsComposite.getProxy(); - } - - protected String getProxyFile() { - return this.proxyOptionsComposite.getProxyFile(); - } - - protected boolean usesStrictValidation() { - return this.options1Composite.usesStrictValidation(); - } - - protected boolean makesReadOnly() { - return this.options1Composite.makesReadOnly(); - } - - protected boolean suppressesPackageInfoGen() { - return this.options1Composite.suppressesPackageInfoGen(); - } - - protected boolean suppressesHeaderGen() { - return this.options1Composite.suppressesHeaderGen(); - } - - protected boolean getTarget() { - return this.options1Composite.targetIs20(); - } - - protected boolean isVerbose() { - return this.options1Composite.isVerbose(); - } - - protected boolean isQuiet() { - return this.options1Composite.isQuiet(); - } - - protected boolean treatsAsXmlSchema() { - return this.options2Composite.treatsAsXmlSchema(); - } - - protected boolean treatsAsRelaxNg() { - return this.options2Composite.treatsAsRelaxNg(); - } - - protected boolean treatsAsRelaxNgCompact() { - return this.options2Composite.treatsAsRelaxNgCompact(); - } - - protected boolean treatsAsDtd() { - return this.options2Composite.treatsAsDtd(); - } - - protected boolean treatsAsWsdl() { - return this.options2Composite.treatsAsWsdl(); - } - - protected boolean showsVersion() { - return this.options2Composite.showsVersion(); - } - - protected boolean showsHelp() { - return this.options2Composite.showsHelp(); - } - - // ********** UI controls ********** - - protected Button buildCheckBox(Composite parent, String text, SelectionListener listener, int verticalIndent) { - Button checkBox = new Button(parent, SWT.CHECK); - GridData gridData = new GridData(); - gridData.verticalIndent= verticalIndent; - checkBox.setLayoutData(gridData); - checkBox.setText(text); - checkBox.addSelectionListener(listener); - return checkBox; - } - - protected Button buildRadioButton(Composite parent, String text, SelectionListener listener, int horizontalSpan) { - Button radioButton = new Button(parent, SWT.RADIO); - GridData gridData = new GridData(); - gridData.horizontalSpan = horizontalSpan; - radioButton.setLayoutData(gridData); - radioButton.setText(text); - radioButton.addSelectionListener(listener); - return radioButton; - } - - protected Text buildText(Composite parent, int horizontalSpan) { - Text text = new Text(parent, SWT.SINGLE | SWT.BORDER); - GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); - gridData.horizontalSpan = horizontalSpan; - text.setLayoutData(gridData); - return text; - } - - protected void disableText(Text text) { - text.setEnabled(false); - text.setText(""); //$NON-NLS-1$ - } - - // ********** internal methods ********** - - private String makeRelativeToProjectPath(String filePath) { - Path path = new Path(filePath); - IPath relativePath = path.makeRelativeTo(this.getProject().getLocation()); - return relativePath.toOSString(); - } - - private IProject getProject() { - return ((ClassesGeneratorWizard)this.getWizard()).getJavaProject().getProject(); - } - - // ********** ProxyOptionsComposite ********** - - class ProxyOptionsComposite { - - private final Button noProxyRadioButton; - - private final Button proxyRadioButton; - private final Text proxyText; - - private final Button proxyFileRadioButton; - private final Text proxyFileText; - private Button browseButton; - - // ********** constructor ********** - - private ProxyOptionsComposite(Composite parent) { - super(); - Group proxyGroup = new Group(parent, SWT.NONE); - GridLayout layout = new GridLayout(3, false); - proxyGroup.setLayout(layout); - proxyGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - proxyGroup.setText(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_proxyGroup); - - SelectionListener proxyButtonListener = this.buildProxyRadioButtonListener(); - - this.noProxyRadioButton = buildRadioButton(proxyGroup, - JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_noProxy, proxyButtonListener, 3); - - this.proxyRadioButton = buildRadioButton(proxyGroup, - JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_proxy, proxyButtonListener, 1); - this.proxyText = buildText(proxyGroup, 1); - new Label(proxyGroup, SWT.WRAP); //empty label for spacing - - this.proxyFileRadioButton = buildRadioButton(proxyGroup, - JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_proxyFile, proxyButtonListener, 1); - this.proxyFileText = buildText(proxyGroup, 1); - this.browseButton = this.buildBrowseButton(proxyGroup); - - this.noProxyRadioButton.setSelection(true); - this.proxyButtonChanged(); - } - - private Button buildBrowseButton(Composite parent) { - Composite buttonComposite = new Composite(parent, SWT.NULL); - GridLayout buttonLayout = new GridLayout(1, false); - buttonComposite.setLayout(buttonLayout); - GridData gridData = new GridData(); - gridData.horizontalAlignment = GridData.FILL; - gridData.verticalAlignment = GridData.BEGINNING; - buttonComposite.setLayoutData(gridData); - - // Browse buttons - Button browseButton = new Button(buttonComposite, SWT.PUSH); - browseButton.setText(JptJaxbUiMessages.ClassesGeneratorWizardPage_browseButton); - gridData = new GridData(); - gridData.horizontalAlignment= GridData.FILL; - gridData.grabExcessHorizontalSpace= true; - browseButton.setLayoutData(gridData); - - browseButton.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} - - public void widgetSelected(SelectionEvent e) { - - String filePath = promptProxyFile(); - if ( ! StringTools.stringIsEmpty(filePath)) { - ProxyOptionsComposite.this.proxyFileText.setText(makeRelativeToProjectPath(filePath)); - } - } - }); - return browseButton; - } - - // ********** listeners ********** - - private SelectionListener buildProxyRadioButtonListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - this.widgetSelected(event); - } - public void widgetSelected(SelectionEvent event) { - proxyButtonChanged(); - } - }; - } - - private void proxyButtonChanged() { - boolean usesProxy = ! this.noProxyRadioButton.getSelection(); - if (usesProxy) { - if (this.proxyRadioButton.getSelection()) { - this.proxyText.setEnabled(true); - disableText(this.proxyFileText); - this.browseButton.setEnabled(false); - } - else if (this.proxyFileRadioButton.getSelection()) { - this.proxyFileText.setEnabled(true); - this.browseButton.setEnabled(true); - disableText(this.proxyText); - } - } - else { - disableText(this.proxyText); - disableText(this.proxyFileText); - this.browseButton.setEnabled(false); - } - } - - // ********** internal methods ********** - /** - * The Add button was clicked, its action invokes this action which should - * prompt the user to select a file and return it. - */ - private String promptProxyFile() { - IWizard wizard = ClassesGeneratorOptionsWizardPage.this.getWizard(); - String projectPath = ((ClassesGeneratorWizard)wizard).getJavaProject().getProject().getLocation().toString(); - - FileDialog dialog = new FileDialog(getShell()); - dialog.setText(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_chooseAProxyFile); - dialog.setFilterPath(projectPath); - - return dialog.open(); - } - - // ********** intra-wizard methods ********** - - protected String getProxy() { - return this.proxyText.getText(); - } - - protected String getProxyFile() { - return this.proxyFileText.getText(); - } - } - - - // ********** Options1Composite ********** - - class Options1Composite { - - private boolean usesStrictValidation; - private final Button usesStrictValidationCheckBox; - - private boolean makesReadOnly; - private final Button makesReadOnlyCheckBox; - - private boolean suppressesPackageInfoGen; - private final Button suppressesPackageInfoGenCheckBox; - - private boolean suppressesHeaderGen; - private final Button suppressesHeaderGenCheckBox; - - private boolean target; - private final Button targetCheckBox; - - private boolean isVerbose; - private final Button isVerboseCheckBox; - - private boolean isQuiet; - private final Button isQuietCheckBox; - - // ********** constructor ********** - - Options1Composite(Composite parent) { - super(); - this.usesStrictValidation = true; - this.makesReadOnly = false; - this.suppressesPackageInfoGen = false; - this.suppressesHeaderGen = false; - this.target = false; - this.isVerbose = false; - this.isQuiet = false; - - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout()); - - this.usesStrictValidationCheckBox = this.buildUsesStrictValidationCheckBox(composite, this.buildUsesStrictValidationSelectionListener()); - this.makesReadOnlyCheckBox = this.buildMakesReadOnlyCheckBox(composite, this.buildMakesReadOnlySelectionListener()); - this.suppressesPackageInfoGenCheckBox = this.buildSuppressesPackageInfoGenCheckBox(composite, this.buildSuppressesPackageInfoGenSelectionListener()); - this.suppressesHeaderGenCheckBox = this.buildSuppressesHeaderGenCheckBox(composite, this.buildSuppressesHeaderGenSelectionListener()); - this.targetCheckBox = this.buildTargetCheckBox(composite, this.buildTargetSelectionListener()); - this.isVerboseCheckBox = this.buildIsVerboseCheckBox(composite, this.buildIsVerboseSelectionListener()); - this.isQuietCheckBox = this.buildIsQuietCheckBox(composite, this.buildIsQuietSelectionListener()); - } - - // ********** UI components ********** - - private Button buildUsesStrictValidationCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_useStrictValidation, listener, 5); - checkBox.setSelection(this.usesStrictValidation()); - return checkBox; - } - - private Button buildMakesReadOnlyCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_makeReadOnly, listener, 5); - checkBox.setSelection(this.makesReadOnly()); - return checkBox; - } - - private Button buildSuppressesPackageInfoGenCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_suppressPackageInfoGen, listener, 5); - checkBox.setSelection(this.suppressesPackageInfoGen()); - return checkBox; - } - - private Button buildSuppressesHeaderGenCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_suppressesHeaderGen, listener, 5); - checkBox.setSelection(this.suppressesHeaderGen()); - return checkBox; - } - - private Button buildTargetCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_target, listener, 5); - checkBox.setSelection(this.targetIs20()); - return checkBox; - } - - private Button buildIsVerboseCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_verbose, listener, 5); - checkBox.setSelection(this.isVerbose()); - return checkBox; - } - - private Button buildIsQuietCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_quiet, listener, 5); - checkBox.setSelection(this.isQuiet()); - return checkBox; - } - - // ********** listeners ********** - - private SelectionListener buildUsesStrictValidationSelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - this.widgetSelected(event); - } - public void widgetSelected(SelectionEvent event) { - Options1Composite.this.setUsesStrictValidation( - Options1Composite.this.usesStrictValidationCheckBox.getSelection()); - } - }; - } - - private SelectionListener buildMakesReadOnlySelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - this.widgetSelected(event); - } - public void widgetSelected(SelectionEvent event) { - Options1Composite.this.setMakesReadOnly( - Options1Composite.this.makesReadOnlyCheckBox.getSelection()); - } - }; - } - - private SelectionListener buildSuppressesPackageInfoGenSelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - this.widgetSelected(event); - } - public void widgetSelected(SelectionEvent event) { - Options1Composite.this.setSuppressesPackageInfoGen( - Options1Composite.this.suppressesPackageInfoGenCheckBox.getSelection()); - } - }; - } - - private SelectionListener buildSuppressesHeaderGenSelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - this.widgetSelected(event); - } - public void widgetSelected(SelectionEvent event) { - Options1Composite.this.setSuppressesHeaderGen( - Options1Composite.this.suppressesHeaderGenCheckBox.getSelection()); - } - }; - } - - private SelectionListener buildTargetSelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - this.widgetSelected(event); - } - public void widgetSelected(SelectionEvent event) { - Options1Composite.this.setTargetIs20( - Options1Composite.this.targetCheckBox.getSelection()); - } - }; - } - - private SelectionListener buildIsVerboseSelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - this.widgetSelected(event); - } - public void widgetSelected(SelectionEvent event) { - Options1Composite.this.setIsVerbose( - Options1Composite.this.isVerboseCheckBox.getSelection()); - } - }; - } - - private SelectionListener buildIsQuietSelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - this.widgetSelected(event); - } - public void widgetSelected(SelectionEvent event) { - Options1Composite.this.setIsQuiet( - Options1Composite.this.isQuietCheckBox.getSelection()); - } - }; - } - - // ********** getters/setters ********* - - protected boolean usesStrictValidation() { - return this.usesStrictValidation; - } - - protected void setUsesStrictValidation(boolean usesStrictValidation){ - this.usesStrictValidation = usesStrictValidation; - } - - protected boolean makesReadOnly() { - return this.makesReadOnly; - } - - protected void setMakesReadOnly(boolean makesReadOnly){ - this.makesReadOnly = makesReadOnly; - } - - protected boolean suppressesPackageInfoGen() { - return this.suppressesPackageInfoGen; - } - - protected void setSuppressesPackageInfoGen(boolean suppressesPackageInfoGen){ - this.suppressesPackageInfoGen = suppressesPackageInfoGen; - } - - protected boolean suppressesHeaderGen() { - return this.suppressesHeaderGen; - } - - protected void setSuppressesHeaderGen(boolean suppressesHeaderGen){ - this.suppressesHeaderGen = suppressesHeaderGen; - } - - protected boolean targetIs20() { - return this.target; - } - - protected void setTargetIs20(boolean targetIs20){ - this.target = targetIs20; - } - - protected boolean isVerbose() { - return this.isVerbose; - } - - protected void setIsVerbose(boolean isVerbose){ - this.isVerbose = isVerbose; - } - - protected boolean isQuiet() { - return this.isQuiet; - } - - protected void setIsQuiet(boolean isQuiet){ - this.isQuiet = isQuiet; - } - - } - - // ********** Options2Composite ********** - - class Options2Composite { - - private boolean treatsAsXmlSchema; - private final Button treatsAsXmlSchemaCheckBox; - - private boolean treatsAsRelaxNg; - private final Button treatsAsRelaxNgCheckBox; - - private boolean treatsAsRelaxNgCompact; - private final Button treatsAsRelaxNgCompactCheckBox; - - private boolean treatsAsDtd; - private final Button treatsAsDtdCheckBox; - - private boolean treatsAsWsdl; - private final Button treatsAsWsdlCheckBox; - - private boolean showsVersion; - private final Button showsVersionCheckBox; - - private boolean showsHelp; - private final Button showsHelpCheckBox; - - // ********** constructor ********** - - Options2Composite(Composite parent) { - super(); - this.treatsAsXmlSchema = false; - this.treatsAsRelaxNg = false; - this.treatsAsRelaxNgCompact = false; - this.treatsAsDtd = false; - this.treatsAsWsdl = false; - this.showsVersion = false; - this.showsHelp = false; - - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout()); - - this.treatsAsXmlSchemaCheckBox = this.buildTreatsAsXmlSchemaCheckBox(composite, this.buildTreatsAsXmlSchemaSelectionListener()); - this.treatsAsRelaxNgCheckBox = this.buildTreatsAsRelaxNgCheckBox(composite, this.buildTreatsAsRelaxNgSelectionListener()); - this.treatsAsRelaxNgCompactCheckBox = this.buildTreatsAsRelaxNgCompactCheckBox(composite, this.buildTreatsAsRelaxNgCompactSelectionListener()); - this.treatsAsDtdCheckBox = this.buildTreatsAsDtdCheckBox(composite, this.buildTreatsAsDtdSelectionListener()); - this.treatsAsWsdlCheckBox = this.buildTreatsAsWsdlCheckBox(composite, this.buildTreatsAsWsdlSelectionListener()); - this.showsVersionCheckBox = this.buildVersionCheckBox(composite, this.buildVersionSelectionListener()); - this.showsHelpCheckBox = this.buildHelpCheckBox(composite, this.buildHelpSelectionListener()); - } - - // ********** UI components ********** - - private Button buildTreatsAsXmlSchemaCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_treatsAsXmlSchema, listener, 5); - checkBox.setSelection(this.treatsAsXmlSchema()); - return checkBox; - } - - private Button buildTreatsAsRelaxNgCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_treatsAsRelaxNg, listener, 5); - checkBox.setSelection(this.treatsAsRelaxNg()); - return checkBox; - } - private Button buildTreatsAsRelaxNgCompactCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_treatsAsRelaxNgCompact, listener, 5); - checkBox.setSelection(this.treatsAsRelaxNgCompact()); - return checkBox; - } - - private Button buildTreatsAsDtdCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_treatsAsDtd, listener, 5); - checkBox.setSelection(this.treatsAsDtd()); - return checkBox; - } - - private Button buildTreatsAsWsdlCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_treatsAsWsdl, listener, 5); - checkBox.setSelection(this.treatsAsWsdl()); - return checkBox; - } - - private Button buildVersionCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_showsVersion, listener, 5); - checkBox.setSelection(this.showsVersion()); - return checkBox; - } - - private Button buildHelpCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_showsHelp, listener, 5); - checkBox.setSelection(this.showsHelp()); - return checkBox; - } - - // ********** listeners ********** - - private SelectionListener buildTreatsAsXmlSchemaSelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - this.widgetSelected(event); - } - public void widgetSelected(SelectionEvent event) { - Options2Composite.this.setTreatsAsXmlSchema( - Options2Composite.this.treatsAsXmlSchemaCheckBox.getSelection()); - } - }; - } - - private SelectionListener buildTreatsAsRelaxNgSelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - this.widgetSelected(event); - } - public void widgetSelected(SelectionEvent event) { - Options2Composite.this.setTreatsAsRelaxNg( - Options2Composite.this.treatsAsRelaxNgCheckBox.getSelection()); - } - }; - } - - private SelectionListener buildTreatsAsRelaxNgCompactSelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - this.widgetSelected(event); - } - public void widgetSelected(SelectionEvent event) { - Options2Composite.this.setTreatsAsRelaxNgCompact( - Options2Composite.this.treatsAsRelaxNgCompactCheckBox.getSelection()); - } - }; - } - - private SelectionListener buildTreatsAsDtdSelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - this.widgetSelected(event); - } - public void widgetSelected(SelectionEvent event) { - Options2Composite.this.setTreatsAsDtd( - Options2Composite.this.treatsAsDtdCheckBox.getSelection()); - } - }; - } - - private SelectionListener buildTreatsAsWsdlSelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - this.widgetSelected(event); - } - public void widgetSelected(SelectionEvent event) { - Options2Composite.this.setTreatsAsWsdl( - Options2Composite.this.treatsAsWsdlCheckBox.getSelection()); - } - }; - } - - private SelectionListener buildVersionSelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - this.widgetSelected(event); - } - public void widgetSelected(SelectionEvent event) { - Options2Composite.this.setShowsVersion( - Options2Composite.this.showsVersionCheckBox.getSelection()); - } - }; - } - - private SelectionListener buildHelpSelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - this.widgetSelected(event); - } - public void widgetSelected(SelectionEvent event) { - Options2Composite.this.setShowsHelp( - Options2Composite.this.showsHelpCheckBox.getSelection()); - } - }; - } - - // ********** getter/setter ********* - - protected boolean treatsAsXmlSchema() { - return this.treatsAsXmlSchema; - } - - protected void setTreatsAsXmlSchema(boolean treatsAsXmlSchema){ - this.treatsAsXmlSchema = treatsAsXmlSchema; - } - - protected boolean treatsAsRelaxNg() { - return this.treatsAsRelaxNg; - } - - protected void setTreatsAsRelaxNg(boolean treatsAsRelaxNg){ - this.treatsAsRelaxNg = treatsAsRelaxNg; - } - - protected boolean treatsAsRelaxNgCompact() { - return this.treatsAsRelaxNgCompact; - } - - protected void setTreatsAsRelaxNgCompact(boolean treatsAsRelaxNgCompact){ - this.treatsAsRelaxNgCompact = treatsAsRelaxNgCompact; - } - - protected boolean treatsAsDtd() { - return this.treatsAsDtd; - } - - protected void setTreatsAsDtd(boolean treatsAsDtd){ - this.treatsAsDtd = treatsAsDtd; - } - - protected boolean treatsAsWsdl() { - return this.treatsAsWsdl; - } - - protected void setTreatsAsWsdl(boolean treatsAsWsdl){ - this.treatsAsWsdl = treatsAsWsdl; - } - - protected boolean showsVersion() { - return this.showsVersion; - } - - protected void setShowsVersion(boolean showsVersion){ - this.showsVersion = showsVersion; - } - - protected boolean showsHelp() { - return this.showsHelp; - } - - protected void setShowsHelp(boolean showsHelp){ - this.showsHelp = showsHelp; - } - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizard.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizard.java deleted file mode 100644 index 5970a90004..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizard.java +++ /dev/null @@ -1,358 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2010, 2011 Oracle. 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: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.wizards.classesgen; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.WorkspaceJob; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.jpt.common.ui.internal.wizards.JavaProjectWizardPage; -import org.eclipse.jpt.jaxb.core.internal.gen.ClassesGeneratorExtensionOptions; -import org.eclipse.jpt.jaxb.core.internal.gen.ClassesGeneratorOptions; -import org.eclipse.jpt.jaxb.core.internal.gen.GenerateJaxbClassesJob; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; -import org.eclipse.osgi.util.NLS; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWizard; - -/** - * ClassesGeneratorWizard - */ -public class ClassesGeneratorWizard extends Wizard implements IWorkbenchWizard { - - private IJavaProject javaProject; - private String schemaPathOrUri; - protected IStructuredSelection selection; - - private String destinationFolder; - private String targetPackage; - private String catalog; - private boolean usesMoxy; - private String[] bindingsFileNames; - private ClassesGeneratorOptions generatorOptions; - private ClassesGeneratorExtensionOptions generatorExtensionOptions; - - private JavaProjectWizardPage projectWizardPage; - private SchemaWizardPage schemaWizardPage; - - private ClassesGeneratorWizardPage settingsPage; - private ClassesGeneratorOptionsWizardPage optionsPage; - private ClassesGeneratorExtensionOptionsWizardPage extensionOptionsPage; - private boolean performsGeneration; - - // ********** constructor ********** - - public ClassesGeneratorWizard() { - super(); - this.performsGeneration = true; - } - - public ClassesGeneratorWizard(IJavaProject javaProject, String xsdSchemaPath) { - super(); - this.javaProject = javaProject; - this.schemaPathOrUri = xsdSchemaPath; - - this.performsGeneration = false; - } - - // ********** IWorkbenchWizard implementation ********** - - public void init(IWorkbench workbench, IStructuredSelection selection) { - this.selection = selection; - - this.setWindowTitle(JptJaxbUiMessages.ClassesGeneratorWizard_title); - this.setDefaultPageImageDescriptor(JptJaxbUiPlugin.getImageDescriptor(JptJaxbUiIcons.CLASSES_GEN_WIZ_BANNER)); - this.setNeedsProgressMonitor(true); - } - - // ********** IWizard implementation ********** - - @Override - public void addPages() { - super.addPages(); - - if(this.selection != null) { - this.javaProject = this.getJavaProjectFromSelection(this.selection); - - this.projectWizardPage = new JavaProjectWizardPage(this.javaProject); - this.projectWizardPage.setTitle(JptJaxbUiMessages.ClassesGeneratorProjectWizardPage_title); - this.projectWizardPage.setDescription(JptJaxbUiMessages.ClassesGeneratorProjectWizardPage_desc); - this.projectWizardPage.setDestinationLabel(JptJaxbUiMessages.JavaProjectWizardPage_destinationProject); - this.addPage(this.projectWizardPage); - - // SchemaWizardPage - IFile schemaSelected = SchemaWizardPage.getSourceSchemaFromSelection(this.selection); - if(schemaSelected == null) { - this.schemaWizardPage = new SchemaWizardPage(this.selection); - this.addPage(this.schemaWizardPage); - } - else { - this.schemaPathOrUri = this.makeRelativeToProjectPath(schemaSelected.getFullPath()); - } - } - this.settingsPage = this.buildClassesGeneratorPage(); - this.optionsPage = this.buildClassesGeneratorOptionsPage(); - this.extensionOptionsPage = this.buildExtensionOptionsPage(); - - this.addPage(this.settingsPage); - this.addPage(this.optionsPage); - this.addPage(this.extensionOptionsPage); - } - - @Override - public boolean performFinish() { - - WizardPage currentPage = (WizardPage)getContainer().getCurrentPage(); - if(currentPage != null) { - if( ! currentPage.isPageComplete()) { - return false; - } - this.retrieveGeneratorSettings(); - this.retrieveGeneratorOptions(); - this.retrieveGeneratorExtensionOptions(); - - IFolder folder = this.getJavaProject().getProject().getFolder(this.destinationFolder); - this.createFolderIfNotExist(folder); - } - - if(this.performsGeneration) { - if(this.displayOverridingClassesWarning(this.generatorOptions)) { - this.generateJaxbClasses(); - } - } - - return true; - } - - @Override - public boolean canFinish() { - return (this.settingsPage.isPageComplete() && - this.optionsPage.isPageComplete() && - this.extensionOptionsPage.isPageComplete()); - } - - // ********** intra-wizard methods ********** - - public IJavaProject getJavaProject() { - if(this.projectWizardPage != null) { - this.javaProject = this.projectWizardPage.getJavaProject(); - } - return this.javaProject; - } - - public String getSchemaPathOrUri() { - if(this.schemaWizardPage != null) { - IFile schemaFile = this.schemaWizardPage.getSourceSchema(); - if(schemaFile != null) { - return this.makeRelativeToProjectPath(schemaFile.getFullPath()); - } - else { - return this.schemaWizardPage.getSourceURI(); - } - } - return this.schemaPathOrUri; - } - - private String makeRelativeToProjectPath(IPath path) { - IPath relativePath = path.makeRelativeTo(this.getJavaProject().getProject().getFullPath()); - return relativePath.toOSString(); - } - - // ********** public methods ********** - - public String getDestinationFolder() { - return this.destinationFolder; - } - - public String getTargetPackage() { - return this.targetPackage; - } - - public String getCatalog() { - return this.catalog; - } - - public boolean usesMoxy() { - return this.usesMoxy; - } - - public String[] getBindingsFileNames() { - return this.bindingsFileNames; - } - - public ClassesGeneratorOptions getGeneratorOptions() { - return this.generatorOptions; - } - - public ClassesGeneratorExtensionOptions getGeneratorExtensionOptions() { - return this.generatorExtensionOptions; - } - - // ********** internal methods ********** - - public IJavaProject getJavaProjectFromSelection(IStructuredSelection selection) { - if(selection == null) { - return null; - } - Object firstElement = selection.getFirstElement(); - if(firstElement instanceof IJavaProject) { - return (IJavaProject)firstElement; - } - else if(firstElement instanceof IResource) { - IProject project = ((IResource) firstElement).getProject(); - return getJavaProjectFrom(project); - } - else if(firstElement instanceof IJavaElement) { - return ((IJavaElement)firstElement).getJavaProject(); - } - return null; - } - - public IJavaProject getJavaProjectFrom(IProject project) { - return (IJavaProject)((IJavaElement)((IAdaptable)project).getAdapter(IJavaElement.class)); - } - - private boolean displayOverridingClassesWarning(ClassesGeneratorOptions generatorOptions) { - - if( ! this.isOverridingClasses(generatorOptions)) { - return true; - } - return MessageDialog.openQuestion( - this.getShell(), - JptJaxbUiMessages.ClassesGeneratorUi_generatingClassesWarningTitle, - JptJaxbUiMessages.ClassesGeneratorUi_generatingClassesWarningMessage); - } - - private boolean isOverridingClasses(ClassesGeneratorOptions generatorOptions) { - if(generatorOptions == null) { - throw new NullPointerException(); - } - if(generatorOptions.showsVersion() || generatorOptions.showsHelp()) { - return false; - } - return true; - } - - private void generateJaxbClasses() { - try { - WorkspaceJob job = new GenerateJaxbClassesJob( - this.getJavaProject(), - this.getSchemaPathOrUri(), - this.destinationFolder, - this.targetPackage, - this.catalog, - this.usesMoxy, - this.bindingsFileNames, - this.generatorOptions, - this.generatorExtensionOptions); - job.schedule(); - } - catch(RuntimeException re) { - JptJaxbUiPlugin.log(re); - - String msg = re.getMessage(); - String message = (msg == null) ? re.toString() : msg; - this.logError(message); - } - } - - private void retrieveGeneratorSettings() { - this.destinationFolder = this.settingsPage.getTargetFolder(); - this.targetPackage = this.settingsPage.getTargetPackage(); - this.catalog = this.settingsPage.getCatalog(); - this.usesMoxy = this.settingsPage.usesMoxy(); - this.bindingsFileNames = this.settingsPage.getBindingsFileNames(); - } - - private void retrieveGeneratorOptions() { - this.generatorOptions = new ClassesGeneratorOptions(); - - this.generatorOptions.setProxy(this.optionsPage.getProxy()); - this.generatorOptions.setProxyFile(this.optionsPage.getProxyFile()); - - this.generatorOptions.setUsesStrictValidation(this.optionsPage.usesStrictValidation()); - this.generatorOptions.setMakesReadOnly(this.optionsPage.makesReadOnly()); - this.generatorOptions.setSuppressesPackageInfoGen(this.optionsPage.suppressesPackageInfoGen()); - this.generatorOptions.setSuppressesHeaderGen(this.optionsPage.suppressesHeaderGen()); - this.generatorOptions.setTargetIs20(this.optionsPage.getTarget()); - this.generatorOptions.setIsVerbose(this.optionsPage.isVerbose()); - this.generatorOptions.setIsQuiet(this.optionsPage.isQuiet()); - - this.generatorOptions.setTreatsAsXmlSchema(this.optionsPage.treatsAsXmlSchema()); - this.generatorOptions.setTreatsAsRelaxNg(this.optionsPage.treatsAsRelaxNg()); - this.generatorOptions.setTreatsAsRelaxNgCompact(this.optionsPage.treatsAsRelaxNgCompact()); - this.generatorOptions.setTreatsAsDtd(this.optionsPage.treatsAsDtd()); - this.generatorOptions.setTreatsAsWsdl(this.optionsPage.treatsAsWsdl()); - this.generatorOptions.setShowsVersion(this.optionsPage.showsVersion()); - this.generatorOptions.setShowsHelp(this.optionsPage.showsHelp()); - } - - private void retrieveGeneratorExtensionOptions() { - - this.generatorExtensionOptions = new ClassesGeneratorExtensionOptions(); - - this.generatorExtensionOptions.setAllowsExtensions(this.extensionOptionsPage.allowsExtensions()); - this.generatorExtensionOptions.setClasspath(this.extensionOptionsPage.getClasspath()); - this.generatorExtensionOptions.setAdditionalArgs(this.extensionOptionsPage.getAdditionalArgs()); - } - - private ClassesGeneratorWizardPage buildClassesGeneratorPage() { - - return new ClassesGeneratorWizardPage(); - } - - private ClassesGeneratorOptionsWizardPage buildClassesGeneratorOptionsPage() { - return new ClassesGeneratorOptionsWizardPage(); - } - - private ClassesGeneratorExtensionOptionsWizardPage buildExtensionOptionsPage() { - return new ClassesGeneratorExtensionOptionsWizardPage(); - } - - private void createFolderIfNotExist(IFolder folder) { - if( folder.exists()) { - return; - } - try { - folder.create(true, true, null); - } - catch (CoreException e) { - JptJaxbUiPlugin.log(e); - - this.logError(NLS.bind( - JptJaxbUiMessages.ClassesGeneratorWizard_couldNotCreate, - folder.getProjectRelativePath().toOSString())); - } - } - - protected void logError(String message) { - this.displayError(message); - } - - private void displayError(String message) { - MessageDialog.openError( - this.getShell(), - JptJaxbUiMessages.ClassesGeneratorWizard_errorDialogTitle, - message - ); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizardPage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizardPage.java deleted file mode 100644 index d1676f5c21..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizardPage.java +++ /dev/null @@ -1,643 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2010 Oracle. 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: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.wizards.classesgen; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.core.IJavaModel; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.internal.ui.wizards.TypedElementSelectionValidator; -import org.eclipse.jdt.internal.ui.wizards.TypedViewerFilter; -import org.eclipse.jdt.ui.JavaElementComparator; -import org.eclipse.jdt.ui.JavaElementLabelProvider; -import org.eclipse.jdt.ui.StandardJavaElementContentProvider; -import org.eclipse.jdt.ui.wizards.NewTypeWizardPage; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.IBaseLabelProvider; -import org.eclipse.jface.viewers.IContentProvider; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jface.window.Window; -import org.eclipse.jpt.common.ui.internal.util.SWTUtil; -import org.eclipse.jpt.common.ui.internal.util.TableLayoutComposite; -import org.eclipse.jpt.common.utility.internal.ArrayTools; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.jaxb.core.internal.gen.ClassesGenerator; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; -import org.osgi.framework.Bundle; - -/** - * ClassesGeneratorWizardPage - */ -public class ClassesGeneratorWizardPage extends NewTypeWizardPage { - static public String JPT_ECLIPSELINK_UI_PLUGIN_ID = "org.eclipse.jpt.jpa.eclipselink.ui"; //$NON-NLS-1$ - static public String XML_FILTER = "*.xml"; //$NON-NLS-1$ - static public String BINDINGS_FILE_FILTER = "*.xjb;*.xml;*.xbd"; //$NON-NLS-1$ - - public static final String HELP_CONTEXT_ID = "org.eclipse.jpt.ui.configure_jaxb_class_generation_dialog"; //$NON-NLS-1$ - - private SettingsGroup settingsGroup; - - private String targetFolder; - private String targetPackage; - - private Button usesMoxyCheckBox; - private boolean usesMoxy; - - // ********** constructor ********** - - public ClassesGeneratorWizardPage() { - super(true, "Classes Generator"); //$NON-NLS-1$ - - this.setDescription(JptJaxbUiMessages.ClassesGeneratorWizardPage_desc); - } - - // ********** UI components ********** - - public void createControl(Composite parent) { - this.setPageComplete(false); - this.setControl(this.buildTopLevelControl(parent)); - } - - // ********** intra-wizard methods ********** - - protected String getTargetFolder() { - return this.targetFolder; - } - - protected String getTargetPackage() { - return this.targetPackage; - } - - protected String getCatalog() { - return this.settingsGroup.getCatalog(); - } - - protected String[] getBindingsFileNames() { - return this.settingsGroup.getBindingsFileNames(); - } - - protected boolean usesMoxy() { - return this.usesMoxy; - } - - protected void setUsesMoxy(boolean usesMoxy){ - this.usesMoxy = usesMoxy; - } - - // ********** internal methods ********** - - private Control buildTopLevelControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout()); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, HELP_CONTEXT_ID); - - this.settingsGroup = new SettingsGroup(composite); - - this.usesMoxyCheckBox = this.buildUsesMoxyCheckBox(composite); - - Dialog.applyDialogFont(parent); - return composite; - } - - private Button buildUsesMoxyCheckBox(Composite parent) { - - Button checkBox = new Button(parent, SWT.CHECK); - GridData gridData = new GridData(); - gridData.verticalIndent = 10; - checkBox.setLayoutData(gridData); - checkBox.setText(JptJaxbUiMessages.ClassesGeneratorWizardPage_usesMoxyImplementation); - checkBox.setSelection(this.usesMoxy()); - checkBox.addSelectionListener(this.buildUsesMoxySelectionListener()); - - return checkBox; - } - - private SelectionListener buildUsesMoxySelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - this.widgetSelected(event); - } - - public void widgetSelected(SelectionEvent event) { - setUsesMoxy(usesMoxyCheckBox.getSelection()); - validateProjectClasspath(); - } - }; - } - - private boolean jptEclipseLinkBundleExists() { - return (this.getJptEclipseLinkBundle() != null); - } - - private Bundle getJptEclipseLinkBundle() { - return Platform.getBundle(JPT_ECLIPSELINK_UI_PLUGIN_ID); // Cannot reference directly EL plugin. - } - - private void validateProjectClasspath() { - //this line will suppress the "default package" warning (which doesn't really apply here - //as the JAXB gen uses an org.example.schemaName package by default) and will clear the classpath warnings when necessary - setMessage(null); - - if ( ! this.genericJaxbIsOnClasspath()) { - this.displayWarning(JptJaxbUiMessages.ClassesGeneratorWizardPage_jaxbLibrariesNotAvailable); - } - else if (this.usesMoxy() && ! this.moxyIsOnClasspath()) { - //this message is being truncated by the wizard width in some cases - this.displayWarning(JptJaxbUiMessages.ClassesGeneratorWizardPage_moxyLibrariesNotAvailable); - } - - //this code will intelligently remove our classpath warnings when they are present but no longer apply (as an alternative - //to setting the message to null continuously as is currently done) -// else if( this.getMessage() != null){ -// if (this.getMessage().equals(JptJaxbUiMessages.ClassesGeneratorWizardPage_jaxbLibrariesNotAvailable) || -// this.getMessage().equals(JptJaxbUiMessages.ClassesGeneratorWizardPage_moxyLibrariesNotAvailable)) { -// setMessage(null); -// } -// } - } - - private void displayWarning(String message) { - this.setMessage(message, WARNING); - } - - /** - * Test if the Jaxb compiler is on the classpath. - */ - private boolean genericJaxbIsOnClasspath() { - try { - String className = ClassesGenerator.JAXB_GENERIC_GEN_CLASS; - IType genClass = this.getJavaProject().findType(className); - return (genClass != null); - } - catch (JavaModelException e) { - throw new RuntimeException(e); - } - } - - /** - * Test if the EclipseLink Jaxb compiler is on the classpath. - */ - private boolean moxyIsOnClasspath() { - try { - String className = ClassesGenerator.JAXB_ECLIPSELINK_GEN_CLASS; - IType genClass = this.getJavaProject().findType(className); - return (genClass != null); - } - catch (JavaModelException e) { - throw new RuntimeException(e); - } - } - - // ********** overrides ********** - - @Override - protected IStatus packageChanged() { - IStatus status = super.packageChanged(); - IPackageFragment packageFragment = getPackageFragment(); - if (!status.matches(IStatus.ERROR)) { - this.targetPackage = packageFragment.getElementName(); - } - return status; - } - - @Override - protected IStatus containerChanged() { - IStatus status = super.containerChanged(); - String srcFolder = getPackageFragmentRootText(); - if( !status.matches(IStatus.ERROR) ){ - this.targetFolder = srcFolder.substring(srcFolder.indexOf("/") + 1); - } - return status; - } - - @Override - protected void handleFieldChanged(String fieldName) { - super.handleFieldChanged(fieldName); - if (this.fContainerStatus.matches(IStatus.ERROR)) { - updateStatus(fContainerStatus); - }else if( ! this.fPackageStatus.matches(IStatus.OK) ) { - updateStatus(fPackageStatus); - } else { - updateStatus(Status.OK_STATUS); - } - validateProjectClasspath(); - } - - /** - * Override setVisible to insure that our more important warning - * message about classpath problems is displayed to the user first. - */ - @Override - public void setVisible(boolean visible) { - super.setVisible(visible); - if(visible) { - this.initContainerPage(((ClassesGeneratorWizard)this.getWizard()).getJavaProject()); - - // default usesMoxy to true only when JPT EclipseLink bundle exists and MOXy is on the classpath - this.usesMoxy = (this.jptEclipseLinkBundleExists() && this.moxyIsOnClasspath()); - - // checkbox is visible only if jpt.eclipselink.ui plugin is available - // and EclipseLink MOXy is not on the classpath - this.usesMoxyCheckBox.setVisible(this.jptEclipseLinkBundleExists() && ! this.moxyIsOnClasspath()); - this.validateProjectClasspath(); - - String schemaPathOrUri = ((ClassesGeneratorWizard)this.getWizard()).getSchemaPathOrUri(); - this.setTitle(NLS.bind(JptJaxbUiMessages.ClassesGeneratorWizardPage_title, schemaPathOrUri)); - } - } - - /** - * Override to allow selection of source folder in current project only - * @see org.eclipse.jdt.ui.wizards.NewContainerWizardPage#chooseContainer() - * Only 1 line in this code is different from the parent - */ - @Override - protected IPackageFragmentRoot chooseContainer() { - Class<?>[] acceptedClasses = new Class[] { IPackageFragmentRoot.class, IJavaProject.class }; - TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, false) { - @Override - public boolean isSelectedValid(Object element) { - try { - if (element instanceof IJavaProject) { - IJavaProject jproject= (IJavaProject)element; - IPath path= jproject.getProject().getFullPath(); - return (jproject.findPackageFragmentRoot(path) != null); - } else if (element instanceof IPackageFragmentRoot) { - return (((IPackageFragmentRoot)element).getKind() == IPackageFragmentRoot.K_SOURCE); - } - return true; - } catch (JavaModelException e) { - JptJaxbUiPlugin.log(e); // just log, no UI in validation - } - return false; - } - }; - - acceptedClasses= new Class[] { IJavaModel.class, IPackageFragmentRoot.class, IJavaProject.class }; - ViewerFilter filter= new TypedViewerFilter(acceptedClasses) { - @Override - public boolean select(Viewer viewer, Object parent, Object element) { - if (element instanceof IPackageFragmentRoot) { - try { - return (((IPackageFragmentRoot)element).getKind() == IPackageFragmentRoot.K_SOURCE); - } catch (JavaModelException e) { - JptJaxbUiPlugin.log(e.getStatus()); // just log, no UI in validation - return false; - } - } - return super.select(viewer, parent, element); - } - }; - - StandardJavaElementContentProvider provider= new StandardJavaElementContentProvider(); - ILabelProvider labelProvider= new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT); - ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), labelProvider, provider); - dialog.setValidator(validator); - dialog.setComparator(new JavaElementComparator()); - dialog.setTitle(JptJaxbUiMessages.ClassesGeneratorWizardPage_sourceFolderSelectionDialog_title); - dialog.setMessage(JptJaxbUiMessages.ClassesGeneratorWizardPage_chooseSourceFolderDialog_desc); - dialog.addFilter(filter); - //set the java project as the input instead of the workspace like the NewContainerWizardPage was doing - //******************************************************// - dialog.setInput(this.getJavaProject()); // - //******************************************************// - dialog.setInitialSelection(getPackageFragmentRoot()); - dialog.setHelpAvailable(false); - - if (dialog.open() == Window.OK) { - Object element= dialog.getFirstResult(); - if (element instanceof IJavaProject) { - IJavaProject jproject= (IJavaProject)element; - return jproject.getPackageFragmentRoot(jproject.getProject()); - } else if (element instanceof IPackageFragmentRoot) { - return (IPackageFragmentRoot)element; - } - return null; - } - return null; - } - - // ********** SettingsGroup class ********** - - private class SettingsGroup { - - private final Text catalogText; - - private final ArrayList<String> bindingsFileNames; - - // ********** constructor ********** - - private SettingsGroup(Composite parent) { - super(); - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(4, false); //must be 4 for the package controls - layout.marginHeight = 0; - layout.marginWidth = 0; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - // TODO PlatformUI.getWorkbench().getHelpSystem().setHelp(this.group, HELP_CONTEXT_ID); - - // Source folder - createContainerControls(composite, 4); - - // Package - createPackageControls(composite, 4); - - Label label = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL); - GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false, 4, 1); - gridData.verticalIndent = 5; - label.setLayoutData(gridData); - - // Catalog - Label catalogLabel = new Label(composite, SWT.NONE); - catalogLabel.setText(JptJaxbUiMessages.ClassesGeneratorWizardPage_catalog); - gridData = new GridData(); - gridData.verticalIndent = 5; - catalogLabel.setLayoutData(gridData); - this.catalogText = this.buildCatalogText(composite); - this.buildBrowseButton(composite); - - // Bindings files - this.bindingsFileNames = new ArrayList<String>(); - Label bindingsFileLabel = new Label(composite, SWT.NONE); - bindingsFileLabel.setText(JptJaxbUiMessages.ClassesGeneratorWizardPage_bindingsFiles); - bindingsFileLabel.setLayoutData(new GridData()); - this.buildBindingsFileTable(composite); - } - - // ********** intra-wizard methods ********** - - protected String getCatalog() { - return this.catalogText.getText(); - } - - protected String[] getBindingsFileNames() { - return ArrayTools.array(this.bindingsFileNames.iterator(), new String[0]); - } - - // ********** UI components ********** - - private Text buildCatalogText(Composite parent) { - Text text = new Text(parent, SWT.BORDER); - GridData gridData = new GridData(GridData.FILL_HORIZONTAL); - gridData.horizontalSpan = 2; - gridData.verticalIndent = 5; - text.setLayoutData(gridData); - return text; - } - - private void buildBrowseButton(Composite parent) { - - Composite buttonComposite = new Composite(parent, SWT.NULL); - GridLayout buttonLayout = new GridLayout(1, false); - buttonComposite.setLayout(buttonLayout); - GridData gridData = new GridData(); - gridData.horizontalAlignment = GridData.FILL; - gridData.verticalAlignment = GridData.BEGINNING; - buttonComposite.setLayoutData(gridData); - - // Browse buttons - Button browseButton = new Button(buttonComposite, SWT.PUSH); - browseButton.setText(JptJaxbUiMessages.ClassesGeneratorWizardPage_browseButton); - gridData = new GridData(); - gridData.horizontalAlignment= GridData.FILL; - gridData.verticalIndent = 5; - gridData.grabExcessHorizontalSpace= true; - browseButton.setLayoutData(gridData); - - browseButton.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} - - public void widgetSelected(SelectionEvent e) { - - String filePath = promptXmlFile(); - if( ! StringTools.stringIsEmpty(filePath)) { - - catalogText.setText(makeRelativeToProjectPath(filePath)); - } - } - }); - } - - private TableViewer buildBindingsFileTable(Composite parent) { - - TableViewer tableViewer = this.buildTableViewer(parent, this.bindingsFileNames); - - this.buildAddRemoveButtons(parent, tableViewer, this.bindingsFileNames); - return tableViewer; - } - - private TableViewer buildTableViewer(Composite parent, ArrayList<String> tableDataModel) { - - TableLayoutComposite tableLayout = new TableLayoutComposite(parent, SWT.NONE); - this.addColumnsData(tableLayout); - - final Table table = new Table(tableLayout, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER); - table.setLinesVisible(false); - - TableColumn column = new TableColumn(table, SWT.NONE, 0); - column.setResizable(true); - - GridData gridData= new GridData(GridData.FILL_BOTH); - gridData.horizontalSpan = 2; - gridData.heightHint= SWTUtil.getTableHeightHint(table, 3); - tableLayout.setLayoutData(gridData); - - TableViewer tableViewer = new TableViewer(table); - tableViewer.setUseHashlookup(true); - tableViewer.setLabelProvider(this.buildLabelProvider()); - tableViewer.setContentProvider(this.buildContentProvider()); - - tableViewer.setInput(tableDataModel); - return tableViewer; - } - - private void buildAddRemoveButtons(Composite parent, final TableViewer tableViewer, final ArrayList<String> tableDataModel) { - - Composite buttonComposite = new Composite(parent, SWT.NULL); - GridLayout buttonLayout = new GridLayout(1, false); - buttonComposite.setLayout(buttonLayout); - GridData gridData = new GridData(); - gridData.horizontalAlignment = GridData.FILL; - gridData.verticalAlignment = GridData.BEGINNING; - buttonComposite.setLayoutData(gridData); - // Add buttons - Button addButton = new Button(buttonComposite, SWT.PUSH); - addButton.setText(JptJaxbUiMessages.ClassesGeneratorWizardPage_addButton); - gridData = new GridData(); - gridData.horizontalAlignment = GridData.FILL; - gridData.grabExcessHorizontalSpace= true; - addButton.setLayoutData(gridData); - addButton.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} - - public void widgetSelected(SelectionEvent e) { - - ArrayList<String> filePaths = promptBindingsFiles(); - for(String filePath : filePaths) { - addBindingsFile(filePath, tableDataModel); - } - tableViewer.refresh(); - } - }); - // Remove buttons - Button removeButton = new Button(buttonComposite, SWT.PUSH); - removeButton.setText(JptJaxbUiMessages.ClassesGeneratorWizardPage_removeButton); - gridData = new GridData(); - gridData.horizontalAlignment = GridData.FILL; - gridData.grabExcessHorizontalSpace= true; - removeButton.setLayoutData(gridData); - removeButton.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} - - public void widgetSelected(SelectionEvent e) { - StructuredSelection selection = (StructuredSelection)tableViewer.getSelection(); - if(selection.isEmpty()) { - return; - } - String bindingsFileName = (String)selection.getFirstElement(); - removeBindingsFile(bindingsFileName); - - tableViewer.refresh(); - } - }); - addButton.setFocus(); - } - - // ********** internal methods ********** - - private String makeRelativeToProjectPath(String filePath) { - Path path = new Path(filePath); - IPath relativePath = path.makeRelativeTo(getJavaProject().getProject().getLocation()); - return relativePath.toOSString(); - } - - private void addBindingsFile(String filePath, final ArrayList<String> tableDataModel) { - String relativePath = this.makeRelativeToProjectPath(filePath); - if( ! tableDataModel.contains(relativePath)) { - tableDataModel.add(relativePath); - } - } - - private void removeBindingsFile(String bindingsName) { - this.bindingsFileNames.remove(bindingsName); - } - - private IBaseLabelProvider buildLabelProvider() { - return new TableLabelProvider(); - } - - private IContentProvider buildContentProvider() { - return new TableContentProvider(); - } - - /** - * The Add button was clicked, its action invokes this action which should - * prompt the user to select a file and return it. - */ - private String promptXmlFile() { - String projectPath= getJavaProject().getProject().getLocation().toString(); - - FileDialog dialog = new FileDialog(getShell()); - dialog.setText(JptJaxbUiMessages.ClassesGeneratorWizardPage_chooseACatalog); - dialog.setFilterPath(projectPath); - dialog.setFilterExtensions(new String[] {XML_FILTER}); - - return dialog.open(); - } - - private ArrayList<String> promptBindingsFiles() { - String projectPath= getJavaProject().getProject().getLocation().toString(); - - FileDialog dialog = new FileDialog(getShell(), SWT.MULTI); - dialog.setText(JptJaxbUiMessages.ClassesGeneratorWizardPage_chooseABindingsFile); - dialog.setFilterPath(projectPath); - dialog.setFilterExtensions(new String[] {BINDINGS_FILE_FILTER}); - - dialog.open(); - String path = dialog.getFilterPath(); - String[] fileNames = dialog.getFileNames(); - ArrayList<String> results = new ArrayList<String>(fileNames.length); - for(String fileName : fileNames) { - results.add(path + File.separator + fileName); - } - return results; - } - - private void addColumnsData(TableLayoutComposite layout) { - layout.addColumnData(new ColumnWeightData(50, true)); - } - - } - - // ********** inner class ********** - private class TableLabelProvider extends LabelProvider implements ITableLabelProvider { - - public Image getColumnImage(Object element, int columnIndex) { - return null; - } - - public String getColumnText(Object element, int columnIndex) { - return (String)element; - } - } - - private class TableContentProvider implements IStructuredContentProvider { - - TableContentProvider() { - super(); - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} - - public void dispose() {} - - public Object[] getElements(Object inputElement) { - return ((Collection<?>) inputElement).toArray(); - } - } -}
\ No newline at end of file diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/SchemaWizardPage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/SchemaWizardPage.java deleted file mode 100644 index 57db24a58d..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/SchemaWizardPage.java +++ /dev/null @@ -1,190 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2010, 2011 Oracle. 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: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.wizards.classesgen; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.jpt.common.ui.internal.wizards.JavaProjectWizardPage; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.common.uriresolver.internal.util.URIHelper; - -/** - * SchemaWizardPage - */ -public class SchemaWizardPage extends WizardPage { - - private final IStructuredSelection initialSelection; - private IProject targetProject; - - protected SelectFileOrXMLCatalogIdPanel selectSourcePanel; - - protected static final String[] browseXSDFilterExtensions = {".xsd"}; //$NON-NLS-1$ - - // ********** static method ********** - - public static IFile getSourceSchemaFromSelection(IStructuredSelection selection) { - Object firstElement = selection.getFirstElement(); - if(firstElement instanceof IFile) { - String elementExtension = ((IFile)firstElement).getFileExtension(); - if(elementExtension != null) { - if(browseXSDFilterExtensions[0].endsWith(elementExtension)) { - return ((IFile)firstElement); - } - } - } - return null; - } - - // ********** constructor ********** - - SchemaWizardPage(IStructuredSelection selection) { - super("SchemaWizardPage"); //$NON-NLS-1$ - - this.initialSelection = selection; - } - - // ********** IDialogPage implementation ********** - - public void createControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); -// PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, HELP_CONTEXT_ID); - composite.setLayout(new GridLayout()); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - this.setControl(composite); - - this.selectSourcePanel = new SelectFileOrXMLCatalogIdPanel(composite, this.initialSelection); - this.selectSourcePanel.setLayoutData(new GridData(GridData.FILL_BOTH)); - - SelectFileOrXMLCatalogIdPanel.PanelListener listener = new SelectFileOrXMLCatalogIdPanel.PanelListener() { - public void completionStateChanged() { - selectFileOrXMLCatalogIdPanelChanged(); - } - }; - this.selectSourcePanel.setListener(listener); - Dialog.applyDialogFont(parent); - } - - @Override - public void setVisible(boolean visible) { - super.setVisible(visible); - if(visible) { - - if(this.getSourceSchema() != null) { - this.selectSourcePanel.setSingleFileViewDefaultSelection(new StructuredSelection(this.getSourceSchema())); - } - else { - this.updateTargetProject(); - IFile schema = getSourceSchemaFromSelection(this.initialSelection); - if(schema != null) { - this.selectSourcePanel.setSingleFileViewDefaultSelection(new StructuredSelection(schema)); - } - else { - this.selectSourcePanel.setSingleFileViewDefaultSelection(new StructuredSelection(this.targetProject)); - } - } - this.selectSourcePanel.update(); - - this.setTitle(JptJaxbUiMessages.SchemaWizardPage_title); - this.setDescription(JptJaxbUiMessages.SchemaWizardPage_desc); - this.selectSourcePanel.setFilterExtensions(browseXSDFilterExtensions); - } - this.selectSourcePanel.setVisibleHelper(visible); - } - - // ********** IWizardPage implementation ********** - - @Override - public boolean isPageComplete() { - - return this.schemaOrUriSelected() && (this.getErrorMessage() == null); - } - - // ********** intra-wizard methods ********** - - public IFile getSourceSchema() { - return this.selectSourcePanel.getFile(); - } - - public String getSourceURI() { - String uri = this.selectSourcePanel.getXMLCatalogURI(); - if(uri == null) { - IFile file = this.selectSourcePanel.getFile(); - if(file != null) { - uri = URIHelper.getPlatformURI(file); - } - } - return uri; - } - - public String getXMLCatalogId() { - return this.selectSourcePanel.getXMLCatalogId(); - } - - // ********** internal methods ********** - - private void updateTargetProject() { - IWizardPage previousPage = this.getPreviousPage(); - - if(previousPage instanceof JavaProjectWizardPage) { - // get project from previousPage - this.targetProject = (((JavaProjectWizardPage)previousPage).getJavaProject()).getProject(); - } - else if(initialSelection != null && ! this.initialSelection.isEmpty()) { - // no previousPage - get project from initialSelection - this.targetProject = this.getProjectFromInitialSelection(); - } - } - - private IProject getProjectFromInitialSelection() { - Object firstElement = initialSelection.getFirstElement(); - if(firstElement instanceof IProject) { - return (IProject)firstElement; - } - else if(firstElement instanceof IResource) { - return ((IResource) firstElement).getProject(); - } - else if(firstElement instanceof IJavaElement) { - return ((IJavaElement)firstElement).getJavaProject().getProject(); - } - return null; - } - - private boolean schemaOrUriSelected() { - return ((this.getSourceSchema() != null) || (this.getSourceURI() != null)); - } - - private String computeErrorMessage() { - String errorMessage = null; - String uri = this.getSourceURI(); - if(uri != null) { - if( ! URIHelper.isReadableURI(uri, false)) { - errorMessage = JptJaxbUiMessages.SchemaWizardPage_errorUriCannotBeLocated; - } - } - return errorMessage; - } - - private void selectFileOrXMLCatalogIdPanelChanged() { - String errorMessage = this.computeErrorMessage(); - this.setErrorMessage(errorMessage); - this.setPageComplete(this.isPageComplete()); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/SelectFileOrXMLCatalogIdPanel.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/SelectFileOrXMLCatalogIdPanel.java deleted file mode 100644 index c7a6db1116..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/SelectFileOrXMLCatalogIdPanel.java +++ /dev/null @@ -1,185 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 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 - * Code originate from org.eclipse.wst.xml.ui.internal.dialogs - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.wizards.classesgen; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.part.PageBook; -import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog; -import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry; - - -public class SelectFileOrXMLCatalogIdPanel extends Composite implements SelectionListener { - - public interface PanelListener { - void completionStateChanged(); - } - - protected PanelListener listener; - protected PageBook pageBook; - - protected Button[] radioButton; - protected SelectFilePanel selectFilePanel; - protected SelectXMLCatalogIdPanel selectXMLCatalogIdPanel; - - // ********** constructor ********** - - public SelectFileOrXMLCatalogIdPanel(Composite parent, IStructuredSelection selection) { - super(parent, SWT.NONE); - - // container group - setLayout(new GridLayout()); - GridData gd = new GridData(GridData.FILL_BOTH); - gd.heightHint = 400; - gd.widthHint = 400; - setLayoutData(gd); - - radioButton = new Button[2]; - radioButton[0] = new Button(this, SWT.RADIO); - radioButton[0].setText("Select file from Workspace"); - radioButton[0].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - radioButton[0].setSelection(true); - radioButton[0].addSelectionListener(this); - - radioButton[1] = new Button(this, SWT.RADIO); - radioButton[1].setText("Select XML Catalog entry"); - radioButton[1].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - radioButton[1].addSelectionListener(this); - - pageBook = new PageBook(this, SWT.NONE); - pageBook.setLayoutData(new GridData(GridData.FILL_BOTH)); - - selectFilePanel = new SelectFilePanel(pageBook, selection); - this.setSingleFileViewDefaultSelection(selection); - - // Catalog - ICatalog xmlCatalog = JptJaxbUiPlugin.instance().getDefaultXMLCatalog(); - selectXMLCatalogIdPanel = new SelectXMLCatalogIdPanel(pageBook, xmlCatalog); - selectXMLCatalogIdPanel.getTableViewer().addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - updateCompletionStateChange(); - } - }); - Dialog.applyDialogFont(parent); - pageBook.showPage(selectFilePanel.getControl()); - } - - public void setSingleFileViewDefaultSelection(ISelection selection) { - this.selectFilePanel.setDefaultSelection(selection); - } - - public IFile getFile() { - IFile result = null; - if (radioButton[0].getSelection()) { - result = selectFilePanel.getFile(); - } - return result; - } - - public ICatalogEntry getXMLCatalogEntry() { - ICatalogEntry result = null; - if (radioButton[1].getSelection()) { - result = selectXMLCatalogIdPanel.getXMLCatalogEntry(); - } - return result; - } - - public String getXMLCatalogId() { - String result = null; - if (radioButton[1].getSelection()) { - result = selectXMLCatalogIdPanel.getId(); - } - return result; - } - - public String getXMLCatalogURI() { - String result = null; - if (radioButton[1].getSelection()) { - result = selectXMLCatalogIdPanel.getURI(); - } - return result; - } - - public void setCatalogEntryType(int catalogEntryType) { - selectXMLCatalogIdPanel.setCatalogEntryType(catalogEntryType); - } - - public void setFilterExtensions(String[] filterExtensions) { - selectFilePanel.resetFilters(); - selectFilePanel.addFilterExtensions(filterExtensions); - - selectXMLCatalogIdPanel.getTableViewer().setFilterExtensions(filterExtensions); - } - - public void setListener(PanelListener listener) { - this.listener = listener; - } - - public void setVisibleHelper(boolean isVisible) { - selectFilePanel.setVisibleHelper(isVisible); - } - - public void updateCompletionStateChange() { - if (listener != null) { - listener.completionStateChanged(); - } - } - - public void widgetDefaultSelected(SelectionEvent e) { - } - - public void widgetSelected(SelectionEvent e) { - if (e.widget == radioButton[0]) { - pageBook.showPage(selectFilePanel.getControl()); - } - else { - pageBook.showPage(selectXMLCatalogIdPanel); - } - updateCompletionStateChange(); - } - - // ********** inner class ********** - - protected class SelectFilePanel extends SelectSingleFileViewFacade implements SelectSingleFileViewFacade.Listener { - protected Control control; - - public SelectFilePanel(Composite parent, IStructuredSelection selection) { - super(selection, true); - // String[] ext = {".dtd"}; - // addFilterExtensions(ext); - control = createControl(parent); - control.setLayoutData(new GridData(GridData.FILL_BOTH)); - SelectFilePanel.this.setListener(this); - } - - public Control getControl() { - return control; - } - - public void setControlComplete(boolean isComplete) { - updateCompletionStateChange(); - } - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/SelectSingleFileViewFacade.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/SelectSingleFileViewFacade.java deleted file mode 100644 index 888095e447..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/SelectSingleFileViewFacade.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2010 Oracle. 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: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.wizards.classesgen; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Composite; - -/** - * SelectSingleFileView - * - * Façade class to change accessibility of SelectSingleFileView. - */ -public class SelectSingleFileViewFacade extends org.eclipse.wst.common.ui.internal.viewers.SelectSingleFileView { - - public static interface Listener extends org.eclipse.wst.common.ui.internal.viewers.SelectSingleFileView.Listener - {} - - public SelectSingleFileViewFacade(IStructuredSelection selection, boolean isFileMandatory) { - super(selection, isFileMandatory); - } - - public void addFilterExtensions(String[] filterExtensions) { - super.addFilterExtensions(filterExtensions); - } - - public Composite createControl(Composite parent) { - return super.createControl(parent); - } - - public IFile getFile() { - return super.getFile(); - } - - public void resetFilters() { - super.resetFilters(); - } - - public void setVisibleHelper(boolean isVisible) { - super.setVisibleHelper(isVisible); - } - - public void setDefaultSelection(ISelection selection) { - super.setDefaultSelection(selection); - } - - public void setListener(Listener listener) { - super.setListener(listener); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/SelectXMLCatalogIdPanel.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/SelectXMLCatalogIdPanel.java deleted file mode 100644 index 2745d0ab04..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/SelectXMLCatalogIdPanel.java +++ /dev/null @@ -1,146 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 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 - * Code originate from org.eclipse.wst.xml.ui.internal.dialogs - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.wizards.classesgen; - -import java.util.Collection; -import java.util.List; -import java.util.Vector; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog; -import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry; -import org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog; - - -public class SelectXMLCatalogIdPanel extends Composite { - protected int catalogEntryType; - protected boolean doTableSizeHack = false; - - protected XMLCatalogTableViewer tableViewer; - protected ICatalog fXmlCatalog; - - public SelectXMLCatalogIdPanel(Composite parent, ICatalog xmlCatalog) { - super(parent, SWT.NONE); - this.fXmlCatalog = xmlCatalog; - - GridLayout gridLayout = new GridLayout(); - this.setLayout(gridLayout); - GridData gd = new GridData(GridData.FILL_BOTH); - gd.heightHint = 200; - gd.widthHint = 700; - this.setLayoutData(gd); - - Label label = new Label(this, SWT.NONE); - label.setText(JptJaxbUiMessages.SchemaWizardPage_xmlCatalogTableTitle); - - tableViewer = createTableViewer(this); - tableViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); - tableViewer.setInput("dummy"); //$NON-NLS-1$ - } - - protected XMLCatalogTableViewer createTableViewer(Composite parent) { - String headings[] = new String[2]; - headings[0] = JptJaxbUiMessages.SchemaWizardPage_xmlCatalogKeyColumn; - headings[1] = JptJaxbUiMessages.SchemaWizardPage_xmlCatalogUriColumn; - - XMLCatalogTableViewer theTableViewer = new XMLCatalogTableViewer(parent, headings) { - - protected void addXMLCatalogEntries(List list, ICatalogEntry[] entries) { - for (int i = 0; i < entries.length; i++) { - ICatalogEntry entry = entries[i]; - if (catalogEntryType == 0) { - list.add(entry); - } - else if (catalogEntryType == entry.getEntryType()) { - list.add(entry); - } - } - } - - public Collection getXMLCatalogEntries() { - List result = null; - - if ((fXmlCatalog == null) || doTableSizeHack) { - // this lets us create a table with an initial height of - // 10 rows - // otherwise we get stuck with 0 row heigh table... that's - // too small - doTableSizeHack = false; - result = new Vector(); - for (int i = 0; i < 6; i++) { - result.add(""); //$NON-NLS-1$ - } - } - else { - result = new Vector(); - INextCatalog[] nextCatalogs = fXmlCatalog.getNextCatalogs(); - for (int i = 0; i < nextCatalogs.length; i++) { - INextCatalog catalog = nextCatalogs[i]; - ICatalog referencedCatalog = catalog.getReferencedCatalog(); - if (referencedCatalog != null) { - if (JptJaxbUiPlugin.SYSTEM_CATALOG_ID.equals(referencedCatalog.getId())) { - ICatalog systemCatalog = referencedCatalog; - addXMLCatalogEntries(result, systemCatalog.getCatalogEntries()); - - } - else if (JptJaxbUiPlugin.USER_CATALOG_ID.equals(referencedCatalog.getId())) { - ICatalog userCatalog = referencedCatalog; - addXMLCatalogEntries(result, userCatalog.getCatalogEntries()); - - } - } - } - } - return result; - } - }; - return theTableViewer; - } - - - public String getId() { - ICatalogEntry entry = getXMLCatalogEntry(); - return entry != null ? entry.getKey() : null; - } - - public XMLCatalogTableViewer getTableViewer() { - return tableViewer; - } - - public String getURI() { - ICatalogEntry entry = getXMLCatalogEntry(); - return entry != null ? entry.getURI() : null; - } - - public ICatalogEntry getXMLCatalogEntry() { - ICatalogEntry result = null; - ISelection selection = tableViewer.getSelection(); - Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null; - if (selectedObject instanceof ICatalogEntry) { - result = (ICatalogEntry) selectedObject; - } - return result; - } - - public void setCatalogEntryType(int catalogEntryType) { - this.catalogEntryType = catalogEntryType; - tableViewer.refresh(); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/XMLCatalogTableViewer.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/XMLCatalogTableViewer.java deleted file mode 100644 index 4a24f1c36b..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/XMLCatalogTableViewer.java +++ /dev/null @@ -1,195 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 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 - * Code originate from org.eclipse.wst.xml.ui.internal.dialogs - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.wizards.classesgen; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Comparator; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.wst.common.uriresolver.internal.util.URIHelper; -import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry; - -import com.ibm.icu.text.Collator; - -public class XMLCatalogTableViewer extends TableViewer { - - protected static String ERROR_STATE_KEY = "errorstatekey"; //$NON-NLS-1$ - - protected static Image dtdFileImage = JptJaxbUiPlugin.getImage("icons/full/obj16/dtdfile.gif"); //$NON-NLS-1$ - protected static Image unknownFileImage = JptJaxbUiPlugin.getImage("icons/full/obj16/text.gif"); //$NON-NLS-1$ - protected static Image xsdFileImage = JptJaxbUiPlugin.getImage("icons/full/obj16/XSDFile.gif"); //$NON-NLS-1$ - protected static Image errorImage = JptJaxbUiPlugin.getImage("icons/full/ovr16/error_ovr.gif"); //$NON-NLS-1$ - - // ********** constructor ********** - - public XMLCatalogTableViewer(Composite parent, String[] columnProperties) { - super(parent, SWT.FULL_SELECTION); - - Table table = getTable(); - table.setLinesVisible(true); - table.setHeaderVisible(true); - table.setLinesVisible(true); - - TableLayout layout = new TableLayout(); - for (int i = 0; i < columnProperties.length; i++) { - TableColumn column = new TableColumn(table, i); - column.setText(columnProperties[i]); - column.setAlignment(SWT.LEFT); - layout.addColumnData(new ColumnWeightData(50, true)); - } - table.setLayout(layout); - table.setLinesVisible(false); - - setColumnProperties(columnProperties); - - setContentProvider(new CatalogEntryContentProvider()); - setLabelProvider(new CatalogEntryLabelProvider()); - } - - public Collection getXMLCatalogEntries() { - return null; - } - - public void menuAboutToShow(IMenuManager menuManager) { - Action action = new Action("hello") { //$NON-NLS-1$ - public void run() { - System.out.println("run!"); //$NON-NLS-1$ - } - }; - menuManager.add(action); - } - - public void setFilterExtensions(String[] extensions) { - resetFilters(); - addFilter(new XMLCatalogTableViewerFilter(extensions)); - } - - // ********** inner class ********** - - public class CatalogEntryContentProvider implements IStructuredContentProvider { - - public void dispose() { - } - - public Object[] getElements(Object element) { - Object[] array = getXMLCatalogEntries().toArray(); - Comparator comparator = new Comparator() { - public int compare(Object o1, Object o2) { - int result = 0; - if ((o1 instanceof ICatalogEntry) && (o2 instanceof ICatalogEntry)) { - ICatalogEntry mappingInfo1 = (ICatalogEntry) o1; - ICatalogEntry mappingInfo2 = (ICatalogEntry) o2; - result = Collator.getInstance().compare(mappingInfo1.getKey(), mappingInfo2.getKey()); - } - return result; - } - }; - Arrays.sort(array, comparator); - return array; - } - - public void inputChanged(Viewer viewer, Object old, Object newobj) { - } - - public boolean isDeleted(Object object) { - return false; - } - } - - public class CatalogEntryLabelProvider extends LabelProvider implements ITableLabelProvider { - - public Image getColumnImage(Object object, int columnIndex) { - Image result = null; - if (columnIndex == 0) { - Image base = null; - if (object instanceof ICatalogEntry) { - ICatalogEntry catalogEntry = (ICatalogEntry) object; - String uri = catalogEntry.getURI(); - if (uri.endsWith("dtd")) { //$NON-NLS-1$ - base = dtdFileImage; - } - else if (uri.endsWith("xsd")) { //$NON-NLS-1$ - base = xsdFileImage; - } - else { - base = unknownFileImage; - } - - if (base != null) { - if (URIHelper.isReadableURI(uri, false)) { - result = base; - } - else { - // TODO... SSE port - result = base;// imageFactory.createCompositeImage(base, - // errorImage, - // ImageFactory.BOTTOM_LEFT); - } - } - } - } - return result; - } - - public String getColumnText(Object object, int columnIndex) { - String result = null; - if (object instanceof ICatalogEntry) { - ICatalogEntry catalogEntry = (ICatalogEntry) object; - result = columnIndex == 0 ? catalogEntry.getKey() : catalogEntry.getURI(); - result = URIHelper.removePlatformResourceProtocol(result); - } - return result != null ? result : ""; //$NON-NLS-1$ - } - } - - class XMLCatalogTableViewerFilter extends ViewerFilter { - protected String[] extensions; - - public XMLCatalogTableViewerFilter(String[] extensions) { - this.extensions = extensions; - } - - public boolean isFilterProperty(Object element, Object property) { - return false; - } - - public boolean select(Viewer viewer, Object parent, Object element) { - boolean result = false; - if (element instanceof ICatalogEntry) { - ICatalogEntry catalogEntry = (ICatalogEntry) element; - for (int i = 0; i < extensions.length; i++) { - if (catalogEntry.getURI().endsWith(extensions[i])) { - result = true; - break; - } - } - } - return result; - } - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetInstallPage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetInstallPage.java deleted file mode 100644 index 23526b7272..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetInstallPage.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.wizards.facet; - -import org.eclipse.jpt.jaxb.core.internal.facet.JaxbFacetInstallDataModelProperties; - -public class JaxbFacetInstallPage - extends JaxbFacetPage - implements JaxbFacetInstallDataModelProperties { - - public JaxbFacetInstallPage() { - super("jpt.jaxb.facet.install.page"); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetPage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetPage.java deleted file mode 100644 index 861dae7f92..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetPage.java +++ /dev/null @@ -1,178 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.wizards.facet; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jpt.jaxb.core.internal.facet.JaxbFacetDataModelProperties; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; -import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate; -import org.eclipse.jst.common.project.facet.ui.libprov.LibraryProviderFrameworkUi; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.help.IWorkbenchHelpSystem; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.web.ui.internal.wizards.DataModelFacetInstallPage; - - -public abstract class JaxbFacetPage - extends DataModelFacetInstallPage - implements JaxbFacetDataModelProperties { - - protected JaxbFacetPage(String pageName) { - super(pageName); - setTitle(JptJaxbUiMessages.JaxbFacetWizardPage_title); - setDescription(JptJaxbUiMessages.JaxbFacetWizardPage_desc); - setImageDescriptor(JptJaxbUiPlugin.getImageDescriptor(JptJaxbUiIcons.JAXB_WIZ_BANNER)); - } - - - @Override - public void setConfig(Object config) { - if (! (config instanceof IDataModel)) { - config = Platform.getAdapterManager().loadAdapter(config, IDataModel.class.getName()); - } - super.setConfig(config); - } - - @Override - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - composite.setLayout(layout); - - addSubComposites(composite); - - Dialog.applyDialogFont(parent); -// PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, JpaHelpContextIds.DIALOG_JPA_FACET); - - return composite; - } - - protected void addSubComposites(Composite composite) { - new PlatformGroup(composite); - new ClasspathConfigGroup(composite); - } - - protected Button createButton(Composite container, int span, String text, int style) { - Button button = new Button(container, SWT.NONE | style); - button.setText(text); - GridData gd = new GridData(); - gd.horizontalSpan = span; - button.setLayoutData(gd); - return button; - } - - protected Combo createCombo(Composite container, int span, boolean fillHorizontal) { - Combo combo = new Combo(container, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY); - GridData gd; - if (fillHorizontal) { - gd = new GridData(GridData.FILL_HORIZONTAL); - } - else { - gd = new GridData(); - } - gd.horizontalSpan = span; - combo.setLayoutData(gd); - return combo; - } - - @Override - protected String[] getValidationPropertyNames() { - return new String[] { - PLATFORM, - LIBRARY_INSTALL_DELEGATE - }; - } - - @Override - public boolean isPageComplete() { - if (! super.isPageComplete()) { - return false; - } - else { - IStatus status = this.model.validate(); - if (status.getSeverity() == IStatus.ERROR) { - setErrorMessage(status.getMessage()); - return false; - }; - setErrorMessage(null); - return true; - } - } - - @Override - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible) { - setErrorMessage(); - } - } - - @Override - public void transferStateToConfig() { - // This method is called when "finish" is being performed. - // We remove "this" as a listener so that it will stop responding to data model changes. - // "This" listens only for validation purposes, and we are done with validation at this - // point. Furthermore, any validation at this point runs into the danger of deadlocking - // the wizard. - this.model.removeListener(this); - this.synchHelper.dispose(); - super.transferStateToConfig(); - } - - protected final IWorkbenchHelpSystem getHelpSystem() { - return PlatformUI.getWorkbench().getHelpSystem(); - } - - - protected final class PlatformGroup - { - private final Combo platformCombo; - - - public PlatformGroup(Composite composite) { - Group group = new Group(composite, SWT.NONE); - group.setText(JptJaxbUiMessages.JaxbFacetWizardPage_platformLabel); - group.setLayout(new GridLayout()); - group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); -// PlatformUI.getWorkbench().getHelpSystem().setHelp(group, JpaHelpContextIds.DIALOG_JPA_PLATFORM); - - this.platformCombo = createCombo(group, 1, true); - JaxbFacetPage.this.synchHelper.synchCombo(platformCombo, PLATFORM, null); - } - } - - - protected final class ClasspathConfigGroup { - - public ClasspathConfigGroup(Composite composite) { - - LibraryInstallDelegate librariesInstallDelegate - = (LibraryInstallDelegate) getDataModel().getProperty(LIBRARY_INSTALL_DELEGATE); - - Composite librariesComposite - = (Composite) LibraryProviderFrameworkUi.createInstallLibraryPanel( - composite, librariesInstallDelegate, - JptJaxbUiMessages.JaxbFacetWizardPage_jaxbImplementationLabel); - librariesComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); -// PlatformUI.getWorkbench().getHelpSystem().setHelp(librariesComposite, JpaHelpContextIds.NEW_JPA_PROJECT_CONTENT_PAGE_CLASSPATH); - } - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetVersionChangePage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetVersionChangePage.java deleted file mode 100644 index 26e1e43b0a..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetVersionChangePage.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.wizards.facet; - -import org.eclipse.jpt.jaxb.core.internal.facet.JaxbFacetVersionChangeDataModelProperties; - -public class JaxbFacetVersionChangePage - extends JaxbFacetPage - implements JaxbFacetVersionChangeDataModelProperties { - - public JaxbFacetVersionChangePage() { - super("jpt.jaxb.facet.versionChange.page"); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/proj/JaxbProjectWizard.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/proj/JaxbProjectWizard.java deleted file mode 100644 index 696d4cee32..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/proj/JaxbProjectWizard.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.wizards.proj; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; -import org.eclipse.jpt.jaxb.ui.internal.wizards.proj.model.JaxbProjectCreationDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.IFacetedProjectTemplate; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.web.ui.internal.wizards.NewProjectDataModelFacetWizard; - - -public class JaxbProjectWizard - extends NewProjectDataModelFacetWizard { - - public JaxbProjectWizard() { - super(); - setWindowTitle(JptJaxbUiMessages.JaxbProjectWizard_title); - } - - public JaxbProjectWizard(IDataModel dataModel) { - super(dataModel); - setWindowTitle(JptJaxbUiMessages.JaxbProjectWizard_title); - } - - - @Override - protected ImageDescriptor getDefaultPageImageDescriptor() { - return JptJaxbUiPlugin.getImageDescriptor(JptJaxbUiIcons.JAXB_WIZ_BANNER); - } - - @Override - protected IWizardPage createFirstPage() { - return new JaxbProjectWizardFirstPage(model, "first.page"); //$NON-NLS-1$ - } - - @Override - protected IDataModel createDataModel() { - return DataModelFactory.createDataModel(new JaxbProjectCreationDataModelProvider()); - } - - @Override - protected IFacetedProjectTemplate getTemplate() { - return ProjectFacetsManager.getTemplate("jpt.jaxb.template"); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/proj/JaxbProjectWizardFirstPage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/proj/JaxbProjectWizardFirstPage.java deleted file mode 100644 index 1a1ec07af8..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/proj/JaxbProjectWizardFirstPage.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.wizards.proj; - -import org.eclipse.jpt.jaxb.core.JaxbFacet; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.web.ui.internal.wizards.DataModelFacetCreationWizardPage; - - -public class JaxbProjectWizardFirstPage - extends DataModelFacetCreationWizardPage { - - public JaxbProjectWizardFirstPage(IDataModel dataModel, String pageName) { - super(dataModel, pageName); - setTitle(JptJaxbUiMessages.JaxbProjectWizard_firstPage_title); - setDescription(JptJaxbUiMessages.JaxbProjectWizard_firstPage_desc); - //setInfopopID(JpaJaxbHelpContextIds.NEW_JAXB_PROJECT); - } - - - @Override - protected Composite createTopLevelComposite(Composite parent) { - final Composite top = super.createTopLevelComposite(parent); - createWorkingSetGroupPanel(top, new String[] { RESOURCE_WORKING_SET, JAVA_WORKING_SET }); - return top; - } - -// @Override -// public boolean internalLaunchNewRuntimeWizard(Shell shell, IDataModel model) { -// IFacetedProjectWorkingCopy fpwc = (IFacetedProjectWorkingCopy) model.getProperty(FACETED_PROJECT_WORKING_COPY); -// IProjectFacetVersion moduleFacet = FacetTools.getModuleFacet(fpwc); -// if (moduleFacet != null) { -// return launchNewRuntimeWizard(shell, model, moduleFacet.getProjectFacet().getId()); -// } -// else { -// return launchNewRuntimeWizard(shell, model); -// } -// } - - @Override - protected String getModuleTypeID() { - return JaxbFacet.ID; - } - - @Override - public void storeDefaultSettings() { - super.storeDefaultSettings(); - // TODO -// IDialogSettings settings = getDialogSettings(); -// if (settings != null) { -// FacetDataModelMap map = (FacetDataModelMap)model.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); -// String facetID = getModuleFacetID(); -// IDataModel j2eeModel = map.getFacetDataModel(facetID); -// if(j2eeModel.getBooleanProperty(IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR)){ -// String lastEARName = j2eeModel.getStringProperty(IJ2EEModuleFacetInstallDataModelProperties.EAR_PROJECT_NAME); -// settings.put(STORE_LABEL, lastEARName); -// } -// } - } - - @Override - public void restoreDefaultSettings() { - super.restoreDefaultSettings(); - // TODO -// IDialogSettings settings = getDialogSettings(); -// if (settings != null) { -// String lastEARName = settings.get(STORE_LABEL); -// if (lastEARName != null){ -// FacetDataModelMap map = (FacetDataModelMap)model.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); -// String facetID = getModuleFacetID(); -// IDataModel j2eeModel = map.getFacetDataModel(facetID); -// j2eeModel.setProperty(IJ2EEModuleFacetInstallDataModelProperties.LAST_EAR_NAME, lastEARName); -// } -// } - } - -// @Override -// protected IDialogSettings getDialogSettings() { -// return J2EEUIPlugin.getDefault().getDialogSettings(); -// } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/proj/model/JaxbProjectCreationDataModelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/proj/model/JaxbProjectCreationDataModelProvider.java deleted file mode 100644 index 76747b04ab..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/proj/model/JaxbProjectCreationDataModelProvider.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.wizards.proj.model; - -import java.util.ArrayList; -import java.util.Collection; -import org.eclipse.jpt.jaxb.core.JaxbFacet; -import org.eclipse.jst.common.project.facet.core.JavaFacet; -import org.eclipse.wst.common.componentcore.datamodel.FacetProjectCreationDataModelProvider; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; - - -public class JaxbProjectCreationDataModelProvider - extends FacetProjectCreationDataModelProvider - implements IFacetProjectCreationDataModelProperties { - - public JaxbProjectCreationDataModelProvider() { - super(); - } - - - @Override - public void init() { - super.init(); - - Collection<IProjectFacet> requiredFacets = new ArrayList<IProjectFacet>(); - requiredFacets.add(JavaFacet.FACET); - requiredFacets.add(JaxbFacet.FACET); - setProperty(REQUIRED_FACETS_COLLECTION, requiredFacets); - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/AbstractJarDestinationWizardPage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/AbstractJarDestinationWizardPage.java deleted file mode 100644 index b703e1c3bb..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/AbstractJarDestinationWizardPage.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2010 Oracle. 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: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.wizards.schemagen; - -import org.eclipse.jdt.ui.jarpackager.JarPackageData; -import org.eclipse.jface.viewers.IStructuredSelection; - -/** - * Façade class to change accessibility of AbstractJarDestinationWizardPage. - */ -@SuppressWarnings("restriction") -public abstract class AbstractJarDestinationWizardPage extends org.eclipse.jdt.internal.ui.jarpackager.AbstractJarDestinationWizardPage -{ - - public AbstractJarDestinationWizardPage(String pageName, IStructuredSelection selection, JarPackageData jarPackage) { - super(pageName, selection, jarPackage); - } - -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/CheckboxTreeAndListGroup.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/CheckboxTreeAndListGroup.java deleted file mode 100644 index e551a5e32f..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/CheckboxTreeAndListGroup.java +++ /dev/null @@ -1,856 +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 - * Code originate from org.eclipse.jdt.internal.ui.jarpackager - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.wizards.schemagen; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.CheckboxTreeViewer; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.ITreeViewerListener; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TreeExpansionEvent; -import org.eclipse.jface.viewers.ViewerComparator; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.Tree; - -/** - * Combines a CheckboxTreeViewer and CheckboxListViewer. - * All viewer selection-driven interactions are handled within this viewer - */ -public class CheckboxTreeAndListGroup implements ICheckStateListener, ISelectionChangedListener, ITreeViewerListener { - - private Object fRoot; - private Object fCurrentTreeSelection; - private List fExpandedTreeNodes= new ArrayList(); - private Map fCheckedStateStore= this.buildCheckedStateStore(); - private List fWhiteCheckedTreeItems= new ArrayList(); - private List fListeners= new ArrayList(); - - private ITreeContentProvider fTreeContentProvider; - private IStructuredContentProvider fListContentProvider; - private ILabelProvider fTreeLabelProvider; - private ILabelProvider fListLabelProvider; - - // widgets - private CheckboxTreeViewer fTreeViewer; - private CheckboxTableViewer fListViewer; - - /** - * Creates an instance of this class. Use this constructor if you wish to specify - * the width and/or height of the combined widget (to only hardcode one of the - * sizing dimensions, specify the other dimension's value as -1) - * @param parent parent composite - * @param rootObject - * @param treeContentProvider - * @param treeLabelProvider - * @param listContentProvider - * @param listLabelProvider - * @param style - * @param width the width - * @param height the height - */ - public CheckboxTreeAndListGroup( - Composite parent, - Object rootObject, - ITreeContentProvider treeContentProvider, - ILabelProvider treeLabelProvider, - IStructuredContentProvider listContentProvider, - ILabelProvider listLabelProvider, - int style, - int width, - int height) { - fRoot= rootObject; - fTreeContentProvider= treeContentProvider; - fListContentProvider= listContentProvider; - fTreeLabelProvider= treeLabelProvider; - fListLabelProvider= listLabelProvider; - createContents(parent, width, height, style); - } - /** - * This method must be called just before this window becomes visible. - */ - public void aboutToOpen() { - determineWhiteCheckedDescendents(fRoot); - checkNewTreeElements(getTreeChildren(fRoot)); - fCurrentTreeSelection= null; - - //select the first element in the list - Object[] elements= getTreeChildren(fRoot); - Object primary= elements.length > 0 ? elements[0] : null; - if (primary != null) { - fTreeViewer.setSelection(new StructuredSelection(primary)); - } - fTreeViewer.getControl().setFocus(); - } - /** - * Adds the passed listener to self's collection of clients - * that listen for changes to element checked states - * - * @param listener ICheckStateListener - */ - public void addCheckStateListener(ICheckStateListener listener) { - fListeners.add(listener); - } - /** - * Adds the receiver and all of it's ancestors to the checkedStateStore if they - * are not already there. - * @param treeElement - */ - private void addToHierarchyToCheckedStore(Object treeElement) { - - // if this tree element is already gray then its ancestors all are as well - if (!fCheckedStateStore.containsKey(treeElement)) - fCheckedStateStore.put(treeElement, new ArrayList()); - - Object parent= fTreeContentProvider.getParent(treeElement); - if (parent != null) - addToHierarchyToCheckedStore(parent); - } - /** - * Returns a boolean indicating whether all children of the passed tree element - * are currently white-checked - * - * @return boolean - * @param treeElement java.lang.Object - */ - protected boolean areAllChildrenWhiteChecked(Object treeElement) { - Object[] children= getTreeChildren(treeElement); - for (int i= 0; i < children.length; ++i) { - if (!fWhiteCheckedTreeItems.contains(children[i])) - return false; - } - - return true; - } - /** - * Returns a boolean indicating whether all list elements associated with - * the passed tree element are currently checked - * - * @return boolean - * @param treeElement java.lang.Object - */ - protected boolean areAllElementsChecked(Object treeElement) { - List checkedElements= (List)fCheckedStateStore.get(treeElement); - if (checkedElements == null) // ie.- tree item not even gray-checked - return false; - - return getListItemsSize(treeElement) == checkedElements.size(); - } - /** - * Iterates through the passed elements which are being realized for the first - * time and check each one in the tree viewer as appropriate - * @param elements - */ - protected void checkNewTreeElements(Object[] elements) { - for (int i= 0; i < elements.length; ++i) { - Object currentElement= elements[i]; - boolean checked= fCheckedStateStore.containsKey(currentElement); - fTreeViewer.setChecked(currentElement, checked); - fTreeViewer.setGrayed( - currentElement, - checked && !fWhiteCheckedTreeItems.contains(currentElement)); - } - } - /** - * An item was checked in one of self's two views. Determine which - * view this occurred in and delegate appropriately - * - * @param event CheckStateChangedEvent - */ - public void checkStateChanged(final CheckStateChangedEvent event) { - - //Potentially long operation - show a busy cursor - BusyIndicator.showWhile(fTreeViewer.getControl().getDisplay(), new Runnable() { - public void run() { - if (event.getCheckable().equals(fTreeViewer)) - treeItemChecked(event.getElement(), event.getChecked()); - else - listItemChecked(event.getElement(), event.getChecked(), true); - - notifyCheckStateChangeListeners(event); - } - }); - } - /** - * Lay out and initialize self's visual components. - * - * @param parent org.eclipse.swt.widgets.Composite - * @param width int - * @param height int - * @param style - */ - protected void createContents( - Composite parent, - int width, - int height, - int style) { - // group pane - Composite composite= new Composite(parent, style); - GridLayout layout= new GridLayout(); - layout.numColumns= 2; - layout.makeColumnsEqualWidth= true; - layout.marginHeight= 0; - layout.marginWidth= 0; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - createTreeViewer(composite, width / 2, height); - createListViewer(composite, width / 2, height); - - initialize(); - } - /** - * Creates this group's list viewer. - * @param parent the parent composite - * @param width the width - * @param height the height - */ - protected void createListViewer(Composite parent, int width, int height) { - fListViewer= CheckboxTableViewer.newCheckList(parent, SWT.BORDER); - fListViewer.setUseHashlookup(true); - GridData data= new GridData(GridData.FILL_BOTH); - data.widthHint= width; - data.heightHint= height; - fListViewer.getTable().setLayoutData(data); - fListViewer.setContentProvider(fListContentProvider); - fListViewer.setLabelProvider(fListLabelProvider); - fListViewer.addCheckStateListener(this); - } - /** - * Creates this group's tree viewer. - * @param parent parent composite - * @param width the width - * @param height the height - */ - protected void createTreeViewer(Composite parent, int width, int height) { - Tree tree= new Tree(parent, SWT.CHECK | SWT.BORDER); - GridData data= new GridData(GridData.FILL_BOTH); - data.widthHint= width; - data.heightHint= height; - tree.setLayoutData(data); - - fTreeViewer= new CheckboxTreeViewer(tree); - fTreeViewer.setUseHashlookup(true); - fTreeViewer.setContentProvider(fTreeContentProvider); - fTreeViewer.setLabelProvider(fTreeLabelProvider); - fTreeViewer.addTreeListener(this); - fTreeViewer.addCheckStateListener(this); - fTreeViewer.addSelectionChangedListener(this); - } - /** - * Returns a boolean indicating whether the passed tree element should be - * at LEAST gray-checked. Note that this method does not consider whether - * it should be white-checked, so a specified tree item which should be - * white-checked will result in a <code>true</code> answer from this method. - * To determine whether a tree item should be white-checked use method - * #determineShouldBeWhiteChecked(Object). - * - * @param treeElement java.lang.Object - * @return boolean - * @see #determineShouldBeWhiteChecked(java.lang.Object) - */ - protected boolean determineShouldBeAtLeastGrayChecked(Object treeElement) { - // if any list items associated with treeElement are checked then it - // retains its gray-checked status regardless of its children - List checked= (List) fCheckedStateStore.get(treeElement); - if (checked != null && (!checked.isEmpty())) - return true; - - // if any children of treeElement are still gray-checked then treeElement - // must remain gray-checked as well - Object[] children= getTreeChildren(treeElement); - for (int i= 0; i < children.length; ++i) { - if (fCheckedStateStore.containsKey(children[i])) - return true; - } - - return false; - } - /** - * Returns a boolean indicating whether the passed tree item should be - * white-checked. - * - * @return boolean - * @param treeElement java.lang.Object - */ - protected boolean determineShouldBeWhiteChecked(Object treeElement) { - return areAllChildrenWhiteChecked(treeElement) - && areAllElementsChecked(treeElement); - } - /** - * Recursively adds appropriate tree elements to the collection of - * known white-checked tree elements. - * - * @param treeElement java.lang.Object - */ - protected void determineWhiteCheckedDescendents(Object treeElement) { - // always go through all children first since their white-checked - // statuses will be needed to determine the white-checked status for - // this tree element - Object[] children= getTreeChildren(treeElement); - for (int i= 0; i < children.length; ++i) - determineWhiteCheckedDescendents(children[i]); - - // now determine the white-checked status for this tree element - if (determineShouldBeWhiteChecked(treeElement)) - setWhiteChecked(treeElement, true); - } - /** - * Causes the tree viewer to expand all its items - */ - public void expandAll() { - fTreeViewer.expandAll(); - } - /** - * Answers a flat collection of all of the checked elements in the - * list portion of self - * - * @return java.util.Vector - */ - public Iterator getAllCheckedListItems() { - Set result= new HashSet(); - Iterator listCollectionsEnum= this.fCheckedStateStore.values().iterator(); - while (listCollectionsEnum.hasNext()) - result.addAll((List)listCollectionsEnum.next()); - return result.iterator(); - } - /** - * Answer a collection of all of the checked elements in the tree portion - * of self - * - * @return java.util.Vector - */ - public Set getAllCheckedTreeItems() { - return new HashSet(fCheckedStateStore.keySet()); - } - /** - * Answers the number of elements that have been checked by the - * user. - * - * @return int - */ - public int getCheckedElementCount() { - return fCheckedStateStore.size(); - } - /** - * Returns a count of the number of list items associated with a - * given tree item. - * - * @return int - * @param treeElement java.lang.Object - */ - protected int getListItemsSize(Object treeElement) { - Object[] elements= getListElements(treeElement); - return elements.length; - } - /** - * Gets the table that displays the folder content - * - * @return the table used to show the list - */ - public Table getTable() { - return fListViewer.getTable(); - } - /** - * Gets the tree that displays the list for a folder - * - * @return the tree used to show the folders - */ - public Tree getTree() { - return fTreeViewer.getTree(); - } - /** - * Adds the given filter to the tree viewer and - * triggers refiltering and resorting of the elements. - * - * @param filter a viewer filter - */ - public void addTreeFilter(ViewerFilter filter) { - fTreeViewer.addFilter(filter); - } - - public void removeTreeFilter(ViewerFilter filter) { - fTreeViewer.removeFilter(filter); - } - - /** - * Adds the given filter to the list viewer and - * triggers refiltering and resorting of the elements. - * - * @param filter a viewer filter - */ - public void addListFilter(ViewerFilter filter) { - fListViewer.addFilter(filter); - } - - /** - * Logically gray-check all ancestors of treeItem by ensuring that they - * appear in the checked table - * @param treeElement - */ - protected void grayCheckHierarchy(Object treeElement) { - - // if this tree element is already gray then its ancestors all are as well - if (fCheckedStateStore.containsKey(treeElement)) - return; // no need to proceed upwards from here - - fCheckedStateStore.put(treeElement, new ArrayList()); - if (determineShouldBeWhiteChecked(treeElement)) { - setWhiteChecked(treeElement, true); - } - Object parent= fTreeContentProvider.getParent(treeElement); - if (parent != null) - grayCheckHierarchy(parent); - } - /** - * Sets the initial checked state of the passed list element to true. - * @param element - */ - public void initialCheckListItem(Object element) { - Object parent= fTreeContentProvider.getParent(element); - fCurrentTreeSelection= parent; - //As this is not done from the UI then set the box for updating from the selection to false - listItemChecked(element, true, false); - updateHierarchy(parent); - } - /** - * Sets the initial checked state of the passed element to true, - * as well as to all of its children and associated list elements - * @param element - */ - public void initialCheckTreeItem(Object element) { - treeItemChecked(element, true); - } - /** - * Initializes this group's viewers after they have been laid out. - */ - protected void initialize() { - fTreeViewer.setInput(fRoot); - } - /** - * Callback that's invoked when the checked status of an item in the list - * is changed by the user. Do not try and update the hierarchy if we are building the - * initial list. - * @param listElement - * @param state - * @param updatingFromSelection - */ - protected void listItemChecked( - Object listElement, - boolean state, - boolean updatingFromSelection) { - List checkedListItems= (List) fCheckedStateStore.get(fCurrentTreeSelection); - - if (state) { - if (checkedListItems == null) { - // since the associated tree item has gone from 0 -> 1 checked - // list items, tree checking may need to be updated - grayCheckHierarchy(fCurrentTreeSelection); - checkedListItems= (List) fCheckedStateStore.get(fCurrentTreeSelection); - } - checkedListItems.add(listElement); - } else { - checkedListItems.remove(listElement); - if (checkedListItems.isEmpty()) { - // since the associated tree item has gone from 1 -> 0 checked - // list items, tree checking may need to be updated - ungrayCheckHierarchy(fCurrentTreeSelection); - } - } - - if (updatingFromSelection) - updateHierarchy(fCurrentTreeSelection); - } - /** - * Notifies all checked state listeners that the passed element has had - * its checked state changed to the passed state - * @param event - */ - protected void notifyCheckStateChangeListeners(CheckStateChangedEvent event) { - Iterator listenersEnum= fListeners.iterator(); - while (listenersEnum.hasNext()) - ((ICheckStateListener) listenersEnum.next()).checkStateChanged(event); - } - /** - *Sets the contents of the list viewer based upon the specified selected - *tree element. This also includes checking the appropriate list items. - * - *@param treeElement java.lang.Object - */ - public void populateListViewer(final Object treeElement) { - if (treeElement == fCurrentTreeSelection) - return; - fCurrentTreeSelection= treeElement; - fListViewer.setInput(treeElement); - List listItemsToCheck= (List) fCheckedStateStore.get(treeElement); - - if (listItemsToCheck != null) { - Iterator listItemsEnum= listItemsToCheck.iterator(); - while (listItemsEnum.hasNext()) - fListViewer.setChecked(listItemsEnum.next(), true); - } - } - /** - * Removes the passed listener from self's collection of clients - * that listen for changes to element checked states - * - * @param listener ICheckStateListener - */ - public void removeCheckStateListener(ICheckStateListener listener) { - fListeners.remove(listener); - } - /** - * Handles the selection of an item in the tree viewer - * - * @param event ISelection - */ - public void selectionChanged(final SelectionChangedEvent event) { - BusyIndicator.showWhile(getTable().getShell().getDisplay(), new Runnable() { - public void run() { - IStructuredSelection selection= (IStructuredSelection) event.getSelection(); - Object selectedElement= selection.getFirstElement(); - if (selectedElement == null) { - fCurrentTreeSelection= null; - fListViewer.setInput(fCurrentTreeSelection); - return; - } - populateListViewer(selectedElement); - } - }); - } - - /** - * Selects or deselect all of the elements in the tree depending on the value of the selection - * boolean. Be sure to update the displayed files as well. - * @param selection - */ - public void setAllSelections(final boolean selection) { - - //Potentially long operation - show a busy cursor - BusyIndicator.showWhile(fTreeViewer.getControl().getDisplay(), new Runnable() { - public void run() { - setTreeChecked(fRoot, selection); - fListViewer.setAllChecked(selection); - } - }); - } - - /** - * Sets the list viewer's providers to those passed - * - * @param contentProvider ITreeContentProvider - * @param labelProvider ILabelProvider - */ - public void setListProviders( - IStructuredContentProvider contentProvider, - ILabelProvider labelProvider) { - fListViewer.setContentProvider(contentProvider); - fListViewer.setLabelProvider(labelProvider); - } - /** - * Sets the sorter that is to be applied to self's list viewer - * @param comparator - */ - public void setListComparator(ViewerComparator comparator) { - fListViewer.setComparator(comparator); - } - /** - * Sets the root of the widget to be new Root. Regenerate all of the tables and lists from this - * value. - * - * @param newRoot - */ - public void setRoot(Object newRoot) { - this.fRoot= newRoot; - initialize(); - } - /** - * Sets the checked state of the passed tree element appropriately, and - * do so recursively to all of its child tree elements as well - * @param treeElement - * @param state - */ - protected void setTreeChecked(Object treeElement, boolean state) { - - if (treeElement.equals(fCurrentTreeSelection)) { - fListViewer.setAllChecked(state); - } - - if (state) { - Object[] listItems= getListElements(treeElement); - List listItemsChecked= new ArrayList(); - for (int i= 0; i < listItems.length; ++i) - listItemsChecked.add(listItems[i]); - - fCheckedStateStore.put(treeElement, listItemsChecked); - } else - fCheckedStateStore.remove(treeElement); - - setWhiteChecked(treeElement, state); - fTreeViewer.setChecked(treeElement, state); - fTreeViewer.setGrayed(treeElement, false); - - // now logically check/uncheck all children as well - Object[] children= getTreeChildren(treeElement); - for (int i= 0; i < children.length; ++i) { - setTreeChecked(children[i], state); - } - } - /** - * Sets the tree viewer's providers to those passed - * - * @param contentProvider ITreeContentProvider - * @param labelProvider ILabelProvider - */ - public void setTreeProviders( - ITreeContentProvider contentProvider, - ILabelProvider labelProvider) { - fTreeViewer.setContentProvider(contentProvider); - fTreeViewer.setLabelProvider(labelProvider); - } - /** - * Sets the sorter that is to be applied to self's tree viewer - * @param sorter - */ - public void setTreeComparator(ViewerComparator sorter) { - fTreeViewer.setComparator(sorter); - } - /** - * Adjusts the collection of references to white-checked tree elements appropriately. - * - * @param treeElement java.lang.Object - * @param isWhiteChecked boolean - */ - protected void setWhiteChecked(Object treeElement, boolean isWhiteChecked) { - if (isWhiteChecked) { - if (!fWhiteCheckedTreeItems.contains(treeElement)) - fWhiteCheckedTreeItems.add(treeElement); - } else - fWhiteCheckedTreeItems.remove(treeElement); - } - /** - * Handle the collapsing of an element in a tree viewer - * @param event - */ - public void treeCollapsed(TreeExpansionEvent event) { - // We don't need to do anything with this - } - - /** - * Handles the expansionsion of an element in a tree viewer - * @param event - */ - public void treeExpanded(TreeExpansionEvent event) { - - Object item= event.getElement(); - - // First see if the children need to be given their checked state at all. If they've - // already been realized then this won't be necessary - if (!fExpandedTreeNodes.contains(item)) { - fExpandedTreeNodes.add(item); - checkNewTreeElements(getTreeChildren(item)); - } - } - - /** - * Callback that's invoked when the checked status of an item in the tree - * is changed by the user. - * @param treeElement - * @param state - */ - protected void treeItemChecked(Object treeElement, boolean state) { - - // recursively adjust all child tree elements appropriately - setTreeChecked(treeElement, state); - - Object parent= fTreeContentProvider.getParent(treeElement); - if (parent == null) - return; - - // now update upwards in the tree hierarchy - if (state) - grayCheckHierarchy(parent); - else - ungrayCheckHierarchy(parent); - - updateHierarchy(treeElement); - } - /** - * Logically un-gray-check all ancestors of treeItem iff appropriate. - * @param treeElement - */ - protected void ungrayCheckHierarchy(Object treeElement) { - if (!determineShouldBeAtLeastGrayChecked(treeElement)) - fCheckedStateStore.remove(treeElement); - - Object parent= fTreeContentProvider.getParent(treeElement); - if (parent != null) - ungrayCheckHierarchy(parent); - } - /** - * Sets the checked state of self and all ancestors appropriately - * @param treeElement - */ - protected void updateHierarchy(Object treeElement) { - - boolean whiteChecked= determineShouldBeWhiteChecked(treeElement); - boolean shouldBeAtLeastGray= determineShouldBeAtLeastGrayChecked(treeElement); - - fTreeViewer.setChecked(treeElement, whiteChecked || shouldBeAtLeastGray); - setWhiteChecked(treeElement, whiteChecked); - if (whiteChecked) - fTreeViewer.setGrayed(treeElement, false); - else - fTreeViewer.setGrayed(treeElement, shouldBeAtLeastGray); - - // proceed up the tree element hierarchy - Object parent= fTreeContentProvider.getParent(treeElement); - if (parent != null) { - updateHierarchy(parent); - } - } - /** - * Update the selections of the tree elements in items to reflect the new - * selections provided. - * - * @param items with keys of Object (the tree element) and values of List (the selected - * list elements). - */ - public void updateSelections(final Map items) { - - //Potentially long operation - show a busy cursor - BusyIndicator.showWhile(fTreeViewer.getControl().getDisplay(), new Runnable() { - public void run() { - handleUpdateSelection(items); - } - }); - } - /** - * Returns the result of running the given elements through the filters. - * @param filters - * - * @param elements the elements to filter - * @return only the elements which all filters accept - */ - protected Object[] filter(ViewerFilter[] filters, Object[] elements) { - if (filters != null) { - ArrayList filtered = new ArrayList(elements.length); - for (int i = 0; i < elements.length; i++) { - boolean add = true; - for (int j = 0; j < filters.length; j++) { - add = filters[j].select(null, null, elements[i]); - if (!add) - break; - } - if (add) - filtered.add(elements[i]); - } - return filtered.toArray(); - } - return elements; - } - - private Object[] getTreeChildren(Object element) { - return filter(fTreeViewer.getFilters(), fTreeContentProvider.getChildren(element)); - } - - private Object[] getListElements(Object element) { - return filter(fListViewer.getFilters(), fListContentProvider.getElements(element)); - } - - public Set getWhiteCheckedTreeItems() { - return new HashSet(fWhiteCheckedTreeItems); - } - - private HashMap buildCheckedStateStore() { - return new HashMap(9); - } - - private void handleUpdateSelection(Map items) { - Iterator keyIterator= items.keySet().iterator(); - - //Update the store before the hierarchy to prevent updating parents before all of the children are done - while (keyIterator.hasNext()) { - Object key= keyIterator.next(); - //Replace the items in the checked state store with those from the supplied items - List selections= (List) items.get(key); - if (selections.size() == 0) - //If it is empty remove it from the list - fCheckedStateStore.remove(key); - else { - fCheckedStateStore.put(key, selections); - // proceed up the tree element hierarchy - Object parent= fTreeContentProvider.getParent(key); - if (parent != null) { - addToHierarchyToCheckedStore(parent); - } - } - } - - //Now update hierarchies - keyIterator= items.keySet().iterator(); - - while (keyIterator.hasNext()) { - Object key= keyIterator.next(); - updateHierarchy(key); - if (fCurrentTreeSelection != null && fCurrentTreeSelection.equals(key)) { - fListViewer.setAllChecked(false); - fListViewer.setCheckedElements(((List) items.get(key)).toArray()); - } - } - } - - /** - * Checks if an element is grey checked. - * @param object - * @return if an element is grey checked. - */ - public boolean isTreeItemGreyChecked(Object object) { - return fTreeViewer.getGrayed(object); - } - - /** - * For a given element, expand its chidren to a level. - * @param object - * @param level - */ - public void expandTreeToLevel(Object object, int level) { - fTreeViewer.expandToLevel(object, level); - } - /** - * @param selection - */ - public void setTreeSelection(ISelection selection) { - fTreeViewer.setSelection(selection); - } -}
\ No newline at end of file diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/NewSchemaFileWizardPage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/NewSchemaFileWizardPage.java deleted file mode 100644 index c384630021..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/NewSchemaFileWizardPage.java +++ /dev/null @@ -1,204 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2010, 2011 Oracle. 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: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.wizards.schemagen; - -import static org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties.CONTAINER_PATH; -import static org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties.FILE_NAME; -import static org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties.PROJECT; -import static org.eclipse.jpt.jaxb.ui.internal.wizards.schemagen.SchemaGeneratorWizard.XSD_EXTENSION; - -import java.io.File; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jpt.common.utility.internal.FileTools; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.dialogs.WizardNewFileCreationPage; -import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -/** - * NewSchemaFileWizardPage - */ -public class NewSchemaFileWizardPage extends WizardNewFileCreationPage { - - protected IDataModel dataModel; - - private IStructuredSelection initialSelection; - - static public String DEFAULT_SCHEMA_NAME = "NewXMLSchema" + XSD_EXTENSION; //$NON-NLS-1$ - - // ********** constructor ********** - - public NewSchemaFileWizardPage(String pageName, IStructuredSelection selection, IDataModel dataModel, - String title, String description) { - - super(pageName, selection); - this.initialSelection = selection; - - this.init(dataModel); - this.setTitle(title); - this.setDescription(description); - } - - protected void init(IDataModel dataModel) { - this.dataModel = dataModel; - - IProject project = this.getProjectFromInitialSelection(); - this.dataModel.setProperty(PROJECT, project); - - IPath containerPath = (IPath) this.dataModel.getProperty(CONTAINER_PATH); - if (containerPath != null) { - this.setContainerFullPath(containerPath); - } - } - - // ********** IDialogPage implementation ********** - @Override - public void createControl(Composite parent) { - super.createControl(parent); - - this.setAllowExistingResources(true); - this.setFileName(DEFAULT_SCHEMA_NAME); - } - - // ********** intra-wizard methods ********** - - public IProject getProject() { - return (IProject) this.dataModel.getProperty(PROJECT); - } - - public IPath getFilePath() { - return this.getContainerFullPath(); - } - - // ********** validation ********** - - @Override - protected boolean validatePage() { - this.dataModel.setProperty(PROJECT, this.getProjectNamed(this.getContainerName())); - this.dataModel.setProperty(CONTAINER_PATH, this.getContainerFullPath()); - this.dataModel.setProperty(FILE_NAME, this.getFileName()); - - boolean valid = super.validatePage(); - if( ! valid) { - return valid; - } - this.overrideFileExistsWarning(); - - //TODO move this validation to the dataModel - see MappingFileNewFileWizardPage - // Validate Project - valid = this.projectIsJavaProject(this.getProject()); - if( ! valid) { - this.setErrorMessage(JptJaxbUiMessages.NewSchemaFileWizardPage_errorNotJavaProject); - return valid; - } - // Validate XSD file not exists. - valid = this.xsdFileNotExists(); - if( ! valid) { - this.setMessage(JptJaxbUiMessages.NewSchemaFileWizardPage_overwriteExistingSchemas, IMessageProvider.WARNING); - return true; - } - this.setErrorMessage(null); - - return valid; - } - - // ********** internal methods ********** - - private boolean projectIsJavaProject(IProject project) { - try { - return (project != null) && (project.hasNature(JavaCore.NATURE_ID)); - } - catch (CoreException e) { - return false; - } - } - - private IProject getProjectFromInitialSelection() { - Object firstElement = initialSelection.getFirstElement(); - if(firstElement instanceof IProject) { - return (IProject)firstElement; - } - else if(firstElement instanceof IResource) { - return ((IResource) firstElement).getProject(); - } - else if(firstElement instanceof IJavaElement) { - return ((IJavaElement)firstElement).getJavaProject().getProject(); - } - return null; - } - - private IProject getProjectNamed(String projectName) { - if(StringTools.stringIsEmpty(projectName)) { - return null; - } - return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - } - - private String getContainerName() { - IPath containerPath = this.getContainerFullPath(); - if(containerPath == null) { - return null; - } - String containerName = containerPath.segment(0); - return containerName; - } - - private void overrideFileExistsWarning() { - String existsString= IDEWorkbenchMessages.ResourceGroup_nameExists; - existsString.toString(); - - existsString = existsString.substring("''{0}''".length(), existsString.length()); //$NON-NLS-1$ - String message = this.getMessage(); - if(message != null && message.endsWith(existsString)) { - this.setMessage(null); - } - } - - private boolean xsdFileNotExists() { - - return ! this.xsdFileExists(this.getContainerAbsolutePath().toFile()); - } - - private boolean xsdFileExists(File directory) { - - if(directory.listFiles() == null) { - throw new RuntimeException("Could not find directory: " + directory); //$NON-NLS-1$ - } - for(File file : directory.listFiles()) { - if (file.isDirectory()) { - continue; - } - else if(XSD_EXTENSION.equalsIgnoreCase(FileTools.extension(file))) { - return true; - } - } - return false; - } - - private IPath getContainerAbsolutePath() { - IPath projectRelativePath = this.getContainerFullPath().makeRelativeTo(this.getProject().getFullPath()); - IResource directory = (projectRelativePath.isEmpty()) ? - this.getProject() : - this.getProject().getFile(projectRelativePath); - return directory.getLocation(); - } - -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java deleted file mode 100644 index 977d6d809a..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java +++ /dev/null @@ -1,267 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2010, 2011 Oracle. 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: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.wizards.schemagen; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.resources.WorkspaceJob; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubMonitor; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jpt.common.utility.internal.ArrayTools; -import org.eclipse.jpt.common.utility.internal.FileTools; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.jaxb.core.internal.gen.SchemaGenerator; -import org.eclipse.jpt.jaxb.core.internal.operations.SchemaFileCreationDataModelProvider; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; -import org.eclipse.osgi.util.NLS; -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbench; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider; - -/** - * SchemaGeneratorWizard - */ -public class SchemaGeneratorWizard extends Wizard implements INewWizard -{ - protected IStructuredSelection initialSelection; - private IJavaProject targetProject; - - protected IDataModel dataModel; - - private NewSchemaFileWizardPage newSchemaFileWizardPage; - - private SchemaGeneratorWizardPage schemaGenWizardPage; - - public static final String XSD_EXTENSION = ".xsd"; //$NON-NLS-1$ - - // ********** constructor ********** - - public SchemaGeneratorWizard() { - super(); - setWindowTitle(JptJaxbUiMessages.SchemaGeneratorWizard_title); - setDefaultPageImageDescriptor(JptJaxbUiPlugin.getImageDescriptor(JptJaxbUiIcons.SCHEMA_GEN_WIZ_BANNER)); - } - - public void init(IWorkbench workbench, IStructuredSelection selection) { - this.initialSelection = selection; - - if (selection == null || selection.isEmpty()) { - return; - } - this.targetProject = this.getProjectFromInitialSelection(); - this.dataModel = null; - } - - // ********** IWizard implementation ********** - - @Override - public void addPages() { - super.addPages(); - - this.newSchemaFileWizardPage = this.buildNewSchemaFileWizardPage(this.initialSelection); - this.addPage(this.newSchemaFileWizardPage); - - this.schemaGenWizardPage = this.buildSchemaGeneratorWizardPage(this.buildSelection(this.getProject())); - this.addPage(this.schemaGenWizardPage); - } - - @Override - public boolean performFinish() { - - this.targetProject = this.getJavaProject(); - - String[] sourceClassNames = this.buildSourceClassNames(this.getAllCheckedItems()); - - WorkspaceJob genSchemaJob = new GenerateSchemaJob( - this.targetProject, - sourceClassNames, - this.getTargetSchema(), - this.usesMoxy()); - genSchemaJob.schedule(); - - return true; - } - - // ********** intra-wizard methods ********** - - public IJavaProject getJavaProject() { - return this.getJavaProjectFrom(this.getProject()); - } - - // ********** internal methods ********** - - private IProject getProject() { - return this.newSchemaFileWizardPage.getProject(); - } - - private IJavaProject getProjectFromInitialSelection() { - IJavaProject project = null; - - Object firstElement = this.initialSelection.getFirstElement(); - if(firstElement instanceof IJavaElement) { - IJavaElement javaElement = (IJavaElement)firstElement; - int type = javaElement.getElementType(); - if(type == IJavaElement.JAVA_PROJECT) { - project = (IJavaProject)javaElement; - } - else if(type == IJavaElement.PACKAGE_FRAGMENT) { - project = ((IPackageFragment)javaElement).getJavaProject(); - } - } - return project; - } - - private IJavaProject getJavaProjectFrom(IProject project) { - IJavaProject javaProject = (IJavaProject)((IJavaElement)((IAdaptable)project).getAdapter(IJavaElement.class)); - if(javaProject == null) { - throw new RuntimeException("Not a Java Project"); //$NON-NLS-1$ - } - return javaProject; - } - - private String getTargetSchema() { - - IPath filePath = this.newSchemaFileWizardPage.getFilePath(); - String fileName = this.newSchemaFileWizardPage.getFileName(); - String targetSchema = filePath.toOSString() + File.separator + fileName; - if ( ! FileTools.extension(targetSchema).equalsIgnoreCase(XSD_EXTENSION)) { - targetSchema += XSD_EXTENSION; - } - - return this.makeRelativeToProjectPath(targetSchema); - } - - private String makeRelativeToProjectPath(String filePath) { - Path path = new Path(filePath); - IPath relativePath = path.makeRelativeTo(this.targetProject.getProject().getLocation()); - return relativePath.removeFirstSegments(1).toOSString(); - } - - private Object[] getAllCheckedItems() { - return this.schemaGenWizardPage.getAllCheckedItems(); - } - - private String[] buildSourceClassNames(Object[] checkedElements) { - - ArrayList<String> classNames = new ArrayList<String>(); - - for(Object element: checkedElements) { - IJavaElement javaElement = (IJavaElement)element; - String packageName = javaElement.getParent().getElementName(); - String elementName = javaElement.getElementName(); - String className = FileTools.stripExtension(elementName); - if(StringTools.stringIsEmpty(packageName)) { - classNames.add(className); - } - else { - classNames.add(packageName + '.' + className); - } - } - - return ArrayTools.array(classNames, new String[0]); - } - - private boolean usesMoxy() { - return this.schemaGenWizardPage.usesMoxy(); - } - - protected NewSchemaFileWizardPage buildNewSchemaFileWizardPage(IStructuredSelection selection) { - return new NewSchemaFileWizardPage( - "Page_1", selection, this.getDataModel(), //$NON-NLS-1$ - JptJaxbUiMessages.SchemaGeneratorProjectWizardPage_title, - JptJaxbUiMessages.SchemaGeneratorProjectWizardPage_desc); - } - - protected SchemaGeneratorWizardPage buildSchemaGeneratorWizardPage(IStructuredSelection selection) { - return new SchemaGeneratorWizardPage(selection); - } - - private IStructuredSelection buildSelection(IProject project) { - - List<IAdaptable> selectedElements = new ArrayList<IAdaptable>(1); - this.addProjectTo(selectedElements, project); - return new StructuredSelection(selectedElements); - } - - private void addProjectTo(List<IAdaptable> selectedElements, IProject project) { - try { - if(project != null && project.hasNature(JavaCore.NATURE_ID)) - selectedElements.add(JavaCore.create(project)); - } - catch(CoreException ex) { - // ignore selected element - } - } - - protected IDataModel getDataModel() { - if (this.dataModel == null) { - this.dataModel = DataModelFactory.createDataModel(getDefaultProvider()); - } - return this.dataModel; - } - - protected IDataModelProvider getDefaultProvider() { - return new SchemaFileCreationDataModelProvider(); - } - - // ********** generate schema job ********** - - static class GenerateSchemaJob extends WorkspaceJob { - private final IJavaProject javaProject; - private final String[] sourceClassNames; - private final String targetSchema; - private final boolean useMoxy; - - GenerateSchemaJob(IJavaProject project, String[] sourceClassNames, String targetSchema, boolean useMoxy) { - super(JptJaxbUiMessages.SchemaGeneratorWizard_generatingSchema); - - this.javaProject = project ; - this.sourceClassNames = sourceClassNames; - this.targetSchema = targetSchema; - this.useMoxy = useMoxy; - - this.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(this.javaProject.getProject())); - } - - @Override - public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { - SubMonitor sm = SubMonitor.convert(monitor, NLS.bind(JptJaxbUiMessages.SchemaGeneratorWizard_generateSchemaTask, this.targetSchema), 1); - try { - SchemaGenerator.generate(this.javaProject, this.targetSchema, this.sourceClassNames, this.useMoxy, sm.newChild(1)); - } - catch (OperationCanceledException e) { - return Status.CANCEL_STATUS; - } - return Status.OK_STATUS; - } - } -}
\ No newline at end of file diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizardPage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizardPage.java deleted file mode 100644 index 70aa054611..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizardPage.java +++ /dev/null @@ -1,439 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2010 Oracle. 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: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.internal.wizards.schemagen; - -import java.util.Iterator; - -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.ui.JavaElementComparator; -import org.eclipse.jdt.ui.JavaElementLabelProvider; -import org.eclipse.jdt.ui.ProblemsLabelDecorator; -import org.eclipse.jdt.ui.StandardJavaElementContentProvider; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.DecoratingLabelProvider; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jpt.common.utility.internal.ArrayTools; -import org.eclipse.jpt.jaxb.core.internal.gen.SchemaGenerator; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; -import org.eclipse.jpt.jaxb.ui.internal.filters.ContainerFilter; -import org.eclipse.jpt.jaxb.ui.internal.filters.EmptyInnerPackageFilter; -import org.eclipse.jpt.jaxb.ui.internal.filters.NonArchiveOrExternalElementFilter; -import org.eclipse.jpt.jaxb.ui.internal.filters.NonContainerFilter; -import org.eclipse.jpt.jaxb.ui.internal.filters.NonJavaElementFilter; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.PlatformUI; -import org.osgi.framework.Bundle; - -/** - * SchemaGeneratorWizardPage - */ -public class SchemaGeneratorWizardPage extends AbstractJarDestinationWizardPage { - - private IJavaProject targetProject; - - // widgets - private SettingsGroup settingsGroup; - private NonContainerFilter projectFilter; - - private Button usesMoxyCheckBox; - private boolean usesMoxy; - - static public String JPT_ECLIPSELINK_UI_PLUGIN_ID = "org.eclipse.jpt.jpa.eclipselink.ui"; //$NON-NLS-1$ - - // other constants - private static final int SIZING_SELECTION_WIDGET_WIDTH = 480; - private static final int SIZING_SELECTION_WIDGET_HEIGHT = 150; - - public static final String HELP_CONTEXT_ID = "org.eclipse.jpt.ui.wizard_jaxbschema_classes"; //$NON-NLS-1$ - - // ********** constructor ********** - - public SchemaGeneratorWizardPage(IStructuredSelection selection) { - super("JAXB Schema Generator", selection, null); //$NON-NLS-1$ - - this.setUsesMoxy(false); - this.setTitle(JptJaxbUiMessages.SchemaGeneratorWizardPage_title); - this.setDescription(JptJaxbUiMessages.SchemaGeneratorWizardPage_desc); - } - - // ********** IDialogPage implementation ********** - @Override - public void createControl(Composite parent) { - this.setPageComplete(false); - this.setControl(this.buildTopLevelControl(parent)); - } - - @Override - public void setVisible(boolean visible) { - super.setVisible(visible); - - if(visible) { - this.updateTargetProject(); - this.updateInputGroupTreeFilter(); - - // default usesMoxy to true only when JPT EclipseLink bundle exists and MOXy is on the classpath - this.updateUsesMoxy(this.jptEclipseLinkBundleExists() && this.moxyIsOnClasspath()); - - // checkbox visible only if jpt.eclipselink.ui plugin is available - // and EclipseLink MOXy is not on the classpath - this.usesMoxyCheckBox.setVisible(this.jptEclipseLinkBundleExists() && ! this.moxyIsOnClasspath()); - - this.validateProjectClasspath(); - } - } - - // ********** IWizardPage implementation ********** - - @Override - public boolean isPageComplete() { - boolean complete = this.validateSourceGroup(); - if(complete) { - this.validateProjectClasspath(); - } - return complete; - } - - @Override - public void setPreviousPage(IWizardPage page) { - super.setPreviousPage(page); - if(this.getControl() != null) - this.updatePageCompletion(); - } - - // ********** intra-wizard methods ********** - - protected Object[] getAllCheckedItems() { - return ArrayTools.array(this.getInputGroup().getAllCheckedListItems()); - } - - protected boolean usesMoxy() { - return this.usesMoxy; - } - - // ********** validation ********** - - @Override - @SuppressWarnings("restriction") - protected void updatePageCompletion() { - super.updatePageCompletion(); - } - - @Override - protected boolean validateDestinationGroup() { - // do nothing - return true; - } - - @Override - protected boolean validateSourceGroup() { - if(this.getAllCheckedItems().length == 0) { - if(this.getErrorMessage() == null) { - this.setErrorMessage(JptJaxbUiMessages.SchemaGeneratorWizardPage_errorNoPackage); - } - return false; - } - this.setErrorMessage(null); - return true; - } - - private void validateProjectClasspath() { - if(this.targetProject == null) { // project selected available yet - return; - } - //this line will suppress the "default package" warning (which doesn't really apply here - //as the JAXB gen uses an org.example.schemaName package by default) and will clear the classpath warnings when necessary - setMessage(null); - - if( ! this.genericJaxbIsOnClasspath()) { - this.displayWarning(JptJaxbUiMessages.SchemaGeneratorWizardPage_jaxbLibrariesNotAvailable); - } - else if(this.usesMoxy() && ! this.moxyIsOnClasspath()) { - //this message is being truncated by the wizard width in some cases - this.displayWarning(JptJaxbUiMessages.SchemaGeneratorWizardPage_moxyLibrariesNotAvailable); - } - - //this code will intelligently remove our classpath warnings when they are present but no longer apply (as an alternative - //to setting the message to null continuously as is currently done) -// else if( this.getMessage() != null){ -// if (this.getMessage().equals(JptJaxbUiMessages.ClassesGeneratorWizardPage_jaxbLibrariesNotAvailable) || -// this.getMessage().equals(JptJaxbUiMessages.ClassesGeneratorWizardPage_moxyLibrariesNotAvailable)) { -// setMessage(null); -// } -// } - } - - /** - * Test if the Jaxb compiler is on the classpath. - */ - private boolean genericJaxbIsOnClasspath() { - try { - String className = SchemaGenerator.JAXB_GENERIC_SCHEMA_GEN_CLASS; - IType genClass = this.targetProject.findType(className); - return (genClass != null); - } - catch(JavaModelException e) { - throw new RuntimeException(e); - } - } - - // ********** internal methods ********** - - private Control buildTopLevelControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout()); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, HELP_CONTEXT_ID); - - this.settingsGroup = new SettingsGroup(composite); - - this.usesMoxyCheckBox = this.buildUsesMoxyCheckBox(composite); - - Dialog.applyDialogFont(parent); - return composite; - } - - private void updateTargetProject() { - - this.targetProject = ((SchemaGeneratorWizard)this.getWizard()).getJavaProject(); - } - - private void updateInputGroupTreeFilter() { - this.getInputGroup().setAllSelections(false); - - if(this.projectFilter != null) { - this.getInputGroup().removeTreeFilter(this.projectFilter); - } - this.projectFilter = new NonContainerFilter(this.targetProject.getProject().getName()); - this.getInputGroup().addTreeFilter(this.projectFilter); - } - - private boolean jptEclipseLinkBundleExists() { - return (this.getJptEclipseLinkBundle() != null); - } - - private Bundle getJptEclipseLinkBundle() { - return Platform.getBundle(JPT_ECLIPSELINK_UI_PLUGIN_ID); // Cannot reference directly EL plugin. - } - - private void setUsesMoxy(boolean usesMoxy){ - this.usesMoxy = usesMoxy; - } - - private void updateUsesMoxy(boolean usesMoxy){ - this.setUsesMoxy(usesMoxy); - this.usesMoxyCheckBox.setSelection(this.usesMoxy()); - this.validateProjectClasspath(); - } - - /** - * Test if the EclipseLink Jaxb compiler is on the classpath. - */ - private boolean moxyIsOnClasspath() { - try { - String className = SchemaGenerator.JAXB_ECLIPSELINK_SCHEMA_GEN_CLASS; - IType genClass = this.targetProject.findType(className); - return (genClass != null); - } - catch (JavaModelException e) { - throw new RuntimeException(e); - } - } - - private void displayWarning(String message) { - this.setMessage(message, WARNING); - } - - private CheckboxTreeAndListGroup getInputGroup() { - return this.settingsGroup.inputGroup; - } - - // ********** overrides ********** - /** - * Returns an iterator over this page's collection of currently-specified - * elements to be exported. This is the primary element selection facility - * accessor for subclasses. - * - * @return an iterator over the collection of elements currently selected for export - */ - @Override - protected Iterator<?> getSelectedResourcesIterator() { - return this.getInputGroup().getAllCheckedListItems(); - } - - @Override - protected void update() { - this.updatePageCompletion(); - } - - @Override - public final void saveWidgetValues() { - // do nothing - } - - @Override - protected void internalSaveWidgetValues() { - // do nothing - } - - @Override - protected void restoreWidgetValues() { - // do nothing - } - - - @Override - protected void initializeJarPackage() { - // do nothing - } - - @Override - protected void giveFocusToDestination() { - // do nothing - } - - // ********** UI components ********** - - private Button buildUsesMoxyCheckBox(Composite parent) { - - Button checkBox = new Button(parent, SWT.CHECK); - GridData gridData = new GridData(); - gridData.verticalIndent = 10; - checkBox.setLayoutData(gridData); - checkBox.setText(JptJaxbUiMessages.ClassesGeneratorWizardPage_usesMoxyImplementation); - checkBox.setSelection(this.usesMoxy()); - checkBox.addSelectionListener(this.buildUsesMoxySelectionListener()); - - return checkBox; - } - - private SelectionListener buildUsesMoxySelectionListener() { - return new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - this.widgetSelected(event); - } - - public void widgetSelected(SelectionEvent event) { - updateUsesMoxy(usesMoxyCheckBox.getSelection()); - validateProjectClasspath(); - } - }; - } - - // ********** SettingsGroup class ********** - - private class SettingsGroup { - - private CheckboxTreeAndListGroup inputGroup; - - // ********** constructor ********** - - private SettingsGroup(Composite parent) { - super(); - initializeDialogUnits(parent); - - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - layout.marginHeight = 0; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - buildSchemaComposite(composite); - - // Input Tree - createPlainLabel(composite, JptJaxbUiMessages.SchemaGeneratorWizardPage_packages); - this.inputGroup = this.createInputGroup(composite); - - } - - protected void buildSchemaComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(3, false); // false = do not make columns equal width - layout.marginWidth = 0; - layout.marginTop = 0; - layout.marginBottom = 10; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - } - - // ********** UI components ********** - - /** - * Creates the checkbox tree and list for selecting resources. - * - * @param parent the parent control - */ - protected CheckboxTreeAndListGroup createInputGroup(Composite parent) { - CheckboxTreeAndListGroup checkboxTreeGroup; - - int labelFlags = JavaElementLabelProvider.SHOW_BASICS - | JavaElementLabelProvider.SHOW_OVERLAY_ICONS - | JavaElementLabelProvider.SHOW_SMALL_ICONS; - ITreeContentProvider treeContentProvider= - new StandardJavaElementContentProvider() { - @Override - public boolean hasChildren(Object element) { - // prevent the + from being shown in front of packages - return !(element instanceof IPackageFragment) && super.hasChildren(element); - } - }; - final DecoratingLabelProvider provider = new DecoratingLabelProvider(new JavaElementLabelProvider(labelFlags), new ProblemsLabelDecorator(null)); - checkboxTreeGroup = new CheckboxTreeAndListGroup( - parent, - JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()), - treeContentProvider, - provider, - new StandardJavaElementContentProvider(), - provider, - SWT.NONE, - SIZING_SELECTION_WIDGET_WIDTH, - SIZING_SELECTION_WIDGET_HEIGHT); - checkboxTreeGroup.addTreeFilter(new EmptyInnerPackageFilter()); - checkboxTreeGroup.setTreeComparator(new JavaElementComparator()); - checkboxTreeGroup.setListComparator(new JavaElementComparator()); - - checkboxTreeGroup.addTreeFilter(new NonJavaElementFilter()); - checkboxTreeGroup.addTreeFilter(new NonArchiveOrExternalElementFilter()); - - checkboxTreeGroup.addListFilter(new ContainerFilter()); - checkboxTreeGroup.addListFilter(new NonJavaElementFilter()); - - checkboxTreeGroup.getTree().addListener(SWT.MouseUp, SchemaGeneratorWizardPage.this); - checkboxTreeGroup.getTable().addListener(SWT.MouseUp, SchemaGeneratorWizardPage.this); - - ICheckStateListener listener = new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - update(); - } - }; - - checkboxTreeGroup.addCheckStateListener(listener); - return checkboxTreeGroup; - } - } -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/navigator/JaxbNavigatorUi.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/navigator/JaxbNavigatorUi.java deleted file mode 100644 index 2db5a2e7aa..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/navigator/JaxbNavigatorUi.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. 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: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.navigator; - -import org.eclipse.jpt.common.ui.jface.ItemLabelProvider; -import org.eclipse.jpt.common.ui.jface.ItemLabelProviderFactory; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProvider; -import org.eclipse.jpt.common.ui.jface.TreeItemContentProviderFactory; - -/** - * Defines content and label provider factories for Project Navigator view for a given JAXB project. - * <p> - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - * - * @version 3.0 - * @since 3.0 - */ -public interface JaxbNavigatorUi { - - /** - * Return the factory to create {@link TreeItemContentProvider}s - */ - TreeItemContentProviderFactory getTreeItemContentProviderFactory(); - - /** - * Return the factory to create {@link ItemLabelProvider}s - */ - ItemLabelProviderFactory getItemLabelProviderFactory(); -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/platform/JaxbPlatformUi.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/platform/JaxbPlatformUi.java deleted file mode 100644 index e50e9ee980..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/platform/JaxbPlatformUi.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. 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: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.platform; - -import org.eclipse.jpt.jaxb.ui.navigator.JaxbNavigatorUi; - -/** - * This interface is to be implemented by a JAXB implementation vendor to provide extensions - * to JAXB UI functionality. - * <p> - * Any implementation should be <i>stateless</i> in nature. - * <p> - * See the extension point: org.eclipse.jpt.jaxb.ui.jaxbPlatforms - * <p> - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - * - * @version 3.0 - * @since 3.0 - */ -public interface JaxbPlatformUi { - - // ********** navigator UI ********** - - /** - * Return the {@link JaxbNavigatorUi} for this platform, - * which determines Project Explorer content - */ - JaxbNavigatorUi getNavigatorUi(); -} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/platform/JaxbPlatformUiManager.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/platform/JaxbPlatformUiManager.java deleted file mode 100644 index 1f04ed438d..0000000000 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/platform/JaxbPlatformUiManager.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. 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: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jaxb.ui.platform; - -import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; - -/** - * Repository for {@link JaxbPlatformUi}s - * <p> - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - * - * @version 3.0 - * @since 3.0 - * @see JptJaxbUiPlugin#getJaxbPlatformUiManager() - */ -public interface JaxbPlatformUiManager { - - /** - * Return the platform UI responsible for providing UI elements for the given - * JAXB platform description - */ - public JaxbPlatformUi getJaxbPlatformUi(JaxbPlatformDescription platformDesc); -} |