From 9b023b56fec9a4df916ed5e18ba2a55d324112c4 Mon Sep 17 00:00:00 2001 From: rescobar Date: Tue, 30 Aug 2011 09:40:59 -0700 Subject: feature[ats_M1Y56]: Remove Osee Types Import Wizard --- .../plugin.xml | 13 - .../ui/integration/operations/ExcelToEMFModel.java | 357 --------------------- .../operations/ResolveImportsOperation.java | 99 ------ .../dsl/ui/integration/wizards/LinkMessage.java | 29 -- .../core/dsl/ui/integration/wizards/LinkNode.java | 60 ---- .../wizards/LinkNodeContentProvider.java | 60 ---- .../integration/wizards/LinkNodeLabelProvider.java | 53 --- .../integration/wizards/NewOseeTypesFilePage.java | 143 --------- .../integration/wizards/OseeTypesImportPage.java | 261 --------------- .../integration/wizards/OseeTypesImportWizard.java | 69 ---- .../integration/wizards/OseeTypesViewerFilter.java | 73 ----- .../integration/wizards/SelectOseeTypesPanel.java | 92 ------ 12 files changed, 1309 deletions(-) delete mode 100644 plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/ExcelToEMFModel.java delete mode 100644 plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/ResolveImportsOperation.java delete mode 100644 plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/LinkMessage.java delete mode 100644 plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/LinkNode.java delete mode 100644 plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/LinkNodeContentProvider.java delete mode 100644 plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/LinkNodeLabelProvider.java delete mode 100644 plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/NewOseeTypesFilePage.java delete mode 100644 plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/OseeTypesImportPage.java delete mode 100644 plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/OseeTypesImportWizard.java delete mode 100644 plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/OseeTypesViewerFilter.java delete mode 100644 plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/SelectOseeTypesPanel.java (limited to 'plugins/org.eclipse.osee.framework.core.dsl.ui.integration') diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/plugin.xml b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/plugin.xml index ba2852cf790..09b15197b85 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/plugin.xml +++ b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/plugin.xml @@ -1,19 +1,6 @@ - - - - Imports OSEE Types - - - oseeModels; - private OseeDsl currentModel; - - public ExcelToEMFModel(Map oseeModels) { - this.factory = OseeDslFactory.eINSTANCE; - this.oseeModels = oseeModels; - } - - public void createModel(String name) { - currentModel = factory.createOseeDsl(); - oseeModels.put(name, currentModel); - } - - private OseeDsl getCurrentModel() { - return currentModel; - } - - private String toQualifiedName(String name) { - return "\"" + name + "\""; - } - - private OseeType getObject(String name, Class classToLookFor) throws OseeArgumentException { - EList types; - - if (classToLookFor.equals(XArtifactType.class)) { - types = getCurrentModel().getArtifactTypes(); - } else if (classToLookFor.equals(XAttributeType.class)) { - types = getCurrentModel().getAttributeTypes(); - } else if (classToLookFor.equals(XRelationType.class)) { - types = getCurrentModel().getRelationTypes(); - } else if (classToLookFor.equals(XOseeEnumType.class)) { - types = getCurrentModel().getEnumTypes(); - } else { - throw new OseeArgumentException("[%s] not a supported type", classToLookFor.getName()); - } - for (OseeType oseeTypes : types) { - if (name.equals(oseeTypes.getName())) { - return classToLookFor.cast(oseeTypes); - } - } - return null; - } - - @Override - public void onArtifactTypeInheritance(String ancestor, Collection descendants) throws OseeCoreException { - XArtifactType ancestorType = (XArtifactType) getObject(ancestor, XArtifactType.class); - if (ancestorType == null) { - throw new OseeInvalidInheritanceException("Ancestor [%s]", ancestor); - } - - // if (superArtifactTypeName != null) { - // ArtifactType superArtifactType = (ArtifactType) getObject(superArtifactTypeName, ArtifactType.class); - // if (superArtifactType == null) { - // boolean isAbstractSuper = false; - // onArtifactType(isAbstractSuper, superArtifactTypeName, null); - // superArtifactType = (ArtifactType) getObject(superArtifactTypeName, ArtifactType.class); - // } - // artifactType.setSuperArtifactType(superArtifactType); - // } - } - - @Override - public void onArtifactType(boolean isAbstract, String name) throws OseeCoreException { - String id = toQualifiedName(name); - OseeType types = getObject(id, XArtifactType.class); - if (types == null) { - XArtifactType artifactType = factory.createXArtifactType(); - artifactType.setName(id); - getCurrentModel().getArtifactTypes().add(artifactType); - } - } - - @Override - public void onAttributeType(String attributeBaseType, String attributeProviderTypeName, String fileTypeExtension, String name, String defaultValue, String validityXml, int minOccurrence, int maxOccurrence, String toolTipText, String taggerId) throws OseeCoreException { - String id = toQualifiedName(name); - OseeType types = getObject(id, XAttributeType.class); - if (types == null) { - XAttributeType attributeType = factory.createXAttributeType(); - attributeType.setName(id); - attributeType.setBaseAttributeType(Lib.getExtension(attributeBaseType)); - attributeType.setDataProvider(Lib.getExtension(attributeProviderTypeName)); - attributeType.setMin(String.valueOf(minOccurrence)); - - String maxValue; - if (maxOccurrence == Integer.MAX_VALUE) { - maxValue = "unlimited"; - } else { - maxValue = String.valueOf(maxOccurrence); - } - attributeType.setMax(maxValue); - - if (Strings.isValid(fileTypeExtension)) { - attributeType.setFileExtension(fileTypeExtension); - } - if (Strings.isValid(defaultValue)) { - attributeType.setDefaultValue(defaultValue); - } - if (Strings.isValid(toolTipText)) { - attributeType.setDescription(toolTipText); - } - if (Strings.isValid(taggerId)) { - attributeType.setTaggerId(taggerId); - } - - XOseeEnumType enumType = getEnumType(attributeBaseType, attributeProviderTypeName, name, validityXml); - if (enumType != null) { - attributeType.setEnumType(enumType); - } - getCurrentModel().getAttributeTypes().add(attributeType); - } - } - - @Override - public boolean doesArtifactSuperTypeExist(String artifactSuperTypeName) throws OseeCoreException { - return getObject(artifactSuperTypeName, XArtifactType.class) != null; - } - - @Override - public void onAttributeValidity(String attributeName, String artifactSuperTypeName, Collection concreteTypes) throws OseeCoreException { - XArtifactType superArtifactType = - (XArtifactType) getObject(toQualifiedName(artifactSuperTypeName), XArtifactType.class); - XAttributeType attributeType = (XAttributeType) getObject(toQualifiedName(attributeName), XAttributeType.class); - - if (superArtifactType == null && "Artifact".equals(artifactSuperTypeName)) { - onArtifactType(false, "Artifact"); - superArtifactType = (XArtifactType) getObject(toQualifiedName(artifactSuperTypeName), XArtifactType.class); - } - - if (superArtifactType == null || attributeType == null) { - throw new OseeStateException("Type Missing: %s - %s", artifactSuperTypeName, attributeName); - } - XAttributeTypeRef reference = factory.createXAttributeTypeRef(); - reference.setValidAttributeType(attributeType); - superArtifactType.getValidAttributeTypes().add(reference); - } - - @Override - public void onRelationType(String name, String sideAName, String sideBName, String artifactTypeSideA, String artifactTypeSideB, String multiplicity, String ordered, String defaultOrderTypeGuid) throws OseeCoreException { - String id = toQualifiedName(name); - OseeType types = getObject(id, XRelationType.class); - if (types == null) { - XRelationType relationType = factory.createXRelationType(); - relationType.setName(id); - relationType.setSideAName(sideAName); - relationType.setSideBName(sideBName); - - String arranger; - if ("Yes".equals(ordered)) { - arranger = "Lexicographical_Ascending"; - } else { - arranger = "Unordered"; - } - relationType.setDefaultOrderType(arranger); - getCurrentModel().getRelationTypes().add(relationType); - } - } - - @Override - public void onRelationValidity(String artifactTypeName, String relationTypeName, int sideAMax, int sideBMax) throws OseeCoreException { - XRelationType relationType = (XRelationType) getObject(toQualifiedName(relationTypeName), XRelationType.class); - XArtifactType artifactType = (XArtifactType) getObject(toQualifiedName(artifactTypeName), XArtifactType.class); - - if (sideAMax > 0) { - relationType.setSideAArtifactType(artifactType); - } - if (sideBMax > 0) { - relationType.setSideBArtifactType(artifactType); - } - - RelationMultiplicityEnum multiplicity = relationType.getMultiplicity(); - if (sideAMax == Integer.MAX_VALUE && sideBMax == 1) { - multiplicity = RelationMultiplicityEnum.ONE_TO_MANY; - - } else if (sideAMax == 1 && sideBMax == Integer.MAX_VALUE) { - multiplicity = RelationMultiplicityEnum.MANY_TO_ONE; - - } else if (sideAMax == Integer.MAX_VALUE && sideBMax == Integer.MAX_VALUE) { - multiplicity = RelationMultiplicityEnum.MANY_TO_MANY; - } else if (sideAMax == 1 && sideBMax == 1) { - multiplicity = RelationMultiplicityEnum.ONE_TO_ONE; - } else { - System.out.println("None detected - " + relationTypeName); - } - - if (multiplicity != null && !multiplicity.equals(relationType.getMultiplicity())) { - relationType.setMultiplicity(multiplicity); - } else { - System.out.println("Null multiplicity - " + relationTypeName); - } - } - - private static void checkEnumTypeName(String enumTypeName) throws OseeCoreException { - if (!Strings.isValid(enumTypeName)) { - throw new OseeArgumentException("Osee Enum Type Name cannot be null."); - } - } - - private XOseeEnumType getEnumType(String attributeBaseType, String attributeProviderTypeName, String name, String validityXml) throws OseeCoreException { - Class> baseAttributeClass = - AttributeExtensionManager.getAttributeClassFor(attributeBaseType); - - XOseeEnumType oseeEnumType = null; - if (EnumeratedAttribute.class.isAssignableFrom(baseAttributeClass)) { - createEnumTypeFromXml(toQualifiedEnumName(name), validityXml); - } - return oseeEnumType; - } - - private String toQualifiedEnumName(String name) { - return "\"" + name + ".enum\""; - } - - private XOseeEnumType createEnumTypeFromXml(String attributeTypeName, String xmlDefinition) throws OseeCoreException { - List> entries = new ArrayList>(); - String enumTypeName = ""; - - if (!Strings.isValid(xmlDefinition)) { - throw new OseeArgumentException("The enum xml definition must not be null or empty"); - } - - Document document = null; - try { - document = Jaxp.readXmlDocument(xmlDefinition); - } catch (Exception ex) { - OseeExceptions.wrapAndThrow(ex); - } - enumTypeName = attributeTypeName; - Element choicesElement = document.getDocumentElement(); - NodeList enumerations = choicesElement.getChildNodes(); - Set choices = new LinkedHashSet(); - - for (int i = 0; i < enumerations.getLength(); i++) { - Node node = enumerations.item(i); - if (node.getNodeName().equalsIgnoreCase("Enum")) { - choices.add(node.getTextContent()); - } else { - throw new OseeArgumentException("Validity Xml not of excepted enum format"); - } - } - - int ordinal = 0; - for (String choice : choices) { - entries.add(new Pair(choice, ordinal++)); - } - - return createEnumType(enumTypeName, entries); - } - - private XOseeEnumType createEnumType(String enumTypeName, List> entries) throws OseeCoreException { - checkEnumTypeName(enumTypeName); - checkEntryIntegrity(enumTypeName, entries); - - XOseeEnumType oseeEnumType = null; - - OseeType types = getObject(enumTypeName, XOseeEnumType.class); - if (types == null) { - oseeEnumType = factory.createXOseeEnumType(); - oseeEnumType.setName(enumTypeName); - - for (Pair entry : entries) { - XOseeEnumEntry oseeEnum = factory.createXOseeEnumEntry(); - oseeEnum.setName(entry.getFirst()); - oseeEnum.setOrdinal(String.valueOf(entry.getSecond())); - oseeEnumType.getEnumEntries().add(oseeEnum); - } - getCurrentModel().getEnumTypes().add(oseeEnumType); - } else { - oseeEnumType = (XOseeEnumType) types; - } - return oseeEnumType; - } - - private static void checkEntryIntegrity(String enumTypeName, List> entries) throws OseeCoreException { - if (entries == null) { - throw new OseeArgumentException("Osee Enum Type [%s] had null entries", enumTypeName); - } - - // if (entries.size() <= 0) throw new OseeArgumentException("Osee Enum Type [%s] had 0 entries", - // enumTypeName); - Map values = new HashMap(); - for (Pair entry : entries) { - String name = entry.getFirst(); - int ordinal = entry.getSecond(); - if (!Strings.isValid(name)) { - throw new OseeArgumentException("Enum entry name cannot be null"); - } - if (ordinal < 0) { - throw new OseeArgumentException("Enum entry ordinal cannot be of negative value"); - } - if (values.containsKey(name)) { - throw new OseeArgumentException("Unique enum entry name violation - [%s] already exists.", name); - } - if (values.containsValue(ordinal)) { - throw new OseeArgumentException("Unique enum entry ordinal violation - [%s] already exists.", ordinal); - } - values.put(name, ordinal); - } - } - - @Override - public void onFinish() { - - } -} diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/ResolveImportsOperation.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/ResolveImportsOperation.java deleted file mode 100644 index 44b9670d719..00000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/ResolveImportsOperation.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 Boeing. - * 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: - * Boeing - initial API and implementation - *******************************************************************************/ -package org.eclipse.osee.framework.core.dsl.ui.integration.operations; - -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.common.util.URI; -import org.eclipse.osee.framework.core.dsl.ui.integration.internal.Activator; -import org.eclipse.osee.framework.core.dsl.ui.integration.wizards.LinkMessage; -import org.eclipse.osee.framework.core.dsl.ui.integration.wizards.LinkNode; -import org.eclipse.osee.framework.core.operation.AbstractOperation; -import org.eclipse.osee.framework.jdk.core.util.Lib; -import org.eclipse.xtext.resource.IClasspathUriResolver; - -/** - * @author Roberto E. Escobar - */ -public class ResolveImportsOperation extends AbstractOperation { - private final Pattern pattern = Pattern.compile("\\s*import\\s+\"(.*?)\""); - private final List selectedItems; - private final Matcher matcher; - private final IClasspathUriResolver resolver; - private final List dependencyData; - - public ResolveImportsOperation(IClasspathUriResolver resolver, List selectedItems, List dependencyData) { - super("Extract imports", Activator.PLUGIN_ID); - this.matcher = pattern.matcher(""); - this.selectedItems = selectedItems; - this.resolver = resolver; - this.dependencyData = dependencyData; - } - - @Override - protected void doWork(IProgressMonitor monitor) throws Exception { - if (!selectedItems.isEmpty()) { - double workPercentage = 1.0 / selectedItems.size(); - for (IFile selectedFile : selectedItems) { - URI uri = URI.createURI(selectedFile.getLocationURI().toASCIIString()); - LinkNode node = new LinkNode(uri); - dependencyData.add(node); - resolveImports(node); - } - monitor.worked(calculateWork(workPercentage)); - } - } - - private void resolveImports(LinkNode node) throws IOException { - if (node.getUri() != null) { - Set requiredImports = null; - try { - requiredImports = getImports(node.getUri()); - } catch (IOException ex) { - node.setIsResolved(false); - throw ex; - } - for (String importEntry : requiredImports) { - URI resolved = resolver.resolve((Object) null, URI.createURI(importEntry)); - LinkMessage message = new LinkMessage(resolved, importEntry); - node.addChild(message); - resolveImports(message); - } - } - } - - private Set getImports(URI uri) throws IOException { - Set imports = new HashSet(); - InputStream inputStream = null; - try { - inputStream = new BufferedInputStream(new URL(uri.toString()).openStream()); - String inputString = Lib.inputStreamToString(inputStream); - matcher.reset(inputString); - while (matcher.find()) { - imports.add(matcher.group(1)); - } - } finally { - if (inputStream != null) { - inputStream.close(); - } - } - return imports; - } -} diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/LinkMessage.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/LinkMessage.java deleted file mode 100644 index 96762ddf28e..00000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/LinkMessage.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 Boeing. - * 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: - * Boeing - initial API and implementation - *******************************************************************************/ -package org.eclipse.osee.framework.core.dsl.ui.integration.wizards; - -import org.eclipse.emf.common.util.URI; - -/** - * @author Roberto E. Escobar - */ -public class LinkMessage extends LinkNode { - private final String importEntry; - - public LinkMessage(URI nodeURI, String importEntry) { - super(nodeURI); - this.importEntry = importEntry; - } - - public String getImportEntry() { - return importEntry; - } -} diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/LinkNode.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/LinkNode.java deleted file mode 100644 index 9a1533914dd..00000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/LinkNode.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 Boeing. - * 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: - * Boeing - initial API and implementation - *******************************************************************************/ -package org.eclipse.osee.framework.core.dsl.ui.integration.wizards; - -import java.util.ArrayList; -import java.util.List; -import org.eclipse.emf.common.util.URI; - -/** - * @author Roberto E. Escobar - */ -public class LinkNode { - public LinkNode nodeParent; - public URI nodeURI; - public List children; - public boolean resolved; - - public LinkNode(URI nodeURI) { - this.nodeURI = nodeURI; - this.children = new ArrayList(); - this.resolved = true; - } - - public void addChild(LinkNode node) { - nodeParent = this; - children.add(node); - } - - public URI getUri() { - return nodeURI; - } - - public LinkNode getParent() { - return nodeParent; - } - - public boolean hasChildren() { - return !getChildren().isEmpty(); - } - - public List getChildren() { - return children; - } - - public void setIsResolved(boolean resolved) { - this.resolved = resolved; - } - - public boolean isResolved() { - return resolved; - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/LinkNodeContentProvider.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/LinkNodeContentProvider.java deleted file mode 100644 index 86245d0d8ed..00000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/LinkNodeContentProvider.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 Boeing. - * 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: - * Boeing - initial API and implementation - *******************************************************************************/ -package org.eclipse.osee.framework.core.dsl.ui.integration.wizards; - -import java.util.Collection; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.Viewer; - -/** - * @author Roberto E. Escobar - */ -public class LinkNodeContentProvider implements ITreeContentProvider { - - @Override - public Object[] getChildren(Object element) { - if (element instanceof LinkNode) { - return ((LinkNode) element).getChildren().toArray(); - } else if (element instanceof Collection) { - return ((Collection) element).toArray(); - } - return new Object[0]; - } - - @Override - public Object getParent(Object element) { - if (element instanceof LinkNode) { - return ((LinkNode) element).getParent(); - } - return null; - } - - @Override - public boolean hasChildren(Object element) { - if (element instanceof LinkNode) { - return ((LinkNode) element).hasChildren(); - } - return false; - } - - @Override - public Object[] getElements(Object inputElement) { - return getChildren(inputElement); - } - - @Override - public void dispose() { - } - - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } -} diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/LinkNodeLabelProvider.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/LinkNodeLabelProvider.java deleted file mode 100644 index f1a6b2f70c5..00000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/LinkNodeLabelProvider.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 Boeing. - * 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: - * Boeing - initial API and implementation - *******************************************************************************/ -package org.eclipse.osee.framework.core.dsl.ui.integration.wizards; - -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.osee.framework.ui.skynet.FrameworkImage; -import org.eclipse.osee.framework.ui.swt.ImageManager; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; - -/** - * @author Roberto E. Escobar - */ -public class LinkNodeLabelProvider extends LabelProvider { - - @Override - public Image getImage(Object element) { - Image toReturn = super.getImage(element); - LinkNode node = null; - if (element instanceof LinkNode) { - node = (LinkNode) element; - toReturn = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT); - } - if (element instanceof LinkMessage) { - toReturn = ImageManager.getImage(FrameworkImage.OSEE_TYPES_LINK); - } - if (node != null && !node.isResolved()) { - toReturn = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK); - } - return toReturn; - } - - @Override - public String getText(Object element) { - if (element instanceof LinkMessage) { - return ((LinkMessage) element).getImportEntry(); - } else if (element instanceof LinkNode) { - LinkNode node = (LinkNode) element; - return node.getUri().toFileString(); - } - return super.getText(element); - } - -} diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/NewOseeTypesFilePage.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/NewOseeTypesFilePage.java deleted file mode 100644 index 841613ae021..00000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/NewOseeTypesFilePage.java +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Boeing. - * 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: - * Boeing - initial API and implementation - *******************************************************************************/ -package org.eclipse.osee.framework.core.dsl.ui.integration.wizards; - -import java.io.File; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.osee.framework.jdk.core.util.Strings; -import org.eclipse.osee.framework.ui.plugin.util.DirectoryOrFileSelector; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.dialogs.WizardDataTransferPage; - -public class NewOseeTypesFilePage extends WizardDataTransferPage { - private static final String PAGE_NAME = - "org.eclipse.osee.framework.core.dsl.ui.integration.wizards.NewOseeTypeFilePage"; - - private DirectoryOrFileSelector sourceFileSelector; - private DirectoryOrFileSelector destinationFileSelector; - private Button fromExcel; - private final IResource defaultDestination; - - protected NewOseeTypesFilePage(String title, IResource destination) { - super(PAGE_NAME); - this.defaultDestination = destination; - setTitle(title); - setDescription(title); - } - - @Override - protected boolean allowNewContainerName() { - return false; - } - - @Override - public void handleEvent(Event event) { - updateWidgetEnablements(); - setPageComplete(determinePageCompletion()); - } - - @Override - public void createControl(Composite parent) { - initializeDialogUnits(parent); - - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout(1, false)); - composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - composite.setFont(parent.getFont()); - - destinationFileSelector = new DirectoryOrFileSelector(composite, SWT.NONE, "Destination File", this); - destinationFileSelector.addListener(SWT.Selection, this); - destinationFileSelector.setDirectorySelected(false); - - fromExcel = new Button(composite, SWT.CHECK); - fromExcel.setText("Based on Excel Osee Types"); - fromExcel.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, false, false)); - - sourceFileSelector = new DirectoryOrFileSelector(composite, SWT.NONE, "Excel Source File(s)", this); - sourceFileSelector.addListener(SWT.Selection, this); - sourceFileSelector.setDirectorySelected(false); - - fromExcel.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - sourceFileSelector.setEnabled(fromExcel.getSelection()); - } - }); - - restoreWidgetValues(); - updateWidgetEnablements(); - setPageComplete(determinePageCompletion()); - setControl(composite); - } - - @Override - protected void restoreWidgetValues() { - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - if (defaultDestination != null) { - destinationFileSelector.setDirectorySelected(true); - destinationFileSelector.setText(new File(defaultDestination.getLocationURI()).getAbsolutePath()); - } else { - restoreSelector(settings, "new.osee.types.destination", destinationFileSelector); - } - - restoreSelector(settings, "new.osee.types.source", sourceFileSelector); - } - } - - private void restoreSelector(IDialogSettings settings, String key, DirectoryOrFileSelector selector) { - String file = settings.get("key"); - boolean isSelected = settings.getBoolean(key + ".isDir"); - if (Strings.isValid(file)) { - selector.setText(file); - selector.setDirectorySelected(isSelected); - } - } - - private void saveSelector(IDialogSettings settings, String key, DirectoryOrFileSelector selector) { - File file = selector.getFile(); - if (file != null) { - settings.put(key, file.getAbsolutePath()); - settings.put(key + ".isDir", file.isDirectory()); - } - } - - @Override - protected void saveWidgetValues() { - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - saveSelector(settings, "new.osee.types.source", sourceFileSelector); - saveSelector(settings, "new.osee.types.destination", destinationFileSelector); - } - } - - @Override - public boolean isPageComplete() { - return getSourceFile() != null && getDestinationFile() != null && super.isPageComplete(); - } - - public File getSourceFile() { - return sourceFileSelector.getFile(); - } - - public File getDestinationFile() { - return destinationFileSelector.getFile(); - } -} diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/OseeTypesImportPage.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/OseeTypesImportPage.java deleted file mode 100644 index dd3e4d8463e..00000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/OseeTypesImportPage.java +++ /dev/null @@ -1,261 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 Boeing. - * 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: - * Boeing - initial API and implementation - *******************************************************************************/ -package org.eclipse.osee.framework.core.dsl.ui.integration.wizards; - -import java.io.File; -import java.lang.reflect.InvocationTargetException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Level; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.osee.framework.core.dsl.ui.integration.internal.Activator; -import org.eclipse.osee.framework.core.dsl.ui.integration.operations.ResolveImportsOperation; -import org.eclipse.osee.framework.core.operation.AbstractOperation; -import org.eclipse.osee.framework.core.operation.CompositeOperation; -import org.eclipse.osee.framework.core.operation.IOperation; -import org.eclipse.osee.framework.core.operation.Operations; -import org.eclipse.osee.framework.database.init.OseeTypesSetup; -import org.eclipse.osee.framework.logging.OseeLog; -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.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.dialogs.WizardDataTransferPage; -import org.eclipse.xtext.resource.ClassloaderClasspathUriResolver; - -/** - * @author Roberto E. Escobar - */ -public class OseeTypesImportPage extends WizardDataTransferPage { - private static final String PAGE_NAME = - "org.eclipse.osee.framework.core.dsl.ui.integration.wizards.OseeTypesImportPage"; - - private final OseeTypesSetup oseeTypesSetup; - private File compositeFile; - private final IStructuredSelection selection; - private TreeViewer linksViewer; - private final SelectOseeTypesPanel oseeTypesPanel; - private final List messages; - private Button reportChanges; - private Button persistChanges; - private Button useCompareEditor; - - protected OseeTypesImportPage(IStructuredSelection selection, String title) { - super(PAGE_NAME); - this.selection = selection; - oseeTypesSetup = new OseeTypesSetup(); - oseeTypesPanel = new SelectOseeTypesPanel(); - oseeTypesPanel.setDefaultItem(getPreselected()); - setTitle(title); - setDescription("Select *.osee files to import"); - messages = new ArrayList(); - } - - private List getPreselected() { - List resources = new ArrayList(); - if (selection != null) { - Iterator iterator = selection.iterator(); - while (iterator.hasNext()) { - Object object = iterator.next(); - if (object instanceof IFile) { - IFile file = (IFile) object; - if (file.getFileExtension().equals("osee")) { - resources.add(file); - } - } - } - } - return resources; - } - - @Override - protected boolean allowNewContainerName() { - return false; - } - - @Override - public void handleEvent(Event event) { - updateWidgetEnablements(); - updateExtractedElements(); - } - - @Override - public void createControl(Composite parent) { - initializeDialogUnits(parent); - - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout(1, false)); - composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - composite.setFont(parent.getFont()); - - oseeTypesPanel.createControl(composite); - oseeTypesPanel.addListener(this); - - Label sectionTitle = new Label(composite, SWT.NONE); - sectionTitle.setText("Resolved dependencies:"); - sectionTitle.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, true, false)); - - linksViewer = new TreeViewer(composite, SWT.BORDER); - linksViewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - linksViewer.setContentProvider(new LinkNodeContentProvider()); - linksViewer.setLabelProvider(new LinkNodeLabelProvider()); - linksViewer.setInput(messages); - - createOptions(composite); - - restoreWidgetValues(); - updateWidgetEnablements(); - updateExtractedElements(); - setPageComplete(determinePageCompletion()); - setControl(composite); - } - - private void createOptions(Composite parent) { - Group composite = new Group(parent, SWT.NULL); - composite.setLayout(new GridLayout(1, false)); - composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - composite.setFont(parent.getFont()); - composite.setText("Options"); - - reportChanges = new Button(composite, SWT.CHECK); - reportChanges.setText("Report Changes"); - reportChanges.setSelection(true); - - useCompareEditor = new Button(composite, SWT.CHECK); - useCompareEditor.setText("Use Compare Editor"); - useCompareEditor.setSelection(false); - - persistChanges = new Button(composite, SWT.CHECK); - persistChanges.setText("Persist Changes"); - persistChanges.setSelection(false); - } - - public boolean isPersistAllowed() { - return persistChanges.getSelection(); - } - - public boolean isReportChanges() { - return reportChanges.getSelection(); - } - - public boolean useCompareEditor() { - return useCompareEditor.getSelection(); - } - - public File getTypesToImport() { - return compositeFile != null ? compositeFile : null; - } - - private void setCompositeFile(File compositeFile) { - this.compositeFile = compositeFile; - } - - @Override - protected boolean validateSourceGroup() { - return oseeTypesPanel.getSelected() != null; - } - - @Override - protected boolean validateDestinationGroup() { - return getTypesToImport() != null; - } - - private synchronized void updateExtractedElements() { - if (oseeTypesPanel.getSelected() != null) { - setErrorMessage(null); - File file = getTypesToImport(); - if (file != null) { - file.delete(); - setCompositeFile(null); - } - OseeLog.log(Activator.class, Level.INFO, "Resolving imports"); - - final List selectedFiles = new ArrayList(oseeTypesPanel.getSelected()); - final List dependencyData = new ArrayList(); - - List ops = new ArrayList(); - ops.add(new ResolveImportsOperation(new ClassloaderClasspathUriResolver(), selectedFiles, dependencyData)); - ops.add(new CreateCombinedFile(dependencyData)); - if (executeOperation(new CompositeOperation("Resolving imports", Activator.PLUGIN_ID, ops))) { - messages.clear(); - messages.addAll(dependencyData); - linksViewer.refresh(); - setPageComplete(determinePageCompletion()); - } - } - } - - protected boolean executeOperation(final IOperation operation) { - final IStatus[] status = new IStatus[1]; - try { - getContainer().run(true, true, new IRunnableWithProgress() { - - @Override - public void run(IProgressMonitor monitor) { - status[0] = Operations.executeWork(operation, monitor); - } - }); - } catch (InterruptedException e) { - return false; - } catch (InvocationTargetException e) { - displayErrorDialog(e.getTargetException()); - return false; - } - - if (status[0].isOK()) { - setErrorMessage(null); - } else { - setErrorMessage(status[0].getMessage()); - } - return true; - } - - private final class CreateCombinedFile extends AbstractOperation { - private final List dependencyData; - - public CreateCombinedFile(List dependencyData) { - super("Create combined file", Activator.PLUGIN_ID); - this.dependencyData = dependencyData; - } - - private void loadMap(LinkNode node, Map map) throws MalformedURLException { - for (LinkNode child : node.getChildren()) { - loadMap(child, map); - } - String path = node.getUri().toString(); - map.put(path, new URL(node.getUri().toString())); - } - - @Override - protected void doWork(IProgressMonitor monitor) throws Exception { - Map resolvedEntries = new LinkedHashMap(); - for (LinkNode node : dependencyData) { - loadMap(node, resolvedEntries); - } - File file = oseeTypesSetup.createCombinedFile(resolvedEntries); - setCompositeFile(file); - } - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/OseeTypesImportWizard.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/OseeTypesImportWizard.java deleted file mode 100644 index 99e83ec7dc8..00000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/OseeTypesImportWizard.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 Boeing. - * 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: - * Boeing - initial API and implementation - *******************************************************************************/ -package org.eclipse.osee.framework.core.dsl.ui.integration.wizards; - -import java.io.File; -import org.eclipse.core.runtime.jobs.IJobChangeEvent; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.core.runtime.jobs.JobChangeAdapter; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.osee.framework.core.dsl.ui.integration.internal.Activator; -import org.eclipse.osee.framework.core.dsl.ui.integration.operations.OseeTypesImportOperation; -import org.eclipse.osee.framework.core.operation.IOperation; -import org.eclipse.osee.framework.core.operation.Operations; -import org.eclipse.osee.framework.core.services.IOseeCachingService; -import org.eclipse.ui.IImportWizard; -import org.eclipse.ui.IWorkbench; - -/** - * @author Roberto E. Escobar - */ -public class OseeTypesImportWizard extends Wizard implements IImportWizard { - private OseeTypesImportPage mainPage; - - public OseeTypesImportWizard() { - super(); - setWindowTitle("OSEE Types Import Wizard"); - setNeedsProgressMonitor(true); - setHelpAvailable(true); - } - - @Override - public boolean performFinish() { - final File file = mainPage.getTypesToImport(); - boolean isReport = mainPage.isReportChanges(); - boolean useCompareEditor = mainPage.useCompareEditor(); - boolean isPersistAllowed = mainPage.isPersistAllowed(); - - IOseeCachingService cacheService = Activator.getOseeCacheService(); - IOperation operation = - new OseeTypesImportOperation(cacheService, file.toURI(), isReport, useCompareEditor, isPersistAllowed); - Job job = Operations.executeAsJob(operation, true); - job.addJobChangeListener(new JobChangeAdapter() { - @Override - public void done(IJobChangeEvent event) { - file.delete(); - } - }); - return true; - } - - @Override - public void init(IWorkbench workbench, IStructuredSelection selection) { - mainPage = new OseeTypesImportPage(selection, getWindowTitle()); - } - - @Override - public void addPages() { - addPage(mainPage); - } -} diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/OseeTypesViewerFilter.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/OseeTypesViewerFilter.java deleted file mode 100644 index 1604076be53..00000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/OseeTypesViewerFilter.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 Boeing. - * 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: - * Boeing - initial API and implementation - *******************************************************************************/ -package org.eclipse.osee.framework.core.dsl.ui.integration.wizards; - -import java.util.logging.Level; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceVisitor; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.osee.framework.core.dsl.ui.integration.internal.Activator; -import org.eclipse.osee.framework.jdk.core.type.MutableBoolean; -import org.eclipse.osee.framework.logging.OseeLog; - -/** - * @author Roberto E. Escobar - */ -public class OseeTypesViewerFilter extends ViewerFilter { - - private boolean processIFile(Object resource) { - boolean toReturn = false; - if (resource instanceof IFile) { - IFile aFile = (IFile) resource; - String currentExtension = aFile.getFileExtension(); - if (currentExtension.equalsIgnoreCase("osee")) { - toReturn = true; - } - } - return toReturn; - } - - @Override - public boolean select(Viewer viewer, Object parentElement, Object element) { - if (element instanceof IProject) { - if (((IProject) element).isOpen()) { - return true; - } - } else if (element instanceof IContainer) { - IContainer container = (IContainer) element; - String name = container.getName(); - if (!name.startsWith(".") && !name.equals("osee")) { - final MutableBoolean mutable = new MutableBoolean(false); - try { - container.accept(new IResourceVisitor() { - - @Override - public boolean visit(IResource resource) { - mutable.setValue(processIFile(resource)); - return mutable.getValue(); - } - }, IResource.DEPTH_INFINITE, true); - } catch (CoreException ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); - } - return mutable.getValue(); - } - } else { - return processIFile(element); - } - return false; - } -} diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/SelectOseeTypesPanel.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/SelectOseeTypesPanel.java deleted file mode 100644 index d7e0364bc74..00000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/SelectOseeTypesPanel.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 Boeing. - * 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: - * Boeing - initial API and implementation - *******************************************************************************/ -package org.eclipse.osee.framework.core.dsl.ui.integration.wizards; - -import java.util.ArrayList; -import java.util.List; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.osee.framework.core.dsl.ui.integration.internal.Activator; -import org.eclipse.osee.framework.ui.skynet.panels.AbstractItemSelectPanel; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.dialogs.CheckedTreeSelectionDialog; -import org.eclipse.ui.dialogs.ISelectionStatusValidator; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; - -/** - * @author Roberto E. Escobar - */ -public class SelectOseeTypesPanel extends AbstractItemSelectPanel> { - - public SelectOseeTypesPanel() { - super(new WorkbenchLabelProvider(), new ArrayContentProvider()); - } - - @Override - protected Dialog createSelectDialog(Shell shell, List lastSelected) { - CheckedTreeSelectionDialog dialog = - new CheckedTreeSelectionDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider()); - dialog.addFilter(new OseeTypesViewerFilter()); - dialog.setTitle("Select OseeTypes to import"); - dialog.setValidator(new Validator()); - dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); - if (lastSelected != null) { - dialog.setInitialElementSelections(lastSelected); - } - return dialog; - } - - @Override - protected boolean updateFromDialogResult(Dialog dialog) { - boolean updateRequired = false; - if (dialog instanceof CheckedTreeSelectionDialog) { - Object[] results = ((CheckedTreeSelectionDialog) dialog).getResult(); - if (results != null && results.length > 0) { - List selected = new ArrayList(); - for (Object object : results) { - if (object instanceof IFile) { - selected.add((IFile) object); - } - } - if (!selected.isEmpty()) { - setSelected(selected); - updateRequired = true; - } - } - } - return updateRequired; - } - - private final class Validator implements ISelectionStatusValidator { - @Override - public IStatus validate(Object[] selection) { - IStatus status = Status.OK_STATUS; - boolean found = false; - if (selection != null) { - for (Object object : selection) { - if (object instanceof IFile) { - found = true; - break; - } - } - } - if (!found) { - status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "At least (1) must be selected"); - } - return status; - } - } -} \ No newline at end of file -- cgit v1.2.3