Commit e934d856 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ first attempt at a protocol server client UI integration, #48, #45, #6, #2

parent befc0ebd
Loading
Loading
Loading
Loading
Loading
+42 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import org.eclipse.jface.preference.FileFieldEditor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.ListEditor;
import org.eclipse.jface.preference.PathEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
@@ -38,6 +39,7 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
import org.eclipse.xtext.util.StringInputStream;
import org.etsi.mts.tdl.transform.Converter;
import org.etsi.mts.tdl.transform.ProtocolServerBridge;
import org.osgi.service.prefs.Preferences;

public class ImportWizardPage extends WizardNewFileCreationPage {
@@ -51,6 +53,8 @@ public class ImportWizardPage extends WizardNewFileCreationPage {
	private FileListEditor fileListEditor;
	private Composite fileSelectionArea;
	private String packageName;
	private String psAddress;
	private StringFieldEditor protocolServer;
	public ImportWizardPage(String pageName, IStructuredSelection selection) {
		super(pageName, selection);
		setTitle(pageName); //NON-NLS-1
@@ -129,6 +133,7 @@ public class ImportWizardPage extends WizardNewFileCreationPage {
		optionsLayout.marginHeight = 0;
		optionsArea.setLayout(optionsLayout);
		
		
        Button buttonCopy = new Button(optionsArea, SWT.CHECK);
        buttonCopy.setSelection(false);
        buttonCopy.addSelectionListener(SelectionListener.widgetSelectedAdapter(this::copyDataDefinitions));
@@ -157,6 +162,34 @@ public class ImportWizardPage extends WizardNewFileCreationPage {
//        fill empty cell
		new Label(optionsArea, SWT.NONE);

		new Label(parent, SWT.NONE);

		Composite psArea = new Composite(parent, SWT.NONE);

		GridData psData = new GridData(GridData.GRAB_HORIZONTAL
				| GridData.FILL_HORIZONTAL);
		psArea.setLayoutData(psData);

		GridLayout psLayout = new GridLayout();
		psLayout.numColumns = 3;
		psLayout.makeColumnsEqualWidth = false;
		psLayout.marginWidth = 0;
		psLayout.marginHeight = 0;
		psArea.setLayout(psLayout);

		protocolServer = new StringFieldEditor("protocolServerAddress", "Protocol Server Address:", 80, 1, StringFieldEditor.VALIDATE_ON_FOCUS_LOST, psArea);
		protocolServer.fillIntoGrid(psArea, 2);
		String lastUsedPS = "LAST_USED_PS";

		protocolServer.getTextControl(psArea).addModifyListener(e -> {
			psAddress = ImportWizardPage.this.protocolServer.getStringValue();
			if (psAddress != null) {
				preferences.put(lastUsedPS, psAddress);
			}
		});
		protocolServer.getTextControl(psArea).setText(preferences.get(lastUsedPS, ""));

		
		setFileName("Imported.tdltx");
	}
	
@@ -206,9 +239,16 @@ public class ImportWizardPage extends WizardNewFileCreationPage {
			}
		}
		if (!asnFiles.isEmpty()) {
			Converter converter = Converter.getConverter("org.etsi.mts.tdl.asn2tdl");
			//TODO: implement properly
			content += converter.processToString(asnFiles, asnFiles.getFirst()+"-generated.tdltx");
//			Converter converter = Converter.getConverter("org.etsi.mts.tdl.asn2tdl");
//			content += converter.processToString(asnFiles, asnFiles.getFirst()+"-generated.tdltx");
			
			ProtocolServerBridge bridge = new ProtocolServerBridge();
			//TODO: expose settings
			//TODO: get content
			content = "Package Imported {\n";
			content += bridge.convertASN1toTDLRemote(psAddress, asnFiles, getContainerFullPath().append(getFileName()).toOSString());
			content += "\n}\n";
		}

		if (overwrite) {