Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/FileExtensionDialog.java')
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/FileExtensionDialog.java267
1 files changed, 131 insertions, 136 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/FileExtensionDialog.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/FileExtensionDialog.java
index fcab03347d8..add9682a58a 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/FileExtensionDialog.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/FileExtensionDialog.java
@@ -40,13 +40,13 @@ public class FileExtensionDialog extends TitleAreaDialog {
private static final String DIALOG_SETTINGS_SECTION = "FileExtensionDialogSettings"; //$NON-NLS-1$
- private String filename = ""; //$NON-NLS-1$
+ private String filename = ""; //$NON-NLS-1$
- private String initialValue;
+ private String initialValue;
- private Text filenameField;
+ private Text filenameField;
- private Button okButton;
+ private Button okButton;
private String title;
@@ -58,50 +58,49 @@ public class FileExtensionDialog extends TitleAreaDialog {
private final String label;
- /**
- * Constructs a new file extension dialog.
- * @param parentShell the parent shell
- */
- public FileExtensionDialog(Shell parentShell) {
- this(parentShell, WorkbenchMessages.FileExtension_shellTitle,
- IWorkbenchHelpContextIds.FILE_EXTENSION_DIALOG,
- WorkbenchMessages.FileExtension_dialogTitle,
- WorkbenchMessages.FileExtension_fileTypeMessage,
+ /**
+ * Constructs a new file extension dialog.
+ *
+ * @param parentShell the parent shell
+ */
+ public FileExtensionDialog(Shell parentShell) {
+ this(parentShell, WorkbenchMessages.FileExtension_shellTitle, IWorkbenchHelpContextIds.FILE_EXTENSION_DIALOG,
+ WorkbenchMessages.FileExtension_dialogTitle, WorkbenchMessages.FileExtension_fileTypeMessage,
WorkbenchMessages.FileExtension_fileTypeLabel);
setShellStyle(getShellStyle() | SWT.SHEET);
}
- /**
- * Constructs a new file extension dialog.
- *
- * @param parentShell the parent shell
- * @param title the dialog title
- * @param helpContextId the help context for this dialog
- * @param headerTitle the dialog header
- * @param message the dialog message
- * @param label the label for the "file type" field
- * @since 3.4
- */
- public FileExtensionDialog(Shell parentShell, String title, String helpContextId, String headerTitle, String message, String label) {
- super(parentShell);
- this.title = title;
- this.helpContextId = helpContextId;
+ /**
+ * Constructs a new file extension dialog.
+ *
+ * @param parentShell the parent shell
+ * @param title the dialog title
+ * @param helpContextId the help context for this dialog
+ * @param headerTitle the dialog header
+ * @param message the dialog message
+ * @param label the label for the "file type" field
+ * @since 3.4
+ */
+ public FileExtensionDialog(Shell parentShell, String title, String helpContextId, String headerTitle,
+ String message, String label) {
+ super(parentShell);
+ this.title = title;
+ this.helpContextId = helpContextId;
this.headerTitle = headerTitle;
message2 = message;
this.label = label;
setShellStyle(getShellStyle() | SWT.SHEET);
- }
+ }
- @Override
+ @Override
protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText(title);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, helpContextId);
- }
-
+ super.configureShell(shell);
+ shell.setText(title);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, helpContextId);
+ }
- @Override
+ @Override
protected Control createDialogArea(Composite parent) {
Composite parentComposite = (Composite) super.createDialogArea(parent);
@@ -111,8 +110,7 @@ public class FileExtensionDialog extends TitleAreaDialog {
setTitle(headerTitle);
setMessage(message2);
- new Label(contents, SWT.LEFT)
- .setText(label);
+ new Label(contents, SWT.LEFT).setText(label);
filenameField = new Text(contents, SWT.SINGLE | SWT.BORDER);
if (initialValue != null) {
@@ -129,124 +127,121 @@ public class FileExtensionDialog extends TitleAreaDialog {
Dialog.applyDialogFont(parentComposite);
Point defaultMargins = LayoutConstants.getMargins();
- GridLayoutFactory.fillDefaults().numColumns(2).margins(
- defaultMargins.x, defaultMargins.y).generateLayout(contents);
+ GridLayoutFactory.fillDefaults().numColumns(2).margins(defaultMargins.x, defaultMargins.y)
+ .generateLayout(contents);
return contents;
}
-
- @Override
+ @Override
protected void createButtonsForButtonBar(Composite parent) {
- okButton = createButton(parent, IDialogConstants.OK_ID,
- IDialogConstants.OK_LABEL, true);
- okButton.setEnabled(false);
- createButton(parent, IDialogConstants.CANCEL_ID,
- IDialogConstants.CANCEL_LABEL, false);
- }
-
- /**
- * Validate the user input for a file type
- */
- private boolean validateFileType() {
- // We need kernel api to validate the extension or a filename
-
- // check for empty name and extension
- if (filename.length() == 0) {
- setErrorMessage(null);
- return false;
- }
-
- // check for empty extension if there is no name
- int index = filename.lastIndexOf('.');
- if (index == filename.length() - 1) {
- if (index == 0 || (index == 1 && filename.charAt(0) == '*')) {
- setErrorMessage(WorkbenchMessages.FileExtension_extensionEmptyMessage);
- return false;
- }
- }
-
- // check for characters before *
- // or no other characters
- // or next chatacter not '.'
- // or another *
- index = filename.indexOf('*');
- if (index > -1) {
- if (filename.length() == 1) {
- setErrorMessage(WorkbenchMessages.FileExtension_extensionEmptyMessage);
- return false;
- }
- if (index != 0 || filename.charAt(1) != '.') {
- setErrorMessage(WorkbenchMessages.FileExtension_fileNameInvalidMessage);
- return false;
- }
- if (filename.length() > index && filename.indexOf('*', index + 1) != -1) {
- setErrorMessage(WorkbenchMessages.FileExtension_fileNameInvalidMessage);
- return false;
- }
- }
-
- setErrorMessage(null);
- return true;
- }
-
- /**
- * Get the extension.
- *
- * @return the extension
- */
- public String getExtension() {
- // We need kernel api to validate the extension or a filename
-
- int index = filename.lastIndexOf('.');
- if (index == -1) {
+ okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+ okButton.setEnabled(false);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ }
+
+ /**
+ * Validate the user input for a file type
+ */
+ private boolean validateFileType() {
+ // We need kernel api to validate the extension or a filename
+
+ // check for empty name and extension
+ if (filename.length() == 0) {
+ setErrorMessage(null);
+ return false;
+ }
+
+ // check for empty extension if there is no name
+ int index = filename.lastIndexOf('.');
+ if (index == filename.length() - 1) {
+ if (index == 0 || (index == 1 && filename.charAt(0) == '*')) {
+ setErrorMessage(WorkbenchMessages.FileExtension_extensionEmptyMessage);
+ return false;
+ }
+ }
+
+ // check for characters before *
+ // or no other characters
+ // or next chatacter not '.'
+ // or another *
+ index = filename.indexOf('*');
+ if (index > -1) {
+ if (filename.length() == 1) {
+ setErrorMessage(WorkbenchMessages.FileExtension_extensionEmptyMessage);
+ return false;
+ }
+ if (index != 0 || filename.charAt(1) != '.') {
+ setErrorMessage(WorkbenchMessages.FileExtension_fileNameInvalidMessage);
+ return false;
+ }
+ if (filename.length() > index && filename.indexOf('*', index + 1) != -1) {
+ setErrorMessage(WorkbenchMessages.FileExtension_fileNameInvalidMessage);
+ return false;
+ }
+ }
+
+ setErrorMessage(null);
+ return true;
+ }
+
+ /**
+ * Get the extension.
+ *
+ * @return the extension
+ */
+ public String getExtension() {
+ // We need kernel api to validate the extension or a filename
+
+ int index = filename.lastIndexOf('.');
+ if (index == -1) {
return ""; //$NON-NLS-1$
}
- if (index == filename.length()) {
+ if (index == filename.length()) {
return ""; //$NON-NLS-1$
}
- return filename.substring(index + 1, filename.length());
- }
-
- /**
- * Get the name.
- *
- * @return the name
- */
- public String getName() {
- // We need kernel api to validate the extension or a filename
-
- int index = filename.lastIndexOf('.');
- if (index == -1) {
+ return filename.substring(index + 1, filename.length());
+ }
+
+ /**
+ * Get the name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ // We need kernel api to validate the extension or a filename
+
+ int index = filename.lastIndexOf('.');
+ if (index == -1) {
return filename;
}
- if (index == 0) {
+ if (index == 0) {
return "*"; //$NON-NLS-1$
}
- return filename.substring(0, index);
- }
+ return filename.substring(0, index);
+ }
- /**
+ /**
* Sets the initial value that should be prepopulated in this dialog.
*
- * @param initialValue
- * the value to be displayed to the user
+ * @param initialValue the value to be displayed to the user
* @since 3.4
*/
- public void setInitialValue(String initialValue) {
- this.initialValue = initialValue;
- }
+ public void setInitialValue(String initialValue) {
+ this.initialValue = initialValue;
+ }
- @Override
+ @Override
protected IDialogSettings getDialogBoundsSettings() {
- IDialogSettings settings = WorkbenchPlugin.getDefault().getDialogSettings();
- IDialogSettings section = settings.getSection(DIALOG_SETTINGS_SECTION);
- if (section == null) section = settings.addNewSection(DIALOG_SETTINGS_SECTION);
- return section;
- }
+ IDialogSettings settings = WorkbenchPlugin.getDefault().getDialogSettings();
+ IDialogSettings section = settings.getSection(DIALOG_SETTINGS_SECTION);
+ if (section == null)
+ section = settings.addNewSection(DIALOG_SETTINGS_SECTION);
+ return section;
+ }
- @Override
+ @Override
protected boolean isResizable() {
- return true;
- }
+ return true;
+ }
}

Back to the top