Example usage for org.eclipse.jface.dialogs MessageDialog openConfirm

List of usage examples for org.eclipse.jface.dialogs MessageDialog openConfirm

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog openConfirm.

Prototype

public static boolean openConfirm(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a simple confirm (OK/Cancel) dialog.

Usage

From source file:com.predic8.plugin.membrane.dialogs.AbstractRuleViewer.java

License:Apache License

protected boolean openConfirmDialog(String msg) {
    return MessageDialog.openConfirm(this.getShell(), "Confirm", msg);
}

From source file:com.puppetlabs.geppetto.puppetdb.ui.views.PuppetResourceEventsView.java

License:Open Source License

private void removeClient(PuppetDBConnection client) {
    final PuppetDBConnectionPreferences prefs = client.getPreferences();
    Shell shell = viewer.getControl().getShell();
    if (MessageDialog.openConfirm(shell, UIPlugin.getLocalString("_UI_Confirm_Removal"),
            UIPlugin.getLocalString("_UI_Is_remove_of_client_ok", prefs.getIdentifier()))) {
        Util.alterPreferences(shell, puppetDBManager, new Callable<Void>() {
            @Override/*from  w w w  .  jav  a  2 s  .  com*/
            public Void call() throws Exception {
                prefs.remove();
                return null;
            }
        });
        viewer.setInput(getPuppetDBConnections(viewer, puppetDBManager));
    }
}

From source file:com.puppetlabs.geppetto.ui.wizard.AbstractPuppetProjectWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    try {/*ww  w .  j  a  va2  s . c om*/
        project = null;
        getContainer().run(false, false, new WorkspaceModifyOperation() {

            @Override
            protected void execute(IProgressMonitor progressMonitor) throws InvocationTargetException {
                SubMonitor monitor = SubMonitor.convert(progressMonitor, 100);
                try {
                    String projectName = projectContainer.segment(0);
                    if (projectLocation == null)
                        projectLocation = ResourcesPlugin.getWorkspace().getRoot().getLocation()
                                .append(projectName);
                    File projectDir = projectLocation.toFile();
                    if (projectDir.exists() && !mayHaveExistingContents()) {
                        if (!MessageDialog.openConfirm(getShell(),
                                UIPlugin.getLocalString("_UI_Confirm_Overwrite"), UIPlugin.getLocalString(
                                        "_UI_Directory_not_empty", projectDir.getAbsolutePath())))
                            // User don't want us to overwrite
                            return;

                        FileUtils.rmR(projectDir);
                    }

                    project = ResourceUtil.createProject(projectContainer,
                            URI.createFileURI(projectDir.getAbsolutePath()), Collections.<IProject>emptyList(),
                            monitor.newChild(1));

                    initializeProjectContents(monitor.newChild(80));
                } catch (Exception exception) {
                    throw new InvocationTargetException(exception);
                } finally {
                    progressMonitor.done();
                }
            }
        });
        return project != null;
    } catch (InvocationTargetException e) {
        Throwable t = e.getTargetException();
        String title = UIPlugin.getLocalString("_UI_CreateProject_title");
        if (t instanceof PartInitException)
            DialogUtil.openError(getShell(), title, t.getMessage(), (PartInitException) t);
        else if (t instanceof CoreException)
            ErrorDialog.openError(getShell(), title, t.getMessage(), ((CoreException) t).getStatus());
        else
            MessageDialog.openError(getShell(), title, t.getMessage());
    } catch (InterruptedException e) {
    }
    return false;
}

