blob: 8c73aa3615245aa824de9f05e06d9e876d851b96 [file] [log] [blame]
/**
* Copyright (c)2020 CEA LIST, Committer Name, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* CEA LIST - Initial API and implementation
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr
*
*/
package org.eclipse.pdp4eng.req.gdprananalysis.internal.ui;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
public class ChooseArticleToGenerate {
private String question= "The process has no consent, contract, no legal obligation no legitmate interest," //$NON-NLS-1$
+ " no vital interest and no public interest.\n Which requirement would you like to generate?"; //$NON-NLS-1$
public String[] requirementTypeText= {
"Consent (Article 6.1.a)", //$NON-NLS-1$
"Contract (Arcticle 6.1.b)", //$NON-NLS-1$
"Legal Obligation (Article 6.1.c)", //$NON-NLS-1$
"Vital Interest (Article 6.1.d)", //$NON-NLS-1$
"Public Interest (Article 6.1.e)", //$NON-NLS-1$
"Legitimate Interest (Article 6.1.f)", //$NON-NLS-1$
"Nothing, Safeguard (Article 6.4)"}; //$NON-NLS-1$
public static String CONSENT="CONSENT"; //$NON-NLS-1$
public static String CONTRACT="CONTRACT"; //$NON-NLS-1$
public static String LEGAL_OBLIGATION="LEGAL_OBLIGATION"; //$NON-NLS-1$
public static String VITAL_INTEREST="VITAL_INTEREST"; //$NON-NLS-1$
public static String PUBLIC_INTEREST="PUBLIC_INTEREST"; //$NON-NLS-1$
public static String LEGITIMATE_INTEREST="LEGITIMATE_INTEREST"; //$NON-NLS-1$
public static String SAFEGUARD="SAFEGUARD"; //$NON-NLS-1$
public static String[] requirementType= {
CONSENT,
CONTRACT,
LEGAL_OBLIGATION,
VITAL_INTEREST,
PUBLIC_INTEREST,
LEGITIMATE_INTEREST,
SAFEGUARD};
public int selection=6;
public String launchWindow(String processName) {
final Display display = Display.getDefault();
Shell shell = new Shell(display);
shell.setText("Choose Article to Generate"); //$NON-NLS-1$
shell.pack();
Label label= new Label(shell, SWT.NONE);
label.setText(processName +": "+question); //$NON-NLS-1$
label.setBounds(10,5,700,30);
Button[] radios = new Button[7];
for(int i=0; i<7; i++) {
radios[i] = new Button(shell, SWT.RADIO);
radios[i].setSelection(false);
radios[i].setText(requirementTypeText[i]);
radios[i].setBounds(10, 40+(i*25), 200, 30);
}
radios[6].setSelection(true);
Button ok = new Button(shell, SWT.PUSH);
ok.setText("OK"); //$NON-NLS-1$
ok.setBounds(150, 240, 300,30);
ok.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
switch (e.type) {
case SWT.Selection:
//look for selection
System.out.println("Button pressed"); //$NON-NLS-1$
for(int i=0; i<7; i++) {
if( radios[i].getSelection()==true) {
selection=i;
}
}
shell.dispose();
break;
}
}
});
Label phantomlabel= new Label(shell, SWT.NONE);
phantomlabel.setBounds(150,270,200,30);
shell.open();
shell.pack();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
return requirementType[selection];
}
public static void main(String[] args) {
ChooseArticleToGenerate articleToGenerate= new ChooseArticleToGenerate();
articleToGenerate.launchWindow( "test"); //$NON-NLS-1$
}
}