use of org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy in project webtools.sourceediting by eclipse.
the class StyleSheetFormatter method formatPre.
/**
*/
protected void formatPre(ICSSNode node, IRegion region, java.lang.StringBuffer source) {
CSSCleanupStrategy stgy = getCleanupStrategy(node);
IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
for (int i = 0; i < regions.length; i++) {
if (i != 0 || needS(outside[0]) || regions[i].getType() == CSSRegionContexts.CSS_CDO || node.getOwnerDocument().getModel().getStyleSheetType() == ICSSModel.EMBEDDED)
appendDelimBefore(node, regions[i], source);
source.append(decoratedRegion(regions[i], 0, stgy));
}
if (needS(outside[1])) {
if (isIncludesPreEnd(node, region)) {
if (source.length() > 0 || node.getOwnerDocument().getModel().getStyleSheetType() == ICSSModel.EMBEDDED) {
String delim = getLineDelimiter(node);
source.append(delim);
}
}
}
}
use of org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy in project webtools.sourceediting by eclipse.
the class StyleSheetFormatter method formatPre.
/**
*/
protected void formatPre(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode node, java.lang.StringBuffer source) {
int start = ((IndexedRegion) node).getStartOffset();
int end = (node.getFirstChild() != null && ((IndexedRegion) node.getFirstChild()).getEndOffset() > 0) ? ((IndexedRegion) node.getFirstChild()).getStartOffset() : getChildInsertPos(node);
if (end > 0) {
CSSCleanupStrategy stgy = getCleanupStrategy(node);
IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
for (int i = 0; i < regions.length; i++) {
if (i != 0 || regions[i].getType() == CSSRegionContexts.CSS_CDO || node.getOwnerDocument().getModel().getStyleSheetType() == ICSSModel.EMBEDDED)
appendDelimBefore(node, regions[i], source);
source.append(decoratedRegion(regions[i], 0, stgy));
}
if (node.getLastChild() != null && (source.length() > 0 || node.getOwnerDocument().getModel().getStyleSheetType() == ICSSModel.EMBEDDED)) {
appendDelimBefore(node, null, source);
}
} else if (node.getOwnerDocument().getModel() != null && node.getOwnerDocument().getModel().getStyleSheetType() == ICSSModel.EMBEDDED) {
appendDelimBefore(node, null, source);
// source.append("<!--");
// appendDelimBefore(node,null, source);
} else
// nothing
return;
}
use of org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy in project webtools.sourceediting by eclipse.
the class StyleSheetFormatter method formatPost.
/**
*/
protected void formatPost(ICSSNode node, IRegion region, StringBuffer source) {
CSSCleanupStrategy stgy = getCleanupStrategy(node);
IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
for (int i = 0; i < regions.length; i++) {
if (i != 0 || needS(outside[0]))
appendDelimBefore(node, regions[i], source);
source.append(decoratedRegion(regions[i], 0, stgy));
}
}
use of org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy in project webtools.sourceediting by eclipse.
the class CleanupDialogCSS method setCleanupOptions.
/**
*/
protected void setCleanupOptions() {
CSSCleanupStrategy stgy = CSSCleanupStrategyImpl.getInstance();
if (fRadioButtonIdentCaseAsis != null) {
if (stgy.getIdentCase() == CSSCleanupStrategy.UPPER)
fRadioButtonIdentCaseUpper.setSelection(true);
else if (stgy.getIdentCase() == CSSCleanupStrategy.LOWER)
fRadioButtonIdentCaseLower.setSelection(true);
else
fRadioButtonIdentCaseAsis.setSelection(true);
}
if (fRadioButtonPropNameCaseAsis != null) {
if (stgy.getPropNameCase() == CSSCleanupStrategy.UPPER)
fRadioButtonPropNameCaseUpper.setSelection(true);
else if (stgy.getPropNameCase() == CSSCleanupStrategy.LOWER)
fRadioButtonPropNameCaseLower.setSelection(true);
else
fRadioButtonPropNameCaseAsis.setSelection(true);
}
if (fRadioButtonPropValueCaseAsis != null) {
if (stgy.getPropValueCase() == CSSCleanupStrategy.UPPER)
fRadioButtonPropValueCaseUpper.setSelection(true);
else if (stgy.getPropValueCase() == CSSCleanupStrategy.LOWER)
fRadioButtonPropValueCaseLower.setSelection(true);
else
fRadioButtonPropValueCaseAsis.setSelection(true);
}
if (fRadioButtonSelectorTagCaseAsis != null) {
if (stgy.getSelectorTagCase() == CSSCleanupStrategy.UPPER)
fRadioButtonSelectorTagCaseUpper.setSelection(true);
else if (stgy.getSelectorTagCase() == CSSCleanupStrategy.LOWER)
fRadioButtonSelectorTagCaseLower.setSelection(true);
else
fRadioButtonSelectorTagCaseAsis.setSelection(true);
}
if (fRadioButtonSelectorIdCaseAsis != null) {
if (stgy.getIdSelectorCase() == CSSCleanupStrategy.UPPER)
fRadioButtonSelectorIdCaseUpper.setSelection(true);
else if (stgy.getIdSelectorCase() == CSSCleanupStrategy.LOWER)
fRadioButtonSelectorIdCaseLower.setSelection(true);
else
fRadioButtonSelectorIdCaseAsis.setSelection(true);
}
if (fRadioButtonSelectorClassCaseAsis != null) {
if (stgy.getClassSelectorCase() == CSSCleanupStrategy.UPPER)
fRadioButtonSelectorClassCaseUpper.setSelection(true);
else if (stgy.getClassSelectorCase() == CSSCleanupStrategy.LOWER)
fRadioButtonSelectorClassCaseLower.setSelection(true);
else
fRadioButtonSelectorClassCaseAsis.setSelection(true);
}
if (fCheckBoxQuoteValues != null)
fCheckBoxQuoteValues.setSelection(stgy.isQuoteValues());
if (fCheckBoxFormatSource != null)
fCheckBoxFormatSource.setSelection(stgy.isFormatSource());
}
use of org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy in project webtools.sourceediting by eclipse.
the class CleanupDialogCSS method updateCleanupOptions.
/**
*/
protected void updateCleanupOptions() {
CSSCleanupStrategy stgy = CSSCleanupStrategyImpl.getInstance();
if (fRadioButtonIdentCaseAsis != null) {
if (fRadioButtonIdentCaseUpper.getSelection())
stgy.setIdentCase(CSSCleanupStrategy.UPPER);
else if (fRadioButtonIdentCaseLower.getSelection())
stgy.setIdentCase(CSSCleanupStrategy.LOWER);
else
stgy.setIdentCase(CSSCleanupStrategy.ASIS);
}
if (fRadioButtonPropNameCaseAsis != null) {
if (fRadioButtonPropNameCaseUpper.getSelection())
stgy.setPropNameCase(CSSCleanupStrategy.UPPER);
else if (fRadioButtonPropNameCaseLower.getSelection())
stgy.setPropNameCase(CSSCleanupStrategy.LOWER);
else
stgy.setPropNameCase(CSSCleanupStrategy.ASIS);
}
if (fRadioButtonPropValueCaseAsis != null) {
if (fRadioButtonPropValueCaseUpper.getSelection())
stgy.setPropValueCase(CSSCleanupStrategy.UPPER);
else if (fRadioButtonPropValueCaseLower.getSelection())
stgy.setPropValueCase(CSSCleanupStrategy.LOWER);
else
stgy.setPropValueCase(CSSCleanupStrategy.ASIS);
}
if (fRadioButtonSelectorTagCaseAsis != null) {
if (fRadioButtonSelectorTagCaseUpper.getSelection())
stgy.setSelectorTagCase(CSSCleanupStrategy.UPPER);
else if (fRadioButtonSelectorTagCaseLower.getSelection())
stgy.setSelectorTagCase(CSSCleanupStrategy.LOWER);
else
stgy.setSelectorTagCase(CSSCleanupStrategy.ASIS);
}
if (fRadioButtonSelectorIdCaseAsis != null) {
if (fRadioButtonSelectorIdCaseUpper.getSelection())
stgy.setIdSelectorCase(CSSCleanupStrategy.UPPER);
else if (fRadioButtonSelectorIdCaseLower.getSelection())
stgy.setIdSelectorCase(CSSCleanupStrategy.LOWER);
else
stgy.setIdSelectorCase(CSSCleanupStrategy.ASIS);
}
if (fRadioButtonSelectorClassCaseAsis != null) {
if (fRadioButtonSelectorClassCaseUpper.getSelection())
stgy.setClassSelectorCase(CSSCleanupStrategy.UPPER);
else if (fRadioButtonSelectorClassCaseLower.getSelection())
stgy.setClassSelectorCase(CSSCleanupStrategy.LOWER);
else
stgy.setClassSelectorCase(CSSCleanupStrategy.ASIS);
}
if (fCheckBoxQuoteValues != null)
stgy.setQuoteValues(fCheckBoxQuoteValues.getSelection());
if (fCheckBoxFormatSource != null)
stgy.setFormatSource(fCheckBoxFormatSource.getSelection());
// save these values to preferences
((CSSCleanupStrategyImpl) stgy).saveOptions();
}
Aggregations