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

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

Introduction

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

Prototype

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

Source Link

Document

Convenience method to open a simple Yes/No question dialog.

Usage

From source file:com.nextep.designer.sqlgen.ui.dbgm.TriggerEditorInput.java

License:Open Source License

private String adjustName(String sql) {
    final IParsingService parsingService = getParsingService();

    // Parsing name
    if (model.isCustom()) {
        String parsedName = parsingService.parseName(IElementType.getInstance(ITrigger.TYPE_ID), sql);
        String renamedSql = sql;/* w  w  w  .  j  a  v  a 2  s. c  om*/
        if (parsedName != null && !parsedName.equalsIgnoreCase(getName())) {
            boolean confirmed = MessageDialog.openQuestion(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    SQLMessages.getString("rename.trigger.confirmTitle"), //$NON-NLS-1$
                    SQLMessages.getString("rename.trigger.confirmMsg")); //$NON-NLS-1$
            if (confirmed) {
                // Renaming element
                model.setName(parsedName);
                // Renaming SQL which will be returned by this method
                renamedSql = parsingService.getRenamedSql(IElementType.getInstance(IProcedure.TYPE_ID), sql,
                        parsedName);
            } else {
                // If user did not confirm, we restore original name on the BODY
                renamedSql = parsingService.getRenamedSql(IElementType.getInstance(IProcedure.TYPE_ID), sql,
                        model.getName());
            }
        }
        return renamedSql;
    } else {
        return sql;
    }
}

From source file:com.nextep.designer.sqlgen.ui.PackageEditorInput.java

License:Open Source License

private String adjustName(String body) {
    final IParsingService parsingService = getParsingService();

    // Parsing name
    String parsedName = parsingService.parseName(IElementType.getInstance(IPackage.TYPE_ID), body);
    String renamedBody = body;/*  w  w w .  ja va2 s  .co  m*/
    if (parsedName != null && !parsedName.equalsIgnoreCase(getName())) {
        boolean confirmed = MessageDialog.openQuestion(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                SQLMessages.getString("rename.package.confirmTitle"), //$NON-NLS-1$
                SQLMessages.getString("rename.package.confirmMsg")); //$NON-NLS-1$
        if (confirmed) {
            // Renaming element
            pkg.setName(parsedName);
            // Renaming SPEC only (because BODY will be updated by the returned body string
            String newSpec = parsingService.getRenamedSql(IElementType.getInstance(IPackage.TYPE_ID),
                    pkg.getSpecSourceCode(), parsedName);
            pkg.setSpecSourceCode(newSpec);
            // Renaming body
            renamedBody = parsingService.getRenamedSql(IElementType.getInstance(IPackage.TYPE_ID), body,
                    parsedName);
        } else {
            // If user did not confirm, we restore original name on the BODY
            renamedBody = parsingService.getRenamedSql(IElementType.getInstance(IPackage.TYPE_ID), body,
                    pkg.getName());
        }
    }
    return renamedBody;
}

From source file:com.nextep.designer.sqlgen.ui.ProcedureEditorInput.java

License:Open Source License

private String adjustName(String sql) {
    final IParsingService parsingService = getParsingService();

    // Parsing name
    String parsedName = parsingService.parseName(IElementType.getInstance(IProcedure.TYPE_ID), sql);
    String renamedSql = sql;/*  w  w w  .  j av a 2 s.co  m*/
    if (parsedName != null && !parsedName.equalsIgnoreCase(getName())) {
        boolean confirmed = MessageDialog.openQuestion(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                SQLMessages.getString("rename.proc.confirmTitle"), //$NON-NLS-1$
                SQLMessages.getString("rename.proc.confirmMsg")); //$NON-NLS-1$
        if (confirmed) {
            // Renaming element
            procedure.setName(parsedName);
            // Renaming SQL which will be returned by this method
            renamedSql = parsingService.getRenamedSql(IElementType.getInstance(IProcedure.TYPE_ID), sql,
                    parsedName);
        } else {
            // If user did not confirm, we restore original name on the BODY
            renamedSql = parsingService.getRenamedSql(IElementType.getInstance(IProcedure.TYPE_ID), sql,
                    procedure.getName());
        }
    }
    return renamedSql;
}

