Search in sources :

Example 56 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project cubrid-manager by CUBRID.

the class OpenTriggerDetailInfoPartProgress method loadTriggerInfoList.

/**
	 * load trigger info list
	 * 
	 * @return Catalog
	 */
public void loadTriggerInfoList() {
    Display display = Display.getDefault();
    display.syncExec(new Runnable() {

        public void run() {
            try {
                new ProgressMonitorDialog(null).run(true, false, OpenTriggerDetailInfoPartProgress.this);
            } catch (Exception e) {
                LOGGER.error(e.getMessage(), e);
            }
        }
    });
}
Also used : ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) Display(org.eclipse.swt.widgets.Display)

Example 57 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project azure-tools-for-java by Microsoft.

the class AzureDockerUIResources method updateAzureResourcesWithProgressDialog.

public static void updateAzureResourcesWithProgressDialog(Shell shell, IProject project) {
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
    try {
        dialog.run(true, true, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) {
                monitor.beginTask("Loading Azure Resources", 100);
                try {
                    monitor.subTask("Creating an Azure instance...");
                    AzureManager azureAuthManager = AuthMethodManager.getInstance().getAzureManager();
                    if (monitor.isCanceled()) {
                        monitor.done();
                        return;
                    }
                    // not signed in
                    if (azureAuthManager == null) {
                        monitor.done();
                        return;
                    }
                    AzureDockerHostsManager dockerManager = AzureDockerHostsManager.getAzureDockerHostsManagerEmpty(azureAuthManager);
                    monitor.worked(10);
                    monitor.subTask("Retrieving the subscription details...");
                    dockerManager.refreshDockerSubscriptions();
                    if (monitor.isCanceled()) {
                        monitor.done();
                        return;
                    }
                    monitor.worked(10);
                    monitor.subTask("Retrieving the key vault...");
                    dockerManager.refreshDockerVaults();
                    monitor.worked(10);
                    if (monitor.isCanceled()) {
                        monitor.done();
                        return;
                    }
                    monitor.worked(10);
                    monitor.subTask("Retrieving the key vault details...");
                    dockerManager.refreshDockerVaultDetails();
                    if (monitor.isCanceled()) {
                        CANCELED = true;
                        monitor.done();
                        return;
                    }
                    monitor.worked(10);
                    monitor.subTask("Retrieving the network details...");
                    dockerManager.refreshDockerVnetDetails();
                    if (monitor.isCanceled()) {
                        monitor.done();
                        return;
                    }
                    monitor.worked(10);
                    monitor.subTask("Retrieving the storage account details...");
                    dockerManager.refreshDockerStorageAccountDetails();
                    if (monitor.isCanceled()) {
                        monitor.done();
                        return;
                    }
                    monitor.subTask("Retrieving the Docker virtual machines details...");
                    dockerManager.refreshDockerHostDetails();
                    CANCELED = false;
                } catch (Exception e) {
                    CANCELED = true;
                    log.log(Level.SEVERE, "updateAzureResourcesWithProgressDialog: " + e.getMessage(), e);
                    e.printStackTrace();
                }
                monitor.done();
            }
        });
    } catch (Exception e) {
        CANCELED = true;
        log.log(Level.SEVERE, "updateAzureResourcesWithProgressDialog: " + e.getMessage(), e);
        e.printStackTrace();
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) AzureDockerHostsManager(com.microsoft.azure.docker.AzureDockerHostsManager) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 58 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project azure-tools-for-java by Microsoft.

the class SignInDialog method signInAsync.

