-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MySQL Experience] (No.4) add link dialog related ui codes. #4965
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6558a2a
added link dialog related ui codes.
shenqianjin 0b6f86a
add itemContains method to change contains logic.
shenqianjin 14b8910
Merge branch 'qianjin-mysql-connected-3' into qianjin-mysql-connected-4
shenqianjin 44bfab3
Merge branch 'qianjin-mysql-connected-3' into qianjin-mysql-connected-4
shenqianjin 4494c5c
Merge branch 'qianjin-mysql-connected-3' into qianjin-mysql-connected-4
shenqianjin e72701f
code refactor.
shenqianjin 5bfd471
remove unused code.
shenqianjin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
39 changes: 39 additions & 0 deletions
39
...-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/common/ModuleComboBox.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,39 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
package com.microsoft.azure.toolkit.intellij.common; | ||
|
||
import com.intellij.openapi.module.Module; | ||
import com.intellij.openapi.module.ModuleManager; | ||
import com.intellij.openapi.project.Project; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class ModuleComboBox extends AzureComboBox<Module> { | ||
|
||
private final Project project; | ||
|
||
public ModuleComboBox(Project project) { | ||
super(true); | ||
this.project = project; | ||
} | ||
|
||
@Override | ||
protected List<? extends Module> loadItems() throws Exception { | ||
return Arrays.asList(ModuleManager.getInstance(project).getModules()); | ||
} | ||
|
||
@Override | ||
protected String getItemText(Object item) { | ||
if (item instanceof Module) { | ||
return ((Module) item).getName(); | ||
} else { | ||
return StringUtils.EMPTY; | ||
} | ||
} | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
...it-for-intellij/src/com/microsoft/azure/toolkit/intellij/link/mysql/DatabaseComboBox.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,68 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
package com.microsoft.azure.toolkit.intellij.link.mysql; | ||
|
||
import com.microsoft.azure.management.mysql.v2020_01_01.Server; | ||
import com.microsoft.azure.management.mysql.v2020_01_01.implementation.DatabaseInner; | ||
import com.microsoft.azure.management.mysql.v2020_01_01.implementation.MySQLManager; | ||
import com.microsoft.azure.management.resources.Subscription; | ||
import com.microsoft.azure.toolkit.intellij.common.AzureComboBox; | ||
import com.microsoft.azuretools.authmanage.AuthMethodManager; | ||
import com.microsoft.azuretools.sdkmanage.AzureManager; | ||
import lombok.Setter; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public class DatabaseComboBox extends AzureComboBox<DatabaseInner> { | ||
|
||
@Setter | ||
private Subscription subscription; | ||
private Server server; | ||
|
||
public DatabaseComboBox() { | ||
super(false); | ||
} | ||
|
||
public void setServer(Server server) { | ||
if (Objects.equals(server, this.server)) { | ||
return; | ||
} | ||
this.server = server; | ||
if (server == null) { | ||
this.clear(); | ||
return; | ||
} | ||
this.refreshItems(); | ||
} | ||
|
||
@Override | ||
protected String getItemText(Object item) { | ||
if (item instanceof DatabaseInner) { | ||
return ((DatabaseInner) item).name(); | ||
} | ||
return super.getItemText(item); | ||
} | ||
|
||
@Override | ||
protected List<? extends DatabaseInner> loadItems() throws Exception { | ||
if (subscription == null) { | ||
return new ArrayList<>(); | ||
} | ||
AzureManager manager = AuthMethodManager.getInstance().getAzureManager(); | ||
if (manager == null) { | ||
return new ArrayList<>(); | ||
} | ||
final MySQLManager mySQLManager = manager.getMySQLManager(subscription.subscriptionId()); | ||
return mySQLManager.databases().inner().listByServer(server.resourceGroupName(), server.name()); | ||
} | ||
|
||
@Override | ||
public boolean isRequired() { | ||
return true; | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
...lkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/link/mysql/ServerComboBox.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,67 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
package com.microsoft.azure.toolkit.intellij.link.mysql; | ||
|
||
import com.microsoft.azure.management.mysql.v2020_01_01.Server; | ||
import com.microsoft.azure.management.mysql.v2020_01_01.implementation.MySQLManager; | ||
import com.microsoft.azure.management.resources.Subscription; | ||
import com.microsoft.azure.toolkit.intellij.common.AzureComboBox; | ||
import com.microsoft.azuretools.authmanage.AuthMethodManager; | ||
import com.microsoft.azuretools.sdkmanage.AzureManager; | ||
import org.apache.commons.collections4.CollectionUtils; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public class ServerComboBox extends AzureComboBox<Server> { | ||
|
||
private Subscription subscription; | ||
|
||
public ServerComboBox() { | ||
super(true); | ||
} | ||
|
||
public void setSubscription(Subscription subscription) { | ||
if (Objects.equals(subscription, this.subscription)) { | ||
return; | ||
} | ||
this.subscription = subscription; | ||
if (subscription == null) { | ||
this.clear(); | ||
return; | ||
} | ||
this.refreshItems(); | ||
} | ||
|
||
@Override | ||
protected String getItemText(Object item) { | ||
if (item instanceof Server) { | ||
return ((Server) item).name(); | ||
} | ||
return super.getItemText(item); | ||
} | ||
|
||
@Override | ||
protected List<? extends Server> loadItems() throws Exception { | ||
if (subscription == null) { | ||
return new ArrayList<>(); | ||
} | ||
AzureManager manager = AuthMethodManager.getInstance().getAzureManager(); | ||
if (manager == null) { | ||
return new ArrayList<>(); | ||
} | ||
final MySQLManager mySQLManager = manager.getMySQLManager(subscription.subscriptionId()); | ||
return mySQLManager.servers().list(); | ||
} | ||
|
||
@Override | ||
public boolean isRequired() { | ||
return true; | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
...it-for-intellij/src/com/microsoft/azure/toolkit/intellij/link/mysql/UsernameComboBox.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,51 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
package com.microsoft.azure.toolkit.intellij.link.mysql; | ||
|
||
import com.microsoft.azure.management.mysql.v2020_01_01.Server; | ||
import com.microsoft.azure.toolkit.intellij.common.AzureComboBox; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public class UsernameComboBox extends AzureComboBox<String> { | ||
|
||
private static final String SEPARATOR = "@"; | ||
|
||
private Server server; | ||
|
||
public UsernameComboBox() { | ||
super(false); | ||
} | ||
|
||
public void setServer(Server server) { | ||
if (Objects.equals(server, this.server)) { | ||
return; | ||
} | ||
this.server = server; | ||
if (server == null) { | ||
this.clear(); | ||
return; | ||
} | ||
this.refreshItems(); | ||
} | ||
|
||
@Override | ||
protected List<? extends String> loadItems() { | ||
if (server == null) { | ||
return new ArrayList<>(); | ||
} | ||
List<String> usernames = new ArrayList<>(); | ||
usernames.add(server.administratorLogin() + SEPARATOR + server.name()); | ||
return usernames; | ||
} | ||
|
||
@Override | ||
public boolean isRequired() { | ||
return true; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!forceDisable