Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2011-08-16 15:59:49 +0000
committerRyan D. Brooks2011-08-16 15:59:49 +0000
commit63984fcdeff57c500df0c9ce52114f3f6670eb0d (patch)
tree5e0d3f68bd511a01b9c05d441e624e2e1c2327ad /plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src
parent612e819915757a6d9f13a32afd924ba497517bb9 (diff)
downloadorg.eclipse.osee-63984fcdeff57c500df0c9ce52114f3f6670eb0d.tar.gz
org.eclipse.osee-63984fcdeff57c500df0c9ce52114f3f6670eb0d.tar.xz
org.eclipse.osee-63984fcdeff57c500df0c9ce52114f3f6670eb0d.zip
feature[ats_M1Y56]: Add uuid to Osee type grammar
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src')
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslTypeSheetRenderer.java133
1 files changed, 133 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslTypeSheetRenderer.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslTypeSheetRenderer.java
new file mode 100644
index 00000000000..49f22c950c8
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslTypeSheetRenderer.java
@@ -0,0 +1,133 @@
+/*
+ * Created on Aug 16, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.core.dsl.ui.integration.internal;
+
+import static org.eclipse.osee.framework.ui.skynet.render.PresentationType.DEFAULT_OPEN;
+import static org.eclipse.osee.framework.ui.skynet.render.PresentationType.GENERALIZED_EDIT;
+import static org.eclipse.osee.framework.ui.skynet.render.PresentationType.PRODUCE_ATTRIBUTE;
+import static org.eclipse.osee.framework.ui.skynet.render.PresentationType.SPECIALIZED_EDIT;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.operation.IOperation;
+import org.eclipse.osee.framework.logging.OseeLevel;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.types.IArtifact;
+import org.eclipse.osee.framework.ui.skynet.render.DefaultArtifactRenderer;
+import org.eclipse.osee.framework.ui.skynet.render.FileSystemRenderer;
+import org.eclipse.osee.framework.ui.skynet.render.PresentationType;
+import org.eclipse.osee.framework.ui.swt.Displays;
+import org.eclipse.swt.program.Program;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+
+public class OseeDslTypeSheetRenderer extends FileSystemRenderer {
+ private static final String COMMAND_ID = "org.eclipse.osee.framework.core.dsl.OseeDslTypeSheet.editor.command";
+
+ @Override
+ public String getName() {
+ return "OseeDsl Editor";
+ }
+
+ @Override
+ public DefaultArtifactRenderer newInstance() {
+ return new OseeDslTypeSheetRenderer();
+ }
+
+ @Override
+ public int getApplicabilityRating(PresentationType presentationType, IArtifact artifact) throws OseeCoreException {
+ Artifact aArtifact = artifact.getFullArtifact();
+ if (!presentationType.matches(GENERALIZED_EDIT, PRODUCE_ATTRIBUTE) && !aArtifact.isHistorical()) {
+ if (aArtifact.isOfType(CoreArtifactTypes.OseeTypeDefinition)) {
+ return ARTIFACT_TYPE_MATCH;
+ }
+ }
+ return NO_MATCH;
+ }
+
+ @Override
+ public List<String> getCommandIds(CommandGroup commandGroup) {
+ ArrayList<String> commandIds = new ArrayList<String>(1);
+ if (commandGroup.isEdit()) {
+ commandIds.add(COMMAND_ID);
+ }
+ return commandIds;
+ }
+
+ @Override
+ public boolean supportsCompare() {
+ return true;
+ }
+
+ @SuppressWarnings("unused")
+ @Override
+ public void open(final List<Artifact> artifacts, PresentationType presentationType) throws OseeCoreException {
+ final PresentationType resultantpresentationType =
+ presentationType == DEFAULT_OPEN ? SPECIALIZED_EDIT : presentationType;
+
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ if (!artifacts.isEmpty()) {
+ try {
+ IFile file = renderToFile(artifacts, resultantpresentationType);
+ if (file != null) {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
+ IDE.openEditor(page, file);
+ }
+ } catch (CoreException ex) {
+ OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
+ }
+ });
+ }
+
+ @SuppressWarnings("unused")
+ @Override
+ public String getAssociatedExtension(Artifact artifact) throws OseeCoreException {
+ return "osee";
+ }
+
+ @Override
+ public InputStream getRenderInputStream(PresentationType presentationType, List<Artifact> artifacts) throws OseeCoreException {
+ Artifact artifact = artifacts.iterator().next();
+ StringBuilder builder = new StringBuilder();
+ builder.append(artifact.getSoleAttributeValueAsString(CoreAttributeTypes.GeneralStringData, ""));
+ InputStream inputStream = null;
+ try {
+ inputStream = new ByteArrayInputStream(builder.toString().getBytes("UTF-8"));
+ } catch (UnsupportedEncodingException ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ }
+ return inputStream;
+ }
+
+ @Override
+ public Program getAssociatedProgram(Artifact artifact) throws OseeCoreException {
+ throw new OseeCoreException("should not be called");
+ }
+
+ @Override
+ protected IOperation getUpdateOperation(File file, List<Artifact> artifacts, Branch branch, PresentationType presentationType) {
+ return null;
+ }
+
+}

Back to the top