Search in sources :

Example 1 with AzureListenerWrapper

use of com.microsoft.azuretools.core.components.AzureListenerWrapper in project azure-tools-for-java by Microsoft.

the class ContainerRegistryExplorerEditor method createPartControl.

@Override
public void createPartControl(Composite parent) {
    scrolledComposite = new ScrolledComposite(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    panelHolder = new Composite(scrolledComposite, SWT.NONE);
    GridLayout glPanelHolder = new GridLayout(1, false);
    glPanelHolder.marginHeight = 0;
    glPanelHolder.verticalSpacing = 0;
    glPanelHolder.horizontalSpacing = 0;
    panelHolder.setLayout(glPanelHolder);
    progressBar = new ProgressBar(panelHolder, SWT.HORIZONTAL | SWT.INDETERMINATE);
    GridData gdProgressBar = new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1);
    gdProgressBar.heightHint = PROGRESS_BAR_HEIGHT;
    progressBar.setLayoutData(gdProgressBar);
    container = new Composite(panelHolder, SWT.NONE);
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    GridLayout glContainer = new GridLayout(4, false);
    glContainer.marginHeight = 2;
    glContainer.marginWidth = 0;
    glContainer.horizontalSpacing = 30;
    glContainer.verticalSpacing = 10;
    container.setLayout(glContainer);
    Label lblRegistryName = new Label(container, SWT.NONE);
    lblRegistryName.setText(LABEL_NAME);
    txtRegistryName = new Text(container, SWT.READ_ONLY | SWT.BORDER);
    txtRegistryName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    txtRegistryName.setText(LOADING);
    Label lblAdminUserEnabled = new Label(container, SWT.NONE);
    lblAdminUserEnabled.setText(LABEL_ADMIN_USER_ENABLED);
    compAdminUserBtn = new Composite(container, SWT.NONE);
    compAdminUserBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    GridLayout compositeLayout = new GridLayout(2, true);
    compositeLayout.marginWidth = 0;
    compositeLayout.marginHeight = 0;
    compositeLayout.horizontalSpacing = 0;
    compositeLayout.verticalSpacing = 0;
    compAdminUserBtn.setLayout(compositeLayout);
    btnEnable = new Button(compAdminUserBtn, SWT.NONE);
    btnEnable.setEnabled(false);
    btnEnable.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnEnable.setText(BTN_ENABLE);
    btnDisable = new Button(compAdminUserBtn, SWT.NONE);
    btnDisable.setEnabled(false);
    btnDisable.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnDisable.setText(BTN_DISABLE);
    Label lblType = new Label(container, SWT.NONE);
    lblType.setText(LABEL_TYPE);
    txtType = new Text(container, SWT.BORDER | SWT.READ_ONLY);
    txtType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    txtType.setText(LOADING);
    lblUserName = new Label(container, SWT.NONE);
    lblUserName.setText(LABEL_USER_NAME);
    lblUserName.setVisible(false);
    txtUserName = new Text(container, SWT.BORDER | SWT.READ_ONLY);
    txtUserName.setText(LOADING);
    txtUserName.setVisible(false);
    Label lblResourceGroup = new Label(container, SWT.NONE);
    lblResourceGroup.setText(LABEL_RES_GRP);
    txtResGrp = new Text(container, SWT.BORDER | SWT.READ_ONLY);
    txtResGrp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    txtResGrp.setText(LOADING);
    lblPrimaryPassword = new Label(container, SWT.NONE);
    lblPrimaryPassword.setText(LABEL_PASSWORD);
    lblPrimaryPassword.setVisible(false);
    lnkPrimaryPassword = new Link(container, SWT.NONE);
    lnkPrimaryPassword.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    lnkPrimaryPassword.setText(COPY_TO_CLIPBOARD);
    lnkPrimaryPassword.setVisible(false);
    lnkPrimaryPassword.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "lnkPrimaryPassword", null) {

        @Override
        protected void handleEventFunc(Event event) {
            try {
                Utils.copyToSystemClipboard(password);
            } catch (Exception e) {
                onError(e.getMessage());
            }
        }
    });
    Label lblSubscriptionId = new Label(container, SWT.NONE);
    lblSubscriptionId.setText(LABEL_SUBSCRIPTION);
    txtSubscriptionId = new Text(container, SWT.BORDER | SWT.READ_ONLY);
    txtSubscriptionId.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    txtSubscriptionId.setText(LOADING);
    lblSecondaryPassword = new Label(container, SWT.NONE);
    lblSecondaryPassword.setText(LABEL_PASSWORD2);
    lblSecondaryPassword.setVisible(false);
    lnkSecondaryPassword = new Link(container, SWT.NONE);
    lnkSecondaryPassword.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    lnkSecondaryPassword.setText(COPY_TO_CLIPBOARD);
    lnkSecondaryPassword.setVisible(false);
    lnkSecondaryPassword.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "lnkSecondaryPassword", null) {

        @Override
        protected void handleEventFunc(Event event) {
            try {
                Utils.copyToSystemClipboard(password2);
            } catch (Exception e) {
                onError(e.getMessage());
            }
        }
    });
    Label lblRegion = new Label(container, SWT.NONE);
    lblRegion.setText(LABEL_REGION);
    txtRegion = new Text(container, SWT.BORDER | SWT.READ_ONLY);
    txtRegion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    txtRegion.setText(LOADING);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    Label lblLoginServerUrl = new Label(container, SWT.NONE);
    lblLoginServerUrl.setText(LABEL_LOGIN_SERVER_URL);
    txtLoginServerUrl = new Text(container, SWT.BORDER | SWT.READ_ONLY);
    txtLoginServerUrl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    txtLoginServerUrl.setText(LOADING);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    label = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL);
    label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1));
    sashForm = new SashForm(container, SWT.NONE);
    sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
    cmpoRepo = new Composite(sashForm, SWT.BORDER);
    cmpoRepo.setLayout(new GridLayout(2, false));
    Label lblRepo = new Label(cmpoRepo, SWT.NONE);
    lblRepo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
    lblRepo.setText(LABEL_REPOSITORY);
    repoRefreshToolBar = new ToolBar(cmpoRepo, SWT.FLAT | SWT.RIGHT);
    tltmRefreshRepo = new ToolItem(repoRefreshToolBar, SWT.NONE);
    tltmRefreshRepo.setImage(imgRefreshEnable);
    tltmRefreshRepo.setToolTipText(TLTM_REFRESH);
    tltmRefreshRepo.setText(TLTM_REFRESH);
    tltmRefreshRepo.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "tltmRefreshRepo", null) {

        @Override
        protected void handleEventFunc(Event event) {
            disableWidgets(true, true);
            containerExplorerPresenter.onRefreshRepositories(subscriptionId, registryId, true);
        }
    });
    lstRepo = new org.eclipse.swt.widgets.List(cmpoRepo, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    lstRepo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    lstRepo.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "lstRepo", null) {

        @Override
        protected void handleEventFunc(Event event) {
            int index = lstRepo.getSelectionIndex();
            if (index < 0 || index >= lstRepo.getItemCount()) {
                return;
            }
            String selectedRepo = lstRepo.getItem(index);
            if (Utils.isEmptyString(selectedRepo) || selectedRepo.equals(currentRepo)) {
                return;
            }
            currentRepo = selectedRepo;
            disableWidgets(false, true);
            containerExplorerPresenter.onListTags(subscriptionId, registryId, currentRepo, true);
        }
    });
    repoToolBar = new ToolBar(cmpoRepo, SWT.FLAT | SWT.RIGHT);
    repoToolBar.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 2, 1));
    tltmRepoPreviousPage = new ToolItem(repoToolBar, SWT.NONE);
    tltmRepoPreviousPage.setToolTipText(TLTM_PREVIOUS);
    tltmRepoPreviousPage.setText(TLTM_PREVIOUS);
    ;
    tltmRepoPreviousPage.setText("Previous");
    tltmRepoPreviousPage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_BACK));
    tltmRepoPreviousPage.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "tltmRepoPreviousPage", null) {

        @Override
        protected void handleEventFunc(Event event) {
            disableWidgets(true, true);
            containerExplorerPresenter.onListRepositories(subscriptionId, registryId, false);
        }
    });
    tltmRepoNextPage = new ToolItem(repoToolBar, SWT.NONE);
    tltmRepoNextPage.setToolTipText(TLTM_NEXT);
    tltmRepoNextPage.setText(TLTM_NEXT);
    tltmRepoNextPage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_FORWARD));
    tltmRepoNextPage.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "tltmRepoNextPage", null) {

        @Override
        protected void handleEventFunc(Event event) {
            disableWidgets(true, true);
            containerExplorerPresenter.onListRepositories(subscriptionId, registryId, true);
        }
    });
    cmpoTag = new Composite(sashForm, SWT.BORDER);
    cmpoTag.setLayout(new GridLayout(2, false));
    lblTag = new Label(cmpoTag, SWT.NONE);
    lblTag.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
    lblTag.setText(LABEL_TAG);
    tagRefreshToolBar = new ToolBar(cmpoTag, SWT.FLAT | SWT.RIGHT);
    tltmRefreshTag = new ToolItem(tagRefreshToolBar, SWT.NONE);
    tltmRefreshTag.setImage(imgRefreshEnable);
    tltmRefreshTag.setToolTipText(TLTM_REFRESH);
    tltmRefreshTag.setText(TLTM_REFRESH);
    tltmRefreshTag.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "tltmRefreshTag", null) {

        @Override
        protected void handleEventFunc(Event event) {
            if (Utils.isEmptyString(currentRepo)) {
                return;
            }
            disableWidgets(false, true);
            containerExplorerPresenter.onListTags(subscriptionId, registryId, currentRepo, true);
        }
    });
    lstTag = new org.eclipse.swt.widgets.List(cmpoTag, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    lstTag.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    lstTag.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "lstTag", null) {

        @Override
        protected void handleEventFunc(Event event) {
            int index = lstTag.getSelectionIndex();
            if (index < 0 || index >= lstTag.getItemCount()) {
                return;
            }
            String selectedTag = lstTag.getItem(index);
            if (Utils.isEmptyString(selectedTag) || selectedTag.equals(currentTag)) {
                return;
            }
            currentTag = selectedTag;
        }
    });
    popupMenu = new Menu(lstTag);
    MenuItem pullImage = new MenuItem(popupMenu, SWT.NONE);
    pullImage.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "menuItem", null) {

        @Override
        protected void handleEventFunc(Event event) {
            pullImage();
        }
    });
    pullImage.setText(PULL_IMAGE);
    lstTag.setMenu(popupMenu);
    lstTag.addListener(SWT.MenuDetect, new Listener() {

        @Override
        public void handleEvent(Event event) {
            int index = lstTag.getSelectionIndex();
            if (index == -1) {
                event.doit = false;
            }
        }
    });
    tagToolBar = new ToolBar(cmpoTag, SWT.FLAT | SWT.RIGHT);
    tagToolBar.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 2, 1));
    tltmTagPreviousPage = new ToolItem(tagToolBar, SWT.NONE);
    tltmTagPreviousPage.setToolTipText(TLTM_PREVIOUS);
    tltmTagPreviousPage.setText(TLTM_PREVIOUS);
    tltmTagPreviousPage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_BACK));
    tltmTagPreviousPage.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "tltmTagPreviousPage", null) {

        @Override
        protected void handleEventFunc(Event event) {
            if (Utils.isEmptyString(currentRepo)) {
                return;
            }
            disableWidgets(false, true);
            containerExplorerPresenter.onListTags(subscriptionId, registryId, currentRepo, false);
        }
    });
    tltmTagNextPage = new ToolItem(tagToolBar, SWT.NONE);
    tltmTagNextPage.setToolTipText(TLTM_NEXT);
    tltmTagNextPage.setText(TLTM_NEXT);
    tltmTagNextPage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_FORWARD));
    tltmTagNextPage.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "tltmTagNextPage", null) {

        @Override
        protected void handleEventFunc(Event event) {
            if (Utils.isEmptyString(currentRepo)) {
                return;
            }
            disableWidgets(false, true);
            containerExplorerPresenter.onListTags(subscriptionId, registryId, currentRepo, true);
        }
    });
    sashForm.setWeights(new int[] { 1, 1 });
    btnEnable.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "btnEnable", null) {

        @Override
        protected void handleEventFunc(Event event) {
            disableWidgets(true, true);
            onAdminUserBtnClick();
        }
    });
    btnDisable.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "btnDisable", null) {

        @Override
        protected void handleEventFunc(Event event) {
            disableWidgets(false, false);
            onAdminUserBtnClick();
        }
    });
    disableWidgets(true, true);
    setScrolledCompositeContent();
    setChildrenTransparent(panelHolder);
    setChildrenTransparent(container);
    txtRegistryName.setFocus();
}
Also used : Listener(org.eclipse.swt.widgets.Listener) IWorkbenchListener(org.eclipse.ui.IWorkbenchListener) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) MenuItem(org.eclipse.swt.widgets.MenuItem) AzureListenerWrapper(com.microsoft.azuretools.core.components.AzureListenerWrapper) PartInitException(org.eclipse.ui.PartInitException) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Event(org.eclipse.swt.widgets.Event) Menu(org.eclipse.swt.widgets.Menu) ProgressBar(org.eclipse.swt.widgets.ProgressBar) Link(org.eclipse.swt.widgets.Link) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 2 with AzureListenerWrapper

