Search in sources :

Example 1 with OperatingSystem

use of com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem in project azure-tools-for-java by Microsoft.

the class AppServiceCreateDialog method collectData.

private void collectData() {
    model.setCreatingNew(true);
    model.setWebAppName(textAppName.getText().trim());
    int index = comboSubscription.getSelectionIndex();
    model.setSubscriptionId(index < 0 ? null : binderSubscriptionDetails.get(index).getId());
    // Resource Group
    boolean isCreatingNewResGrp = btnResourceGroupCreateNew.getSelection();
    model.setCreatingResGrp(isCreatingNewResGrp);
    if (isCreatingNewResGrp) {
        model.setResourceGroup(textResourceGroupName.getText().trim());
    } else {
        index = comboResourceGroup.getSelectionIndex();
        model.setResourceGroup(index < 0 ? null : binderResourceGroup.get(index).getName());
    }
    // App Service Plan
    boolean isCreatingAppServicePlan = btnAppServiceCreateNew.getSelection();
    model.setCreatingAppServicePlan(isCreatingAppServicePlan);
    if (isCreatingAppServicePlan) {
        model.setAppServicePlanName(textAppSevicePlanName.getText().trim());
        index = comboAppServicePlanLocation.getSelectionIndex();
        model.setRegion(index < 0 ? null : binderAppServicePlanLocation.get(index).getName());
        model.setPricing(Optional.ofNullable(getSelectedPricingTier()).map(PricingTier::toString).orElse(APPSETTINGS_TOOLTIP));
    } else {
        index = comboAppServicePlan.getSelectionIndex();
        model.setAppServicePlanId(index < 0 ? null : binderAppServicePlan.get(index).id());
    }
    // Runtime
    final OperatingSystem os = getSelectedOS();
    final Runtime runtime = os == OperatingSystem.LINUX ? getSelectedRuntimeStack() : Runtime.getRuntime(OperatingSystem.WINDOWS, getSelectedWebcontainer(), getSelectedJavaVersion());
    model.saveRuntime(runtime);
}
Also used : PricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier) OperatingSystem(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem) Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime) Point(org.eclipse.swt.graphics.Point)

Example 2 with OperatingSystem

use of com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem in project azure-tools-for-java by Microsoft.

the class AppServiceCreateDialog method fillAppServicePlans.

