Example usage for org.eclipse.jface.dialogs Dialog Dialog

List of usage examples for org.eclipse.jface.dialogs Dialog Dialog

Introduction

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

Prototype

protected Dialog(IShellProvider parentShell) 

Source Link

Document

Creates a dialog with the given parent.

Usage

From source file:org.topcased.model2doc.query2table.ui.pages.ConfigurationWizardPage.java

License:Open Source License

/**
 * Creates the buttons columns./*from  w w w .j a v  a 2s.c o  m*/
 * 
 * @param section
 *            the section
 */
private void createButtonsColumns(Composite section) {
    buttonTable = toolkit.createButton(section, "", SWT.PUSH);
    buttonTable.setLayoutData(new GridData(SWT.CENTER, SWT.BOTTOM, false, false));
    buttonTable.setImage(imageTable);
    buttonTable.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Shell shell = getShell();
            Dialog d = new Dialog(shell) {

                @Override
                protected void configureShell(Shell newShell) {
                    super.configureShell(newShell);
                    newShell.setText("Preview");
                }

                protected Control createDialogArea(Composite parent) {
                    setErrorMessage(null);
                    ModelExport modelExport = q2t.getModelExport();
                    try {
                        TableTree tree = new Export2TableAction().generateTreeFromModel(modelExport);
                        TableViewer viewer = new TableViewer(parent, SWT.V_SCROLL);
                        Table t = viewer.getTable();
                        t.setHeaderVisible(true);
                        t.setLinesVisible(true);
                        for (Column c : modelExport.getColumns()) {
                            TableColumn col = new TableColumn(t, SWT.NONE, c.getIndex());
                            col.setText(c.getTitle());
                            col.setWidth(200);
                            col.setResizable(true);
                        }
                        t.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));

                        viewer.setContentProvider(new IStructuredContentProvider() {
                            public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
                            }

                            public void dispose() {
                            }

                            public Object[] getElements(Object inputElement) {
                                if (inputElement instanceof TableTree) {
                                    TableTree tree = (TableTree) inputElement;
                                    return TreeUtils.getTreeElements(tree).toArray();
                                }
                                return Collections.EMPTY_LIST.toArray();
                            }
                        });
                        viewer.setLabelProvider(new ITableLabelProvider() {

                            public void removeListener(ILabelProviderListener listener) {
                            }

                            public boolean isLabelProperty(Object element, String property) {
                                return true;
                            }

                            public void dispose() {
                            }

                            public void addListener(ILabelProviderListener listener) {
                            }

                            public String getColumnText(Object element, int columnIndex) {
                                if (element instanceof TableTreeNode) {
                                    TableTreeNode node = (TableTreeNode) element;
                                    int index = TreeUtils.getIndex(node);
                                    if (columnIndex == index) {
                                        return node.getDisplayValue();
                                    } else if (columnIndex < index) {
                                        node = TreeUtils.getParent(node, index - columnIndex);
                                        return node.getDisplayValue();
                                    } else {
                                        return "";
                                    }
                                }
                                return "";
                            }

                            public Image getColumnImage(Object element, int columnIndex) {
                                return null;
                            }
                        });
                        viewer.setInput(tree);
                    } catch (NullPointerException npe) {
                        setErrorMessage("internal occurs in Query2Table");
                        throw new RuntimeException();
                    } catch (Exception e) {
                        setErrorMessage(e.getMessage());
                        throw new RuntimeException();
                    }
                    return parent;
                }

            };
            try {
                d.open();

            } catch (RuntimeException ex) {
            }
        }
    });

    buttonSave = toolkit.createButton(section, "", SWT.PUSH);
    buttonSave.setLayoutData(new GridData(SWT.CENTER, SWT.BOTTOM, false, false));
    buttonSave.setImage(imageSave);
    buttonSave.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {

            try {
                URI uri = q2t.resourcesSave();
                setMessage("Saved at " + uri.toString(), DialogPage.INFORMATION);
            } catch (IOException io) {
                setErrorMessage("IO error occurs " + io.getMessage());
            } catch (Exception e1) {
                setErrorMessage(e1.getMessage());
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {

        }
    });

    buttonAddColumn = toolkit.createButton(section, "", SWT.PUSH);
    buttonAddColumn.addSelectionListener(new EventSelectionListener() {

        @Override
        public event_execute getEvent() {
            return SM.event_execute.buttonPlus;
        }

        @Override
        public void doWidgetSelected(SelectionEvent e) {
            Column column = Query2tableFactory.eINSTANCE.createColumn();
            if (table.getItemCount() == 0) {
                column.setIndex(highColumnIndex);
            } else {
                column.setIndex(highColumnIndex + 1);
            }
            column.setTitle("Title to modify");
            getController().getQ2T().getModelExport().getColumns().add(column);
            columnsTableViewer.refresh();
            unselectDisplay();
        }
    });
    buttonAddColumn.setLayoutData(new GridData(SWT.CENTER, SWT.BOTTOM, false, false));
    buttonAddColumn.setImage(imageAdd);

    // Create remove button
    buttonRemoveColumn = toolkit.createButton(section, "", SWT.PUSH);
    buttonRemoveColumn.addSelectionListener(new EventSelectionListener() {

        @Override
        public event_execute getEvent() {
            return event_execute.buttonMoin;
        }

        @Override
        public void doWidgetSelected(SelectionEvent e) {
            unselectDisplay();
            ISelection selection = columnsTableViewer.getSelection();
            if (selection instanceof IStructuredSelection) {
                IStructuredSelection select = (IStructuredSelection) selection;
                for (Iterator<?> i = select.iterator(); i.hasNext();) {
                    Object o = i.next();
                    if (o instanceof Column) {
                        Column column = (Column) o;
                        getController().getQ2T().getModelExport().getColumns().remove(column);
                    }
                }
            }
            columnsTableViewer.refresh();
        }
    });
    buttonRemoveColumn.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false));
    buttonRemoveColumn.setImage(imageRemove);

}

