use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.
the class TableLayout method computeLayoutTable.
private TablePassInfo computeLayoutTable(List<TabInfo> visibleInfos) {
final TablePassInfo data = new TablePassInfo(myTabs, visibleInfos);
final Insets insets = myTabs.getLayoutInsets();
data.toFitRec = new Rectangle(insets.left, insets.top, myTabs.getWidth() - insets.left - insets.right, myTabs.getHeight() - insets.top - insets.bottom);
int eachRow = 0, eachX = data.toFitRec.x;
TableRow eachTableRow = new TableRow(data);
data.table.add(eachTableRow);
data.requiredRows = 1;
for (TabInfo eachInfo : data.myVisibleInfos) {
final TabLabel eachLabel = myTabs.myInfo2Label.get(eachInfo);
final Dimension size = eachLabel.getPreferredSize();
if (eachX + size.width >= data.toFitRec.getMaxX()) {
data.requiredRows++;
eachX = data.toFitRec.x;
}
myTabs.layout(eachLabel, eachX, 0, size.width, 1);
eachX += size.width + myTabs.getInterTabSpaceLength();
data.requiredWidth += size.width + myTabs.getInterTabSpaceLength();
}
int selectedRow = -1;
eachX = data.toFitRec.x;
data.rowToFitMaxX = (int) data.toFitRec.getMaxX();
if (data.requiredRows > 1) {
final int rowFit = insets.left + data.requiredWidth / data.requiredRows;
for (TabInfo eachInfo : data.myVisibleInfos) {
final TabLabel eachLabel = myTabs.myInfo2Label.get(eachInfo);
final Rectangle eachBounds = eachLabel.getBounds();
if (eachBounds.contains(rowFit, 0)) {
data.rowToFitMaxX = (int) eachLabel.getBounds().getMaxX();
break;
}
}
}
for (TabInfo eachInfo : data.myVisibleInfos) {
final TabLabel eachLabel = myTabs.myInfo2Label.get(eachInfo);
final Dimension size = eachLabel.getPreferredSize();
if (eachX + size.width <= data.rowToFitMaxX) {
eachTableRow.add(eachInfo);
if (myTabs.getSelectedInfo() == eachInfo) {
selectedRow = eachRow;
}
eachX += size.width + myTabs.getInterTabSpaceLength();
} else {
eachTableRow = new TableRow(data);
data.table.add(eachTableRow);
eachRow++;
eachX = insets.left + size.width;
eachTableRow.add(eachInfo);
if (myTabs.getSelectedInfo() == eachInfo) {
selectedRow = eachRow;
}
}
}
List<TableRow> toMove = new ArrayList<>();
for (int i = selectedRow + 1; i < data.table.size(); i++) {
toMove.add(data.table.get(i));
}
return data;
}
use of com.intellij.ui.tabs.TabInfo in project buck by facebook.
the class BuckToolWindowFactory method createToolWindowContent.
@Override
public void createToolWindowContent(final Project project, ToolWindow toolWindow) {
toolWindow.setAvailable(true, null);
toolWindow.setToHideOnEmptyContent(true);
toolWindow.setIcon(BuckIcons.BUCK_TOOL_WINDOW_ICON);
RunnerLayoutUi runnerLayoutUi = BuckUIManager.getInstance(project).getLayoutUi(project);
BuckSettingsProvider.State state = BuckSettingsProvider.getInstance().getState();
JBTabs myTabs = new JBTabsImpl(project);
// Debug Console
if (state.showDebug) {
Content consoleContent = createConsoleContent(runnerLayoutUi, project);
myTabs.addTab(new TabInfo(consoleContent.getComponent())).setText("Debug");
}
// Build Tree Events
Content treeViewContent = runnerLayoutUi.createContent(BUILD_OUTPUT_PANEL, createBuildInfoPanel(project), "Build Output", null, null);
myTabs.addTab(new TabInfo(treeViewContent.getComponent()).setText("Build"));
Content tabsContent = runnerLayoutUi.createContent(TABS_CONTENT_ID, myTabs.getComponent(), "Buck Tool Tabs", null, null);
runnerLayoutUi.addContent(tabsContent, 0, PlaceInGrid.center, false);
runnerLayoutUi.getOptions().setLeftToolbar(getLeftToolbarActions(project), ActionPlaces.UNKNOWN);
runnerLayoutUi.updateActionsNow();
final ContentManager contentManager = toolWindow.getContentManager();
Content content = contentManager.getFactory().createContent(runnerLayoutUi.getComponent(), "", true);
contentManager.addContent(content);
updateBuckToolWindowTitle(project);
}
use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.
the class GridCellImpl method remove.
void remove(Content content) {
if (!myContents.containsKey(content))
return;
final TabInfo info = getTabFor(content);
myContents.remove(content);
revalidateCell(() -> myTabs.removeTab(info));
updateSelection(myTabs.getComponent().getRootPane() != null);
}
use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.
the class GridCellImpl method updateSelection.
public void updateSelection(final boolean isShowing) {
ContentManager contentManager = myContext.getContentManager();
if (contentManager.isDisposed())
return;
for (Content each : myContents.getKeys()) {
final TabInfo eachTab = getTabFor(each);
boolean isSelected = eachTab != null && myTabs.getSelectedInfo() == eachTab;
if (isSelected && isShowing) {
contentManager.addSelectedContent(each);
} else {
contentManager.removeFromSelection(each);
}
}
for (Content each : myMinimizedContents) {
contentManager.removeFromSelection(each);
}
}
use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.
the class RunnerContentUi method doSaveUiState.
private void doSaveUiState() {
if (isStateBeingRestored())
return;
for (TabInfo each : myTabs.getTabs()) {
GridImpl eachGrid = getGridFor(each);
eachGrid.saveUiState();
}
for (RunnerContentUi child : myChildren) {
child.doSaveUiState();
}
}
Aggregations