Author: scabanovich
Date: 2012-05-24 14:11:59 -0400 (Thu, 24 May 2012)
New Revision: 41365
Added:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectEditorErrorTickUpdater.java
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectMultiPageEditor.java
Log:
JBIDE-11915
https://issues.jboss.org/browse/JBIDE-11915
Editor tab of JBoss Tools editor is decorated with warning/error image if edited file has
warning/error markers.
Added:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectEditorErrorTickUpdater.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectEditorErrorTickUpdater.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectEditorErrorTickUpdater.java 2012-05-24
18:11:59 UTC (rev 41365)
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.editor;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jdt.internal.ui.JavaPlugin;
+import org.eclipse.jdt.internal.ui.viewsupport.IProblemChangedListener;
+import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider;
+import org.eclipse.jdt.internal.ui.viewsupport.JavaUILabelProvider;
+import org.eclipse.jdt.ui.ProblemsLabelDecorator;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+
+public class ObjectEditorErrorTickUpdater implements IProblemChangedListener {
+
+ private ObjectMultiPageEditor fJavaEditor;
+ private JavaUILabelProvider fLabelProvider;
+
+ public ObjectEditorErrorTickUpdater(ObjectMultiPageEditor editor) {
+ Assert.isNotNull(editor);
+ fJavaEditor= editor;
+ fLabelProvider= new JavaUILabelProvider(0, JavaElementImageProvider.SMALL_ICONS);
+ fLabelProvider.addLabelDecorator(new ProblemsLabelDecorator(null));
+ JavaPlugin.getDefault().getProblemMarkerManager().addListener(this);
+ }
+
+ /*
+ * @see IProblemChangedListener#problemsChanged(IResource[], boolean)
+ */
+ public void problemsChanged(IResource[] changedResources, boolean isMarkerChange) {
+ if (!isMarkerChange)
+ return;
+
+ IEditorInput input= fJavaEditor.getEditorInput();
+ if (input instanceof IFileEditorInput) {
+ IFile resource = ((IFileEditorInput)input).getFile();
+ if (resource != null) {
+ for (int i = 0; i < changedResources.length; i++) {
+ if (changedResources[i].equals(resource)) {
+ updateEditorImage(resource);
+ }
+ }
+ }
+ }
+ }
+
+ public void updateEditorImage(IFile jelement) {
+ Image titleImage= fJavaEditor.getTitleImage();
+ if (titleImage == null) {
+ return;
+ }
+ Image newImage = fLabelProvider.getImage(jelement);
+ if (titleImage != newImage) {
+ postImageChange(newImage);
+ }
+ }
+
+ private void postImageChange(final Image newImage) {
+ Shell shell= fJavaEditor.getEditorSite().getShell();
+ if (shell != null && !shell.isDisposed()) {
+ shell.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ fJavaEditor.updatedTitleImage(newImage);
+ }
+ });
+ }
+ }
+
+ public void dispose() {
+ fLabelProvider.dispose();
+ JavaPlugin.getDefault().getProblemMarkerManager().removeListener(this);
+ }
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectEditorErrorTickUpdater.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectMultiPageEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectMultiPageEditor.java 2012-05-24
18:07:27 UTC (rev 41364)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectMultiPageEditor.java 2012-05-24
18:11:59 UTC (rev 41365)
@@ -28,6 +28,7 @@
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.*;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
@@ -79,9 +80,14 @@
private ActivationListener fActivationListener= new ActivationListener();
protected XModelObjectSelectionProvider selectionProvider = new
XModelObjectSelectionProvider();
protected NatureChecker natureChecker = new NatureChecker();
+ protected ObjectEditorErrorTickUpdater errorTickUpdater;
private QualifiedName persistentTabQualifiedName = new QualifiedName("",
"Selected_tab"); //$NON-NLS-1$ //$NON-NLS-2$
int selectedPageIndex = 0;
+
+ public ObjectMultiPageEditor() {
+ errorTickUpdater = new ObjectEditorErrorTickUpdater(this);
+ }
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
natureChecker.check(input, getSupportedNatures(), getNatureWarningMessageKey());
@@ -103,6 +109,10 @@
} else {
firePropertyChange(IEditorPart.PROP_INPUT);
}
+ if (errorTickUpdater != null && getFile() != null) {
+ errorTickUpdater.updateEditorImage(getFile());
+ }
+
}
protected IEditorSite createSite(IEditorPart editor) {
@@ -504,6 +514,10 @@
}
if (outline!=null) outline.dispose();
outline = null;
+ if(errorTickUpdater != null) {
+ errorTickUpdater.dispose();
+ errorTickUpdater = null;
+ }
}
protected void initEditors() {
@@ -1062,6 +1076,10 @@
});
}
+ public void updatedTitleImage(Image image) {
+ setTitleImage(image);
+ }
+
class PostMultiPageEditorSite extends MultiPageEditorSite {
private ISelectionChangedListener postSelectionChangedListener = null;