Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan E. Jensen2013-06-13 21:13:50 +0000
committerRoberto E. Escobar2013-06-17 23:09:30 +0000
commit407d89fbfa7ac9f2cb2ac14c3c752e9176b500b1 (patch)
tree2f7758f85652ea3ef43014dbf76f70a850295597 /plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org
parent44d00a5571af2feb2c1bc40948e63a19f725ab36 (diff)
downloadorg.eclipse.osee-407d89fbfa7ac9f2cb2ac14c3c752e9176b500b1.tar.gz
org.eclipse.osee-407d89fbfa7ac9f2cb2ac14c3c752e9176b500b1.tar.xz
org.eclipse.osee-407d89fbfa7ac9f2cb2ac14c3c752e9176b500b1.zip
feature[ats_QGK3T]: Create DSL renderer
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org')
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/AbstractDslRenderer.java163
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslRenderer.java86
2 files changed, 175 insertions, 74 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/AbstractDslRenderer.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/AbstractDslRenderer.java
new file mode 100644
index 00000000000..b057d25e101
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/AbstractDslRenderer.java
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * 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;
+
+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.File;
+import java.io.InputStream;
+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.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.dsl.ui.integration.internal.DslUiIntegrationConstants;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+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;
+
+/**
+ * @author Jonathan E. Jensen
+ */
+public abstract class AbstractDslRenderer extends FileSystemRenderer {
+
+ protected static final String COMMAND_ID = "org.eclipse.osee.framework.ui.skynet.render.dsl.editor.command";
+
+ protected AbstractDslRenderer() {
+ super();
+ }
+
+ /**
+ * Simple String name of the renderer
+ */
+ @Override
+ public abstract String getName();
+
+ /**
+ * Provides an instance of the concrete class.
+ */
+ @Override
+ public abstract DefaultArtifactRenderer newInstance();
+
+ /**
+ * Provides a list of the artifact types that the renderer supports.
+ *
+ * @return a list of the artifact types that the renderer supports
+ */
+ protected abstract IArtifactType[] getArtifactTypeMatches();
+
+ /**
+ * Provides the command ID associated with this renderer and adds it to the commandGroup.
+ */
+ @Override
+ public List<String> getCommandIds(CommandGroup commandGroup) {
+ ArrayList<String> commandIds = new ArrayList<String>(1);
+ if (commandGroup.isEdit()) {
+ commandIds.add(COMMAND_ID);
+ }
+
+ return commandIds;
+ }
+
+ /**
+ * Get the file extention associated with the dsl and related artifact.
+ */
+ @Override
+ public abstract String getAssociatedExtension(Artifact artifact) throws OseeCoreException;
+
+ /**
+ * Provides a render input stream for the given input.
+ */
+ @Override
+ public abstract InputStream getRenderInputStream(PresentationType presentationType, List<Artifact> artifacts) throws OseeCoreException;
+
+ /**
+ * Provides the update operation for the renderer.
+ */
+ @Override
+ protected abstract IOperation getUpdateOperation(File file, List<Artifact> artifacts, IOseeBranch branch, PresentationType presentationType);
+
+ /**
+ * Provides the minimum match ranking for this renderer.
+ */
+ @Override
+ public abstract int minimumRanking();
+
+ /**
+ * This function can be overridden if the subclass does not support compare
+ */
+ @Override
+ public boolean supportsCompare() {
+ return true;
+ }
+
+ @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(getArtifactTypeMatches())) {
+ return ARTIFACT_TYPE_MATCH;
+ }
+ }
+ return NO_MATCH;
+ }
+
+ @SuppressWarnings("unused")
+ @Override
+ public final void open(final List<Artifact> artifacts, final PresentationType presentationType) throws OseeCoreException {
+
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ if (!artifacts.isEmpty()) {
+ try {
+ PresentationType onOpenPresentationType = getOnOpenPresentationType(presentationType);
+ IFile file = renderToFile(artifacts, onOpenPresentationType);
+ if (file != null) {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
+ IDE.openEditor(page, file);
+ }
+ } catch (CoreException ex) {
+ OseeLog.log(DslUiIntegrationConstants.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
+ }
+ });
+ }
+
+ public PresentationType getOnOpenPresentationType(PresentationType presentationType) {
+ return presentationType == DEFAULT_OPEN ? SPECIALIZED_EDIT : presentationType;
+ }
+
+ /**
+ * This is required by the base class but not by this renderer. Therefore, we stub it out.
+ */
+ @Override
+ public final Program getAssociatedProgram(Artifact artifact) throws OseeCoreException {
+ throw new OseeCoreException("should not be called");
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslRenderer.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslRenderer.java
index 2036f27f061..a837c04f82d 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslRenderer.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslRenderer.java
@@ -10,45 +10,33 @@
*******************************************************************************/
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.data.IArtifactType;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.dsl.integration.util.OseeDslSegmentParser;
+import org.eclipse.osee.framework.core.dsl.ui.integration.AbstractDslRenderer;
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.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.FileToAttributeUpdateOperation;
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;
/**
* @author Roberto E. Escobar
*/
-public final class OseeDslRenderer extends FileSystemRenderer {
- private static final String COMMAND_ID = "org.eclipse.osee.framework.core.dsl.OseeDsl.editor.command";
+public final class OseeDslRenderer extends AbstractDslRenderer {
+ private static final IArtifactType[] MATCHING_ARTIFACT_TYPES = {
+ CoreArtifactTypes.AccessControlModel,
+ CoreArtifactTypes.OseeTypeDefinition};
+
private static final OseeDslSegmentParser parser = new OseeDslSegmentParser();
@Override
@@ -61,56 +49,6 @@ public final class OseeDslRenderer extends FileSystemRenderer {
return new OseeDslRenderer();
}
- @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.AccessControlModel, 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(DslUiIntegrationConstants.class, OseeLevel.SEVERE_POPUP, ex);
- }
- }
- }
- });
- }
-
@SuppressWarnings("unused")
@Override
public String getAssociatedExtension(Artifact artifact) throws OseeCoreException {
@@ -144,11 +82,6 @@ public final class OseeDslRenderer extends FileSystemRenderer {
}
@Override
- public Program getAssociatedProgram(Artifact artifact) throws OseeCoreException {
- throw new OseeCoreException("should not be called");
- }
-
- @Override
protected IOperation getUpdateOperation(File file, List<Artifact> artifacts, IOseeBranch branch, PresentationType presentationType) {
IOperation op;
Artifact artifact = artifacts.iterator().next();
@@ -167,4 +100,9 @@ public final class OseeDslRenderer extends FileSystemRenderer {
public int minimumRanking() {
return GENERAL_MATCH;
}
+
+ @Override
+ protected IArtifactType[] getArtifactTypeMatches() {
+ return MATCHING_ARTIFACT_TYPES;
+ }
}

Back to the top