How to give Exclusive edit permissions? - baseline

a few days ago i developed a script in dxl to make a "first release" Baseline for each module in a project folder. But when I run the script appears a message saying I have not permissions to do so. This is my code:
void CreateBaseline (Module mod) { // Function to create
create (mod, nextMajor(), "First Release") // baseline
}
Folder fStart = folder "/Z_Training/Baselines" // Folder
Module iCurrent // Module handler
for iCurrent in fStart do{
setExclusive() // Set Exclusive edit
Module (iCurrent, true) // rights
CreateBaseline(iCurrent)
}
As you can see I included the line "setExclusive()" to deal with it, but this does not fix the problem completely since the baseline is created only for the current open Module. Could you help me in this? Thanks in advance.

Seems I omitted a step when answering Is it possible to create a baseline for each module in a Folder using a dxl script (DOORS)?. Sorry, I do not have a DOORS installation at my current computer.
The method how to open a module in exclusive mode is described in the DXL manual, section "Module manipulation". You will need the perm Module edit(string name
[,bool disp[, bool silent[, bool loadStandardView]]]) (see the manual for a description of the parameters).
In this example this would be
[…] do {
Module mod = edit (fullName iCurrent, false, true, true)
CreateBaseline(mod)

Related

Found 'UR'-anomaly for variable

I have this sonar error Major:
Found 'UR'-anomaly for variable 'language' (lines '83'-'85')
in this function:
public void saveAll(List<Language> languages){
//Found 'UR'-anomaly for variable 'country' (lines '83'-'85').
//Code Smell Major Open Not assigned 20min effort Comment
for (Language language: languages) {
save(language);
}
}
how to fix this major error please, thanks for advance
Edit:
Found even more information it this other SO post. While that is more PMD centric, the background information can be of interest to you.
Java for each loop being flagged as UR anomaly by PMD.
This is a rule from PMD it seems. Definition:
The dataflow analysis tracks local definitions, undefinitions and
references to variables on different paths on the data flow. From
those informations there can be found various problems. 1. UR -
Anomaly: There is a reference to a variable that was not defined
before. This is a bug and leads to an error. 2. DU - Anomaly: A
recently defined variable is undefined. These anomalies may appear in
normal source text. 3. DD - Anomaly: A recently defined variable is
redefined. This is ominous but don't have to be a bug.
There is an open bug report for this:
https://sourceforge.net/p/pmd/bugs/1190/
In the example they report it for Arrays, but somebody commented that it happens for them also for collections.
Example:
public static void main(final String[] args) {
for (final String string : args) {
string.getBytes(); //UR Anomaly
}
for (int i = 0; i < args.length; i++) {
args[i].getBytes();
}
}
In our sonar setup we don't use this rule. Based on the available information you may wish not to use it in yours.

How to display a warning at a specific line

Quick Intellij plugin Development question.
Can somebody show me a snippet of code on how to display a warning at a specific line?
I want to display a yellow bulb and be able to alt enter.
I don't know if the yellow bulb is part of a warning or just a hint but i would very much appreciate if somebody would show me how to do it.
I tried to find it on idea plugin development but didn't have any luck
private List<PsiFile> psiFiles = new ArrayList<PsiFile>();
public void actionPerformed(AnActionEvent e) {
PsiManager psiManager=PsiManager.getInstance(e.getProject());
Project project = e.getProject();
VirtualFile srcFile;
if(e.getProject().getBaseDir().findChild("src") == null)
return;
else
{
srcFile = e.getProject().getBaseDir().findChild("src");
}
//using the buildFilesList i get all the .java files
buildFilesList(psiManager,srcFile);
for(PsiFile file : psiFiles)
//here i would want for a psiFile a warning to be displayed at a specific line
System.out.println(file);
}
What you need to write is an inspection. You don't need to enumerate the files in the project; IntelliJ IDEA will take care of calling your API at the correct moment. You can find a simple example of a plugin that implements an inspection here.

OpenNI 1.5::Could not run code from documentation

I am trying to run a sample code from the OpenNI 1.5 documentation.I have imported the library required XnCppWrapper.h so that I can use C++.The code has only one error on a particular variable "bshouldrun".I know that it should be declared as something but since I am new at this and the documentation does not contain anything above the main, I dont know what to declare it as..Please help!!
And thanks in advance.
#include <XnOpenNI.h>
#include <XnCppWrapper.h>
#include <stdio.h>
int main()
{
XnStatus nRetVal = XN_STATUS_OK;
xn::Context context;
// Initialize context object
nRetVal = context.Init();
// TODO: check error code
// Create a DepthGenerator node
xn::DepthGenerator depth;
nRetVal = depth.Create(context);
// TODO: check error code
// Make it start generating data
nRetVal = context.StartGeneratingAll();
// TODO: check error code
// Main loop
while (bShouldRun) //<-----------------------------**ERROR;bShouldRun Undefined**
{
// Wait for new data to be available
nRetVal = context.WaitOneUpdateAll(depth);
if (nRetVal != XN_STATUS_OK)
{
printf("Failed updating data: %s\n", xnGetStatusString(nRetVal));
continue;
}
// Take current depth map
const XnDepthPixel* pDepthMap = depth.GetDepthMap();
// TODO: process depth map
}
// Clean-up
context.Shutdown();
}
Here's what I did to run a sample from Visual Studio 2010 Express on Windows (8):
Opened the NiSimpleViewer.vcxproj VS2010 project from C:\Program Files (x86)\OpenNI\Samples\NiSimpleViewer
Edited OpenNI.rc to comment out #include "afxres.h" on line 10(might be missing this because I'm using Express version, not sure. Your machine might compile this fine/not complain about the missing header file)
Enabled Tools > Options > Debugging > Symbols > Microsoft Symbol Servers (to get past missing pdb files issue)
Optionally edit the SAMPLE_XML_PATH to "SamplesConfig.xml" rather than the default "../../../Data/SamplesConfig.xml", otherwise you need to run the sample executable from ..\Bin\Debug\NiSimpleViewer.exe by navigating to there rather than using the Ctrl+F5. A;so copy the SamplesConfig.xml file into your sample folder as you can see bellow
Here are a few images to illustrate some of the above steps:
You can also compile the NiHandTracker sample, which sounds closer to what you need.
So this explains the setup for OpenNI 1.5 which is what your question is about.
I've noticed your OpenNI 2 lib issue in the comments. It should be a matter of linking against SimpleHandTracker.lib which you can do via Project Properties (right-click project->select Properties) > Linker > Input > Additional Dependencies > Edit.
I don't have OpenNI2 setup on this machine, but assuming SimpleHandTracker.lib would be in OpenNI_INSTALL_FOLDER\Lib. Try a file search in case I might be wrong.

Can't find system.out.println()

I created a project, it asked me to select JDK version and finish.
I couldn't find system namespace in autocomplete.
I typed it manually but IDEA told me that system doesn't exist.
It's System (with a cap)
Some very useful shortcuts:
soutm (+TAB) ==> System.out.println("Class.And.Method.Name")
soutv (+TAB) ==> System.out.println("Last variable used = " + value);
sout (+TAB) ==> System.out.println();
I really love IntelliJ. Glad I moved to it from Eclipse a couple of years ago ;)
Just type sout.
public class Main {
public static void main(String[] args) {
int data = 1;
System.out.println(); ===>sout
System.out.println("Main.main"); ===>soutm
System.out.println("args = [" + args + "]"); ===>soutp
System.out.println("data = " + data); ===>soutv
}
}
sout - just print System.out.println()
soutm - added Class name & method name
soutp - added parameter
soutv - added last variable name
We can change the auto complete settings to to ignore case. Go to:
File -> Settings... -> IDE Settings -> Editor -> Code Completion
and change 'Case sensitive completion' to 'None'.
I came from eclipse and was using the syso shortcut, so I have just added it to my live template. Here is a templete:
System.out.println($END$);
Here is a screenshot:
Don't forget to add Java as applicable context (at the bottom of the window).
Now it will appear as a hint while you typing syso here is a screenshot:
Hope it helps
This can also happen because user has not created any main function or trying to test this directly in class without any function

Install ClickOnce without running

When you install a ClickOnce application, the program runs after the install. Is it possible to install without running?
I know I can use a setup and deployment project and create an installer, but I'd prefer to use ClickOnce.
I guess you could fake it. Introduce an "IsInstalled" boolean property, defaulted to false. Then in Program.cs, change your Main() method to look like this:
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (!Properties.Settings.Default.IsInstalled)
{
Properties.Settings.Default.IsInstalled = true;
Properties.Settings.Default.Save();
MessageBox.Show("Install Complete");
return;
}
Application.Run(new Form1());
}
So now when the app is first installed, it checks that property and simply displays a message to the user and then quits.
If you wanted to get tricky then you could look at parsing the Activation URI for the deployment and have a URI parameter which specifies whether the program should run when it's first installed or just close silently.
You can do this by editing the application manifest in Mage. There is a checkbox to stop the application running after installation.
If you are not comfortable editing a manifest manually or with Mage then you can use the built-in deployment class to check whether this is the first time the application has run.
using System.Deployment.Application
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (ApplicationDeployment.CurrentDeployment.IsFirstRun)
{
MessageBox.Show("Install Complete");
return;
}
Application.Run(new Form1());
}
After trying all the suggested solutions and still running into the same problems, I fiddled with this for a while and combined several solutions to one that actually works.
The problem with just setting an "isInstalled" property is the value is retained after upgrades, so every time you install the new version, it runs the app again. But using an application manifest file and Mage is just too much work and too complicated just to solve this little problem.
So what I did was acquire the current build # of the running version of the app, save that to a property, then check the property against the running version each time. This works because each publish increments the version #.
1) Change your Assembly version to use wildcards in AssemblyInfo.cs:
[assembly: AssemblyVersion("1.0.*")]
2) If that throws a "Deterministic" error on Build, open your .csproj file and set Deterministic to false in the PropertyGroup section
<Deterministic>false</Deterministic>
3) Add this fool-proof function to acquire the running assembly version:
private Version GetRunningVersion()
{
try
{
return System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion;
}
catch
{
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
}
}
4) In your project's properties, open the Settings tab, and add a setting named lastVersion (String, User). Leave the Value empty.
5) Add this property to use to determine whether this is the first time the application is running after installation.
private bool isFirstRun
{
get { return Properties.Settings.Default.lastVersion != GetRunningVersion().ToString(); }
}
6) Then in your code, add this after you check for isFirstRun:
if (isFirstRun)
{
Properties.Settings.Default.lastVersion = GetRunningVersion().ToString();
Properties.Settings.Default.Save();
}