use of com.intellij.openapi.wm.IdeFrame in project intellij-community by JetBrains.
the class EditorsSplitters method updateFileName.
void updateFileName(@Nullable final VirtualFile updatedFile) {
final EditorWindow[] windows = getWindows();
for (int i = 0; i != windows.length; ++i) {
for (VirtualFile file : windows[i].getFiles()) {
if (updatedFile == null || file.getName().equals(updatedFile.getName())) {
windows[i].updateFileName(file);
}
}
}
Project project = myManager.getProject();
final IdeFrame frame = getFrame(project);
if (frame != null) {
VirtualFile file = getCurrentFile();
File ioFile = file == null ? null : new File(file.getPresentableUrl());
String fileTitle = null;
if (file != null) {
fileTitle = DumbService.isDumb(project) ? file.getName() : FrameTitleBuilder.getInstance().getFileTitle(project, file);
}
frame.setFileTitle(fileTitle, ioFile);
}
}
use of com.intellij.openapi.wm.IdeFrame in project intellij-community by JetBrains.
the class ApplicationActivationStateManager method updateState.
public static boolean updateState(final WindowEvent windowEvent) {
final Application application = ApplicationManager.getApplication();
if (!(application instanceof ApplicationImpl))
return false;
final Window eventWindow = windowEvent.getWindow();
if (windowEvent.getID() == WindowEvent.WINDOW_ACTIVATED || windowEvent.getID() == WindowEvent.WINDOW_GAINED_FOCUS) {
if (state.isInactive()) {
Window window = windowEvent.getWindow();
return setActive(application, window);
}
} else if (windowEvent.getID() == WindowEvent.WINDOW_DEACTIVATED && windowEvent.getOppositeWindow() == null) {
requestToDeactivateTime.getAndSet(System.currentTimeMillis());
// For stuff that cannot wait windowEvent notify about deactivation immediately
if (state.isActive()) {
IdeFrame ideFrame = getIdeFrameFromWindow(windowEvent.getWindow());
if (ideFrame != null) {
application.getMessageBus().syncPublisher(ApplicationActivationListener.TOPIC).applicationDeactivated(ideFrame);
}
}
// We do not know for sure that application is going to be inactive,
// windowEvent could just be showing a popup or another transient window.
// So let's postpone the application deactivation for a while
state = State.DEACTIVATING;
LOG.debug("The app is in the deactivating state");
Timer timer = UIUtil.createNamedTimer("ApplicationDeactivation", Registry.intValue("application.deactivation.timeout"), new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (state.equals(State.DEACTIVATING)) {
state = State.DEACTIVATED;
LOG.debug("The app is in the deactivated state");
IdeFrame ideFrame = getIdeFrameFromWindow(windowEvent.getWindow());
if (ideFrame != null) {
application.getMessageBus().syncPublisher(ApplicationActivationListener.TOPIC).delayedApplicationDeactivated(ideFrame);
}
}
}
});
timer.setRepeats(false);
timer.start();
return true;
}
return false;
}
use of com.intellij.openapi.wm.IdeFrame in project intellij-community by JetBrains.
the class NotificationsManagerImpl method notifyByBalloon.
@Nullable
private static Balloon notifyByBalloon(@NotNull final Notification notification, @NotNull final NotificationDisplayType displayType, @Nullable final Project project) {
if (isDummyEnvironment())
return null;
Window window = findWindowForBalloon(project);
if (window instanceof IdeFrame) {
BalloonLayout layout = ((IdeFrame) window).getBalloonLayout();
if (layout == null)
return null;
final ProjectManager projectManager = ProjectManager.getInstance();
final boolean noProjects = projectManager.getOpenProjects().length == 0;
final boolean sticky = NotificationDisplayType.STICKY_BALLOON == displayType || noProjects;
Ref<BalloonLayoutData> layoutDataRef = new Ref<>();
if (project == null || project.isDefault()) {
BalloonLayoutData layoutData = new BalloonLayoutData();
layoutData.groupId = "";
layoutData.welcomeScreen = layout instanceof WelcomeBalloonLayoutImpl;
layoutData.type = notification.getType();
layoutDataRef.set(layoutData);
} else {
BalloonLayoutData.MergeInfo mergeData = ((BalloonLayoutImpl) layout).preMerge(notification);
if (mergeData != null) {
BalloonLayoutData layoutData = new BalloonLayoutData();
layoutData.mergeData = mergeData;
layoutDataRef.set(layoutData);
}
}
final Balloon balloon = createBalloon((IdeFrame) window, notification, false, false, layoutDataRef, project != null ? project : ApplicationManager.getApplication());
if (notification.isExpired()) {
return null;
}
layout.add(balloon, layoutDataRef.get());
if (balloon.isDisposed()) {
return null;
}
if (layoutDataRef.get() != null) {
layoutDataRef.get().project = project;
}
((BalloonImpl) balloon).startFadeoutTimer(0);
if (NotificationDisplayType.BALLOON == displayType) {
FrameStateManager.getInstance().getApplicationActive().doWhenDone(() -> {
if (!sticky && !balloon.isDisposed()) {
((BalloonImpl) balloon).startSmartFadeoutTimer(10000);
}
});
}
return balloon;
}
return null;
}
use of com.intellij.openapi.wm.IdeFrame in project intellij-community by JetBrains.
the class NotificationsManagerImpl method showNotification.
private static void showNotification(@NotNull final Notification notification, @Nullable final Project project) {
Application application = ApplicationManager.getApplication();
if (application instanceof ApplicationEx && !((ApplicationEx) application).isLoaded()) {
application.invokeLater(() -> showNotification(notification, project), ModalityState.current());
return;
}
String groupId = notification.getGroupId();
final NotificationSettings settings = NotificationsConfigurationImpl.getSettings(groupId);
NotificationDisplayType type = settings.getDisplayType();
String toolWindowId = NotificationsConfigurationImpl.getInstanceImpl().getToolWindowId(groupId);
if (type == NotificationDisplayType.TOOL_WINDOW && (toolWindowId == null || project == null || !ToolWindowManager.getInstance(project).canShowNotification(toolWindowId))) {
type = NotificationDisplayType.BALLOON;
}
switch(type) {
case NONE:
return;
// break;
case STICKY_BALLOON:
case BALLOON:
default:
Balloon balloon = notifyByBalloon(notification, type, project);
if (project == null || project.isDefault()) {
return;
}
if (!settings.isShouldLog() || type == NotificationDisplayType.STICKY_BALLOON) {
if (balloon == null) {
notification.expire();
} else {
balloon.addListener(new JBPopupAdapter() {
@Override
public void onClosed(LightweightWindowEvent event) {
if (!event.isOk()) {
notification.expire();
}
}
});
}
}
break;
case TOOL_WINDOW:
MessageType messageType = notification.getType() == NotificationType.ERROR ? MessageType.ERROR : notification.getType() == NotificationType.WARNING ? MessageType.WARNING : MessageType.INFO;
final NotificationListener notificationListener = notification.getListener();
HyperlinkListener listener = notificationListener == null ? null : new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
notificationListener.hyperlinkUpdate(notification, e);
}
};
assert toolWindowId != null;
String msg = notification.getTitle();
if (StringUtil.isNotEmpty(notification.getContent())) {
if (StringUtil.isNotEmpty(msg)) {
msg += "<br>";
}
msg += notification.getContent();
}
Window window = findWindowForBalloon(project);
if (window instanceof IdeFrame) {
BalloonLayout layout = ((IdeFrame) window).getBalloonLayout();
if (layout != null) {
((BalloonLayoutImpl) layout).remove(notification);
}
}
//noinspection SSBasedInspection
ToolWindowManager.getInstance(project).notifyByBalloon(toolWindowId, messageType, msg, notification.getIcon(), listener);
}
}
use of com.intellij.openapi.wm.IdeFrame in project intellij-community by JetBrains.
the class KeymapPanel method createKeymapButtonsPanel.
private JPanel createKeymapButtonsPanel() {
final JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
panel.setLayout(new GridBagLayout());
myCopyButton = new JButton(new AbstractAction(KeyMapBundle.message("copy.keymap.button")) {
@Override
public void actionPerformed(ActionEvent e) {
copyKeymap();
}
});
Insets insets = JBUI.insets(2);
myCopyButton.setMargin(insets);
final GridBagConstraints gc = new GridBagConstraints(GridBagConstraints.RELATIVE, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0);
panel.add(myCopyButton, gc);
myResetToDefault = new JButton(CommonBundle.message("button.reset"));
myResetToDefault.setMargin(insets);
panel.add(myResetToDefault, gc);
myDeleteButton = new JButton(new AbstractAction(KeyMapBundle.message("delete.keymap.button")) {
@Override
public void actionPerformed(ActionEvent e) {
deleteKeymap();
}
});
myDeleteButton.setMargin(insets);
gc.weightx = 1;
panel.add(myDeleteButton, gc);
IdeFrame ideFrame = IdeFocusManager.getGlobalInstance().getLastFocusedFrame();
if (ideFrame != null && KeyboardSettingsExternalizable.isSupportedKeyboardLayout(ideFrame.getComponent())) {
String displayLanguage = ideFrame.getComponent().getInputContext().getLocale().getDisplayLanguage();
myNonEnglishKeyboardSupportOption = new JCheckBox(new AbstractAction(displayLanguage + " " + KeyMapBundle.message("use.non.english.keyboard.layout.support")) {
@Override
public void actionPerformed(ActionEvent e) {
KeyboardSettingsExternalizable.getInstance().setNonEnglishKeyboardSupportEnabled(myNonEnglishKeyboardSupportOption.isSelected());
}
});
myNonEnglishKeyboardSupportOption.setSelected(KeyboardSettingsExternalizable.getInstance().isNonEnglishKeyboardSupportEnabled());
panel.add(myNonEnglishKeyboardSupportOption, gc);
}
myResetToDefault.addActionListener(new ActionListener() {
@Override
public void actionPerformed(@NotNull ActionEvent e) {
resetKeymap();
}
});
return panel;
}
Aggregations