Commit c4d86192 authored by Adam Knapp's avatar Adam Knapp
Browse files

Refactoring hover control (issue #452)


Signed-off-by: Adam Knapp's avatarAdam Knapp <adam.knapp@ericsson.com>
parent 0504db7e
......@@ -974,6 +974,15 @@
</type>
</extension>
<extension point="org.eclipse.ui.ide.markerResolution"><!-- TODO: not working yet -->
<markerResolutionGenerator
markerType="org.eclipse.titan.designer.compilerErrorMarker"
class="org.eclipse.titan.designer.editors.actions.QuickFixGenerator" />
<markerResolutionGenerator
markerType="org.eclipse.titan.designer.compilerWarningMarker"
class="org.eclipse.titan.designer.editors.actions.QuickFixGenerator" />
<markerResolutionGenerator
markerType="org.eclipse.titan.designer.compilerInfoMarker"
class="org.eclipse.titan.designer.editors.actions.QuickFixGenerator" />
<markerResolutionGenerator
markerType="org.eclipse.titan.designer.ontheflySyntacticMarker"
class="org.eclipse.titan.designer.editors.actions.QuickFixGenerator" />
......
......@@ -18,16 +18,16 @@ public class MarkerHoverContent {
private String text;
private HoverProposal[] proposals;
public MarkerHoverContent(String text, HoverProposal[] proposals) {
public MarkerHoverContent(final String text, final HoverProposal[] proposals) {
this.text = text;
this.proposals = proposals;
}
public String getText() {
return text;
return text == null ? "" : text;
}
public void setText(String text) {
public void setText(final String text) {
this.text = text;
}
......@@ -35,11 +35,11 @@ public class MarkerHoverContent {
return proposals;
}
public HoverProposal getProposal(int index) {
return proposals[index];
public HoverProposal getProposal(final int index) {
return proposals == null ? null : proposals[index];
}
public void setProposals(HoverProposal[] proposals) {
public void setProposals(final HoverProposal[] proposals) {
this.proposals = proposals;
}
......
......@@ -147,18 +147,17 @@ public class Ttcn3HoverInfoControl extends AbstractInformationControl implements
viewer.setStyleRange(style);
}
};
if (isRich) {
if (toolbar != null) {
final ToolBar tb = toolbar.createControl(fParent);
tb.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_HAND));
tb.setForeground(fShell.getDisplay().getSystemColor(SWT.COLOR_LINK_FOREGROUND));
switchAction.setText(getButtonText());
if (isRich && toolbar != null) {
final ToolBar tb = toolbar.createControl(fParent);
tb.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_HAND));
tb.setForeground(fShell.getDisplay().getSystemColor(SWT.COLOR_LINK_FOREGROUND));
switchAction.setText(getButtonText());
if (toolbar.getItems().length == 0) {
toolbar.add(switchAction);
tb.setSize(SWT.DEFAULT, 30);
toolbar.update(true);
toolbarTextSize = tb.getSize().x;
}
toolbar.update(true);
toolbarTextSize = tb.getSize().x;
}
break;
case MarkerHover:
......@@ -166,26 +165,23 @@ public class Ttcn3HoverInfoControl extends AbstractInformationControl implements
if (markersText != null) {
viewer.setText(markersText);
}
if (isRich) {
if (toolbar != null) {
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);
dispose();
}
};
propAction.setText(prop.getLabel());
toolbar.add(propAction);
tb.setSize(SWT.DEFAULT, 30);
toolbar.update(true);
toolbarTextSize = tb.getSize().x;
if (isRich && toolbar != null) {
final int nrOfProposals = markerContent.nrOfProposals();
final ToolBar tb = toolbar.createControl(fParent);
for (int i = 0; i < nrOfProposals; i++) {
final HoverProposal prop = markerContent.getProposal(i);
IAction propAction = new Action("", IAction.AS_PUSH_BUTTON) {
@Override
public void run() {
prop.run(null);
dispose();
}
}
};
propAction.setText(prop.getLabel());
toolbar.add(propAction);
toolbar.update(true);
toolbarTextSize = tb.getSize().x;
setSize(computeSizeHint());
}
}
}
......@@ -210,7 +206,7 @@ public class Ttcn3HoverInfoControl extends AbstractInformationControl implements
final Rectangle shellRect = fShell.getBounds();
maxWidth = displayRect.width - shellRect.x;
maxHeight = displayRect.height - shellRect.y;
fShell.setSize(Math.min(Math.max(width + 15, toolbarTextSize + 15), maxWidth), Math.min(height + 12, maxHeight));
fShell.setSize(Math.min(Math.max(width + 15, toolbarTextSize + 15), maxWidth), Math.min(height + 15, maxHeight));
}
public void setSize(Point size) {
......@@ -218,6 +214,6 @@ public class Ttcn3HoverInfoControl extends AbstractInformationControl implements
}
private String getButtonText() {
return "Click to switch to " + actualType.toString() + " view";
return "Click to switch to " + (actualType == HoverContentType.INFO ? HoverContentType.SOURCE : HoverContentType.INFO) + " view";
}
}
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