Exemple #1
0
  protected void cfgChanged(ICConfigurationDescription _cfgd) {

    CConfigurationStatus st = _cfgd.getConfigurationStatus();
    if (errPane != null && errMessage != null) {
      if (st.isOK()) {
        errPane.setVisible(false);
      } else {
        errMessage.setText(st.getMessage());
        errPane.setVisible(true);
      }
    }

    resd = getResDesc(_cfgd);

    if (excludeFromBuildCheck != null) {
      excludeFromBuildCheck.setEnabled(resd.canExclude(!resd.isExcluded()));
      excludeFromBuildCheck.setSelection(resd.isExcluded());
    }
    int x = CDTPropertyManager.getPagesCount();
    for (int i = 0; i < x; i++) {
      Object p = CDTPropertyManager.getPage(i);
      if (p == null || !(p instanceof AbstractPage)) continue;
      AbstractPage ap = (AbstractPage) p;
      if (ap.displayedConfig) ap.forEach(ICPropertyTab.UPDATE, getResDesc());
    }
  }
Exemple #2
0
  @Override
  public ICResourceDescription getResDesc(ICConfigurationDescription cf) {
    IAdaptable ad = getElement();

    if (isForProject()) return cf.getRootFolderDescription();
    ICResourceDescription out = null;
    IResource res = (IResource) ad;
    IPath p = res.getProjectRelativePath();
    if (isForFolder() || isForFile()) {
      if (cf instanceof ICMultiItemsHolder) {
        out = cf.getResourceDescription(p, isForFolder()); // sic !
      } else {
        out = cf.getResourceDescription(p, false);
        if (!p.equals(out.getPath())) {
          try {
            if (isForFolder()) out = cf.createFolderDescription(p, (ICFolderDescription) out);
            else out = cf.createFileDescription(p, out);
          } catch (CoreException e) {
            System.out.println(
                Messages.AbstractPage_10
                    + p.toOSString()
                    + "\n"
                    + e.getLocalizedMessage()); // $NON-NLS-1$
          }
        }
      }
    }
    return out;
  }
Exemple #3
0
  @Override
  public void setVisible(boolean visible) {
    super.setVisible(visible);
    if (visible) {
      handleResize(true);
      displayedConfig = true;
      if (excludeFromBuildCheck != null && resd != null)
        excludeFromBuildCheck.setSelection(resd.isExcluded());
      populateConfigurations();
    }

    if (itabs.size() < 1) return;

    if (currentTab == null && folder.getItemCount() > 0) {
      Object ob = folder.getItem(0).getData();
      currentTab = (ICPropertyTab) ob;
    }
    if (currentTab != null)
      currentTab.handleTabEvent(ICPropertyTab.VISIBLE, visible ? NOT_NULL : null);
  }
 @Override
 protected void updateData(ICResourceDescription rd) {
   if (rd == null) return;
   icfgd = rd.getConfiguration();
   setValues();
 }
 @Override
 protected void updateData(ICResourceDescription cfg) {
   setValues(cfg.getConfiguration());
 }
Exemple #6
0
  /** The same code used to perform OK and Apply */
  private boolean performSave(int mode) {
    final int finalMode = mode;
    if (noContentOnPage || !displayedConfig) return true;
    if ((mode == SAVE_MODE_OK || mode == SAVE_MODE_APPLYOK) && CDTPropertyManager.isSaveDone())
      return true; // do not duplicate

    final boolean needs = (mode != SAVE_MODE_OK);
    final ICProjectDescription local_prjd =
        needs ? CoreModel.getDefault().getProjectDescription(getProject()) : null;

    ICResourceDescription lc = null;

    if (needs) {
      if (isMultiCfg()) {
        ICResourceDescription[] rds =
            (ICResourceDescription[]) ((ICMultiItemsHolder) resd).getItems();
        for (int i = 0; i < rds.length; i++) {
          ICConfigurationDescription c =
              local_prjd.getConfigurationById(rds[i].getConfiguration().getId());
          rds[i] = getResDesc(c);
        }
        lc = MultiItemsHolder.createRDescription(rds);
      } else {
        ICConfigurationDescription c = findCfg(local_prjd, resd.getConfiguration());
        if (c == null) return false; // cannot save: no cfg found
        lc = getResDesc(c);
      }
    }
    final ICResourceDescription local_cfgd = lc;

    final boolean rebuildIndex = isIndexerAffected();
    IRunnableWithProgress runnable =
        new IRunnableWithProgress() {

          private void sendOK() {
            for (int j = 0; j < CDTPropertyManager.getPagesCount(); j++) {
              Object p = CDTPropertyManager.getPage(j);
              if (p != null && p instanceof AbstractPage) {
                AbstractPage ap = (AbstractPage) p;
                if (ap.displayedConfig) ap.forEach(ICPropertyTab.OK, null);
              }
            }
          }

          @Override
          public void run(IProgressMonitor monitor) {
            // ask all tabs to store changes in cfg
            switch (finalMode) {
              case SAVE_MODE_APPLYOK:
                sendOK();
                ICConfigurationDescription[] olds =
                    CDTPropertyManager.getProjectDescription(AbstractPage.this, getProject())
                        .getConfigurations();
                for (ICConfigurationDescription old : olds) {
                  resd = getResDesc(old);
                  ICResourceDescription r =
                      getResDesc(local_prjd.getConfigurationById(old.getId()));
                  for (int j = 0; j < CDTPropertyManager.getPagesCount(); j++) {
                    Object p = CDTPropertyManager.getPage(j);
                    if (p != null && p instanceof AbstractPage) {
                      AbstractPage ap = (AbstractPage) p;
                      if (ap.displayedConfig) {
                        ap.forEach(ICPropertyTab.UPDATE, resd);
                        ap.forEach(ICPropertyTab.APPLY, r);
                      }
                    }
                  }
                }
                break;
              case SAVE_MODE_APPLY:
                forEach(ICPropertyTab.APPLY, local_cfgd);
                break;
              case SAVE_MODE_OK:
                sendOK();
                break;
            } // end switch
            try {
              if (needs) //
              CoreModel.getDefault().setProjectDescription(getProject(), local_prjd);
              else CDTPropertyManager.performOk(AbstractPage.this);
            } catch (CoreException e) {
              CUIPlugin.logError(Messages.AbstractPage_11 + e.getLocalizedMessage());
            }
            updateViews(internalElement);
          }
        };
    IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
    try {
      PlatformUI.getWorkbench()
          .getProgressService()
          .runInUI(
              new ProgressMonitorDialog(getShell()), op, ResourcesPlugin.getWorkspace().getRoot());
    } catch (InvocationTargetException e) {
      Throwable e1 = e.getTargetException();
      CUIPlugin.errorDialog(getShell(), Messages.AbstractPage_8, Messages.AbstractPage_9, e1, true);
      return false;
    } catch (InterruptedException e) {
      // IProgressService.runInUI(...) misuses this exception to signal that the operation was
      // canceled.
      return false;
    }

    if (rebuildIndex) rebuildIndex();
    return true;
  }