use of com.microsoft.azuretools.core.components.AzureListenerWrapper in project azure-tools-for-java by Microsoft.

the class RedisExplorerEditor method createPartControl.

/**
 * Create contents of the editor part.
 *
 * @param parent.
 */
@Override
public void createPartControl(Composite parent) {
    ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    Composite cmpoMain = new Composite(scrolledComposite, SWT.NONE);
    GridLayout gridLayout = new GridLayout(2, false);
    cmpoMain.setLayout(gridLayout);
    Label lblChooseDb = new Label(cmpoMain, SWT.NONE);
    lblChooseDb.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblChooseDb.setText("Database :");
    cbDatabase = new Combo(cmpoMain, SWT.READ_ONLY);
    cbDatabase.setEnabled(false);
    GridData cbDataBaseLayout = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
    cbDataBaseLayout.minimumWidth = 50;
    cbDatabase.setLayoutData(cbDataBaseLayout);
    SashForm sashForm = new SashForm(cmpoMain, SWT.HORIZONTAL);
    sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 2, 1));
    Composite cmpoKeyArea = new Composite(sashForm, SWT.BORDER);
    cmpoKeyArea.setLayout(new GridLayout(3, false));
    cbActionType = new Combo(cmpoKeyArea, SWT.READ_ONLY);
    cbActionType.setEnabled(false);
    cbActionType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    cbActionType.add(ACTION_SCAN);
    cbActionType.add(ACTION_GET);
    cbActionType.select(0);
    txtKeyPattern = new Text(cmpoKeyArea, SWT.BORDER);
    txtKeyPattern.setEditable(false);
    txtKeyPattern.setText(DEFAULT_SCAN_PATTERN);
    txtKeyPattern.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    btnSearch = new Button(cmpoKeyArea, SWT.NONE);
    btnSearch.setEnabled(false);
    btnSearch.setImage(Activator.getImageDescriptor(SEARCH_ICON_PATH).createImage());
    lstKey = new List(cmpoKeyArea, SWT.BORDER | SWT.V_SCROLL);
    lstKey.setEnabled(false);
    lstKey.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 3, 1));
    btnScanMoreKey = new Button(cmpoKeyArea, SWT.NONE);
    btnScanMoreKey.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 3, 1));
    btnScanMoreKey.setEnabled(false);
    btnScanMoreKey.setText("Scan More");
    Composite cmpoValueArea = new Composite(sashForm, SWT.NONE);
    GridLayout cmpoValueAreaLayout = new GridLayout(2, false);
    cmpoValueAreaLayout.marginWidth = NO_MARGIN;
    cmpoValueAreaLayout.marginHeight = NO_MARGIN;
    cmpoValueArea.setLayout(cmpoValueAreaLayout);
    cmpoValue = new Composite(cmpoValueArea, SWT.BORDER);
    cmpoValue.setLayout(new GridLayout(2, false));
    cmpoValue.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    GridLayout cmpoKeyInfoLayout = new GridLayout(2, false);
    cmpoKeyInfoLayout.verticalSpacing = 8;
    cmpoKeyInfoLayout.marginHeight = NO_MARGIN;
    cmpoKeyInfoLayout.marginTop = NO_MARGIN;
    cmpoKeyInfoLayout.marginWidth = NO_MARGIN;
    Composite cmpoKeyInfo = new Composite(cmpoValue, SWT.NONE);
    cmpoKeyInfo.setLayout(cmpoKeyInfoLayout);
    cmpoKeyInfo.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false, 2, 1));
    Label lblType = new Label(cmpoKeyInfo, SWT.NONE);
    lblType.setText("Type :");
    lblTypeValue = new Label(cmpoKeyInfo, SWT.NONE);
    lblTypeValue.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label lblKey = new Label(cmpoKeyInfo, SWT.NONE);
    lblKey.setText("Key :");
    lblKeyValue = new Label(cmpoKeyInfo, SWT.NONE);
    lblKeyValue.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label lblValue = new Label(cmpoKeyInfo, SWT.NONE);
    lblValue.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    lblValue.setText("Value :");
    cmpoInnerValue = new Composite(cmpoValue, SWT.NONE);
    cmpoInnerValue.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    cmpoInnerValue.setVisible(false);
    GridLayout cmpoInnerValueLayout = new GridLayout(1, false);
    cmpoInnerValueLayout.marginHeight = NO_MARGIN;
    cmpoInnerValueLayout.marginWidth = NO_MARGIN;
    cmpoInnerValue.setLayout(cmpoInnerValueLayout);
    tblInnerValue = new Table(cmpoInnerValue, SWT.BORDER | SWT.FULL_SELECTION);
    tblInnerValue.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    tblInnerValue.setHeaderVisible(true);
    tblInnerValue.setLinesVisible(true);
    cmpoStringValue = new Composite(cmpoValue, SWT.NONE);
    cmpoStringValue.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    cmpoStringValue.setVisible(false);
    GridLayout cmpoStringValueLayout = new GridLayout(1, false);
    cmpoStringValueLayout.marginHeight = NO_MARGIN;
    cmpoStringValueLayout.marginWidth = NO_MARGIN;
    cmpoStringValue.setLayout(cmpoStringValueLayout);
    txtStringValue = new Text(cmpoStringValue, SWT.BORDER | SWT.READ_ONLY | SWT.MULTI);
    txtStringValue.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    txtStringValue.setBackground(tblInnerValue.getBackground());
    GridLayout cmpoProgressLayout = new GridLayout(1, false);
    cmpoProgressLayout.marginWidth = NO_MARGIN;
    cmpoProgressLayout.marginTop = PROGRESS_MARGIN_TOP;
    cmpoProgressLayout.marginBottom = PROGRESS_MARGIN_BOTTOM;
    Composite cmpoProgress = new Composite(cmpoValueArea, SWT.NONE);
    cmpoProgress.setLayout(cmpoProgressLayout);
    cmpoProgress.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 2, 1));
    progressBar = new ProgressBar(cmpoProgress, SWT.HORIZONTAL | SWT.INDETERMINATE);
    GridData progressBarLayout = new GridData(SWT.RIGHT, SWT.BOTTOM, false, false, 1, 1);
    progressBarLayout.widthHint = PROGRESS_WIDTH;
    progressBar.setLayoutData(progressBarLayout);
    sashForm.setWeights(new int[] { 1, 1 });
    scrolledComposite.setContent(cmpoMain);
    scrolledComposite.setMinSize(cmpoMain.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    cbDatabase.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "cbDatabase", null) {

        @Override
        protected void handleEventFunc(Event event) {
            if (cbActionType.getText().equals(ACTION_GET)) {
                return;
            }
            setWidgetEnableStatus(false);
            txtKeyPattern.setText(DEFAULT_SCAN_PATTERN);
            onDataBaseSelect();
        }
    });
    lstKey.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "lstKey", null) {

        @Override
        protected void handleEventFunc(Event event) {
            String selectedKey = lstKey.getItem(lstKey.getSelectionIndex());
            if (selectedKey.equals(lastChosenKey)) {
                return;
            }
            setWidgetEnableStatus(false);
            lastChosenKey = selectedKey;
            redisExplorerPresenter.onkeySelect(cbDatabase.getSelectionIndex(), selectedKey);
        }
    });
    btnSearch.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "btnSearch", null) {

        @Override
        protected void handleEventFunc(Event event) {
            onBtnSearchClick();
        }
    });
    btnScanMoreKey.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "btnScanMoreKey", null) {

        @Override
        protected void handleEventFunc(Event event) {
            setWidgetEnableStatus(false);
            redisExplorerPresenter.onKeyList(cbDatabase.getSelectionIndex(), currentCursor, txtKeyPattern.getText());
        }
    });
    txtKeyPattern.addListener(SWT.KeyDown, event -> {
        // Enter key pressed
        if (event.keyCode == SWT.CR) {
            onBtnSearchClick();
        }
    });
    cbActionType.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "cbActionType", null) {

        @Override
        protected void handleEventFunc(Event event) {
            String selected = cbActionType.getText();
            if (selected.equals(ACTION_GET)) {
                btnScanMoreKey.setEnabled(false);
            } else if (selected.equals(ACTION_SCAN)) {
                btnScanMoreKey.setEnabled(true);
            }
        }
    });
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) AzureListenerWrapper(com.microsoft.azuretools.core.components.AzureListenerWrapper) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Event(org.eclipse.swt.widgets.Event) List(org.eclipse.swt.widgets.List) ProgressBar(org.eclipse.swt.widgets.ProgressBar)

