From d6fa96b4cd67cf4fa18b5b9b6739f9bc2494a9f4 Mon Sep 17 00:00:00 2001 From: guest Date: Tue, 23 Sep 2008 21:29:27 +0000 Subject: initial import git-svn-id: http://manut.eu/svn/yalp/trunk@1 f059d3a0-6783-47b7-97ff-1fe0bbf25129 --- src/YalpClients/SwtClient/GUI/GUI.java | 2101 ++++++++++++++++++++ src/YalpClients/SwtClient/GUI/InitGUI.java | 58 + src/YalpClients/SwtClient/GUI/LoadDialog.java | 110 + .../SwtClient/GUI/SWTResourceManager.java | 145 ++ src/YalpClients/SwtClient/GUI/SortListener.java | 63 + src/YalpClients/SwtClient/GUI/StartDialog.java | 236 +++ 6 files changed, 2713 insertions(+) create mode 100644 src/YalpClients/SwtClient/GUI/GUI.java create mode 100644 src/YalpClients/SwtClient/GUI/InitGUI.java create mode 100644 src/YalpClients/SwtClient/GUI/LoadDialog.java create mode 100644 src/YalpClients/SwtClient/GUI/SWTResourceManager.java create mode 100644 src/YalpClients/SwtClient/GUI/SortListener.java create mode 100644 src/YalpClients/SwtClient/GUI/StartDialog.java (limited to 'src/YalpClients/SwtClient/GUI') diff --git a/src/YalpClients/SwtClient/GUI/GUI.java b/src/YalpClients/SwtClient/GUI/GUI.java new file mode 100644 index 0000000..4c0e474 --- /dev/null +++ b/src/YalpClients/SwtClient/GUI/GUI.java @@ -0,0 +1,2101 @@ +/* + * Copyright (c) 2006 Manuel Traut and Volker Dahnke + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: Manuel Traut and Volker Dahnke + */ + +package YalpClients.SwtClient.GUI; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.layout.*; +import org.eclipse.swt.widgets.*; +import org.eclipse.swt.events.*; +import java.util.*; + +import YalpInterfaces.*; +import YalpClients.SwtClient.*; + +/* + * + * Class GUI + * + * + * + * @author Volker Dahnke / Manuel Traut + * + * @version 1 02-04-2006
+ * + */ +public class GUI extends org.eclipse.swt.widgets.Composite { + + public Model model; + public Composite resultComposite; + public Composite playlistComposite; + public Composite bottemComposite; + public Table resultTable1; + public Table resultTable2; + public Composite composite1; + public Composite changeComposite; + public Table UserTable; + public Composite composite3; + + private AccessRights userKind; + private StyledText styledText1; + private CTabFolder cTabFolder1; + private CTabItem tab1; + private Composite container1; + private Composite topComposite; + private Group find; + private Group logo; + private CTabItem tab2; + private Composite container2; + private Group group1; + private Group group2; + private CLabel authorLabel; + private CLabel titleLabel; + private CLabel streamLabel2; + private CLabel actualStreamLabel2; + private CLabel actualStreamLabel1; + private CLabel streamLabel1; + private CLabel data2; + private CLabel data1; + private Button shutdown; + private TableColumn ip; + private TableColumn userName; + public Table iptable; + private Composite composite4; + + private Button submitButton; + private CLabel adminAddLabel; + private CLabel passwdAddLable; + private CLabel usernameAddLable; + private CLabel realnameAddLabel; + private CCombo adminAdd; + private Text realnameAdd; + private Text passwdAdd; + private Text usernameAdd; + private Group tab3group5; + private Button next; + private Button stop; + private Button play; + private CLabel cLabel2; + private Button save; + private Text userTableId; + private Text passwd; + private Text username; + private Text userTableName; + private CLabel adminLabel; + private CCombo adminCombo; + private CLabel nameLable; + private CLabel passwdLable; + private CLabel usernameLable; + private CLabel idLable; + private Group tab3group4; + private Button delete; + private Button add1; + private Group tab3Group3; + private Group tab3Group2; + private Group tab3Group1; + private Composite container3; + private Button deleteButton; + private Button addButton; + private StyledText status; + private Button saveButton; + private Text id; + private CLabel idLabel; + private CLabel cLabel1; + private CLabel nameLabel; + private CLabel pathLabel; + private CLabel lastEditLable; + private CLabel ownerIdLabel; + private CLabel resolutionLabel; + private CLabel vBitrateLabel; + private CLabel aBitrateLabel; + private CLabel durationLabel; + private CLabel yearLabel; + private CLabel categoryLabel; + private CLabel albumLabel; + private CCombo type; + private Text name; + private Text path; + private Text lastEdit; + private Text ownerId; + private Text resolution; + private Text vBitrate; + private Text aBitrate; + private Text duration; + private Text year; + private Text category; + private Text album; + private Text author; + private Text title; + private Composite composite2; + private Table playlistTable; + private Button add2; + private Button del; + private Boolean isNotPlaying=true; + private Boolean paused =true; + private CTabItem tab3; + private Composite parent; + private Display display; + final Image pauseImage=new Image(this.getDisplay(),"img/pause.gif"); + final Image playImage=new Image(this.getDisplay(),"img/play.gif"); + final Image forwardImage=new Image(this.getDisplay(),"img/forward.gif"); + { + //Register as a resource user - SWTResourceManager will + //handle the obtaining and disposing of resources + SWTResourceManager.registerResourceUser(this); + } + + public GUI( Composite parent, Display display, Model model, + AccessRights userKind, int style ) { + + super(parent, style); + + this.parent = parent; + this.display = display; + this.model = model; + this.userKind = userKind; + + initGUI(); + } + + private void initGUI() { + try { + this.setSize(800, 600); + this.setBackground(SWTResourceManager.getColor(192, 192, 192)); + GridLayout thisLayout = new GridLayout(1, true); + thisLayout.marginWidth = 5; + thisLayout.marginHeight = 5; + thisLayout.numColumns = 1; + thisLayout.makeColumnsEqualWidth = true; + thisLayout.horizontalSpacing = 5; + thisLayout.verticalSpacing = 5; + this.setLayout(thisLayout); + + { + if (this.userKind.value() == AccessRights._USER){ + cTabFolder1 = new CTabFolder(this, SWT.NONE); + GridData cTabFolder1LData = new GridData(); + cTabFolder1LData.widthHint = 787; + cTabFolder1LData.heightHint = 568; + cTabFolder1.setLayoutData(cTabFolder1LData); + { + tab1 = new CTabItem(cTabFolder1,SWT.NONE); + tab1.setText("Find"); + { + container1 = new Composite(cTabFolder1,SWT.NONE); + tab1.setControl(container1); + RowLayout container1Layout = new RowLayout(org.eclipse.swt.SWT.HORIZONTAL); + container1.setLayout(container1Layout); + { + topComposite = new Composite(container1,SWT.NONE); + GridLayout topCompositeLayout = new GridLayout(); + topCompositeLayout.makeColumnsEqualWidth = true; + topCompositeLayout.numColumns = 2; + topCompositeLayout.verticalSpacing = 2; + topCompositeLayout.horizontalSpacing = 5; + topComposite.setLayout(topCompositeLayout); + RowData topCompositeLData = new RowData(); + topCompositeLData.width = 783; + topCompositeLData.height = 566; + topComposite.setLayoutData(topCompositeLData); + { + find = new Group(topComposite,SWT.NONE); + this.find(find,resultComposite,playlistComposite,bottemComposite,1); + } + { + logo = new Group(topComposite,SWT.NONE); + this.logo(logo); + } + { + resultComposite = new Composite(topComposite,SWT.NONE); + resultTable1 = new Table(resultComposite,SWT.MULTI|SWT.FULL_SELECTION); + resultTable1.setToolTipText("Medias"); + resultTable1.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent evt) { + add2.setEnabled(true); + } + }); + this.resultTable(resultComposite,resultTable1,1); + } + { + playlistComposite = new Composite(topComposite,SWT.NONE); + FormLayout playlistCompositeLayout = new FormLayout(); + playlistComposite.setLayout(playlistCompositeLayout); + GridData playlistCompositeLData = new GridData(); + playlistCompositeLData.heightHint = 390; + playlistCompositeLData.horizontalAlignment = GridData.FILL; + playlistComposite.setLayoutData(playlistCompositeLData); + playlistComposite.setVisible(false); + playlistComposite.setSize(238, 390); + { + next = new Button(playlistComposite,SWT.PUSH | SWT.CENTER); + FormData nextLData = new FormData(); + nextLData.width = 45; + nextLData.height = 21; + nextLData.left = new FormAttachment(0, 1000, 185); + nextLData.top = new FormAttachment(0, 1000, 365); + next.setLayoutData(nextLData); + next.setEnabled(false); + next.setFont(SWTResourceManager.getFont("Times", 8, 1, false, false)); + next.setToolTipText("play next Title"); + next.setImage(forwardImage); + next.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent evt) { + model.next(); + } + }); + } + { + stop = new Button(playlistComposite,SWT.PUSH | SWT.CENTER); + FormData stopLData = new FormData(); + stopLData.width = 35; + stopLData.height = 21; + stopLData.left = new FormAttachment(0, 1000, 91); + stopLData.top = new FormAttachment(0, 1000, 365); + stop.setLayoutData(stopLData); + stop.setImage(new Image(this.getDisplay(),"img/stop.gif")); + stop.setEnabled(false); + stop.setToolTipText("stop"); + stop.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent evt) { + if (model.stop()){ + play.setEnabled(true); + next.setEnabled(false); + stop.setEnabled(false); + play.setImage(playImage); + play.setToolTipText("play"); + isNotPlaying=true; + } + + } + }); + } + { + play = new Button(playlistComposite,SWT.PUSH | SWT.CENTER); + FormData playLData = new FormData(); + playLData.width = 35; + playLData.height = 21; + playLData.left = new FormAttachment(0, 1000, 50); + playLData.top = new FormAttachment(0, 1000, 365); + play.setLayoutData(playLData); + play.setImage(playImage); + play.setEnabled(false); + play.setToolTipText("play"); + play.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent evt) { + stop.setEnabled(true); + if (playlistTable.getItemCount()>1)next.setEnabled(true); + del.setEnabled(false); + //add2.setEnabled(false); + if (isNotPlaying){ + play.setCursor(SWTResourceManager.getCursor(SWT.CURSOR_WAIT)); + if(model.play()){ + play.setImage(pauseImage); + play.setToolTipText("pause"); + play.setCursor(SWTResourceManager.getCursor(SWT.NONE)); + isNotPlaying= false; + }else; + }else{ + if(model.pause()){ + if (paused){ + play.setImage(playImage); + play.setToolTipText("play"); + paused=false; + }else{ + play.setImage(pauseImage); + play.setToolTipText("pause"); + paused=true; + } + }else; + } + + } + }); + } + { + add2 = new Button(playlistComposite,SWT.PUSH | SWT.CENTER); + FormData addLData = new FormData(); + addLData.width = 25; + addLData.height = 21; + addLData.left = new FormAttachment(0, 1000, 2); + addLData.top = new FormAttachment(0, 1000, 160); + add2.setLayoutData(addLData); + add2.setText(">>"); + add2.setEnabled(false); + add2.setToolTipText("add to Playlist"); + add2.setFont(SWTResourceManager.getFont("Times", 8, 1, false, false)); + add2.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent evt) { + if (System.getProperty("os.name")== "Mac OS X"){ + for (int i=resultTable1.getSelectionCount()-1;i>=0;i--){ + int id=new Integer(resultTable1.getSelection()[i].getText(0)).intValue(); + System.out.println(resultTable1.getSelection()[i].getText(1)); + model.add2PlayList(id); + } + }else{ + for (int i=0;i playlist=model.getToPlaylist(); + for(int i=0;i1&& !isNotPlaying)next.setEnabled(true); + } + }); + } + { + del = new Button(playlistComposite,SWT.PUSH | SWT.CENTER); + FormData delLData = new FormData(); + delLData.width = 25; + delLData.height = 21; + delLData.left = new FormAttachment(0, 1000, 2); + delLData.top = new FormAttachment(0, 1000, 200); + del.setLayoutData(delLData); + del.setEnabled(false); + del.setToolTipText("del from Playlist"); + del.setText("<<"); + del.setFont(SWTResourceManager.getFont("Times", 8, 1, false, false)); + del.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent evt) { + for (int i=playlistTable.getSelectionCount()-1;i>=0;i--){ + int pos = playlistTable.getSelectionIndices()[i]; + model.removeFromPlayList(pos); + } + + del.setEnabled(false); + while(playlistTable.getItemCount()!=0){ + playlistTable.remove(0); + } + ArrayList playlist=model.getToPlaylist(); + for(int i=0;i resultList = model.getUser(); + for (int i = 0; i < resultList.size(); i++) { + TableItem item; + YalpUser result = resultList.get(i); + item = new TableItem(UserTable,SWT.NONE); + item.setText(0,new Integer(result.id).toString()); + item.setText(1,result.name); + // item.setText(2,result.password); + item.setText(3,result.realName); + item.setText(4,model.accessRightsName(result.level)); + } + tab3group4.setVisible(false); + } + }); + } + { + add1 = new Button(tab3Group3,SWT.PUSH | SWT.CENTER); + add1.setText("Add"); + FormData addLData = new FormData(); + addLData.width = 45; + addLData.height = 21; + addLData.left = new FormAttachment(0, 1000, 7); + addLData.top = new FormAttachment(0, 1000, 254); + add1.setLayoutData(addLData); + add1.setToolTipText("add new User "); + add1.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent evt) { + tab3group5.setVisible(true); + } + }); + } + { + UserTable = new Table(tab3Group3,SWT.SINGLE|SWT.FULL_SELECTION); + FormData UserTableLData = new FormData(); + UserTableLData.width = 467; + UserTableLData.height = 224; + UserTableLData.left = new FormAttachment(11, 1000, 0); + UserTableLData.right = new FormAttachment(988, 1000, 0); + UserTableLData.top = new FormAttachment(19, 1000, 0); + UserTableLData.bottom = new FormAttachment(864, 1000, 0); + UserTable.setLayoutData(UserTableLData); + UserTable.setHeaderVisible(true); + UserTable.setToolTipText("registrated User"); + UserTable.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent evt) { + userTableId.setText(UserTable.getSelection()[0].getText(0)); + username.setText(UserTable.getSelection()[0].getText(1)); + passwd.setText(UserTable.getSelection()[0].getText(2)); + userTableName.setText(UserTable.getSelection()[0].getText(3)); + adminCombo.setText(UserTable.getSelection()[0].getText(4)); + tab3group4.setVisible(true); + } + }); + { + TableColumn id = new TableColumn(UserTable,SWT.BEGINNING); + id.setText("ID"); + id.setWidth(45); + id.setMoveable(true); + id.addListener(SWT.Selection, new SortListener(this,UserTable,0,5)); + TableColumn userName = new TableColumn(UserTable,SWT.BEGINNING); + userName.setMoveable(true); + userName.setText("Username"); + userName.setWidth(120); + userName.addListener(SWT.Selection, new SortListener(this,UserTable,1,5)); + TableColumn passwd = new TableColumn(UserTable,SWT.BEGINNING); + passwd.setMoveable(true); + passwd.setText("Password"); + passwd.setWidth(120); + passwd.addListener(SWT.Selection, new SortListener(this,UserTable,2,5)); + TableColumn name = new TableColumn(UserTable,SWT.BEGINNING); + name.setMoveable(true); + name.setText("Name"); + name.setWidth(130); + name.addListener(SWT.Selection, new SortListener(this,UserTable,3,5)); + TableColumn admin = new TableColumn(UserTable,SWT.BEGINNING); + admin.setMoveable(true); + admin.setText("Admin"); + admin.setWidth(74); + admin.addListener(SWT.Selection, new SortListener(this,UserTable,4,5)); + //TableColumn huhu=new TableColumn(UserTable,SWT.BEGINNING); + //huhu.dispose(); + ArrayList resultList = model.getUser(); + for (int i = 0; i < resultList.size(); i++) { + TableItem item; + YalpUser result = resultList.get(i); + item = new TableItem(UserTable,SWT.NONE); + item.setText(0,new Integer(result.id).toString()); + item.setText(1,result.name); + //item.setText(2,result.passwd); + item.setText(3,result.realName); + item.setText(4,model.accessRightsName(result.level)); + } + } + } + } + { + tab3group4 = new Group(container3,SWT.NONE); + FormLayout tab3group4Layout = new FormLayout(); + tab3group4.setLayout(tab3group4Layout); + tab3group4.setText("Edit User"); + GridData tab3group4LData = new GridData(); + tab3group4LData.widthHint = 256; + tab3group4LData.heightHint = 284; + tab3group4.setLayoutData(tab3group4LData); + tab3group4.setVisible(false); + { + save = new Button(tab3group4,SWT.PUSH | SWT.CENTER); + save.setText("save"); + FormData saveLData = new FormData(); + saveLData.width = 45; + saveLData.height = 21; + saveLData.left = new FormAttachment(0, 1000, 42); + saveLData.top = new FormAttachment(0, 1000, 157); + save.setLayoutData(saveLData); + save.setToolTipText("save Changes"); + save.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent evt) { + YalpUser toChange = new YalpUser(); + toChange.id = new Integer(userTableId.getText()).intValue(); + toChange.name = username.getText(); + model.changeUser(toChange, passwd.getText(), Action.EDIT); + while(UserTable.getItemCount()!=0){ + UserTable.remove(0); + } + ArrayList resultList = model.getUser(); + for (int i = 0; i < resultList.size(); i++) { + TableItem item; + YalpUser result = resultList.get(i); + item = new TableItem(UserTable,SWT.NONE); + item.setText(0,new Integer(result.id).toString()); + item.setText(1,result.name); + //item.setText(2,result.passwd); + item.setText(3,result.realName); + item.setText(4,model.accessRightsName(result.level)); + } + tab3group4.setVisible(false); + } + }); + } + { + userTableName = new Text(tab3group4,SWT.NONE); + FormData text2LData = new FormData(); + text2LData.width = 94; + text2LData.height = 14; + text2LData.left = new FormAttachment(0, 1000, 117); + text2LData.top = new FormAttachment(0, 1000, 112); + userTableName .setLayoutData(text2LData); + } + { + passwd = new Text(tab3group4,SWT.NONE); + FormData passwdLData = new FormData(); + passwdLData.width = 94; + passwdLData.height = 14; + passwdLData.left = new FormAttachment(0, 1000, 117); + passwdLData.top = new FormAttachment(0, 1000, 92); + passwd.setLayoutData(passwdLData); + } + { + username = new Text(tab3group4,SWT.NONE); + FormData usernameLData = new FormData(); + usernameLData.width = 94; + usernameLData.height = 14; + usernameLData.left = new FormAttachment(0, 1000, 117); + usernameLData.top = new FormAttachment(0, 1000, 72); + username.setLayoutData(usernameLData); + } + { + userTableId = new Text(tab3group4,SWT.NONE); + FormData text1LData = new FormData(); + text1LData.width = 94; + text1LData.height = 14; + text1LData.left = new FormAttachment(0, 1000, 117); + text1LData.top = new FormAttachment(0, 1000, 52); + userTableId.setLayoutData(text1LData); + userTableId.setEditable(false); + } + { + adminLabel = new CLabel(tab3group4,SWT.NONE); + adminLabel.setText("Admin:"); + FormData adminLabelLData = new FormData(); + adminLabelLData.width = 42; + adminLabelLData.height = 21; + adminLabelLData.left = new FormAttachment(0, 1000, 27); + adminLabelLData.top = new FormAttachment(0, 1000, 127); + adminLabel.setLayoutData(adminLabelLData); + } + { + idLable = new CLabel(tab3group4,SWT.NONE); + idLable.setText("Id:"); + FormData idLableLData = new FormData(); + idLableLData.width = 20; + idLableLData.height = 21; + idLableLData.left = new FormAttachment(107, 1000, 0); + idLableLData.right = new FormAttachment(185, 1000, 0); + idLableLData.top = new FormAttachment(167, 1000, 0); + idLableLData.bottom = new FormAttachment(241, 1000, 0); + idLable.setLayoutData(idLableLData); + } + { + usernameLable = new CLabel(tab3group4,SWT.NONE); + usernameLable.setText("Username:"); + FormData usernameLableLData = new FormData(); + usernameLableLData.width = 58; + usernameLableLData.height = 21; + usernameLableLData.left = new FormAttachment(107, 1000, 0); + usernameLableLData.right = new FormAttachment(333, 1000, 0); + usernameLableLData.top = new FormAttachment(237, 1000, 0); + usernameLableLData.bottom = new FormAttachment(311, 1000, 0); + usernameLable.setLayoutData(usernameLableLData); + } + { + passwdLable = new CLabel(tab3group4,SWT.NONE); + passwdLable.setText("Password:"); + FormData passwdLableLData = new FormData(); + passwdLableLData.width = 56; + passwdLableLData.height = 21; + passwdLableLData.left = new FormAttachment(107, 1000, 0); + passwdLableLData.right = new FormAttachment(326, 1000, 0); + passwdLableLData.top = new FormAttachment(308, 1000, 0); + passwdLableLData.bottom = new FormAttachment(382, 1000, 0); + passwdLable.setLayoutData(passwdLableLData); + } + { + nameLable = new CLabel(tab3group4,SWT.NONE); + nameLable.setText("Name:"); + FormData nameLableLData = new FormData(); + nameLableLData.width = 37; + nameLableLData.height = 21; + nameLableLData.left = new FormAttachment(107, 1000, 0); + nameLableLData.right = new FormAttachment(251, 1000, 0); + nameLableLData.top = new FormAttachment(378, 1000, 0); + nameLableLData.bottom = new FormAttachment(452, 1000, 0); + nameLable.setLayoutData(nameLableLData); + } + { + adminCombo = new CCombo(tab3group4,SWT.NONE); + FormData adminComboLData = new FormData(); + adminComboLData.width = 81; + adminComboLData.height = 16; + adminComboLData.left = new FormAttachment(458, 1000, 0); + adminComboLData.right = new FormAttachment(849, 1000, 0); + adminComboLData.top = new FormAttachment(466, 1000, 0); + adminComboLData.bottom = new FormAttachment(522, 1000, 0); + adminCombo.setLayoutData(adminComboLData); + { + adminCombo.add("true"); + adminCombo.add("false"); + } + } + } + tab3group5 = new Group(container3,SWT.NONE); + FormLayout tab3group5Layout = new FormLayout(); + tab3group5.setLayout(tab3group5Layout); + GridData tab3group5LData = new GridData(); + tab3group5LData.widthHint = 500; + tab3group5LData.heightHint = 99; + tab3group5.setLayoutData(tab3group5LData); + tab3group5.setText("Add User"); + tab3group5.setVisible(false); + { + submitButton = new Button(tab3group5,SWT.PUSH | SWT.CENTER); + submitButton.setText("Submit"); + FormData submitButtonLData = new FormData(); + submitButtonLData.width = 50; + submitButtonLData.height = 21; + submitButtonLData.left = new FormAttachment(0, 1000, 382); + submitButtonLData.top = new FormAttachment(0, 1000, 52); + submitButton.setLayoutData(submitButtonLData); + submitButton.setToolTipText("add User"); + submitButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent evt) { + System.out.println("submit"); + YalpUser toChange = new YalpUser(); + toChange.id = 100; + toChange.name = usernameAdd.getText(); + toChange.realName = realnameAdd.getText(); + model.changeUser(toChange, passwdAdd.getText(), Action.CREATE); + while(UserTable.getItemCount()!=0){ + UserTable.remove(0); + } + ArrayList resultList = model.getUser(); + for (int i = 0; i < resultList.size(); i++) { + TableItem item; + YalpUser result = resultList.get(i); + item = new TableItem(UserTable,SWT.NONE); + item.setText(0,new Integer(result.id).toString()); + item.setText(1,result.name); + //item.setText(2,result.passwd); + item.setText(3,result.realName); + item.setText(4,model.accessRightsName(result.level)); + } + } + }); + } + { + adminAddLabel = new CLabel(tab3group5,SWT.NONE); + adminAddLabel.setText("Admin:"); + FormData adminAddLabelLData = new FormData(); + adminAddLabelLData.width = 40; + adminAddLabelLData.height = 21; + adminAddLabelLData.left = new FormAttachment(0, 1000, 291); + adminAddLabelLData.top = new FormAttachment(0, 1000, 17); + adminAddLabel.setLayoutData(adminAddLabelLData); + } + { + passwdAddLable = new CLabel(tab3group5,SWT.NONE); + passwdAddLable.setText("Password:"); + FormData passwdAddLableLData = new FormData(); + passwdAddLableLData.width = 60; + passwdAddLableLData.height = 21; + passwdAddLableLData.left = new FormAttachment(0, 1000, 17); + passwdAddLableLData.top = new FormAttachment(0, 1000, 57); + passwdAddLable.setLayoutData(passwdAddLableLData); + } + { + usernameAddLable = new CLabel(tab3group5,SWT.NONE); + usernameAddLable.setText("Username:"); + FormData usernameAddLableLData = new FormData(); + usernameAddLableLData.width = 60; + usernameAddLableLData.height = 21; + usernameAddLableLData.left = new FormAttachment(0, 1000, 17); + usernameAddLableLData.top = new FormAttachment(0, 1000, 37); + usernameAddLable.setLayoutData(usernameAddLableLData); + } + { + realnameAddLabel = new CLabel(tab3group5,SWT.NONE); + realnameAddLabel.setText("Name:"); + FormData realnameAddLabelLData = new FormData(); + realnameAddLabelLData.width = 60; + realnameAddLabelLData.height = 21; + realnameAddLabelLData.left = new FormAttachment(0, 1000, 17); + realnameAddLabelLData.top = new FormAttachment(0, 1000, 17); + realnameAddLabel.setLayoutData(realnameAddLabelLData); + } + { + adminAdd = new CCombo(tab3group5,SWT.NONE); + FormData adminAddLData = new FormData(); + adminAddLData.width = 65; + adminAddLData.height = 12; + adminAddLData.left = new FormAttachment(0, 1000, 347); + adminAddLData.top = new FormAttachment(0, 1000, 22); + adminAdd.setLayoutData(adminAddLData); + adminAdd.setText("false"); + { + adminAdd.add("false"); + adminAdd.add("true"); + } + } + { + realnameAdd = new Text(tab3group5,SWT.NONE); + FormData realnameAddLData = new FormData(); + realnameAddLData.width = 174; + realnameAddLData.height = 14; + realnameAddLData.left = new FormAttachment(0, 1000, 82); + realnameAddLData.top = new FormAttachment(0, 1000, 22); + realnameAdd.setLayoutData(realnameAddLData); + } + { + usernameAdd = new Text(tab3group5,SWT.NONE); + FormData usernameAddLData = new FormData(); + usernameAddLData.width = 174; + usernameAddLData.height = 13; + usernameAddLData.left = new FormAttachment(165, 1000, 0); + usernameAddLData.right = new FormAttachment(525, 1000, 0); + usernameAddLData.top = new FormAttachment(429, 1000, 0); + usernameAddLData.bottom = new FormAttachment(560, 1000, 0); + usernameAdd.setLayoutData(usernameAddLData); + } + { + FormData PasswdAddLData = new FormData(); + PasswdAddLData.width = 174; + PasswdAddLData.height = 13; + PasswdAddLData.left = new FormAttachment(165, 1000, 0); + PasswdAddLData.right = new FormAttachment(525, 1000, 0); + PasswdAddLData.top = new FormAttachment(631, 1000, 0); + PasswdAddLData.bottom = new FormAttachment(762, 1000, 0); + passwdAdd = new Text(tab3group5,SWT.NONE); + passwdAdd.setLayoutData(PasswdAddLData); + } + } + } + cTabFolder1.setSelection(0); + } + else{ + GridData testLData = new GridData(); + testLData.widthHint = 792; + testLData.heightHint = 590; + Composite simpelUser = new Composite(this, SWT.NONE); + RowLayout testLayout = new RowLayout(org.eclipse.swt.SWT.HORIZONTAL); + simpelUser.setLayout(testLayout); + simpelUser.setLayoutData(testLData); + { + topComposite = new Composite(simpelUser,SWT.NONE); + GridLayout topCompositeLayout = new GridLayout(); + topCompositeLayout.makeColumnsEqualWidth = true; + topCompositeLayout.numColumns = 2; + topCompositeLayout.verticalSpacing = 2; + topCompositeLayout.horizontalSpacing = 5; + topComposite.setLayout(topCompositeLayout); + RowData topCompositeLData = new RowData(); + topCompositeLData.width = 783; + topCompositeLData.height = 566; + topComposite.setLayoutData(topCompositeLData); + { + find = new Group(topComposite,SWT.NONE); + this.find(find,resultComposite,playlistComposite,bottemComposite,1); + } + { + logo = new Group(topComposite,SWT.NONE); + this.logo(logo); + } + { + resultComposite = new Composite(topComposite,SWT.NONE); + resultTable1 = new Table(resultComposite,SWT.MULTI|SWT.FULL_SELECTION); + resultTable1.setToolTipText("Medias"); + resultTable1.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent evt) { + add2.setEnabled(true); + } + }); + this.resultTable(resultComposite,resultTable1,1); + } + { + playlistComposite = new Composite(topComposite,SWT.NONE); + FormLayout playlistCompositeLayout = new FormLayout(); + playlistComposite.setLayout(playlistCompositeLayout); + GridData playlistCompositeLData = new GridData(); + playlistCompositeLData.heightHint = 390; + playlistCompositeLData.horizontalAlignment = GridData.FILL; + playlistComposite.setLayoutData(playlistCompositeLData); + playlistComposite.setVisible(false); + playlistComposite.setSize(238, 390); + { + next = new Button(playlistComposite,SWT.PUSH | SWT.CENTER); + FormData nextLData = new FormData(); + nextLData.width = 45; + nextLData.height = 21; + nextLData.left = new FormAttachment(0, 1000, 185); + nextLData.top = new FormAttachment(0, 1000, 365); + next.setLayoutData(nextLData); + next.setEnabled(false); + next.setFont(SWTResourceManager.getFont("Times", 8, 1, false, false)); + next.setToolTipText("play next Title"); + next.setImage(forwardImage); + next.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent evt) { + model.next(); + } + }); + } + { + stop = new Button(playlistComposite,SWT.PUSH | SWT.CENTER); + FormData stopLData = new FormData(); + stopLData.width = 35; + stopLData.height = 21; + stopLData.left = new FormAttachment(0, 1000, 91); + stopLData.top = new FormAttachment(0, 1000, 365); + stop.setLayoutData(stopLData); + stop.setImage(new Image(this.getDisplay(),"img/stop.gif")); + stop.setEnabled(false); + stop.setToolTipText("stop"); + stop.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent evt) { + if (model.stop()){ + play.setEnabled(true); + next.setEnabled(false); + stop.setEnabled(false); + play.setImage(playImage); + play.setToolTipText("play"); + isNotPlaying=true; + } + + } + }); + } + { + play = new Button(playlistComposite,SWT.PUSH | SWT.CENTER); + FormData playLData = new FormData(); + playLData.width = 35; + playLData.height = 21; + playLData.left = new FormAttachment(0, 1000, 50); + playLData.top = new FormAttachment(0, 1000, 365); + play.setLayoutData(playLData); + play.setImage(playImage); + play.setEnabled(false); + play.setToolTipText("play"); + play.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent evt) { + stop.setEnabled(true); + if (playlistTable.getItemCount()>1)next.setEnabled(true); + del.setEnabled(false); + //add2.setEnabled(false); + if (isNotPlaying){ + play.setCursor(SWTResourceManager.getCursor(SWT.CURSOR_WAIT)); + if(model.play()){ + play.setImage(pauseImage); + play.setToolTipText("pause"); + play.setCursor(SWTResourceManager.getCursor(SWT.NONE)); + isNotPlaying= false; + }else; + }else{ + if(model.pause()){ + if (paused){ + play.setImage(playImage); + play.setToolTipText("play"); + paused=false; + }else{ + play.setImage(pauseImage); + play.setToolTipText("pause"); + paused=true; + } + }else; + } + + } + }); + } + { + add2 = new Button(playlistComposite,SWT.PUSH | SWT.CENTER); + FormData addLData = new FormData(); + addLData.width = 25; + addLData.height = 21; + addLData.left = new FormAttachment(0, 1000, 2); + addLData.top = new FormAttachment(0, 1000, 160); + add2.setLayoutData(addLData); + add2.setText(">>"); + add2.setEnabled(false); + add2.setToolTipText("add to Playlist"); + add2.setFont(SWTResourceManager.getFont("Times", 8, 1, false, false)); + add2.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent evt) { + if (System.getProperty("os.name")== "Mac OS X"){ + for (int i=resultTable1.getSelectionCount()-1;i>=0;i--){ + int id=new Integer(resultTable1.getSelection()[i].getText(0)).intValue(); + System.out.println(resultTable1.getSelection()[i].getText(1)); + model.add2PlayList(id); + } + }else{ + for (int i=0;i playlist=model.getToPlaylist(); + for(int i=0;i1&& !isNotPlaying)next.setEnabled(true); + } + }); + } + { + del = new Button(playlistComposite,SWT.PUSH | SWT.CENTER); + FormData delLData = new FormData(); + delLData.width = 25; + delLData.height = 21; + delLData.left = new FormAttachment(0, 1000, 2); + delLData.top = new FormAttachment(0, 1000, 200); + del.setLayoutData(delLData); + del.setEnabled(false); + del.setToolTipText("del from Playlist"); + del.setText("<<"); + del.setFont(SWTResourceManager.getFont("Times", 8, 1, false, false)); + del.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent evt) { + for (int i=playlistTable.getSelectionCount()-1;i>=0;i--){ + int pos = playlistTable.getSelectionIndices()[i]; + model.removeFromPlayList(pos); + } + + del.setEnabled(false); + while(playlistTable.getItemCount()!=0){ + playlistTable.remove(0); + } + ArrayList playlist=model.getToPlaylist(); + for(int i=0;i types = new ArrayList(); + + if( videoCheckBox.getSelection() ) + types.add(MediaType.VIDEO); + + if( audioCheckBox.getSelection() ) + types.add(MediaType.SOUND); + /* t.b.d. add IMAGE support */ + + if (tab==1){ + while(resultTable1.getItemCount()!=0){ + resultTable1.remove(0); + } + }else{ + while(resultTable2.getItemCount()!=0){ + resultTable2.remove(0); + } + } + returnVal= model.search(search, types, tab); + ArrayListresultList=model.getMedia(tab); + for(int i=0;i=0;i--){ + + Media result = model.getMediaWithId( + new Integer(resultTable2.getSelection()[i].getText(0)).intValue(),2 ); + + changeComposite.setVisible(false); + deleteButton.setVisible(false); + model.changeMedia(result, Action.DELETE); + resultTable2.remove(resultTable2.getSelectionIndices()[i]); + } + }catch (Exception e){ + System.out.println("Exception in DeleteButton "+e); + } + } + private void addButtonWidgetSelected(SelectionEvent evt) { + System.out.println("browser not implemented in yalp v2"); + } + + + public void refillIpTable(){ + /* t.b.d. replace by session viewer + try{ + ArrayList list=model.srvCon.getClientInfo(); + while(iptable.getItemCount()!=0){ + iptable.remove(0); + } + for(ClientInfo info : list){ + TableItem item = new TableItem(iptable,SWT.NONE); + item.setText(0,info.getUserName()); + item.setText(1,info.getIp()); + } + }catch(Exception e){System.out.println("geht nicht "+e);} + */ + } + + public void show(){ + ((Shell)this.parent).setImage(new Image(display,"img/yalpV2_klein.gif")); + ((Shell)this.parent).setText("yalp"); + this.parent.addListener(SWT.Dispose,new org.eclipse.swt.widgets.Listener(){ + public void handleEvent(org.eclipse.swt.widgets.Event e) { + ShellClose(); + } + }); + Point size = this.getSize(); + java.awt.Dimension screen = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); + Rectangle shellBounds = this.parent.computeTrim((screen.width-size.x)/2,(screen.height-size.y)/2,size.x,size.y); + this.parent.setLayout(new FillLayout()); + this.parent.layout(); + this.parent.setBounds(shellBounds); + ((Shell)this.parent).open(); + while (!this.parent.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + } + public void ShellClose(){ + this.model.logoff(); + System.exit(0); + } + +} + diff --git a/src/YalpClients/SwtClient/GUI/InitGUI.java b/src/YalpClients/SwtClient/GUI/InitGUI.java new file mode 100644 index 0000000..6b1fa51 --- /dev/null +++ b/src/YalpClients/SwtClient/GUI/InitGUI.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2006 Manuel Traut and Volker Dahnke + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: Manuel Traut and Volker Dahnke + */ + +package YalpClients.SwtClient.GUI; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +import YalpClients.SwtClient.*; +import YalpInterfaces.AccessRights; + +/* + * Class InitGUI + * + * + * + * @author Volker Dahnke / Manuel Traut + * + * @version 1 02-04-2006
+ * + */ + +public class InitGUI { + private Model model; + private Display display; + private int time = 1000; + + public InitGUI(Model model,AccessRights kind){ + this.model=model; + this.display = Display.getDefault(); + final Runnable timer = new Runnable() { + public void run() { + serverStillAlive(this); + } + }; + display.timerExec(time, timer); + + GUI gui= new GUI( + new Shell(display ,SWT.MIN), display, model, kind, SWT.NULL ); + gui.show(); + } + + public void serverStillAlive(Runnable timer){ + model.serverStillAlive(); + if (!this.model.getLogoff()){ + this.display.timerExec(time, timer); + } + } + +} diff --git a/src/YalpClients/SwtClient/GUI/LoadDialog.java b/src/YalpClients/SwtClient/GUI/LoadDialog.java new file mode 100644 index 0000000..dcdc4a8 --- /dev/null +++ b/src/YalpClients/SwtClient/GUI/LoadDialog.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2006 Manuel Traut and Volker Dahnke + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: Manuel Traut and Volker Dahnke + */ + +package YalpClients.SwtClient.GUI; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.layout.*; +import org.eclipse.swt.widgets.*; + +/* + * Class LoadDialog + * + * + * + * @author Volker Dahnke / Manuel Traut + * + * @version 1 02-04-2006
+ */ +public class LoadDialog extends Composite{ + + { + //Register as a resource user - SWTResourceManager will + //handle the obtaining and disposing of resources + SWTResourceManager.registerResourceUser(this); + } + + private CLabel cLabel1; + private CLabel cLabel2; + private CLabel cLabel3; + private Shell parent; + + public LoadDialog(Composite parent, int style) { + super(parent, style); + this.parent=(Shell)parent; + initDialog(); + } + + private void initDialog(){ + GridLayout thisLayout = new GridLayout(); + thisLayout.makeColumnsEqualWidth = true; + this.setLayout(thisLayout); + this.setSize(300,170); + { + Composite composite = new Composite(this, SWT.NONE); + FormLayout compositeLayout = new FormLayout(); + composite.setLayout(compositeLayout); + GridData compositeLData = new GridData(); + compositeLData.widthHint = 287; + compositeLData.heightHint = 165; + composite.setLayoutData(compositeLData); + composite.setVisible(true); + { + cLabel3 = new CLabel(composite, SWT.LEFT); + cLabel3.setText("Copyright (c) 2006 Manuel Traut and Volker Dahnke"); + FormData cLabel3LData = new FormData(); + cLabel3LData.width = 300; + cLabel3LData.height = 20; + cLabel3LData.left = new FormAttachment(0, 1000, 0); + cLabel3LData.top = new FormAttachment(0, 1000, 145); + cLabel3.setLayoutData(cLabel3LData); + cLabel3.setFont(SWTResourceManager.getFont("Times", 7, 0, false, false)); + } + { + cLabel2 = new CLabel(composite, SWT.CENTER); + cLabel2.setText("Loading..."); + FormData cLabel2LData = new FormData(); + cLabel2LData.width = 105; + cLabel2LData.height = 25; + cLabel2LData.left = new FormAttachment(0, 1000, 91); + cLabel2LData.top = new FormAttachment(0, 1000, 123); + cLabel2.setLayoutData(cLabel2LData); + cLabel2.setFont(SWTResourceManager.getFont("Times", 12, 1, false, false)); + } + { + cLabel1 = new CLabel(composite, SWT.CENTER); + FormData cLabel1LData = new FormData(); + cLabel1LData.width = 200; + cLabel1LData.height = 120; + cLabel1LData.left = new FormAttachment(0, 1000, 40); + cLabel1LData.top = new FormAttachment(0, 1000, 0); + cLabel1.setLayoutData(cLabel1LData); + cLabel1.setImage(new Image(this.getDisplay(),"img/yalpV2.gif")); + } + + } + } + + public void show(){ + Point size = this.getSize(); + java.awt.Dimension screen = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); + Rectangle shellBounds = this.parent.computeTrim((screen.width-size.x)/2,(screen.height-size.y)/2,size.x,size.y); + this.parent.setLayout(new FillLayout()); + this.parent.layout(); + this.parent.setBounds(shellBounds); + this.parent.open(); + } + + public void close(){ + this.parent.close(); + } +} diff --git a/src/YalpClients/SwtClient/GUI/SWTResourceManager.java b/src/YalpClients/SwtClient/GUI/SWTResourceManager.java new file mode 100644 index 0000000..87dffc3 --- /dev/null +++ b/src/YalpClients/SwtClient/GUI/SWTResourceManager.java @@ -0,0 +1,145 @@ +package YalpClients.SwtClient.GUI; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Vector; + +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Cursor; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Widget; + +/* + * Class to manage SWT resources (Font, Color, Image and Cursor) + * There are no restrictions on the use of this code. + * + * You may change this code and your changes will not be overwritten, + * but if you change the version number below then this class will be + * completely overwritten by Jigloo. + * #SWTResourceManager:version4.0.0# + */ +public class SWTResourceManager { + + private static HashMap resources = new HashMap(); + private static Vector users = new Vector(); + private static SWTResourceManager instance = new SWTResourceManager(); + + private static DisposeListener disposeListener = new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + users.remove(e.getSource()); + if (users.size() == 0) + dispose(); + } + }; + + /* + * This method should be called by *all* Widgets which use resources + * provided by this SWTResourceManager. When widgets are disposed, + * they are removed from the "users" Vector, and when no more + * registered Widgets are left, all resources are disposed. + *

+ * If this method is not called for all Widgets then it should not be called + * at all, and the "dispose" method should be explicitly called after all + * resources are no longer being used. + */ + public static void registerResourceUser(Widget widget) { + if (users.contains(widget)) + return; + users.add(widget); + widget.addDisposeListener(disposeListener); + } + + public static void dispose() { + Iterator it = resources.keySet().iterator(); + while (it.hasNext()) { + Object resource = resources.get(it.next()); + if (resource instanceof Font) + ((Font) resource).dispose(); + else if (resource instanceof Color) + ((Color) resource).dispose(); + else if (resource instanceof Image) + ((Image) resource).dispose(); + else if (resource instanceof Cursor) + ((Cursor) resource).dispose(); + } + resources.clear(); + } + + public static Font getFont(String name, int size, int style) { + return getFont(name, size, style, false, false); + } + + public static Font getFont(String name, int size, int style, boolean strikeout, boolean underline) { + String fontName = name + "|" + size + "|" + style + "|" + strikeout + "|" + underline; + if (resources.containsKey(fontName)) + return (Font) resources.get(fontName); + FontData fd = new FontData(name, size, style); + if (strikeout || underline) { + try { + Class lfCls = Class.forName("org.eclipse.swt.internal.win32.LOGFONT"); + Object lf = FontData.class.getField("data").get(fd); + if (lf != null && lfCls != null) { + if (strikeout) + lfCls.getField("lfStrikeOut").set(lf, new Byte((byte) 1)); + if (underline) + lfCls.getField("lfUnderline").set(lf, new Byte((byte) 1)); + } + } catch (Throwable e) { + System.err.println( + "Unable to set underline or strikeout" + " (probably on a non-Windows platform). " + e); + } + } + Font font = new Font(Display.getDefault(), fd); + resources.put(fontName, font); + return font; + } + + public static Image getImage(String url, Control widget) { + Image img = getImage(url); + if(img != null && widget != null) + img.setBackground(widget.getBackground()); + return img; + } + + public static Image getImage(String url) { + try { + url = url.replace('\\', '/'); + if (url.startsWith("/")) + url = url.substring(1); + if (resources.containsKey(url)) + return (Image) resources.get(url); + Image img = new Image(Display.getDefault(), instance.getClass().getClassLoader().getResourceAsStream(url)); + if (img != null) + resources.put(url, img); + return img; + } catch (Exception e) { + System.err.println("SWTResourceManager.getImage: Error getting image "+url+", "+e); + return null; + } + } + + public static Color getColor(int red, int green, int blue) { + String name = "COLOR:" + red + "," + green + "," + blue; + if (resources.containsKey(name)) + return (Color) resources.get(name); + Color color = new Color(Display.getDefault(), red, green, blue); + resources.put(name, color); + return color; + } + + public static Cursor getCursor(int type) { + String name = "CURSOR:" + type; + if (resources.containsKey(name)) + return (Cursor) resources.get(name); + Cursor cursor = new Cursor(Display.getDefault(), type); + resources.put(name, cursor); + return cursor; + } + +} diff --git a/src/YalpClients/SwtClient/GUI/SortListener.java b/src/YalpClients/SwtClient/GUI/SortListener.java new file mode 100644 index 0000000..a2ff35a --- /dev/null +++ b/src/YalpClients/SwtClient/GUI/SortListener.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2006 Manuel Traut and Volker Dahnke + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: Manuel Traut and Volker Dahnke + */ + +package YalpClients.SwtClient.GUI; + +import java.text.Collator; +import java.util.Locale; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.*; + +/* + * Class SortListener + * + * + * + * @author Volker Dahnke / Manuel Traut + * + * @version 1 02-04-2006
+ */ +public class SortListener implements Listener{ + private Table table; + private int colum,numColum; + private GUI gui; + + public SortListener(GUI gui,Table table,int colum,int numColum){ + this.colum=colum; + this.numColum=numColum; + this.table=table; + this.gui=gui; + } + + public void handleEvent(Event e) { + TableItem[] items = table.getItems(); + Collator collator = Collator.getInstance(Locale.getDefault()); + for (int i = 1; i < items.length; i++) { + String value1 = items[i].getText(colum); + for (int j = 0; j < i; j++) { + String value2 = items[j].getText(colum); + if (collator.compare(value1, value2) < 0) { + String[] values= new String[numColum]; + for(int g=0;g + * + * @author Volker Dahnke / Manuel Traut + * + * @version 1 02-04-2006
+ */ +public class StartDialog extends Composite { + + { + //Register as a resource user - SWTResourceManager will + //handle the obtaining and disposing of resources + SWTResourceManager.registerResourceUser(this); + } + private Display display; + private CLabel cLabel1; + private CLabel LogoLabel; + private Model model; + private Composite parent; + private Composite composite; + private CLabel logonLable; + private Button ok; + private Text passwd; + private Text username; + private CLabel passwdLable; + private CLabel usernameLable; + + + public StartDialog(Composite parent,Model model, int style) { + super(parent, style); + + this.parent=parent; + this.model=model; + this.display=Display.getDefault(); + initStartDialog(); + } + + private void initStartDialog(){ + GridLayout thisLayout = new GridLayout(); + thisLayout.makeColumnsEqualWidth = true; + this.setLayout(thisLayout); + this.setSize(300,150); + Listener listener =new Listener() { + public void handleEvent(org.eclipse.swt.widgets.Event evt) { + if (evt.character==SWT.CR){ + OkPressed(); + } + } + }; + addListener(SWT.KeyDown,listener); + { + composite = new Composite(this, SWT.NONE); + FormLayout compositeLayout = new FormLayout(); + composite.setLayout(compositeLayout); + GridData compositeLData = new GridData(); + compositeLData.widthHint = 287; + compositeLData.heightHint = 140; + composite.setLayoutData(compositeLData); + composite.setVisible(true); + composite.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent evt) { + if (evt.character==SWT.CR){ + OkPressed(); + } + } + }); + { + cLabel1 = new CLabel(composite, SWT.NONE); + FormData cLabel1LData = new FormData(); + cLabel1LData.width = 120; + cLabel1LData.height = 20; + cLabel1LData.left = new FormAttachment(0, 1000, 93); + cLabel1LData.top = new FormAttachment(0, 1000, 40); + cLabel1.setLayoutData(cLabel1LData); + Color col =display.getSystemColor(SWT.COLOR_RED); + cLabel1.setForeground(col); + cLabel1.setFont(SWTResourceManager.getFont("Times", 10, 1, false, false)); + } + { + LogoLabel = new CLabel(composite, SWT.NONE); + FormData LogoLabelLData = new FormData(); + LogoLabelLData.width = 70; + LogoLabelLData.height = 42; + LogoLabelLData.left = new FormAttachment(0, 1000, 77); + LogoLabelLData.top = new FormAttachment(0, 1000, 0); + LogoLabelLData.right = new FormAttachment(1000, 1000, -140); + LogoLabelLData.bottom = new FormAttachment(1000, 1000, -98); + LogoLabel.setLayoutData(LogoLabelLData); + LogoLabel.setImage(new Image(this.getDisplay(),"img/yalpV2_mittel.gif")); + } + { + logonLable = new CLabel(composite, SWT.BEGINNING); + logonLable.setText("Login"); + FormData logonLableLData = new FormData(); + logonLableLData.width = 70; + logonLableLData.height = 28; + logonLableLData.left = new FormAttachment(0, 1000, 147); + logonLableLData.top = new FormAttachment(0, 1000, 5); + logonLable.setLayoutData(logonLableLData); + logonLable.setFont(SWTResourceManager.getFont("Times", 14, 1, false, false)); + } + { + username = new Text(composite, SWT.NONE); + FormData usernameLData = new FormData(); + usernameLData.width = 117; + usernameLData.height = 15; + usernameLData.left = new FormAttachment(0, 1000, 120); + usernameLData.top = new FormAttachment(0, 1000, 65); + username.setLayoutData(usernameLData); + username.setFocus(); + username.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent evt) { + if (evt.character==SWT.CR){ + OkPressed(); + } + } + }); + } + { + passwd = new Text(composite, SWT.PASSWORD); + FormData passwdLData = new FormData(); + passwdLData.width = 117; + passwdLData.height = 15; + passwdLData.left = new FormAttachment(0, 1000, 120); + passwdLData.top = new FormAttachment(0, 1000, 88); + passwd.setLayoutData(passwdLData); + passwd.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent evt) { + if (evt.character==SWT.CR){ + OkPressed(); + } + } + }); + } + { + ok = new Button(composite, SWT.PUSH | SWT.CENTER); + ok.setText("OK"); + FormData okLData = new FormData(); + okLData.width = 65; + okLData.height = 21; + okLData.left = new FormAttachment(0, 1000, 110); + okLData.top = new FormAttachment(0, 1000, 115); + ok.setLayoutData(okLData); + ok.setFont(SWTResourceManager.getFont("Times", 10, 1, false, false)); + ok.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent evt) { + OkPressed(); + } + }); + } + { + passwdLable = new CLabel(composite, SWT.NONE); + passwdLable.setText("Password:"); + FormData passwdLableLData = new FormData(); + passwdLableLData.width = 70; + passwdLableLData.height = 20; + passwdLableLData.left = new FormAttachment(0, 1000, 35); + passwdLableLData.top = new FormAttachment(0, 1000, 83); + passwdLable.setLayoutData(passwdLableLData); + passwdLable.setFont(SWTResourceManager.getFont("Times", 10, 0, false, false)); + } + { + usernameLable = new CLabel(composite, SWT.NONE); + usernameLable.setText("Username:"); + FormData usernameLableLData = new FormData(); + usernameLableLData.width = 70; + usernameLableLData.height = 20; + usernameLableLData.left = new FormAttachment(0, 1000, 35); + usernameLableLData.top = new FormAttachment(0, 1000, 60); + usernameLable.setLayoutData(usernameLableLData); + usernameLable.setFont(SWTResourceManager.getFont("Times", 10, 0, false, false)); + } + } + this.layout(); + + } + private void OkPressed(){ + AccessRights kind; + kind = model.userVerify(username.getText(), passwd.getText()); + + if (kind.value() == AccessRights._NO_YALP_SERVER ) { + cLabel1.setText("Server offline"); + } else if (kind.value() == AccessRights._DENY ){ + cLabel1.setText("Access Denied"); + username.setText(""); + passwd.setText(""); + username.setFocus(); + } else { + display.close(); + InitGUI gui = new InitGUI(model, kind); + } + + } + + public void show(){ + ((Shell)this.parent).setImage(new Image(display,"img/yalpV2_klein.gif")); + ((Shell)this.parent).setText("yalp"); + Point size = this.getSize(); + java.awt.Dimension screen = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); + Rectangle shellBounds = this.parent.computeTrim((screen.width-size.x)/2,(screen.height-size.y)/2,size.x,size.y); + this.parent.setLayout(new FillLayout()); + this.parent.layout(); + this.parent.setBounds(shellBounds); + ((Shell)this.parent).open(); + while (!this.parent.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + } + + +} -- cgit v1.2.3