Lazarus, How to detect in a custom component if the current project is been closed? - pascal

I am writing a custom component to Lazarus IDE and I need to detect in the 'destructor' of it when it is been destroyed by the user or when it is been destroyed by the Lazarus IDE when is closing.
Below is a draft idea.
destructor TNewCompoent.Destroy;
begin
if(IDE.IsClosing)then
...
else
...;
inherited Destroy;
end;
Thanks a lot.
Edit (07-05-2017)
My question was not completely correct; so I edited it.
The point is that I am not asking about “When the IDE was closing”; I really need to know “When the current project is been closed”.
My problem:
When a project is been closed the Lazarus’s IDE free the components that you are using; and of course, each one of the components execute their destructor procedure; In that way, if you are developing a custom component the use the destructor procedure to do something in designing time (specially with pointers or FreeAndNil) this code will be executed and it would be a problem(It is a problem to my project).
I found some examples for designer events on http://wiki.freepascal.org/Extending_the_IDE and I’m trying to register the handler LazarusIDE.AddHandlerOnProjectClose(#myprocedure) but is not working.
Maybe I am not thinking the best and secure choice to design my component.
Anyway, thanks a lot and if you have an idea about it I will thank you.

Related

Disordered GUI formatting

I'm creating a GUI in NetBeans 13 using Java Swing and Maven as my Built Tool, and I'm about to finish up when I noticed that my GUI formatting got disorganized.
I'm gonna send a picture of what my JFrame form should look like and the disordered one to further clarify my question.
How it initially looked like
The disordered version
I have a total of four JFrame Forms, namely, Final_Frame, Log_In, Register, and Loading_screen(my main class). Everything is working perfectly fine when I tried to run my project starting from Log_In to Final_Frame, Register to Final_Frame, or Log_in to Register to Final_Frame. But when I tried to add Loading_screen at the very start since this is my main class, although it doesn't affect the GUI format of my Log_In and/or Register, it started to affect the GUI formatting of my Final_Frame. I also don't know how my Loading_screen affected Final_Frame since my Loading_screen only has a couple of JPanel, JLabel, and a Progress Bar
I couldn't figure out the problem at all since it is not throwing an Exception so I tried to Clean my project and then Build again but the problem still occurs.
Hope you can help me, thank you so much.

Can I do tooled refactoring for UFT script code, especially when changing function signatures?

As an enthusiasting refactorer, there's an IntelliJ feature that I love: "Refactor --> Change signature".
Basically, you have a function and you can decide to remove a parameter or add a new one, setting a default value. This is so convenient, so beautiful, and I dearly love it.
So when I got involved in an oldschool UFT project with maintenance tasks, I felt jaded.
It there a way to achieve this without changing each and every instance of the function? Please tell me yes. Please!
Well, no. I don´t know of any tool capable of this.
There seem to be people who created a C# adapter for the UFT test object API, enabling them to write their tests in C#, and to use VisualStudio for development of test scripts. In VS, you have the refactoring support you look for. But you don´t create UFT scripts anymore, you´d create C# apps. (Note I am not talking about the API testing aspect of UFT, which uses C# anyways -- I am talking about the VBScript test scripts for GUI tests and BPT components.)
UFT itself is not capable of doing real static code analysis. (Let this statement drown a minute, and you´ll agree: it´s true.)
Adding this to the fact that the UFT´s IDE is, let´s say: sub-optimal, this led to the development of Test Design Studio (TDS), a VisualStudio "feel-alike" subset of VS for UFT (VBScript) scripts. You can check it out here: http://www.patterson-consulting.net/products/test_design_studio/Default.aspx
Among other things, TDS does static code analysis for UFT scripts in a pretty complete way (as far as an interpreted variant-typed language like VBScript allows that at all), and the author of the tool seems to be thinking about adding refactoring features like the one you asked for, but -- this has not happened yet. It will probably come only if demand is high.
Until then, TDS could help you:
You could simply change the signature
If TDS knows all calls (which is usually does), it will list you all locations where you need to edit -- and this happens at design-time, not at runtime
TDS allows you to specify the type of identifiers, for example: formal parameters, variables, and so on. This means you might even get warnings if you change nothing about the pure VBScript signature (which does not include type information), but do change the TDS directive of that signature parameter of which you changed the type.
This is no advertisement. I am not part of the company that developed TDS.
This is just an honest answer to the (slightly offtopic) question that I wish would have gotten years ago, asking questions like yours, and it proved to be a real lifesaver.
In summary, TDS quadrupled (or more) my productivity when creating and maintaining test scripts, especially if a large base framework is used. So I´d recommend checking out the option of using TDS to better handle changes like the ones you outlined.

IBM Worklight - Shell Component