From source file:com.nextep.designer.vcs.ui.controllers.MergeController.java

License:Open Source License

/**
 * @see com.nextep.datadesigner.gui.model.InvokableController#invoke(java.lang.Object)
 *//* w w  w .  j av  a 2  s  . c om*/
@Override
public Object invoke(Object... model) {
    if (model.length == 0) {
        throw new ErrorException("The merge controller need at least 1 non-null argument to proceed.");
    } else {
        final IVersionable<?> versionable = (IVersionable<?>) model[0];
        final MergeWizard wiz = new MergeWizard(new MergeInitGUI(versionable),
                new MergePreviewWizard(versionable));
        wiz.setToVersionable(versionable);
        WizardDialog w = new WizardDialog(
                VCSUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), wiz);
        w.setBlockOnOpen(true);
        w.open();
        if (w.getReturnCode() != Window.CANCEL) {
            // FIXME QUICKFIX calling this static method => TO remove !!!
            MergeStrategy.setIsGenerating(false);
            // try {
            final IMerger m = MergerFactory.getMerger(wiz.getToRelease());
            // Building compare command
            ICommand compareCommand = new ICommand() {

                @Override
                public Object execute(Object... parameters) {
                    return m.compare(wiz.getReference(), wiz.getFromRelease(), wiz.getToRelease(), true);
                }

                @Override
                public String getName() {
                    return "Computing differences between " + wiz.getToRelease().getLabel() + " and "
                            + wiz.getFromRelease().getLabel();
                }
            };
            final IComparisonItem comp = (IComparisonItem) CommandProgress.runWithProgress(compareCommand)
                    .iterator().next();

            ProgressMonitorDialog pd = new ProgressMonitorDialog(
                    VCSUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell());
            try {
                pd.run(true, false, new MergeProgress(comp, m));
            } catch (Exception e) {
                throw new ErrorException(e);
            }
            // } finally {
            MergeStrategy.setIsGenerating(true);
            // }
            MergeResultGUI mergeGUI = new MergeResultGUI(true, comp);
            mergeGUI.setIsRepositoryMerge(true);
            mergeGUI.setRootText(
                    "Source release " + wiz.getFromRelease().getLabel() + " ["
                            + wiz.getFromRelease().getBranch().getName() + "]",
                    "Current target release " + wiz.getToRelease().getLabel() + " ["
                            + wiz.getToRelease().getBranch().getName() + "]",
                    "Merge result");
            boolean doItAgain = true;
            while (doItAgain) {
                invokeGUI(new GUIWrapper(mergeGUI, "Merge results", 800, 600));
                // Checking that everything is resolved
                if (comp.getMergeInfo().getStatus() != MergeStatus.MERGE_RESOLVED) {
                    // IF not we ask if the user would like to edit again
                    doItAgain = MessageDialog.openQuestion(
                            VCSUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
                            VCSUIMessages.getString("mergeUnresolvedTitle"),
                            VCSUIMessages.getString("mergeUnresolved"));
                    if (!doItAgain) {
                        throw new CancelException("Merge operation aborted due to unresolved conflicts.");
                    }
                } else {
                    doItAgain = false;
                }
            }
            // We fall here if no cancel exception
            // HibernateUtil.getInstance().getSession().clear();
            // IdentifiableDAO.getInstance().loadAll(VersionReference.class);
            HibernateUtil.getInstance().clearAllSessions();
            pd = new ProgressMonitorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
            try {
                pd.run(false, false, new IRunnableWithProgress() {

                    @Override
                    public void run(IProgressMonitor monitor)
                            throws InvocationTargetException, InterruptedException {
                        monitor.beginTask("Merge in progress...", 5);
                        // Global listeners switch off
                        Observable.deactivateListeners();
                        // Refreshing progress
                        monitor.worked(1);
                        IVersionable<?> mergedObject = null;
                        try {
                            // Building the merge result
                            final String activityText = "Merged " + wiz.getFromRelease().getLabel() + " -> "
                                    + wiz.getFromRelease().getBranch().getName();
                            final IVersioningService versioningService = VCSPlugin
                                    .getService(IVersioningService.class);
                            final IActivity mergeActivity = versioningService.createActivity(activityText);
                            mergedObject = (IVersionable<?>) m.buildMergedObject(comp, mergeActivity);
                            // Checking if the merge did anything
                            if (mergedObject instanceof IVersionable<?>) {
                                if (((IVersionable<?>) mergedObject).getVersion()
                                        .getStatus() == IVersionStatus.CHECKED_IN) {
                                    final boolean forceMerge = MessageDialog.openQuestion(
                                            Display.getCurrent().getActiveShell(),
                                            VCSUIMessages.getString("mergeDidNothingTitle"),
                                            VCSUIMessages.getString("mergeDidNothing"));
                                    if (forceMerge) {
                                        comp.getMergeInfo().setMergeProposal(null);
                                        mergedObject = (IVersionable<?>) m.buildMergedObject(comp,
                                                mergeActivity);
                                    } else {
                                        return;
                                    }
                                }
                            }
                        } finally {
                            Observable.activateListeners();
                        }
                        log.info("Merged successfully!");
                        // Refreshing progress
                        monitor.worked(1);
                        monitor.setTaskName("Updating view contents...");

                        // Temporary bugfix for DES-710
                        // TODO refactor EVERYTHING as a service
                        final Session session = HibernateUtil.getInstance().getSandBoxSession();

                        // FIXME draft of view removal / addition of the merged object
                        // Switching versionables (for database only)
                        IVersionContainer parent = versionable.getContainer();
                        // First removing current versionable in current session
                        parent.getContents().remove(versionable);
                        versionable.setContainer(null);

                        // Forcing save of module without parent
                        final IIdentifiableDAO identifiableDao = CorePlugin.getIdentifiableDao();
                        identifiableDao.save(parent);
                        // Refreshing progress
                        monitor.worked(1);
                        // Reloading parent container in sandbox (because merged object is in
                        // sandbox)

                        if (parent instanceof IWorkspace) {
                            parent = (IVersionContainer) identifiableDao.load(Workspace.class, parent.getUID(),
                                    session, false);
                        } else {
                            parent = (IVersionContainer) identifiableDao.load(IVersionable.class,
                                    parent.getUID(), session, false);
                        }
                        // Refreshing progress
                        monitor.worked(1);
                        monitor.setTaskName("Committing to repository...");
                        // Adding sandbox merged object
                        mergedObject.setContainer(parent);
                        parent.getContents().add(mergedObject);
                        // Saving to sandbox before reloading view

                        identifiableDao.save(mergedObject);
                        session.flush();
                        // **************
                        // DES-710 urgent workaround
                        // Hibernate does not properly send the INSERT statements to the db
                        // But logs it properly in the logs !
                        final IRepositoryService repositoryService = CorePlugin.getRepositoryService();
                        final IDatabaseConnector connector = repositoryService.getRepositoryConnector();
                        final IConnection repositoryConnection = repositoryService.getRepositoryConnection();
                        Connection conn = null;
                        PreparedStatement stmt = null;
                        try {
                            conn = connector.connect(repositoryConnection);
                            String insertSql = null;
                            if (parent instanceof IWorkspace) {
                                insertSql = "INSERT INTO REP_VIEW_CONTENTS (VIEW_ID,VERSION_ID) VALUES (?,?)"; //$NON-NLS-1$
                            } else {
                                insertSql = "INSERT INTO REP_MODULE_CONTENTS (MODULE_ID,VERSION_ID) VALUES (?,?)"; //$NON-NLS-1$
                            }
                            stmt = conn.prepareStatement(insertSql);
                            stmt.setLong(1, parent.getUID().rawId());
                            stmt.setLong(2, mergedObject.getUID().rawId());
                            stmt.execute();
                            if (!conn.getAutoCommit()) {
                                conn.commit();
                            }
                        } catch (SQLException e) {
                            log.error(e);
                        } finally {
                            if (stmt != null) {
                                try {
                                    stmt.close();
                                } catch (SQLException e) {
                                    log.error(e);
                                }
                            }
                            if (conn != null) {
                                try {
                                    conn.close();
                                } catch (SQLException e) {
                                    log.error(e);
                                }
                            }
                        }
                        // End of DES-710 workaround
                        // **************

                        // HibernateUtil.getInstance().reconnectAll();
                        // Merger.save(mergedObject);
                        // Merger.save(parent);
                        monitor.worked(1);
                        log.info("Please wait while view is reloading...");
                        monitor.setTaskName("Finished: Reloading view...");
                        monitor.done();
                        // END OF the fixme part

                    }

                });
            } catch (Exception e) {
                throw new ErrorException(e);
            }

            // Restoring a new view
            log.info("Refreshing current view");
            VersionUIHelper.changeView(VersionHelper.getCurrentView().getUID());

            // Designer.getInstance().invokeSelection("com.neXtep.designer.vcs.SelectionInvoker",
            // "version.compare", comp);
        }
    }
    return null;
}