From source file:com.puppetlabs.geppetto.ui.wizard.NewPuppetModuleProjectWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    try {//from w  w  w.  ja  v  a  2 s .co m
        project = null;
        getContainer().run(false, false, new WorkspaceModifyOperation() {

            @Override
            protected void execute(IProgressMonitor progressMonitor) throws InvocationTargetException {
                SubMonitor monitor = SubMonitor.convert(progressMonitor, 100);
                try {
                    String projectName = projectContainer.segment(0);
                    if (projectLocation == null)
                        projectLocation = ResourcesPlugin.getWorkspace().getRoot().getLocation()
                                .append(projectName);
                    File projectDir = projectLocation.toFile();
                    if (projectDir.exists()) {
                        if (!MessageDialog.openConfirm(getShell(),
                                UIPlugin.getLocalString("_UI_Confirm_Overwrite"), UIPlugin.getLocalString(
                                        "_UI_Directory_not_empty", projectDir.getAbsolutePath())))
                            // User don't want us to overwrite
                            return;

                        FileUtils.rmR(projectDir);
                    }

                    project = ResourceUtil.createProject(projectContainer,
                            URI.createFileURI(projectDir.getAbsolutePath()), Collections.<IProject>emptyList(),
                            monitor.newChild(1));

                    initializeProjectContents(monitor.newChild(80));
                    pptpHandler.ensureStateOfPuppetProjects(monitor.newChild(10));

                    IFile modulefile = ResourceUtil.getFile(project.getFullPath().append(MODULEFILE_NAME)); //$NON-NLS-1$
                    if (modulefile.exists()) {
                        NewModulefileWizard.ensureMetadataJSONExists(modulefile, monitor.newChild(1));
                        ResourceUtil.selectFile(modulefile);

                        try {
                            ResourceUtil.openEditor(modulefile);
                        } catch (PartInitException partInitException) {
                            MessageDialog.openError(getShell(), UIPlugin.getLocalString("_UI_OpenEditor_title"), //$NON-NLS-1$
                                    partInitException.getMessage());
                        }
                    }
                } catch (Exception exception) {
                    throw new InvocationTargetException(exception);
                } finally {
                    progressMonitor.done();
                }
            }
        });
        if (project == null)
            return false;

        new PPBuildJob(project.getWorkspace(), true).schedule(1000);
        return true;
    } catch (InvocationTargetException e) {
        Throwable t = e.getTargetException();
        String title = UIPlugin.getLocalString("_UI_CreateProject_title");
        if (t instanceof PartInitException)
            DialogUtil.openError(getShell(), title, t.getMessage(), (PartInitException) t);
        else if (t instanceof CoreException)
            ErrorDialog.openError(getShell(), title, t.getMessage(), ((CoreException) t).getStatus());
        else
            MessageDialog.openError(getShell(), title, t.getMessage());
    } catch (InterruptedException e) {
    }
    return false;
}

From source file:com.quantcomponents.ui.marketdata.NewHistoricalData.java

License:Open Source License

@Override
public boolean performFinish() {
    boolean realtimeUpdate = page3.isRealtimeUpdate();
    final StockDatabasePresentationWrapper stockDatabase = marketDataManager.createStockDatabase(
            page2.getSelectedContract(), page3.getDataType(), page3.getBarSize(), page3.isAfterHoursIncluded(),
            page3.getTimeZone());//www .j a v  a2  s .c o m
    try {
        TimePeriod period = new TimePeriod(page3.getPeriodUnit(), page3.getPeriodAmount());
        endDateTime = null;
        if (realtimeUpdate) {
            endDateTime = new Date();
        } else {
            endDateTime = page3.getEndDate();
        }
        startDateTime = TimePeriod.subtractPeriodFromDate(endDateTime, period);
        retrieveHistoricalData(stockDatabase, startDateTime, endDateTime);
    } catch (InvocationTargetException e) {
        if (!MessageDialog.openConfirm(this.getShell(), "Historical data error",
                "Server error while retrieving historical data [" + e.getCause().getMessage()
                        + "]\nContinue?")) {
            return false;
        }
    } catch (InterruptedException e) {
        displayErrorMessage("Historical data error", "Task interrupted while retrieving historical data",
                e.getMessage());
        return false;
    }
    try {
        if (realtimeUpdate) {
            startAutoUpdate(stockDatabase);
        }
        IBaseLabelProvider labelDecorator = PlatformUI.getWorkbench().getDecoratorManager()
                .getBaseLabelProvider(AutoUpdateIconDecorator.DECORATOR_ID);
        if (labelDecorator != null) { // it is enabled
            AutoUpdateIconDecorator autoUpdateIconDecorator = (AutoUpdateIconDecorator) labelDecorator;
            autoUpdateIconDecorator.fireLabelProviderChanged(stockDatabase);
        }
    } catch (InvocationTargetException e) {
        displayErrorMessage("Auto-update error", "Server error while setting auto-update",
                e.getCause().getMessage());
    } catch (InterruptedException e) {
        displayErrorMessage("Auto-update error", "Task interrupted while setting auto-update", e.getMessage());
    } catch (Exception e) {
        displayErrorMessage("Auto-update error", "Error while setting auto-update", e.getMessage());
    }
    return true;
}

