AddTrustedStaticLibFileDialog.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. ///////////////////////////////////////////////////////////////////////////
  2. // Copyright (c) 2018 Intel Corporation. //
  3. // //
  4. // All rights reserved. This program and the accompanying materials //
  5. // are made available under the terms of the Eclipse Public License v1.0 //
  6. // which accompanies this distribution, and is available at //
  7. // http://www.eclipse.org/legal/epl-v10.html //
  8. // //
  9. // Contributors: //
  10. // Intel Corporation - initial implementation and documentation //
  11. ///////////////////////////////////////////////////////////////////////////
  12. package com.intel.sgx.dialogs;
  13. import javax.swing.JOptionPane;
  14. import org.eclipse.swt.SWT;
  15. import org.eclipse.swt.graphics.Point;
  16. import org.eclipse.swt.layout.GridData;
  17. import org.eclipse.swt.layout.GridLayout;
  18. import org.eclipse.swt.widgets.Composite;
  19. import org.eclipse.swt.widgets.Control;
  20. import org.eclipse.swt.widgets.Group;
  21. import org.eclipse.swt.widgets.Label;
  22. import org.eclipse.swt.widgets.Shell;
  23. import org.eclipse.swt.widgets.Text;
  24. import com.intel.sgx.handlers.AddTrustedStaticLib;
  25. public class AddTrustedStaticLibFileDialog extends SGXDialogBase {
  26. private Text fileNameField;
  27. private AddTrustedStaticLib addHandler;
  28. private boolean generateApp = false;
  29. public AddTrustedStaticLibFileDialog(Shell shell, AddTrustedStaticLib addHandler) {
  30. super(shell);
  31. this.addHandler = addHandler;
  32. this.shell = shell;
  33. // setShellStyle(SWT.RESIZE | SWT.TITLE);
  34. }
  35. public boolean generateApp()
  36. {
  37. return generateApp;
  38. }
  39. @Override
  40. protected Control createDialogArea(Composite parent) {
  41. Composite composite = (Composite) super.createDialogArea(parent);
  42. final GridLayout gridLayout = new GridLayout(1,false);
  43. composite.setLayout(gridLayout);
  44. final Group container = new Group(composite, SWT.NONE);
  45. container.setLayout(new GridLayout(3,false));
  46. GridData innergrid1 = new GridData(GridData.FILL_HORIZONTAL);
  47. innergrid1.horizontalSpan = 3;
  48. container.setLayoutData(innergrid1);
  49. addLabel(container, "Enter the name of the Static Trusted Library.");
  50. addLabel(container, "Make sure the name is unique within the hosting application.");
  51. final Label fileNameLabel = new Label(container, SWT.NONE);
  52. fileNameLabel.setText("Static Trusted Library Name:");
  53. fileNameLabel.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER, false, false));
  54. fileNameField = new Text(container,SWT.SINGLE | SWT.BORDER);
  55. GridData textGridData1 = new GridData(GridData.FILL_HORIZONTAL);
  56. textGridData1.minimumWidth = 400;
  57. textGridData1.grabExcessHorizontalSpace = true;
  58. fileNameField.setLayoutData(textGridData1);
  59. composite.layout();
  60. return composite;
  61. }
  62. @Override
  63. protected void configureShell(Shell newShell) {
  64. super.configureShell(newShell);
  65. newShell.setText("Add New Intel(R) SGX Static Trusted Library Dialog");
  66. }
  67. @Override
  68. protected
  69. void okPressed(){
  70. addHandler.edlFilename = fileNameField.getText();
  71. if(!fileNameField.getText().isEmpty()
  72. ){
  73. if(Character.isDigit(fileNameField.getText().charAt(0)))
  74. {
  75. JOptionPane.showMessageDialog(null, "Enclave names starting with digits are not allowed.", "Error",
  76. JOptionPane.ERROR_MESSAGE);
  77. }
  78. else
  79. super.okPressed();
  80. }
  81. }
  82. @Override
  83. protected Point getInitialSize(){
  84. return new Point(675,200);
  85. }
  86. public String getFileName() {
  87. return fileNameField.getText();
  88. }
  89. }