Ejemplo n.º 1
0
  protected static void doProjectUpdate(IProgressMonitor monitor, IProject[] project)
      throws CoreException {
    monitor.beginTask(
        MakeUIPlugin.getResourceString("UpdateMakeProjectAction.monitor.update"),
        project.length * 4); // $NON-NLS-1$
    try {
      for (int i = 0; i < project.length; i++) {
        // remove old builder
        project[i].refreshLocal(IResource.DEPTH_ONE, new SubProgressMonitor(monitor, 1));
        MakeProjectNature.removeFromBuildSpec(
            project[i], MakeCorePlugin.OLD_BUILDER_ID, new SubProgressMonitor(monitor, 1));

        // convert .cdtproject
        CCorePlugin.getDefault().mapCProjectOwner(project[i], MakeCorePlugin.MAKE_PROJECT_ID, true);
        // add new nature
        MakeProjectNature.addNature(project[i], new SubProgressMonitor(monitor, 1));

        // move existing build properties to new
        IMakeBuilderInfo newInfo =
            MakeCorePlugin.createBuildInfo(project[i], MakeBuilder.BUILDER_ID);
        final int LOCATION = 0, FULL_ARGS = 1, INC_ARGS = 2, STOP_ERORR = 3, USE_DEFAULT = 4;
        QualifiedName[] qName = new QualifiedName[USE_DEFAULT + 1];
        qName[LOCATION] = new QualifiedName(CCorePlugin.PLUGIN_ID, "buildLocation"); // $NON-NLS-1$
        qName[FULL_ARGS] =
            new QualifiedName(CCorePlugin.PLUGIN_ID, "buildFullArguments"); // $NON-NLS-1$
        qName[INC_ARGS] =
            new QualifiedName(CCorePlugin.PLUGIN_ID, "buildIncrementalArguments"); // $NON-NLS-1$
        qName[STOP_ERORR] = new QualifiedName(CCorePlugin.PLUGIN_ID, "stopOnError"); // $NON-NLS-1$
        qName[USE_DEFAULT] =
            new QualifiedName(CCorePlugin.PLUGIN_ID, "useDefaultBuildCmd"); // $NON-NLS-1$

        String property = project[i].getPersistentProperty(qName[LOCATION]);
        if (property != null) {
          newInfo.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, property);
        }
        property = project[i].getPersistentProperty(qName[FULL_ARGS]);
        if (property != null) {
          newInfo.setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, property);
        }
        property = project[i].getPersistentProperty(qName[STOP_ERORR]);
        if (property != null) {
          newInfo.setStopOnError(Boolean.valueOf(property).booleanValue());
        }
        property = project[i].getPersistentProperty(qName[USE_DEFAULT]);
        if (property != null) {
          newInfo.setUseDefaultBuildCmd(Boolean.valueOf(property).booleanValue());
        }
        for (int j = 0; j < qName.length; j++) {
          project[i].setPersistentProperty(qName[j], null);
        }

        IProgressMonitor subMon =
            new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
        project[i].accept(new TargetConvertVisitor(subMon), 0);
        monitor.worked(1);
      }
    } finally {
      monitor.done();
    }
  }
Ejemplo n.º 2
0
 protected void createSettingControls(Composite parent) {
   Group group =
       ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_SETTING_GROUP), 1);
   stopOnErrorButton = new Button(group, SWT.CHECK);
   stopOnErrorButton.setText(MakeUIPlugin.getResourceString(MAKE_SETTING_STOP_ERROR));
   if (fBuildInfo.isStopOnError()) {
     stopOnErrorButton.setSelection(true);
   }
   stopOnErrorButton.setEnabled(fBuildInfo.isDefaultBuildCmd());
 }
