Skip to content

Commit

Permalink
Enhanced syntax highlighting apache#4737
Browse files Browse the repository at this point in the history
- Add StyleAttribute to highlight with color and style
(NORMAL,ITALIC,BOLD)
- Add symbol syntax coloring
- Fix JavaScript function names highlight
- Replace synchronized Vector and Hashtable class
- Change colors for dark mode
- Fix look UserDefinedJavaClassDialog
- Code cleanup
  • Loading branch information
nadment authored and hansva committed Dec 24, 2024
1 parent 2fa12bb commit b3925a3
Show file tree
Hide file tree
Showing 10 changed files with 1,435 additions and 1,344 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ public String open() {
wlPosition.setLayoutData(fdlPosition);

folder = new CTabFolder(wTop, SWT.BORDER | SWT.RESIZE);
PropsUi.setLook(folder, Props.WIDGET_STYLE_TAB);
folder.setUnselectedImageVisible(true);
folder.setUnselectedCloseVisible(true);
FormData fdScript = new FormData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,24 +357,23 @@ public void mouseUp(MouseEvent e) {
private List<String> getSqlReservedWords() {
// Do not search keywords when connection is empty
if (input.getConnection() == null || input.getConnection().isEmpty()) {
return new ArrayList<>();
return List.of();
}

// If connection is a variable that can't be resolved
if (variables.resolve(input.getConnection()).startsWith("${")) {
return new ArrayList<>();
return List.of();
}

DatabaseMeta databaseMeta = pipelineMeta.findDatabase(input.getConnection(), variables);
if (databaseMeta == null) {
logError("Database connection not found. Proceding without keywords.");
return new ArrayList<>();
}
Database db = new Database(loggingObject, variables, databaseMeta);
DatabaseMetaData databaseMetaData = null;
try {

try (Database db = new Database(loggingObject, variables, databaseMeta)) {
db.connect();
databaseMetaData = db.getDatabaseMetaData();
DatabaseMetaData databaseMetaData = db.getDatabaseMetaData();
if (databaseMetaData == null) {
logError("Couldn't get database metadata");
return new ArrayList<>();
Expand All @@ -392,10 +391,7 @@ private List<String> getSqlReservedWords() {
return sqlKeywords;
} catch (HopDatabaseException e) {
logError("Couldn't extract keywords from database metadata. Proceding without them.");
return new ArrayList<>();
} finally {
db.disconnect();
db.close();
return List.of();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void addLineStyleListener() {
}

@Override
public void addLineStyleListener(List<String> keywords) {
addLineStyleListener(new JavaScriptHighlight());
public void addLineStyleListener(List<String> functionNames) {
addLineStyleListener(new JavaScriptHighlight(functionNames));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,26 @@

import java.util.List;
import org.apache.hop.core.variables.IVariables;
import org.apache.hop.ui.core.widget.highlight.SQLValuesHighlight;
import org.apache.hop.i18n.BaseMessages;
import org.apache.hop.ui.core.ConstUi;
import org.apache.hop.ui.core.FormDataBuilder;
import org.apache.hop.ui.core.PropsUi;
import org.apache.hop.ui.core.gui.GuiResource;
import org.apache.hop.ui.core.widget.highlight.SqlHighlight;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.LineStyleListener;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;

public class SQLStyledTextComp extends StyledTextVar {
Expand All @@ -44,11 +63,11 @@ public SQLStyledTextComp(

@Override
public void addLineStyleListener() {
addLineStyleListener(new SQLValuesHighlight(List.of()));
addLineStyleListener(new SqlHighlight(List.of()));
}

@Override
public void addLineStyleListener(List<String> keywords) {
addLineStyleListener(new SQLValuesHighlight(keywords));
addLineStyleListener(new SqlHighlight(keywords));
}
}
Loading

0 comments on commit b3925a3

Please sign in to comment.