Commit 18a94ee4 authored by Miklos Magyari's avatar Miklos Magyari
Browse files

Added marker resolution support to Ttcn3HoverInfoControl


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent 70bcd1b3
......@@ -63,8 +63,8 @@ import org.eclipse.titan.designer.editors.ProposalCollector;
import org.eclipse.titan.designer.editors.Stylers;
import org.eclipse.titan.designer.editors.T3Doc;
import org.eclipse.titan.designer.editors.actions.DeclarationCollector;
import org.eclipse.titan.designer.editors.controls.HoverProposal;
import org.eclipse.titan.designer.editors.controls.HoverContentType;
import org.eclipse.titan.designer.editors.controls.HoverProposal;
import org.eclipse.titan.designer.editors.controls.Ttcn3HoverContent;
import org.eclipse.titan.designer.editors.ttcn3editor.TTCN3CodeSkeletons;
import org.eclipse.titan.designer.parsers.CompilationTimeStamp;
......
......@@ -110,7 +110,7 @@ public final class AnnotationHover implements IAnnotationHover, IAnnotationHover
}
}
}
return new MarkerHoverContent(builder.toString());
return new MarkerHoverContent(builder.toString(), null);
}
@Override
......
......@@ -9,9 +9,10 @@ package org.eclipse.titan.designer.editors.controls;
import org.eclipse.core.resources.IMarker;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IMarkerResolution;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.views.markers.WorkbenchMarkerResolution;
public class HoverProposal implements IMarkerResolution {
public class HoverProposal extends WorkbenchMarkerResolution {
public static final String PROPOSAL = "proposal";
private String label;
......@@ -30,4 +31,22 @@ public class HoverProposal implements IMarkerResolution {
MessageDialog.openInformation(null, "QuickFix Demo",
"This quick-fix is not yet implemented");
}
@Override
public String getDescription() {
// TODO Auto-generated method stub
return null;
}
@Override
public Image getImage() {
// TODO Auto-generated method stub
return null;
}
@Override
public IMarker[] findOtherMarkers(IMarker[] markers) {
// TODO Auto-generated method stub
return null;
}
}
......@@ -16,9 +16,11 @@ package org.eclipse.titan.designer.editors.controls;
*/
public class MarkerHoverContent {
private String text;
private HoverProposal[] proposals;
public MarkerHoverContent(String text) {
public MarkerHoverContent(String text, HoverProposal[] proposals) {
this.text = text;
this.proposals = proposals;
}
public String getText() {
......@@ -27,5 +29,21 @@ public class MarkerHoverContent {
public void setText(String text) {
this.text = text;
}
}
public HoverProposal[] getProposals() {
return proposals;
}
public HoverProposal getProposal(int index) {
return proposals[index];
}
public void setProposals(HoverProposal[] proposals) {
this.proposals = proposals;
}
public int nrOfProposals() {
return proposals.length;
}
}
......@@ -154,9 +154,7 @@ public class Ttcn3HoverInfoControl extends AbstractInformationControl implements
tb.setForeground(fShell.getDisplay().getSystemColor(SWT.COLOR_LINK_FOREGROUND));
switchAction.setText(getButtonText());
if (toolbar.getItems().length == 0) {
toolbar.add(switchAction);
}
toolbar.add(switchAction);
tb.setSize(SWT.DEFAULT, 30);
toolbar.update(true);
toolbarTextSize = tb.getSize().x;
......@@ -170,7 +168,23 @@ public class Ttcn3HoverInfoControl extends AbstractInformationControl implements
}
if (isRich) {
if (toolbar != null) {
// add proposals here
if (markerContent.nrOfProposals() > 0) {
final ToolBar tb = toolbar.createControl(fParent);
for (int i = 0; i < markerContent.nrOfProposals(); i++) {
final HoverProposal prop = markerContent.getProposal(i);
IAction propAction = new Action("", IAction.AS_PUSH_BUTTON) {
@Override
public void run() {
prop.run(null);
}
};
propAction.setText(prop.getLabel());
toolbar.add(propAction);
tb.setSize(SWT.DEFAULT, 30);
toolbar.update(true);
toolbarTextSize = tb.getSize().x;
}
}
}
}
}
......
......@@ -7,9 +7,12 @@
******************************************************************************/
package org.eclipse.titan.designer.editors.ttcn3editor;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator;
......@@ -31,6 +34,7 @@ import org.eclipse.titan.designer.AST.TTCN3.definitions.IHoverContent;
import org.eclipse.titan.designer.editors.BaseTextHover;
import org.eclipse.titan.designer.editors.IReferenceParser;
import org.eclipse.titan.designer.editors.controls.HoverContentType;
import org.eclipse.titan.designer.editors.controls.HoverProposal;
import org.eclipse.titan.designer.editors.controls.MarkerHoverContent;
import org.eclipse.titan.designer.editors.controls.PeekSource;
import org.eclipse.titan.designer.editors.controls.Ttcn3HoverContent;
......@@ -105,6 +109,7 @@ public final class TextHover extends BaseTextHover implements ITextHoverExtensio
if (annotationModel != null) {
final Iterator<?> iterator = annotationModel.getAnnotationIterator();
StringBuilder markerInfo = new StringBuilder();
List<HoverProposal> proposals = new ArrayList<HoverProposal>();
while (iterator.hasNext()) {
final Object o = iterator.next();
if (o instanceof MarkerAnnotation) {
......@@ -120,10 +125,24 @@ public final class TextHover extends BaseTextHover implements ITextHoverExtensio
// FIXME error handling
}
markerInfo.append(message);
Object attr = null;
try {
attr = actualMarker.getMarker().getAttribute(HoverProposal.PROPOSAL);
} catch (CoreException e) {
// TODO Auto-generated catch block
}
if (attr instanceof HoverProposal[]) {
HoverProposal[] propsInMarker = (HoverProposal[])attr;
for (int i = 0; i < propsInMarker.length; i++) {
proposals.add(propsInMarker[i]);
}
}
}
}
if (markerInfo.length() > 0) {
return new MarkerHoverContent(markerInfo.toString());
HoverProposal[] propArr = {};
propArr = proposals.toArray(propArr);
return new MarkerHoverContent(markerInfo.toString(), propArr);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment