use of com.intellij.ui.tabs.impl.TabLabel in project android by JetBrains.
the class GradleTestArtifactSyncTest method testTestFileBackground.
@Test
public void testTestFileBackground() throws Exception {
guiTest.importSimpleApplication();
EditorFixture editor = guiTest.ideFrame().getEditor();
editor.open("app/src/test/java/google/simpleapplication/UnitTest.java");
TabLabel tabLabel = findTab(editor);
Color green = new JBColor(new Color(231, 250, 219), new Color(0x425444));
assertEquals(green, tabLabel.getInfo().getTabColor());
// TODO re-enable following code when we fix background color support
//editor.close();
//editor.open("app/src/androidTest/java/google/simpleapplication/ApplicationTest.java");
//tabLabel = findTab(editor);
//Color blue = new JBColor(new Color(0xdcf0ff), new Color(0x3C476B));
//assertEquals(blue, tabLabel.getInfo().getTabColor());
}
use of com.intellij.ui.tabs.impl.TabLabel in project android by JetBrains.
the class AndroidToolWindowFixture method selectTab.
private void selectTab(@NotNull final String tabName) {
JBRunnerTabs tabs = myRobot.finder().findByType(getContentPanel(), JBRunnerTabs.class);
TabLabel tabLabel = myRobot.finder().find(tabs, new GenericTypeMatcher<TabLabel>(TabLabel.class) {
@Override
protected boolean isMatching(@NotNull TabLabel component) {
return tabName.equals(component.toString()) && component.getParent() == tabs;
}
});
myRobot.click(tabLabel);
}
use of com.intellij.ui.tabs.impl.TabLabel in project intellij-community by JetBrains.
the class CompressibleSingleRowLayout method layoutLabelsAndGhosts.
@Override
protected void layoutLabelsAndGhosts(SingleRowPassInfo data) {
if (myTabs.getPresentation().getTabsPosition() != JBTabsPosition.top && myTabs.getPresentation().getTabsPosition() != JBTabsPosition.bottom) {
super.layoutLabelsAndGhosts(data);
return;
}
int maxGridSize = 0;
int spentLength = 0;
int lengthEstimation = 0;
int[] lengths = new int[data.toLayout.size()];
List<TabInfo> layout = data.toLayout;
for (int i = 0; i < layout.size(); i++) {
final TabLabel label = myTabs.myInfo2Label.get(layout.get(i));
if (maxGridSize == 0) {
Font font = label.getLabelComponent().getFont();
maxGridSize = GraphicsUtil.stringWidth("m", font == null ? JBUI.Fonts.label() : font) * myTabs.tabMSize();
}
int lengthIncrement = label.getPreferredSize().width;
lengths[i] = lengthIncrement;
lengthEstimation += lengthIncrement;
}
final int extraWidth = data.toFitLength - lengthEstimation;
Arrays.sort(lengths);
double acc = 0;
int actualGridSize = 0;
for (int i = 0; i < lengths.length; i++) {
int length = lengths[i];
acc += length;
actualGridSize = (int) Math.min(maxGridSize, (acc + extraWidth) / (i + 1));
if (i < lengths.length - 1 && actualGridSize < lengths[i + 1])
break;
}
for (Iterator<TabInfo> iterator = data.toLayout.iterator(); iterator.hasNext(); ) {
final TabLabel label = myTabs.myInfo2Label.get(iterator.next());
label.setActionPanelVisible(true);
int length;
int lengthIncrement = label.getPreferredSize().width;
if (!iterator.hasNext()) {
length = Math.min(data.toFitLength - spentLength, Math.max(actualGridSize, lengthIncrement));
} else if (extraWidth <= 0) {
//need compress
length = (int) (lengthIncrement * (float) data.toFitLength / lengthEstimation);
} else {
length = Math.max(lengthIncrement, actualGridSize);
}
spentLength += length + myTabs.getInterTabSpaceLength();
applyTabLayout(data, label, length, 0);
data.position = (int) label.getBounds().getMaxX() + myTabs.getInterTabSpaceLength();
}
for (TabInfo eachInfo : data.toDrop) {
JBTabsImpl.resetLayout(myTabs.myInfo2Label.get(eachInfo));
}
}
use of com.intellij.ui.tabs.impl.TabLabel in project intellij-community by JetBrains.
the class ScrollableSingleRowLayout method isTabHidden.
@Override
public boolean isTabHidden(TabInfo tabInfo) {
final TabLabel label = myTabs.myInfo2Label.get(tabInfo);
final Rectangle bounds = label.getBounds();
return getStrategy().getMinPosition(bounds) < -10 || bounds.isEmpty();
}
use of com.intellij.ui.tabs.impl.TabLabel in project intellij-community by JetBrains.
the class TableLayout method layoutTable.
public LayoutPassInfo layoutTable(List<TabInfo> visibleInfos) {
myTabs.resetLayout(true);
final TablePassInfo data = computeLayoutTable(visibleInfos);
final Insets insets = myTabs.getLayoutInsets();
int eachY = insets.top;
int eachX;
int row = 0;
final int tabUnderlineFix = myTabs.isEditorTabs() ? myTabs.getActiveTabUnderlineHeight() : 0;
for (TableRow eachRow : data.table) {
eachX = insets.left;
int deltaToFit = 0;
boolean toAjust = false;
if (eachRow.width < data.toFitRec.width && data.table.size() > 1) {
deltaToFit = (int) Math.floor((double) (data.toFitRec.width - eachRow.width) / (double) eachRow.myColumns.size());
toAjust = true;
}
for (int i = 0; i < eachRow.myColumns.size(); i++) {
TabInfo tabInfo = eachRow.myColumns.get(i);
final TabLabel label = myTabs.myInfo2Label.get(tabInfo);
label.putClientProperty(JBTabsImpl.STRETCHED_BY_WIDTH, Boolean.valueOf(toAjust));
int width;
if (i < eachRow.myColumns.size() - 1 || !toAjust) {
width = label.getPreferredSize().width + deltaToFit;
} else {
width = data.toFitRec.width + insets.left - eachX;
}
myTabs.layout(label, eachX, eachY, width, row < data.table.size() - 1 ? myTabs.myHeaderFitSize.height - tabUnderlineFix : myTabs.myHeaderFitSize.height);
label.setAlignmentToCenter(deltaToFit > 0);
boolean lastCell = i == eachRow.myColumns.size() - 1;
eachX += width + (lastCell ? 0 : myTabs.getInterTabSpaceLength());
}
eachY += myTabs.myHeaderFitSize.height - 1 + myTabs.getInterTabSpaceLength() - (row < data.table.size() - 1 ? tabUnderlineFix : 0);
row++;
}
if (myTabs.getSelectedInfo() != null) {
final JBTabsImpl.Toolbar selectedToolbar = myTabs.myInfo2Toolbar.get(myTabs.getSelectedInfo());
int xAddin = 0;
if (!myTabs.myHorizontalSide && selectedToolbar != null && !selectedToolbar.isEmpty()) {
xAddin = selectedToolbar.getPreferredSize().width + 1;
myTabs.layout(selectedToolbar, insets.left + 1, eachY + 1, selectedToolbar.getPreferredSize().width, myTabs.getHeight() - eachY - insets.bottom - 2);
}
myTabs.layoutComp(xAddin, eachY + (myTabs.isEditorTabs() ? 0 : 2) - myTabs.getLayoutInsets().top, myTabs.getSelectedInfo().getComponent(), 0, 0);
}
myLastTableLayout = data;
return data;
}
Aggregations