use of net.sf.eclipsecs.core.jobs.ConfigureDeconfigureNatureJob in project eclipse-cs by checkstyle.
the class CheckstylePropertyPage method performOk.
@Override
public boolean performOk() {
try {
IProject project = mProjectConfig.getProject();
// save the edited project configuration
if (mProjectConfig.isDirty()) {
mProjectConfig.store();
}
boolean checkstyleEnabled = mChkEnable.getSelection();
boolean needRebuild = mProjectConfig.isRebuildNeeded();
// check if checkstyle nature has to be configured/deconfigured
if (checkstyleEnabled != mCheckstyleInitiallyActivated) {
ConfigureDeconfigureNatureJob configOperation = new ConfigureDeconfigureNatureJob(project, CheckstyleNature.NATURE_ID);
configOperation.setRule(ResourcesPlugin.getWorkspace().getRoot());
configOperation.schedule();
needRebuild = needRebuild || !mCheckstyleInitiallyActivated;
}
if (checkstyleEnabled && mProjectConfig.isSyncFormatter()) {
TransformCheckstyleRulesJob transFormJob = new TransformCheckstyleRulesJob(project);
transFormJob.schedule();
}
// really be done.
if (checkstyleEnabled && needRebuild) {
String promptRebuildPref = CheckstyleUIPluginPrefs.getString(CheckstyleUIPluginPrefs.PREF_ASK_BEFORE_REBUILD);
boolean doRebuild = MessageDialogWithToggle.ALWAYS.equals(promptRebuildPref) && needRebuild;
//
if (MessageDialogWithToggle.PROMPT.equals(promptRebuildPref) && needRebuild) {
MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(getShell(), Messages.CheckstylePropertyPage_titleRebuild, Messages.CheckstylePropertyPage_msgRebuild, Messages.CheckstylePropertyPage_nagRebuild, false, CheckstyleUIPlugin.getDefault().getPreferenceStore(), CheckstyleUIPluginPrefs.PREF_ASK_BEFORE_REBUILD);
doRebuild = dialog.getReturnCode() == IDialogConstants.YES_ID;
}
// check if a rebuild is necessary
if (checkstyleEnabled && doRebuild) {
BuildProjectJob rebuildOperation = new BuildProjectJob(project, IncrementalProjectBuilder.FULL_BUILD);
rebuildOperation.setRule(ResourcesPlugin.getWorkspace().getRoot());
rebuildOperation.schedule();
}
}
} catch (CheckstylePluginException e) {
CheckstyleUIPlugin.errorDialog(getShell(), e, true);
}
return true;
}
Aggregations