Author Topic: Best Practices/Ideas for Config Management  (Read 9372 times)

bercikr

  • Community Member
  • Posts: 45
  • Hero Points: 2
Best Practices/Ideas for Config Management
« on: April 15, 2008, 05:44:33 pm »
I'd like a little input regarding a project I am working on and the best way to integrate with SE Core for Eclipse. Here are is a brief overview of what I am trying to do and then some more specific questions about how best to proceed. I am working on a project supporting a large group of developers(100+) who are writing code using several proprietary languages(8+ languages). As of right now these developers are using a mix of CodeWright or Eclipse, both with heavy customization to support the proprietary languages. We are now in the process of customizing SE Core so that we can do as little Eclipse RCP development as possible and get rid of CodeWright entirely. At the end of the day, we would like a deliverable that can be passed off to these developers, where all they need to do is download a local copy of Eclipse 3.3 and possibly hit one update site to pull down updates, new language modifications and macros. So here are the questions I would have for the Forum.

1.) Whats the best way to store/load language definitions?
1a.) Can I just place these in user.vlx, or should i write a script to add extensions and to populate this file?
1b.) Whats the best way to modify these scripts/files using a transparent update strategy?

2.) Is there any recommended way to maintain a project structure for Slick-C macros. I see a primarily flat structure in SlickEdit itself, but perhaps there are some other ways to do things.

3.) How much of eclipse is accessible through Slick-C macros? I have already been able to access the outline view very cleanly. How about external tool integration(Compilers) accessing things like the problem view or equivalent.


Any input would be greatly appreciated here even if you can't answer any of these questions directly, maybe some of you have worked on something like this before.

Thanks,
Rob

Ryan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 987
  • Hero Points: 77
Re: Best Practices/Ideas for Config Management
« Reply #1 on: April 16, 2008, 02:22:00 pm »
Hi Rob, I'll try to be as helpful as I can :D.

Quote
1.) Whats the best way to store/load language definitions?
1a.) Can I just place these in user.vlx, or should i write a script to add extensions and to populate this file?
1b.) Whats the best way to modify these scripts/files using a transparent update strategy?

You should probably look at either fortran.e or modula.e as examples.  These files are both really good starting points for adding custom language support.  Basically for one of your languages, you are going to want to create a similar macro file, which calls create_ext in the defload function.  You can also define your lexer in LANGUAGE_NAME.vlx, and load this in the defload function of your macro file by calling cload.  That way, when your language support macro is loaded into the editor, so is the lexer, and you are good to go.

Now to distribute your custom macro files and custom lexer files to your developers once they have Core installed, you have a couple options.  You could of course have your developers download and load all of your custom macro files, and then they would be set.  This is the probably the easiest.  The other option is to use the hotfix mechanism of SlickEdit which was introduced in the v12 timeline (Core 3.3.0 is based off SlickEdit 12.0.3).  This mechanism was never exposed in Core, but the functionality is still there.  So you could create a hotfix zip file containing all of your custom macros, have your developers download this and then load it via the load_hotfix command.  Creating a hotfix file will be a little bit of work, but we could provide you directions on how to do so.

If you explain more specifically what you are getting at in 1b I might be able to help you out there...

Quote
2.) Is there any recommended way to maintain a project structure for Slick-C macros. I see a primarily flat structure in SlickEdit itself, but perhaps there are some other ways to do things.

For working on your Slick-C macros, you will probably want to create an Eclipse workspace for your Slick-C code, and then you can organize this however you want.  But no, there is no recommended way to maintain a structure for Slick-C macros...at least not on the v12 base.  In v13 we have Object Oriented aspects incorporated into Slick-C like classes, inheritance...so we have a much different structure for our code.

Quote
3.) How much of eclipse is accessible through Slick-C macros? I have already been able to access the outline view very cleanly. How about external tool integration(Compilers) accessing things like the problem view or equivalent.

We don't really have APIs for accessing Eclipse views through Slick-C macros  :-\.  You can access the Outline view through Slick-C because that is basically the SlickEdit defs tab dumped into the Outline view :).  You will (of course) be able to access any of the other SlickEdit views through Slick-C, but you won't be able to directly influence something like the Problems view from Slick-C code. 

