forked from redhat-developer/intellij-openshift-connector
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: validate new project name (redhat-developer#237)
Signed-off-by: Andre Dietisheim <[email protected]>
- Loading branch information
Showing
6 changed files
with
251 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/main/java/org/jboss/tools/intellij/openshift/ui/BaseDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Red Hat, Inc. | ||
* Distributed under license by Red Hat, Inc. All rights reserved. | ||
* This program is made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, | ||
* and is available at http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
******************************************************************************/ | ||
package org.jboss.tools.intellij.openshift.ui; | ||
|
||
import com.intellij.openapi.actionSystem.ActionManager; | ||
import com.intellij.openapi.actionSystem.AnAction; | ||
import com.intellij.openapi.actionSystem.CommonShortcuts; | ||
import com.intellij.openapi.actionSystem.IdeActions; | ||
import com.intellij.openapi.project.DumbAwareAction; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.ui.DialogWrapper; | ||
import com.intellij.ui.PopupBorder; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import javax.swing.JRootPane; | ||
import javax.swing.RootPaneContainer; | ||
import java.awt.Point; | ||
import java.awt.Window; | ||
|
||
import static org.jboss.tools.intellij.openshift.ui.SwingUtils.locationOrMouseLocation; | ||
|
||
public abstract class BaseDialog extends DialogWrapper { | ||
|
||
private final Point location; | ||
|
||
protected BaseDialog(@Nullable Project project, Point location) { | ||
super(project, false); | ||
this.location = location; | ||
init(); | ||
} | ||
|
||
@Override | ||
protected void init() { | ||
super.init(); | ||
Window dialogWindow = getPeer().getWindow(); | ||
JRootPane rootPane = ((RootPaneContainer) dialogWindow).getRootPane(); | ||
registerShortcuts(rootPane); | ||
setBorders(rootPane); | ||
setLocation(locationOrMouseLocation(location)); | ||
} | ||
|
||
private void registerShortcuts(JRootPane rootPane) { | ||
AnAction escape = ActionManager.getInstance().getAction(IdeActions.ACTION_EDITOR_ESCAPE); | ||
DumbAwareAction.create(e -> closeImmediately()) | ||
.registerCustomShortcutSet( | ||
escape == null ? CommonShortcuts.ESCAPE : escape.getShortcutSet(), | ||
rootPane, | ||
myDisposable); | ||
} | ||
|
||
private void setBorders(JRootPane rootPane) { | ||
rootPane.setBorder(PopupBorder.Factory.create(true, true)); | ||
rootPane.setWindowDecorationStyle(JRootPane.NONE); | ||
} | ||
|
||
protected void closeImmediately() { | ||
if (isVisible()) { | ||
doCancelAction(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.