From source file:com.redhat.ea.archimate.strategyexport.EaUmlImporter.java

License:Open Source License

@Override
public void doImport() throws IOException {

    boolean runThis = false;
    IArchimateModel m = null;//from w  w w.j a v  a 2s  .c o  m
    boolean isNewModel = false;

    int numModelsOpen = IEditorModelManager.INSTANCE.getModels().size();

    if (numModelsOpen > 0) {
        if ((MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Strategy Importer",
                "Warning: This utility will import into the first open model.\nPress OK to continue."))) {
            runThis = true;
            m = IEditorModelManager.INSTANCE.getModels().get(0);

        }
    } else {
        // create a new model to use;
        m = IArchimateFactory.eINSTANCE.createArchimateModel();
        m.setDefaults();
        runThis = true;
        isNewModel = true;
    }

    if (runThis) {
        File file = askOpenFile();
        if (file == null) {
            return;
        }

        Uml241Importer importer = new Uml241Importer(file, m);

        try {
            importer.doImport();
            // And open the Model in the Editor
            if (isNewModel) {
                IEditorModelManager.INSTANCE.openModel(importer.getModel());
            }
        } catch (Exception e) {
            System.err.println(e.getMessage());
            e.printStackTrace();
        }

        MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Strategy Importer",
                "Completed import!");
    }
}

From source file:com.runwaysdk.manager.view.EditView.java

License:Open Source License

public void delete() {
    Shell shell = getWidget().getShell();

    boolean confirm = MessageDialog.openConfirm(shell, Localizer.getMessage("CONFIRM_TITLE"),
            Localizer.getMessage("CONFIRM_DELETE"));

    if (confirm) {
        try {//  w  w  w  .ja  v a 2  s .c om
            this.getEntity().delete();

            String key = TabManager.getEditKey(this.getEntity());

            getModule().closeTab(key);

            if (config.isCloseOnSucess()) {
                controller.resumeImport();
            }
        } catch (Throwable t) {
            getModule().error(t);
        }
    }
}

From source file:com.sabre.buildergenerator.ui.wizard.GenerateBuilderWizard.java

License:Open Source License

/**
 * (non-Javadoc)/*from w ww  . j  av a  2  s.  co m*/
 *
 * @see org.eclipse.jface.wizard.Wizard#performFinish()
 */
@Override
public boolean performFinish() {
    boolean finish = false;

    if (generateBuilderWizardPage.isValid()) {
        if (!generateBuilderWizardPage.builderFQNameIsUnique()) {
            finish = MessageDialog.openConfirm(getShell(), "Builder name is not unique",
                    "Builder name is not unique. Do you want to replace the existing class?");
        } else {
            finish = true;
        }
    }

    return finish;
}

From source file:com.safi.workshop.sqlexplorer.connections.actions.DeleteAction.java

License:Open Source License