protected void fillAppServicePlans() {
    Subscription selectedSubscription = getSelectedSubscription();
    if (selectedSubscription == null) {
        return;
    }
    OperatingSystem os = getSelectedOS();
    setComboRefreshingStatus(comboAppServicePlan, true);
    Mono.fromCallable(() -> {
        return Azure.az(AzureAppService.class).appServicePlans(selectedSubscription.getId(), false).stream().filter(asp -> asp.entity().getOperatingSystem() == null || asp.entity().getOperatingSystem() == os).collect(Collectors.toList());
    }).subscribeOn(Schedulers.boundedElastic()).subscribe(appServicePlans -> {
        appServicePlans.sort(Comparator.comparing(IAppServicePlan::name));
        DefaultLoader.getIdeHelper().invokeLater(() -> {
            setComboRefreshingStatus(comboAppServicePlan, false);
            binderAppServicePlan = new ArrayList<>();
            for (IAppServicePlan asp : appServicePlans) {
                binderAppServicePlan.add(asp);
                comboAppServicePlan.add(asp.name());
            }
            if (comboAppServicePlan.getItemCount() > 0) {
                comboAppServicePlan.select(0);
            }
            String aspName = CommonUtils.getPreference(CommonUtils.ASP_NAME);
            CommonUtils.selectComboIndex(comboAppServicePlan, aspName);
            fillAppServicePlansDetails();
        });
    });
}
Also used : OperatingSystem(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem) Arrays(java.util.Arrays) Azure(com.microsoft.azure.toolkit.lib.Azure) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) FocusEvent(org.eclipse.swt.events.FocusEvent) StringUtils(org.apache.commons.lang3.StringUtils) Point(org.eclipse.swt.graphics.Point) CommonUtils(com.microsoft.azuretools.webapp.util.CommonUtils) PluginUtil(com.microsoft.azuretools.core.utils.PluginUtil) Composite(org.eclipse.swt.widgets.Composite) PartInitException(org.eclipse.ui.PartInitException) Map(java.util.Map) AzureGroup(com.microsoft.azure.toolkit.lib.resource.AzureGroup) TraverseEvent(org.eclipse.swt.events.TraverseEvent) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) ILog(org.eclipse.core.runtime.ILog) PlatformUI(org.eclipse.ui.PlatformUI) Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime) Status(org.eclipse.core.runtime.Status) JavaVersion(com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion) TraverseListener(org.eclipse.swt.events.TraverseListener) Window(org.eclipse.jface.window.Window) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) SWT(org.eclipse.swt.SWT) EventUtil(com.microsoft.azuretools.telemetrywrapper.EventUtil) OperatingSystem(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem) SelectionListener(org.eclipse.swt.events.SelectionListener) AzureUIRefreshCore(com.microsoft.azuretools.utils.AzureUIRefreshCore) SimpleDateFormat(java.text.SimpleDateFormat) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject) Listener(org.eclipse.swt.widgets.Listener) ErrorWindow(com.microsoft.azuretools.core.ui.ErrorWindow) DefaultLoader(com.microsoft.tooling.msservices.components.DefaultLoader) Font(org.eclipse.swt.graphics.Font) GridData(org.eclipse.swt.layout.GridData) Link(org.eclipse.swt.widgets.Link) Nullable(javax.annotation.Nullable) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) TableItem(org.eclipse.swt.widgets.TableItem) FontDescriptor(org.eclipse.jface.resource.FontDescriptor) Shell(org.eclipse.swt.widgets.Shell) Mono(reactor.core.publisher.Mono) Field(java.lang.reflect.Field) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup) ASP_CREATE_PRICING(com.microsoft.azuretools.webapp.util.CommonUtils.ASP_CREATE_PRICING) ProgressDialog(com.microsoft.azuretools.core.utils.ProgressDialog) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) GridLayout(org.eclipse.swt.layout.GridLayout) TableEditor(org.eclipse.swt.custom.TableEditor) Activator(com.microsoft.azuretools.webapp.Activator) URL(java.net.URL) Date(java.util.Date) TableColumn(org.eclipse.swt.widgets.TableColumn) CommonUtils.getSelectedItem(com.microsoft.azuretools.webapp.util.CommonUtils.getSelectedItem) MavenUtils(com.microsoft.azuretools.core.utils.MavenUtils) IStatus(org.eclipse.core.runtime.IStatus) WebContainer(com.microsoft.azure.toolkit.lib.appservice.model.WebContainer) AzureWebAppMvpModel(com.microsoft.azuretools.core.mvp.model.webapp.AzureWebAppMvpModel) Button(org.eclipse.swt.widgets.Button) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Display(org.eclipse.swt.widgets.Display) Collectors(java.util.stream.Collectors) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Objects(java.util.Objects) ISharedImages(org.eclipse.ui.ISharedImages) List(java.util.List) CREATE_WEBAPP(com.microsoft.azuretools.telemetry.TelemetryConstants.CREATE_WEBAPP) Modifier(java.lang.reflect.Modifier) Optional(java.util.Optional) AzureMvpModel(com.microsoft.azuretools.core.mvp.model.AzureMvpModel) Label(org.eclipse.swt.widgets.Label) WEBAPP(com.microsoft.azuretools.telemetry.TelemetryConstants.WEBAPP) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration) Image(org.eclipse.swt.graphics.Image) Rectangle(org.eclipse.swt.graphics.Rectangle) HashMap(java.util.HashMap) PricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier) Table(org.eclipse.swt.widgets.Table) IWebApp(com.microsoft.azure.toolkit.lib.appservice.service.IWebApp) Event(org.eclipse.swt.widgets.Event) Region(com.microsoft.azure.toolkit.lib.common.model.Region) IAppServicePlan(com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan) ObjectUtils(org.apache.commons.lang3.ObjectUtils) Schedulers(reactor.core.scheduler.Schedulers) LinkedList(java.util.LinkedList) FillLayout(org.eclipse.swt.layout.FillLayout) AzureAppService(com.microsoft.azure.toolkit.lib.appservice.AzureAppService) Combo(org.eclipse.swt.widgets.Combo) MalformedURLException(java.net.MalformedURLException) AzureUIRefreshEvent(com.microsoft.azuretools.utils.AzureUIRefreshEvent) Group(org.eclipse.swt.widgets.Group) ASP_CREATE_LOCATION(com.microsoft.azuretools.webapp.util.CommonUtils.ASP_CREATE_LOCATION) EventType(com.microsoft.azuretools.telemetrywrapper.EventType) AccessibilityUtils(com.microsoft.azuretools.core.utils.AccessibilityUtils) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Comparator(java.util.Comparator) FocusAdapter(org.eclipse.swt.events.FocusAdapter) WebAppSettingModel(com.microsoft.azuretools.core.mvp.model.webapp.WebAppSettingModel) Control(org.eclipse.swt.widgets.Control) IAppServicePlan(com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription)

