⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adaptoramin.java

📁 数据库通用适配器:实现行粒度的数据库的转换
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		final FormData fd_button_1 = new FormData();
		fd_button_1.top = new FormAttachment(button_2, 0, SWT.TOP);
		fd_button_1.right = new FormAttachment(button_2, -30);
		button_1.setLayoutData(fd_button_1);
		button_1.setText("删除");
		
		final Button button = new Button(composite, SWT.NONE);
		button.setSize(50,10);
		final FormData fd_button = new FormData();		
		//fd_button.left = new FormAttachment(0, 644);
		fd_button.right = new FormAttachment(button_1,-30);
		fd_button.top = new FormAttachment(button_2, 0, SWT.TOP);
		button.setLayoutData(fd_button);
		button.setText("添加");
		
				
		
		final Button button_4 = new Button(composite, SWT.CHECK);
		final FormData fd_button_4 = new FormData();
		fd_button_4.bottom = new FormAttachment(button_2, 22, SWT.TOP);
		fd_button_4.top = new FormAttachment(button_1, 0, SWT.TOP);
		fd_button_4.right = new FormAttachment(0, 70);
		fd_button_4.left = new FormAttachment(0, 10);
		button_4.setLayoutData(fd_button_4);
		button_4.setText("全选");


		final Button button_3 = new Button(composite, SWT.NONE);
		button_3.setSize(130,10);
		final FormData fd_button_3 = new FormData();		
		fd_button_3.bottom = new FormAttachment(button_2, 22, SWT.TOP);
		fd_button_3.top = new FormAttachment(button_1, 0, SWT.TOP);
		fd_button_3.right = new FormAttachment(0, 150);
		fd_button_3.left = new FormAttachment(button_4, 20);
		button_3.setLayoutData(fd_button_3);
		button_3.setText("执行任务");
		
		final Button button_3_1 = new Button(composite, SWT.NONE);
		button_3_1.setSize(130,10);
		final FormData fd_button_3_1 = new FormData();
		fd_button_3_1.top = new FormAttachment(button_3, -22, SWT.BOTTOM);
		fd_button_3_1.bottom = new FormAttachment(button_3, 0, SWT.BOTTOM);
		fd_button_3_1.left = new FormAttachment(button_3, 30);
		fd_button_3_1.right = new FormAttachment(0, 235);
		button_3_1.setLayoutData(fd_button_3_1);
		button_3_1.setText("查看日志");
		
	
		
		button.addSelectionListener(new SelectionAdapter(){
        	public void widgetSelected(SelectionEvent event){       		
        		
        			count++;        			
        			TableItem newItemTableItem = new TableItem(table, SWT.BORDER);        			
        			newItemTableItem.setText(0, "方案"+count);   
        			TableItem[] items=table.getItems();
        			int k=items.length-1;
        			System.out.println("k="+k);
        			System.out.println();
        			//方案名设置
        			Message m=new Message();
        			m.setPeriod("每年");
        			m.setImportWay("更新");
        			m.setUse(0);
        			Message.add(m);
        			final TableEditor editor=new TableEditor(table);
        			final Text text=new Text(table,SWT.None);
        			text.setText(items[k].getText());
        			Text1.add(text);
        			editor.grabHorizontal=true;
        			editor.setEditor(text, items[k], 0);
        			
        			text.addModifyListener(new ModifyListener(){

        				public void modifyText(ModifyEvent e) {
        					
        					editor.getItem().setText(0, text.getText());
        				}				
        			});
        			//数据源选择
        			final TableEditor editor1=new TableEditor(table);
        			final CCombo combo=new CCombo(table,SWT.None);
        			System.out.println("DataSour的大小:"+S.getS().size());
        			if(S.getS().size()!=0)
        				for(int j=0;j<S.getS().size();j++){
						    combo.add(((Source)S.getS().elementAt(j)).getDateName());
						}
        			//comb[k][1]=combo;        			
        			comb1.add(combo);
        			combo.setText("");
        			editor1.grabHorizontal=true;
        			editor1.setEditor(combo, items[k], 1);
        			combo.addModifyListener(new ModifyListener(){

        				public void modifyText(ModifyEvent e) {
        					
        					editor1.getItem().setText(1, combo.getText());
        				}
        				
        			});
        			
        			//目的数据库选择
        			final TableEditor editor2=new TableEditor(table);
        			final CCombo combo1=new CCombo(table,SWT.None);        			
        			editor2.grabHorizontal=true;
        			if(S.getS().size()!=0)
        				for(int j=0;j<S.getS().size();j++){
						    combo1.add(((Source)S.getS().elementAt(j)).getDateName());
						}
        			comb2.add(combo1);
        			combo1.setText("");
        			//comb[k][2]=combo1;
        			editor2.setEditor(combo1, items[k], 3);
        			combo1.addModifyListener(new ModifyListener(){

        				public void modifyText(ModifyEvent e) {
        				
        					editor2.getItem().setText(1, combo1.getText());
        				}
        				
        			});
        			//数据源的表
        			final TableEditor editor3=new TableEditor(table);
        			final CCombo combo2=new CCombo(table,SWT.None);
        			combo2.setText("");
        			comb3.add(combo2);
        			editor3.grabHorizontal=true;
        			editor3.setEditor(combo2, items[k], 2);
        			combo2.addModifyListener(new ModifyListener(){

        				public void modifyText(ModifyEvent e) {
        					
        					editor3.getItem().setText(1, combo2.getText());
        				}
        				
        			});
        			combo.addSelectionListener(new SelectionAdapter(){
        	        	public void widgetSelected(SelectionEvent event){ 
        	        		//String query="SELECT * from SCOTT.PERSON";
        	        		if(!combo.getText().equals("")){
        	        			for(int i=0;i<S.getS().size();i++){
        	        				if(combo.getText().equals(((Source)S.getS().elementAt(i)).getDateName())){ 
        	        					if(((Source)S.getS().elementAt(i)).getType().equals("Excel")){
        	        						combo2.removeAll();
        	        						combo2.setText(((Source)S.getS().elementAt(i)).getDateName());
        	        					}else{	
        	        						try {
        	        							String schema=((Source)S.getS().elementAt(i)).getSchema();
        	        							//String query="SELECT * from "+schema;
        	        							Class.forName(((Source)S.getS().elementAt(i)).getDriver());
        										
												Connection con=DriverManager.getConnection(((Source)S.getS().elementAt(i)).getConnURL(),
														((Source)S.getS().elementAt(i)).getUseName(),((Source)S.getS().elementAt(i)).getPassword());
												System.out.println(""+((Source)S.getS().elementAt(i)).getConnURL()+((Source)S.getS().elementAt(i)).getUseName()+((Source)S.getS().elementAt(i)).getPassword());
												Statement stmt=con.createStatement();
												DatabaseMetaData m_DBMetaData =con.getMetaData();
												ResultSet rs=m_DBMetaData.getTables(null, schema,"%",new String[]{"TABLE"});
												combo2.removeAll();
												while(rs.next()) {
													System.out.println(rs.getString("TABLE_NAME"));
													
													combo2.add(rs.getString("TABLE_NAME"));
												}												
												System.out.println("");												
												rs.close();
												stmt.close();												
												con.close();
											} catch (SQLException e) {
												// TODO Auto-generated catch block
												e.printStackTrace();
											}
											catch(java.lang.Exception ex){
												ex.printStackTrace();
											}
        	        					
        	        					}
        	        				}
        	        			}
        	        		}
        	        	}
        			});
        			
        			//目的数据库表
        			final TableEditor editor4=new TableEditor(table);
        			final CCombo combo3=new CCombo(table,SWT.None);
        			combo3.setText("");
        			comb4.add(combo3);
        			editor4.grabHorizontal=true;
        			editor4.setEditor(combo3,items[k], 4);
        			combo3.addModifyListener(new ModifyListener(){

        				public void modifyText(ModifyEvent e) {
        					
        					editor4.getItem().setText(1, combo3.getText());
        				}
        				
        			}); 
        			
        			combo1.addSelectionListener(new SelectionAdapter(){
        	        	public void widgetSelected(SelectionEvent event){ 
        	        		//String query="SELECT * from SCOTT.PERSON";
        	        		if(!combo1.getText().equals("")){
        	        			for(int i=0;i<S.getS().size();i++){
        	        				if(combo1.getText().equals(((Source)S.getS().elementAt(i)).getDateName())){ 
        	        					if(((Source)S.getS().elementAt(i)).getType().equals("Excel")){
        	        						combo3.removeAll();
        	        						combo3.setText(((Source)S.getS().elementAt(i)).getDateName());
        	        					}else{	
        	        						try {
        	        							String schema=((Source)S.getS().elementAt(i)).getSchema();
        	        							String query="SELECT * from "+schema;
        	        							Class.forName(((Source)S.getS().elementAt(i)).getDriver());
												Connection con=DriverManager.getConnection(((Source)S.getS().elementAt(i)).getConnURL(),
														((Source)S.getS().elementAt(i)).getUseName(),((Source)S.getS().elementAt(i)).getPassword());
												Statement stmt=con.createStatement();
												DatabaseMetaData m_DBMetaData =con.getMetaData();
												ResultSet rs=m_DBMetaData.getTables(null, schema,"%",new String[]{"TABLE"});
												combo3.removeAll();
												while(rs.next()) {
													System.out.println(rs.getString("TABLE_NAME"));
													
													combo3.add(rs.getString("TABLE_NAME"));
												}												
												System.out.println("");												
												rs.close();
												stmt.close();												
												con.close();
											} catch (SQLException e) {
												// TODO Auto-generated catch block
												e.printStackTrace();
											}
											catch(java.lang.Exception ex){
												ex.printStackTrace();
											}
        	        					
        	        					}
        	        				}
        	        			}
        	        		}
        	        	}
        			});
        			//方案状态
        			final TableEditor editor5=new TableEditor(table);
        			final CCombo combo4=new CCombo(table,SWT.None);
        			combo4.setText("");
        			combo4.setEnabled(true);
        			comb5.add(combo4);
        			editor5.grabHorizontal=true;
        			editor5.setEditor(combo4,items[k], 5);
        			combo3.addModifyListener(new ModifyListener(){

        				public void modifyText(ModifyEvent e) {
        					editor5.getItem().setText(1, combo4.getText());
        				}
        				
        			});	
        		}
        		
		});
		
		button_1.addSelectionListener(new SelectionAdapter(){
			public void widgetSelected(SelectionEvent event){ 
				TableItem[] items=table.getItems();
        		for(int i=0;i<items.length;i++)
        		{
        			if(!items[i].getChecked())continue;
        			int index=table.indexOf(items[i]);
        			if(index<0)continue;   
        			((Text)Text1.elementAt(index)).dispose();
        			((CCombo)comb1.elementAt(index)).dispose();
        			((CCombo)comb2.elementAt(index)).dispose();
        			((CCombo)comb3.elementAt(index)).dispose();
        			((CCombo)comb4.elementAt(index)).dispose();
        			((CCombo)comb5.elementAt(index)).dispose();
        			table.remove(index); 
        			Message.removeElementAt(index);
        			Text1.remove(index);
        			comb1.remove(index);
        			comb2.remove(index);
        			comb3.remove(index);
        			comb4.remove(index);
        			comb5.remove(index);
        			items=table.getItems();
        			//if(index!=(items.length-1))
        			for(int j=index;j<table.getItems().length;j++)
        			{
        				//方案名设置
            			final TableEditor editor=new TableEditor(table);
            			editor.grabHorizontal=true;
            			editor.setEditor(((Text)Text1.elementAt(j)), items[j], 0);
            			
            			//数据源选择
            			final TableEditor editor1=new TableEditor(table);            			
            			editor1.grabHorizontal=true;
            			editor1.setEditor(((CCombo)comb1.elementAt(j)), items[j], 1);
            			
            		
            			//目的数据库选择
            			final TableEditor editor2=new TableEditor(table);
            			editor2.grabHorizontal=true;
            			
            			editor2.setEditor(((CCombo)comb2.elementAt(j)), items[j], 3);
            			
            			//数据源的表
            			final TableEditor editor3=new TableEditor(table);
            			editor3.grabHorizontal=true;
            			editor3.setEditor(((CCombo)comb3.elementAt(j)), items[j], 2);
//            			目的数据库表
            			final TableEditor editor4=new TableEditor(table);            			
            			editor4.grabHorizontal=true;
            			editor4.setEditor(((CCombo)comb4.elementAt(j)), items[j], 4);
            			//方案状态
            			final TableEditor editor5=new TableEditor(table);            			
            			editor5.grabHorizontal=true;
            			editor5.setEditor(((CCombo)comb5.elementAt(j)), items[j], 5);
            			
            		}
    			}
			}
            		
    		});
		
		button_2.addSelectionListener(new SelectionAdapter(){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -