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

Refactoring and sizing improvements (issue #452)


Signed-off-by: Adam Knapp's avatarAdam Knapp <adam.knapp@ericsson.com>
parent fc09781a
......@@ -17,7 +17,6 @@ import org.eclipse.jface.text.IInformationControlExtension2;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
......@@ -42,7 +41,27 @@ public class Ttcn3HoverInfoControl extends AbstractInformationControl implements
private int maxWidth = SWT.DEFAULT;
private int maxHeight = SWT.DEFAULT;
private int toolbarTextSize = 0;
private IAction switchAction = new Action("", IAction.AS_PUSH_BUTTON) {
@Override
public void run() {
switch (actualType) {
case INFO:
actualType = HoverContentType.SOURCE;
break;
case SOURCE:
actualType = HoverContentType.INFO;
break;
}
setText(getButtonText());
HoverContentType.storeAsProperty(actualType);
setHoverContentToActual();
setSize(computeSizeHint());
toolbar.update(true);
}
};
public Ttcn3HoverInfoControl(Shell parentShell, String string) {
super(parentShell, string);
create();
......@@ -81,31 +100,13 @@ public class Ttcn3HoverInfoControl extends AbstractInformationControl implements
viewer.setEditable(false);
viewer.setBackground(fShell.getBackground());
if (isRich) {
IAction switchAction = new Action("", IAction.AS_PUSH_BUTTON) {
@Override
public void run() {
switch (actualType) {
case INFO:
actualType = HoverContentType.SOURCE;
break;
case SOURCE:
actualType = HoverContentType.INFO;
break;
}
setText(getButtonText());
HoverContentType.storeAsProperty(actualType);
setHoverContentToActual();
setSize(computeSizeHint());
toolbar.update(true);
}
};
ToolBar tb = toolbar.createControl(parent);
final ToolBar tb = toolbar.createControl(parent);
tb.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_HAND));
//setBackgroundColor(display.getSystemColor(SWT.COLOR_YELLOW));
tb.setForeground(fShell.getDisplay().getSystemColor(SWT.COLOR_LINK_FOREGROUND));
switchAction.setText(getButtonText());
toolbar.add(switchAction);
toolbar.update(true);
toolbarTextSize = tb.getSize().x;
} else {
setStatusText("Hover to focus");
}
......@@ -161,7 +162,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(width + 10, maxWidth), Math.min(height + 10, maxHeight));
fShell.setSize(Math.min(Math.max(width + 15, toolbarTextSize + 15), maxWidth), Math.min(height + 12, maxHeight));
}
public void setSize(Point size) {
......@@ -169,6 +170,6 @@ public class Ttcn3HoverInfoControl extends AbstractInformationControl implements
}
private String getButtonText() {
return "Click to switch to " + (actualType == HoverContentType.INFO ? "source" : "info") + " view";
return "Click to switch to " + actualType.toString() + " 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