Automatically sort class items in PlantUML - uml

Sometimes it is very tiresome to sort keys alphabetically, especially in larger tables, which grow over time.
Let's look at this diagram:
#startuml
!define Table(name,desc) class name as "desc" << (T,white) >>
!define primary_key(x) <b><color:b8861b><&key></color> x</b>
!define column(x) <color:black><&media-record></color> x
Table(testTable, "demoTable") {
column(zzz)
column(aaaa)
column(gggg)
}
#enduml
Is there any option for PlantUML that would sort my column entries based on their names?
I want to display the diagram as if I'd have written it as
#startuml
!define Table(name,desc) class name as "desc" << (T,white) >>
!define primary_key(x) <b><color:b8861b><&key></color> x</b>
!define column(x) <color:black><&media-record></color> x
Table(testTable, "demoTable") {
column(aaaa)
column(gggg)
column(zzz)
}
#enduml
Is it possible with built-in tools, or do you have any idea how to accomplish this?

You could suggest the feature to the PlantUML Q&A Forum.
In the mean time, why not use an !include and sort the items in your operating system. Here's a sample:
#startuml
!define Table(name,desc) class name as "desc" << (T,white) >>
!define primary_key(x) <b><color:b8861b><&key></color> x</b>
!define column(x) <color:black><&media-record></color> x
Table(testTable, "demoTable") {
!include items.include
}
Table(testTableSorted, "demoTable(sorted)") {
!include sorted_items.include
}
#enduml
You could always keep the file sorted, or sort a copy of it:
sort items.include > sorted_items.include

Related

Setting a text view to blank text after being toggled

I have a text view that is clickable. Every time the user clicks the text box, it will display a string. When they click it again, the box will become blank. I have this so far:
textToggle.setOnClickListener {
textToggle.text = "Hello"
}
I have seen some examples where the person did an override on onClick. Would that be the case for here too, or is there a simpler way that I'm not seeing?
Just check the length of the text when you click on it.
textToggle.setOnClickListener {
if(textToggle.text.length > 0) textToggle.text = ""
else textToggle.text = "Hello"
}

How to get Text Input (Tizen Native App)

I have been working on a Tizen project where I need to calculate BMI of a person. So i need to take input of the name of the user and the height and weight from the user. So far I have created a functional interface where I can navigate users to the options. I can prompt for input and keyboard pops up. But I am not sure how to take and save the input in a variable like we do on android : int/String x = editText.getText()
I have searched a lot, but the tizen community seems a bit more advanced on documentation. Any help will be appreciated. below are some of the code for edit text (for text input). I just need to know how I can extract the input value from it.
Edit Text code:
static Evas_Object *
create_singlelines_editfield_layout(Evas_Object *parent) {
Evas_Object *editfield, *entry, *button, *buttonOk;
editfield = elm_layout_add(parent);
elm_layout_theme_set(editfield, "layout", "editfield", "singleline");
evas_object_size_hint_align_set(editfield, EVAS_HINT_FILL, 0.5);
evas_object_size_hint_weight_set(editfield, EVAS_HINT_EXPAND, 0.5);
entry = elm_entry_add(editfield);
elm_entry_single_line_set(entry, EINA_TRUE);
elm_entry_scrollable_set(entry, EINA_TRUE);
elm_object_part_text_set(entry, "elm.guide", "Enter Your Weight");
evas_object_smart_callback_add(entry, "focused", editfield_focused_cb, editfield);
evas_object_smart_callback_add(entry, "unfocused", editfield_unfocused_cb, editfield);
evas_object_smart_callback_add(entry, "changed", editfield_changed_cb, editfield);
evas_object_smart_callback_add(entry, "preedit,changed", editfield_changed_cb, editfield);
elm_object_part_content_set(editfield, "elm.swallow.content", entry);
//elm_object_part_content_set(editfield, "elm.swallow.button", button);
return editfield;
}
Thanks
char const * const text = elm_entry_entry_get(ad->input);
You can see it in action with :
https://github.com/rzr/ekzekuto