Example 3 with AzureListenerWrapper

use of com.microsoft.azuretools.core.components.AzureListenerWrapper in project azure-tools-for-java by Microsoft.

the class WebAppBasePropertyEditor method createPartControl.

@Override
public void createPartControl(Composite parent) {
    GridLayout glCpRoot = new GridLayout(1, false);
    glCpRoot.marginWidth = 0;
    glCpRoot.verticalSpacing = 0;
    glCpRoot.horizontalSpacing = 0;
    glCpRoot.marginHeight = 0;
    Composite cpRoot = new Composite(parent, SWT.NONE);
    cpRoot.setLayout(glCpRoot);
    progressBar = new ProgressBar(cpRoot, SWT.INDETERMINATE);
    GridData gdProgressBar = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gdProgressBar.heightHint = PROGRESS_BAR_HEIGHT;
    progressBar.setLayoutData(gdProgressBar);
    ScrolledComposite scrolledComposite = new ScrolledComposite(cpRoot, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    Composite area = new Composite(scrolledComposite, SWT.NONE);
    GridLayout glArea = new GridLayout(1, false);
    area.setLayout(glArea);
    Composite composite = new Composite(area, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    GridLayout glComposite = new GridLayout(1, false);
    composite.setLayout(glComposite);
    Composite cpControlButtons = new Composite(composite, SWT.NONE);
    cpControlButtons.setLayout(new GridLayout(3, false));
    cpControlButtons.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
    btnGetPublishProfile = new Button(cpControlButtons, SWT.NONE);
    btnGetPublishProfile.setText("Get Publish Profile");
    btnGetPublishProfile.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_PRINT_EDIT));
    btnGetPublishProfile.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "btnGetPublishProfile", null) {

        @Override
        protected void handleEventFunc(Event event) {
            onBtnGetPublishProfileSelection();
        }
    });
    btnSave = new Button(cpControlButtons, SWT.NONE);
    btnSave.setText("Save");
    btnSave.setEnabled(false);
    btnSave.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_SAVE_EDIT));
    btnSave.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "btnSave", null) {

        @Override
        protected void handleEventFunc(Event event) {
            setBtnEnableStatus(false);
            webAppBasePropertyViewPresenter.onUpdateWebAppProperty(subscriptionId, webAppId, slotName, cachedAppSettings, editedAppSettings);
        }
    });
    btnDiscard = new Button(cpControlButtons, SWT.NONE);
    btnDiscard.setText("Discard");
    btnDiscard.setEnabled(false);
    btnDiscard.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE));
    btnDiscard.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "btnDiscard", null) {

        @Override
        protected void handleEventFunc(Event event) {
            updateMapStatus(editedAppSettings, cachedAppSettings);
            resetTblAppSettings(editedAppSettings);
        }
    });
    cpOverview = new Composite(composite, SWT.NONE);
    cpOverview.setLayout(new GridLayout(4, false));
    cpOverview.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label lblResourceGroup = new Label(cpOverview, SWT.NONE);
    lblResourceGroup.setText("Resource Group:");
    txtResourceGroup = new Text(cpOverview, SWT.NONE);
    txtResourceGroup.setEditable(false);
    txtResourceGroup.setText(TXT_LOADING);
    txtResourceGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label lblAppServicePlan = new Label(cpOverview, SWT.NONE);
    lblAppServicePlan.setText("App Service Plan:");
    txtAppServicePlan = new Text(cpOverview, SWT.NONE);
    txtAppServicePlan.setEditable(false);
    txtAppServicePlan.setText(TXT_LOADING);
    txtAppServicePlan.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label lblStatus = new Label(cpOverview, SWT.NONE);
    lblStatus.setText("Status:");
    txtStatus = new Text(cpOverview, SWT.NONE);
    txtStatus.setEditable(false);
    txtStatus.setText(TXT_LOADING);
    txtStatus.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label lblUrl = new Label(cpOverview, SWT.NONE);
    lblUrl.setText("URL:");
    lnkUrl = new Link(cpOverview, SWT.NONE);
    lnkUrl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    lnkUrl.setText(TXT_LOADING);
    // click to open browser
    lnkUrl.addListener(SWT.Selection, event -> Program.launch(event.text));
    Label lblLocation = new Label(cpOverview, SWT.NONE);
    lblLocation.setText("Location:");
    txtLocation = new Text(cpOverview, SWT.NONE);
    txtLocation.setEditable(false);
    txtLocation.setText(TXT_LOADING);
    txtLocation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label lblPricingTier = new Label(cpOverview, SWT.NONE);
    lblPricingTier.setText("Pricing Tier:");
    txtPricingTier = new Text(cpOverview, SWT.NONE);
    txtPricingTier.setEditable(false);
    txtPricingTier.setText(TXT_LOADING);
    txtPricingTier.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label lblSubscription = new Label(cpOverview, SWT.NONE);
    lblSubscription.setText("Subscription ID:");
    txtSubscription = new Text(cpOverview, SWT.NONE);
    txtSubscription.setEditable(false);
    txtSubscription.setText(TXT_LOADING);
    txtSubscription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    cpExtraInfo = new Composite(composite, SWT.NONE);
    cpExtraInfo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    cpExtraInfo.setLayout(new GridLayout(2, false));
    lblJavaVersion = new Label(cpExtraInfo, SWT.NONE);
    lblJavaVersion.setText("Java Version:");
    txtJavaVersion = new Text(cpExtraInfo, SWT.NONE);
    txtJavaVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtJavaVersion.setEditable(false);
    txtJavaVersion.setText(TXT_LOADING);
    lblContainer = new Label(cpExtraInfo, SWT.NONE);
    lblContainer.setText("Web Container:");
    txtContainer = new Text(cpExtraInfo, SWT.NONE);
    txtContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtContainer.setEditable(false);
    txtContainer.setText(TXT_LOADING);
    Composite cpAppSettings = new Composite(composite, SWT.NONE);
    cpAppSettings.setLayout(new GridLayout(2, false));
    cpAppSettings.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    tblAppSettings = new Table(cpAppSettings, SWT.BORDER | SWT.FULL_SELECTION);
    tblAppSettings.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    tblAppSettings.setHeaderVisible(true);
    tblAppSettings.setLinesVisible(true);
    tblAppSettings.addListener(SWT.MouseDoubleClick, event -> onTblAppSettingMouseDoubleClick(event));
    editor = new TableEditor(tblAppSettings);
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;
    TableColumn tblclmnKey = new TableColumn(tblAppSettings, SWT.NONE);
    tblclmnKey.setWidth(300);
    tblclmnKey.setText("Key");
    TableColumn tblclmnValue = new TableColumn(tblAppSettings, SWT.NONE);
    tblclmnValue.setWidth(300);
    tblclmnValue.setText("Value");
    Composite cpTableButtons = new Composite(cpAppSettings, SWT.NONE);
    cpTableButtons.setLayout(new GridLayout(1, false));
    cpTableButtons.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
    btnNewItem = new Button(cpTableButtons, SWT.NONE);
    btnNewItem.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnNewItem.setText("New");
    btnNewItem.setToolTipText("New");
    btnNewItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ADD));
    btnNewItem.setEnabled(false);
    btnNewItem.addListener(SWT.Selection, event -> onBtnNewItemSelection());
    btnDeleteItem = new Button(cpTableButtons, SWT.NONE);
    btnDeleteItem.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnDeleteItem.setText("Delete");
    btnDeleteItem.setToolTipText("Delete");
    btnDeleteItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE));
    btnDeleteItem.setEnabled(false);
    btnDeleteItem.addListener(SWT.Selection, event -> onBtnDeleteItemSelection());
    btnEditItem = new Button(cpTableButtons, SWT.NONE);
    btnEditItem.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnEditItem.setText("Edit");
    btnEditItem.setToolTipText("Edit");
    btnEditItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_CLEAR));
    btnEditItem.setEnabled(false);
    btnEditItem.addListener(SWT.Selection, event -> onBtnEditItemSelection());
    scrolledComposite.setContent(area);
    scrolledComposite.setMinSize(area.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    setExtraInfoVisible(false);
    setChildrenTransparent(cpOverview);
    setChildrenTransparent(cpExtraInfo);
    btnGetPublishProfile.setFocus();
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) TableEditor(org.eclipse.swt.custom.TableEditor) TableColumn(org.eclipse.swt.widgets.TableColumn) AzureListenerWrapper(com.microsoft.azuretools.core.components.AzureListenerWrapper) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Event(org.eclipse.swt.widgets.Event) ProgressBar(org.eclipse.swt.widgets.ProgressBar) Link(org.eclipse.swt.widgets.Link)

Aggregations

AzureListenerWrapper (com.microsoft.azuretools.core.components.AzureListenerWrapper)3 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Button (org.eclipse.swt.widgets.Button)3 Composite (org.eclipse.swt.widgets.Composite)3 Event (org.eclipse.swt.widgets.Event)3 Label (org.eclipse.swt.widgets.Label)3 ProgressBar (org.eclipse.swt.widgets.ProgressBar)3 Text (org.eclipse.swt.widgets.Text)3 SashForm (org.eclipse.swt.custom.SashForm)2 Link (org.eclipse.swt.widgets.Link)2 Table (org.eclipse.swt.widgets.Table)2 TableEditor (org.eclipse.swt.custom.TableEditor)1 Combo (org.eclipse.swt.widgets.Combo)1 List (org.eclipse.swt.widgets.List)1 Listener (org.eclipse.swt.widgets.Listener)1 Menu (org.eclipse.swt.widgets.Menu)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1 TableColumn (org.eclipse.swt.widgets.TableColumn)1