/**
   * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(ILaunchConfigurationWorkingCopy)
   */
  public void performApply(ILaunchConfigurationWorkingCopy configuration) {
    if (server != null) {
      configuration.setAttribute(Server.NAME, server.getName());
    } else {
      configuration.setAttribute(Server.NAME, (String) null);
    }
    String fileName = fFile.getText();

    String urlPath = fURLPath.getText().replace('\\', '/');
    if (urlPath.startsWith("/")) { // $NON-NLS-1$
      urlPath = urlPath.substring(1);
    }
    String url = fURLHost.getText() + urlPath;
    configuration.setAttribute(Server.FILE_NAME, fileName);
    configuration.setAttribute(Server.BASE_URL, url);
    configuration.setAttribute(AUTO_GENERATED_URL, autoGeneratedURL.getSelection());

    try {
      updateURLEnabled(configuration);
    } catch (CoreException e) {
      PHPDebugPlugin.log(e);
    }

    applyExtension(configuration);

    if (saveWorkingCopy) {
      try {
        configuration.doSave();
      } catch (CoreException e) {
      }
      saveWorkingCopy = false;
    }
    applyLaunchDelegateConfiguration(configuration);
  }
 protected void initializeURLControl() {
   if (fFile == null || fURLPath == null || fURLHost == null) {
     return;
   }
   String file;
   if (autoGeneratedURL.getSelection()) {
     file = formatFileName(fFile.getText());
   } else {
     file = fURLPath.getText();
   }
   updateURLComponents(computeURL(file));
 }
 protected void updateURLComponents(String urlStr) {
   try {
     URL url = new URL(urlStr);
     String port = url.getPort() == -1 ? "" : ":" + url.getPort(); // $NON-NLS-1$ //$NON-NLS-2$
     fURLHost.setText(
         url.getProtocol() + "://" + url.getHost() + port + "/"); // $NON-NLS-1$ //$NON-NLS-2$
     if (url.getQuery() != null) {
       fURLPath.setText(url.getPath() + "?" + url.getQuery()); // $NON-NLS-1$
     } else {
       fURLPath.setText(url.getPath());
     }
   } catch (MalformedURLException e) {
     Logger.logException(e);
   }
 }
 private void updateURLEnabled(ILaunchConfiguration configuration) throws CoreException {
   boolean enabled = configuration.getAttribute(SERVER_ENABLED, true);
   fURLLabel.getParent().setVisible(enabled);
   if (enabled) {
     fURLPath.setEnabled(!autoGeneratedURL.getSelection());
   }
 }
  public void createURLControl(Composite composite) {
    Group group = new Group(composite, SWT.NONE);
    String projectLabel = PHPServerUIMessages.getString("ServerTab.url"); // $NON-NLS-1$
    group.setText(projectLabel);
    group.setLayout(new GridLayout(2, false));
    group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    autoGeneratedURL = new Button(group, SWT.CHECK);
    autoGeneratedURL.setText(
        PHPServerUIMessages.getString("ServerTab.autoGenerate")); // $NON-NLS-1$
    autoGeneratedURL.setSelection(true);
    autoGeneratedURL.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
    autoGeneratedURL.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            initializeURLControl();
            updateLaunchConfigurationDialog();
          }
        });

    fURLLabel = new Label(group, SWT.NONE);
    fURLLabel.setText(PHPServerUIMessages.getString("ServerTab.urlLabel")); // $NON-NLS-1$
    GridData gridData = new GridData();
    gridData.horizontalIndent = 20;
    gridData.horizontalSpan = 1;
    fURLLabel.setLayoutData(gridData);

    Composite urlComposite = new Composite(group, SWT.NONE);
    urlComposite.setLayout(new GridLayout(2, false));
    urlComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    fURLHost = new Text(urlComposite, SWT.SINGLE | SWT.BORDER);
    fURLHost.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fURLHost.setEnabled(false);

    fURLPath = new Text(urlComposite, SWT.SINGLE | SWT.BORDER);
    fURLPath.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fURLPath.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            updateLaunchConfigurationDialog();
          }
        });
  }
 /** Tests if the current workbench selection is a suitable container to use. */
 private void initialize() {
   if (selection != null
       && selection.isEmpty() == false
       && selection instanceof IStructuredSelection) {
     IStructuredSelection ssel = (IStructuredSelection) selection;
     if (ssel.size() > 1) {
       return;
     }
     Object obj = ssel.getFirstElement();
     if (obj instanceof IResource) {
       IContainer container;
       if (obj instanceof IContainer) {
         container = (IContainer) obj;
       } else {
         container = ((IResource) obj).getParent();
       }
       containerText.setText(container.getFullPath().toString());
     }
   }
   fileText.setText("new.gaml");
 }
  protected void createFileComponent(Composite parent) {
    Group group = new Group(parent, SWT.NONE);
    String projectLabel = PHPServerUIMessages.getString("ServerTab.file_project"); // $NON-NLS-1$
    group.setText(projectLabel);
    group.setLayout(new GridLayout(3, false));
    group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    fFile = new Text(group, SWT.SINGLE | SWT.BORDER);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    fFile.setLayoutData(gd);
    fFile.addModifyListener(fListener);

    fileButton =
        createPushButton(
            group, PHPServerUIMessages.getString("ServerTab.browse"), null); // $NON-NLS-1$
    gd = (GridData) fileButton.getLayoutData();
    gd.horizontalSpan = 1;
    fileButton.addSelectionListener(fListener);

    handleServerSelection();
  }
 /**
  * Uses the standard container selection dialog to choose the new value for the container field.
  */
 private void handleBrowse() {
   ContainerSelectionDialog dialog =
       new ContainerSelectionDialog(
           getShell(),
           ResourcesPlugin.getWorkspace().getRoot(),
           false,
           "Select a project as a container");
   if (dialog.open() == Window.OK) {
     Object[] result = dialog.getResult();
     if (result.length == 1) {
       containerText.setText(((Path) result[0]).toString());
     }
   }
 }
  protected void handleFileButtonSelected() {

    IResource file = null;
    file = getFileFromDialog(null);

    if (file == null) return;

    String fName = file.getFullPath().toString();
    fFile.setText(fName);

    if (autoGeneratedURL.getSelection()) {
      updateURLComponents(computeURL(formatFileName(fName)));
    }
  }
  /** @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(ILaunchConfiguration) */
  public void initializeFrom(ILaunchConfiguration configuration) {
    serverCombo.setEnabled(true);
    // remove error message that other instances may have set
    setErrorMessage(null);

    try {
      String fileName = configuration.getAttribute(Server.FILE_NAME, ""); // $NON-NLS-1$
      String url = configuration.getAttribute(Server.BASE_URL, ""); // $NON-NLS-1$
      boolean isAutoGeneratedURL = configuration.getAttribute(AUTO_GENERATED_URL, true);

      initializeServerControl(configuration);

      if (isAutoGeneratedURL) {
        autoGeneratedURL.setSelection(true);
        String computedURL = computeURL(formatFileName(fileName));
        fURLLabel.setEnabled(false);
        updateURLComponents(computedURL);
        fURLPath.setEnabled(false);
      } else {
        autoGeneratedURL.setSelection(false);
        fURLLabel.setEnabled(true);
        updateURLComponents(url);
        fURLPath.setEnabled(true);
      }

      fFile.setText(fileName);

      updateFileEnabled(configuration);
      updateURLEnabled(configuration);
    } catch (CoreException e) {
      // ignore
    }

    initializeExtensionControls(configuration);

    isValid(configuration);
  }