private void signInAsync() throws InvocationTargetException, InterruptedException {
    IRunnableWithProgress op = new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            monitor.beginTask("Signing In...", IProgressMonitor.UNKNOWN);
            try {
                AdAuthManager.getInstance().signIn();
            } catch (AuthCanceledException ex) {
                System.out.println(ex.getMessage());
            } catch (IOException ex) {
                System.out.println("run@ProgressDialog@signInAsync@SingInDialog: " + ex.getMessage());
                //ex.printStackTrace();
                //LOG.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "run@ProgressDialog@signInAsync@SingInDialog", e));
                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        ErrorWindow.go(getShell(), ex.getMessage(), "Sign In Error");
                        ;
                    }
                });
            }
        }
    };
    new ProgressMonitorDialog(this.getShell()).run(true, false, op);
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) AuthCanceledException(com.microsoft.azuretools.adauth.AuthCanceledException) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IOException(java.io.IOException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 59 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project azure-tools-for-java by Microsoft.

the class SignInDialog method doCreateServicePrincipal.

private void doCreateServicePrincipal() {
    setErrorMessage(null);
    AdAuthManager adAuthManager = null;
    try {
        adAuthManager = AdAuthManager.getInstance();
        if (adAuthManager.isSignedIn()) {
            adAuthManager.signOut();
        }
        signInAsync();
        if (!adAuthManager.isSignedIn()) {
            // canceled by the user
            System.out.println(">> Canceled by the user");
            return;
        }
        AccessTokenAzureManager accessTokenAzureManager = new AccessTokenAzureManager();
        SubscriptionManager subscriptionManager = accessTokenAzureManager.getSubscriptionManager();
        IRunnableWithProgress op = new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask("Getting Subscription List...", IProgressMonitor.UNKNOWN);
                try {
                    subscriptionManager.getSubscriptionDetails();
                } catch (Exception ex) {
                    System.out.println("run@ProgressDialog@doCreateServicePrincipal@SignInDialog: " + ex.getMessage());
                    LOG.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "run@ProgressDialog@doCreateServicePrincipal@SignInDialogg", ex));
                }
            }
        };
        new ProgressMonitorDialog(this.getShell()).run(true, false, op);
        SrvPriSettingsDialog d = SrvPriSettingsDialog.go(this.getShell(), subscriptionManager.getSubscriptionDetails());
        List<SubscriptionDetail> subscriptionDetailsUpdated;
        String destinationFolder;
        if (d != null) {
            subscriptionDetailsUpdated = d.getSubscriptionDetails();
            destinationFolder = d.getDestinationFolder();
        } else {
            System.out.println(">> Canceled by the user");
            return;
        }
        Map<String, List<String>> tidSidsMap = new HashMap<>();
        for (SubscriptionDetail sd : subscriptionDetailsUpdated) {
            if (sd.isSelected()) {
                System.out.format(">> %s\n", sd.getSubscriptionName());
                String tid = sd.getTenantId();
                List<String> sidList;
                if (!tidSidsMap.containsKey(tid)) {
                    sidList = new LinkedList<>();
                } else {
                    sidList = tidSidsMap.get(tid);
                }
                sidList.add(sd.getSubscriptionId());
                tidSidsMap.put(tid, sidList);
            }
        }
        SrvPriCreationStatusDialog d1 = SrvPriCreationStatusDialog.go(this.getShell(), tidSidsMap, destinationFolder);
        if (d1 == null) {
            System.out.println(">> Canceled by the user");
            return;
        }
        String path = d1.getSelectedAuthFilePath();
        if (path == null) {
            System.out.println(">> No file was created");
            return;
        }
        textAuthenticationFilePath.setText(path);
        fileDialog.setFilterPath(destinationFolder);
    } catch (Exception ex) {
        ex.printStackTrace();
        LOG.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "doCreateServicePrincipal@SignInDialog", ex));
    } finally {
        if (adAuthManager != null) {
            adAuthManager.signOut();
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) HashMap(java.util.HashMap) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) AccessTokenAzureManager(com.microsoft.azuretools.sdkmanage.AccessTokenAzureManager) AdAuthManager(com.microsoft.azuretools.authmanage.AdAuthManager) SubscriptionManager(com.microsoft.azuretools.authmanage.SubscriptionManager) PartInitException(org.eclipse.ui.PartInitException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) AuthCanceledException(com.microsoft.azuretools.adauth.AuthCanceledException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) LinkedList(java.util.LinkedList) List(java.util.List)

Example 60 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project cubrid-manager by CUBRID.

the class UnifyHostConfigEditor method registerCubridBrokerTableContextMenu.

/**
	 * register CubridConfTable context menu
	 */