@Override
public void run() {
    SafiNavigator nav = SafiWorkshopEditorUtil.getSafiNavigator();
    IStructuredSelection viewerSelection = nav.getViewerSelection();
    if (viewerSelection.isEmpty())
        return;//  ww  w . jav a  2s  .  c  o m

    boolean okToDelete = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Delete Resource",
            "Are you sure you  want to delete the selected resource?");

    if (!okToDelete)
        return;

    List<IResource> resources = new ArrayList<IResource>();
    List<Object> dbResources = new ArrayList<Object>();
    List<ServerResource> serverResources = new ArrayList<ServerResource>();
    for (Object selected : viewerSelection.toArray()) {
        if (selected instanceof ManagedDriver) {

            MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Delete Driver rejected",
                    "You can not delete Driver Resource.");
            return;

        }
        if (selected instanceof DBResource || selected instanceof User || selected instanceof Alias
        /* || selected instanceof ManagedDriver */) {
            dbResources.add(selected);
        } else if (selected instanceof IResource)
            resources.add((IResource) selected);
        else if (selected instanceof ServerResource)
            serverResources.add((ServerResource) selected);
    }

    if (!resources.isEmpty()) {
        if (SafiServerPlugin.getDefault().isConnected()) {
            boolean foundPersisted = false;
            for (IResource res : resources) {
                try {
                    int id = SafletPersistenceManager.getInstance().getResourceId(res);
                    if (id >= 0) {
                        foundPersisted = true;
                        break;
                    }
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            if (foundPersisted)
                MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Delete Local Only",
                        "This operation will delete only local copies of any selected Saflets or SafiProjects.  "
                                + " If you wish to delete them from the production SafiServer open the Delete Saflet dialog from the main toolbar.");
        }
        com.safi.workshop.navigator.DeleteResourceAction ac = new com.safi.workshop.navigator.DeleteResourceAction();
        ac.selectionChanged(viewerSelection);
        ac.run();
    }
    if (!dbResources.isEmpty()) {
        int deletePref = 1;
        com.safi.db.server.config.User user = SafiServerPlugin.getDefault().getCurrentUser();
        boolean isConnected = SafiServerPlugin.getDefault().isConnected();

        if (isConnected
                && !EntitlementUtils.isUserEntitled(user, EntitlementUtils.ENTIT_PUBLISH_DB_RESOURCES)) {
            MessageDialog.openError(SafiWorkshopEditorUtil.getActiveShell(), "Not Entitled",
                    "You do not have sufficient privileges to carry out this operation.");
            return;
        }
        removeDBResourceChildren(dbResources);

        // if (SafiServerPlugin.getDefault().isConnected())
        // deleteFromServer =
        // MessageDialog.openQuestion(Display.getCurrent().getActiveShell(),
        // "Delete From Server?",
        // "Do you want to delete database resource(s) from the production SafiServer?");
        for (Object o : dbResources) {
            if (o instanceof Alias) {
                Alias alias = (Alias) o;
                DBConnection conn = alias.getConnection();
                List<Query> queries = new ArrayList<Query>(conn.getQueries());

                alias.getConnection().setLastModified(new Date());
                if (deletePref != 2 && deletePref != 3 && isConnected && alias.getConnection().getId() != -1) {
                    MessageDialog dialog = new MessageDialog(SafiWorkshopEditorUtil.getActiveShell(),
                            "Delete From Server?", null,
                            "Do you want to delete database connection " + alias.getName()
                                    + " from the production SafiServer?",
                            SWT.ICON_QUESTION,
                            new String[] { "YES", "NO", "YES TO ALL", "NO TO ALL", "CANCEL" }, 1);
                    deletePref = dialog.open();
                    if (deletePref == 4)
                        return;
                }
                try {
                    alias.remove(deletePref == 0 || deletePref == 2, true);
                } catch (Exception e) {
                    MessageDialog.openError(SafiWorkshopEditorUtil.getActiveShell(), "Delete Failed",
                            "Couldn't delete alias " + alias.getName() + ": " + e.getLocalizedMessage());
                    AsteriskDiagramEditorPlugin.getInstance().logError("Couldn't delete alias", e);
                }
                for (Query query : queries) {
                    SafiWorkshopEditorUtil.closeSQLEditors(query);
                }
            } else if (o instanceof Query) {
                Query query = (Query) o;
                if (deletePref != 2 && deletePref != 3 && isConnected && query.getId() != -1) {
                    MessageDialog dialog = new MessageDialog(SafiWorkshopEditorUtil.getActiveShell(),
                            "Delete From Server?", null,
                            "Do you want to delete database query " + query.getName()
                                    + " from the production SafiServer?",
                            SWT.ICON_QUESTION,
                            new String[] { "YES", "NO", "YES TO ALL", "NO TO ALL", "CANCEL" }, 1);
                    deletePref = dialog.open();
                    if (deletePref == 4)
                        return;
                }
                if (deletePref == 0 || deletePref == 2) {

                    try {
                        SQLExplorerPlugin.getDefault().deleteDBResource(query);
                    } catch (Exception e) {
                        MessageDialog.openError(SafiWorkshopEditorUtil.getActiveShell(), "Delete Failed",
                                "Couldn't delete query " + query.getName() + ": " + e.getLocalizedMessage());
                        AsteriskDiagramEditorPlugin.getInstance()
                                .logError("Couldn't delete query " + query.getName(), e);
                    }
                }
                query.getConnection().setLastModified(new Date());
                query.getConnection().getQueries().remove(query);
                SafiWorkshopEditorUtil.closeSQLEditors(query);
            } else if (o instanceof ManagedDriver) {
                ManagedDriver driver = (ManagedDriver) o;
                if (driver.getDriver() != null && !driver.getDriver().isDefault()) {
                    if (deletePref != 2 && deletePref != 3 && isConnected && driver.getDriver().getId() != -1) {
                        MessageDialog dialog = new MessageDialog(SafiWorkshopEditorUtil.getActiveShell(),
                                "Delete From Server?", null,
                                "Do you want to delete database driver " + driver.getDriver().getName()
                                        + " from the production SafiServer?",
                                SWT.ICON_QUESTION,
                                new String[] { "YES", "NO", "YES TO ALL", "NO TO ALL", "CANCEL" }, 1);
                        deletePref = dialog.open();
                        if (deletePref == 4)
                            return;
                    }
                    if (deletePref == 0 || deletePref == 1) {
                        try {
                            SQLExplorerPlugin.getDefault().deleteDBResource(driver.getDriver());
                        } catch (Exception e) {
                            MessageDialog.openError(SafiWorkshopEditorUtil.getActiveShell(), "Delete Failed",
                                    "Couldn't delete query " + driver.getDriver().getName() + ": "
                                            + e.getLocalizedMessage());
                            AsteriskDiagramEditorPlugin.getInstance()
                                    .logError("Couldn't delete query " + driver.getDriver().getName(), e);
                        }
                    }
                    SQLExplorerPlugin.getDefault().getDriverModel().removeDriver(driver);
                }
            }
        }
        SQLExplorerPlugin.getDefault().saveDBResources(false);
    }

    if (!serverResources.isEmpty()) {
        com.safi.db.server.config.User user = SafiServerPlugin.getDefault().getCurrentUser();

        List<ServerResource> deleted = new ArrayList<ServerResource>();
        SafiServer production = null;
        try {
            production = SafiServerPlugin.getDefault().getSafiServer(true);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if (production != null) {
            removeChildren(serverResources);
            boolean checkedTelEntit = false;
            boolean checkedUsers = false;
            for (ServerResource r : serverResources) {
                if (r instanceof com.safi.db.server.config.User) {
                    if (!checkedUsers) {
                        if (!EntitlementUtils.isUserEntitled(user, EntitlementUtils.ENTIT_MANAGE_USERS)) {
                            MessageDialog.openError(SafiWorkshopEditorUtil.getActiveShell(), "Not Entitled",
                                    "You do not have sufficient privileges to carry out this operation.");
                            return;
                        } else
                            checkedUsers = true;
                    }

                    if (r.getId() == SafiServerPlugin.getDefault().getCurrentUser().getId()) {
                        MessageDialog.openInformation(Display.getCurrent().getActiveShell(),
                                "Can't Delete Self", "The currently logged in user cannot be deleted.");
                        continue;
                    } else {
                        production.getUsers().remove(r);
                        deleted.add(r);
                    }
                }

            }
        } else {
            MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Can't Delete",
                    "An error has occurred.  No SafiServer instance could be found.");
            return;
        }
        deleteServerResources(production, deleted);

    }

    if (dbResources.isEmpty() && serverResources.isEmpty())
        nav.refresh();
    else {
        try {
            SafiServerPlugin.getDefault().updateServerResources(new NullProgressMonitor());
        } catch (Exception e) {
            e.printStackTrace();
            MessageDialog.openError(SafiWorkshopEditorUtil.getActiveShell(), "Database Error",
                    "Couldn't refresh from production SafiServer: " + e.getLocalizedMessage());
            return;
        }
        // nav.modelChanged(SafiServerPlugin.getDefault().isConnected());
    }

    // if (!viewerSelection.isEmpty() && viewerSelection.getFirstElement()
    // instanceof
    // IResource){
    // DeleteResourceAction action = new
    // DeleteResourceAction(Display.getCurrent().getActiveShell());
    // action.selectionChanged(viewerSelection);
    // action.run();
    // return;
    // }
    //    
    //
    //    
    // boolean deleteFromServer = false;
    // if (SafiServerPlugin.getDefault().hasProductionServerInfo())
    // deleteFromServer =
    // MessageDialog.openQuestion(Display.getCurrent().getActiveShell(),
    // "Delete From Server?",
    // "Do you want to delete from the production SafiServer?");
    // boolean needsToSave = false;
    //    
    // Set<User> selectedUsers = nav.getSelectedUsers(false);
    // Date now = new Date();
    // for (User user : selectedUsers) {
    // user.getAlias().removeUser(user);
    // user.getAlias().getConnection().setLastModified(now);
    // }
    // if (!selectedUsers.isEmpty()) {
    // needsToSave = true;
    // }
    // Set<Alias> selectedAliases = nav.getSelectedAliases(false);
    // for (Alias alias : selectedAliases) {
    // alias.getConnection().setLastModified(now);
    // try {
    // alias.remove(deleteFromServer, true);
    // } catch (Exception e) {
    // MessageDialog.openError(AsteriskDiagramEditorUtil.getActiveShell(),
    // "Delete Failed", "Couldn't delete alias " + alias.getName() + ": "
    // + e.getLocalizedMessage());
    // AsteriskDiagramEditorPlugin.getInstance().logError("Couldn't delete alias",
    // e);
    // return;
    // }
    // }
    // if (!selectedAliases.isEmpty())
    // needsToSave = true;
    // Set<Query> selectedQueries = nav.getSelectedQueries(false);
    // for (Query query : selectedQueries) {
    // if (deleteFromServer) {
    // query.getConnection().setLastModified(now);
    // try {
    // SQLExplorerPlugin.getDefault().deleteDBResource(query);
    // } catch (Exception e) {
    // MessageDialog.openError(AsteriskDiagramEditorUtil.getActiveShell(),
    // "Delete Failed", "Couldn't delete query " + query.getName() + ": "
    // + e.getLocalizedMessage());
    // AsteriskDiagramEditorPlugin.getInstance().logError(
    // "Couldn't delete query " + query.getName(), e);
    // }
    // }
    // query.getConnection().getQueries().remove(query);
    // }
    // if (!selectedQueries.isEmpty())
    // needsToSave = true;
    //
    // Set<ManagedDriver> selectedDrivers = nav.getSelectedDrivers(false);
    // if (selectedDrivers != null && !selectedDrivers.isEmpty()) {
    // for (ManagedDriver driver : selectedDrivers) {
    // if (driver.getDriver() != null && !driver.getDriver().isDefault()) {
    // if (deleteFromServer) {
    // try {
    // SQLExplorerPlugin.getDefault().deleteDBResource(driver.getDriver());
    // } catch (Exception e) {
    // MessageDialog.openError(AsteriskDiagramEditorUtil.getActiveShell(),
    // "Delete Failed", "Couldn't delete query "
    // + driver.getDriver().getName() + ": " + e.getLocalizedMessage());
    // AsteriskDiagramEditorPlugin.getInstance().logError(
    // "Couldn't delete query " + driver.getDriver().getName(), e);
    // }
    // }
    // SQLExplorerPlugin.getDefault().getDriverModel().removeDriver(driver);
    // needsToSave = true;
    // }
    // }
    // }
    //
    // if (needsToSave) {
    // SQLExplorerPlugin.getDefault().saveDBResources(false);
    // nav.modelChanged();
    // return;
    // }
    // nav.refresh();
}

