Search in sources :

Example 71 with MessageDialog

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

the class AzureDockerUIResources method deleteAzureDockerHostConfirmationDialog.

public static int deleteAzureDockerHostConfirmationDialog(Shell shell, Azure azureClient, DockerHost dockerHost) {
    String promptMessageDeleteAll = String.format("This operation will delete virtual machine %s and its resources:\n" + "\t - network interface: %s\n" + "\t - public IP: %s\n" + "\t - virtual network: %s\n" + "The associated disks and storage account will not be deleted\n", dockerHost.hostVM.name, dockerHost.hostVM.nicName, dockerHost.hostVM.publicIpName, dockerHost.hostVM.vnetName);
    String promptMessageDelete = String.format("This operation will delete virtual machine %s.\n" + "The associated disks and storage account will not be deleted\n\n" + "Are you sure you want to continue?\n", dockerHost.hostVM.name);
    String[] options;
    String promptMessage;
    if (AzureDockerVMOps.isDeletingDockerHostAllSafe(azureClient, dockerHost.hostVM.resourceGroupName, dockerHost.hostVM.name)) {
        promptMessage = promptMessageDeleteAll;
        options = new String[] { "Cancel", "Delete VM Only", "Delete All" };
    } else {
        promptMessage = promptMessageDelete;
        options = new String[] { "Cancel", "Delete" };
    }
    MessageDialog deleteDialog = new MessageDialog(shell, "Delete Docker Host", null, promptMessage, MessageDialog.ERROR, options, 0);
    int dialogReturn = deleteDialog.open();
    switch(dialogReturn) {
        case 0:
            if (AzureDockerUtils.DEBUG)
                System.out.format("Delete Docker Host op was canceled %s\n", dialogReturn);
            break;
        case 1:
            if (AzureDockerUtils.DEBUG)
                System.out.println("Delete VM only: " + dockerHost.name);
            break;
        case 2:
            if (AzureDockerUtils.DEBUG)
                System.out.println("Delete VM and resources: " + dockerHost.name);
            break;
        default:
            if (AzureDockerUtils.DEBUG)
                System.out.format("Delete Docker Host op was canceled %s\n", dialogReturn);
    }
    return dialogReturn;
}
Also used : MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 72 with MessageDialog

use of org.eclipse.jface.dialogs.MessageDialog in project tdi-studio-se by Talend.

the class ComponentProjectPreferencePage method propertyChange.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.eclipse.jface.preference.FieldEditorPreferencePage#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
     */
public void propertyChange(PropertyChangeEvent event) {
    super.propertyChange(event);
    MessageDialog warningMessageDialog = new MessageDialog(getFieldEditorParent().getShell(), //$NON-NLS-1$
    Messages.getString("ComponentProjectPreferencePage.Warning"), //$NON-NLS-1$
    null, //$NON-NLS-1$
    Messages.getString("ComponentProjectPreferencePage.WarningMSG"), //$NON-NLS-1$
    MessageDialog.WARNING, new String[] { Messages.getString("ComponentProjectPreferencePage.ButtonLabel0") }, //$NON-NLS-1$
    0);
    warningMessageDialog.open();
}
Also used : MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 73 with MessageDialog

use of org.eclipse.jface.dialogs.MessageDialog in project tdi-studio-se by Talend.

the class ImportDemoProjectItemsPage method performFinish.

