@Override protected void updateData(ICResourceDescription cfg) { setValues(cfg.getConfiguration()); }
@Override protected void updateData(ICResourceDescription rd) { if (rd == null) return; icfgd = rd.getConfiguration(); setValues(); }
/** 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; }