Skip to content

Simplify the user interface for the “Check files locked” action #5356 #5357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,3 @@ On certain operating systems (MS Windows systems in particular) this operation w
|Wildcard|The wildcards are Java Regular expressions.
For instance .*\.txt would check any file with a .txt extension.
|===

After specifying a folder and wildcard (regular expression), use the `Add` button to add your file/folder selection to the table. Use the `Delete` or `Edit` buttons to remove or edit selected lines in the table.
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@

package org.apache.hop.workflow.actions.checkfilelocked;

import org.apache.commons.vfs2.FileObject;
import org.apache.hop.core.Const;
import org.apache.hop.core.exception.HopFileException;
import org.apache.hop.core.logging.LogChannel;
import org.apache.hop.core.util.Utils;
import org.apache.hop.core.variables.IVariables;
import org.apache.hop.core.vfs.HopVfs;
import org.apache.hop.i18n.BaseMessages;
import org.apache.hop.ui.core.PropsUi;
import org.apache.hop.ui.core.dialog.BaseDialog;
import org.apache.hop.ui.core.dialog.MessageBox;
import org.apache.hop.ui.core.widget.ColumnInfo;
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.core.widget.TextVar;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.apache.hop.ui.workflow.action.ActionDialog;
import org.apache.hop.ui.workflow.dialog.WorkflowDialog;
Expand All @@ -51,15 +54,10 @@ public class ActionCheckFilesLockedDialog extends ActionDialog {
private static final Class<?> PKG = ActionCheckFilesLocked.class;

private static final String[] FILETYPES =
new String[] {BaseMessages.getString(PKG, "ActionCheckFilesLocked.Filetype.All")};
new String[] {BaseMessages.getString(PKG, "System.FileType.AllFiles")};

private Text wName;

private Label wlFilename;
private Button wbFilename;
private Button wbDirectory;
private TextVar wFilename;

private Button wIncludeSubfolders;

private ActionCheckFilesLocked action;
Expand All @@ -71,13 +69,6 @@ public class ActionCheckFilesLockedDialog extends ActionDialog {
private Label wlFields;
private TableView wFields;

private Label wlFileMask;
private TextVar wFileMask;

private Button wbdFilename; // Delete
private Button wbeFilename; // Edit
private Button wbaFilename; // Add or change

public ActionCheckFilesLockedDialog(
Shell parent,
ActionCheckFilesLocked action,
Expand Down Expand Up @@ -205,124 +196,20 @@ public IAction open() {
// / END OF SETTINGS GROUP
// ///////////////////////////////////////////////////////////

// Filename line
wlFilename = new Label(shell, SWT.RIGHT);
wlFilename.setText(BaseMessages.getString(PKG, "ActionCheckFilesLocked.Filename.Label"));
PropsUi.setLook(wlFilename);
FormData fdlFilename = new FormData();
fdlFilename.left = new FormAttachment(0, 0);
fdlFilename.top = new FormAttachment(wSettings, 2 * margin);
fdlFilename.right = new FormAttachment(middle, -margin);
wlFilename.setLayoutData(fdlFilename);

// Browse Source folders button ...
wbDirectory = new Button(shell, SWT.PUSH | SWT.CENTER);
PropsUi.setLook(wbDirectory);
wbDirectory.setText(BaseMessages.getString(PKG, "ActionCheckFilesLocked.BrowseFolders.Label"));
FormData fdbDirectory = new FormData();
fdbDirectory.right = new FormAttachment(100, -margin);
fdbDirectory.top = new FormAttachment(wSettings, margin);
wbDirectory.setLayoutData(fdbDirectory);

wbDirectory.addListener(
SWT.Selection, e -> BaseDialog.presentDirectoryDialog(shell, wFilename, variables));

wbFilename = new Button(shell, SWT.PUSH | SWT.CENTER);
PropsUi.setLook(wbFilename);
wbFilename.setText(BaseMessages.getString(PKG, "ActionCheckFilesLocked.BrowseFiles.Label"));
FormData fdbFilename = new FormData();
fdbFilename.right = new FormAttachment(100, 0);
fdbFilename.top = new FormAttachment(wSettings, margin);
fdbFilename.right = new FormAttachment(wbDirectory, -margin);
wbFilename.setLayoutData(fdbFilename);

wbaFilename = new Button(shell, SWT.PUSH | SWT.CENTER);
PropsUi.setLook(wbaFilename);
wbaFilename.setText(BaseMessages.getString(PKG, "ActionCheckFilesLocked.FilenameAdd.Button"));
FormData fdbaFilename = new FormData();
fdbaFilename.right = new FormAttachment(wbFilename, -margin);
fdbaFilename.top = new FormAttachment(wSettings, margin);
wbaFilename.setLayoutData(fdbaFilename);

wFilename = new TextVar(variables, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
PropsUi.setLook(wFilename);
wFilename.addModifyListener(lsMod);
FormData fdFilename = new FormData();
fdFilename.left = new FormAttachment(middle, 0);
fdFilename.top = new FormAttachment(wSettings, 2 * margin);
fdFilename.right = new FormAttachment(wbaFilename, -2 * margin);
wFilename.setLayoutData(fdFilename);

// Whenever something changes, set the tooltip to the expanded version:
wFilename.addModifyListener(
e -> wFilename.setToolTipText(this.variables.resolve(wFilename.getText())));

wbFilename.addListener(
SWT.Selection,
e ->
BaseDialog.presentFileDialog(
shell, wFilename, variables, new String[] {"*"}, FILETYPES, false));

// Filemask
wlFileMask = new Label(shell, SWT.RIGHT);
wlFileMask.setText(BaseMessages.getString(PKG, "ActionCheckFilesLocked.Wildcard.Label"));
PropsUi.setLook(wlFileMask);
FormData fdlFilemask = new FormData();
fdlFilemask.left = new FormAttachment(0, 0);
fdlFilemask.top = new FormAttachment(wFilename, margin);
fdlFilemask.right = new FormAttachment(middle, -margin);
wlFileMask.setLayoutData(fdlFilemask);
wFileMask =
new TextVar(
variables,
shell,
SWT.SINGLE | SWT.LEFT | SWT.BORDER,
BaseMessages.getString(PKG, "ActionCheckFilesLocked.Wildcard.Tooltip"));
PropsUi.setLook(wFileMask);
wFileMask.addModifyListener(lsMod);
FormData fdFilemask = new FormData();
fdFilemask.left = new FormAttachment(middle, 0);
fdFilemask.top = new FormAttachment(wFilename, margin);
fdFilemask.right = new FormAttachment(wbaFilename, -margin);
wFileMask.setLayoutData(fdFilemask);

wlFields = new Label(shell, SWT.NONE);
wlFields.setText(BaseMessages.getString(PKG, "ActionCheckFilesLocked.Fields.Label"));
PropsUi.setLook(wlFields);
FormData fdlFields = new FormData();
fdlFields.left = new FormAttachment(0, 0);
fdlFields.right = new FormAttachment(middle, -margin);
fdlFields.top = new FormAttachment(wFileMask, margin);
fdlFields.top = new FormAttachment(wSettings, margin);
wlFields.setLayoutData(fdlFields);

// Buttons to the right of the screen...
wbdFilename = new Button(shell, SWT.PUSH | SWT.CENTER);
PropsUi.setLook(wbdFilename);
wbdFilename.setText(
BaseMessages.getString(PKG, "ActionCheckFilesLocked.FilenameDelete.Button"));
wbdFilename.setToolTipText(
BaseMessages.getString(PKG, "ActionCheckFilesLocked.FilenameDelete.Tooltip"));
FormData fdbdFilename = new FormData();
fdbdFilename.right = new FormAttachment(100, 0);
fdbdFilename.top = new FormAttachment(wlFields, margin);
wbdFilename.setLayoutData(fdbdFilename);

wbeFilename = new Button(shell, SWT.PUSH | SWT.CENTER);
PropsUi.setLook(wbeFilename);
wbeFilename.setText(BaseMessages.getString(PKG, "ActionCheckFilesLocked.FilenameEdit.Button"));
wbeFilename.setToolTipText(
BaseMessages.getString(PKG, "ActionCheckFilesLocked.FilenameEdit.Tooltip"));
FormData fdbeFilename = new FormData();
fdbeFilename.right = new FormAttachment(100, 0);
fdbeFilename.left = new FormAttachment(wbdFilename, 0, SWT.LEFT);
fdbeFilename.top = new FormAttachment(wbdFilename, margin);
wbeFilename.setLayoutData(fdbeFilename);

ColumnInfo[] fileFields =
new ColumnInfo[] {
new ColumnInfo(
BaseMessages.getString(PKG, "ActionCheckFilesLocked.Fields.Argument.Label"),
ColumnInfo.COLUMN_TYPE_TEXT,
ColumnInfo.COLUMN_TYPE_TEXT_BUTTON,
false),
new ColumnInfo(
BaseMessages.getString(PKG, "ActionCheckFilesLocked.Fields.Wildcard.Label"),
Expand All @@ -332,6 +219,7 @@ public IAction open() {

fileFields[0].setUsingVariables(true);
fileFields[0].setToolTip(BaseMessages.getString(PKG, "ActionCheckFilesLocked.Fields.Column"));
fileFields[0].setTextVarButtonSelectionListener(getFileSelectionAdapter());
fileFields[1].setUsingVariables(true);
fileFields[1].setToolTip(BaseMessages.getString(PKG, "ActionCheckFilesLocked.Wildcard.Column"));

Expand All @@ -348,58 +236,13 @@ public IAction open() {
FormData fdFields = new FormData();
fdFields.left = new FormAttachment(0, 0);
fdFields.top = new FormAttachment(wlFields, margin);
fdFields.right = new FormAttachment(wbdFilename, -margin);
fdFields.right = new FormAttachment(100, 0);
fdFields.bottom = new FormAttachment(wOk, -2 * margin);
wFields.setLayoutData(fdFields);

wlFields.setEnabled(!action.isArgFromPrevious());
wFields.setEnabled(!action.isArgFromPrevious());

// Add the file to the list of files...
SelectionAdapter selA =
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
wFields.add(wFilename.getText(), wFileMask.getText());
wFilename.setText("");
wFileMask.setText("");
wFields.removeEmptyRows();
wFields.setRowNums();
wFields.optWidth(true);
}
};
wbaFilename.addSelectionListener(selA);
wFilename.addSelectionListener(selA);

// Delete files from the list of files...
wbdFilename.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
int[] idx = wFields.getSelectionIndices();
wFields.remove(idx);
wFields.removeEmptyRows();
wFields.setRowNums();
}
});

// Edit the selected file & remove from the list...
wbeFilename.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
int idx = wFields.getSelectionIndex();
if (idx >= 0) {
String[] string = wFields.getItem(idx);
wFilename.setText(string[0]);
wFileMask.setText(string[1]);
wFields.remove(idx);
}
wFields.removeEmptyRows();
wFields.setRowNums();
}
});

// Add listeners
getData();
setPrevious();
Expand All @@ -409,21 +252,30 @@ public void widgetSelected(SelectionEvent arg0) {
return action;
}

protected SelectionAdapter getFileSelectionAdapter() {
return new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
try {
String path = wFields.getActiveTableItem().getText(wFields.getActiveTableColumn());
FileObject fileObject = HopVfs.getFileObject(path);

path =
BaseDialog.presentFileDialog(
shell, null, variables, fileObject, new String[] {"*"}, FILETYPES, true);
if (path != null) {
wFields.getActiveTableItem().setText(wFields.getActiveTableColumn(), path);
}
} catch (HopFileException e) {
LogChannel.UI.logError("Error selecting file or directory", e);
}
}
};
}