From source file:tinyos.dlrc.search.ui.SearchForPanel.java

License:Open Source License

private void openAdvanced() {
    final AdvancedSearchForPanel advanced = new AdvancedSearchForPanel(advancedTags);

    Dialog advancedDialog = new Dialog(control.getShell()) {
        {//from  w ww . j  a va  2s  .  co m
            setShellStyle(SWT.RESIZE | SWT.CLOSE | SWT.TITLE);
        }

        @Override
        protected Control createDialogArea(Composite parent) {
            Composite panel = (Composite) super.createDialogArea(parent);
            advanced.createControl(panel);
            advanced.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
            advanced.setSelection(advancedSelection);

            getShell().setText("Tags");

            return panel;
        }

        @Override
        protected void okPressed() {
            advancedSelection = advanced.getSelection();
            super.okPressed();
        }
    };

    advancedDialog.open();
}

From source file:tubame.wsearch.ui.preferences.LibraryRepositoryPreferencePage.java

License:Apache License

/**
 * Create a button.<br/>//from   w ww  .java2s  .  co  m
 * 
 * @param parent
 *            Parent group
 * @param viewer
 *            Checkbox table viewer
 */
private void createButtons(Group parent, final CheckboxTableViewer viewer) {
    Composite buttonComposite = new Composite(parent, SWT.NONE);
    buttonComposite.setLayout(new GridLayout(1, false));
    buttonComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    Button addButton = new Button(buttonComposite, SWT.PUSH);
    addButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    addButton.setText(
            Activator.getResourceString(LibraryRepositoryPreferencePage.class.getName() + ".label.add"));
    addButton.addSelectionListener(new SelectionListener() {

        /**
         * {@inheritDoc}
         */
        public void widgetDefaultSelected(SelectionEvent e) {

        }

        /**
         * {@inheritDoc}
         */
        public void widgetSelected(SelectionEvent e) {
            EditLibraryRepositoryDialog dialog = new EditLibraryRepositoryDialog(getShell(), null, false);
            int ok = dialog.open();
            if (ok == Window.OK) {
                LibraryRepository repository = dialog.getRepository();
                String libraryName = repository.getName();
                repository.setOrder(libraryRepositories.size() + 1);
                int index = -1;
                for (LibraryRepository rep : libraryRepositories) {
                    if (rep.getName().equals(libraryName)) {
                        int ret = new Dialog(getShell()) {
                            protected Control createDialogArea(Composite parent) {
                                Composite composite = (Composite) super.createDialogArea(parent);
                                Label label = new Label(composite, SWT.SHADOW_NONE);
                                label.setText(Activator
                                        .getResourceString(LibraryRepositoryPreferencePage.class.getName()
                                                + ".label.AddOverwrite"));
                                return composite;
                            }
                        }.open();
                        if (ret == IDialogConstants.CANCEL_ID) {
                            return;
                        }
                        repository.setOrder(rep.getOrder());
                        index = libraryRepositories.indexOf(rep);
                        break;
                    }
                }
                File cacheDir = new File(Activator.getLibraryCacheHomeDir(), libraryName);
                if (cacheDir.exists()) {
                    try {
                        FileVisitor.walkFileTree(cacheDir, new FileVisitor() {
                            @Override
                            public FileVisitResult visitFile(File file) throws IOException {
                                file.delete();
                                return FileVisitResult.CONTINUE;
                            }

                            @Override
                            public FileVisitResult postVisitDirectory(File dir) throws IOException {
                                dir.delete();
                                return FileVisitResult.CONTINUE;
                            }
                        });
                    } catch (IOException e1) {
                        Activator.log(e1);
                        ErrorDialog.openErrorDialog(getShell(), null, Activator.getResourceString(
                                LibraryRepositoryPreferencePage.class.getName() + ".err.msg.DeleteCacheErr"));
                        return;
                    }
                }
                if (index >= 0) {
                    libraryRepositories.set(index, repository);
                } else {
                    libraryRepositories.add(repository);
                }
                viewer.refresh();
                tableViewer.setChecked(repository, repository.isEnabled());
            }
            viewer.refresh();
        }
    });

    final Button editButton = new Button(buttonComposite, SWT.PUSH);
    editButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    editButton.setText(
            Activator.getResourceString(LibraryRepositoryPreferencePage.class.getName() + ".label.edit"));
    editButton.setEnabled(false);

    editButton.addSelectionListener(new SelectionListener() {

        /**
         * {@inheritDoc}
         */
        public void widgetSelected(SelectionEvent e) {
            ISelection sel = viewer.getSelection();
            if (sel instanceof IStructuredSelection) {
                IStructuredSelection selection = (IStructuredSelection) sel;
                Object object = selection.getFirstElement();
                if (object instanceof LibraryRepository) {
                    LibraryRepository repository = (LibraryRepository) object;
                    LibraryRepository edit = new LibraryRepository(repository.getName(), repository.getUrl(),
                            repository.getDescription(), repository.isEnabled(), repository.isMavenType(),
                            repository.isPluginEmbedded());

                    boolean zip = true;
                    if (new File(repository.getUrl()).isDirectory()) {
                        zip = false;
                    }
                    EditLibraryRepositoryDialog dialog = new EditLibraryRepositoryDialog(getShell(), edit, zip);
                    int ok = dialog.open();
                    if (ok == Window.OK) {
                        repository.setName(edit.getName());
                        repository.setUrl(edit.getUrl());
                        repository.setEnabled(edit.isEnabled());
                        repository.setDescription(edit.getDescription());
                        viewer.refresh();
                        tableViewer.setChecked(repository, repository.isEnabled());
                        updateDetailsText(repository);
                    }
                }
            }
        }

        /**
         * {@inheritDoc}
         */
        public void widgetDefaultSelected(SelectionEvent e) {

        }
    });

    final Button removeButton = new Button(buttonComposite, SWT.PUSH);
    removeButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    removeButton.setText(
            Activator.getResourceString(LibraryRepositoryPreferencePage.class.getName() + ".label.remove"));
    removeButton.setEnabled(false);

    final Button upButton = new Button(buttonComposite, SWT.PUSH);
    upButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    upButton.setText(
            Activator.getResourceString(LibraryRepositoryPreferencePage.class.getName() + ".label.up"));
    upButton.setEnabled(false);

    final Button downButton = new Button(buttonComposite, SWT.PUSH);
    downButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    downButton.setText(
            Activator.getResourceString(LibraryRepositoryPreferencePage.class.getName() + ".label.down"));
    downButton.setEnabled(false);

    final Button exportButton = new Button(buttonComposite, SWT.PUSH);
    exportButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    exportButton.setText(
            Activator.getResourceString(LibraryRepositoryPreferencePage.class.getName() + ".label.export"));
    exportButton.setEnabled(false);

    removeButton.addSelectionListener(new SelectionListener() {

        /**
         * {@inheritDoc}
         */
        public void widgetSelected(SelectionEvent e) {
            ISelection sel = viewer.getSelection();
            if (sel instanceof IStructuredSelection) {
                IStructuredSelection selection = (IStructuredSelection) sel;
                Object object = selection.getFirstElement();
                if (object instanceof LibraryRepository) {
                    int order = ((LibraryRepository) object).getOrder();
                    libraryRepositories.remove(object);
                    editButton.setEnabled(false);
                    removeButton.setEnabled(false);
                    upButton.setEnabled(false);
                    downButton.setEnabled(false);
                    exportButton.setEnabled(false);
                    for (LibraryRepository rep : libraryRepositories) {
                        if (rep.getOrder() > order) {
                            rep.setOrder(rep.getOrder() - 1);
                        }
                    }
                    detailsText.setText(CmnStringUtil.EMPTY);
                    viewer.refresh();
                }
            }
        }

        /**
         * {@inheritDoc}
         */
        public void widgetDefaultSelected(SelectionEvent e) {

        }
    });
    upButton.addSelectionListener(new SelectionListener() {

        /**
         * {@inheritDoc}
         */
        public void widgetSelected(SelectionEvent e) {
            ISelection sel = viewer.getSelection();
            if (sel instanceof IStructuredSelection) {
                IStructuredSelection selection = (IStructuredSelection) sel;
                Object object = selection.getFirstElement();
                if (object instanceof LibraryRepository) {
                    LibraryRepository selected = (LibraryRepository) object;
                    int selectedIndex = libraryRepositories.indexOf(selected);
                    if (selectedIndex > 0) {
                        LibraryRepository temp = libraryRepositories.get(selectedIndex - 1);
                        libraryRepositories.set((selectedIndex - 1), selected);
                        libraryRepositories.set(selectedIndex, temp);
                        selected.setOrder(selectedIndex - 1);
                        temp.setOrder(selectedIndex);
                        viewer.refresh();
                        int newIndex = selectedIndex - 1;
                        downButton.setEnabled(newIndex < (libraryRepositories.size() - 1));
                        upButton.setEnabled(newIndex > 0);
                    }
                }
            }
        }

        /**
         * {@inheritDoc}
         */
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    downButton.addSelectionListener(new SelectionListener() {

        /**
         * {@inheritDoc}
         */
        public void widgetSelected(SelectionEvent e) {
            ISelection sel = viewer.getSelection();
            if (sel instanceof IStructuredSelection) {
                IStructuredSelection selection = (IStructuredSelection) sel;
                Object object = selection.getFirstElement();
                if (object instanceof LibraryRepository) {
                    LibraryRepository selected = (LibraryRepository) object;
                    int selectedIndex = libraryRepositories.indexOf(selected);
                    if ((selectedIndex >= 0) && (selectedIndex < libraryRepositories.size())) {
                        LibraryRepository temp = libraryRepositories.get(selectedIndex + 1);
                        libraryRepositories.set(selectedIndex, temp);
                        libraryRepositories.set((selectedIndex + 1), selected);
                        selected.setOrder(selectedIndex + 1);
                        temp.setOrder(selectedIndex);
                        viewer.refresh();
                        int newIndex = selectedIndex + 1;
                        downButton.setEnabled(newIndex < (libraryRepositories.size() - 1));
                        upButton.setEnabled(newIndex > 0);
                    }
                }
            }
        }

        /**
         * {@inheritDoc}
         */
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    final Button importButton = new Button(buttonComposite, SWT.PUSH);
    importButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    importButton.setText(
            Activator.getResourceString(LibraryRepositoryPreferencePage.class.getName() + ".label.import"));
    importButton.setEnabled(true);
    importButton.addSelectionListener(new SelectionListener() {

        /**
         * {@inheritDoc}
         */
        public void widgetDefaultSelected(SelectionEvent e) {
        }

        /**
         * {@inheritDoc}
         */
        public void widgetSelected(SelectionEvent e) {
            EditLibraryRepositoryImportExportDialog dialog = new EditLibraryRepositoryImportExportDialog(
                    getShell(), null, true);
            int ok = dialog.open();
            if (ok == Window.OK) {
                LibraryRepository repository = dialog.getRepository();

                String targetZip = repository.getUrl();
                String libraryCacheHomeDir = Activator.getLibraryCacheHomeDir();

                LibraryModel libraryModel = new LibraryModel();
                libraryModel.setPath(targetZip);
                WSearchLibraryCacheArgument argument = new WSearchLibraryCacheArgument(CacheBase.TYPE.LIBRARY,
                        libraryCacheHomeDir, libraryModel);
                try {
                    String libraryName = targetZip.substring((targetZip.lastIndexOf(File.separator) + 1),
                            targetZip.lastIndexOf("."));
                    String pomEntry = libraryName + File.separator + "pom.xml";
                    if (!ZipUtil.existsEntry(targetZip, pomEntry)) {
                        ErrorDialog.openErrorDialog(getShell(), null, Activator.getResourceString(
                                LibraryRepositoryPreferencePage.class.getName() + ".err.msg.FormatErr"));
                        return;
                    }
                    int index = -1;
                    for (LibraryRepository rep : libraryRepositories) {
                        if (rep.getName().equals(libraryName)) {
                            int ret = new Dialog(getShell()) {
                                protected Control createDialogArea(Composite parent) {
                                    Composite composite = (Composite) super.createDialogArea(parent);
                                    Label label = new Label(composite, SWT.SHADOW_NONE);
                                    label.setText(Activator
                                            .getResourceString(LibraryRepositoryPreferencePage.class.getName()
                                                    + ".label.ImportOverwrite"));
                                    return composite;
                                }
                            }.open();
                            if (ret == IDialogConstants.CANCEL_ID) {
                                return;
                            }
                            rep.setUrl(repository.getUrl());
                            repository = rep;
                            index = libraryRepositories.indexOf(rep);
                            break;
                        }
                    }
                    File cacheDir = new File(Activator.getLibraryCacheHomeDir(), libraryName);
                    if (cacheDir.exists()) {
                        try {
                            FileVisitor.walkFileTree(cacheDir, new FileVisitor() {
                                @Override
                                public FileVisitResult visitFile(File file) throws IOException {
                                    file.delete();
                                    return FileVisitResult.CONTINUE;
                                }

                                @Override
                                public FileVisitResult postVisitDirectory(File dir) throws IOException {
                                    dir.delete();
                                    return FileVisitResult.CONTINUE;
                                }
                            });
                        } catch (IOException e1) {
                            Activator.log(e1);
                            ErrorDialog.openErrorDialog(getShell(), null,
                                    Activator.getResourceString(LibraryRepositoryPreferencePage.class.getName()
                                            + ".err.msg.DeleteCacheErr"));
                            return;
                        }
                    }
                    Activator.extractCacheDir(new File(targetZip), argument, false);
                    String pomPath = libraryCacheHomeDir + File.separator + libraryName + File.separator
                            + "pom.xml";
                    PomReader reader = new PomReader();
                    reader.loadPomFile(pomPath);
                    repository.setName(libraryName);
                    repository.setCache(true);
                    repository.setEnabled(true);
                    repository.setMavenType(reader.isMavenType());
                    repository.setPluginEmbedded(reader.isEmbeddedCache());
                    repository.setZipCache(true);
                    repository.setOrder(libraryRepositories.size() + 1);
                    if (index >= 0) {
                        libraryRepositories.set(index, repository);
                    } else {
                        libraryRepositories.add(repository);
                    }
                } catch (IOException ex) {
                    String message = Activator.getResourceString(
                            LibraryRepositoryPreferencePage.class.getName() + ".err.msg.UnzipErr");
                    Activator.log(ex, message);
                    ErrorDialog.openErrorDialog(getShell(), ex, message);
                    return;
                } catch (XmlPullParserException ex) {
                    String message = Activator.getResourceString(
                            LibraryRepositoryPreferencePage.class.getName() + ".err.msg.PomReadErr");
                    Activator.log(ex, message);
                    ErrorDialog.openErrorDialog(getShell(), ex, message);
                    return;
                }
                viewer.refresh();
                tableViewer.setChecked(repository, repository.isEnabled());
            }
            viewer.refresh();
        }

    });

    exportButton.addSelectionListener(new SelectionListener() {

        /**
         * {@inheritDoc}
         */
        public void widgetDefaultSelected(SelectionEvent e) {
        }

        /**
         * {@inheritDoc}
         */
        public void widgetSelected(SelectionEvent e) {
            EditLibraryRepositoryImportExportDialog dialog = new EditLibraryRepositoryImportExportDialog(
                    getShell(), selectionLibrary, false);
            int ok = dialog.open();
            if (ok == Window.OK) {
                LibraryRepository repository = dialog.getRepository();

                String targetZip = repository.getUrl();

                String base = Activator.getLibraryCacheHomeDir() + File.separator + repository.getName();
                File baseFile = new File(base);
                try {
                    ZipUtil.zip(baseFile, new File(targetZip));
                } catch (IOException ex) {
                    String message = Activator.getResourceString(
                            LibraryRepositoryPreferencePage.class.getName() + ".err.msg.ZipErr");
                    Activator.log(ex, message);
                    ErrorDialog.openErrorDialog(getShell(), ex, message);
                    return;
                }
            }
        }
    });

    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        /**
         * {@inheritDoc}
         */
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection sel = viewer.getSelection();
            if (sel instanceof IStructuredSelection) {
                IStructuredSelection selection = (IStructuredSelection) sel;
                Object object = selection.getFirstElement();
                if (object instanceof LibraryRepository) {
                    selectionLibrary = (LibraryRepository) object;
                    if (selectionLibrary.isPluginEmbedded() || selectionLibrary.hasCache()) {
                        editButton.setEnabled(false);
                        exportButton.setEnabled(true);
                    } else {
                        editButton.setEnabled(true);
                        exportButton.setEnabled(false);
                    }
                    removeButton.setEnabled(true);
                    upButton.setEnabled(false);
                    downButton.setEnabled(false);
                    if (libraryRepositories.size() > 1) {
                        Iterator<LibraryRepository> iterator = libraryRepositories.iterator();
                        LibraryRepository first = null;
                        if (iterator.hasNext()) {
                            first = iterator.next();
                        }
                        LibraryRepository last = null;
                        while (iterator.hasNext()) {
                            last = iterator.next();
                        }
                        if (selectionLibrary.equals(last)) {
                            upButton.setEnabled(true);
                        } else if (selectionLibrary.equals(first)) {
                            downButton.setEnabled(true);
                        } else {
                            upButton.setEnabled(true);
                            downButton.setEnabled(true);
                        }
                    }
                    updateDetailsText(selectionLibrary);
                }
            } else {
                editButton.setEnabled(false);
                removeButton.setEnabled(false);
                upButton.setEnabled(false);
                downButton.setEnabled(false);
            }
        }
    });
}

From source file:tubame.wsearch.ui.wizards.ConfirmationGenericSearchWizard.java

License:Apache License

/**
 * {@inheritDoc}/*w  w  w. j  av  a 2 s  . co  m*/
 */
@Override
public boolean performFinish() {
    LOGGER.info(
            Activator.getResourceString("debug.msg.start") + "ConfirmationGenericSearchWizard#performFinish");

    if (CmnStringUtil.isEmpty(confirmationGenericSearchPage.getOutputPlace().getText())) {
        MessageDialog.openError(getShell(),
                Activator.getResourceString(ConfirmationGenericSearchWizard.class.getName() + ".title.error"),
                Activator.getResourceString(
                        ConfirmationGenericSearchWizard.class.getName() + ".err.msg.NoPath"));
        return false;
    }
    File resultPath = new File(PluginUtil.getSelectedProject().getLocation().removeLastSegments(1).toString(),
            confirmationGenericSearchPage.getOutputPlace().getText());
    if (!resultPath.exists()) {
        MessageDialog.openError(getShell(),
                Activator.getResourceString(ConfirmationGenericSearchWizard.class.getName() + ".title.error"),
                Activator.getResourceString(
                        ConfirmationGenericSearchWizard.class.getName() + ".err.msg.NotExists"));
        return false;
    }
    if (!resultPath.isDirectory()) {
        MessageDialog.openError(getShell(),
                Activator.getResourceString(ConfirmationGenericSearchWizard.class.getName() + ".title.error"),
                Activator.getResourceString(
                        ConfirmationGenericSearchWizard.class.getName() + ".err.msg.NotDirectory"));
        return false;
    }
    File resultFile = new File(resultPath.toString(), ResourceUtil.RESULT_FILE_NAME);
    if (resultFile.exists()) {
        int ret = new Dialog(getShell()) {
            protected Control createDialogArea(Composite parent) {
                Composite composite = (Composite) super.createDialogArea(parent);
                composite.getShell().setText(Activator.getResourceString(
                        ConfirmationGenericSearchWizard.class.getName() + ".title.Overwrite"));
                Label label = new Label(composite, SWT.SHADOW_NONE);

                label.setText(Activator.getResourceString(
                        ConfirmationGenericSearchWizard.class.getName() + ".label.Overwrite"));
                return composite;
            }
        }.open();
        if (ret == IDialogConstants.CANCEL_ID) {
            return false;
        }
    }

    // Acquisition of preferences extension of search
    Set<SearchFilter> srcSearchFilters = Activator.getSrcSearchFilters();
    Set<SearchFilter> targets = new HashSet<SearchFilter>();
    for (SearchFilter searchFilter : srcSearchFilters) {
        if (searchFilter.isEnabled()) {
            targets.add(searchFilter);
        }
    }
    if (targets.size() == 0) {
        String msg = Activator
                .getResourceString(this.getClass().getName() + ".err.msg.SearchFilterCheckUnEnableERR");
        Activator.logWithDialog(new IllegalArgumentException(msg), msg);
        return false;
    }
    IProject selectedProject = PluginUtil.getSelectedProject();
    String selectionDir = selectedProject.getName();
    String stateDir = Activator.getDefault().getStateLocation().toOSString();
    WSearchAnalyzerCacheArgument cacheArgument = new WSearchAnalyzerCacheArgument(TYPE.ANALYZE, stateDir,
            selectionDir, new AnalyzerCacheLoaderDelegate());
    try {
        this.bizDomain.cacheInit(cacheArgument, this.resource);
    } catch (WSearchBizException e1) {

        // Interrupt the process.
        return false;
    }
    String outputDirPath = selectedProject.getLocation().removeLastSegments(1).toString() + CmnStringUtil.SLASH
            + confirmationGenericSearchPage.getOutputPlace().getText();

    if (this.bizDomain.createAnalyzeAndCompareJobs(this.resource, srcSearchFilters, outputDirPath)) {
        try {
            this.bizDomain.generateDestLibMetaData(Activator.getLibraryRepositories().values(), cacheArgument,
                    stateDir, outputDirPath);
        } catch (WorkbenchException e) {
            String message = Activator.getResourceString(
                    ConfirmationGenericSearchWizard.class.getName() + ".err.msg.GenerateLibMetaDataErr");
            Activator.log(e, message);
            ErrorDialog.openErrorDialog(getShell(), e, message);
            return false;
        }
    } else {
        return false;
    }
    LOGGER.info(Activator.getResourceString("debug.msg.end") + "ConfirmationGenericSearchWizard#performFinish");
    return true;
}