Ejemplo n.º 3
0
  /**
   * @param project - project where to get build command from
   * @return build command from project settings.
   */
  public static String getProjectBuildCommand(IProject project) {
    IMakeTargetManager targetManager = MakeCorePlugin.getDefault().getTargetManager();
    String[] targetBuilders = targetManager.getTargetBuilders(project);
    if (targetBuilders == null || targetBuilders.length == 0) {
      return DEFAULT_BUILD_COMMAND;
    }

    String builderId = targetManager.getBuilderID(targetBuilders[0]);
    String buildCommand = DEFAULT_BUILD_COMMAND;
    try {
      IMakeBuilderInfo buildInfo = MakeCorePlugin.createBuildInfo(project, builderId);
      buildCommand = buildInfo.getBuildCommand().toString().trim();
    } catch (CoreException e) {
      // keep default value
    }
    return buildCommand;
  }
Ejemplo n.º 4
0
  @Override
  public void performDefaults() {
    // Missing builder info
    if (fBuildInfo == null) {
      return;
    }
    IMakeBuilderInfo info;
    if (getContainer().getProject() != null) {
      info = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, false);
    } else {
      info = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, true);
    }
    if (info.isStopOnError()) stopOnErrorButton.setSelection(true);
    else stopOnErrorButton.setSelection(false);
    if (info.getBuildCommand() != null) {
      StringBuffer cmd = new StringBuffer(info.getBuildCommand().toOSString());
      if (!info.isDefaultBuildCmd()) {
        String args = info.getBuildArguments();
        if (args != null && !args.equals("")) { // $NON-NLS-1$
          cmd.append(" "); // $NON-NLS-1$
          cmd.append(args);
        }
      }
      buildCommand.setText(cmd.toString());
    }
    if (info.isDefaultBuildCmd()) {
      buildCommand.setEnabled(false);
      argumentVariablesButton.setEnabled(false);
      stopOnErrorButton.setEnabled(true);
    } else {
      buildCommand.setEnabled(true);
      argumentVariablesButton.setEnabled(true);
      stopOnErrorButton.setEnabled(false);
    }

    defButton.setSelection(info.isDefaultBuildCmd());

    autoButton.setSelection(info.isAutoBuildEnable());
    autoVariableButton.setEnabled(info.isAutoBuildEnable());
    targetAuto.setEnabled(info.isAutoBuildEnable());
    targetAuto.setText(info.getAutoBuildTarget());
    incrButton.setSelection(info.isIncrementalBuildEnabled());
    incrVariableButton.setEnabled(info.isIncrementalBuildEnabled());
    targetIncr.setText(info.getIncrementalBuildTarget());
    targetIncr.setEnabled(info.isIncrementalBuildEnabled());
    cleanButton.setSelection(info.isCleanBuildEnabled());
    cleanVariableButton.setEnabled(info.isCleanBuildEnabled());
    targetClean.setText(info.getCleanBuildTarget());
    targetClean.setEnabled(info.isCleanBuildEnabled());
  }