Example 3 with OperatingSystem

use of com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem in project azure-tools-for-java by Microsoft.

the class AppServiceInfoAdvancedPanel method onRuntimeChanged.

private void onRuntimeChanged(final ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED || e.getStateChange() == ItemEvent.DESELECTED) {
        final Runtime runtime = (Runtime) e.getItem();
        final OperatingSystem operatingSystem = Objects.isNull(runtime) ? null : runtime.getOperatingSystem();
        this.selectorServicePlan.setOperatingSystem(operatingSystem);
    }
}
Also used : OperatingSystem(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem) Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime)

Example 4 with OperatingSystem

use of com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem in project azure-tools-for-java by Microsoft.

the class FunctionAppConfigFormPanelAdvance method createUIComponents.

private void createUIComponents() {
    // TODO: place custom component creation code here
    appServiceConfigPanelAdvanced = new AppServiceInfoAdvancedPanel<>(project, () -> FunctionAppConfig.builder().build());
    appServiceConfigPanelAdvanced.setValidRuntime(Runtime.FUNCTION_APP_RUNTIME);
    appServiceConfigPanelAdvanced.setValidPricingTier(new ArrayList<>(PricingTier.FUNCTION_PRICING), PricingTier.CONSUMPTION);
    // Function does not support file deployment
    appServiceConfigPanelAdvanced.setDeploymentVisible(false);
    insightsConfig = ApplicationInsightsConfig.builder().newCreate(true).name(appServiceConfigPanelAdvanced.getTextName().getValue()).build();
    appServiceMonitorPanel = new AppServiceMonitorPanel(project);
    appServiceMonitorPanel.setWebServerLogVisible(false);
    appServiceMonitorPanel.setData(MonitorConfig.builder().applicationInsightsConfig(insightsConfig).build());
    appServiceConfigPanelAdvanced.getSelectorSubscription().addActionListener(event -> appServiceMonitorPanel.getApplicationInsightsComboBox().setSubscription(appServiceConfigPanelAdvanced.getSelectorSubscription().getValue()));
    appServiceConfigPanelAdvanced.getSelectorRuntime().addActionListener(event -> {
        final OperatingSystem operatingSystem = Optional.ofNullable(appServiceConfigPanelAdvanced.getSelectorRuntime().getValue()).map(Runtime::getOperatingSystem).orElse(null);
        appServiceMonitorPanel.setApplicationLogVisible(operatingSystem == OperatingSystem.WINDOWS);
    });
}
Also used : OperatingSystem(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem) AppServiceMonitorPanel(com.microsoft.azure.toolkit.intellij.appservice.AppServiceMonitorPanel)

Example 5 with OperatingSystem

use of com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem in project azure-tools-for-java by Microsoft.

the class WebAppBasePropertyView method showProperty.