Esempio n. 11
0
 private void radioChanged() {
   if (exampleModelButton.getSelection()) {
     descriptionText.setText("This model displays an awesome simulation of something ...");
     titleText.setText("example");
     fileText.setText("example.gaml");
     updateStatus(null);
   }
   if (emptyModelButton.getSelection() || skeletonModelButton.getSelection()) {
     descriptionText.setText("");
     titleText.setText("new");
     fileText.setText("new.gaml");
     updateStatus(null);
   }
   dialogChanged();
 }
Esempio n. 12
0
 /** Gets the model name of the new file */
 @Override
 public String getDescription() {
   return descriptionText.getText();
 }
Esempio n. 13
0
  @Override
  public void createControl(final Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 3;
    layout.verticalSpacing = 9;
    Label label = new Label(container, SWT.NULL);
    label.setText("&Container:");

    containerText = new Text(container, SWT.BORDER | SWT.SINGLE);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    containerText.setLayoutData(gd);
    containerText.addModifyListener(
        new ModifyListener() {

          @Override
          public void modifyText(final ModifyEvent e) {
            dialogChanged();
          }
        });

    Button button = new Button(container, SWT.PUSH);
    button.setText("Browse...");
    button.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent e) {
            handleBrowse();
          }
        });

    label = new Label(container, SWT.NULL);
    label.setText("&Choose a model:");

    Composite middleComposite = new Composite(container, SWT.NULL);
    FillLayout fillLayout = new FillLayout();
    middleComposite.setLayout(fillLayout);

    emptyModelButton = new Button(middleComposite, SWT.RADIO);
    emptyModelButton.setText("Empty");
    emptyModelButton.setSelection(true);
    skeletonModelButton = new Button(middleComposite, SWT.RADIO);
    skeletonModelButton.setText("Skeleton");
    exampleModelButton = new Button(middleComposite, SWT.RADIO);
    exampleModelButton.setText("Example");
    emptyModelButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent se) {
            typeOfModel = "empty";
            radioChanged();
          }
        });
    exampleModelButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent se) {
            typeOfModel = "example";
            radioChanged();
          }
        });
    skeletonModelButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent se) {
            typeOfModel = "skeleton";
            radioChanged();
          }
        });

    /* Need to add empty label so the next controls are pushed to the next line in the grid. */
    label = new Label(container, SWT.NULL);
    label.setText("");

    label = new Label(container, SWT.NULL);
    label.setText("&File name:");

    fileText = new Text(container, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    fileText.setLayoutData(gd);
    fileText.addModifyListener(
        new ModifyListener() {

          @Override
          public void modifyText(final ModifyEvent e) {
            Text t = (Text) e.getSource();
            String fname = t.getText();
            int i = fname.lastIndexOf(".gaml");
            if (i > 0) {
              // model title = filename less extension less all non alphanumeric characters
              titleText.setText(fname.substring(0, i).replaceAll("[^\\p{Alnum}]", ""));
            } /*
               * else if (fname.length()>0) {
               * int pos = t.getSelection().x;
               * fname = fname.replaceAll("[[^\\p{Alnum}]&&[^_-]&&[^\\x2E]]", "_");
               * t.setText(fname+".gaml");
               * t.setSelection(pos);
               * } else {
               * t.setText("new.gaml");
               * }
               */
            dialogChanged();
          }
        });

    /* Need to add empty label so the next two controls are pushed to the next line in the grid. */
    label = new Label(container, SWT.NULL);
    label.setText("");

    label = new Label(container, SWT.NULL);
    label.setText("&Author:");

    authorText = new Text(container, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    authorText.setLayoutData(gd);
    authorText.setText(getComputerFullName());
    authorText.addModifyListener(
        new ModifyListener() {

          @Override
          public void modifyText(final ModifyEvent e) {
            dialogChanged();
          }
        });

    /* Need to add empty label so the next two controls are pushed to the next line in the grid. */
    label = new Label(container, SWT.NULL);
    label.setText("");

    label = new Label(container, SWT.NULL);
    label.setText("&Model name:");

    titleText = new Text(container, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    titleText.setLayoutData(gd);
    titleText.setText("new");
    titleText.addModifyListener(
        new ModifyListener() {

          @Override
          public void modifyText(final ModifyEvent e) {
            dialogChanged();
          }
        });

    /* Need to add empty label so the next two controls are pushed to the next line in the grid. */
    label = new Label(container, SWT.NULL);
    label.setText("");

    label = new Label(container, SWT.NULL);
    label.setText("&Model description:");

    descriptionText =
        new Text(container, SWT.WRAP | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    descriptionText.setBounds(0, 0, 250, 100);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    gd.verticalSpan = 4;
    descriptionText.setLayoutData(gd);

    /*
     * Need to add seven empty labels in order to push next controls after the descriptionText
     * box.
     */
    // TODO Dirty!! Change the way to do this
    for (int i = 0; i < 7; i++) {
      label = new Label(container, SWT.NULL);
      label.setText("");
    }

    label = new Label(container, SWT.NULL);
    label.setText("&Create a html template \nfor the model description ?");

    middleComposite = new Composite(container, SWT.NULL);
    fillLayout = new FillLayout();
    middleComposite.setLayout(fillLayout);

    yesButton = new Button(middleComposite, SWT.RADIO);
    yesButton.setText("Yes");
    yesButton.setSelection(true);
    Button noButton = new Button(middleComposite, SWT.RADIO);
    noButton.setText("No");
    yesButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent se) {
            dialogChanged();
          }
        });

    /* Finished adding the custom control */
    initialize();
    dialogChanged();
    setControl(container);
  }
Esempio n. 14
0
 /** Gets the model name of the new file */
 public String getModelName() {
   return titleText.getText();
 }
Esempio n. 15
0
 /** Gets the author of the new file */
 public String getAuthor() {
   return authorText.getText();
 }
Esempio n. 16
0
 /** Gets the file name of the new file */
 public String getFileName() {
   return fileText.getText();
 }
Esempio n. 17
0
 /** Gets the container name of the new file */
 public String getContainerName() {
   // TODO user has to select a project otherwise it doesn't work
   return containerText.getText();
 }
 private void updateFileEnabled(ILaunchConfiguration configuration) throws CoreException {
   boolean enabled = configuration.getAttribute(SERVER_ENABLED, true);
   fFile.getParent().setVisible(enabled);
 }