mirror of
https://github.com/umlet/umlet.git
synced 2024-09-11 21:27:15 +03:00
Added possibility to link files to graphical elements by
"link=path_to_uxf_file" notation and open them via a new "Open Link" menu entry in the context menu. The path_to_uxf_file can be absolute or relative to the currently open file.
This commit is contained in:
parent
a8e583a67a
commit
60a909d1e9
@ -58,6 +58,7 @@ public class MenuConstants {
|
||||
public static final String LAYER = "Layer";
|
||||
public static final String LAYER_UP = "to front (layer +1)";
|
||||
public static final String LAYER_DOWN = "to back (layer -1)";
|
||||
public static final String OPEN_LINK = "Open Link";
|
||||
|
||||
// OTHERS
|
||||
public static final String SEARCH = "Search";
|
||||
|
@ -21,6 +21,7 @@ import com.baselet.element.facet.common.HorizontalAlignFacet;
|
||||
import com.baselet.element.facet.common.LayerFacet;
|
||||
import com.baselet.element.facet.common.LineTypeFacet;
|
||||
import com.baselet.element.facet.common.LineWidthFacet;
|
||||
import com.baselet.element.facet.common.LinkFacet;
|
||||
import com.baselet.element.facet.common.SeparatorLineFacet;
|
||||
import com.baselet.element.facet.common.TextPrintFacet;
|
||||
import com.baselet.element.facet.common.TransparencyFacet;
|
||||
@ -39,7 +40,7 @@ import com.baselet.element.relation.facet.RelationLineTypeFacet;
|
||||
*/
|
||||
public abstract class Settings {
|
||||
// the following lists are default facet configurations. they are declared here as a simple overview and for easy reuse
|
||||
protected static final List<Facet> BASE = listOf(BackgroundColorFacet.INSTANCE, TransparencyFacet.INSTANCE, ForegroundColorFacet.INSTANCE, LayerFacet.INSTANCE, LineWidthFacet.INSTANCE, GroupFacet.INSTANCE, CommentFacet.INSTANCE);
|
||||
protected static final List<Facet> BASE = listOf(BackgroundColorFacet.INSTANCE, TransparencyFacet.INSTANCE, ForegroundColorFacet.INSTANCE, LayerFacet.INSTANCE, LineWidthFacet.INSTANCE, GroupFacet.INSTANCE, CommentFacet.INSTANCE, LinkFacet.INSTANCE);
|
||||
protected static final List<Facet> BASE_WITH_LINETYPE = listOf(BASE, LineTypeFacet.INSTANCE, CustomDrawingFacet.INSTANCE, AdvancedDrawingsFacet.INSTANCE);
|
||||
protected static final List<Facet> BASE_EXTENDED = listOf(BASE_WITH_LINETYPE, TextPrintFacet.INSTANCE, FontSizeFacet.INSTANCE);
|
||||
|
||||
@ -134,4 +135,4 @@ public abstract class Settings {
|
||||
return secondRunFacets;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.baselet.element.facet.common;
|
||||
|
||||
import com.baselet.element.facet.FirstRunKeyValueFacet;
|
||||
import com.baselet.element.facet.PropertiesParserState;
|
||||
|
||||
public class LinkFacet extends FirstRunKeyValueFacet {
|
||||
|
||||
public static final LinkFacet INSTANCE = new LinkFacet();
|
||||
|
||||
private LinkFacet() {}
|
||||
|
||||
@Override
|
||||
public KeyValue getKeyValue() {
|
||||
return new KeyValue("link", false, "../../dummyLink.uxf", "path to a uxf file relative to the path of current file.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleValue(String value, PropertiesParserState state) {
|
||||
/* Empty at first. */
|
||||
}
|
||||
}
|
@ -54,7 +54,7 @@ public abstract class Utils {
|
||||
String compatibleFullString = fullString.replaceAll("\r\n", delimiter); // compatibility to windows \r\n
|
||||
|
||||
for (String line : compatibleFullString.split("\\" + delimiter)) {
|
||||
if (filterComments && line.matches("((//)|(fg=)|(bg=)|(autoresize=)|(layer=)|(group=)).*")) {
|
||||
if (filterComments && line.matches("((//)|(fg=)|(bg=)|(autoresize=)|(layer=)|(group=)|(link=)).*")) {
|
||||
continue;
|
||||
}
|
||||
else if (filterNewLines && line.isEmpty()) {
|
||||
|
@ -60,6 +60,7 @@ public abstract class BaseGUI {
|
||||
MenuFactorySwing menuFactory = MenuFactorySwing.getInstance();
|
||||
|
||||
JPopupMenu contextMenu = new JPopupMenu();
|
||||
contextMenu.add(createOpenLinkMenu(menuFactory));
|
||||
if (e instanceof CustomElement) {
|
||||
contextMenu.add(menuFactory.createEditSelected());
|
||||
}
|
||||
@ -90,6 +91,12 @@ public abstract class BaseGUI {
|
||||
return contextMenu;
|
||||
}
|
||||
|
||||
private JMenuItem createOpenLinkMenu(MenuFactorySwing menuFactory) {
|
||||
JMenuItem item = menuFactory.createOpenLinkMenu();
|
||||
item.setEnabled((selected_elements.size() == 1) && (selected_elements.iterator().next().getSetting("link") != null));
|
||||
return item;
|
||||
}
|
||||
|
||||
private JMenu createLayerMenu(MenuFactorySwing menuFactory) {
|
||||
JMenu layerMenu = menuFactory.createLayerUp();
|
||||
layerMenu.setEnabled(!selected_elements.isEmpty());
|
||||
|
@ -25,6 +25,7 @@ import static com.baselet.control.constants.MenuConstants.NEW_FROM_TEMPLATE;
|
||||
import static com.baselet.control.constants.MenuConstants.ONLINE_HELP;
|
||||
import static com.baselet.control.constants.MenuConstants.ONLINE_SAMPLE_DIAGRAMS;
|
||||
import static com.baselet.control.constants.MenuConstants.OPEN;
|
||||
import static com.baselet.control.constants.MenuConstants.OPEN_LINK;
|
||||
import static com.baselet.control.constants.MenuConstants.OPTIONS;
|
||||
import static com.baselet.control.constants.MenuConstants.PASTE;
|
||||
import static com.baselet.control.constants.MenuConstants.PRINT;
|
||||
@ -41,6 +42,8 @@ import static com.baselet.control.constants.MenuConstants.UNDO;
|
||||
import static com.baselet.control.constants.MenuConstants.UNGROUP;
|
||||
import static com.baselet.control.constants.MenuConstants.VIDEO_TUTORIAL;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import java.awt.MouseInfo;
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
@ -241,6 +244,25 @@ public class MenuFactory {
|
||||
valueMap.put(e, Integer.toString(e.getLayer() + change));
|
||||
}
|
||||
actualHandler.getController().executeCommand(new ChangeElementSetting(LayerFacet.KEY, valueMap));
|
||||
}
|
||||
else if (menuItem.equals(OPEN_LINK) && actualHandler != null && actualSelector != null) {
|
||||
List<GridElement> v = actualSelector.getSelectedElements();
|
||||
if (v.size() == 1) {
|
||||
GridElement e = v.get(0);
|
||||
String absoluteLinkName = e.getSetting("link");
|
||||
File link = new File(absoluteLinkName);
|
||||
if (!link.isAbsolute()) {
|
||||
File file = new File(actualHandler.getFileHandler().getFullPathName());
|
||||
String parentDir = file.getParent();
|
||||
try {
|
||||
File canonical = new File(parentDir + "/" + absoluteLinkName).getCanonicalFile();
|
||||
absoluteLinkName = canonical.getAbsolutePath();
|
||||
} catch (Exception exc) {
|
||||
exc.printStackTrace();
|
||||
}
|
||||
}
|
||||
main.doOpen(absoluteLinkName);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -16,6 +16,7 @@ import static com.baselet.control.constants.MenuConstants.GENERATE_CLASS;
|
||||
import static com.baselet.control.constants.MenuConstants.GENERATE_CLASS_OPTIONS;
|
||||
import static com.baselet.control.constants.MenuConstants.GROUP;
|
||||
import static com.baselet.control.constants.MenuConstants.LAYER;
|
||||
import static com.baselet.control.constants.MenuConstants.OPEN_LINK;
|
||||
import static com.baselet.control.constants.MenuConstants.LAYER_DOWN;
|
||||
import static com.baselet.control.constants.MenuConstants.LAYER_UP;
|
||||
import static com.baselet.control.constants.MenuConstants.MAIL_TO;
|
||||
@ -301,6 +302,10 @@ public class MenuFactorySwing extends MenuFactory {
|
||||
return alignMenu;
|
||||
}
|
||||
|
||||
public JMenuItem createOpenLinkMenu() {
|
||||
return createJMenuItem(false, OPEN_LINK, null, null, null);
|
||||
}
|
||||
|
||||
public JMenu createLayerUp() {
|
||||
JMenu alignMenu = new JMenu(LAYER);
|
||||
for (String direction : new String[] { LAYER_DOWN, LAYER_UP }) {
|
||||
|
Loading…
Reference in New Issue
Block a user