From source file:com.nextep.designer.vcs.ui.controllers.ReloadViewInvoker.java

License:Open Source License

@Override
public Object invoke(Object... arg) {
    boolean reload = true;
    if (arg.length == 0) {
        if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
            reload = MessageDialog.openQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    VCSUIMessages.getString("reloadViewPromptTitle"),
                    VCSUIMessages.getString("reloadViewPrompt"));
        } else {//from   ww  w .j av a 2  s. c om
            reload = true;
        }
    }
    if (reload) {
        final IWorkspaceService viewService = getViewService();
        // Saving preivous view instance reference (because some listeners point to it)
        final IWorkspace v = viewService.getCurrentWorkspace();
        // Reloading view (creates a new view instance)
        viewService.changeWorkspace(viewService.getCurrentWorkspace().getUID(), new NullProgressMonitor());

        // Switching listeners to listen to the new view instance
        Designer.getListenerService().switchListeners(v, viewService.getCurrentWorkspace());
        for (IEventListener l : new ArrayList<IEventListener>(v.getListeners())) {
            Designer.getListenerService().unregisterListener(v, l);
        }

        // Changing opened editors' model: since the view has been reloaded, edited
        // objects are deprecated
        // and new instances have been loaded to represent the new database status.
        // We will now browse all opened editors to map the previously edited item
        // instance with the new one
        final IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                .getActivePage().getEditorReferences();
        final List<IEditorReference> editorsToClose = new ArrayList<IEditorReference>();
        for (IEditorReference r : editorRefs) {
            try {
                // We consider editors whose input contains a model, that is to say they
                // implement IModelOriented
                if (r.getEditorInput() instanceof IModelOriented) {
                    final IReferenceable element = (IReferenceable) r.getEditorInput()
                            .getAdapter(IReferenceable.class);
                    // To have a chance to convert their input, we need the model to be
                    // referenceable
                    if (element != null) {
                        final IReference ref = element.getReference();
                        // Trying to locate new referenced model through the reference
                        // manager
                        IReferenceable newElement = VersionHelper.getReferencedItem(ref);
                        if (newElement != null) {
                            // Switching listeners
                            Designer.getListenerService().switchListeners((IObservable) element,
                                    (IObservable) newElement);
                            // Here we are, changing model (may already be done through
                            // the listeners switch)
                            ((IModelOriented) r.getEditorInput()).setModel(newElement);

                        } else {
                            // No reference found, closing...
                            editorsToClose.add(r);
                        }
                    } else {
                        // Not a referenceable element, closing editor
                        editorsToClose.add(r);
                    }
                }
            } catch (PartInitException e) {
                // Problems to retrieve the input, closing
                editorsToClose.add(r);
            }
        }
        // Closing all remaining editors (it is much likely editors on object which do
        // no more
        // exist in the new reloaded view)
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
                .closeEditors(editorsToClose.toArray(new IEditorReference[editorsToClose.size()]), false);
    }
    return null;
}

From source file:com.nextep.designer.vcs.ui.controllers.RepositoryFileController.java

License:Open Source License

@Override
public void defaultOpen(ITypedObject model) {
    IRepositoryFile file = (IRepositoryFile) model;
    if (file.getFileSizeKB() > 20000) {
        boolean isOK = MessageDialog.openQuestion(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Large file warning",
                MessageFormat.format(VCSUIMessages.getString("repositoryFileLargeWarn"),
                        String.valueOf(file.getFileSizeKB())));
        if (!isOK) {
            return;
        }/* www. j av a 2s .  c om*/
    }
    super.defaultOpen(model);
}

From source file:com.nextep.designer.vcs.ui.dialogs.ViewSelectorDialog.java

License:Open Source License

/**
 * Configures the viewer which displays workspaces.<br>
 * The setup is a bit tricky as we need a "button" behaviour which reacts on the deletion
 * column, thus allowing the user to remove a view. We do this by adding an editor which fires
 * the deletion on activation. The way JFace performs editor checks impose us to add cell
 * modifier and label properties as well.<br>
 * Because of JFace, the order in which elements are added are <b>very important</b> as editors
 * and modifiers need to be added <u>before</u> label providers.
 *///from   w  w w . ja  v a  2 s . c  om
private void configureTableViewer() {
    viewer = new TableViewer(viewsTable);
    viewer.setCellEditors(new CellEditor[] { null, null, null, new CellEditor() {

        @Override
        public void activate() {
            ISelection s = viewer.getSelection();
            if (s instanceof IStructuredSelection) {
                final IWorkspace view = (IWorkspace) ((IStructuredSelection) s).getFirstElement();
                boolean confirm = MessageDialog.openQuestion(viewsTable.getShell(),
                        MessageFormat.format(VCSUIMessages.getString("delViewConfirmTitle"), //$NON-NLS-1$
                                view.getName()),
                        MessageFormat.format(VCSUIMessages.getString("delViewConfirm"), view.getName())); //$NON-NLS-1$
                if (confirm) {
                    final IWorkspace originalView = getViewService().getCurrentWorkspace();
                    try {
                        getViewService().setCurrentWorkspace(view);
                        deleteView(view);
                    } finally {
                        getViewService().setCurrentWorkspace(originalView);
                    }
                    refreshGUI();
                }
            }
        }

        @Override
        protected Control createControl(Composite parent) {
            return null;
        }

        @Override
        protected Object doGetValue() {
            return null;
        }

        @Override
        protected void doSetFocus() {
        }

        @Override
        protected void doSetValue(Object value) {
        }
    } });
    viewer.setColumnProperties(new String[] { "name", "vendor", "desc", "del" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    viewer.setCellModifier(new ICellModifier() {

        @Override
        public void modify(Object element, String property, Object value) {
        }

        @Override
        public Object getValue(Object element, String property) {
            return null;
        }

        @Override
        public boolean canModify(Object element, String property) {
            return "del".equals(property); //$NON-NLS-1$
        }
    });
    viewer.setComparator(new TableColumnSorter(viewsTable, viewer));
    viewer.setContentProvider(new WorkspaceContentProvider());
    viewer.setLabelProvider(new WorkspaceLabelProvider());
}

From source file:com.nextep.designer.vcs.ui.dialogs.ViewSelectorDialog.java

License:Open Source License

private void deleteView(IWorkspace view) {
    if (view == null)
        return;/* w ww  .j  a v  a2 s. c o m*/
    // Checking checkout state
    boolean hasCheckouts = false;
    view = (IWorkspace) CorePlugin.getIdentifiableDao().load(Workspace.class, view.getUID());
    for (IVersionable<?> v : view.getContents()) {
        if (v.getVersion().getStatus() != IVersionStatus.CHECKED_IN) {
            hasCheckouts = true;
            break;
        }
    }
    if (hasCheckouts) {
        final boolean confirmed = MessageDialog.openQuestion(null,
                VCSUIMessages.getString("delViewWithCheckoutsConfirmTitle"), //$NON-NLS-1$
                VCSUIMessages.getString("delViewWithCheckoutsConfirm")); //$NON-NLS-1$
        if (!confirmed) {
            return;
        }
    }
    ControllerFactory.getController(view.getType()).modelDeleted(view);
}

From source file:com.nokia.carbide.cdt.builder.builder.CarbideCPPBuilder.java

License:Open Source License

private static void buildSisFile(final ISISBuilderInfo sisInfo, final ICarbideBuildConfiguration config,
        CarbideCommandLauncher cmdLauncher, IProgressMonitor monitor, boolean createOutputFromPKGFileName) {
    IPath pkgPath = sisInfo.getPKGFullPath();
    if (pkgPath == null) {
        cmdLauncher.writeToConsole("PKG file does not exist.  Skipping...");
        return;/*from   w ww  . j a  v a  2  s  .  c o m*/
    } else if (!pkgPath.toFile().exists()) {

        // Check to see if this is a Qt project and if the template format could have changed.
        IProject project = config.getCarbideProject().getProject();
        if (QtCorePlugin.isQtProject(project)) {
            final String currentPKGName = pkgPath.lastSegment();
            pkgPath = pkgPath.removeLastSegments(1).append(project.getName() + "_template.pkg"); //$NON-NLS-N$
            if (pkgPath.toFile().exists()) {

                final IPath finalPkgPath = pkgPath;
                Display.getDefault().syncExec(new Runnable() {
                    public void run() {
                        if (true == MessageDialog.openQuestion(WorkbenchUtils.getSafeShell(),
                                "Can not find PKG file for SIS builder", //$NON-NLS-1$
                                "The file \"" + currentPKGName //$NON-NLS-1$
                                        + "\" does not exist for this Qt project. The suggested file is \""
                                        + finalPkgPath.lastSegment()
                                        + "\".\n\nDo you want to update your build configuration to use this PKG file?")) {
                            IWorkspace workspace = ResourcesPlugin.getWorkspace();
                            IFile ifile = workspace.getRoot().getFileForLocation(finalPkgPath);
                            sisInfo.setPKGFile(ifile.getLocation().toOSString());
                            config.getSISBuilderInfoList().remove(sisInfo);
                            config.getSISBuilderInfoList().add(sisInfo);
                            config.saveConfiguration(false);
                        }
                    }
                });
            }
        }

        if (!sisInfo.getPKGFullPath().toFile().exists()) {
            cmdLauncher.writeToConsole("PKG file " + pkgPath.toOSString() + " does not exist.  Skipping..."); //$NON-NLS-N$
            return;
        }
    }

    // see if we need to rebuild the sis file
    boolean shouldBuild = false;

    String sisName = createOutputFromPKGFileName
            ? pkgPath.toOSString().substring(0, pkgPath.toOSString().lastIndexOf(".")) + ".sis"
            : sisInfo.getUnsignedSISFullPath().toOSString();
    File sisFile = new File(sisName);
    if (!sisFile.exists()) {
        // no sis file - need to build
        shouldBuild = true;
    } else {
        long sisFileTimestamp = sisFile.lastModified();

        // see if the pkg file is newer than the sis
        if (pkgPath.toFile().lastModified() > sisFileTimestamp) {
            shouldBuild = true;
        } else {
            // get the list of files from the pkg file and check for their existence
            for (IPath path : EpocEngineHelper.getFilesInPKG(pkgPath, config, sisInfo)) {
                File file = path.toFile();
                if (!file.exists()) {
                    shouldBuild = true;
                    break;
                }
            }
        }
    }

    if (!shouldBuild) {
        // see if they have changed any sis builder settings since the
        // last build
        if (sisInfo instanceof SISBuilderInfo2) {
            SISBuilderInfo2 info = (SISBuilderInfo2) sisInfo;
            if (info.hasSisChanges()) {
                shouldBuild = true;
            }
        }
    }

    // check to see if any of the files listed in the pkg have changed since the sis file
    // was last built.  remember the list of files that have changed in case we're building
    // a partial upgrade
    boolean creatingPU = false;
    boolean createPartialUpgradeEnabled = false;
    if (sisInfo instanceof SISBuilderInfo2) {
        createPartialUpgradeEnabled = ((SISBuilderInfo2) sisInfo).isPartialUpgrade();
    }
    final List<File> modifiedFiles = new ArrayList<File>();

    if (!shouldBuild) {
        long sisFileTimestamp = sisFile.lastModified();
        for (IPath path : EpocEngineHelper.getFilesInPKG(pkgPath, config, sisInfo)) {
            if (path.toFile().lastModified() > sisFileTimestamp) {
                // file has changed since the sis was built
                shouldBuild = true;
                if (createPartialUpgradeEnabled) {
                    modifiedFiles.add(path.toFile());
                } else {
                    break;
                }
            }
        }
    }

    SubMonitor subMonitor = SubMonitor.convert(monitor, 1);

    if (shouldBuild) {
        if (sisInfo instanceof SISBuilderInfo2) {
            SISBuilderInfo2 info = (SISBuilderInfo2) sisInfo;
            info.setHasSisChanges(false);
        }

        subMonitor.setTaskName("Building sis file");

        // put temp _resolved.pkg file in epoc32/build tree
        IPath buildDirPath = getBuilder(config.getCarbideProject().getProject()).getMakefileDirectory(config);
        String prefix = RESOLVED_PKG_PREFIX;

        IPath tmpPKGPath = buildDirPath.append(prefix + pkgPath.lastSegment());

        IPath resolvedPKGPath = resolvePKGFile(pkgPath, config.getBuildContext(), tmpPKGPath);

        List<String> args = new ArrayList<String>();

        // add the search location if specified
        String searchDir = sisInfo.getContentSearchLocation();
        if (searchDir != null && searchDir.length() > 0) {
            args.add("-d" + searchDir);
        }

        args.add(resolvedPKGPath.toOSString());
        args.add(sisName);

        IPath makeSisPath = config.getSDK().getToolsPath().append(MAKESIS_EXE);

        cmdLauncher.writeToConsole("\n***Invoking " + MAKESIS_EXE + " ....\n");
        cmdLauncher.setErrorParserManager(pkgPath.removeLastSegments(1),
                getParserIdArray(ICarbideBuildConfiguration.ERROR_PARSERS_SIS_BUILDER));
        int retVal = cmdLauncher.executeCommand(makeSisPath, args.toArray(new String[args.size()]),
                getResolvedEnvVars(config), pkgPath.removeLastSegments(1));

        subMonitor.worked(1);
        if (subMonitor.isCanceled()) {
            return;
        }

        if (retVal != 0) {
            cmdLauncher.writeToConsole(
                    "***Non-Zero Status: " + MAKESIS_EXE + " returned with exit value = " + retVal);
            CarbideBuilderPlugin.createCarbideProjectMarker(config.getCarbideProject().getProject(),
                    IMarker.SEVERITY_ERROR, MAKESIS_EXE + " returned with exit value = " + retVal,
                    IMarker.PRIORITY_LOW);
            return;
        }

        // now create the partial upgrade sis file if necessary
        if (createPartialUpgradeEnabled && modifiedFiles.size() > 0) {
            creatingPU = true;

            if (!createPartialUpgradeSis(sisInfo, config, cmdLauncher, subMonitor, createOutputFromPKGFileName,
                    modifiedFiles)) {
                return;
            }
        } else {
            // delete the partial upgrade files and links if they exist since they are now obsolete
            IFile tempPkgFileLink = getTempPkgIFile(pkgPath, getTempPkgBuildTreePath(sisInfo, config), config);
            if (tempPkgFileLink.exists()) {
                try {
                    tempPkgFileLink.getRawLocation().toFile().delete();
                    tempPkgFileLink.delete(0, null);
                } catch (CoreException e) {
                    e.printStackTrace();
                    CarbideBuilderPlugin.log(e);
                }
            }

            IPath tempPkgBuildTreePath = getTempPkgBuildTreePath(sisInfo, config);
            IFile tempSisFileLink = getTempSisIFile(pkgPath,
                    getPUSisPath(sisInfo, tempPkgBuildTreePath, createOutputFromPKGFileName, false), config);
            if (tempSisFileLink.exists()) {
                try {
                    tempSisFileLink.getRawLocation().toFile().delete();
                    tempSisFileLink.delete(0, null);
                } catch (CoreException e) {
                    e.printStackTrace();
                    CarbideBuilderPlugin.log(e);
                }
            }
        }
    } else {
        subMonitor.worked(1);
        if (subMonitor.isCanceled()) {
            return;
        }

        cmdLauncher.writeToConsole(
                "\nSIS file " + sisFile.getAbsolutePath() + " already up to date.  Skipping...");
    }

    buildSisxFile(sisInfo, config, cmdLauncher, monitor, createOutputFromPKGFileName, sisFile, creatingPU);

    cmdLauncher.writeToConsole("\n***SIS Creation Complete\n");
}

From source file:com.nokia.carbide.cdt.internal.builder.ui.CarbideBuildConfigurationsPage.java

License:Open Source License

private void handleConfigurationChangeEvent(boolean comparePrefs) {
    if (lastSelectedConfigName.length() == 0) {
        lastSelectedConfigName = buildConfigurationCombo.getText();
        return;/*from  ww w  . j  av  a2  s.c  o  m*/
    }

    ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(project);
    if (cpi != null) {
        ICarbideBuildConfiguration selectedConfig = cpi.getNamedConfiguration(lastSelectedConfigName);
        if (selectedConfig == null) {
            return;
        }

        if (comparePrefs) {
            if (!compareConfigurationSettings(selectedConfig, false)) {
                // message box that stuff has changed, do you want to save?
                if (true == MessageDialog.openQuestion(getShell(),
                        Messages.getString("CarbideBuildConfigurationsPage.Apply_Configuration_Changes"), //$NON-NLS-1$
                        Messages.getString("CarbideBuildConfigurationsPage.Apply_Config_Changes_Msg"))) { //$NON-NLS-1$
                    // save the configuration data...
                    saveConfigurationSettings(selectedConfig);
                }
            }
        }
    } else {
        return; // can't do anything without ICarbideProjectInfo...
    }

    // Load the new data...
    lastSelectedConfigName = buildConfigurationCombo.getText();
    ICarbideBuildConfiguration lastConfig = cpi.getNamedConfiguration(lastSelectedConfigName);
    if (lastConfig != null) {
        sisFilesBlock.initData(lastConfig);

        setUpEnvVarsTable(new String[0], null); // refresh env vars info
        if (argumentsTabcomposite != null) {
            argumentsTabcomposite.initData(lastConfig);
        }
        pathsAndSymbolsTabComposite.initData(lastConfig);
    }
}