From source file:com.safi.workshop.sqlexplorer.plugin.SQLExplorerPlugin.java

License:Open Source License

public void updateDBResource(Alias alias) throws DBManagerException {
    DBConnection oldConnection = alias.getConnection();
    if (oldConnection.getLastUpdated() == null)
        return;//from  www.  ja va 2 s.  co  m
    DBResource rez = DBManager.getInstance().updateDBResource(safiDriverManager, oldConnection);
    if (rez == oldConnection) {
        MessageDialog.openInformation(getWorkbench().getDisplay().getActiveShell(), "No changes",
                "There have been no changes to the selected resource");
        return;
    }
    if (rez == null) {
        DBConnection conn = oldConnection;
        boolean isModified = false;
        for (Query q : conn.getQueries()) {
            if (q.getLastUpdated() == null || q.getLastModified().compareTo(q.getLastUpdated()) >= 0) {
                isModified = true;
                break;
            }
        }
        if (isModified) {
            boolean ok = MessageDialog.openConfirm(getWorkbench().getDisplay().getActiveShell(),
                    "Resource Deleted",
                    "The selected resource " + alias.getName() + " has been renamed or deleted but\n"
                            + "one or more child queries have been modified.  Press 'OK' to continue or 'Cancel' \nto keep your changes ");
            if (!ok) {
                disconnectChildren(conn);
                return;
            }
        }
        try {
            alias.remove(false, true);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else {
        Date now = new Date();
        DBManager.getInstance().copyProperties(oldConnection, rez, false);
        oldConnection.setLastUpdated(now);
        DBManager.touchChildren(oldConnection, now);

    }
    SafiWorkshopEditorUtil.getSafiNavigator().modelChanged(SafiServerPlugin.getDefault().isConnected());

}