Esempio n. 1
0
  public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);

    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    composite.setLayout(gridLayout);

    Label urlLabel = new Label(composite, SWT.NONE);
    urlLabel.setText(Messages.Wizard_WW_Description);
    GridData gridLabel = new GridData();
    urlLabel.setLayoutData(gridLabel);

    // region Enter URL
    btnUrl = new Button(composite, SWT.RADIO);
    btnUrl.addSelectionListener(radioSelectionListener);
    btnUrl.setSelection(true);
    btnUrl.setText(Messages.Wizard_WW_Url);

    comboUrl = new Combo(composite, SWT.BORDER);
    comboUrl.setItems(getRecentURLs());
    comboUrl.setVisibleItemCount(RecentHistory.DEFAULT_LIMIT);

    GridData gridDataCombo = new GridData(GridData.FILL_HORIZONTAL);
    gridDataCombo.widthHint = 400;
    comboUrl.setLayoutData(gridDataCombo);

    // For Drag 'n Drop as well as for general selections
    // look for a url as part of the selection
    Map<String, Serializable> params = defaultParams(); // based on selection
    setDefaultUrl(getURL(params));

    comboUrl.addModifyListener(this);
    // endregion

    // region Select local file
    btnLocalFile = new Button(composite, SWT.RADIO);
    btnLocalFile.setText(Messages.Wizard_WW_LocalFile);

    Composite row = new Composite(composite, SWT.NONE);
    row.setLayout(new RowLayout(SWT.HORIZONTAL));

    txtLocalFile = new Text(row, SWT.BORDER);
    txtLocalFile.setLayoutData(new RowData(350, 20));

    btnOpenFileDialog = new Button(row, SWT.PUSH);
    btnOpenFileDialog.setText(Messages.Wizard_WW_SelectFile);
    final Shell shell = parent.getShell();
    btnOpenFileDialog.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            FileDialog fd = new FileDialog(shell, SWT.OPEN);
            fd.setText(Messages.Wizard_WW_SelectFile);
            setLastUsedPath(fd);

            // Set filter on XML-files
            String[] filterExtensions = {"*.xml"}; // $NON-NLS-1$
            String[] filterNames = {"NASA WorldWind Configuration File (*.xml)"}; // $NON-NLS-1$
            fd.setFilterExtensions(filterExtensions);
            fd.setFilterNames(filterNames);

            // Open the dialog
            String selectedFile = fd.open();

            if (selectedFile != null) {
              txtLocalFile.setText(selectedFile);
              saveLastUsedPath(fd.getFilterPath());

              modifyText(null);
            }
          }

          private void saveLastUsedPath(String path) {
            if (settings != null && path != null) {
              settings.put(WW_PATH, path);
            }
          }

          private void setLastUsedPath(FileDialog fd) {
            if (settings != null) {
              fd.setFilterPath(settings.get(WW_PATH));
            }
          }
        });
    // endregion

    radioSelectionListener.widgetSelected(null);

    setControl(composite);
    getWizard().getContainer().updateButtons();

    Display.getCurrent()
        .asyncExec(
            new Runnable() {
              public void run() {
                EndConnectionState currentState = getState();
                Map<IService, Throwable> errors = currentState.getErrors();
                if (errors != null && !errors.isEmpty()) {
                  for (Map.Entry<IService, Throwable> entry : errors.entrySet()) {
                    if (entry.getKey() instanceof WWService) {
                      Throwable value = entry.getValue();
                      String message =
                          Messages.Wizard_WW_ConnectionProblem + value.getLocalizedMessage();
                      setErrorMessage(message);
                    }
                  }
                }
              }
            });
  }
 @Override
 public void mouseDoubleClick(MouseEvent arg0) {
   onConnecToToHost.widgetSelected(null);
 }
Esempio n. 3
0
  protected void createWorkBenchBuildControls(Composite parent) {
    SelectionAdapter selectionAdapter =
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            targetAuto.setEnabled(autoButton.getSelection());
            autoVariableButton.setEnabled(autoButton.getSelection());
            targetIncr.setEnabled(incrButton.getSelection());
            incrVariableButton.setEnabled(incrButton.getSelection());
            targetClean.setEnabled(cleanButton.getSelection());
            cleanVariableButton.setEnabled(cleanButton.getSelection());
            getContainer().updateContainer();
          }
        };
    Group group =
        ControlFactory.createGroup(
            parent, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_GROUP), 1);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    layout.makeColumnsEqualWidth = false;
    group.setLayout(layout);
    group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Label label = new Label(group, SWT.NONE);
    label.setText(MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_TYPE));
    label = new Label(group, SWT.NONE);
    label.setText(MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_TARGET));
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 2;
    label.setLayoutData(gd);
    autoButton =
        ControlFactory.createCheckBox(
            group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_AUTO));
    autoButton.addSelectionListener(selectionAdapter);
    autoButton.setSelection(fBuildInfo.isAutoBuildEnable());
    targetAuto = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
    targetAuto.setText(
        fBuildInfo.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, "")); // $NON-NLS-1$
    ((GridData) (targetAuto.getLayoutData())).horizontalAlignment = GridData.FILL;
    ((GridData) (targetAuto.getLayoutData())).grabExcessHorizontalSpace = true;
    addControlAccessibleListener(
        targetAuto, MakeUIPlugin.getResourceString(MAKE_BUILD_AUTO_TARGET));
    autoVariableButton = addVariablesButton(group, targetAuto);
    String noteTitle =
        MakeUIPlugin.getResourceString("SettingsBlock.makeWorkbench.note"); // $NON-NLS-1$
    String noteMessage =
        MakeUIPlugin.getResourceString(
            "SettingsBlock.makeWorkbench.autobuildMessage"); //$NON-NLS-1$
    Composite noteControl =
        createNoteComposite(JFaceResources.getDialogFont(), group, noteTitle, noteMessage);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 3;
    noteControl.setLayoutData(gd);
    incrButton =
        ControlFactory.createCheckBox(
            group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_INCR));
    incrButton.addSelectionListener(selectionAdapter);
    incrButton.setSelection(fBuildInfo.isIncrementalBuildEnabled());
    targetIncr = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
    targetIncr.setText(
        fBuildInfo.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL, "")); // $NON-NLS-1$
    ((GridData) (targetIncr.getLayoutData())).horizontalAlignment = GridData.FILL;
    ((GridData) (targetIncr.getLayoutData())).grabExcessHorizontalSpace = true;
    addControlAccessibleListener(
        targetIncr, MakeUIPlugin.getResourceString(MAKE_BUILD_INCREMENTAL_TARGET));
    incrVariableButton = addVariablesButton(group, targetIncr);
    cleanButton =
        ControlFactory.createCheckBox(
            group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_CLEAN));
    cleanButton.addSelectionListener(selectionAdapter);
    cleanButton.setSelection(fBuildInfo.isCleanBuildEnabled());
    targetClean = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
    targetClean.setText(
        fBuildInfo.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_CLEAN, "")); // $NON-NLS-1$
    ((GridData) (targetClean.getLayoutData())).horizontalAlignment = GridData.FILL;
    ((GridData) (targetClean.getLayoutData())).grabExcessHorizontalSpace = true;
    addControlAccessibleListener(
        targetClean, MakeUIPlugin.getResourceString(MAKE_BUILD_CLEAN_TARGET));
    cleanVariableButton = addVariablesButton(group, targetClean);
    selectionAdapter.widgetSelected(null);
  }