Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngel Avila2015-03-19 21:37:32 +0000
committerAngel Avila2015-03-19 21:37:32 +0000
commit8bdce190649362dd04b770ae2209047d61da2ab1 (patch)
tree3b926be68287bb9bbc5d35443c196ce5436b1520 /plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org
parente942944a27a74e7309bad875eff32b986da7f3c1 (diff)
downloadorg.eclipse.osee-8bdce190649362dd04b770ae2209047d61da2ab1.tar.gz
org.eclipse.osee-8bdce190649362dd04b770ae2209047d61da2ab1.tar.xz
org.eclipse.osee-8bdce190649362dd04b770ae2209047d61da2ab1.zip
refactor: Move OseeTypes import/export to skynet
Change-Id: I12201f2d9fad0c74017496b02c79003960d7fa36 Signed-off-by: Angel Avila <angel.avila2@boeing.com>
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/operations/AbstractOseeDslProvider.java5
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/CreateEditorReportOperation.java104
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/OseeTypesExportOperation.java53
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/OseeTypesImportOperation.java95
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/XtextOseeTypesHandler.java55
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/OseeTypesExportWizard.java84
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/ResourceSelectionPage.java97
7 files changed, 3 insertions, 490 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/AbstractOseeDslProvider.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/AbstractOseeDslProvider.java
index d07f0688264..eb55992f7be 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/AbstractOseeDslProvider.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/AbstractOseeDslProvider.java
@@ -18,6 +18,7 @@ import org.eclipse.osee.framework.core.exception.OseeExceptions;
import org.eclipse.osee.framework.core.operation.IOperation;
import org.eclipse.osee.framework.core.operation.Operations;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
/**
* @author Roberto E. Escobar
@@ -39,8 +40,8 @@ public abstract class AbstractOseeDslProvider implements OseeDslProvider {
public void loadDsl() throws OseeCoreException {
String accessModel = getModelFromStorage();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- IOperation operation = new OseeTypesExportOperation(outputStream);
- Operations.executeWorkAndCheckStatus(operation);
+ IOperation op = ArtifactTypeManager.newExportTypesOp(outputStream);
+ Operations.executeWorkAndCheckStatus(op);
try {
outputStream.write(accessModel.getBytes("utf-8"));
oseeDsl = OseeDslResourceUtil.loadModel(locationUri, outputStream.toString("utf-8")).getModel();
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/CreateEditorReportOperation.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/CreateEditorReportOperation.java
deleted file mode 100644
index 079d3e1ad79..00000000000
--- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/CreateEditorReportOperation.java
+++ /dev/null
@@ -1,104 +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.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-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.nebula.widgets.xviewer.XViewerColumn;
-import org.eclipse.nebula.widgets.xviewer.XViewerColumn.SortDataType;
-import org.eclipse.osee.framework.core.dsl.ui.integration.internal.DslUiIntegrationConstants;
-import org.eclipse.osee.framework.core.model.TableData;
-import org.eclipse.osee.framework.core.operation.AbstractOperation;
-import org.eclipse.osee.framework.core.operation.Operations;
-import org.eclipse.osee.framework.ui.skynet.results.IResultsEditorProvider;
-import org.eclipse.osee.framework.ui.skynet.results.IResultsEditorTab;
-import org.eclipse.osee.framework.ui.skynet.results.ResultsEditor;
-import org.eclipse.osee.framework.ui.skynet.results.table.IResultsXViewerRow;
-import org.eclipse.osee.framework.ui.skynet.results.table.ResultsEditorTableTab;
-import org.eclipse.osee.framework.ui.skynet.results.table.ResultsXViewerRow;
-import org.eclipse.swt.SWT;
-import org.eclipse.ui.progress.UIJob;
-
-/**
- * @author Roberto E. Escobar
- */
-public class CreateEditorReportOperation extends AbstractOperation {
- private final Collection<TableData> tableData;
- private final String reportName;
-
- public CreateEditorReportOperation(String reportName, Collection<TableData> tableData) {
- super("Generate Report", DslUiIntegrationConstants.PLUGIN_ID);
- this.tableData = tableData;
- this.reportName = reportName;
- }
-
- @Override
- protected void doWork(IProgressMonitor monitor) throws Exception {
- List<IResultsEditorTab> tabs = new ArrayList<IResultsEditorTab>();
- for (TableData data : tableData) {
- List<XViewerColumn> columns = new ArrayList<XViewerColumn>();
- for (String name : data.getColumns()) {
- columns.add(new XViewerColumn(name, name, 80, SWT.LEFT, true, SortDataType.String, false, ""));
- }
- List<IResultsXViewerRow> rows = new ArrayList<IResultsXViewerRow>();
- for (String[] row : data.getRows()) {
- rows.add(new ResultsXViewerRow(row));
- }
- tabs.add(new ResultsEditorTableTab(data.getTitle(), columns, rows));
- }
- openReport(tabs);
- }
-
- private void openReport(final List<IResultsEditorTab> resultsTabs) {
- Job job = new UIJob(reportName) {
-
- @Override
- public IStatus runInUIThread(IProgressMonitor monitor) {
- IStatus status;
- try {
- ResultsEditor.open(new ReportProvider(getName(), resultsTabs));
- status = Status.OK_STATUS;
- } catch (Exception ex) {
- status =
- new Status(IStatus.ERROR, DslUiIntegrationConstants.PLUGIN_ID, String.format("Error creating %s Report", reportName),
- ex);
- }
- return status;
- }
- };
- Operations.scheduleJob(job, true, Job.SHORT, null);
- }
-
- private static final class ReportProvider implements IResultsEditorProvider {
- private final List<IResultsEditorTab> resultsTabs;
- private final String editorName;
-
- public ReportProvider(String editorName, List<IResultsEditorTab> resultsTabs) {
- this.resultsTabs = resultsTabs;
- this.editorName = editorName;
- }
-
- @Override
- public String getEditorName() {
- return editorName;
- }
-
- @Override
- public List<IResultsEditorTab> getResultsEditorTabs() {
- return resultsTabs;
- }
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/OseeTypesExportOperation.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/OseeTypesExportOperation.java
deleted file mode 100644
index 32a5cecfeec..00000000000
--- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/OseeTypesExportOperation.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.operations;
-
-import java.io.OutputStream;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.client.ClientSessionManager;
-import org.eclipse.osee.framework.core.client.server.HttpUrlBuilderClient;
-import org.eclipse.osee.framework.core.data.OseeServerContext;
-import org.eclipse.osee.framework.core.dsl.ui.integration.internal.DslUiIntegrationConstants;
-import org.eclipse.osee.framework.core.operation.AbstractOperation;
-import org.eclipse.osee.framework.core.util.HttpProcessor;
-import org.eclipse.osee.framework.core.util.HttpProcessor.AcquireResult;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Conditions;
-
-/**
- * @author Roberto E. Escobar
- */
-public class OseeTypesExportOperation extends AbstractOperation {
- private final OutputStream outputStream;
-
- public OseeTypesExportOperation(OutputStream outputStream) {
- super("Export Osee Types Model", DslUiIntegrationConstants.PLUGIN_ID);
- this.outputStream = outputStream;
- }
-
- @Override
- protected void doWork(IProgressMonitor monitor) throws Exception {
- Conditions.checkNotNull(outputStream, "outputStream");
- Map<String, String> parameters = new HashMap<String, String>();
- parameters.put("sessionId", ClientSessionManager.getSessionId());
-
- String url =
- HttpUrlBuilderClient.getInstance().getOsgiServletServiceUrl(OseeServerContext.OSEE_MODEL_CONTEXT, parameters);
-
- AcquireResult results = HttpProcessor.acquire(new URL(url), outputStream);
- if (!results.wasSuccessful()) {
- throw new OseeCoreException("Error exporting osee types");
- }
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/OseeTypesImportOperation.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/OseeTypesImportOperation.java
deleted file mode 100644
index b84a6e68f05..00000000000
--- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/OseeTypesImportOperation.java
+++ /dev/null
@@ -1,95 +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.URI;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.data.OseeServerContext;
-import org.eclipse.osee.framework.core.dsl.ui.integration.internal.DslUiIntegrationConstants;
-import org.eclipse.osee.framework.core.enums.CoreTranslatorId;
-import org.eclipse.osee.framework.core.model.OseeImportModelRequest;
-import org.eclipse.osee.framework.core.model.OseeImportModelResponse;
-import org.eclipse.osee.framework.core.model.TableData;
-import org.eclipse.osee.framework.core.operation.AbstractOperation;
-import org.eclipse.osee.framework.core.operation.Operations;
-import org.eclipse.osee.framework.core.services.IOseeCachingService;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.skynet.core.artifact.HttpClientMessage;
-
-/**
- * @author Roberto E. Escobar
- */
-public class OseeTypesImportOperation extends AbstractOperation {
- private final IOseeCachingService cacheService;
- private final URI model;
- private final boolean createTypeChangeReport;
-
- public OseeTypesImportOperation(IOseeCachingService cacheService, URI model, boolean createTypeChangeReport) {
- super("Import Osee Types Model", DslUiIntegrationConstants.PLUGIN_ID);
- this.cacheService = cacheService;
- this.model = model;
- this.createTypeChangeReport = createTypeChangeReport;
- }
-
- private String getModel(URL url) throws IOException {
- InputStream inputStream = null;
- try {
- inputStream = new BufferedInputStream(url.openStream());
- return Lib.inputStreamToString(inputStream);
- } finally {
- Lib.close(inputStream);
- }
- }
-
- private String getName(URI uri) {
- String name = uri.toASCIIString();
- int index = name.lastIndexOf("/");
- if (index > 0) {
- name = name.substring(index + 1, name.length());
- }
- return name;
- }
-
- @Override
- protected void doWork(IProgressMonitor monitor) throws Exception {
- Map<String, String> parameters = new HashMap<String, String>();
-
- OseeImportModelRequest modelRequest =
- new OseeImportModelRequest(getName(model), getModel(model.toURL()), createTypeChangeReport, false);
-
- OseeImportModelResponse response =
- HttpClientMessage.send(OseeServerContext.OSEE_MODEL_CONTEXT, parameters,
- CoreTranslatorId.OSEE_IMPORT_MODEL_REQUEST, modelRequest, CoreTranslatorId.OSEE_IMPORT_MODEL_RESPONSE);
-
- if (response.wasPersisted()) {
- cacheService.getEnumTypeCache().reloadCache();
- cacheService.getAttributeTypeCache().reloadCache();
- cacheService.getArtifactTypeCache().reloadCache();
- cacheService.getRelationTypeCache().reloadCache();
- }
-
- if (createTypeChangeReport) {
- openTabReport(response.getReportData());
- }
-
- }
-
- private void openTabReport(List<TableData> tableData) {
- Operations.executeAsJob(new CreateEditorReportOperation("Un-Persisted Osee Types", tableData), true);
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/XtextOseeTypesHandler.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/XtextOseeTypesHandler.java
deleted file mode 100644
index 08d182a8ae7..00000000000
--- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/XtextOseeTypesHandler.java
+++ /dev/null
@@ -1,55 +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.net.URI;
-import org.eclipse.core.runtime.IProgressMonitor;
-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.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Conditions;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.skynet.core.importing.IOseeTypesHandler;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
-
-/**
- * @author Roberto E. Escobar
- */
-public class XtextOseeTypesHandler implements IOseeTypesHandler {
-
- @Override
- public void execute(IProgressMonitor monitor, URI uri) throws OseeCoreException {
- IOseeCachingService cacheService = getCachingService();
- IOperation operation = new OseeTypesImportOperation(cacheService, uri, false);
- Operations.executeWorkAndCheckStatus(operation, monitor);
- }
-
- @Override
- public boolean isApplicable(String resource) {
- return Strings.isValid(resource) && resource.endsWith(".osee");
- }
-
- private IOseeCachingService getCachingService() throws OseeCoreException {
- Bundle bundle = FrameworkUtil.getBundle(getClass());
- Conditions.checkNotNull(bundle, "bundle");
- BundleContext bundleContext = bundle.getBundleContext();
- Conditions.checkNotNull(bundleContext, "bundleContext");
- ServiceReference<IOseeCachingService> reference = bundleContext.getServiceReference(IOseeCachingService.class);
- IOseeCachingService cacheService = bundleContext.getService(reference);
- Conditions.checkNotNull(cacheService, "cacheService");
- return cacheService;
- }
-
-}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/OseeTypesExportWizard.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/OseeTypesExportWizard.java
deleted file mode 100644
index d1dcb70e457..00000000000
--- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/OseeTypesExportWizard.java
+++ /dev/null
@@ -1,84 +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.BufferedOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.OutputStream;
-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.DslUiIntegrationConstants;
-import org.eclipse.osee.framework.core.dsl.ui.integration.operations.OseeTypesExportOperation;
-import org.eclipse.osee.framework.core.operation.IOperation;
-import org.eclipse.osee.framework.core.operation.Operations;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.logging.OseeLevel;
-import org.eclipse.osee.framework.logging.OseeLog;
-import org.eclipse.ui.IImportWizard;
-import org.eclipse.ui.IWorkbench;
-
-/**
- * @author Roberto E. Escobar
- */
-public class OseeTypesExportWizard extends Wizard implements IImportWizard {
- private ResourceSelectionPage mainPage;
-
- public OseeTypesExportWizard() {
- super();
- // setDialogSettings(Activator.getInstance().getDialogSettings());
- setWindowTitle("OSEE Types Export Wizard");
- setNeedsProgressMonitor(true);
- setHelpAvailable(true);
- }
-
- @Override
- public boolean performFinish() {
- File folder = mainPage.getFile();
-
- File file = new File(folder, getOseeFileName());
- FileOutputStream fos = null;
- try {
- fos = new FileOutputStream(file);
- final OutputStream outputStream = new BufferedOutputStream(fos);
- IOperation op = new OseeTypesExportOperation(outputStream);
- Operations.executeAsJob(op, true, Job.LONG, new JobChangeAdapter() {
- @Override
- public void done(IJobChangeEvent event) {
- Lib.close(outputStream);
- }
- });
- } catch (FileNotFoundException ex) {
- OseeLog.log(DslUiIntegrationConstants.class, OseeLevel.SEVERE_POPUP, ex);
- } finally {
- Lib.close(fos);
- }
- return true;
- }
-
- private String getOseeFileName() {
- return "OseeTypes_" + Lib.getDateTimeString() + ".osee";
- }
-
- @Override
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- mainPage = new ResourceSelectionPage(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/ResourceSelectionPage.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/ResourceSelectionPage.java
deleted file mode 100644
index a8e6305feec..00000000000
--- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/ResourceSelectionPage.java
+++ /dev/null
@@ -1,97 +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.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.ui.ws.AWorkspace;
-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.DirectoryDialog;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.WizardDataTransferPage;
-
-public class ResourceSelectionPage extends WizardDataTransferPage {
- private static final String PAGE_NAME = "osee.define.wizardPage.artifactImportSourcePage";
-
- private Text text;
-
- protected ResourceSelectionPage(String title) {
- super(PAGE_NAME);
- 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);
-
- Group composite = new Group(parent, SWT.NONE);
- composite.setText("Select destination...");
- composite.setLayout(new GridLayout(2, false));
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- composite.setFont(parent.getFont());
-
- text = new Text(composite, SWT.SINGLE | SWT.BORDER);
- text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- text.addListener(SWT.Modify, this);
-
- Button button = new Button(composite, SWT.PUSH);
- button.setText("&Browse...");
- button.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.OPEN);
- File file = getFile();
- if (file != null && Strings.isValid(file.getAbsolutePath())) {
- dialog.setFilterPath(file.getAbsolutePath());
- } else {
- dialog.setFilterPath(AWorkspace.getWorkspacePath());
- }
- String path = dialog.open();
-
- File directory = path != null ? new File(path) : null;
- if (directory != null && directory.isDirectory()) {
- text.setText(directory.getPath());
- }
- }
- });
-
- restoreWidgetValues();
- updateWidgetEnablements();
- setPageComplete(determinePageCompletion());
- setControl(composite);
- }
-
- public File getFile() {
- return new File(text.getText());
- }
-
-}

Back to the top