Skip to content

Commit

Permalink
Merge pull request #748 from claesrosell/JSEditor_is_leaking_Fonts_#734
Browse files Browse the repository at this point in the history
JSEditor is leaking fonts #734
  • Loading branch information
ruspl-afed committed Nov 27, 2021
2 parents 0166aeb + 29137df commit 2a94776
Showing 1 changed file with 48 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*************************************************************************************
* Copyright (c) 2004-2009 Actuate Corporation and others.
* All rights reserved. This program and the accompanying materials
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
*
* Contributors:
* Actuate Corporation - Initial implementation.
************************************************************************************/
Expand Down Expand Up @@ -70,6 +70,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.gef.ui.views.palette.PalettePage;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
Expand Down Expand Up @@ -334,7 +335,7 @@ public JSEditor(IEditorPart parent) {

/**
* Creates script editor, dosen't include controller
*
*
* @return a script editor
*/
protected IScriptEditor createScriptEditor() {
Expand All @@ -360,7 +361,7 @@ public boolean isDirty() {

/*
* (non-Javadoc)
*
*
* @see org.eclipse.ui.editors.text.TextEditor#isSaveAsAllowed()
*/
public boolean isSaveAsAllowed() {
Expand Down Expand Up @@ -514,7 +515,7 @@ private void updateScriptContext(DesignElementHandle handle, String method) {

/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets
* .Composite)
Expand Down Expand Up @@ -591,7 +592,7 @@ public void handleEvent(Event event) {

/**
* Connect the root to add the listener
*
*
* @param root
*/
public void connectRoot(ModuleHandle root) {
Expand All @@ -604,7 +605,7 @@ public void connectRoot(ModuleHandle root) {

/**
* DisConnect the root to add the listener
*
*
* @param root
*/
public void disConnectRoot(ModuleHandle root) {
Expand All @@ -617,7 +618,7 @@ public void disConnectRoot(ModuleHandle root) {

/**
* Sets the status of the text listener.
*
*
* @param enabled <code>true</code> if enable, <code>false</code> otherwise.
*/
private void setTextListenerEnable(boolean enabled) {
Expand All @@ -626,7 +627,7 @@ private void setTextListenerEnable(boolean enabled) {

/**
* Get current edit element, not report design model.
*
*
* @return
*/
public Object getModel() {
Expand All @@ -636,7 +637,7 @@ public Object getModel() {

/**
* Returns parent editor.
*
*
* @return parent editor.
*/
public IEditorPart getParentEditor() {
Expand All @@ -655,7 +656,7 @@ private void updateAnnotationLabel(Object handle) {

/*
* (non-Javadoc)
*
*
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
public Object getAdapter(Class adapter) {
Expand Down Expand Up @@ -709,9 +710,9 @@ protected PropertyHandle getPropertyHandle() {
}

/**
*
*
* initEditorLayout - initialize the UI components of the editor
*
*
*/
private Composite initEditorLayout(Composite parent) {
// Create the editor parent composite.
Expand Down Expand Up @@ -742,7 +743,7 @@ private Composite initEditorLayout(Composite parent) {

/*
* (non-Javadoc)
*
*
* @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse
* .swt.events.PaintEvent)
*/
Expand All @@ -767,7 +768,7 @@ public void paintControl(PaintEvent e) {

/**
* Creates tool bar pane.
*
*
* @param parent the parent of controller
*/
private void createController(Composite parent) {
Expand Down Expand Up @@ -803,7 +804,7 @@ private void createController(Composite parent) {

/*
* (non-Javadoc)
*
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
Expand All @@ -826,7 +827,7 @@ public void widgetSelected(SelectionEvent e) {

/*
* (non-Javadoc)
*
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
Expand All @@ -849,7 +850,7 @@ public void widgetSelected(SelectionEvent e) {

/*
* (non-Javadoc)
*
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
Expand All @@ -874,7 +875,7 @@ public void widgetSelected(SelectionEvent e) {

/**
* Creates description pane.
*
*
* @param parent the parent of controller
*/
private void createDescriptionPane(Composite parent) {
Expand All @@ -897,7 +898,7 @@ private void createDescriptionPane(Composite parent) {

/*
* (non-Javadoc)
*
*
* @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse
* .swt.events.PaintEvent)
*/
Expand Down Expand Up @@ -925,7 +926,7 @@ protected void hideValidateButtonIcon() {

/**
* Hides a control from its parent composite.
*
*
* @param control the control to hide
*/
private void hideControl(Control control) {
Expand All @@ -951,7 +952,7 @@ private void hideControl(Control control) {

/**
* Shows a control from its parent composite.
*
*
* @param control the control to show
*/
private void showControl(Control control) {
Expand Down Expand Up @@ -1185,7 +1186,7 @@ private Object findData(String name) {

/**
* setEditorText - sets the editor content.
*
*
* @param text
*/
protected void setEditorText(String text) {
Expand All @@ -1209,15 +1210,15 @@ protected void setEditorText(String text) {

/**
* getEditorText() - gets the editor content.
*
*
*/
String getEditorText() {
return scriptEditor.getScript();
}

/**
* saveEditorContentsDE - saves the current editor contents to ROM using DE API
*
*
* @param desHdl
* @return true if updated else false.
*/
Expand Down Expand Up @@ -1266,7 +1267,7 @@ private void saveModel() {

/**
* Returns current undo level.
*
*
* @return current undo level.
*/
private int getUndoLevel() {
Expand Down Expand Up @@ -1333,7 +1334,7 @@ private void disableEditor() {

/**
* Gets source viewer in the editor
*
*
* @return source viewer
*/
public SourceViewer getViewer() {
Expand All @@ -1346,7 +1347,7 @@ public boolean isInterested(IMediatorRequest request) {

/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.birt.report.designer.core.util.mediator.IColleague#performRequest
* ( org.eclipse.birt.report.designer.core.util.mediator.request.ReportRequest )
Expand Down Expand Up @@ -1395,7 +1396,7 @@ private void setComboViewerInput(String message) {

/**
* Reset the selection forcely.
*
*
* @param list
*/
public void handleSelectionChange(List list) {
Expand All @@ -1409,7 +1410,7 @@ public void handleSelectionChange(List list) {

/**
* Returns the current script editor.
*
*
* @return the current script editor.
*/
protected IScriptEditor getScriptEditor() {
Expand Down Expand Up @@ -1442,8 +1443,8 @@ public void doValidate() {

/**
* Sets the validate icon with the specified image and tool tip text.
*
*
*
*
* @param image the icon image
* @param tip the tool tip text
*/
Expand All @@ -1456,7 +1457,7 @@ private void setValidateIcon(Image image, String tip) {

/*
* (non-Javadoc)
*
*
* @see org.eclipse.ui.part.EditorPart#doSaveAs()
*/
public void doSaveAs() {
Expand All @@ -1465,7 +1466,7 @@ public void doSaveAs() {

/*
* (non-Javadoc)
*
*
* @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite,
* org.eclipse.ui.IEditorInput)
*/
Expand All @@ -1477,15 +1478,15 @@ public void init(IEditorSite site, IEditorInput input) throws PartInitException

/*
* (non-Javadoc)
*
*
* @see org.eclipse.ui.part.WorkbenchPart#setFocus()
*/
public void setFocus() {
scriptEditor.setFocus();
}

/**
*
*
*/
public void resetText() {
if (editObject instanceof DesignElementHandle && cmbItemLastSelected != null) {
Expand All @@ -1498,7 +1499,7 @@ public void resetText() {

/**
* Updates the description label with the specified method name.
*
*
* @param methodName the method to update.
*/
private void updateMethodDescription(String methodName) {
Expand All @@ -1517,34 +1518,29 @@ private void updateMethodDescription(String methodName) {

/**
* Sets the description with the specified text.
*
*
* @param text the text to set.
*/
private void setDescriptionText(String text) {
Font font = descriptionText.getFont();
FontData[] fontData = font.getFontData();
Font fontToUse;
String description;

if (text != null && text.length() > 0) {
for (int i = 0; i < fontData.length; i++) {
fontData[i].setStyle(fontData[i].getStyle() & ~SWT.ITALIC);
}
fontToUse = JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT);
description = text;
} else {
for (int i = 0; i < fontData.length; i++) {
fontData[i].setStyle(fontData[i].getStyle() | SWT.ITALIC);
}
fontToUse = JFaceResources.getFontRegistry().getItalic(JFaceResources.DEFAULT_FONT);
description = Messages.getString("JSEditor.Text.NoDescription"); //$NON-NLS-1$ ;
}
descriptionText.setFont(new Font(font.getDevice(), fontData));
descriptionText.setFont(fontToUse);
descriptionText.setText(description);
}
}

/**
* class JSExpListProvider - Is the content and label provider for the
* expression list
*
*
*/

class JSExpListProvider implements IStructuredContentProvider, ILabelProvider {
Expand Down Expand Up @@ -1603,7 +1599,7 @@ public String getText(Object element) {

/*
* (non-Javadoc)
*
*
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
*/
public Image getImage(Object element) {
Expand All @@ -1612,7 +1608,7 @@ public Image getImage(Object element) {

/*
* (non-Javadoc)
*
*
* @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.
* jface.viewers.ILabelProviderListener)
*/
Expand All @@ -1622,7 +1618,7 @@ public void addListener(ILabelProviderListener listener) {

/*
* (non-Javadoc)
*
*
* @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang
* .Object, java.lang.String)
*/
Expand All @@ -1632,7 +1628,7 @@ public boolean isLabelProperty(Object element, String property) {

/*
* (non-Javadoc)
*
*
* @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse
* .jface.viewers.ILabelProviderListener)
*/
Expand Down

0 comments on commit 2a94776

Please sign in to comment.