private void registerCubridBrokerTableContextMenu() {
    brokerConfTabTableViewer.getTable().addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent event) {
            ActionManager.getInstance().changeFocusProvider(brokerConfTabTableViewer.getTable());
        }
    });
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    Menu contextMenu = menuManager.createContextMenu(brokerConfTabTableViewer.getTable());
    brokerConfTabTableViewer.getTable().setMenu(contextMenu);
    Menu menu = new Menu(this.getSite().getShell(), SWT.POP_UP);
    final MenuItem itemEditAnnotation = new MenuItem(menu, SWT.PUSH);
    itemEditAnnotation.setText(Messages.confEditorTableMenuEditAnnotation);
    itemEditAnnotation.addSelectionListener(new SelectionAdapter() {

        @SuppressWarnings("all")
        public void widgetSelected(SelectionEvent event) {
            //seems like MenuEvent can't get the mouse click Point
            //so use the point which table MouseDown event marked 
            Point pt = cubridBrokerTableClickPoint;
            int selectIndex = brokerConfTabTableViewer.getTable().getSelectionIndex();
            final TableItem item = brokerConfTabTableViewer.getTable().getItem(selectIndex);
            if (item == null) {
                return;
            }
            for (int i = 0; i < brokerConfTabTableViewer.getTable().getColumnCount(); i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {
                    if (i == 0) {
                        CommonUITool.openErrorBox(getSite().getShell(), Messages.annotationDialogOpenErrorMsg);
                        return;
                    }
                    IStructuredSelection selection = (IStructuredSelection) brokerConfTabTableViewer.getSelection();
                    HashMap<String, String> valueMap = (HashMap<String, String>) selection.getFirstElement();
                    String serverName = cubridBrokerConfListData.get(0).get(i + "");
                    String parentPropertyKey = valueMap.get("0");
                    String parentKey = " ";
                    Map<String, String> brokerMap = cubridBrokerConfListData.get(1);
                    String brokerName = "";
                    if (brokerMap != null) {
                        brokerName = brokerMap.get(i + "");
                    }
                    if (selectIndex == 0) {
                        parentKey += serverName;
                    } else {
                        if (selectIndex == 1) {
                            parentKey += serverName + "->" + brokerName;
                        } else {
                            parentKey += serverName + "->" + brokerName + "->" + parentPropertyKey;
                        }
                    }
                    String annotationKey = Integer.toString(i) + BrokerConfPersistUtil.ANNOTATION;
                    CubridBrokerConfEditAnnotationDialog dialog = new CubridBrokerConfEditAnnotationDialog(getSite().getShell(), parentKey, annotationKey, valueMap);
                    if (IDialogConstants.OK_ID == dialog.open()) {
                        setDirty(true);
                    }
                }
            }
        }
    });
    final MenuItem itemAddBrokerConf = new MenuItem(menu, SWT.PUSH);
    itemAddBrokerConf.setText(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorAddBrokerConfItemLabel);
    itemAddBrokerConf.setImage(CommonUIPlugin.getImage("icons/action/column_insert.png"));
    itemAddBrokerConf.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            try {
                ProgressMonitorDialog progress = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
                progress.setCancelable(true);
                progress.run(true, true, new IRunnableWithProgress() {

                    public void run(final IProgressMonitor monitor) throws InvocationTargetException {
                        Display.getDefault().asyncExec(new Runnable() {

                            public void run() {
                                //									int horizontalSelectionInt = brokerConfTabTableViewer.getTable().getHorizontalBar().getSize().y - 
                                //									brokerConfTabTableViewer.getTable().getHorizontalBar().getSelection();
                                //									 = brokerConfTabTableViewer.getTable().getHorizontalBar().getSelection();
                                monitor.beginTask(Messages.unifyHostConfigEditorAddColumnMsg, 1);
                                addBrokerConfColumn();
                                monitor.worked(1);
                            //									horizontalSelectionInt = brokerConfTabTableViewer.getTable().getHorizontalBar().getSize().y - horizontalSelectionInt;
                            //									brokerConfTabTableViewer.getTable().getHorizontalBar().setSelection(horizontalSelectionInt + 160);
                            }
                        });
                    }
                });
            } catch (Exception e) {
                LOGGER.error("", e);
            }
            setDirty(true);
        }
    });
    final MenuItem itemDeleteBrokerConf = new MenuItem(menu, SWT.PUSH);
    itemDeleteBrokerConf.setText(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorDeleteBrokerConfItemLabel);
    itemDeleteBrokerConf.setImage(CommonUIPlugin.getImage("icons/action/column_delete.png"));
    itemDeleteBrokerConf.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            try {
                ProgressMonitorDialog progress = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
                progress.setCancelable(true);
                progress.run(true, true, new IRunnableWithProgress() {

                    public void run(final IProgressMonitor monitor) throws InvocationTargetException {
                        Display.getDefault().asyncExec(new Runnable() {

                            public void run() {
                                //									int horizontalSelectionInt = brokerConfTabTableViewer.getTable().getHorizontalBar().getSize().y - 
                                //									brokerConfTabTableViewer.getTable().getHorizontalBar().getSelection();
                                //									 = brokerConfTabTableViewer.getTable().getHorizontalBar().getSelection();
                                monitor.beginTask(Messages.unifyHostConfigEditorDelColumnMsg, 1);
                                delBrokerConfColumn();
                                monitor.worked(1);
                            //									horizontalSelectionInt = brokerConfTabTableViewer.getTable().getHorizontalBar().getSize().y - horizontalSelectionInt;
                            //									brokerConfTabTableViewer.getTable().getHorizontalBar().setSelection(horizontalSelectionInt + 160);
                            }
                        });
                    }
                });
            } catch (Exception e) {
                LOGGER.error("", e);
            }
            setDirty(true);
        }
    });
    menu.addMenuListener(new MenuAdapter() {

        public void menuShown(MenuEvent event) {
            //seems like MenuEvent can't get the mouse click Point
            //so use the point which table MouseDown event marked 
            Point pt = cubridBrokerTableClickPoint;
            // click timing
            if (System.currentTimeMillis() - cubridBrokerTableClickPointTiming > 300) {
                itemEditAnnotation.setEnabled(false);
                itemDeleteBrokerConf.setEnabled(false);
                itemAddBrokerConf.setEnabled(false);
                return;
            }
            int selectIndex = brokerConfTabTableViewer.getTable().getSelectionIndex();
            if (selectIndex == -1) {
                itemEditAnnotation.setEnabled(false);
                itemDeleteBrokerConf.setEnabled(false);
                itemAddBrokerConf.setEnabled(false);
                return;
            }
            if (selectIndex == 0) {
                itemEditAnnotation.setEnabled(false);
                itemDeleteBrokerConf.setEnabled(false);
                itemAddBrokerConf.setEnabled(true);
                return;
            }
            final TableItem item = brokerConfTabTableViewer.getTable().getItem(selectIndex);
            if (item == null) {
                return;
            }
            for (int i = 0; i < brokerConfTabTableViewer.getTable().getColumnCount(); i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {
                    if (i == 0) {
                        itemEditAnnotation.setEnabled(false);
                        itemDeleteBrokerConf.setEnabled(false);
                    } else {
                        itemEditAnnotation.setEnabled(true);
                        itemDeleteBrokerConf.setEnabled(true);
                    }
                }
            }
            itemAddBrokerConf.setEnabled(true);
        }
    });
    brokerConfTabTableViewer.getTable().setMenu(menu);
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) Rectangle(org.eclipse.swt.graphics.Rectangle) CubridBrokerConfEditAnnotationDialog(com.cubrid.common.ui.common.dialog.CubridBrokerConfEditAnnotationDialog) MenuAdapter(org.eclipse.swt.events.MenuAdapter) MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) FocusEvent(org.eclipse.swt.events.FocusEvent) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MenuManager(org.eclipse.jface.action.MenuManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) MenuEvent(org.eclipse.swt.events.MenuEvent)

Aggregations

ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)88 InvocationTargetException (java.lang.reflect.InvocationTargetException)81 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)74 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)74 ArrayList (java.util.ArrayList)27 Display (org.eclipse.swt.widgets.Display)22 CoreException (org.eclipse.core.runtime.CoreException)17 PersistenceException (org.talend.commons.exception.PersistenceException)17 List (java.util.List)15 Shell (org.eclipse.swt.widgets.Shell)12 PartInitException (org.eclipse.ui.PartInitException)12 IFile (org.eclipse.core.resources.IFile)11 SQLException (java.sql.SQLException)10 IOException (java.io.IOException)9 HashMap (java.util.HashMap)9 SocketTask (com.cubrid.cubridmanager.core.common.socket.SocketTask)8 File (java.io.File)8 Item (org.talend.core.model.properties.Item)8 IProject (org.eclipse.core.resources.IProject)7 TableItem (org.eclipse.swt.widgets.TableItem)7