Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle ClassCastException #374

Closed
wants to merge 1 commit into from

Conversation

spirentitestdevter
Copy link

java.lang.ClassCastException: org.eclipse.jface.action.SubContributionItem cannot be cast to org.eclipse.ui.texteditor.StatusLineContributionItemjava.lang.ClassCastException: org.eclipse.jface.action.SubContributionItem cannot be cast to org.eclipse.ui.texteditor.StatusLineContributionItem at org.robotframework.ide.eclipse.main.plugin.tableeditor.source.SuiteSourceEditor.updateLineLocationStatusBar(SuiteSourceEditor.java:207) at org.robotframework.ide.eclipse.main.plugin.tableeditor.source.SuiteSourceEditor.lambda$2(SuiteSourceEditor.java:195) at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:97) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:86) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4428) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1103) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1088) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:802) at org.eclipse.swt.custom.StyledText.setCaretOffset(StyledText.java:8688) at org.eclipse.swt.custom.StyledText.doMouseLocationChange(StyledText.java:2881) at org.eclipse.swt.custom.StyledText.handleMouseDown(StyledText.java:6107) at org.eclipse.swt.custom.StyledText.lambda$1(StyledText.java:5735) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:86) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4428) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4238) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3817) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1150) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1039) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153) at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:680) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:594) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148) at com.fnfr.svt.rcp.Application.runWorkbench(Application.java:231) at com.fnfr.svt.rcp.Application.start(Application.java:190) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590) at org.eclipse.equinox.launcher.Main.run(Main.java:1499)

java.lang.ClassCastException: org.eclipse.jface.action.SubContributionItem cannot be cast to org.eclipse.ui.texteditor.StatusLineContributionItemjava.lang.ClassCastException: org.eclipse.jface.action.SubContributionItem cannot be cast to org.eclipse.ui.texteditor.StatusLineContributionItem at org.robotframework.ide.eclipse.main.plugin.tableeditor.source.SuiteSourceEditor.updateLineLocationStatusBar(SuiteSourceEditor.java:207) at org.robotframework.ide.eclipse.main.plugin.tableeditor.source.SuiteSourceEditor.lambda$2(SuiteSourceEditor.java:195) at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:97) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:86) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4428) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1103) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1088) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:802) at org.eclipse.swt.custom.StyledText.setCaretOffset(StyledText.java:8688) at org.eclipse.swt.custom.StyledText.doMouseLocationChange(StyledText.java:2881) at org.eclipse.swt.custom.StyledText.handleMouseDown(StyledText.java:6107) at org.eclipse.swt.custom.StyledText.lambda$1(StyledText.java:5735) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:86) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4428) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4238) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3817) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1150) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1039) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153) at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:680) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:594) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148) at com.fnfr.svt.rcp.Application.runWorkbench(Application.java:231) at com.fnfr.svt.rcp.Application.start(Application.java:190) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590) at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
@spirentitestdevter
Copy link
Author

Please accept my pull request :( I always get error and can't do anything.

.find(ITextEditorActionConstants.STATUS_CATEGORY_INPUT_POSITION);
if (find instanceof StatusLineContributionItem) {
final String delimiter = DocumentUtilities.getDelimiter(document);
find.setText("\r\n".equals(delimiter) ? "CR+LF" : "LF");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this compile?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely it will not compile, similarly as line 218

Copy link
Author

@spirentitestdevter spirentitestdevter Jun 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michalanglart
Sorry, Can you update as below for me ? Thanks.
private void updateLineLocationStatusBar(final int caretPosition) {
try {
final IDocument document = getDocument();
int lineNumber = document.getLineOfOffset(caretPosition);
final int columnNumber = caretPosition - document.getLineOffset(lineNumber) + 1;
lineNumber++;

        final IContributionItem find = getEditorSite().getActionBars()
                .getStatusLineManager()
                .find(ITextEditorActionConstants.STATUS_CATEGORY_INPUT_POSITION);
        if (find instanceof StatusLineContributionItem) {
			((StatusLineContributionItem )find).setText(lineNumber + ":" + columnNumber);
		}
    } catch (final BadLocationException e) {
        RedPlugin.logError("Unable to get position in source editor in order to update status bar", e);
    }
}

private void updateLineDelimitersStatus() {
    final IDocument document = getDocument();

    final IContributionItem find = getEditorSite().getActionBars()
            .getStatusLineManager()
            .find(RobotFormEditorActionBarContributor.DELIMITERS_INFO_ID);
	if (find instanceof StatusLineContributionItem) {
		final String delimiter = DocumentUtilities.getDelimiter(document);
		((StatusLineContributionItem )find).setText("\r\n".equals(delimiter) ? "CR+LF" : "LF");
	}
}

@michalanglart
Copy link
Collaborator

Hi,

first of all you're proposing pull request without specifying the issue but as far as I understand this PR should fix this issue: #309 which was reported over a year ago by you but we closed it some months later due to lack of help from your side when we were trying to understand the root cause of it.

I reopened the issue to which this PR relates.

Do not worry we can accept it but keep in mind that simply accepting the PR does not change anything for you. It would just change the code in the codebase but you would still need to wait for release or build the binaries for yourself (and the latter you can do it right now without even having your PR accepted).

@spirentitestdevter
Copy link
Author

hich was reported over a year a

Hi @michalanglart Sorry for my late response. We imported RED source codes to my project and added workaround for RED v0.8.11. Now We upgrade the Eclipse and upgrade RED and get error again, we could have to add source codes again. We hope that you can fix it in next release to avoid our effort. I'm very appreciate your help.
Thanks.

@michalanglart
Copy link
Collaborator

Your change with needed update for compilation issues was imported into our internal repository. This change will be effective in next version

@spirentitestdevter spirentitestdevter deleted the patch-1 branch July 6, 2020 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants