Package org.openquark.cal.services

Examples of org.openquark.cal.services.Status


   
                    ValueNode targetValue = null;
                    try {
                        targetValue = gemCutter.getValueRunner().getValue(valueTarget, workingModuleName);
                    } catch (TargetRunner.ProgramCompileException pce) {
                        status.add(new Status(Status.Severity.ERROR, "Error updating value gem. Can't compile the following text: " + updatedValueString));
                    }
                   
                    if (targetValue == null) {
                        status.add(new Status(Status.Severity.ERROR, "Error updating value gem. Can't convert the following text to a value node: " + updatedValueString));
                    }
                   
                    vGem.changeValue(targetValue);
                }
            }
View Full Code Here


        // This may take a while, so set the cursor.
        Cursor oldCursor = getCursor();
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
       
        try{
            Status syncStatus = new Status(getResourceString("SyncWorkspaceStatus"));
            CALWorkspace workspace = getWorkspace();
            CALWorkspace.SyncInfo syncInfo = new CALWorkspace.SyncInfo();
           
            for (final ModuleRevision moduleRevision : moduleRevisions) {
                CALWorkspace.SyncInfo newSyncInfo =
View Full Code Here

     * Handle the situation where the user has indicated that they would like to deploy the current workspace.
     * @param vault the vault to which to deploy the new workspace.
     */
    private void handleDeployWorkspaceAction(Vault vault) {

        Status deployStatus = new Status("Deploy status");

        // Map from module name to the latest revision identical to the current form of that module, if any.
        Map<ModuleName, Integer> moduleNameToExistingRevisionMap = new HashMap<ModuleName, Integer>();
       
        // Iterate over the modules in the workspace.
        ModuleName[] moduleNames = getWorkspace().getModuleNames();
       
        DeployWorkspaceDialog.ModuleRevisionInfo[] moduleRevisions = new DeployWorkspaceDialog.ModuleRevisionInfo[moduleNames.length];
        for (int i = 0; i < moduleNames.length; i++) {
            ModuleName moduleName = moduleNames[i];
           
            // TODOEL: should we try to add getLatestIdenticalRevision() to the vault interface?
            int latestIdenticalRevision =
                enterpriseSupport.getLatestIdenticalRevisionFromMaybeEnterpriseVault(vault, moduleName, getWorkspace(), deployStatus);

            if (latestIdenticalRevision > 0) {
                // An identical revision already exists.
                moduleRevisions[i] = new DeployWorkspaceDialog.ModuleRevisionInfo(moduleName, latestIdenticalRevision, false);
                moduleNameToExistingRevisionMap.put(moduleName, new Integer(latestIdenticalRevision));
           
            } else {
                // We must deploy a new revision of the module.
                RevisionHistory revisionHistory = vault.getModuleRevisionHistory(moduleName);
                int latestRevision = revisionHistory.getLatestRevision();
                int revisionToDeploy = (latestRevision < 0) ? 1 : latestRevision + 1;
                moduleRevisions[i] = new DeployWorkspaceDialog.ModuleRevisionInfo(moduleName, revisionToDeploy, true);
            }
        }
       
        // Handle any errors (in vaultStatus) getting the latest revision info.
        if (deployStatus.getSeverity().compareTo(Status.Severity.ERROR) >= 0) {
            JOptionPane.showMessageDialog(this, deployStatus.getDebugMessage(),
                                          getResourceString("DeployWorkspaceFailedTitle"), JOptionPane.ERROR_MESSAGE);
            return;
        }
       
       
        // Display the dialog for deploying the workspace.
        String[] availableWorkspaceDeclarations = vault.getAvailableWorkspaceDeclarations(deployStatus);
       
        DeployWorkspaceDialog deployWorkspaceDialog = new DeployWorkspaceDialog(GemCutter.this, moduleRevisions, availableWorkspaceDeclarations);
        boolean accepted = deployWorkspaceDialog.doModal();
       
        if (!accepted) {
            return;
        }

        // Map from module name to the deployed revision for that module.
        Map<ModuleName, Integer> moduleNameToDeployedRevisionMap = new TreeMap<ModuleName, Integer>();   

        // Get the result, and deploy...
        DeployWorkspaceDialog.DeployDialogResult result = deployWorkspaceDialog.getResult();

        ModuleName[] modulesToDeploy = result.getModulesToDeploy();
        for (final ModuleName moduleToDeploy : modulesToDeploy) {
            Integer existingRevisionInteger = moduleNameToExistingRevisionMap.get(moduleToDeploy);
            if (existingRevisionInteger != null) {
                // Don't need to add the module to the vault.  Just reuse the revision number
                moduleNameToDeployedRevisionMap.put(moduleToDeploy, existingRevisionInteger);
               
            } else {
                // Actually add the module to the vault.
                int addedRevisionNumber = vault.putStoredModule(moduleToDeploy, getWorkspace(), deployStatus);
               
                // Remember the revision number which was added, so we can use it in the workspace declaration.
                moduleNameToDeployedRevisionMap.put(moduleToDeploy, new Integer(addedRevisionNumber));
            }
        }
       
        // Handle any errors (in vaultStatus) adding the module revisions.
        if (deployStatus.getSeverity().compareTo(Status.Severity.ERROR) >= 0) {
            JOptionPane.showMessageDialog(this, deployStatus.getDebugMessage(),
                                          getResourceString("DeployWorkspaceFailedTitle"), JOptionPane.ERROR_MESSAGE);
            return;
        }
       
        // Now deploy the workspace file..
        String workspaceDeclarationName = result.getWorkspaceName();
       
        String vaultDescriptor = vault.getVaultProvider().getVaultDescriptor();
        String vaultLocation = vault.getLocationString();
       
        VaultElementInfo[] vaultModuleInfo = new VaultElementInfo[moduleNameToDeployedRevisionMap.size()];
       
        int index = 0;
        for (final Map.Entry<ModuleName, Integer> mapEntry : moduleNameToDeployedRevisionMap.entrySet()) {
            String moduleName = mapEntry.getKey().toString();
            int deployedRevisionNum = mapEntry.getValue().intValue();
           
            vaultModuleInfo[index] = VaultElementInfo.makeBasic(vaultDescriptor, moduleName, vaultLocation, deployedRevisionNum);
            index++;
        }
       
        // Create the workspace declaration.
        WorkspaceDeclaration workspaceDeclaration = new WorkspaceDeclaration(vaultModuleInfo);
       
        // Put the declaration in the vault.
        vault.putWorkspaceDeclaration(workspaceDeclarationName, workspaceDeclaration, deployStatus);

        // Handle any errors (in vaultStatus) adding the workspace deployment.
        if (deployStatus.getSeverity().compareTo(Status.Severity.ERROR) >= 0) {
            JOptionPane.showMessageDialog(this, deployStatus.getDebugMessage(),
                                          getResourceString("DeployWorkspaceFailedTitle"), JOptionPane.ERROR_MESSAGE);
            return;
        }
    }
View Full Code Here

        RenameRefactoringDialog.Result renameResult = renameDialog.display();
        if (renameResult != null) {
            QualifiedName qualifiedFromName = QualifiedName.makeFromCompoundName(renameResult.getFromName());
            QualifiedName qualifiedToName = QualifiedName.makeFromCompoundName(renameResult.getToName());
            try {
                GemCutterRenameUpdater designUpdater = new GemCutterRenameUpdater(new Status("GemGraph update status"), getTypeChecker(), qualifiedToName, qualifiedFromName, renameResult.getCategory());
                designUpdater.updateTableTop(this);
            } catch (GemEntityNotPresentException fanpe) {
                // Couldn't reload the functional agent for one of the gems.              
                JOptionPane.showMessageDialog(this, "Error reloading functional agent: " + fanpe.getEntityName(),
                        "Reload error", JOptionPane.WARNING_MESSAGE);
View Full Code Here

        RenameRefactoringDialog.Result renameResult = renameDialog.display();
        if (renameResult != null) {
            QualifiedName qualifiedFromName = QualifiedName.make(ModuleName.make(renameResult.getFromName()), Refactorer.Rename.UNQUALIFIED_NAME_FOR_MODULE_RENAMING);
            QualifiedName qualifiedToName = QualifiedName.make(ModuleName.make(renameResult.getToName()), Refactorer.Rename.UNQUALIFIED_NAME_FOR_MODULE_RENAMING);
            try {
                GemCutterRenameUpdater designUpdater = new GemCutterRenameUpdater(new Status("GemGraph update status"), getTypeChecker(), qualifiedToName, qualifiedFromName, renameResult.getCategory());
                designUpdater.updateTableTop(this);
            } catch (GemEntityNotPresentException fanpe) {
                // Couldn't reload the functional agent for one of the gems.
                JOptionPane.showMessageDialog(this, "Error reloading functional agent: " + fanpe.getEntityName(),
                        "Reload error", JOptionPane.WARNING_MESSAGE);
View Full Code Here

   
        if (!saveDialog.isDialogAccepted()) {
            return false;
        }

        Status saveStatus = persistenceManager.saveGem(targetCollector, saveDialog.getScope());
       
        if (saveStatus.getSeverity() != Status.Severity.ERROR) {
            // Get the entity for the newly saved gem.
            GemEntity newGemEntity = getWorkspace().getGemEntity(gemName);
           
            BrowserTree browserTree = getGemBrowser().getBrowserTree();
            //BrowserTreeModel browserTreeModel = (BrowserTreeModel) browserTree.getModel();
           
            // Select the newly saved gem in the gem browser.
            browserTree.selectGemNode(newGemEntity);
           
            // Refresh the tree node associated with this gem entity
            //browserTreeModel.getTreeNode(newGemEntity).refreshNode();
           
            if (saveStatus.getSeverity() == Status.Severity.WARNING) {
                JOptionPane.showMessageDialog(this, saveStatus.getDebugMessage(), getResourceString("SaveGem_SavedWithWarnings"), JOptionPane.WARNING_MESSAGE);
            } else {
                statusMessageManager.displayMessage(this, getResourceString("SaveGem_SaveSuccessful"), StatusMessageDisplayer.MessageType.TRANSIENT, true);
            }

            // Update the dirty edit
            editToUndoWhenNonDirty = extendedUndoManager.editToBeUndone();
            updateWindowTitle();
       
        } else {
            JOptionPane.showMessageDialog(this, saveStatus.getDebugMessage(), getResourceString("SaveGem_SaveFailed"), JOptionPane.ERROR_MESSAGE);
            return false;
        }
        return true;
   
    }
View Full Code Here

       
        if (!promptSaveCurrentTableTopIfNonEmpty(null, null)){
            return;
        }
       
        Status loadStatus = new Status("GemDesignLoadStatus");
       
        if (gemEntity != null) {
            persistenceManager.loadGemDesign(gemEntity, loadStatus);
            if (loadStatus.isOK()) {
                // select the gem in the browser
                getGemBrowser().getBrowserTree().selectGemNode(gemEntity);
            }
        } else {
           
            // Display a dialog for the user to pick a design to load.
            FileFilter fileFilter = new ExtensionFileFilter(XMLPersistenceConstants.XML_FILE_EXTENSION, getResourceString("OpenDesign_FileDescription"));
       
            String initialDir = getPreferences().get(OPEN_DESIGN_DIRECTORY_PREF_KEY, OPEN_DESIGN_DIRECTORY_DEFAULT);
           
            JFileChooser fileChooser = new JFileChooser(initialDir);
            fileChooser.setFileFilter(fileFilter);
       
            int chooserOption = fileChooser.showOpenDialog(this);
            if (chooserOption != JFileChooser.APPROVE_OPTION) {
                return;
            }
           
            // Save the directory the user browsed to for next time
            String lastDir = fileChooser.getSelectedFile().getParentFile().getAbsolutePath();
            getPreferences().put(OPEN_DESIGN_DIRECTORY_PREF_KEY, lastDir);
   
            String fileName = fileChooser.getSelectedFile().getAbsolutePath();
            File designFile = new File(fileName);
           
            GemDesign gemDesign = GemDesign.loadGemDesign(designFile, loadStatus);
            QualifiedName designName = gemDesign.getDesignName();
           
            if (designName != null && getWorkspace().getMetaModule(designName.getModuleName()) == null) {

                // If the module the design is from does not exist, ask the user if he wants
                // to load the design in the current module.
               
                int result = JOptionPane.showConfirmDialog(this,
                                                           getResourceString("OpenDesign_ModuleNotOpen"),                                                          
                                                           getResourceString("OpenDesign_ConfirmDialogTitle"),
                                                           JOptionPane.OK_CANCEL_OPTION);
               
                if (result == JOptionPane.CANCEL_OPTION) {
                    return;
                }
            }
           
            persistenceManager.loadGemDesign(gemDesign, loadStatus);
        }
       
        if (!loadStatus.isOK()) {
            String title = getResourceString("WarningDialogTitle");
            String message = getResourceString("OpenErrorsWarning");
            String details = loadStatus.getDebugMessage();
            DetailsDialog dialog = new DetailsDialog(this, title, message, details, DetailsDialog.MessageType.WARNING);
            dialog.doModal();
        }
           
        // reset the table top explorer
View Full Code Here

     */
    public CALFeatureMetadata getMetadata(CALFeatureName featureName, Locale locale) {
       
        LocalizedResourceName resourceName = new LocalizedResourceName(featureName, locale);
        InputStream metadataInputStream;
        Status loadStatus = null;
        CALFeatureMetadata metadata;
       
        // Keep track of the originally requested locale
        Locale originalLocale = locale;
       
        synchronized (cacheLock) {
           
            // Check if we already have this cached
            MetadataCacheEntry cacheEntry = metadataCache.get(resourceName);
            if (cacheEntry != null) {
                return cacheEntry.getMetadata();
            }
           
            // Get the input stream for the metadata, and use this to load.
            metadataInputStream = metadataStore.getInputStream(resourceName);
           
            // go through the fallback mechanism if necessary
           
            // variant-specific locale not found, fallback to country-specific locale
            if (metadataInputStream == null && locale.getVariant().length() > 0) {
                locale = new Locale(locale.getLanguage(), locale.getCountry());
                resourceName = new LocalizedResourceName(featureName, locale);
                metadataInputStream = metadataStore.getInputStream(resourceName);
            }
           
            // country-specific locale not found, fallback to language-specific locale
            if (metadataInputStream == null && locale.getCountry().length() > 0) {
                locale = new Locale(locale.getLanguage());
                resourceName = new LocalizedResourceName(featureName, locale);
                metadataInputStream = metadataStore.getInputStream(resourceName);
            }
           
            // language-specific locale not found, fallback to neutral locale
            if (metadataInputStream == null) {
                locale = LocaleUtilities.INVARIANT_LOCALE;
                resourceName = new LocalizedResourceName(featureName, locale);
                metadataInputStream = metadataStore.getInputStream(resourceName);
            }
           
            if (metadataInputStream == null) {
                metadata = getEmptyMetadata(featureName, originalLocale);

            } else {
                loadStatus = new Status("Load status");
                // note that we pass in the original locale unaffected
                // by the fallback mechanism - this is done on purpose: once the
                // fallback mechanism finds the proper resource to load, its content
                // is treated as though it is the metadata for the originally requested locale.
                metadata = MetadataPersistenceHelper.loadMetadata(featureName, originalLocale, metadataInputStream, loadStatus);
            }
           
            // Add to the cache.
            cacheEntry = new MetadataCacheEntry(metadata);
            metadataCache.put(cacheEntry);
        }
       
        if (loadStatus != null && loadStatus.getSeverity().compareTo(Status.Severity.WARNING) >= 0) {
            METADATA_LOGGER.log(Level.WARNING, "Problems were encountered loading metadata for " + featureName);
            METADATA_LOGGER.log(Level.WARNING, loadStatus.getDebugMessage());
        }
       
        // Make sure we close any open stream.
        if (metadataInputStream != null) {
            try {
View Full Code Here

        enterpriseSupport.registerEnterpriseVaultProvider(workspaceManager.getWorkspace());
       
        // Register the CE vault authenticator.
        enterpriseSupport.registerEnterpriseVaultAuthenticator(getWorkspace(), GemCutter.this);
       
        Status initStatus = new Status("Init status.");
       
        String defaultStandardVaultWorkspaceName = System.getProperty (GEMCUTTER_PROP_DEFAULT_STANDARD_VAULT_WORKSPACE, defaultWorkspaceFile);

        // Create a default workspace declaration provider if none is provided.
        if (workspaceDeclarationStreamProvider == null) {
            workspaceDeclarationStreamProvider =
                DefaultWorkspaceDeclarationProvider.getDefaultWorkspaceDeclarationProvider(GEMCUTTER_PROP_WORKSPACE_FILE, defaultStandardVaultWorkspaceName);
        }
       
        // Init the workspace.
        workspaceManager.initWorkspace(workspaceDeclarationStreamProvider, initStatus);
       
        // TODOEL how to handle this?
        // Ask the user if they would like to load a default workspace, or something..
        if (initStatus.getSeverity().compareTo(Status.Severity.WARNING) >= 0) {
            String title = getResourceString("WindowTitle");
            String message = "Problems were encountered loading the workspace.";
            String details = initStatus.getDebugMessage();
           
            DetailsDialog.MessageType messageType = initStatus.getSeverity() == Status.Severity.WARNING ?
                        DetailsDialog.MessageType.WARNING : DetailsDialog.MessageType.ERROR;
           
            DetailsDialog dialog = new DetailsDialog(this, title, message, details, messageType);
            dialog.doModal();
           
            if (initStatus.getSeverity().compareTo(Status.Severity.ERROR) >= 0) {
                System.exit(-1);
            }
        }
    }
View Full Code Here

                    for (final Map.Entry<String, String> mapEntry : sourceElementMap.entrySet()) {
                        String unqualifiedGemName = mapEntry.getKey();
                        String gemSource = mapEntry.getValue();

                        QualifiedName qualifiedGemName = QualifiedName.make(getWorkingModuleName(), unqualifiedGemName);
                        Status saveStatus = getWorkspace().saveEntity(qualifiedGemName, gemSource, null, null);
                        lastGemName = unqualifiedGemName;

                        if (saveStatus.getSeverity() == Status.Severity.ERROR) {
                            String errTitle = getResourceString("CannotSaveDialogTitle");
                            String errMessage = getResourceString("ErrorSavingGemDefinition");

                            DetailsDialog dialog = new DetailsDialog(GemCutter.this, errTitle, errMessage,
                                    saveStatus.getDebugMessage(), DetailsDialog.MessageType.ERROR);

                            dialog.doModal();
   
                            // Don't bother trying to save the other gems.
                            break;
                        }
                    }
                }

                Status generationStatus = new Status("Generation status.");
               
                SourceModel.ModuleDefn moduleDefn = definitions.getModuleDefn();
                if (moduleDefn != null) {
                    // There was a generated module defn.
                   
                    ModuleName generatedModuleName = SourceModel.Name.Module.toModuleName(moduleDefn.getModuleName());

                    // Can't overwrite the prelude.
                    if (generatedModuleName.equals(CAL_Prelude.MODULE_NAME)) {
                        String errTitle = getResourceString("CannotSaveDialogTitle");
                        String errMessage = getResourceString("CannotClobberPrelude");
                        JOptionPane.showMessageDialog(GemCutter.this, errMessage, errTitle, JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                   
                    // Check whether the module name exists, and if so confirm that the user wished to clobber.
                    // This goes to the workspace source manager -- so it's a bit hacky.
                    // We can't just ask the workspace if it has the module though, since it might be the case where the workspace isn't
                    //   using a module in the nullary case.
                    if (getWorkspace().getSourceManager(generatedModuleName).getResourceStore().hasFeature(
                            new ResourceName(CALFeatureName.getModuleFeatureName(generatedModuleName)))) {
                       
                        // TODOEL: Ideally, if the user does not want to clobber the existing module, we should
                        //   go back to the dialog with the existing inputs.
                       
                        String warningTitle = getResourceString("WarningDialogTitle");
                        String errMessage = getResourceString("ModuleExistsWarning");
                        int continueChoice = JOptionPane.showConfirmDialog(GemCutter.this, errMessage, warningTitle, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                        if (continueChoice != JOptionPane.OK_OPTION) {
                            return;
                        }
                    }
                   
                   
                    // *** HACK ***
                    // *** Fix me when we can handle modules without vault info.
                   
                    // Ok, now we have the generated module defn.  Where do we put it?
                    // It should go into the workspace, but the workspace can't handle modules without any vault info.
                    // So for now we create a temp file first, and add from there.

                    // We could use NonExistentVault instead, but that requires some work to implement StoredVaultElement.Module.
                   
                    String tmpDir = System.getProperty("java.io.tmpdir");
                    String fileName = generatedModuleName + ".cal";
                   
                    File tempFile = new File(tmpDir, fileName);
                    String sourceText = moduleDefn.toSourceText();
                    Writer writer = null;
                    try {
                        writer = new BufferedWriter(new FileWriter(tempFile));
                        writer.write(sourceText);
                    } catch (IOException ioe) {
                        generationStatus.add(new Status(Status.Severity.ERROR, "Error writing file: " + tempFile, ioe));

                    } finally {
                        if (writer != null) {
                            try {
                                writer.flush();
                                writer.close();
                            } catch (IOException ioe) {
                                // Not much we can do about this.
                            }
                        }
                    }
                   
                    // Add the module to the workspace.
                    // Note: this can result in errors in cases where the module is erroneous.
                    //  For instance, if generating a foreign import module, this can result in errors if the module refers to
                    //    foreign classes which are not on the classpath.
                    boolean addModuleAttemptSuccessful = false;
                    if (generationStatus.getSeverity().compareTo(Status.Severity.ERROR) < 0) {

                        SimpleCALFileVault simpleCALFileVault = SimpleCALFileVault.getSimpleCALFileVault(tempFile);
                       
                        // This call also calls recompileWorkspace(true).
                        if (simpleCALFileVault != null) {
                            handleAddModuleAttempt(simpleCALFileVault, generatedModuleName, -1, false);
                            addModuleAttemptSuccessful = true;
                        } else {
                            String details = getResourceString("CannotCreateSimpleCALFileVault");
                            showProblemsGeneratingModuleDialog(DetailsDialog.MessageType.ERROR, details);
                        }
                    }
                   
                    // Delete the tempFile.  Don't worry too much about if this fails..
                    tempFile.delete();
                   
                    // Select the module which was compiled, if any.
                    if (addModuleAttemptSuccessful && generationStatus.getSeverity().compareTo(Status.Severity.ERROR) < 0) {
                        getGemBrowser().getBrowserTree().selectDrawerNode(generatedModuleName);
                       
                        // Also display a message.
                        String statusMessage = GemCutterMessages.getString("SM_ModuleGenerated", generatedModuleName);
                        statusMessageManager.displayMessage(this, statusMessage, StatusMessageDisplayer.MessageType.TRANSIENT, true);

                    }
                   
                    if (generationStatus.getSeverity().compareTo(Status.Severity.WARNING) >= 0) {
                        String details = generationStatus.getDebugMessage();
                        DetailsDialog.MessageType messageType = generationStatus.getSeverity() == Status.Severity.WARNING ?
                                DetailsDialog.MessageType.WARNING : DetailsDialog.MessageType.ERROR;
                       
                        showProblemsGeneratingModuleDialog(messageType, details);
                    }
                   
View Full Code Here

TOP

Related Classes of org.openquark.cal.services.Status

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.