Ejemplo n.º 5
0
  protected void createBuilderWorkingDirControls(Composite parent) {
    Group group =
        ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_BUILD_DIR_GROUP), 1);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.makeColumnsEqualWidth = false;
    group.setLayout(layout);
    group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Label label =
        ControlFactory.createLabel(group, MakeUIPlugin.getResourceString(MAKE_BUILD_DIR_LABEL));
    ((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING;
    ((GridData) (label.getLayoutData())).grabExcessHorizontalSpace = false;
    buildLocation = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
    ((GridData) (buildLocation.getLayoutData())).horizontalAlignment = GridData.FILL;
    ((GridData) (buildLocation.getLayoutData())).grabExcessHorizontalSpace = true;
    buildLocation.addListener(
        SWT.Modify,
        new Listener() {

          public void handleEvent(Event e) {
            getContainer().updateContainer();
          }
        });

    Composite buttons = ControlFactory.createComposite(group, 4);
    layout = new GridLayout(4, false);
    layout.marginHeight = layout.marginWidth = 0;
    buttons.setLayout(layout);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    buttons.setLayoutData(gd);

    Label emptyLabel = ControlFactory.createLabel(buttons, ""); // $NON-NLS-1$
    emptyLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Button browseWorkspace = new Button(buttons, SWT.NONE);
    browseWorkspace.setText(MakeUIPlugin.getResourceString(MAKE_BUILD_DIR_BROWSE_WORKSPACE));
    browseWorkspace.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            ContainerSelectionDialog dialog =
                new ContainerSelectionDialog(
                    getShell(),
                    getContainer().getProject(),
                    true,
                    MakeUIPlugin.getResourceString(
                        "SettingsBlock.title.selectLocationToBuildFrom")); //$NON-NLS-1$
            if (dialog.open() == Window.OK) {
              Object[] selection = dialog.getResult();
              if (selection.length > 0) {
                buildLocation.setText(((IPath) selection[0]).toOSString());
              }
            }
          }
        });

    Button browseFilesystem = new Button(buttons, SWT.NONE);
    browseFilesystem.setText(MakeUIPlugin.getResourceString(MAKE_BUILD_DIR_BROWSE_FILESYSTEM));
    browseFilesystem.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.NONE);
            dialog.setText(
                MakeUIPlugin.getResourceString(
                    "SettingsBlock.title.selectLocationToBuildFrom")); //$NON-NLS-1$
            dialog.setFilterPath(getContainer().getProject().toString());
            String directory = dialog.open();
            if (directory != null) {
              if (directory.trim().length() > 0) {
                buildLocation.setText(directory);
              }
            }
          }
        });

    buildLocation.setText(
        fBuildInfo.getBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION, "")); // $NON-NLS-1$
    locationVariablesButton = addVariablesButton(buttons, buildLocation);
  }
Ejemplo n.º 6
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);
  }
Ejemplo n.º 7
0
  protected void createBuildCmdControls(Composite parent) {
    Group group =
        ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_CMD_GROUP), 1);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    layout.makeColumnsEqualWidth = false;
    group.setLayout(layout);
    group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    defButton =
        ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_CMD_USE_DEFAULT));
    defButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            if (defButton.getSelection() == true) {
              buildCommand.setEnabled(false);
              argumentVariablesButton.setEnabled(false);
              stopOnErrorButton.setEnabled(true);
              getContainer().updateContainer();
            } else {
              buildCommand.setEnabled(true);
              argumentVariablesButton.setEnabled(true);
              stopOnErrorButton.setEnabled(false);
              getContainer().updateContainer();
            }
          }
        });
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 3;
    defButton.setLayoutData(gd);
    Label label = ControlFactory.createLabel(group, MakeUIPlugin.getResourceString(MAKE_CMD_LABEL));
    ((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING;
    ((GridData) (label.getLayoutData())).grabExcessHorizontalSpace = false;
    buildCommand = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);

    ((GridData) (buildCommand.getLayoutData())).horizontalAlignment = GridData.FILL;
    ((GridData) (buildCommand.getLayoutData())).grabExcessHorizontalSpace = true;
    buildCommand.addListener(
        SWT.Modify,
        new Listener() {

          public void handleEvent(Event e) {
            getContainer().updateContainer();
          }
        });
    if (fBuildInfo.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, null) != null) {
      StringBuffer cmd =
          new StringBuffer(
              fBuildInfo.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "")); // $NON-NLS-1$
      if (!fBuildInfo.isDefaultBuildCmd()) {
        String args =
            fBuildInfo.getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, ""); // $NON-NLS-1$
        if (args != null && !args.equals("")) { // $NON-NLS-1$
          cmd.append(" "); // $NON-NLS-1$
          cmd.append(args);
        }
      }
      buildCommand.setText(cmd.toString());
    }
    argumentVariablesButton = addVariablesButton(group, buildCommand);
    if (fBuildInfo.isDefaultBuildCmd()) {
      buildCommand.setEnabled(false);
      argumentVariablesButton.setEnabled(false);
    }
    defButton.setSelection(fBuildInfo.isDefaultBuildCmd());
  }