|
From: Matthias K <mat...@us...> - 2006-04-30 13:11:08
|
Update of /cvsroot/jcommander/plugins/org.jcommander.ui.filepanel/src/org/jcommander/ui/filepanel/dialogs/old In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1394/src/org/jcommander/ui/filepanel/dialogs/old Added Files: FileQuestionDialogController.java DeleteProgressDialogComposite.java CopyReportDialogComposite.java CustomConfirmDialogComposite.java OperationDialogController.java FileQuestionDialogComposite.java Log Message: further implementation of the move to JFace Dialogs: - deleting files is now a job, thus the DeleteProgressDialog is replaced by the standard job progress dialog - file questions (overwrite, read error, etc) use now JFace dialogs, too. - make directory dialog is now a JFace dialog. --- NEW FILE: DeleteProgressDialogComposite.java --- /* * Created on Jan 16, 2005 */ package org.jcommander.ui.filepanel.dialogs.old; import org.eclipse.swt.*; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridData; /** * Composite that serves as the content of the copy progress dialog. * * @author sky_halud */ public class DeleteProgressDialogComposite extends Composite { private Composite progressComposite = null; private Composite buttonsComposite = null; private Button pauseButton = null; private Button abortButton = null; private Composite progressLabelsComposite = null; private ProgressBar totalProgressBar = null; private Label label = null; private Label currentFileLabel = null; private Label label2 = null; public DeleteProgressDialogComposite(Composite parent, int style) { super(parent, style); initialize(); } private void initialize() { createProgressComposite(); createButtonsComposite(); this.setLayout(new GridLayout()); setSize(new org.eclipse.swt.graphics.Point(387, 143)); } /** * This method initializes composite */ private void createProgressComposite() { GridData gridData5 = new GridData(); GridData gridData1 = new GridData(); progressComposite = new Composite(this, SWT.NONE); createProgressLabelsComposite(); totalProgressBar = new ProgressBar(progressComposite, SWT.NONE); progressComposite.setLayout(new GridLayout()); progressComposite.setLayoutData(gridData1); gridData5.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL; gridData5.grabExcessHorizontalSpace = true; totalProgressBar.setLayoutData(gridData5); gridData1.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL; gridData1.grabExcessHorizontalSpace = true; gridData1.grabExcessVerticalSpace = true; gridData1.verticalAlignment = org.eclipse.swt.layout.GridData.CENTER; } /** * This method initializes composite1 */ private void createButtonsComposite() { GridLayout gridLayout3 = new GridLayout(); GridData gridData2 = new GridData(); buttonsComposite = new Composite(this, SWT.NONE); pauseButton = new Button(buttonsComposite, SWT.NONE); abortButton = new Button(buttonsComposite, SWT.NONE); gridData2.horizontalAlignment = org.eclipse.swt.layout.GridData.CENTER; gridData2.grabExcessHorizontalSpace = true; gridData2.verticalAlignment = org.eclipse.swt.layout.GridData.END; buttonsComposite.setLayoutData(gridData2); buttonsComposite.setLayout(gridLayout3); gridLayout3.numColumns = 2; gridLayout3.marginHeight = 1; gridLayout3.marginWidth = 1; pauseButton.setText("&Pause"); abortButton.setText("&Abort"); } /** * This method initializes composite */ private void createProgressLabelsComposite() { GridData gridData = new GridData(); gridData.grabExcessHorizontalSpace = true; gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL; GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 3; GridData gridData4 = new GridData(); progressLabelsComposite = new Composite(progressComposite, SWT.NONE); label = new Label(progressLabelsComposite, SWT.NONE); currentFileLabel = new Label(progressLabelsComposite, SWT.NONE); label2 = new Label(progressLabelsComposite, SWT.NONE); gridData4.grabExcessHorizontalSpace = true; gridData4.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL; progressLabelsComposite.setLayoutData(gridData4); progressLabelsComposite.setLayout(gridLayout); label.setText("Deleting"); currentFileLabel.setText(""); currentFileLabel.setLayoutData(gridData); label2.setText("..."); } public Button getAbortButton() { return abortButton; } public Label getCurrentFileLabel() { return currentFileLabel; } public Button getPauseButton() { return pauseButton; } public ProgressBar getTotalProgressBar() { return totalProgressBar; } } // @jve:decl-index=0:visual-constraint="10,10" --- NEW FILE: OperationDialogController.java --- /* * Created on May 3, 2005 */ package org.jcommander.ui.filepanel.dialogs.old; import org.eclipse.swt.widgets.*; import org.jcommander.ui.filepanel.*; import org.jcommander.ui.filepanel.performers.*; import org.jcommander.ui.utils.*; /** * This is a controller for internal operation dialog lifecycle management. * * @author sky_halud */ public class OperationDialogController { protected Shell shell; protected Object workerLock = new Object(); private boolean resumeOperationThread; protected Object userChoice; protected Shell parent; public OperationDialogController(Shell parent, TabMediator mediator, String title) { this.parent = parent; this.shell = Utils.createOperationDialog(parent, mediator, title); } public void openShell() { shell.open(); } protected void requestShellClose() { resumeOperationThread = true; synchronized(workerLock) { workerLock.notify(); } } protected void setUserChoice(Object choice) { userChoice = choice; requestShellClose(); } public Object waitForUserChoice() { resumeOperationThread = false; while(!resumeOperationThread) { synchronized (workerLock) { try { workerLock.wait(); }catch(InterruptedException ex) {} } } EclipseBroker.getDisplay().syncExec(new Runnable() { public void run() { shell.dispose(); } }); return userChoice; } public Shell getShell() { return shell; } protected void accomodateComposite(Composite composite) { Utils.accomodateComposite(composite); } } --- NEW FILE: CopyReportDialogComposite.java --- /* * Created on Dec 13, 2004 */ package org.jcommander.ui.filepanel.dialogs.old; import org.eclipse.swt.widgets.*; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; /** * TODO Insert class comment here. * * @author sky_halud */ public class CopyReportDialogComposite extends Composite { private Composite reportsComposite = null; private Composite buttonsComposite = null; private Button showProcessedButton = null; private Button showSkippedButton = null; private Button dismissButton = null; private Table table = null; public CopyReportDialogComposite(Composite parent, int style) { super(parent, style); initialize(); } private void initialize() { createComposite(); this.setLayout(new GridLayout()); createComposite2(); setSize(new org.eclipse.swt.graphics.Point(353,200)); } /** * This method initializes composite * */ private void createComposite() { GridData gridData1 = new GridData(); reportsComposite = new Composite(this, SWT.NONE); createTable(); gridData1.grabExcessHorizontalSpace = true; gridData1.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL; gridData1.grabExcessVerticalSpace = true; gridData1.verticalAlignment = org.eclipse.swt.layout.GridData.FILL; reportsComposite.setLayoutData(gridData1); reportsComposite.setLayout(new FillLayout()); } /** * This method initializes composite * */ private void createComposite2() { FillLayout fillLayout3 = new FillLayout(); GridData gridData2 = new GridData(); buttonsComposite = new Composite(this, SWT.NONE); showProcessedButton = new Button(buttonsComposite, SWT.TOGGLE); showSkippedButton = new Button(buttonsComposite, SWT.TOGGLE); dismissButton = new Button(buttonsComposite, SWT.NONE); gridData2.grabExcessHorizontalSpace = true; gridData2.verticalAlignment = org.eclipse.swt.layout.GridData.END; buttonsComposite.setLayoutData(gridData2); buttonsComposite.setLayout(fillLayout3); fillLayout3.spacing = 5; showProcessedButton.setText("Show processed"); showSkippedButton.setText("Show skipped"); dismissButton.setText("Dismiss"); } /** * This method initializes table * */ private void createTable() { table = new Table(reportsComposite, SWT.NONE); TableColumn filenameColumn = new TableColumn(table, SWT.NONE); filenameColumn.setText("Filename"); table.setHeaderVisible(true); } } // @jve:decl-index=0:visual-constraint="10,10" --- NEW FILE: FileQuestionDialogComposite.java --- /* * Created on May 3, 2005 */ package org.jcommander.ui.filepanel.dialogs.old; import org.eclipse.swt.*; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.SWT; /** * This is a composite for various question dialogs. * * @author sky_halud */ public class FileQuestionDialogComposite extends Composite { private Label messageLabel = null; private Composite buttonsComposite = null; private Button currentButton = null; private Button allButton = null; private Button skipCurrentButton = null; private Button skipAllButton = null; private boolean allButtonVisible; public FileQuestionDialogComposite(Composite parent, int style) { this(parent, true, style); } /** * * @param parent * @param allButtonVisible Set the visibility of the "All" button. * @param style */ public FileQuestionDialogComposite(Composite parent, boolean allButtonVisible, int style) { super(parent, style); this.allButtonVisible = allButtonVisible; initialize(); } private void initialize() { GridData gridData3 = new GridData(); gridData3.grabExcessHorizontalSpace = true; gridData3.grabExcessVerticalSpace = true; gridData3.horizontalAlignment = org.eclipse.swt.layout.GridData.CENTER; GridData gridData6 = new GridData(); gridData6.grabExcessHorizontalSpace = true; gridData6.grabExcessVerticalSpace = true; gridData6.horizontalAlignment = org.eclipse.swt.layout.GridData.CENTER; this.setLayout(new GridLayout()); setSize(new org.eclipse.swt.graphics.Point(306,93)); messageLabel = new Label(this, SWT.WRAP | SWT.CENTER); messageLabel.setText("Label"); createButtonsComposite(); messageLabel.setLayoutData(gridData6); } /** * This method initializes composite * */ private void createButtonsComposite() { RowLayout rowLayout5 = new RowLayout(); rowLayout5.fill = true; rowLayout5.justify = false; rowLayout5.pack = true; rowLayout5.wrap = false; GridData gridData4 = new GridData(); gridData4.grabExcessHorizontalSpace = true; gridData4.horizontalAlignment = org.eclipse.swt.layout.GridData.CENTER; buttonsComposite = new Composite(this, SWT.NONE); buttonsComposite.setLayoutData(gridData4); buttonsComposite.setLayout(rowLayout5); currentButton = new Button(buttonsComposite, SWT.NONE); currentButton.setText("&Current"); if(allButtonVisible) { allButton = new Button(buttonsComposite, SWT.NONE); allButton.setText("&All"); } skipCurrentButton = new Button(buttonsComposite, SWT.NONE); skipCurrentButton.setText("&Skip Current"); skipAllButton = new Button(buttonsComposite, SWT.NONE); skipAllButton.setText("Skip A&ll"); } public Button getAllButton() { return allButton; } public Button getCurrentButton() { return currentButton; } public Label getMessageLabel() { return messageLabel; } public Button getSkipAllButton() { return skipAllButton; } public Button getSkipCurrentButton() { return skipCurrentButton; } } // @jve:decl-index=0:visual-constraint="10,117" --- NEW FILE: CustomConfirmDialogComposite.java --- /** * */ package org.jcommander.ui.filepanel.dialogs.old; 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 { public static final int YES_NO = 1; public static final int OK_CANCEL = 2; 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; private int buttons = 0; /** * @param parent * @param style */ public CustomConfirmDialogComposite(Composite parent, int style, int buttons) { super(parent, style); this.buttons=buttons; 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; detailsComposite.setLayoutData(detailsData); GridLayout detailsLayout = new GridLayout(); detailsLayout.marginWidth=0; detailsComposite.setLayout(detailsLayout); GridLayout buttonsLayout = new GridLayout(); GridData buttonsData = 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); buttonsData.grabExcessHorizontalSpace = true; buttonsData.horizontalAlignment = org.eclipse.swt.layout.GridData.END; buttonsData.verticalAlignment = org.eclipse.swt.layout.GridData.END; buttonsData.minimumWidth=400; buttonsComposite.setLayoutData(buttonsData); buttonsComposite.setLayout(buttonsLayout); buttonsLayout.numColumns = 3; buttonsLayout.marginHeight = 1; buttonsLayout.marginWidth = 1; buttonsLayout.marginLeft=200; // GridLayout buttonLayout1 = new GridLayout(); GridData yesButtonData = new GridData(); //l1.horizontalAlignment=SWT.FILL; yesButtonData.grabExcessHorizontalSpace=true; yesButtonData.minimumWidth=75; yesButton.setLayoutData(yesButtonData); GridData noButtonData = new GridData(); noButtonData.grabExcessHorizontalSpace=true; //l2.horizontalAlignment=SWT.FILL; noButtonData.minimumWidth=75; noButton.setLayoutData(noButtonData); if (buttons==YES_NO) { yesButton.setText("&Yes"); noButton.setText("&No"); } else if (buttons==OK_CANCEL) { yesButton.setText("&Ok"); noButton.setText("&Cancel"); } detailsButton = new Button(buttonsComposite, SWT.NONE); GridData detailsButtonData = new GridData(); detailsButtonData.grabExcessHorizontalSpace=true; detailsButtonData.minimumWidth=75; detailsButton.setLayoutData(detailsButtonData); 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); //detailsComposite.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_RED)); Point p = detailsContent.getSize(); detailsHeight = p.y; shell.setSize(shellSize.x, shellSize.y+detailsHeight); shell.pack(); } } }); } /** * Override this method in a subclass to create the details view * of the dialog. The method is called every time the "Details" button * is clicked to show the view. Thus dialog elements created in this method * are available only if the dialogs are currently showing. * @param parent The parent composite. Make all elements children of this. */ protected void createDetailsContent(Composite parent){ } /** * Override this method in a subclass to create the main * content of the dialog. The method is called in the constructor. * @param parent The parent composite. Make all elements children of this. */ protected void createMainContent(Composite parent){ } /** * Gets the Yes button. */ public Button getYesButton() { return yesButton; } /** * Gets the Ok button. */ public Button getOkButton() { return yesButton; } /** * Gets the no button. */ public Button getNoButton() { return noButton; } /** * Gets the Cancel button. */ public Button getCancelButton() { return noButton; } /** * * @return whether the details are currently showing */ public boolean isDetailsShowing(){ return detailsContent!=null; } } --- NEW FILE: FileQuestionDialogController.java --- /* * Created on May 3, 2005 */ package org.jcommander.ui.filepanel.dialogs.old; import org.eclipse.swt.*; import org.eclipse.swt.events.*; import org.eclipse.swt.widgets.*; import org.jcommander.ui.filepanel.*; import org.jcommander.ui.filepanel.performers.*; import org.jcommander.ui.utils.*; /** * This is a specialized dialog controller for file operation question dialogs. * * @author sky_halud */ public class FileQuestionDialogController extends OperationDialogController { public static final Integer CURRENT_CHOICE = new Integer(1); public static final Integer ALL_CHOICE = new Integer(2); public static final Integer SKIP_CURRENT_CHOICE = new Integer(3); public static final Integer SKIP_ALL_CHOICE = new Integer(4); protected String message; private boolean showAllButton; public FileQuestionDialogController(Shell parent, TabMediator mediator, String title, String message) { this(parent, mediator, title, message, true); } public FileQuestionDialogController(Shell parent, TabMediator mediator, String title, String message, boolean showAllButton) { super(parent, mediator, title); this.message = message; this.showAllButton = showAllButton; } public void openShell() { FileQuestionDialogComposite composite = new FileQuestionDialogComposite(shell, showAllButton, SWT.NONE); composite.getMessageLabel().setText(message); composite.getCurrentButton().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { setUserChoice(CURRENT_CHOICE); } }); if(composite.getAllButton() != null) { composite.getAllButton().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { setUserChoice(ALL_CHOICE); } }); } composite.getSkipCurrentButton().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { setUserChoice(SKIP_CURRENT_CHOICE); } }); composite.getSkipAllButton().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { setUserChoice(SKIP_ALL_CHOICE); } }); Utils.accomodateComposite(composite); shell.pack(); WindowUtils.centerRelativeTo(shell, parent); shell.setVisible(true); shell.setActive(); super.openShell(); } } |