|
From: Matthias K <mat...@us...> - 2006-04-08 22:54:41
|
Update of /cvsroot/jcommander/incubator/matthias_kue/dialogs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27852/matthias_kue/dialogs Added Files: CustomConfirmDialogComposite.java DeleteConfirmDialogComposite.java Log Message: New dialog implementation with details --- NEW FILE: CustomConfirmDialogComposite.java --- /** * */ package org.jcommander.ui.filepanel.dialogs; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.internal.progress.ProgressMessages; /** * @author MatthiasK * */ public class CustomConfirmDialogComposite extends Composite { private Composite mainComposite = null; private Composite buttonsComposite = null; private Composite detailsComposite = null; private Composite detailsContent = null; private Button yesButton = null; private Button noButton = null; private Button detailsButton = null; private GridData detailsData = null; private int detailsHeight = 0; /** * @param parent * @param style */ public CustomConfirmDialogComposite(Composite parent, int style) { super(parent, style); initialize(); } private void initialize(){ createMainContent(this); createButtonsComposite(); //mainComposite.setLayout(new GridLayout()); this.setLayout(new GridLayout()); } private void createButtonsComposite(){ detailsComposite = new Composite(this, SWT.NONE); detailsData=new GridData(); detailsData.horizontalAlignment=SWT.FILL; //detailsData.grabExcessHorizontalSpace=true; GridLayout detailsLayout = new GridLayout(); detailsLayout.marginWidth=0; detailsComposite.setLayout(detailsLayout); detailsComposite.setLayoutData(detailsData); GridLayout gridLayout3 = new GridLayout(); GridData gridData2 = new GridData(); buttonsComposite = new Composite(this, SWT.NONE); Label fillLabel = new Label(buttonsComposite, SWT.NONE); GridData gridDataFill = new GridData(); gridDataFill.grabExcessHorizontalSpace=true; gridDataFill.minimumWidth=200; fillLabel.setLayoutData(gridDataFill); yesButton = new Button(buttonsComposite, SWT.NONE); noButton = new Button(buttonsComposite, SWT.NONE); gridData2.grabExcessHorizontalSpace = true; gridData2.horizontalAlignment = org.eclipse.swt.layout.GridData.END; gridData2.verticalAlignment = org.eclipse.swt.layout.GridData.END; buttonsComposite.setLayoutData(gridData2); buttonsComposite.setLayout(gridLayout3); gridLayout3.numColumns = 4; gridLayout3.marginHeight = 1; gridLayout3.marginWidth = 1; yesButton.setText("&Yes"); // GridLayout buttonLayout1 = new GridLayout(); GridData l1 = new GridData(); //l1.horizontalAlignment=SWT.FILL; l1.grabExcessHorizontalSpace=true; l1.minimumWidth=75; yesButton.setLayoutData(l1); GridData l2 = new GridData(); l2.grabExcessHorizontalSpace=true; //l2.horizontalAlignment=SWT.FILL; l2.minimumWidth=75; noButton.setText("&No"); noButton.setLayoutData(l2); detailsButton = new Button(buttonsComposite, SWT.NONE); GridData detailsButtonData = new GridData(); detailsButtonData.minimumWidth=75; detailsButton.setText(ProgressMessages.ProgressMonitorJobsDialog_DetailsTitle); detailsButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); Shell shell = getShell(); Point shellSize = shell.getSize(); Composite composite = buttonsComposite.getParent(); if (detailsContent != null) { detailsContent.dispose(); detailsContent = null; composite.layout(); shell.setSize(shellSize.x, shellSize.y -detailsHeight); detailsButton.setText(ProgressMessages.ProgressMonitorJobsDialog_DetailsTitle); } else { //Abort if there are no jobs visible /*if (ProgressManager.getInstance().getRootElements(Policy.DEBUG_SHOW_SYSTEM_JOBS).length == 0) { detailsButton.setEnabled(false); return; }*/ detailsContent = new Composite(detailsComposite, SWT.NONE|SWT.BORDER); //detailsContent.setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE)); GridData detailsCData = new GridData(); detailsCData.horizontalAlignment=SWT.FILL; detailsCData.grabExcessHorizontalSpace=true; //detailsCData.height=200; detailsContent.setLayoutData(detailsCData); detailsContent.setLayout(new RowLayout()); createDetailsContent(detailsContent); /*Button b = new Button(detailsContent, SWT.NONE); b.setText("b");*/ detailsComposite.layout(true); detailsContent.setVisible(true); detailsButton.setText(ProgressMessages.ProgressMonitorJobsDialog_HideTitle); //b.setVisible(true); composite.layout(true); Point p = detailsContent.getSize(); detailsHeight = p.y; shell.setSize(shellSize.x, shellSize.y+detailsHeight); shell.pack(); } } }); } protected void createDetailsContent(Composite parent){ } protected void createMainContent(Composite parent){ } public Button getYesButton() { return yesButton; } public Button getNoButton() { return noButton; } } --- NEW FILE: DeleteConfirmDialogComposite.java --- /* * Created on Jan 16, 2005 */ package org.jcommander.ui.filepanel.dialogs; import org.eclipse.core.runtime.Platform; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.resource.*; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.jcommander.ui.filepanel.FilePanelPlugin; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.layout.GridLayout; /** * Composite to show inside the delete confirmation dialog. * * @author sky_halud */ public class DeleteConfirmDialogComposite extends CustomConfirmDialogComposite{ private Label label = null; private Composite infoComposite = null; private Composite listComposite = null; private List deleteFileList; private Button moveToRecycleButton = null; private Label trashLabel = null; private boolean moveToRecycle; public DeleteConfirmDialogComposite(Composite parent, int style) { super(parent, style); } private void createListComposite(Composite info) { GridData gridData = new GridData(); gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.verticalAlignment = org.eclipse.swt.layout.GridData.FILL; gridData.grabExcessVerticalSpace = true; GridData gridData1 = new GridData(); GridData gridData2 = new GridData(); gridData1.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL; gridData1.grabExcessHorizontalSpace = true; gridData1.verticalAlignment = org.eclipse.swt.layout.GridData.FILL; gridData1.grabExcessVerticalSpace = true; gridData1.heightHint=60; gridData2.horizontalAlignment = org.eclipse.swt.layout.GridData.END; gridData2.verticalAlignment = org.eclipse.swt.layout.GridData.BEGINNING; GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; gridLayout.marginWidth=0; listComposite = new Composite(info, SWT.NONE); listComposite.setLayoutData(gridData); listComposite.setLayout(gridLayout); deleteFileList = new List(listComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); deleteFileList.setLayoutData(gridData1); // removeFileButton = new Button(listComposite, SWT.NONE); // removeFileButton.setLayoutData(gridData2); // removeFileButton.setText("&Remove"); // // removeFileButton.addSelectionListener(new SelectionAdapter() { // public void widgetSelected(SelectionEvent e) { // int [] indices = deleteFileList.getSelectionIndices(); // deleteFileList.remove(indices); // // if(deleteFileList.getItemCount() == 0) { // /** Nothing to delete. Disabling controls */ // removeFileButton.setEnabled(false); // yesButton.setEnabled(false); // deleteFileList.setEnabled(false); // } // } // }); } @Override protected void createMainContent(Composite parent) { GridLayout gridLayout1 = new GridLayout(); gridLayout1.numColumns = 1; GridData gridData2 = new GridData(); GridData gridData1 = new GridData(); label = new Label(parent, SWT.NONE); infoComposite = new Composite(parent, SWT.NONE); //gridData1.horizontalAlignment = org.eclipse.swt.layout.GridData.CENTER; gridData1.grabExcessHorizontalSpace = true; gridData1.grabExcessVerticalSpace = true; label.setText("Delete selected files?"); label.setLayoutData(gridData1); createListComposite(infoComposite); moveToRecycle = ((FilePanelPlugin.getDefault().getPreferenceStore()). getBoolean(FilePanelPlugin.MOVE_TO_RECYCLE_KEY)); gridData2.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL; gridData2.verticalAlignment = org.eclipse.swt.layout.GridData.CENTER; gridData2.grabExcessHorizontalSpace = true; gridData2.grabExcessVerticalSpace = true; gridLayout1.marginWidth=0; infoComposite.setLayoutData(gridData2); infoComposite.setLayout(gridLayout1); } @Override protected void createDetailsContent(Composite parent) { //Button b = new Button(parent, SWT.NONE); Composite trashComposite = new Composite(parent, SWT.NONE); GridLayout trashLayout = new GridLayout(); trashLayout.numColumns=2; trashComposite.setLayout(trashLayout); GridData trashData1 = new GridData(); GridData trashData2 = new GridData(); trashData1.verticalAlignment=SWT.CENTER; trashData2.verticalAlignment=SWT.CENTER; trashLabel = new Label(trashComposite, SWT.NONE); trashLabel.setText(""); ImageDescriptor imgDesc = FilePanelPlugin.imageDescriptorFromPlugin(FilePanelPlugin.ID, "icons/trash.gif"); Image trashImg = imgDesc.createImage(getDisplay()); trashLabel.setImage(trashImg); trashLabel.setLayoutData(trashData1); moveToRecycleButton = new Button(trashComposite, SWT.CHECK); if(Platform.getOS().equals(Platform.OS_WIN32)) { moveToRecycleButton.setText("&Move to the recycle bin"); moveToRecycleButton.setToolTipText("Moved deleted files to the recycle bin"); } else { moveToRecycleButton.setText("&Move to the trash"); moveToRecycleButton.setToolTipText("Moved deleted files to the trash"); } moveToRecycleButton.setSelection(moveToRecycle); moveToRecycleButton. addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { try { IPreferenceStore store = FilePanelPlugin.getDefault().getPreferenceStore(); store.setValue(FilePanelPlugin.MOVE_TO_RECYCLE_KEY,((Button) e.getSource()).getSelection()); } catch(Exception ex) { //ignore } } }); moveToRecycleButton.setLayoutData(trashData2); } public List getDeleteFileList() { return deleteFileList; } private void toggleEnableMoveToRecycle(boolean value) { if (moveToRecycleButton!=null) { moveToRecycleButton.setEnabled(value); } } private void setMoveToRecycle(boolean value) { IPreferenceStore store = FilePanelPlugin.getDefault().getPreferenceStore(); store.setValue(FilePanelPlugin.MOVE_TO_RECYCLE_KEY,value); if (moveToRecycleButton!=null) { moveToRecycleButton.setSelection(value); } } public void disableMoveToRecycle() { setMoveToRecycle(false); toggleEnableMoveToRecycle(false); } public boolean getMoveToRecycle() { return moveToRecycle; } } // @jve:decl-index=0:visual-constraint="10,10" |