mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Cosmetics.
This commit is contained in:
parent
a840d359aa
commit
74d3d47147
3 changed files with 10 additions and 20 deletions
|
@ -51,9 +51,9 @@ import org.eclipse.cdt.internal.ui.text.SimpleCSourceViewerConfiguration;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public abstract class CPreview {
|
public abstract class CPreview {
|
||||||
|
|
||||||
private final class CSourcePreviewerUpdater {
|
private final class CSourcePreviewerUpdater {
|
||||||
|
|
||||||
final IPropertyChangeListener fontListener= new IPropertyChangeListener() {
|
final IPropertyChangeListener fontListener= new IPropertyChangeListener() {
|
||||||
public void propertyChange(PropertyChangeEvent event) {
|
public void propertyChange(PropertyChangeEvent event) {
|
||||||
if (event.getProperty().equals(PreferenceConstants.EDITOR_TEXT_FONT)) {
|
if (event.getProperty().equals(PreferenceConstants.EDITOR_TEXT_FONT)) {
|
||||||
|
@ -76,7 +76,6 @@ public abstract class CPreview {
|
||||||
};
|
};
|
||||||
|
|
||||||
public CSourcePreviewerUpdater() {
|
public CSourcePreviewerUpdater() {
|
||||||
|
|
||||||
JFaceResources.getFontRegistry().addListener(fontListener);
|
JFaceResources.getFontRegistry().addListener(fontListener);
|
||||||
fPreferenceStore.addPropertyChangeListener(propertyListener);
|
fPreferenceStore.addPropertyChangeListener(propertyListener);
|
||||||
|
|
||||||
|
@ -190,8 +189,6 @@ public abstract class CPreview {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Map<String, String> getWorkingValues() {
|
public Map<String, String> getWorkingValues() {
|
||||||
return fWorkingValues;
|
return fWorkingValues;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.preferences.formatter;
|
package org.eclipse.cdt.internal.ui.preferences.formatter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -28,11 +27,9 @@ import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.ICStatusConstants;
|
import org.eclipse.cdt.internal.ui.ICStatusConstants;
|
||||||
|
|
||||||
|
|
||||||
public class SnippetPreview extends CPreview {
|
public class SnippetPreview extends CPreview {
|
||||||
|
|
||||||
public final static class PreviewSnippet {
|
public final static class PreviewSnippet {
|
||||||
|
|
||||||
public String header;
|
public String header;
|
||||||
public final String source;
|
public final String source;
|
||||||
public final int kind;
|
public final int kind;
|
||||||
|
@ -45,7 +42,7 @@ public class SnippetPreview extends CPreview {
|
||||||
|
|
||||||
private ArrayList<PreviewSnippet> fSnippets;
|
private ArrayList<PreviewSnippet> fSnippets;
|
||||||
|
|
||||||
public SnippetPreview(Map<String,String> workingValues, Composite parent) {
|
public SnippetPreview(Map<String, String> workingValues, Composite parent) {
|
||||||
super(workingValues, parent);
|
super(workingValues, parent);
|
||||||
fSnippets= new ArrayList<PreviewSnippet>();
|
fSnippets= new ArrayList<PreviewSnippet>();
|
||||||
}
|
}
|
||||||
|
@ -57,14 +54,15 @@ public class SnippetPreview extends CPreview {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//This delimiter looks best for invisible characters
|
// This delimiter looks best for invisible characters
|
||||||
final String delimiter= "\n"; //$NON-NLS-1$
|
final String delimiter= "\n"; //$NON-NLS-1$
|
||||||
|
|
||||||
final StringBuffer buffer= new StringBuffer();
|
final StringBuffer buffer= new StringBuffer();
|
||||||
for (PreviewSnippet snippet: fSnippets) {
|
for (PreviewSnippet snippet: fSnippets) {
|
||||||
String formattedSource;
|
String formattedSource;
|
||||||
try {
|
try {
|
||||||
TextEdit edit= CodeFormatterUtil.format(snippet.kind, snippet.source, 0, delimiter, fWorkingValues);
|
TextEdit edit= CodeFormatterUtil.format(snippet.kind, snippet.source, 0, delimiter,
|
||||||
|
fWorkingValues);
|
||||||
if (edit == null) {
|
if (edit == null) {
|
||||||
formattedSource= snippet.source;
|
formattedSource= snippet.source;
|
||||||
} else {
|
} else {
|
||||||
|
@ -73,8 +71,9 @@ public class SnippetPreview extends CPreview {
|
||||||
formattedSource= document.get();
|
formattedSource= document.get();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
final IStatus status= new Status(IStatus.ERROR, CUIPlugin.getPluginId(), ICStatusConstants.INTERNAL_ERROR,
|
final IStatus status= new Status(IStatus.ERROR, CUIPlugin.getPluginId(),
|
||||||
FormatterMessages.CPreview_formatter_exception, e);
|
ICStatusConstants.INTERNAL_ERROR,
|
||||||
|
FormatterMessages.CPreview_formatter_exception, e);
|
||||||
CUIPlugin.log(status);
|
CUIPlugin.log(status);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -85,9 +84,7 @@ public class SnippetPreview extends CPreview {
|
||||||
}
|
}
|
||||||
fPreviewDocument.set(buffer.toString());
|
fPreviewDocument.set(buffer.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void add(PreviewSnippet snippet) {
|
public void add(PreviewSnippet snippet) {
|
||||||
fSnippets.add(snippet);
|
fSnippets.add(snippet);
|
||||||
}
|
}
|
||||||
|
@ -103,5 +100,4 @@ public class SnippetPreview extends CPreview {
|
||||||
public void clear() {
|
public void clear() {
|
||||||
fSnippets.clear();
|
fSnippets.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
* Sergey Prigogin, Google
|
* Sergey Prigogin, Google
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.preferences.formatter;
|
package org.eclipse.cdt.internal.ui.preferences.formatter;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -31,9 +30,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.ICStatusConstants;
|
import org.eclipse.cdt.internal.ui.ICStatusConstants;
|
||||||
|
|
||||||
|
|
||||||
public class TranslationUnitPreview extends CPreview {
|
public class TranslationUnitPreview extends CPreview {
|
||||||
|
|
||||||
private String fPreviewText;
|
private String fPreviewText;
|
||||||
private String fFormatterId;
|
private String fFormatterId;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue