|
From: jistrawn <jis...@us...> - 2006-10-30 15:18:46
|
Update of /cvsroot/modelwizard/source/Model Wizard Plugin/src/net/sourceforge/modelWizard/wizards In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv23766/src/net/sourceforge/modelWizard/wizards Modified Files: ModelExtractWizardPage2.java Log Message: reformatted Index: ModelExtractWizardPage2.java =================================================================== RCS file: /cvsroot/modelwizard/source/Model Wizard Plugin/src/net/sourceforge/modelWizard/wizards/ModelExtractWizardPage2.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ModelExtractWizardPage2.java 24 Oct 2006 23:13:00 -0000 1.6 --- ModelExtractWizardPage2.java 30 Oct 2006 15:18:33 -0000 1.7 *************** *** 50,317 **** import org.eclipse.ui.help.WorkbenchHelp; - public class ModelExtractWizardPage2 - extends WizardPage - { - - private Text fileText; - private Text containerText; - ModelAccess model = ModelAccess.INSTANCE; - ArrayList fields = new ArrayList(); - private int modelAccessKey; - private Composite holder; - private IContainer container; - private IPath filePath; - private Label fileLabel; private Group exporterSpecificParametersGroup; private Map params; ! public ModelExtractWizardPage2(IContainer container) ! { ! super("Model Exporter"); ! setTitle("Model Exporter"); ! setDescription("Specify the required parameters."); ! setImageDescriptor(ModelWizardPlugin.getIconPath("wizardIcon.gif")); ! this.container = container; ! } ! public void createControl(Composite parent) ! { ! holder = new Composite( ! parent, ! SWT.NULL); ! holder.setLayout(new GridLayout()); ! WorkbenchHelp.setHelp(holder, ! "net.sourceforge.modelwizard.documentation.exportWizardHelpId"); ! // ! setControl(holder); ! final Group destinationGroup = new Group(holder, SWT.NONE); ! destinationGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); ! destinationGroup.setLayout(new FormLayout()); ! destinationGroup.setText("Destination "); ! final Label containerLabel = new Label(destinationGroup, SWT.NONE); ! final FormData formData_1 = new FormData(); ! formData_1.top = new FormAttachment( ! 0, ! 5); ! formData_1.left = new FormAttachment( ! 0, ! 5); ! containerLabel.setLayoutData(formData_1); ! containerLabel.setText("Container"); ! final Button containerBrowseButton = new Button(destinationGroup, SWT.PUSH); ! final FormData formData_2 = new FormData(); ! formData_2.top = new FormAttachment( ! containerLabel, ! 0, ! SWT.CENTER); ! formData_2.right = new FormAttachment( ! 100, ! -5); ! containerBrowseButton.setLayoutData(formData_2); ! containerBrowseButton.setText("Browse..."); ! containerBrowseButton.addSelectionListener( ! new SelectionAdapter() ! { ! public void widgetSelected(SelectionEvent e) ! { ! handleBrowse(); ! checkFilename(); ! } ! }); ! containerText = new Text( ! destinationGroup, ! SWT.BORDER); ! final FormData formData = new FormData(); ! formData.top = new FormAttachment( ! containerLabel, ! 0, ! SWT.CENTER); ! formData.right = new FormAttachment( ! containerBrowseButton, ! -5, ! SWT.DEFAULT); ! formData.left = new FormAttachment( ! containerLabel, ! 5, ! SWT.DEFAULT); ! containerText.setLayoutData(formData); ! containerText.setEditable(false); ! containerText.setText(container.getFullPath().toOSString()); ! final String defFileName = "export"; ! fileLabel = new Label( ! destinationGroup, ! SWT.NONE); ! final FormData formData_3 = new FormData(); ! formData_3.top = new FormAttachment( ! containerBrowseButton, ! 10, ! SWT.DEFAULT); ! formData_3.left = new FormAttachment( ! 0, ! 5); ! fileLabel.setLayoutData(formData_3); ! fileLabel.setText("File"); ! fileText = new Text( ! destinationGroup, ! SWT.BORDER); ! final FormData formData_4 = new FormData(); ! formData_4.right = new FormAttachment( ! 100, ! -5); ! formData_4.top = new FormAttachment( ! fileLabel, ! 0, ! SWT.CENTER); ! formData_4.left = new FormAttachment( ! containerText, ! 0, ! SWT.LEFT); ! fileText.setLayoutData(formData_4); ! fileText.addModifyListener( ! new ModifyListener() ! { ! public void modifyText(ModifyEvent e) ! { ! checkFilename(); ! } ! }); ! fileText.setText(defFileName); ! checkFilename(); ! createExporterSpecificControls(holder); ! } ! /** ! * Uses the standard container st election dialog to ! * choose the new value for the container field. ! */ ! private void handleBrowse() ! { ! ContainerSelectionDialog dialog = ! new ContainerSelectionDialog( ! getShell(), ! ResourcesPlugin.getWorkspace().getRoot(), ! false, ! "Select new file container"); ! if (dialog.open() == ContainerSelectionDialog.OK) ! { ! Object[] result = dialog.getResult(); ! if (result.length == 1) ! { ! containerText.setText(((Path)result[0]).toOSString()); ! } ! } ! } ! private void updateStatus(String message) ! { ! setErrorMessage(message); ! setPageComplete(message == null); ! } ! /** ! * ! */ ! protected void checkFilename() ! { ! if (containerText.getText().length() == 0) ! { ! updateStatus("File container must be specified"); ! return; ! } ! filePath = new Path(containerText.getText()); ! if (fileText.isEnabled()) ! { ! if (fileText.getText().length() == 0) ! { ! updateStatus("File name must be specified"); ! return; ! } ! IPath f = new Path(fileText.getText()); ! f = f.removeFileExtension().addFileExtension(model.getExporterFileExt(modelAccessKey)); ! filePath = filePath.addTrailingSeparator().append(f); ! IStatus s = ResourcesPlugin.getWorkspace().validatePath( ! filePath.toString(), ! IResource.FILE); ! if (!s.isOK()) ! { ! updateStatus("Not a valid file path :" + s.getMessage()); ! return; ! } ! } ! updateStatus(null); ! } ! /** ! * @return Returns the filePath. ! */ ! public IPath getFilePath() ! { ! return filePath; ! } ! private void createExporterSpecificControls(Composite container) ! { ! if (exporterSpecificParametersGroup != null) { ! exporterSpecificParametersGroup.dispose(); ! exporterSpecificParametersGroup = null; ! } ! params = model.getModelExporter(modelAccessKey).getParameters(model.getCurrentModel()); ! if (params != null) ! { ! exporterSpecificParametersGroup = new Group(container, SWT.NONE); exporterSpecificParametersGroup.setText("Exporter Specific Parameters"); ! exporterSpecificParametersGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); ! final GridLayout gridLayout_1 = new GridLayout(); ! gridLayout_1.numColumns = 3; ! exporterSpecificParametersGroup.setLayout(gridLayout_1); ! for (Iterator i = params.values().iterator(); i.hasNext();) ! { ! ExportParameter param = (ExportParameter)i.next(); ! param.addWidgets(exporterSpecificParametersGroup); ! } ! } // Compute the new window size. ! container.layout(true); getShell().layout(true); ! Point p = getShell().computeSize(500,SWT.DEFAULT,true); getShell().setSize(p); - - } ! public int getModelAccessKey() ! { ! return modelAccessKey; ! } ! public void setModelAccessKey(int modelAccessKey) ! { ! this.modelAccessKey = modelAccessKey; ! fields.clear(); ! createExporterSpecificControls(holder); ! if (model.isFile(modelAccessKey)) ! { ! fileLabel.setEnabled(true); ! fileText.setEnabled(true); ! } ! else ! { ! fileLabel.setEnabled(false); ! fileText.setEnabled(false); ! } ! checkFilename(); ! } ! public Map getParameters() ! { ! return params; ! } } \ No newline at end of file --- 50,250 ---- import org.eclipse.ui.help.WorkbenchHelp; + public class ModelExtractWizardPage2 extends WizardPage { + + private Text fileText; + + private Text containerText; + + ModelAccess model = ModelAccess.INSTANCE; + + ArrayList fields = new ArrayList(); + + private int modelAccessKey; + + private Composite holder; + + private IContainer container; + + private IPath filePath; + + private Label fileLabel; private Group exporterSpecificParametersGroup; + private Map params; ! public ModelExtractWizardPage2(IContainer container) { ! super("Model Exporter"); ! setTitle("Model Exporter"); ! setDescription("Specify the required parameters."); ! setImageDescriptor(ModelWizardPlugin.getIconPath("wizardIcon.gif")); ! this.container = container; ! } ! public void createControl(Composite parent) { ! holder = new Composite(parent, SWT.NULL); ! holder.setLayout(new GridLayout()); ! WorkbenchHelp.setHelp(holder, "net.sourceforge.modelwizard.documentation.exportWizardHelpId"); ! setControl(holder); ! final Group destinationGroup = new Group(holder, SWT.NONE); ! destinationGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); ! destinationGroup.setLayout(new FormLayout()); ! destinationGroup.setText("Destination "); ! final Label containerLabel = new Label(destinationGroup, SWT.NONE); ! final FormData formData_1 = new FormData(); ! formData_1.top = new FormAttachment(0, 5); ! formData_1.left = new FormAttachment(0, 5); ! containerLabel.setLayoutData(formData_1); ! containerLabel.setText("Container"); ! final Button containerBrowseButton = new Button(destinationGroup, SWT.PUSH); ! final FormData formData_2 = new FormData(); ! formData_2.top = new FormAttachment(containerLabel, 0, SWT.CENTER); ! formData_2.right = new FormAttachment(100, -5); ! containerBrowseButton.setLayoutData(formData_2); ! containerBrowseButton.setText("Browse..."); ! containerBrowseButton.addSelectionListener(new SelectionAdapter() { ! public void widgetSelected(SelectionEvent e) { ! handleBrowse(); ! checkFilename(); ! } ! }); ! containerText = new Text(destinationGroup, SWT.BORDER); ! final FormData formData = new FormData(); ! formData.top = new FormAttachment(containerLabel, 0, SWT.CENTER); ! formData.right = new FormAttachment(containerBrowseButton, -5, SWT.DEFAULT); ! formData.left = new FormAttachment(containerLabel, 5, SWT.DEFAULT); ! containerText.setLayoutData(formData); ! containerText.setEditable(false); ! containerText.setText(container.getFullPath().toOSString()); ! final String defFileName = "export"; ! fileLabel = new Label(destinationGroup, SWT.NONE); ! final FormData formData_3 = new FormData(); ! formData_3.top = new FormAttachment(containerBrowseButton, 10, SWT.DEFAULT); ! formData_3.left = new FormAttachment(0, 5); ! fileLabel.setLayoutData(formData_3); ! fileLabel.setText("File"); ! fileText = new Text(destinationGroup, SWT.BORDER); ! final FormData formData_4 = new FormData(); ! formData_4.right = new FormAttachment(100, -5); ! formData_4.top = new FormAttachment(fileLabel, 0, SWT.CENTER); ! formData_4.left = new FormAttachment(containerText, 0, SWT.LEFT); ! fileText.setLayoutData(formData_4); ! fileText.addModifyListener(new ModifyListener() { ! public void modifyText(ModifyEvent e) { ! checkFilename(); ! } ! }); ! fileText.setText(defFileName); ! checkFilename(); ! createExporterSpecificControls(holder); ! } ! /** ! * Uses the standard container st election dialog to choose the new value ! * for the container field. ! */ ! private void handleBrowse() { ! ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), ! false, "Select new file container"); ! if (dialog.open() == ContainerSelectionDialog.OK) { ! Object[] result = dialog.getResult(); ! if (result.length == 1) { ! containerText.setText(((Path) result[0]).toOSString()); ! } ! } ! } ! private void updateStatus(String message) { ! setErrorMessage(message); ! setPageComplete(message == null); ! } ! /** ! * ! */ ! protected void checkFilename() { ! if (containerText.getText().length() == 0) { ! updateStatus("File container must be specified"); ! return; ! } ! filePath = new Path(containerText.getText()); ! if (fileText.isEnabled()) { ! if (fileText.getText().length() == 0) { ! updateStatus("File name must be specified"); ! return; ! } ! IPath f = new Path(fileText.getText()); ! f = f.removeFileExtension().addFileExtension(model.getExporterFileExt(modelAccessKey)); ! filePath = filePath.addTrailingSeparator().append(f); ! IStatus s = ResourcesPlugin.getWorkspace().validatePath(filePath.toString(), IResource.FILE); ! if (!s.isOK()) { ! updateStatus("Not a valid file path :" + s.getMessage()); ! return; ! } ! } ! updateStatus(null); ! } ! /** ! * @return Returns the filePath. ! */ ! public IPath getFilePath() { ! return filePath; ! } ! private void createExporterSpecificControls(Composite container) { ! if (exporterSpecificParametersGroup != null) { ! exporterSpecificParametersGroup.dispose(); ! exporterSpecificParametersGroup = null; ! } ! params = model.getModelExporter(modelAccessKey).getParameters(model.getCurrentModel()); ! if (params != null) { ! exporterSpecificParametersGroup = new Group(container, SWT.NONE); exporterSpecificParametersGroup.setText("Exporter Specific Parameters"); ! exporterSpecificParametersGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); ! final GridLayout gridLayout_1 = new GridLayout(); ! gridLayout_1.numColumns = 3; ! exporterSpecificParametersGroup.setLayout(gridLayout_1); ! for (Iterator i = params.values().iterator(); i.hasNext();) { ! ExportParameter param = (ExportParameter) i.next(); ! param.addWidgets(exporterSpecificParametersGroup); ! } ! } // Compute the new window size. ! container.layout(true); getShell().layout(true); ! Point p = getShell().computeSize(500, SWT.DEFAULT, true); getShell().setSize(p); ! } ! public int getModelAccessKey() { ! return modelAccessKey; ! } ! public void setModelAccessKey(int modelAccessKey) { ! this.modelAccessKey = modelAccessKey; ! fields.clear(); ! createExporterSpecificControls(holder); ! if (model.isFile(modelAccessKey)) { ! fileLabel.setEnabled(true); ! fileText.setEnabled(true); ! } else { ! fileLabel.setEnabled(false); ! fileText.setEnabled(false); ! } ! checkFilename(); ! } ! ! public Map getParameters() { ! return params; ! } } \ No newline at end of file |