private void setPrevious() {
wlFields.setEnabled(!wPrevious.getSelection());
wFields.setEnabled(!wPrevious.getSelection());

wFilename.setEnabled(!wPrevious.getSelection());
wlFilename.setEnabled(!wPrevious.getSelection());
wbFilename.setEnabled(!wPrevious.getSelection());

wlFileMask.setEnabled(!wPrevious.getSelection());
wFileMask.setEnabled(!wPrevious.getSelection());

wbdFilename.setEnabled(!wPrevious.getSelection());
wbeFilename.setEnabled(!wPrevious.getSelection());
wbaFilename.setEnabled(!wPrevious.getSelection());
wbDirectory.setEnabled(!wPrevious.getSelection());
}

/** Copy information from the meta-data input to the dialog fields. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#
#

ActionCheckFilesLocked.BrowseFiles.Label=Datei...
ActionCheckFilesLocked.BrowseFolders.Label=Verzeichnis...
ActionCheckFilesLocked.CheckingFile=Pr\u00FCfe Datei [{0}] ...
ActionCheckFilesLocked.CouldNotProcess=Konnte [{0}] nicht verarbeiten, Fehler: {1}
ActionCheckFilesLocked.Description=Pr\u00FCfe, ob eine oder mehrere Dateien von anderen Prozessen blockiert sind
Expand All @@ -28,14 +26,7 @@ ActionCheckFilesLocked.Fields.Argument.Label=Datei/Verzeichnis
ActionCheckFilesLocked.Fields.Column=Zu pr\u00FCfende Dateien hier angeben
ActionCheckFilesLocked.Fields.Label=Dateien/Verzeichnisse:
ActionCheckFilesLocked.Fields.Wildcard.Label=Platzhalter
ActionCheckFilesLocked.Filename.Label=Datei/Verzeichnis
ActionCheckFilesLocked.FilenameAdd.Button=Hinzuf\u00FCgen
ActionCheckFilesLocked.FilenameDelete.Button=L\u00F6schen
ActionCheckFilesLocked.FilenameDelete.Tooltip=Entferne ausgew\u00E4hlte Dateien aus der Konfiguration
ActionCheckFilesLocked.FilenameEdit.Button=Bearbeiten
ActionCheckFilesLocked.FilenameEdit.Tooltip=Bearbeite ausgew\u00E4hlte Dateien
ActionCheckFilesLocked.FileNotExist=Konnte Datei [{0}] nicht finden.
ActionCheckFilesLocked.Filetype.All=Alle Dateien
ActionCheckFilesLocked.FoundPreviousRows={0} Zeilen aus Vorg\u00E4nger gefunden
ActionCheckFilesLocked.IncludeSubfolders.Label=Unterordner ber\u00FCcksichtigen
ActionCheckFilesLocked.IncludeSubfolders.Tooltip=Unterordner ber\u00FCcksichtigen
Expand All @@ -54,7 +45,4 @@ ActionCheckFilesLocked.ProcessingRow=Verarbeite Zeile [{0}].. Platzhalter [{1}]
ActionCheckFilesLocked.Settings.Label=Einstellungen
ActionCheckFilesLocked.Title=Pr\u00FCfe Dateisperren
ActionCheckFilesLocked.TotalFilesToCheck=Gesamtanzahl zu pr\u00FCfender Dateien = {0}
ActionCheckFilesLocked.UnableToLoadFromXml=Konnte Action 'Pr\u00FCfe Dateisperren' nicht aus XML laden.
ActionCheckFilesLocked.Wildcard.Column=Platzhalter hier angeben
ActionCheckFilesLocked.Wildcard.Label=Platzhalter
ActionCheckFilesLocked.Wildcard.Tooltip=Platzhalter
ActionCheckFilesLocked.Wildcard.Column=Platzhalter hier angeben
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
# limitations under the License.
#

ActionCheckFilesLocked.BrowseFiles.Label=File...
ActionCheckFilesLocked.BrowseFolders.Label=Folder...

ActionCheckFilesLocked.CheckingFile=Checking file [{0}] ...
ActionCheckFilesLocked.CouldNotProcess=Could not process [{0}], exception: {1}
ActionCheckFilesLocked.Description=Check if one or several files are locked by another process
Expand All @@ -26,14 +25,7 @@ ActionCheckFilesLocked.Fields.Argument.Label=File/Folder
ActionCheckFilesLocked.Fields.Column=Specify here files to check
ActionCheckFilesLocked.Fields.Label=Files/Folders:
ActionCheckFilesLocked.Fields.Wildcard.Label=Wildcard
ActionCheckFilesLocked.Filename.Label=File/Folder
ActionCheckFilesLocked.FilenameAdd.Button=&Add
ActionCheckFilesLocked.FilenameDelete.Button=&Delete
ActionCheckFilesLocked.FilenameDelete.Tooltip=Remove selected files from the grid
ActionCheckFilesLocked.FilenameEdit.Button=&Edit
ActionCheckFilesLocked.FilenameEdit.Tooltip=Edit selected files
ActionCheckFilesLocked.FileNotExist=We can not find file [{0}].
ActionCheckFilesLocked.Filetype.All=All files
ActionCheckFilesLocked.FoundPreviousRows=Found {0} previous result rows
ActionCheckFilesLocked.IncludeSubfolders.Label=Include Subfolders
ActionCheckFilesLocked.IncludeSubfolders.Tooltip=Include Subfolders
Expand All @@ -52,7 +44,4 @@ ActionCheckFilesLocked.ProcessingRow=Processing row [{0}]..wildcard [{1}] ?
ActionCheckFilesLocked.Settings.Label=Settings
ActionCheckFilesLocked.Title=Check files locked
ActionCheckFilesLocked.TotalFilesToCheck=Total files to check = {0}
ActionCheckFilesLocked.UnableToLoadFromXml=Unable to load action of type 'Check files locked' from XML node
ActionCheckFilesLocked.Wildcard.Column=Specify here a Wildcard
ActionCheckFilesLocked.Wildcard.Label=Wildcard
ActionCheckFilesLocked.Wildcard.Tooltip=Wildcard
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#
#

ActionCheckFilesLocked.BrowseFiles.Label=Archivo...
ActionCheckFilesLocked.BrowseFolders.Label=Directorio...
ActionCheckFilesLocked.CheckingFile=Verificando archivo [{0}]...
ActionCheckFilesLocked.CouldNotProcess=[{0}] no pudo procesarse. Excepci\u00F3n\: {1}
ActionCheckFilesLocked.Error.Exception.ProcessError=Error
Expand All @@ -27,14 +25,7 @@ ActionCheckFilesLocked.Fields.Argument.Label=Archivo/Directorio
ActionCheckFilesLocked.Fields.Column=Indique aqu\u00ED los archivos a verificar
ActionCheckFilesLocked.Fields.Label=Archivos/Directorios\:
ActionCheckFilesLocked.Fields.Wildcard.Label=Comod\u00EDn
ActionCheckFilesLocked.Filename.Label=Archivo/Directorio
ActionCheckFilesLocked.FilenameAdd.Button=&A\u00F1adir
ActionCheckFilesLocked.FilenameDelete.Button=&Eliminar
ActionCheckFilesLocked.FilenameDelete.Tooltip=Quitar los archivos seleccionados de la grilla
ActionCheckFilesLocked.FilenameEdit.Button=E&ditar
ActionCheckFilesLocked.FilenameEdit.Tooltip=Editar los archivos seleccionados
ActionCheckFilesLocked.FileNotExist=El archivo [{0}] no puede ser encontrado.
ActionCheckFilesLocked.Filetype.All=Todos los archivos
ActionCheckFilesLocked.FoundPreviousRows=Se encontraron {0} filas de resultados previos.
ActionCheckFilesLocked.IncludeSubfolders.Label=Incluir subdirectorios
ActionCheckFilesLocked.IncludeSubfolders.Tooltip=Incluir subdirectorios
Expand All @@ -51,7 +42,4 @@ ActionCheckFilesLocked.ProcessingRow=Procesando la fila [{0}]... Comod\u00EDn [{
ActionCheckFilesLocked.Settings.Label=Ajustes
ActionCheckFilesLocked.Title=Verificar bloqueo de archivos
ActionCheckFilesLocked.TotalFilesToCheck=Total de archivos a verificar \= {0}
ActionCheckFilesLocked.UnableToLoadFromXml=Imposible cargar la entrada de trabajo del tipo 'Verificar bloqueo de archivo' del nodo XML
ActionCheckFilesLocked.Wildcard.Column=Indique aqu\u00ED un comod\u00EDn
ActionCheckFilesLocked.Wildcard.Label=Comod\u00EDn
ActionCheckFilesLocked.Wildcard.Tooltip=Comod\u00EDn
Loading
Loading