blob: 61ab8a03e2485c988d0c31a0afdbb20af974def3 [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
* Gabriel Pedroza (CEA LIST) gabriel.pedroza@cea.fr
*
*/
package org.eclipse.papyrus.pdp4eng.designer.controller.internal.processcreation;
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.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
class RulesInformation extends Dialog {
private boolean seekParameter=false;
private boolean sourceParameter=false;
public RulesInformation(Shell parent) {
this(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
}
public RulesInformation(Shell parent, int style) {
super(parent, style);
}
public void open() {
Shell shell = new Shell(getParent(), getStyle());
shell.setText("Rules generation");
shell.setSize(400,200);
createContents(shell);
shell.pack();
shell.open();
Display display = getParent().getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
public boolean generateSeekAsParameter() {
return seekParameter;
}
public boolean generateSourceAsParameter() {
return sourceParameter;
}
private void createContents(final Shell shell) {
shell.setLayout(new GridLayout(2, true));
GridData data = new GridData();
Button sourceDataButton = new Button (shell, SWT.CHECK);
sourceDataButton.setText("Generate a ParameterNode for each source DataStore node");
sourceDataButton.setSelection(true);
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
sourceDataButton.setLayoutData(data);
Button seekDataButton = new Button (shell, SWT.CHECK);
seekDataButton.setText("Generate a ParameterNode for each seek DataStore node");
seekDataButton.setSelection(true);
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
seekDataButton.setLayoutData(data);
Button ok = new Button(shell, SWT.PUSH);
ok.setText("OK");
data = new GridData(GridData.FILL_HORIZONTAL);
ok.setLayoutData(data);
ok.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
seekParameter=seekDataButton.getSelection();
sourceParameter=sourceDataButton.getSelection();
shell.close();
}
});
shell.setDefaultButton(ok);
}
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setSize(400, 100);
RulesInformation dlg = new RulesInformation(shell);
dlg.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}