xpages dojo text area binding to a dialog list field

I have a Dojo Text Area control binding to a field from a form, the field is a Dialog list which uses a simple #DBColumn formula:
_view := "vwAuthor";
#Unique ( #DbColumn( "" : "NoCache" ; #DbName ; _view ; 1 ) )
I have saved one doc. with the Dojo text area control = Name1, but when I create another new doc. is there any chance to have that "auto-refresh" from Clasic Lotus Notes so that When I just type N the Name1 should be displayed?
Thanks for your time!
Create instead of the value picker for your Dojo Text Area a dialog box with an input text field with type ahead.
Feed the type ahead with the first column of your view "vwAuthor":
<xp:inputText
...>
<xp:typeAhead
mode="full"
minChars="1">
<xp:this.valueList><![CDATA[#{javascript:
#Unique(#DbColumn("", "vwAuthor", 1))
}]]></xp:this.valueList>
</xp:typeAhead>
</xp:inputText>
A text area by default does not offer any data entry assistance. Switch to a regular input box and use the type-ahead support build into XPages. Check the basic workshop, especially Exercise 7.

How do I safely add menuItems to an existing menu in Maya MEL

I tried adding menu items to an existing menu in Maya using MEL
Example:
menuItem -label "Mylabel" -insertAfter "someEntry" -parent $gMainFileMenu;
menuItem -label "Mylabel2" -insertAfter "someEntry" -parent $gMainFileMenu;
The issue is that the menu doesn't get populated by the normal entries like it should but only by the entries I've added with these 2 lines of code.
For example, the file menu normally contains "New scene", "Open scene", "Save scene", etc., but when I do these 2 lines, it only contains "Mylabel" and "Mylabel2".
Is there a fix or a workaround to make sure the menu gets fully populated? Is there a way to force Maya to build it without the user actually clicking on it?
Actually the problem is that Maya first populates the menu the first time the user opens it. It checks if the menu length and if it's greater than 0, it doesn't populate it. Since you've added 2 entries, the menu length is greater than 0 and doesn't get populated with the standard entries.
To fix that problem there is two ways to do it. You can do it by force-building the menu items or by registering your build menuItem. Bot ways are usable in different cases.
By force building the menu :
What you have to do, is find the function that Maya call to build the menu you need. You can find these functions in the folder <MayaInstall>/scripts/startup/*. A good way to find the procedure name is to open the Maya Console, enable "echo all commands" and then to click the menu you want to see the function called to build it.
In your case the function is called buildFileMenu() and can be found in the script FileMenu.mel.
Now that you have that function name, you have to check it's parameters. Sometime it need a menu name as parameters some times not. See the bottom section about how to find a menu name if you need one.
Now let's build it.
global string $gMainFileMenu; // Retrieve the menu name
buildFileMenu(); // Build it
// Now build your menu
menuItem -divider true -parent $gMainFileMenu SuperMenuDivider;
menuItem -label "MyLabel1" -parent $gMainFileMenu SuperMenuLab1;
menuItem -label "MyLabel2" -parent $gMainFileMenu SuperMenuLab2;
// Create a proc to remove your menu items
global proc RemoveMyMenuItems()
{
if(`menuItem -ex SuperMenuDivider`) deleteUI -mi SuperMenuDivider;
if(`menuItem -ex SuperMenuLab1`) deleteUI -mi SuperMenuLab1;
if(`menuItem -ex SuperMenuLab2`) deleteUI -mi SuperMenuLab2;
}
// You can then call that function when in the unload function of your plugin.
By registering the build menuItem call
What you have to do is use a function called addMenuItemSafe which takes 3 parameters, the menu you want to populate, the name of the function which populates the menu, and a global variable name to hold the callback.
So first thing you have to do is create the function that will populate your menu, then the function to remove it and then call the AddMenuItemSafe method. Note that in the function you have to check if your menu is already created because Maya will call that function every time the menu is shown.
First, the two functions to add and remove our menu entries:
global proc string AddMyMenuItems()
{
// Global variable to hold the test to see if the menu is populated.
global int $gMyMenuItemsTest;
// Menu var needed in our case because we are inserting in the middle of the menu
global string $gMainFileMenu;
if( $gMyMenuItemsTest == 0 )
{
// Actually build your menu.
// Note that if you don't need to insert it after a specific entry,
// You can just do `menuItem -label "blep"`. No need of -ia and -p
// Also, for inserting in the middle you have to put stuff in reverse order.
// If you are just appending, put it in the normal order.
menuItem -label "Mylabel2" -insertAfter "someEntry" -parent $gMainFileMenu MyMenuLab2;
menuItem -label "Mylabel" -insertAfter "someEntry" -parent $gMainFileMenu MyMenuLab;
menuItem -divider true -parent $gMainFileMenu MyMenuDiv;
$gMyMenuItemsTest = 1;
}
return "RemoveMyMenuItems()"; // Returns the callback
}
global proc RemoveMyMenuItems()
{
global int $gMyMenuItemsTest;
if( $gMyMenuItemsTest == 1 )
{
// Delete your items if they exist (yes we are kind of
// doing the check twice, but I find it safe.
// The user could have deleted it from Maya in the command
// line for whatever reason, more robustness is always good.
if(`menu -ex MyMenuDiv`) deleteUI -mi MyMenuDiv;
if(`menu -ex MyMenuLab`) deleteUI -mi MyMenuLab;
if(`menu -ex MyMenuLab2`) deleteUI -mi MyMenuLab2;
}
}
And then the actual call to the AddMenuItemSafe:
// The menu we want to use ... here it is the File Menu.
global string $gMainFileMenu;
// Our variables needed for the addSafe call
global int $gMyMenuItemsTest;
global string $gMyMenuVariable;
$gMyMenuItemsTest = 0;
$gMyMenuVariable = "";
// The menu creation
addMenuItemSafe($gMainFileMenu, "AddMyMenuItems", "gMyMenuVariable");
You are free to put that function call in a plugin instantiation or where ever it pleases you.
For more information about the function AddMenuItemSafe, you can go in your Maya Scripts Directory it should be there "AddMenuItemSafe.mel".
How to find a menu name
Note for the menu variable names, you can "build" them by using the following convention
"g" + View + Name + "Menu"
Where :
View is the view where you can find that menu. Ex: Main, Polygons, Animations, etc.
Name is the name of the menu. Ex: File, Edit, Mesh, etc.
Note Autodesk will sometimes rename menus and use old globalVariable names so using this method might not always work

Textmate 2 scope: Increase font size for section in latex document

Q: When editing a .tex file in Textmate 2: How can you print latex sections in a bigger font size?
I added following grammar to the Latex bundle:
{ patterns = (
{ begin = 'section\{';
end = '\}';
name = 'markup.heading.1.latex';
},
);
}
And additionally I added following Setting that is applied to the newly defined markup.heading.1.latex scope:
{ fontName = 'Baskerville';
fontSize = '2.25em';
}
The problem: it only matches sections without a leading :
... and when I change the scope definition to the following (adding \\ in front of "section"):
{ patterns = (
{ begin = '\\section\{';
end = '\}';
name = 'markup.heading.1.latex';
},
);
}
.. the scope is not applied.
Any ideas?
The answer to your question is to edit the theme bundle.
The procedure to change the appearance of section in Texmate 2 is the following:
In the Bundle editor menu, select Edit bundles ....
Then select the bundle Themes.
From menu File, select New, and when prompted select Setting
Give a name to the setting.
In the Scope Selector field use meta.function.section.latex
Then you can edit the setting, for example:
{
fontName = 'Courier';
fontSize = 36;
}
Then save (in the usual way, e.g, command-s).
You can repeat for other sectioning command (to identify the scope, move the cursor on the appropriate place and then use the following key combination control-shift-P)
answer taken from here Please give the original author credit.

Resources