Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright (C) 2010 Jorge Gomez Sanz, Ruben Fuentes
* Modifications over original code from jgraph.sourceforge.net
*
*
* This file is part of the INGENME tool. INGENME is an open source meta-editor
* which produces customized editors for user-defined modeling languages
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation version 3 of the License
*
* This program 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. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see
**/
package ingenias.editor;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
import java.awt.event.*;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.HashSet;
import java.util.Map;
import java.util.Hashtable;
import java.util.ArrayList;
import javax.swing.event.UndoableEditEvent;
import org.jgraph.JGraph;
import org.jgraph.graph.*;
import org.jgraph.event.*;
import java.util.Vector;
import org.jgraph.JGraph;
import org.jgraph.graph.*;
import org.jgraph.event.*;
import org.jgraph.plaf.basic.*;
import com.languageExplorer.widgets.ScrollableBar;
import ingenias.editor.Preferences.RelationshipLayout;
import ingenias.editor.editiondialog.GeneralEditionPanel;
import ingenias.editor.entities.*;
import ingenias.editor.cell.*;
import ingenias.editor.models.*;
import ingenias.editor.rendererxml.CollectionPanel;
//import ingenias.editor.auml.*;
import ingenias.exception.*;
import ingenias.generator.browser.Browser;
import ingenias.generator.browser.BrowserImp;
import java.io.*;
import java.awt.geom.*;
public class Editor
extends JPanel
implements java.io.Serializable {
/*public void setCommonButtons(ButtonToolBar commonButtons) {
this.commonButtons = commonButtons;
}*/
public JPanel getUpperSidePanel() {
return upperSidePanel;
}
// JGraph instance
/**
* Description of the Field
*/
private JTabbedPane graphPanel;
// Undo Manager
/**
* Description of the Field
*/
protected GraphUndoManager undoManager;
private JPanel gpan, upperSidePanel;
protected ObjectManager om = null;
// public static final ingenias.editor.events.ChangeNARYEdgeLocation relationshipLocationListener=new ingenias.editor.events.ChangeNARYEdgeLocation();
protected JComponent modelToolBar = null;
// protected ButtonToolBar commonButtons = null;
public static int idCounter = 0;
// To make "cut" action not to delete until pasted
public static final int COPIED = 0;
public static final int PASTED = 1;
public static final int NONE = 2;
public static final int CUT = 3;
private Preferences prefs;
private GraphManager gm;
private Vector graphModelListeners=new
Vector();
private MouseListener lastMouseListener;
public void addGraphModelListener(GraphModelListener gl){
graphModelListeners.add(gl);
};
public static String getNewId(ObjectManager om, GraphManager gm) {
idCounter=0;
Vector rels;
rels = RelationshipManager.getRelationshipsVector(gm);
HashSet trels=new HashSet ();
for (NAryEdgeEntity nedge:rels){
trels.add(nedge.getId());
}
while (trels.contains(""+idCounter) ||
om.findUserObject(""+idCounter).size()>0 ||
gm.getModel(""+idCounter)!=null){
idCounter++;
}
return ""+idCounter;
}
public static String getNewId(Browser browser) {
return getNewId(browser.getState().om,browser.getState().gm);
}
public JTabbedPane getGraphPanel(){
return graphPanel;
}
public void addTabSelectorChangeListener(javax.swing.event.ChangeListener cl){
graphPanel.addChangeListener(cl);
}
//
// Editor Panel
//
// Construct an Editor Panel
/**
* Constructor for the Editor object
*/
public Editor(ObjectManager om, GraphManager gm, Preferences prefs) {
this.om = om;
this.gm=gm;
this.prefs=prefs;
this.setName("grapheditor");
graphPanel = new DraggableTabbedPane();
//graphPanel.setUI(new JTabbedPaneWithCloseIconsUI());
graphPanel.setName("DiagramsPanel");
// Use Border Layout
setLayout(new BorderLayout());
// Construct the Graph
// graph = new JGraph(new Model(), new MarqueeHandler(this));
// Construct Command History
//
// Create a GraphUndoManager which also Updates the ToolBar
undoManager =
new GraphUndoManager() {
// Override Superclass
/**
* Description of the Method
*
*@param e Description of Parameter
*/
public void undoableEditHappened(UndoableEditEvent e) {
// First Invoke Superclass
super.undoableEditHappened(e);
// Then Update Undo/Redo Buttons
//updateHistoryButtons();
}
};
// Construct Panel
//
// Add a ToolBar
upperSidePanel = new JPanel();
upperSidePanel.setLayout(new GridLayout(1, 1));
//commonButtons = createToolBar();
//upperSidePanel.add(commonButtons);
add(upperSidePanel, BorderLayout.NORTH);
// Add the Graph as Center Component
this.addTabSelectorChangeListener(new ChangeListener(){
public void stateChanged(ChangeEvent e) {
if (graphPanel.getSelectedComponent()!=null){
graphPanel.getSelectedComponent().invalidate();
graphPanel.getSelectedComponent().validate();
graphPanel.getSelectedComponent().repaint();
}
}
});
add(graphPanel, BorderLayout.CENTER);
}
public void closeTab(String name) {
int size = graphPanel.getTabCount();
int k = 0;
String title = "";
while (k < size && !title.equals(name)) {
title = graphPanel.getTitleAt(k);
if (!title.equals(name)) {
k++;
}
}
if (k < size) {
graphPanel.removeTabAt(k);
}
}
public ModelJGraph getGraph() {
if (graphPanel.getTabCount()>0 && graphPanel.getComponentAt(graphPanel.getSelectedIndex()) instanceof JScrollPane){
JScrollPane comp=(JScrollPane)(graphPanel.getComponentAt(graphPanel.getSelectedIndex()));
if (comp!=null && comp.getViewport().getView()!=null){
//System.err.println(comp.getViewport().getView().getClass().getName());
return (ModelJGraph)(comp.getViewport().getView());
} /*else {
throw new RuntimeException("getGraph returned a null object. This will cause bad behaviors");
}
} else
throw new RuntimeException("getGraph returned a null object because there is no graph stored in the editor. This will cause bad behaviors");*/
}
return null;
}
// This method can be invoked by pressing the project tree and the state
// change listener (when the tab changes)
public synchronized void changeGraph(final ModelJGraph graph) {
if (ModelJGraph.getEnabledAllListeners()){
if (graph != null) {
graph.setPortsVisible(true);
if (this.graphPanel.indexOfTab(graph.getID()) < 0) {
this.graphPanel.addTab(graph.getID(), ProjectTreeRenderer.selectIconByUserObject(graph),new JScrollPane(graph));
graph.getModel().addGraphModelListener(new GraphModelListener(){
public void graphChanged(GraphModelEvent e) {
selectedGraphModelHasChanged(e);
}
});
}
if (lastMouseListener!=null)
graph.removeMouseListener(lastMouseListener);
}
this.graphPanel.setSelectedIndex(this.graphPanel.indexOfTab(graph.getID()));
updateBars(graph);
lastMouseListener=new MouseListener(){
@Override
public void mouseClicked(MouseEvent arg0) {
}
@Override
public void mouseEntered(MouseEvent arg0) {
}
@Override
public void mouseExited(MouseEvent arg0) {
}
@Override
public void mousePressed(MouseEvent arg0) {
}
@Override
public void mouseReleased(MouseEvent arg0) {
if (graph.getSelectionCells().length==1 &&
!graph.getListenerContainer().getParentRelationships().containsKey(graph.getSelectionCells()[0])){
Object selectedCell=graph.getSelectionCells()[0];
Object currentCell=null;
Object oldCell=null;
HashSet cells=new HashSet();
int oldSize=0;
do {
oldCell=currentCell;
oldSize=cells.size();
currentCell=graph.getNextCellForLocation(oldCell, arg0.getPoint().getX(), arg0.getPoint().getY());
if (currentCell!=null)
cells.add(currentCell);
}while (currentCell!=null && !currentCell.equals(oldCell) && cells.size()>oldSize);
cells.remove(selectedCell);
if (cells.size()>=1){
// check if the cell underneath is a container
Hashtable