When I have created a shell component, inside the shell component common folder there is folder called preview. I need to know what is the use of this folder. I am trying to understand about it using the following point specified in IBM modules.
preview: can be used to implement native functionality stubs for simulation in the Worklight Console preview instead of receiving exceptions
Still i am not having any clear idea about this. Can anyone give a clear idea about this.
Thanks in advance!
I believe that the main idea of the preview folder for shell component is to simulate its native behaviour, let's say for example you want to you the Google Maps API on a given area.
For the one developing the shell they do not have the final App, to test its behaviour. So, they can create some simulation such as a picture for a Map or a Picture of a Android TOAST, to allow them to work in the shell it self.

Visual studio 2010 colourizers, intellisense and the rest. Where to start!

Ok, before I begin I realize that there is a lot of documentation on this subject but I have thus far failed to get even basic colourization working for VS2010.
My goal is to simply get to a point where I can open a document and everything is coloured red, from here I can implement the relevant parsing logic.
Here's what I have tried/found:
1) Downloaded all the relevent SDK's and such- Found the ook sample (http://code.msdn.microsoft.com/ookLanguage) - didn't build, didn't work.
2) Knowing almost nothing about MEF read through "Implementing a Language Service By Using the Managed Package Framework" - http://msdn.microsoft.com/en-us/library/bb166533(v=VS.100).aspx
This was pretty much a copy and paste of all the basic stuff here, and also updating some references which were out of date with the sample see: http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/a310fe67-afd2-4592-b295-3fc86fec7996
Now, I have got to a point where when running the package MEF appears to have hooked up correctly (I know this because with the debugger open I can see that the packages initialize and FDoIdle methods are being hit).
When I open a file of the extension I have registered with the ProvideLanguageExtensionAttribute everything dies as if in an endless loop, yet no debug symbols hit (though they are loaded).
Looking at the ook sample and the MEF examples they seem to be totally different approaches to the same problem. In the ook sample there are notions of Clasifications and Completion controllers which aren't mentioned in the MEF example. Also, they don't seem to create a Package or Language service, so I have no idea how it should work?
With the MEF example, my assumption is that I need to hook into the "IScanner.ScanTokenAndProvideInfoAboutIt" to provide syntax highlighting? Which would be fine if I could ever hit this method.
So my first question I guess is which approach should I be taking here? Or do they both somehow tie together?
My second questions is, where can I find a basic fully working project that implements bog standard basic syntax highlighting and intellisense or VS2010?
Thirdly, in the MEF example when I created a Package there were a bunch of test projects created for me. I appears that the integration tests launch the VS2010 test rig somehow, but the test fails. It would be good to write my service with tests but I have no idea what/how I can test each interaction so any references to testing Language services would be helpful.
Finally, please throw any resource/book links my way that I may find useful.
Cheers, Chris.
N.B. Sorry I realize this is part question part rant, but I have never been so confused.
First, the package example is not using MEF. Essentially everyplace that you mention MEF in your question is not actually MEF, but the managed package framework (MPF), also colloquially called the managed language service (MLS). You'd know if your extension was using MEF by two things: the vsixmanifest lists your assembly as containing a MEF component, and you see [Export] and [Import] attributes in the code.
The easiest way to do this is to use MEF. Since you have the SDK installed, you also have a template for an editor classifier project (under C# (or VB)->Extensibility->Editor classifier in the New Project dialog). You can certainly do this with a language service/colorizer/package, but there will be significantly more code than the equivalent classifier.
The Ook solution is the sample for this and should work; if it doesn't build/work, then can you send me email (noahric at microsoft) with what errors you are seeing so I can email the owner of that sample?
In general, you should also read my answer for the question on "How can I write a plugin for VS2010 using MEF?". That has links to other resources that should help.

Can the Visual Studio properties editor reference a property to component in another form (or class)?

As a Delphi developer moving to .NET I'm expecting similar concept like TDataModule & TForm to be available. However, I could not find way to make a reference from a component on a Form to another component on another Form (or Component) class.
I understand technical difference underlying the issue. Delphi component architecture is based on component-streaming (resource serialization), but .NET form is actually a code generator. If it's not possible to do such thing; I wonder how typically, form UI designer put common component into the same place ? Does it always have to be implemented in code only ?
For a bit more specific to what I'm trying to accomplish; I'm using DevExpress XtraGrid for which multiple instance of grids can reference to common "ExternalRepository" How can the grids in separated forms reference to the same instance of ExternalRepository ? Setting this property via code is completely eliminate grid design-time capabilities.
Any trick here?
Question answered by DevExpress Forum
Sorry, but it seams like it is not
possible. You will find some
explaination about this in this
support center issue:
Can the same PersistentRepository be
linked to many GridControls in
different forms in design time?
http://www.devexpress.com/Support/Center/p/DQ11884.aspx
Short answer: only possible at
runtime.
Regards,
Marc Greiner [DX-Squad]

Resources