Skip to content
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
9 changes: 6 additions & 3 deletions messages/src/main/proto/data_transfer_objects.proto
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,12 @@ message SightTypeDto {
message TokenPropertyDto {
string name = 1;
google.protobuf.StringValue short_name = 2;
bool high_priority = 3;
bool owner_only = 4;
bool gm_only = 5;
optional bool high_priority = 3;
optional bool owner_only = 4;
optional bool gm_only = 5;
optional string stat_sheet_view_permission = 8;
optional string editor_view_permission = 9;
optional string editor_edit_permission = 10;
google.protobuf.StringValue default_value = 6;
google.protobuf.StringValue display_name = 7;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
* This software Copyright by the RPTools.net development team, and
* licensed under the Affero GPL Version 3 or, at your option, any later
* version.
*
* MapTool Source Code is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public
* License * along with this source Code. If not, please visit
* <http://www.gnu.org/licenses/> and specifically the Affero license
* text at <http://www.gnu.org/licenses/agpl.html>.
*/
package net.rptools.maptool.client.swing.table;

import com.jidesoft.combobox.MultilineStringExComboBox;
import com.jidesoft.combobox.PopupPanel;
import com.jidesoft.grid.MultilineStringCellEditor;
import com.jidesoft.plaf.basic.BasicExComboBoxUI;
import java.awt.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.swing.*;
import net.rptools.maptool.client.AppConstants;
import net.rptools.maptool.client.AppPreferences;
import net.rptools.maptool.language.I18N;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
import org.fife.ui.rsyntaxtextarea.Theme;
import org.fife.ui.rtextarea.RTextScrollPane;

/* Pop-up cell editor using RSyntaxTextArea. Used in Token Property editor. */
public class MTMultilineStringCellEditor extends MultilineStringCellEditor {
private static final Logger log = LogManager.getLogger(MTMultilineStringCellEditor.class);

public MTMultilineStringExComboBox createMultilineStringComboBox() {
MTMultilineStringExComboBox localMultilineStringExComboBox = new MTMultilineStringExComboBox();
localMultilineStringExComboBox.setEditable(true);
localMultilineStringExComboBox.setUI(new BasicExComboBoxUI());
return localMultilineStringExComboBox;
}

/* needed to change the popup for properties */
public static class MTMultilineStringExComboBox extends MultilineStringExComboBox {
final ResourceBundle a = ResourceBundle.getBundle("com.jidesoft.combobox.combobox");

public ResourceBundle getResourceBundle(Locale paramLocale) {
return ResourceBundle.getBundle("com.jidesoft.combobox.combobox", paramLocale);
}

public PopupPanel createPopupComponent() {
return new MTMultilineStringPopupPanel(
getResourceBundle(Locale.getDefault()).getString("ComboBox.multilineStringTitle"));
}
}

/* the property popup table */
private static class MTMultilineStringPopupPanel extends PopupPanel {
private final RSyntaxTextArea j = createTextArea();

public MTMultilineStringPopupPanel() {
this("");
}

public MTMultilineStringPopupPanel(String paramString) {
this.setResizable(true);
/* Set the color style via Theme */
try {
File themeFile =
new File(
AppConstants.THEMES_DIR, AppPreferences.defaultMacroEditorTheme.get() + ".xml");
Theme theme = Theme.load(new FileInputStream(themeFile));
theme.apply(j);

j.revalidate();
} catch (IOException e) {
log.error("Error while loading multiline property editor theme", e);
}
JScrollPane localJScrollPane = new RTextScrollPane(j);
localJScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
localJScrollPane.setAutoscrolls(true);
localJScrollPane.setPreferredSize(new Dimension(300, 200));
setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 5));
setLayout(new BorderLayout());
setTitle(paramString);
add(localJScrollPane, "Center");
setDefaultFocusComponent(j);
j.setLineWrap(false);
JCheckBox wrapToggle = new JCheckBox(I18N.getString("EditTokenDialog.msg.wrap"));
wrapToggle.addActionListener(e -> j.setLineWrap(!j.getLineWrap()));

DefaultComboBoxModel<String> syntaxListModel = new DefaultComboBoxModel<>();
syntaxListModel.addElement(SyntaxConstants.SYNTAX_STYLE_NONE);
syntaxListModel.addElement(SyntaxConstants.SYNTAX_STYLE_JSON);
syntaxListModel.addElement(SyntaxConstants.SYNTAX_STYLE_PROPERTIES_FILE);
syntaxListModel.addElement(SyntaxConstants.SYNTAX_STYLE_HTML);
syntaxListModel.addElement(SyntaxConstants.SYNTAX_STYLE_XML);
JComboBox<String> syntaxComboBox = new JComboBox<>(syntaxListModel);
syntaxComboBox.addActionListener(
e -> j.setSyntaxEditingStyle((String) syntaxComboBox.getSelectedItem()));

add(syntaxComboBox, BorderLayout.BEFORE_FIRST_LINE);
add(wrapToggle, BorderLayout.AFTER_LAST_LINE);
}

public Object getSelectedObject() {
return j.getText();
}

public void setSelectedObject(Object paramObject) {
if (paramObject != null) {
j.setText(paramObject.toString());
} else {
j.setText("");
}
}

protected RSyntaxTextArea createTextArea() {
RSyntaxTextArea textArea = new RSyntaxTextArea();
textArea.setUseFocusableTips(false);
textArea.setAnimateBracketMatching(true);
textArea.setBracketMatchingEnabled(true);
textArea.setLineWrap(false);
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE);
return textArea;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* This software Copyright by the RPTools.net development team, and
* licensed under the Affero GPL Version 3 or, at your option, any later
* version.
*
* MapTool Source Code is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public
* License * along with this source Code. If not, please visit
* <http://www.gnu.org/licenses/> and specifically the Affero license
* text at <http://www.gnu.org/licenses/agpl.html>.
*/
package net.rptools.maptool.client.swing.table;

import com.formdev.flatlaf.FlatIconColors;
import com.formdev.flatlaf.util.ColorFunctions;
import java.awt.*;
import javax.swing.*;
import javax.swing.table.TableCellRenderer;

public class MultiLineTableHeaderRenderer implements TableCellRenderer {
private static final Color HEADER_BACKGROUND =
UIManager.getDefaults().getColor("TableHeader.background");
private static final Color HEADER_FOREGROUND =
UIManager.getDefaults().getColor("TableHeader.foreground");
private static final Color HEADER_ALTERNATE_BACKGROUND;
private static final Color HEADER_ALTERNATE_FOREGROUND;

static {
// this is so tests can be passed as they do not install the LaF
Color c1, c2;
try {
Color mixWith = UIManager.getColor(FlatIconColors.OBJECTS_BLACK_TEXT.key);
c1 = ColorFunctions.mix(HEADER_BACKGROUND, mixWith, 0.94f);
c2 = ColorFunctions.mix(HEADER_FOREGROUND, mixWith, 0.31f);
} catch (Exception e) {
c1 = Color.WHITE;
c2 = Color.BLACK;
}
HEADER_ALTERNATE_BACKGROUND = c1;
HEADER_ALTERNATE_FOREGROUND = c2;
}

public MultiLineTableHeaderRenderer() {}

@Override
public Component getTableCellRendererComponent(
JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JPanel panel = new JPanel();
Color foreground = column % 2 == 0 ? HEADER_ALTERNATE_FOREGROUND : HEADER_FOREGROUND;
Color background = column % 2 == 0 ? HEADER_ALTERNATE_BACKGROUND : HEADER_BACKGROUND;
panel.setBackground(background);
panel.setForeground(foreground);

LookAndFeel.installBorder(panel, "TableHeader.cellBorder");

BoxLayout box = new BoxLayout(panel, BoxLayout.PAGE_AXIS);
panel.setLayout(box);

String[] heading = ((String) value).split(" ");
for (String word : heading) {
JLabel label = new JLabel(word, null, SwingConstants.CENTER);
label.setBackground(background);
label.setForeground(foreground);
label.setOpaque(true);
label.setAlignmentX(0.5f);
panel.add(label);
}
panel.invalidate();

return panel;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* <http://www.gnu.org/licenses/> and specifically the Affero license
* text at <http://www.gnu.org/licenses/agpl.html>.
*/
package net.rptools.maptool.client.swing;
package net.rptools.maptool.client.swing.table;

import java.awt.*;
import javax.swing.*;
Expand Down Expand Up @@ -40,6 +40,7 @@ public TextFieldEditorButtonTableCellEditor() {
textField.addActionListener(l -> fireEditingStopped());
panel.add(textField);
JButton button = new JButton("...");

button.addActionListener(
l ->
MacroEditorDialog.createModalDialog(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* This software Copyright by the RPTools.net development team, and
* licensed under the Affero GPL Version 3 or, at your option, any later
* version.
*
* MapTool Source Code is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public
* License * along with this source Code. If not, please visit
* <http://www.gnu.org/licenses/> and specifically the Affero license
* text at <http://www.gnu.org/licenses/agpl.html>.
*/
package net.rptools.maptool.client.swing.table;

import com.formdev.flatlaf.ui.FlatUIUtils;
import java.awt.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import javax.swing.*;
import javax.swing.table.TableCellRenderer;
import net.rptools.maptool.client.AppConstants;
import net.rptools.maptool.client.AppPreferences;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rsyntaxtextarea.Theme;

/* cell renderer for properties table */
public class WordWrapCellRenderer extends RSyntaxTextArea implements TableCellRenderer {
private static final Logger log = LogManager.getLogger();

public WordWrapCellRenderer() {
setLineWrap(false);
setWrapStyleWord(true);

/* Set the color style via Theme */
try {
File themeFile =
new File(AppConstants.THEMES_DIR, AppPreferences.defaultMacroEditorTheme.get() + ".xml");
Theme theme = Theme.load(new FileInputStream(themeFile));
theme.apply(this);
setFont(FlatUIUtils.nonUIResource(UIManager.getFont("monospaced.font")));
revalidate();
} catch (IOException e) {
log.error("Error while loading theme", e);
}
}

public Component getTableCellRendererComponent(
JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (value == null) {
value = "";
}
setText(value.toString());
setSize(table.getColumnModel().getColumn(column).getWidth(), getPreferredSize().height);
if (table.getRowHeight(row) != getPreferredSize().height) {
table.setRowHeight(row, getPreferredSize().height);
}
return this;
}
}
Loading
Loading