Now, the Problems view is supported by Core, meaning that the Problems view will still be populated in Eclipse just as it would without Core, and clicking on a problem will bring you to the appropriate position in a SlickEdit editor, etc. 


I hope this helps at least a little bit...let me know if you have any follow-ups.

- Ryan

bercikr

  • Community Member
  • Posts: 45
  • Hero Points: 2
Re: Best Practices/Ideas for Config Management
« Reply #2 on: April 18, 2008, 05:48:12 pm »
Ryan,

    Thanks for the response, you helped me out quite a bit already in organizing my project and getting the ball moving. I have a few more specifics I would like to hash out before we move forward with this project. Returning back to question 1a.) I have taken your advice and split our existing language definitons into seperate .vlx files and have begun trying to load them from language specific macros. I have started writing a macro language1.e that loads language1.vlx. Here's a few more questions that have come up.

4.) What directory does SE Core look by default once you have loaded a macro... is it the VSLICKCONFIG dir? In java, i would simply create a new file and get the full path in order to find the directory i was in, but I am not familiar enough with vslick to do this yet.

Another issue i ran into was using the create_ext command. When I did so the extension was created successfully, but not the color coding lexer file. here is the code I tried.
Code: [Select]
_command void test_load_efs(_str command = "")
{
   _str setup_info='MN='OCL_MODE_NAME',TABS=+2,MA=1 74 1,':+
                   'KEYTAB='OCL_MODE_NAME'-keys,WW=1,IWT=0,ST=0,';
   _str compile_info='';
   _str syntax_info='3 1 1 0 0 1 0';
   _str be_info='(BEGIN)|(END);i';
   int kt_index=0;   
   create_ext(kt_index,OCL_LANGUAGE_ID, '', OCL_MODE_NAME,
                   setup_info, compile_info, syntax_info, be_info,'','',OCL_MODE_NAME,'');
}

When I opened the File Extension Setup-->Advanced tab and selected ocl it had no color coding lexer defined.
5.) Do I need to load the .vlx file first, or am I making the call incorrecty?

One of the unique challenges of this project is that the languages will be changing a lot and we are trying to roll this project out quickly so they can begin using the tools, but would like to be able to add languages and changes quickly and often. I have looked into the hotfix solution, but i don't think this would be received well by our users.

6.) Does slickedit have any functionality to pull down files(any type of file, but probably macro/.vlx files) from a website? I would prefer to do it this way rather than using a network drive or similar. I initially tried to use the open_url using a http url, but it always seemed to try reference a file on the local filesystem rather than look to the web.

Ok, thats all i have for now, again thanks for your help(It doesn't seem like too many people read this forum yet...)

Rob

Ryan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 987
  • Hero Points: 77
Re: Best Practices/Ideas for Config Management
« Reply #3 on: April 18, 2008, 08:56:08 pm »
Quote
4.) What directory does SE Core look by default once you have loaded a macro... is it the VSLICKCONFIG dir? In java, i would simply create a new file and get the full path in order to find the directory i was in, but I am not familiar enough with vslick to do this yet.

If I'm understanding correctly, you just want to know what is your current working directory?  getcwd should do what you want...it returns just that, feel free to call it anytime.

Quote
When I opened the File Extension Setup-->Advanced tab and selected ocl it had no color coding lexer defined.
5.) Do I need to load the .vlx file first, or am I making the call incorrecty?

Your code looks fine, but I don't see where you are actually loading the lexer file with cload.  That would explain the lexer file not being loaded ;).  From above: 

Quote
You can also define your lexer in LANGUAGE_NAME.vlx, and load this in the defload function of your macro file by calling cload.

So before your call to create_ext, try something like (with the absolute path to mylexer.vlx, with quotes if necessary):

Code: [Select]
cload(mylexer.vlx);

Quote
6.) Does slickedit have any functionality to pull down files(any type of file, but probably macro/.vlx files) from a website? I would prefer to do it this way rather than using a network drive or similar. I initially tried to use the open_url using a http url, but it always seemed to try reference a file on the local filesystem rather than look to the web.

