JComboBox display two different lists
I have a JComboBox in a JTable column. The requirement is that the JComboBox displays two different lists based upon which mouse button is clicked on the JComboBox. i.e When user clicks on mouse Button1 the JComboBox should popup with a list of products(user default products). But, when the user clicks on mouse Button2 the JComboBox should popup with a different list of products(all the products).
Any help will be appreciated,
Thanks in advance!
UNDEBUGGED, UNTESTED, OFF THE CUFF CODE
public class myEditor extends AbstractCellEditor implements TableCellEditor {
private int sel = 0;
private String[][] str = {{"Option 1", "Option 2", "Option 3"},
{"Select 1", "Select 2", "Select 3"}};
private JComboBox[] fieldCombos = new JComboBox[str.length];
private DefaultCellEditor[] fieldEditors = new DefaultCellEditor[str.length];
public myEditor() {
for (int i=0; i<fieldEditors.length; i++) {
fieldCombos[i] = new JComboBox();
for (int j=0; j<str[0].length; j++) {
fieldCombos.addItem(str[0][j]);
fieldEditors[i] = new DefaultCellEditor(fieldCombos[i]);
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected, int row, int column) {
fieldCombos[sel].setSelectedItem(value);
return fieldEditors[sel];
public void setSelector(int Selector) {
if (Selector>=0 && Selector<str.length) sel=Selector;
Similar Messages
-
How to display two different hierarchical sequential lists in one o/p scree
Hi Gurus,
I have a requirement for displaying two hierarchical lists in one output screen. I have created my hierarchical sequential lists using
function module : - 'REUSE_ALV_HIERSEQ_LIST_DISPLAY', but i dont know how to append my second hierarchical sequential list
into this.
Will it be easily possible through OO ABAP where i will have two containers at the screen and each container will display one hierarchical sequential list at the output screen. But i have no idea how to do this through OO ABAP.
Please help...
Thanks,
Bhupenderi want to display the records corresponding to the user details enterd
in Text Fields in the same Frame by replacintg the previous display..1) Quit multi-posting.
2) You where given an answer in your last posting on the topic.
3) The code isn't formatted so don't expect us to read the code. -
Display two Different reports together
Hi Experts,
Is there any way that I can display two different reports simultaneously/together in Web Portal
Thanks in advance.Hi Manpreet,
Although we can easily perform this in WAD , but as you asked the other option which requires some coding .
Check the below thread for the same :
how to display two lables in alv report
Hope it helps,
Supriya -
How to display two different parts of one image in two windows?
hi everyone:) i need to display two different parts of one image in two windows. i have problem with displaying :/ because after creating windows there aren't any images :( i supose my initialization code of creating windows is incomplete, maybe i miss something or maybe there is some inconistency. graphics in java is not my strong position. complete code is below. can anybody help me?
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;
import java.util.*;
class ImgFrame extends JFrame
private BufferedImage img;
ImgFrame(BufferedImage B_Img, int x, int y, int w, int h)
super("d");
img=new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);
img=B_Img.getSubimage(x, y, w, h);
}//end ImgFrame construction
public void paint(Graphics g)
Graphics2D g2D = (Graphics2D)g;
g.drawImage(img, 8, 8, null);
}//end paint method
public Dimension getPrefferedSize()
if(img==null)
return(new Dimension(100,100));
else
return(new Dimension(img.getWidth(null),img.getHeight(null)));
}//end of GetPrefferedSize method
}//end ImgFrame class
public class TestGraph2D_03 extends Component
static BufferedImage IMG;
public static void Load()
try
IMG=ImageIO.read(new File("c:/test.bmp"));
catch(IOException ioe)
System.out.println("an exception: "+ioe);
}//end try catch
}//end TestGraph2D_03 construction
public static void main(String[] args)
Load();
ImgFrame F1 = new ImgFrame(IMG, 0, 0, 8, 8);
ImgFrame F2 = new ImgFrame(IMG, 8, 8, 8, 8);
F1.addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
System.exit(0);
F1.pack();
F1.setVisible(true);
F2.addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
System.exit(0);
F2.pack();
F2.setVisible(true);
}//end of main method in TestGraph2D_01 class
}//end of TestGraph2D_03 classNever override the paint(...) method of a Swing component.
If you have a sub image then add the image to a JLabel and add the label to the GUI. No need for custom painting. -
Can a combobox contain two different list seperated by vdivider ?
Hi,
I need a combobox which contains list item of two types.
These items should be in two different list in a combobox seperated
with vidivider. Is this is possible.
Any one with suggestion or solution can help a lot.
Thanks...hi,
Actually the i have an arrayCollection which which is having
items as some strings, thing is that some strings having numbers at
their end like text2,text5... and some are like text,demo.... these
strings are added in arrayCollection such that the strings with
numbers are at top and then are strings without number.
I want that the combobox should show numbered strings in
first half of list then there should be a
verticalDivider(mx:VDividedBox) and the string without numbers in
second half.
I mean to say a combobox with mx:VDividedBox which is having
two lists. something like this,
<mx:ComboBox width="250" dataProvider="" >
<mx:itemRenderer>
<mx:Component>
<mx:VDividedBox>
<mx:List dataProvider="" labelField="" >
</mx:List>
<mx:List dataProvider="" labelField="" >
</mx:List>
</mx:Component>
</mx:itemRenderer>
</mx:ComboBox>
Here it is some thing like i want but how to provide the
dataprovider to this i don't know.
Is it possible ? any how i need a solution for it...Please
reply if have some solution -
Group radio button itemrenderers of two different lists
Hello ,
How do I group radio button item-renderers of two different lists? If i select a radio button of list 1, then the list 2 Radiobutton which was selected previously should be un-selected. How to do?Are you looking for something like this:
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Declarations>
<fx:Component className="MyRenderer">
<s:ItemRenderer>
<s:RadioButton id="rb" label="{data}" group="{outerDocument.rbg}" width="100%" height="100%" />
</s:ItemRenderer>
</fx:Component>
<s:RadioButtonGroup id="rbg" />
</fx:Declarations>
<s:List id="myList" itemRenderer="MyRenderer">
<s:dataProvider>
<s:ArrayList>
<fx:String>0</fx:String>
<fx:String>1</fx:String>
<fx:String>2</fx:String>
</s:ArrayList>
</s:dataProvider>
</s:List>
<s:List id="myList2" x="150" itemRenderer="MyRenderer">
<s:dataProvider>
<s:ArrayList>
<fx:String>A</fx:String>
<fx:String>B</fx:String>
<fx:String>C</fx:String>
</s:ArrayList>
</s:dataProvider>
</s:List>
</s:Application> -
How to Display two different objects in a single table header in Cross Tab?
i All,
I've a reqiurement for a Cross Tab Report like I need two different objects that should be displayed side-by-side, one object's values after another in a single header. In the picture below I've shown the objects separately in two rows, top header having BSNLNL,MTNLNL,RCOMNL and Header-2 having AIRTIL,RCOMIL. But requirements needs to be showing like this,
BSNLNL
MTNLNL
RCOMNL
AIRTIL
RCOMIL
Actually, the data for the header comes from a single object called Operator. I've show the Operators name ending with NL and after that names ending with IL. So, i've separated the data into two variables using the below formulae.
IL:
=[Billing Operator]
Where
Match([Billing Operator];"*IL")=1
NL:
=[Billing Operator]
Where
Match([Billing Operator];"*NL")=1
Also, the NL data should start first and after the NL data's last value ends, the IL data should begin.
One more thing is that I've to show '0' for null values. So i've used the below formulae on the column data. You can see below that except the "Outgoing ILD Mins in the month from Mobile Network" everything else showing fine. I don't understand why.
=If
Substr([Franchise];3;1)="M"
Then
[Mobile Outgoing Charged Usage Minutes]
Else
0
I tried different approaches but couldn't find a solution. Could you please help me?
I'm using BO WebI 4.1 SP1
Regards,
Naren Vema.Hi Naren,
No need to split Billing Operator object. Create a variable-
V_IL_NL= If Match([Billing Operator];"*IL")=1 Then "IL" ElseIf Match([Billing Operator];"*NL")=1 Then "NL"
1) Put V_IL_NL variable below Billing Operator object header.
2) Sort and create break on this variable.
3) Delete Footer column. it will automatically create when you apply break.
4) Hide V_IL_NL variable from this header.
~Anuj -
Display two different column types in cross tab
I am using Cross Tab template in crystal XI and I have to show two different column types one is of type int and other is of type string. Below is the format of the report
AmountGiven Amount Spent Attended
Mike 5000 3000 Yes
Steve 200 200 No
Is there a way I can do this showing "yes" or "no" in the third column???
Thanks...Hi
If you are trying to show "yes" or "no" for a column value in a cross tab, then yes we can try using a formula for it.
I would suggest you 2 ways that you can try at your end:
1.
a) Create a formula in the cross tab expert and write your condition.
for eg: if Sum({Orders.Order amount}) > 5000 then "yes" else "no"
b) Then select that formula in the summarized fields in cross tab expert and change the summary to MODE.
c) You can see the "yes" and "no" Within the same box.
2.
a) Add a field to the colums in the cross tab expert.
b) A column gets inserted in the cross tab.
c) Right click the field and select format field.
d) Go to Common tab and write a formula for the display string.
e) Write the condition in that formula.
f) You can see a new column with the expected values.
Hope this helps you..
Please revert incase of any queries.
Regards
Pradeep Hulke -
Create Site Column and add it to two different list as dependent lookup column
I want to create two lookup lists that will have one common column. The common column values will vary depending on the list.
For ex: List A holds Countries (USA) and their Currency code (USD). List B holds States (New York) and their code (NY). The lists are completely independent of each other. I would like to create a common site column named "Code" of type
Text and use it across these two lists. Is it possible?
My solution so far -
a. created the site column (programmatically) which is pretty straight forward.
b. created list definition with two fields (Title and Code).
c. created list instance for Country list. Added data rows in the elements.xml. But not sure how to add Code field as dependent lookup.
If I remove the code field from the elements.xml, the solution deploys successfully creating the Country list with just the Title field. But I need both the fields. Any help is appreciated.
Here is a look at the elements.xml with data rows for Country list instance
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListInstance Title="List Instance" OnQuickLaunch="TRUE" TemplateType="10001" Url="Lists/CountryList" Description="Country Values">
<Data>
<Rows>
<Row>
<Field Name="Title">USA</Field>
<Field Name="Code">USD</Field>
</Row>
<Row>
<Field Name="Title">Japan</Field>
<Field Name="Code">Yen</Field>
</Row>
<Row>
<Field Name="Title">Australia</Field>
<Field Name="Code">AUD</Field>
</Row>
</Rows>
</Data>
</ListInstance>
</Elements>Hi,
According to your post, my understanding is that you want to add lookup field to the list in elements.xml.
I recoment you to create lookup column as site column, then bind the lookup column to the contnet type, and then use the contnet type in the list.
For more information, you can refer to:
http://spcodes.blogspot.com/2013/02/create-custom-content-type-with-lookup.html
http://social.msdn.microsoft.com/Forums/office/en-US/d5ec08d5-cfa7-4bbb-9459-78d04674ee59/add-a-lookup-column-in-the-schemaxml?forum=sharepointcustomizationlegacy
http://www.justanothertechnologyguy.com/2013/01/how-to-create-and-connect-lookup-fields.html
Best Regards,
Linda Li
Linda Li
TechNet Community Support -
How to insert data into two different lists in sharepoint 2010
I have a page containing a dropdown list having two departments like IT, HR.
If i select HR, one input form will display for filling HR related info, these i need to store in HR list.
In the same way for other dept through custom coding.
someone help me on thisHello
chiranjeevi avala
I think You can do it using event listener on Item Creation event of your HR List and put your functionality to add elements in IT list over their.
for more info check this link:
http://msdn.microsoft.com/en-us/library/office/ms437502(v=office.14).aspx
http://msdn.microsoft.com/en-us/library/office/gg749858(v=office.14).aspx
***If my post is answer for your query please mark as answer***
***If my answer is helpful please vote*** -
Fetch Data from two different Lists (Based on criteria)
I have two lists. One is for Designations and another is for
Hirings. Designations list holds all available designations and Hiring list has list of hired employees. Data may look like following...
Designations list:
PostTitle
Software Engineer
Web Developer
Graphic Designer
Trainer
Manager
Team Lead
and Hiring list may look like following
Hirings list:
PostTitle
Employee
Start Date End Date
Trainer David
05-Jun-14
Manager Peter
06-Jun-14 30-Jun-14
PostTitle is lookup column in hirings list. Now, I have to create several views over this data... one of them is of "Vacant Posts" that will fetch all those records from Designations which are either not referenced in hirings or are referenced
in hirings but has some end date.
Vacant Posts View:
Fetch all records from Designation which are NOT in Hirings
UNION
Fetch all records from Designations which are in Hirings But has some END DATE.
Please guide me how can I create this Vacant Posts view ? Is their any out of the box functionality available ? what are the easiest possible ways to accomplish this?
Zia.Yes You can Use CAML.
Below Query can be helpful to start with.
Function GetSharePointList1() {
context = SP.ClientContext.get_curre
nt();
oList = context.get_web().get_lists().getByTitle('SharePoint List 2');
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(query);
items = oList.getItems(camlQuery);
context.load(items);
context.executeQueryAsync(
Function.createDelegate(this, onSuccessSharePointList1),
Function.createDelegate(this, onFail)
function onSuccessSharePointList1(){
recNum = items.get_count();
if(recNum != 0){
var listItemEnumerator = items.getEnumerator();
while(listItemEnumerator.moveNext()){
var oListItem = listItemEnumerator.get_current();
$().SPServices({
operation: "GetListItems",
async: false,
listName: "SharePoint List 2",
CAMLViewFields: "<ViewFields><FieldRef Name='Worklocation'/></ViewFields>",
CAMLQuery: "<Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>" + ReferenceID +
"</Value></Eq></Where></Query>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
Worklocation = ($(this).attr("ows_Worklocation"));
s = ..... (display all in table format)
$("#resultTable").append(s);
i++;
Thanks and Regards Rahul Dagar -
i want some of my users to see all the projects in the Project Center at my top-level site, and those same users to see only the projects they own at a subsite level in Project Center. that way they could see an 'all project' view on the homepage and only
their projects on their dashboard pages (which also have an instance of Project Center web part on them). i have searched and searched but cannot find a solution to this. is there any way to acheive this functionality? thanks in advance for your assistance!I have tried this in the past, but was not successful, as far as I can recall. Once you access the project center webpart in one page, the view will be retained regardless where you see it again. (until you apply a different view or clear your browser cache).
May be an easier solution is to display a 'report' on the home page with ALL projects (much easier to do), and use the Project Center webpart for the My projects view as it is easier to achieve via Project Server Security, than a report.
Cheers,
Prasanna Adavi, Project MVP
Blog:
Podcast:
Twitter:
LinkedIn:
-
ALV Report to have two different Reports
Hi All,
I have a need to display two different reports for the same set of data selections, (Successful data and Error Data) in a Single ALV Layout using a Application tool bar Button. Does anyone have a sample code for this kind of requirement. Preferably using Objects.
Also, how can we check if an object is already created? In other words, how to check for a null reference?
Thanks in advance.
Jr.Sample code for split alv using OOABAP.
this would help you in ur requirement.
go through this program where the screen is divided in two for two alv in different containers.
DATA: save_ok LIKE sy-ucomm,
g_container TYPE scrfname VALUE 'CC1',
g_grid TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container,
gt_fieldcat TYPE lvc_t_fcat,
g_max TYPE i VALUE 100.
declarations for top of page event
Data: gv_c_split type ref to cl_gui_splitter_container,
gv_c_ptv type ref to cl_gui_container,
gv_alv_ptv type ref to cl_gui_alv_grid,
o_dd_doc TYPE REF TO cl_dd_document,
text TYPE sdydo_text_element,
o_split type ref to cl_gui_easy_splitter_container,
o_top type ref to cl_gui_container,
o_bot type ref to cl_gui_container,
gv_c_vp type ref to cl_gui_container.
end of declaration for top of page.
CLASS lcl_event_receiver DEFINITION DEFERRED.
*class lcl_application_dc definition deferred.
DATA: o_event_receiver TYPE REF TO lcl_event_receiver.
g_dc type ref to lcl_application_dc.
DATA: gt_outtab TYPE TABLE OF sbook.
CLASS lcl_event_receiver DEFINITION
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS: handle_f4 FOR EVENT onf4 OF cl_gui_alv_grid
IMPORTING e_fieldname
es_row_no
er_event_data
et_bad_cells
e_display,
handle_top_of_page FOR EVENT top_of_page OF cl_gui_alv_grid
IMPORTING e_dyndoc_id.
METHODS: reset.
METHODS: show_f4.
PRIVATE SECTION.
attributes for creating an own F4-Help
(using a second ALV Grid Control
DATA: f4_grid TYPE REF TO cl_gui_alv_grid,
f4_custom_container TYPE REF TO cl_gui_custom_container.
TYPES: BEGIN OF ty_f4.
TYPES: value TYPE s_class.
TYPES: descr(20) TYPE c.
TYPES: END OF ty_f4.
DATA: f4_itab TYPE TABLE OF ty_f4.
DATA: f4_fieldcatalog TYPE lvc_t_fcat.
attributes to store event parameters
(after the CALL SCREEN command, the event parameters
are not accessible)
TYPES: BEGIN OF onf4_event_parameters_type.
TYPES: c_fieldname TYPE lvc_fname.
TYPES: cs_row_no TYPE lvc_s_roid.
TYPES: cr_event_data TYPE REF TO cl_alv_event_data.
TYPES: ct_bad_cells TYPE lvc_t_modi.
TYPES: c_display TYPE char01.
TYPES: END OF onf4_event_parameters_type.
DATA: f4_params TYPE onf4_event_parameters_type.
Methods to create own F4-Help
(This is done using a second ALV Grid Control)
METHODS: init_f4.
METHODS: build_fieldcatalog.
METHODS: fill_f4_itab .
METHODS: on_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING es_row_no.
ENDCLASS. "lcl_application_f4 DEFINITION
CLASS lcl_event_receiver IMPLEMENTATION
CLASS lcl_event_receiver IMPLEMENTATION.
*§2. Implement an event handler method for event ONF4.
METHOD handle_f4.
Save event parameter as global attributes of this class
(maybe solved differently if you use a function module!)
f4_params-c_fieldname = e_fieldname.
f4_params-cs_row_no = es_row_no.
f4_params-cr_event_data = er_event_data.
f4_params-ct_bad_cells = et_bad_cells.
f4_params-c_display = e_display.
*§3. Call your own f4 help. To customize your popup check
first if the cell is ready for input (event parameter E_DISPLAY).
(parameter E_DISPLAY is checked later in method on_double_click)
(Probably, you would call a function module at this point,
pass the needed event parameter and call the popup screen
within that function module. This is not done in this example
to avoid scattering its code).
CALL SCREEN 101 STARTING AT 10 10.
*§7. Inform the ALV Grid Control that an own f4 help has been processed
to suppress the standard f4 help.
er_event_data->m_event_handled = 'X'.
ENDMETHOD. "on_f4
METHOD show_f4.
DATA: ls_outtab TYPE sbook.
initialize own f4 help if needed
IF f4_custom_container IS INITIAL.
CALL METHOD init_f4.
ENDIF.
CALL METHOD fill_f4_itab.
refresh list of values in f4 help and show it
CALL METHOD f4_grid->refresh_table_display.
CAUTION: Do not use method REFRESH_TABLE_DISPLAY for
your editable ALV Grid instances while handling events
DATA_CHANGED or ONf4. You would overwrite intermediate
values of your output table on frontend.
'f4_grid' is a non-editable ALV Grid Control for the
application specific F4-Help. Therefore, calling
REFRESH_TABLE_DISPLAY for this instance has no
negative effect.
CALL METHOD cl_gui_cfw=>flush.
ENDMETHOD. "show_f4
METHOD init_f4.
DATA: ls_f4_layout TYPE lvc_s_layo.
build fieldcatalog entries for f4
CALL METHOD build_fieldcatalog.
create controls
CREATE OBJECT f4_custom_container
EXPORTING container_name = 'CC_ONF4'.
CREATE OBJECT f4_grid
EXPORTING i_parent = f4_custom_container.
hide toolbar
ls_f4_layout-no_toolbar = 'X'.
CALL METHOD f4_grid->set_table_for_first_display
EXPORTING
is_layout = ls_f4_layout
CHANGING
it_fieldcatalog = f4_fieldcatalog
it_outtab = f4_itab.
register event double click on backend
SET HANDLER me->on_double_click FOR f4_grid.
flush since 'ls_layout' is local!
CALL METHOD cl_gui_cfw=>flush.
ENDMETHOD. "init_f4
METHOD fill_f4_itab.
DATA ls_f4_itab TYPE ty_f4.
Delete all entries in f4_itab to determine
offered values dynamically
CLEAR f4_itab[].
ls_f4_itab-value = 'C'.
ls_f4_itab-descr = text-t03. "Business Class
APPEND ls_f4_itab TO f4_itab.
ls_f4_itab-value = 'Y'.
ls_f4_itab-descr = text-t04. "Economie Class
APPEND ls_f4_itab TO f4_itab.
ls_f4_itab-value = 'F'.
ls_f4_itab-descr = text-t05. "First Class
APPEND ls_f4_itab TO f4_itab.
ENDMETHOD. "fill_f4_itab
METHOD build_fieldcatalog.
DATA: ls_fcat TYPE lvc_s_fcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'VALUE'.
ls_fcat-coltext = text-t02.
ls_fcat-inttype = 'S_CLASS'.
ls_fcat-outputlen = 5.
APPEND ls_fcat TO f4_fieldcatalog.
CLEAR ls_fcat.
ls_fcat-fieldname = 'DESCR'.
ls_fcat-coltext = text-t01.
ls_fcat-inttype = 'C'.
ls_fcat-outputlen = 20.
APPEND ls_fcat TO f4_fieldcatalog.
ENDMETHOD. "build_fieldcatalog
METHOD on_double_click.
*§5. If not already caught by your own f4 help, check whether
the triggered cell was ready for input by using E_DISPLAY
and if not, exit.
IF f4_params-c_display EQ 'X'.
LEAVE SCREEN.
ENDIF.
*§6. After the user selected a value, pass it to the ALV Grid Control:
*§ 6a. Define a field symbol of type: LVC_T_MODI and a structure of
type LVC_S_MODI to pass the value later on.
FIELD-SYMBOLS TYPE lvc_t_modi.
DATA: ls_modi TYPE lvc_s_modi,
ls_f4_itab TYPE ty_f4.
*§ 6b. Dereference attribute M_DATA into your field symbol and add
the selected value to the table to which this symbol points to.
ASSIGN f4_params-cr_event_data->m_data->* TO .
LEAVE TO SCREEN 0.
ENDMETHOD. "on_double_click
METHOD reset.
FIELD-SYMBOLS display_document
EXPORTING parent = o_top.
ENDMETHOD. "handle_top_of_page
ENDCLASS. "lcl_application_f4 IMPLEMENTATION
END-OF-SELECTION.
CALL SCREEN 100.
MODULE PBO OUTPUT *
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
IF g_custom_container IS INITIAL.
PERFORM create_and_init_alv CHANGING gt_outtab[]
gt_fieldcat.
ENDIF.
ENDMODULE. "pbo OUTPUT
MODULE PAI INPUT *
MODULE pai INPUT.
save_ok = sy-ucomm.
CLEAR sy-ucomm.
CASE save_ok.
WHEN 'EXIT' OR 'BACK' OR 'CANCEL'.
PERFORM exit_program.
WHEN 'SWITCH'.
PERFORM switch_edit_mode.
WHEN OTHERS.
do nothing
ENDCASE.
ENDMODULE. "pai INPUT
FORM EXIT_PROGRAM *
FORM exit_program.
LEAVE PROGRAM.
ENDFORM. "exit_program
*& Form build_fieldcat
text
-->PT_FIELDCAT text
FORM build_fieldcat CHANGING pt_fieldcat TYPE lvc_t_fcat.
DATA ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SBOOK'
CHANGING
ct_fieldcat = pt_fieldcat.
LOOP AT pt_fieldcat INTO ls_fcat.
Exchange smoker field with invoice field - just to
make the dependance between SMOKER and CLASS more transparent
(Smoking is only allowed in the first class).
IF ls_fcat-fieldname EQ 'SMOKER'.
ls_fcat-col_pos = 11.
ls_fcat-outputlen = 10.
ls_fcat-edit = 'X'.
Field 'checktable' is set to avoid shortdumps that are caused
by inconsistend data in check tables. You may comment this out
when the test data of the flight model is consistent in your system.
ls_fcat-checktable = '!'. "do not check foreign keys
MODIFY pt_fieldcat FROM ls_fcat.
ELSEIF ls_fcat-fieldname EQ 'INVOICE'.
ls_fcat-col_pos = 7.
MODIFY pt_fieldcat FROM ls_fcat.
ELSEIF ls_fcat-fieldname EQ 'CLASS'.
ls_fcat-edit = 'X'.
ls_fcat-outputlen = 5.
ls_fcat-checktable = '!'. "do not check foreign keys
MODIFY pt_fieldcat FROM ls_fcat.
ENDIF.
ENDLOOP.
ENDFORM. "build_fieldcat
*& Form create_and_init_alv
text
-->PT_OUTTAB text
-->PT_FIELDCAT text
FORM create_and_init_alv CHANGING pt_outtab TYPE STANDARD TABLE
pt_fieldcat TYPE lvc_t_fcat.
DATA: lt_exclude TYPE ui_functions,
ls_layout TYPE lvc_s_layo.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
CREATE OBJECT g_grid
EXPORTING i_parent = g_custom_container.
CREATE OBJECT gv_c_split
EXPORTING
link_dynnr = lv_dynnr
link_repid = lv_repid
parent = g_custom_container
rows = 2
columns = 1
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
others = 3 .
CALL METHOD gv_c_split->set_border
EXPORTING
border = space.
CALL METHOD gv_c_split->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = gv_c_ptv.
CALL METHOD gv_c_split->set_row_height
EXPORTING
id = 1
height = 20
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 6 .
CALL METHOD gv_c_split->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = gv_c_vp .
CALL METHOD gv_c_split->set_row_height
EXPORTING
id = 2
height = 10
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3 .
CREATE OBJECT o_split
EXPORTING
parent = gv_c_ptv
with_border = 1
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
others = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
o_top = o_split->top_left_container.
o_bot = o_split->bottom_right_container.
CREATE OBJECT gv_alv_ptv
EXPORTING
i_parent = o_bot
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5 .
CREATE OBJECT g_grid
EXPORTING
i_parent = gv_c_vp
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5 .
PERFORM build_fieldcat CHANGING pt_fieldcat.
Optionally restrict generic functions to 'change only'.
(The user shall not be able to add new lines).
PERFORM exclude_tb_functions CHANGING lt_exclude.
PERFORM build_data CHANGING pt_outtab.
ls_layout-grid_title = 'F4 help implemented for field CLASS'.
CREATE OBJECT o_event_receiver.
SET HANDLER o_event_receiver->handle_top_of_page FOR gv_alv_ptv.
SET HANDLER o_event_receiver->handle_top_of_page FOR g_grid.
CREATE OBJECT o_dd_doc EXPORTING style = 'ALV_GRID'
no_margins = 'X'.
CALL METHOD gv_alv_ptv->set_table_for_first_display
EXPORTING
is_layout = ls_layout
CHANGING
it_outtab = pt_outtab[]
it_fieldcatalog = pt_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
it_toolbar_excluding = lt_exclude
is_layout = ls_layout
CHANGING
it_fieldcatalog = pt_fieldcat
it_outtab = pt_outtab[].
CALL METHOD gv_alv_ptv->list_processing_events
EXPORTING
i_event_name = 'TOP_OF_PAGE'
i_dyndoc_id = o_dd_doc.
register f4 for field CLASS
PERFORM register_events.
Set editable cells to ready for input initially
CALL METHOD g_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
ENDFORM. "CREATE_AND_INIT_ALV
*& Form exclude_tb_functions
text
-->PT_EXCLUDE text
FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
Only allow to change data not to create new entries (exclude
generic functions).
DATA ls_exclude TYPE ui_func.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
APPEND ls_exclude TO pt_exclude.
ENDFORM. " EXCLUDE_TB_FUNCTIONS
*& Form build_data
text
--> p1 text
<-- p2 text
FORM build_data CHANGING pt_outtab TYPE STANDARD TABLE.
DATA: ls_sbook TYPE sbook,
l_index TYPE i.
SELECT * FROM sbook INTO TABLE gt_outtab UP TO g_max ROWS.
IF sy-subrc NE 0.
PERFORM generate_entries CHANGING pt_outtab.
ENDIF.
LOOP AT pt_outtab INTO ls_sbook.
l_index = sy-tabix.
CLEAR ls_sbook-class.
Alternate between smoker and non smoker to make
it more obvious what this example is about
l_index = l_index MOD 2.
IF l_index EQ 1.
ls_sbook-smoker = 'X'.
ELSE.
ls_sbook-smoker = ' '.
ENDIF.
MODIFY pt_outtab FROM ls_sbook.
ENDLOOP.
ENDFORM. " build_data
*& Form generate_entries
text
-->PT_SBOOK text
FORM generate_entries CHANGING pt_sbook TYPE STANDARD TABLE.
DATA: ls_sbook TYPE sbook,
l_month(2) TYPE c,
l_day(2) TYPE c,
l_date(8) TYPE c,
l_prebookid TYPE i.
ls_sbook-carrid = 'LH'.
ls_sbook-connid = '0400'.
ls_sbook-forcurkey = 'DEM'.
ls_sbook-loccurkey = 'USD'.
ls_sbook-custtype = 'B'.
DO 110 TIMES.
l_prebookid = sy-index.
ls_sbook-forcuram = sy-index * 10.
ls_sbook-loccuram = ls_sbook-loccuram * 2.
ls_sbook-customid = sy-index.
ls_sbook-counter = 18.
ls_sbook-agencynum = 11.
l_month = sy-index / 10 + 1.
DO 2 TIMES.
l_day = 3 + l_month + sy-index * 2.
l_date+0(4) = '2000'.
l_date+4(2) = l_month.
l_date+6(2) = l_day.
ls_sbook-fldate = l_date.
SUBTRACT 3 FROM l_day.
ls_sbook-order_date+0(6) = l_date+0(6).
ls_sbook-order_date+6(2) = l_day.
ls_sbook-bookid = l_prebookid * 2 + sy-index.
IF sy-index EQ 1.
ls_sbook-smoker = 'X'.
ELSE.
ls_sbook-smoker = space.
ENDIF.
ls_sbook-luggweight = l_prebookid * 10.
IF ls_sbook-luggweight GE 1000.
ls_sbook-wunit = 'G'.
ls_sbook-class = 'C'.
ELSE.
ls_sbook-wunit = 'KG'.
ls_sbook-class = 'Y'.
ENDIF.
IF ls_sbook-bookid > 40 AND ls_sbook-wunit EQ 'KG'.
ls_sbook-invoice = 'X'.
ENDIF.
IF ls_sbook-bookid EQ 2.
ls_sbook-cancelled = 'X'.
ls_sbook-class = 'F'.
ENDIF.
APPEND ls_sbook TO pt_sbook.
ENDDO.
ENDDO.
ENDFORM. " generate_entries
*& Form register_events
text
FORM register_events.
*§1. Register event ONF4 at frontend using method
register_f4_for_fields. For this purpose, you pass a table
with all fields, for which you want to implement your own
f4 help.
remark: If you want to use an own f4 help for fields where
no standard f4 help exists set field F4AVAILABL for
this field in the fieldcatalog.
DATA: lt_f4 TYPE lvc_t_f4 WITH HEADER LINE.
CLEAR lt_f4.
lt_f4-fieldname = 'CLASS'.
If you would like to deregister the field again,
pass value SPACE with field 'register'.
lt_f4-register = 'X'.
*§ 1b. If the value range in your f4 help depends on other
values of cells that are input enabled, set the
GETBEFORE parameter.
The consequence is that the ALV Grid Control raises
event DATA_CHANGED before the f4 help is called to
check values that the f4 help depends on.
lt_f4-getbefore = 'X'.
The next parameter is used to change values after onf4 has
been processed. The ALV Grid Control will raise
event DATA_CHANGED afterwards, if you set it.
lt_f4-chngeafter = space.
INSERT TABLE lt_f4.
CALL METHOD g_grid->register_f4_for_fields
EXPORTING
it_f4 = lt_f4[].
register events for abap objects (backend)
SET HANDLER o_event_receiver->handle_f4 FOR g_grid.
ENDFORM. " register_events
MODULE status_0101 OUTPUT
MODULE status_0101 OUTPUT.
SET PF-STATUS 'POPUP'.
SET TITLEBAR 'POPUP'.
CALL METHOD o_event_receiver->show_f4.
ENDMODULE. " STATUS_0101 OUTPUT
*& Module USER_COMMAND_0101 INPUT
text
MODULE user_command_0101 INPUT.
PERFORM user_command.
ENDMODULE. " USER_COMMAND_0101 INPUT
*& Form user_command
text
FORM user_command.
DATA: save_ok TYPE sy-ucomm.
save_ok = sy-ucomm.
CLEAR sy-ucomm.
CASE save_ok.
WHEN 'CANCEL'.
CALL METHOD o_event_receiver->reset.
LEAVE TO SCREEN 0.
ENDCASE.
ENDFORM. "user_command
*& Form switch_edit_mode
text
FORM switch_edit_mode.
IF g_grid->is_ready_for_input( ) EQ 0.
set edit enabled cells ready for input
CALL METHOD g_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
ELSE.
lock edit enabled cells against input
CALL METHOD g_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 0.
ENDIF.
ENDFORM. "switch_edit_mode -
One Model, Two Trees, Two Different Views
Here is what I need to do:
- Maintain 1 and only 1 model for tree data
- Display two different JTrees, each using the same model, but one showing all the data, and the other only showing a subset.
Example:
My Tree Data model is a file system containing all drives and folders below them.
One tree needs to show all the drives and folders below them.
The other tree needs to only show one drive and the folders below it.
I am open to any suggestions, even if you are just brainstorming.My abstract adapter for my experimantal GEDCOM editor - still being worked on
abstract public class AbstractTreeViewAdapter implements TreeModel
private String rootElementName_;
private Model m_model;
private Element rootElement_;
public AbstractTreeViewAdapter(Model model, String rootElementName)
m_model = model;
rootElementName_ = rootElementName;
Element root = m_model.getGEDCOMDocument().getRootElement();
rootElement_ = root.getChild(rootElementName, root.getNamespace());
m_model.addPropertyChangeListener(new PropertyChangeListener()
public void propertyChange(PropertyChangeEvent event)
if (rootElement_ != null)
removeAllChildNodesFromRoot();
Element root = m_model.getGEDCOMDocument().getRootElement();
rootElement_ = root.getChild(rootElementName_, root.getNamespace());
addAllChildNodes();
// Methods to edit the tree /////////////////////////////////////
public void removeChild(Object parent, int childIndex)
public void removeChild(Object parent, Element child)
int childIndex = getIndexOfChild(parent, child);
if (childIndex < 0)
throw new IllegalArgumentException("Cannot find child");
removeChild(parent, childIndex);
public void insertChild(Object parent, Element child, int index)
int numberOfChildren = getChildCount(parent);
if ((index < 0) || (index > numberOfChildren))
throw new IllegalArgumentException("Index out of range");
Object[] path = getPath((Element)parent);
Object[] childToInsert = {child};
int[] indexToInsert = {index};
TreeModelEvent event = new TreeModelEvent(this, path, indexToInsert, childToInsert);
Iterator it = m_listeners.iterator();
while (it.hasNext())
TreeModelListener listener = (TreeModelListener)it.next();
listener.treeNodesInserted(event);
private Object[] getPath(Element element)
LinkedList result = new LinkedList();
while ((element != null) && !element.getName().equals(rootElementName_))
result.addFirst(element);
element = element.getParent();
result.addFirst(getRoot());
return result.toArray();
public Object getChild(Object obj, int index)
if (obj instanceof Element)
return ((Element)obj).getChildren().get(index);
else if (obj instanceof Model)
return getChild(rootElement_, index);
else
return null;
public int getChildCount(Object obj)
if (obj instanceof Element)
return ((Element)obj).getChildren().size();
else if (obj instanceof Model)
int childCount = (rootElement_ == null)?0:rootElement_.getChildren().size();
return childCount;
else
return 0;
public int getIndexOfChild(Object obj, Object child)
if (obj instanceof Element)
Iterator it = ((Element)obj).getChildren().iterator();
for( int index = 0; it.hasNext(); index++)
if (it.next() == child)
return index;
return -1;
else if (obj instanceof Model)
return getIndexOfChild(rootElement_, child);
else
return -1;
public Object getRoot()
return m_model;
public boolean isLeaf(Object obj)
if (obj instanceof Element)
return !((Element)obj).hasChildren();
else if (obj instanceof Model)
return false;
else
return true;
public void removeTreeModelListener(javax.swing.event.TreeModelListener treeModelListener)
m_listeners.remove(treeModelListener);
public void valueForPathChanged(javax.swing.tree.TreePath treePath, Object obj)
System.out.println("VFPC"+obj);
public void addTreeModelListener(javax.swing.event.TreeModelListener treeModelListener)
m_listeners.remove(treeModelListener);
m_listeners.add(treeModelListener);
public void removeAllChildNodesFromRoot()
Object[] path =
{getRoot()};
removeAllChildNodes(path);
public void removeAllChildNodes(Object[] path)
ChildrenOf children = new ChildrenOf(path[path.length-1]);
if (children.size() == 0)
return;
TreeModelEvent event = new TreeModelEvent(this, path, children.getIndexSet(), children.getChildren());
Iterator it = m_listeners.iterator();
while (it.hasNext())
TreeModelListener listener = (TreeModelListener)it.next();
listener.treeNodesRemoved(event);
public void addAllChildNodes()
Object[] path =
{getRoot()};
addAllChildNodes(path);
public void addAllChildNodes(Object[] path)
ChildrenOf children = new ChildrenOf(path[path.length-1]);
if (children.size() == 0)
return;
TreeModelEvent event = new TreeModelEvent(this, path, children.getIndexSet(), children.getChildren());
Iterator it = m_listeners.iterator();
while (it.hasNext())
TreeModelListener listener = (TreeModelListener)it.next();
listener.treeNodesInserted(event);
private class ChildrenOf
ChildrenOf(Object parent)
if (parent instanceof Element)
children_ = ((Element)parent).getChildren().toArray();
else if (parent instanceof Model)
if (rootElement_ == null)
children_ = new Object[0];
else
children_ = rootElement_.getChildren().toArray();
else
children_ = new Object[0];
int[] getIndexSet()
int[] indexes = new int[children_.length];
for (int i = 0; i < children_.length; i++)
indexes[i] = i;
return indexes;
Object[] getChildren()
return children_;
int size()
return children_.length;
private Object[] children_;
public void notifyAllChanged(TreeModelEvent event)
Iterator it = m_listeners.iterator();
while (it.hasNext())
TreeModelListener listener = (TreeModelListener)it.next();
listener.treeStructureChanged(event);
public void notifyStructureChanged(TreeModelEvent event)
Iterator it = m_listeners.iterator();
while (it.hasNext())
TreeModelListener listener = (TreeModelListener)it.next();
listener.treeStructureChanged(event);
* The set of listeners that will be notifed when the tree changes
private Vector m_listeners = new Vector();
} -
How can I share data between two forms on different lists
Using a custom content type, I created two lists that I want to share the same data - one is a calendar. Our employees complete a form from the "Out of Office Request" list that has workflow functionality that sends an email to that person's
manager. If the manager approves the request, the item automatically populates the "Out of Office Calendar." The problem is that the only information from the request list that populates the calendar is the Title field and date/time fields.
I need the manager name in order to create a view for each manager.
How can I connect the other information in the request list to the calendar list. It seems to me that if the title and date fields carry over the information, there should be a way to connect the other information. I'm using Designer.
I've tried to connect the two lists' webparts with the wizard, but when I get to the page that maps the two lists, there are no column names and the "Next >" button is grayed out. This seems like the logical place to connect the two lists,
but it isn't working.Hi,
According to your post, my understanding is that you wanted share data between two forms on different lists.
To show external information on the calendar event, there are two methods: Calculated column, workflow. You can refer to:
A Simple Guide to Show More Information on a Calendar Event
I recommend to use workflow to achieve what you want. But you need to create a people column to display the manager.
You can create a workflow associated to the "Out of Office Request" list, add action to Start Approve Process. If the manager approves the request, you can create a item in the calendar, and then update the people column and the title column.
Then the calendar will display the Title, date/time and the manager.
To create a view for each manager, you need to modify the Filter. You can use the people column is equal to the manager name or the Title contains the manager name.
Thank you for your understanding.
Best Regards,
Linda Li
Linda Li
TechNet Community Support
Maybe you are looking for
-
Post Author: jacquie CA Forum: Desktop Intelligence Reporting anyone has a solution for this error: An error has occurred: The viewstate is invalid for this page and might be corrupted.
-
How do you filter out moving objects in a movie?
Hello! I'v searched the internet for solutions to this but I cann't find any. Im prittie new and I need to make a house on fire while two guys (one is me) will be walking away from it, towards the camera. I want to filter out these two guys and only
-
Convert a line read from text file into string
how to convert a line from text file into string? i know how to convert to numbers, private int parseLine1(String line) { StringTokenizer tokenizer = new StringTokenizer(line); value1 = Integer.valueOf(tokenizer.nextToken()).
-
LSMW - cannot be run in background since recent SAP Notes
Hi Sorry if this needs to be moved as not really S&A. We are on a 4.6C R3 system and are in the process of importing Basis Support Package 61 SAPKB46C61 and I now seem to have lost the ability to run an LSMW in background - the thing runs but does no
-
Incopy CS4/Win: Prevent the input or change text in tables
Hi I have a plugin for InCopy CS4. In this plugin, I like to prevent the input or the change of text in tables. This works in the layout window, I can detect if the user clicks into a table and then I prevent the input. - How can I do this in the Gal