Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
Expand Down Expand Up @@ -44,7 +44,6 @@
public class AntCodeFormatterPreferencePage extends AbstractAntEditorPreferencePage {

private SourceViewer fPreviewViewer;
private AntPreviewerUpdater fPreviewerUpdater;

@Override
protected OverlayPreferenceStore createOverlayStore() {
Expand Down Expand Up @@ -137,7 +136,7 @@ private Control createPreviewer(Composite parent) {
fPreviewViewer.getTextWidget().setFont(font);

IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { getOverlayStore(), EditorsUI.getPreferenceStore() });
fPreviewerUpdater = new AntPreviewerUpdater(fPreviewViewer, configuration, store);
new AntPreviewerUpdater(fPreviewViewer, configuration, store);

String content = loadPreviewContentFromFile("FormatPreviewCode.txt"); //$NON-NLS-1$
content = formatContent(content, store);
Expand All @@ -159,14 +158,6 @@ protected void handleDefaults() {
// do nothing
}

@Override
public void dispose() {
super.dispose();
if (fPreviewerUpdater != null) {
fPreviewerUpdater.dispose();
}
}

@Override
protected String getHelpContextId() {
return IAntUIHelpContextIds.ANT_EDITOR_FORMATTER_PREFERENCE_PAGE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -105,7 +104,7 @@ public int getSelection(String value) {

/**
* Item in the highlighting color list.
*
*
* @since 3.0
*/
private static class HighlightingColorListItem {
Expand All @@ -122,7 +121,7 @@ private static class HighlightingColorListItem {

/**
* Initialize the item with the given values.
*
*
* @param displayName
* the display name
* @param colorKey
Expand Down Expand Up @@ -180,7 +179,7 @@ public Color getItemColor() {

/**
* Color list label provider.
*
*
* @since 3.0
*/
private static class ColorListLabelProvider extends LabelProvider implements IColorProvider {
Expand All @@ -203,7 +202,7 @@ public Color getBackground(Object element) {

/**
* Color list content provider.
*
*
* @since 3.0
*/
private static class ColorListContentProvider implements IStructuredContentProvider {
Expand Down Expand Up @@ -239,7 +238,6 @@ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
private final List<HighlightingColorListItem> fHighlightingColorList = new ArrayList<>(5);

private SourceViewer fPreviewViewer;
private AntPreviewerUpdater fPreviewerUpdater;

private SelectionListener fSelectionListener;
protected Map<String, String> fWorkingValues;
Expand Down Expand Up @@ -522,7 +520,7 @@ private Control createPreviewer(Composite parent) {
fPreviewViewer.getTextWidget().setFont(font);

IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { getOverlayStore(), EditorsUI.getPreferenceStore() });
fPreviewerUpdater = new AntPreviewerUpdater(fPreviewViewer, configuration, store);
new AntPreviewerUpdater(fPreviewViewer, configuration, store);

String content = loadPreviewContentFromFile("SyntaxPreviewCode.txt"); //$NON-NLS-1$
IDocument document = new Document(content);
Expand All @@ -542,7 +540,7 @@ private void handleSyntaxColorListSelection() {

/**
* Returns the current highlighting color list item.
*
*
* @return the current highlighting color list item
* @since 3.0
*/
Expand All @@ -551,14 +549,6 @@ private HighlightingColorListItem getHighlightingColorListItem() {
return (HighlightingColorListItem) selection.getFirstElement();
}

@Override
public void dispose() {
super.dispose();
if (fPreviewerUpdater != null) {
fPreviewerUpdater.dispose();
}
}

private Composite createProblemsTabContent(TabFolder folder) {
fComboBoxes = new ArrayList<>();
fProblemLabels = new ArrayList<>();
Expand Down Expand Up @@ -712,10 +702,8 @@ protected void updateControls() {

@Override
public boolean performOk() {
Iterator<String> iter = fWorkingValues.keySet().iterator();
IPreferenceStore store = getPreferenceStore();
while (iter.hasNext()) {
String key = iter.next();
for (String key : fWorkingValues.keySet()) {
store.putValue(key, fWorkingValues.get(key));
}
if (store.needsSaving()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@
*/
class AntPreviewerUpdater {

private Color fForegroundColor = null;
private Color fBackgroundColor = null;
private Color fSelectionBackgroundColor = null;
private Color fSelectionForegroundColor = null;

/**
* Creates a source preview updater for the given viewer, configuration and preference store.
*
Expand Down Expand Up @@ -122,44 +117,20 @@ protected void initializeViewerColors(ISourceViewer viewer, IPreferenceStore sto
: createColor(store, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, styledText.getDisplay());
styledText.setForeground(color);

if (fForegroundColor != null) {
fForegroundColor.dispose();
}

fForegroundColor = color;

// ---------- background color ----------------------
color = store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT) ? null
: createColor(store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay());
styledText.setBackground(color);

if (fBackgroundColor != null) {
fBackgroundColor.dispose();
}

fBackgroundColor = color;

// ----------- selection foreground color --------------------
color = store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT) ? null
: createColor(store, AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND, styledText.getDisplay());
styledText.setSelectionForeground(color);

if (fSelectionForegroundColor != null) {
fSelectionForegroundColor.dispose();
}

fSelectionForegroundColor = color;

// ---------- selection background color ----------------------
color = store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT) ? null
: createColor(store, AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND, styledText.getDisplay());
styledText.setSelectionBackground(color);

if (fSelectionBackgroundColor != null) {
fSelectionBackgroundColor.dispose();
}

fSelectionBackgroundColor = color;
}

/**
Expand Down Expand Up @@ -192,25 +163,4 @@ private Color createColor(IPreferenceStore store, String key, Display display) {
return null;
}

public void dispose() {
if (fForegroundColor != null) {
fForegroundColor.dispose();
fForegroundColor = null;
}

if (fBackgroundColor != null) {
fBackgroundColor.dispose();
fBackgroundColor = null;
}

if (fSelectionForegroundColor != null) {
fSelectionForegroundColor.dispose();
fSelectionForegroundColor = null;
}

if (fSelectionBackgroundColor != null) {
fSelectionBackgroundColor.dispose();
fSelectionBackgroundColor = null;
}
}
}
Loading