Hmm...well, there isn't anything spectacular that comes to me off the top of my head  :-\.  I don't think open_url by itself is what you want, that will just try to open a networked file in your editor.  I suppose you could write yourself a macro which used open_url in conjunction with save and load in order to grab files, save them locally, and load them.  Through Slick-C you can also execute any OS command with the shell command...if you wanted to write a batch script which did what you wanted.

I'll let you know if anything comes to mind...

Quote
It doesn't seem like too many people read this forum yet...

Our plug-in products for both Visual Studio and Eclipse don't quite have the user base of our standalone editor, but both populations are growing pretty rapidly.  Also, a lot of people choose mostly to interact with us via our Tech Support group, but we get some pretty good input down here at the Eclipse forums too ;).

Let me know how this is going...

- Ryan

bercikr

  • Community Member
  • Posts: 45
  • Hero Points: 2
Re: Best Practices/Ideas for Config Management
« Reply #4 on: April 18, 2008, 10:51:44 pm »
Thanks Ryan, getcwd is what I was looking for, i wasn't able to find it myself.

Quote
Your code looks fine, but I don't see where you are actually loading the lexer file with cload.  That would explain the lexer file not being loaded.  From above: 

I should have mentioned that I had tried to call cload("correctpath/ourcustomlanguage.vlx"); both before and after calling create_ext without any success. Is there any other reason why my lexer isn't getting created and associated? My Call looks exactly like it did before with the above line added before the call to create_ext

Also, with regard to open_url i am getting some strange behavior. The behavior you described would be ideal, but when i call it, i get a message about mapped url's. For instance, if you try and call, open_url('www.slickedit.com/images/stories/support/macros/stata.vlx') you will see what i mean. Any idea how to pull this file down using this call?

Thanks,
Rob



Ryan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 987
  • Hero Points: 77
Re: Best Practices/Ideas for Config Management
« Reply #5 on: April 21, 2008, 04:15:49 pm »
Ok, you are right...cload doesn't seem to be working properly, and I'm not actually sure that a lexer file loaded with cload is permanent.  So below is your same code, slightly modified, which I will explain: 

Code: [Select]
/**
 * Update destination lexer file with contents
 * in source file.  By default, the dest_lexer_filename refers
 * to the user.vlx in the user configuration directory.
 *
 * @param filename
 * @param dest_lexer_filename
 */
void import_lexer_file(_str filename, _str dest_lexer_filename = '')
{
   int orig_view_id = p_window_id;
   _str lexernames[];
   int status = _ini_get_sections_list(filename, lexernames);
   if (status) return;

   if (dest_lexer_filename == '') {
      dest_lexer_filename = _config_path():+USER_LEXER_FILENAME;
   }
   int i, len = lexernames._length();
   for (i = 0; i < len; ++i) {
      int lexer_view_id;
      status = _ini_get_section(filename, lexernames[i], lexer_view_id);
      if (status) break;
      status = _ini_put_section(dest_lexer_filename, lexernames[i], lexer_view_id);
      if (status) break;
   }
   p_window_id = orig_view_id;
   if (file_exists(dest_lexer_filename)) {
      status = _clex_load(dest_lexer_filename);
      if (status) {
         _message_box(nls("Could not load file '%s'\n\n%s", dest_lexer_filename, get_message(status)));
      }
   }
}

_command void test_load_efs(_str command = "")
{
   _DeleteExtensionOptions(OCL_MODE_NAME);
   _str setup_info='MN='OCL_MODE_NAME',TABS=+2,MA=1 74 1,':+
                   'KEYTAB='OCL_MODE_NAME'-keys,WW=1,IWT=0,ST=0,LN=OCL_LEXER_NAME';
   _str compile_info='';
   _str syntax_info='3 1 1 0 0 1 0';
   _str be_info='(BEGIN)|(END);i';
   int kt_index=0;   
   import_lexer_file('correctpath/language.vlx');
   create_ext(kt_index,OCL_LANGUAGE_ID, '', OCL_MODE_NAME,
                   setup_info, compile_info, syntax_info, be_info,'','',OCL_LEXER_NAME,'');
}

The first thing to point out is the helper function import_lexer_file.  This will update user.vlx with the contents of the lexer file you pass in as the first argument.  I ported this over from v13 for you.