public boolean performFinish() {
    List<DemoProjectBean> checkedElements = getCheckedElements();
    final List<ResourcesManager> finalCheckManagers = getResourceManagers(checkedElements);
    String warnMessage = populateExistItemRecords(finalCheckManagers);
    if (!warnMessage.equals("")) {
        MessageDialog dialog = new MessageDialog(getShell(), Messages.getString("ImportDemoProjectPage.overwrite"), null, warnMessage, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
        dialog.open();
        int result = dialog.getReturnCode();
        if (result != MessageDialog.OK) {
            return false;
        }
    }
    ProgressDialog progressDialog = new ProgressDialog(getShell()) {

        private IProgressMonitor monitorWrap;

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            monitorWrap = new EventLoopProgressMonitor(monitor);
            try {
                for (ResourcesManager resManager : finalCheckManagers) {
                    List<ImportItem> projectRecords = importManager.populateImportingItems(resManager, true, monitorWrap);
                    // clearOverWriteErrorMessages(projectRecords, overwrite);
                    importManager.importItemRecords(monitorWrap, resManager, projectRecords, true, projectRecords.toArray(new ImportItem[0]), null);
                }
            } catch (Exception e) {
                ExceptionHandler.process(e);
            }
            monitorWrap.done();
            if (monitor.isCanceled()) {
                MessageDialog.openInformation(getShell(), Messages.getString("ImportDemoProjectAction.messageDialogTitle.demoProjectCancel"), Messages.getString("ImportDemoProjectAction.messageDialogContent.demoProjectImportedIncompletely"));
                return;
            } else {
                MessageDialog.openInformation(getShell(), //$NON-NLS-1$
                Messages.getString("ImportDemoProjectAction.messageDialogTitle.demoProject"), //$NON-NLS-1$
                Messages.getString("ImportDemoProjectAction.messageDialogContent.demoProjectImportedSuccessfully"));
            }
        }
    };
    try {
        progressDialog.executeProcess();
    } catch (InvocationTargetException e) {
        MessageBoxExceptionHandler.process(e.getTargetException(), getShell());
    } catch (InterruptedException e) {
    // Nothing to do
    }
    return true;
}
Also used : ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) EventLoopProgressMonitor(org.talend.commons.ui.swt.dialogs.EventLoopProgressMonitor) ProgressDialog(org.talend.commons.ui.swt.dialogs.ProgressDialog) ZipException(java.util.zip.ZipException) FileNotFoundException(java.io.FileNotFoundException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TarException(org.eclipse.ui.internal.wizards.datatransfer.TarException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ResourcesManager(org.talend.repository.items.importexport.manager.ResourcesManager) MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 74 with MessageDialog

use of org.eclipse.jface.dialogs.MessageDialog in project tdi-studio-se by Talend.

the class PaletteSettingPage method setComponentVisible.

/**
     * set the selected component as visible or not
     * 
     * @param selection
     * @param b
     */
protected void setComponentVisible(ISelection selection, boolean visible) {
    IStructuredSelection sel = (IStructuredSelection) selection;
    Set<IPaletteItem> items = new HashSet<IPaletteItem>();
    for (Iterator iterator = sel.iterator(); iterator.hasNext(); ) {
        IPaletteItem entry = (IPaletteItem) iterator.next();
        retrieveAllEntry(items, entry);
    }
    Set<IComponent> usedComponents = getComponentsUsedInProject(ProjectManager.getInstance().getCurrentProject());
    boolean isUsed = false;
    for (IPaletteItem item : items) {
        if (!visible && item instanceof ComponentPaletteItem) {
            if (usedComponents.contains(((ComponentPaletteItem) item).getComponent())) {
                isUsed = true;
                continue;
            }
        }
        setComponentVisible(item, visible);
    }
    if (isUsed) {
        MessageDialog messageDialog = new MessageDialog(getShell(), //$NON-NLS-1$
        Messages.getString("PaletteSettingPage.paletteSettings"), //$NON-NLS-1$
        null, //$NON-NLS-1$ //$NON-NLS-2$
        Messages.getString("PaletteSettingPage.selection1") + "\n" + //$NON-NLS-1$
        Messages.getString("PaletteSettingPage.selection2"), //$NON-NLS-1$
        MessageDialog.INFORMATION, new String[] { "OK" }, //$NON-NLS-1$
        0);
        messageDialog.open();
    }
    refreshViewer();
}
Also used : ComponentPaletteItem(org.talend.repository.preference.palettesettings.ComponentPaletteItem) IPaletteItem(org.talend.core.ui.component.preference.provider.IPaletteItem) IComponent(org.talend.core.model.components.IComponent) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) HashSet(java.util.HashSet)

Example 75 with MessageDialog

use of org.eclipse.jface.dialogs.MessageDialog in project tdi-studio-se by Talend.

the class EditQueriesAction method doRun.

@Override
protected void doRun() {
    IStructuredSelection selection = (IStructuredSelection) getSelection();
    if (repositoryNode == null && selection != null) {
        repositoryNode = (RepositoryNode) selection.getFirstElement();
    }
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    IRepositoryViewObject nodeObject = repositoryNode.getObject();
    boolean locked = false;
    if (!factory.getRepositoryContext().isEditableAsReadOnly()) {
        if (nodeObject.getRepositoryStatus() == ERepositoryStatus.LOCK_BY_OTHER) {
            locked = true;
        }
    }
    // Avoid to delete node which is locked.
    if (locked || RepositoryManager.isOpenedItemInEditor(nodeObject)) {
        final String title = "Impossible to edit queries";
        String nodeName = nodeObject.getRepositoryObjectType().getLabel();
        final String message = "item is already locked by another user.";
        Display.getDefault().syncExec(new Runnable() {

            @Override
            public void run() {
                MessageDialog dialog = new MessageDialog(new Shell(), title, null, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0);
                dialog.open();
            }
        });
        return;
    }
    DatabaseConnectionItem dbConnectionItem = null;
    boolean readOnly = false;
    ConnectionParameters connParameters = new ConnectionParameters();
    if (repositoryNode.getObjectType() == ERepositoryObjectType.METADATA_CONNECTIONS) {
        dbConnectionItem = (DatabaseConnectionItem) repositoryNode.getObject().getProperty().getItem();
        connParameters.setRepositoryName(repositoryNode.getObject().getLabel());
        connParameters.setRepositoryId(repositoryNode.getObject().getId());
        //$NON-NLS-1$
        connParameters.setQuery("");
    } else if (repositoryNode.getObjectType() == ERepositoryObjectType.METADATA_CON_QUERY) {
        QueryRepositoryObject queryRepositoryObject = (QueryRepositoryObject) repositoryNode.getObject();
        readOnly = SubItemHelper.isDeleted(queryRepositoryObject.getAbstractMetadataObject());
        dbConnectionItem = (DatabaseConnectionItem) queryRepositoryObject.getProperty().getItem();
        connParameters.setRepositoryName(dbConnectionItem.getProperty().getLabel());
        connParameters.setRepositoryId(dbConnectionItem.getProperty().getId());
        connParameters.setQueryObject(queryRepositoryObject.getQuery());
        connParameters.setQuery(queryRepositoryObject.getQuery().getValue());
        // first open Sql Builder,set true
        connParameters.setFirstOpenSqlBuilder(true);
    } else if (repositoryNode.getObjectType() == ERepositoryObjectType.METADATA_CON_TABLE) {
        dbConnectionItem = (DatabaseConnectionItem) repositoryNode.getObject().getProperty().getItem();
        connParameters.setRepositoryName(dbConnectionItem.getProperty().getLabel());
        connParameters.setRepositoryId(dbConnectionItem.getProperty().getId());
        connParameters.setMetadataTable((MetadataTableRepositoryObject) repositoryNode.getObject());
        //$NON-NLS-1$
        connParameters.setQuery("");
    }
    IRepositoryView viewPart = getViewPart();
    Display display = null;
    if (viewPart != null) {
        display = viewPart.getViewer().getControl().getDisplay();
    } else {
        display = Display.getCurrent();
        if (display == null) {
            display = Display.getDefault();
        }
    }
    Shell parentShell = new Shell(display);
    TextUtil.setDialogTitle(TextUtil.SQL_BUILDER_TITLE_REP);
    Connection connection = dbConnectionItem.getConnection();
    String selectedContext = null;
    if (connection.isContextMode()) {
        ContextItem contextItem = ContextUtils.getContextItemById2(connection.getContextId());
        if (contextItem != null && connection.isContextMode()) {
            ContextSetsSelectionDialog setsDialog = new ContextSetsSelectionDialog(null, contextItem, false);
            setsDialog.open();
            selectedContext = setsDialog.getSelectedContext();
        }
    }
    SQLBuilderDialog dial = new SQLBuilderDialog(parentShell, repositoryNode, selectedContext);
    dial.setReadOnly(readOnly);
    if (connection instanceof DatabaseConnection) {
        IMetadataConnection imetadataConnection = ConvertionHelper.convert(connection, true);
        connParameters.setSchema(imetadataConnection.getSchema() == null ? "" : imetadataConnection.getSchema());
        UIUtils.checkConnection(parentShell, imetadataConnection);
    }
    connParameters.setNodeReadOnly(readOnly);
    connParameters.setFromRepository(true);
    dial.setConnParameters(connParameters);
    dial.open();
    IRepositoryView view = getViewPart();
    if (view != null) {
        view.refreshView();
    }
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) ConnectionParameters(org.talend.core.sqlbuilder.util.ConnectionParameters) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IRepositoryView(org.talend.repository.ui.views.IRepositoryView) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) Shell(org.eclipse.swt.widgets.Shell) QueryRepositoryObject(org.talend.core.repository.model.repositoryObject.QueryRepositoryObject) ContextSetsSelectionDialog(org.talend.metadata.managment.ui.wizard.metadata.ContextSetsSelectionDialog) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) SQLBuilderDialog(org.talend.sqlbuilder.ui.SQLBuilderDialog) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) Display(org.eclipse.swt.widgets.Display)

Aggregations

MessageDialog (org.eclipse.jface.dialogs.MessageDialog)129 Shell (org.eclipse.swt.widgets.Shell)27 CoreException (org.eclipse.core.runtime.CoreException)16 IPath (org.eclipse.core.runtime.IPath)14 File (java.io.File)10 ArrayList (java.util.ArrayList)10 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)10 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 Composite (org.eclipse.swt.widgets.Composite)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 Point (org.eclipse.swt.graphics.Point)7 IOException (java.io.IOException)6 IFile (org.eclipse.core.resources.IFile)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 List (java.util.List)5 IStatus (org.eclipse.core.runtime.IStatus)5 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)5 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)5 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)4 Path (org.eclipse.core.runtime.Path)4