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();
}
}
use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.
the class RunnerContentUi method initUi.
public void initUi() {
if (myTabs != null)
return;
myTabs = (JBRunnerTabs) new JBRunnerTabs(myProject, myActionManager, myFocusManager, this).setDataProvider(new DataProvider() {
@Override
public Object getData(@NonNls final String dataId) {
if (ViewContext.CONTENT_KEY.is(dataId)) {
TabInfo info = myTabs.getTargetInfo();
if (info != null) {
return getGridFor(info).getData(dataId);
}
} else if (ViewContext.CONTEXT_KEY.is(dataId)) {
return RunnerContentUi.this;
}
return null;
}
}).setTabLabelActionsAutoHide(false).setInnerInsets(JBUI.emptyInsets()).setToDrawBorderIfTabsHidden(false).setTabDraggingEnabled(isMoveToGridActionEnabled()).setUiDecorator(null).getJBTabs();
rebuildTabPopup();
myTabs.getPresentation().setPaintBorder(0, 0, 0, 0).setPaintFocus(false).setRequestFocusOnLastFocusedComponent(true);
myTabs.getComponent().setBackground(myToolbar.getBackground());
myTabs.getComponent().setBorder(new EmptyBorder(0, 1, 0, 0));
final NonOpaquePanel wrappper = new MyComponent(new BorderLayout(0, 0));
wrappper.add(myToolbar, BorderLayout.WEST);
wrappper.add(myTabs.getComponent(), BorderLayout.CENTER);
wrappper.setBorder(new EmptyBorder(-1, 0, 0, 0));
myComponent = wrappper;
myTabs.addListener(new TabsListener.Adapter() {
@Override
public void beforeSelectionChanged(TabInfo oldSelection, TabInfo newSelection) {
if (oldSelection != null && !isStateBeingRestored()) {
final GridImpl grid = getGridFor(oldSelection);
if (grid != null && getTabFor(grid) != null) {
grid.saveUiState();
}
}
}
@Override
public void tabsMoved() {
saveUiState();
}
@Override
public void selectionChanged(final TabInfo oldSelection, final TabInfo newSelection) {
if (!myTabs.getComponent().isShowing())
return;
if (newSelection != null) {
newSelection.stopAlerting();
getGridFor(newSelection).processAddToUi(false);
}
if (oldSelection != null) {
getGridFor(oldSelection).processRemoveFromUi();
}
}
});
myTabs.addTabMouseListener(new MouseAdapter() {
@Override
public void mousePressed(@NotNull MouseEvent e) {
if (UIUtil.isCloseClick(e)) {
final TabInfo tabInfo = myTabs.findInfo(e);
final GridImpl grid = tabInfo == null ? null : getGridFor(tabInfo);
final Content[] contents = grid != null ? CONTENT_KEY.getData(grid) : null;
if (contents == null)
return;
// see GridCellImpl.closeOrMinimize as well
if (CloseViewAction.isEnabled(contents)) {
CloseViewAction.perform(RunnerContentUi.this, contents[0]);
} else if (MinimizeViewAction.isEnabled(RunnerContentUi.this, contents, ViewContext.TAB_TOOLBAR_PLACE)) {
grid.getCellFor(contents[0]).minimize(contents[0]);
}
}
}
});
if (myOriginal != null) {
final ContentManager manager = ContentFactory.SERVICE.getInstance().createContentManager(this, false, myProject);
Disposer.register((Disposable) myRunnerUi, manager);
manager.getComponent();
} else {
final DockManager dockManager = DockManager.getInstance(myProject);
if (dockManager != null) {
//default project
dockManager.register(this);
}
}
}
use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.
the class RunnerContentUi method select.
@Override
public ActionCallback select(@NotNull final Content content, final boolean requestFocus) {
final GridImpl grid = (GridImpl) findGridFor(content);
if (grid == null)
return ActionCallback.DONE;
final TabInfo info = myTabs.findInfo(grid);
if (info == null)
return ActionCallback.DONE;
final ActionCallback result = new ActionCallback();
myTabs.select(info, false).doWhenDone(() -> grid.select(content, requestFocus).notifyWhenDone(result));
return result;
}
use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.
the class RunnerContentUi method processDropOver.
@Override
public Image processDropOver(@NotNull DockableContent dockable, RelativePoint dropTarget) {
JBTabs current = getTabsAt(dockable, dropTarget);
if (myCurrentOver != null && myCurrentOver != current) {
resetDropOver(dockable);
}
if (myCurrentOver == null && current != null) {
myCurrentOver = current;
Presentation presentation = dockable.getPresentation();
myCurrentOverInfo = new TabInfo(new JLabel("")).setText(presentation.getText()).setIcon(presentation.getIcon());
myCurrentOverImg = myCurrentOver.startDropOver(myCurrentOverInfo, dropTarget);
}
if (myCurrentOver != null) {
myCurrentOver.processDropOver(myCurrentOverInfo, dropTarget);
}
if (myCurrentPainter == null) {
myCurrentPainter = new MyDropAreaPainter();
IdeGlassPaneUtil.find(myComponent).addPainter(myComponent, myCurrentPainter, this);
}
myCurrentPainter.processDropOver(this, dockable, dropTarget);
return myCurrentOverImg;
}
use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.
the class RunnerContentUi method processBounce.
public void processBounce(Content content, final boolean activate) {
final GridImpl grid = getGridFor(content, false);
if (grid == null)
return;
final GridCellImpl cell = grid.findCell(content);
if (cell == null)
return;
final TabInfo tab = myTabs.findInfo(grid);
if (tab == null)
return;
if (getSelectedGrid() != grid) {
tab.setAlertIcon(content.getAlertIcon());
if (activate) {
tab.fireAlert();
} else {
tab.stopAlerting();
}
} else {
grid.processAlert(content, activate);
}
}
Aggregations