The changes to test_load_efs are as follows:
  • Added OCL_LEXER_NAME for the bracketed name at the top of your vlx file...in case it is different from OCL_MODE_NAME
  • Call _DeleteExtensionOptions before we call anything in order to clear it out
  • Appended 'LN=OCL_LEXER_NAME' to setup_info to declare lexer file there
  • Call import_lexer_file before we call create_ext

This should work.

Quote
The behavior you described would be ideal, but when i call it, i get a message about mapped url's.

Yea, when a file is hosted for download, open_url doesn't get an expected response from the site, and throws up an error.  The message about URL mappings is a red herring...really has nothing to do with it.  If you did open_url('http://www.slickedit.com'), you will see it work as expected.

I'm not sure what this means for you, but I had another thought.  Getting back to the original desire to be able to automate pulling down macro files/lexer files from a remote site, have you thought of setting up an ftp site and using our ftp functionality to get the files?  This might work better in conjuction with SlickEdit, rather than hosting them on a website.

- Ryan

bercikr

  • Community Member
  • Posts: 45
  • Hero Points: 2
Re: Best Practices/Ideas for Config Management
« Reply #6 on: April 21, 2008, 09:43:05 pm »
Ryan,

    That was it, that new function plus the added "LN=OCL_LEXER_NAME" directive seems to have solved the majority of my problems with loading languages. I am now able to start up Eclipse and load several languages with no need for the users themselves to do anything...thats a big step in the right direction :). I also am now loading all of my modules from one top-level module, so that I can edit and compile several different languages at once and reload them all at once...very good stuff. I still haven't quite nailed down how I am going to deliver new language updates to the users yet...I think I may go with a network drive solution rather than FTP.
    Ok, for my next question. I am now at the point where I would like to add some custom menus for various features I've added. I am able to do this myself manually via the "Edit this menu" item, but would like to do it programmatically. Is there an example on how to do this somewhere?

Thanks,
Rob

Ryan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 987
  • Hero Points: 77
Re: Best Practices/Ideas for Config Management
« Reply #7 on: April 22, 2008, 04:25:50 pm »
Quote
I am now able to start up Eclipse and load several languages with no need for the users themselves to do anything...thats a big step in the right direction . I also am now loading all of my modules from one top-level module, so that I can edit and compile several different languages at once and reload them all at once...very good stuff.

Glad to hear it  :D.

Quote
I am now at the point where I would like to add some custom menus for various features I've added...would like to do it programmatically.

So to do this, you are going to want to become familiar with the _menu_ functions.  _menu_load will get you the handle to a menu (assuming you know the name), and _menu_find will get you a handle to a submenu on a menu.  Once you have an appropriate menu handle, you can do things like _menu_insert to add an item, _menu_delete to remove an item, and _menu_set_state to disable/enable/check items.

For an example, check out the ctlsstab1.rbutton_up event in bufftabs.e...that is a pretty simple example.  To get all your modifications done dynamically, usually using the rbutton handler for the control where the menu is shown is best, but you can also define an _on_popup_MENUNAME function, which will automatically get called when MENUNAME is opened. 

- Ryan

« Last Edit: April 22, 2008, 04:33:46 pm by Ryan »

bercikr

  • Community Member
  • Posts: 45
  • Hero Points: 2
Re: Best Practices/Ideas for Config Management
« Reply #8 on: April 23, 2008, 08:23:44 pm »
Hi Ryan,

     Thanks for pointing me in the right direction on the menu functions, adding menu files seems pretty straightforward. In the meantime have been working on reading/writing to buffers to do various tasks(read config files, etc.), but the list-buffers -h command does not to be working properly. Is there some limitation of the SlickEdit Core, where hidden buffers cannot be displayed? I tried out identical code in Slickedit 2008 and in SlickEdit core and the hidden buffers used only showed up in 2008. Any insight?

Thanks,
Rob

Ryan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 987
  • Hero Points: 77
Re: Best Practices/Ideas for Config Management
« Reply #9 on: April 23, 2008, 09:20:06 pm »
Yea list-buffers in Eclipse, as you've probably noticed, just channels the Eclipse navigate buffers functionality.  If you go to the function (fp list_buffers), you will see.  Eclipse doesn't know anything about hidden SlickEdit buffers that are opened in a temp view.

- Ryan