@Override
public void showProperty(WebAppProperty webAppProperty) {
    txtResourceGroup.setText(webAppProperty.getValue(WebAppPropertyViewPresenter.KEY_RESOURCE_GRP) == null ? TXT_NA : (String) webAppProperty.getValue(WebAppPropertyViewPresenter.KEY_RESOURCE_GRP));
    txtStatus.setText(webAppProperty.getValue(WebAppPropertyViewPresenter.KEY_STATUS) == null ? TXT_NA : (String) webAppProperty.getValue(WebAppPropertyViewPresenter.KEY_STATUS));
    txtLocation.setText(webAppProperty.getValue(WebAppPropertyViewPresenter.KEY_LOCATION) == null ? TXT_NA : (String) webAppProperty.getValue(WebAppPropertyViewPresenter.KEY_LOCATION));
    txtSubscription.setText(webAppProperty.getValue(WebAppPropertyViewPresenter.KEY_SUB_ID) == null ? TXT_NA : (String) webAppProperty.getValue(WebAppPropertyViewPresenter.KEY_SUB_ID));
    txtAppServicePlan.setText(webAppProperty.getValue(WebAppPropertyViewPresenter.KEY_PLAN) == null ? TXT_NA : (String) webAppProperty.getValue(WebAppPropertyViewPresenter.KEY_PLAN));
    Object url = webAppProperty.getValue(WebAppPropertyViewPresenter.KEY_URL);
    if (url == null) {
        lnkUrl.setHyperlinkText(TXT_NA);
    } else {
        lnkUrl.setHyperlinkText("http://" + url);
        lnkUrl.setHyperlinkTarget("http://" + url);
    }
    txtPricingTier.setText(webAppProperty.getValue(WebAppPropertyViewPresenter.KEY_PRICING) == null ? TXT_NA : (String) webAppProperty.getValue(WebAppPropertyViewPresenter.KEY_PRICING));
    Object os = webAppProperty.getValue(WebAppPropertyViewPresenter.KEY_OPERATING_SYS);
    if (os != null && os instanceof OperatingSystem) {
        switch((OperatingSystem) os) {
            case WINDOWS:
            case LINUX:
                txtJavaVersion.setText(webAppProperty.getValue(WebAppPropertyViewPresenter.KEY_JAVA_VERSION) == null ? TXT_NA : (String) webAppProperty.getValue(WebAppPropertyViewPresenter.KEY_JAVA_VERSION));
                txtContainer.setText(webAppProperty.getValue(WebAppPropertyViewPresenter.KEY_JAVA_CONTAINER) == null ? TXT_NA : (String) webAppProperty.getValue(WebAppPropertyViewPresenter.KEY_JAVA_CONTAINER));
                txtJavaVersion.setVisible(true);
                txtContainer.setVisible(true);
                lblJavaVersion.setVisible(true);
                lblContainer.setVisible(true);
                break;
            case DOCKER:
                txtJavaVersion.setVisible(false);
                txtContainer.setVisible(false);
                lblJavaVersion.setVisible(false);
                lblContainer.setVisible(false);
                break;
            default:
                break;
        }
    }
    tableModel.getDataVector().removeAllElements();
    cachedAppSettings.clear();
    tblAppSetting.getEmptyText().setText(TABLE_EMPTY_MESSAGE);
    Object appSettingsObj = webAppProperty.getValue(WebAppPropertyViewPresenter.KEY_APP_SETTING);
    if (appSettingsObj != null && appSettingsObj instanceof Map) {
        Map<String, String> appSettings = (Map<String, String>) appSettingsObj;
        for (String key : appSettings.keySet()) {
            tableModel.addRow(new String[] { key, appSettings.get(key) });
            cachedAppSettings.put(key, appSettings.get(key));
        }
    }
    updateMapStatus(editedAppSettings, cachedAppSettings);
    pnlOverview.revalidate();
    pnlAppSettings.revalidate();
}
Also used : OperatingSystem(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

OperatingSystem (com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem)5 Runtime (com.microsoft.azure.toolkit.lib.appservice.model.Runtime)3 PricingTier (com.microsoft.azure.toolkit.lib.appservice.model.PricingTier)2 Point (org.eclipse.swt.graphics.Point)2 AppServiceMonitorPanel (com.microsoft.azure.toolkit.intellij.appservice.AppServiceMonitorPanel)1 Azure (com.microsoft.azure.toolkit.lib.Azure)1 AzureAppService (com.microsoft.azure.toolkit.lib.appservice.AzureAppService)1 JavaVersion (com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion)1 WebContainer (com.microsoft.azure.toolkit.lib.appservice.model.WebContainer)1 IAppServicePlan (com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan)1 IWebApp (com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)1 AzureAccount (com.microsoft.azure.toolkit.lib.auth.AzureAccount)1 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)1 Region (com.microsoft.azure.toolkit.lib.common.model.Region)1 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)1 Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)1 AzureGroup (com.microsoft.azure.toolkit.lib.resource.AzureGroup)1 AzureMvpModel (com.microsoft.azuretools.core.mvp.model.AzureMvpModel)1 AzureWebAppMvpModel (com.microsoft.azuretools.core.mvp.model.webapp.AzureWebAppMvpModel)1 WebAppSettingModel (com.microsoft.azuretools.core.mvp.model.webapp.WebAppSettingModel)1