Search in sources :

Example 36 with EditPart

use of org.eclipse.gef.EditPart in project cubrid-manager by CUBRID.

the class ShowHostAction method run.

/**
	 * Create a new figure in dashboard.
	 * 
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    IStructuredSelection selection = (IStructuredSelection) getSelection();
    Iterator<?> iterator = selection.iterator();
    List<HostNode> hosts = new ArrayList<HostNode>();
    EditPart root = null;
    while (iterator.hasNext()) {
        Object objSelected = iterator.next();
        if (objSelected instanceof DatabaseMonitorPart) {
            DatabaseMonitorPart cmp = (DatabaseMonitorPart) objSelected;
            DatabaseNode dn = ((DatabaseNode) cmp.getModel());
            if (!hosts.contains(dn.getParent())) {
                hosts.add(dn.getParent());
            }
            root = cmp.getParent();
        } else if (objSelected instanceof BrokerMonitorPart) {
            BrokerMonitorPart cmp = (BrokerMonitorPart) objSelected;
            BrokerNode bn = ((BrokerNode) cmp.getModel());
            if (!hosts.contains(bn.getParent())) {
                hosts.add(bn.getParent());
            }
            root = cmp.getParent();
        }
    }
    for (HostNode host : hosts) {
        if (host.isVisible() == isChecked()) {
            continue;
        }
        host.setVisible(isChecked());
    }
    if (root != null) {
        root.refresh();
    }
}
Also used : BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) BrokerMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerMonitorPart) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) ArrayList(java.util.ArrayList) EditPart(org.eclipse.gef.EditPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DatabaseMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)

Example 37 with EditPart

use of org.eclipse.gef.EditPart in project cubrid-manager by CUBRID.

the class ClearNodeErrorMsgAction method run.

/**
	 * Create a new figure in dashboard.
	 * 
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    IStructuredSelection selection = (IStructuredSelection) getSelection();
    Iterator<?> iterator = selection.iterator();
    EditPart root = null;
    while (iterator.hasNext()) {
        Object objSelected = iterator.next();
        if (objSelected instanceof HANodePart) {
            HANodePart ep = (HANodePart) objSelected;
            ((HANode) ep.getModel()).clearErrorMessages();
            root = ep.getParent();
        }
    }
    if (root != null) {
        root.refresh();
    }
}
Also used : EditPart(org.eclipse.gef.EditPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) HANode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HANode) HANodePart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HANodePart)

Example 38 with EditPart

use of org.eclipse.gef.EditPart in project cubrid-manager by CUBRID.

the class DashboardRefreshAction method run.

/**
	 * refresh dashboard run.
	 * 
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    Object[] objArr = this.getSelectedObj();
    if (objArr == null || objArr.length <= 0 || !isSupported(objArr[0])) {
        setEnabled(false);
        return;
    }
    DashboardPart dp = null;
    if (objArr[0] instanceof DashboardPart) {
        dp = (DashboardPart) objArr[0];
    } else {
        dp = (DashboardPart) ((EditPart) objArr[0]).getParent();
    }
    //Clear error messages
    IStructuredSelection selection = (IStructuredSelection) getSelection();
    Iterator<?> iterator = selection.iterator();
    while (iterator.hasNext()) {
        Object objSelected = iterator.next();
        if (objSelected instanceof HANodePart) {
            HANodePart ep = (HANodePart) objSelected;
            ((HANode) ep.getModel()).clearErrorMessages();
        }
    }
    dp.refresh();
    List<?> childEditPart = dp.getChildren();
    for (Object child : childEditPart) {
        ((EditPart) child).refresh();
    }
}
Also used : DashboardPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DashboardPart) EditPart(org.eclipse.gef.EditPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) HANode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HANode) HANodePart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HANodePart)

Example 39 with EditPart

use of org.eclipse.gef.EditPart in project cubrid-manager by CUBRID.

the class AbstractBasicPart method handleInputChange.

private void handleInputChange(PropertyChangeEvent evt) {
    Object newValue = evt.getNewValue();
    Object oldValue = evt.getOldValue();
    if (oldValue == null && newValue == null) {
        throw new IllegalStateException(Messages.errOldNewValueBothNull);
    }
    if (newValue != null) {
        // add new connection
        ConnectionEditPart connPart = createOrFindConnection(newValue);
        int modelIndex = getModelTargetConnections().indexOf(newValue);
        addTargetConnection(connPart, modelIndex < 0 ? 0 : modelIndex);
    } else {
        // remove connection
        List children = getTargetConnections();
        ConnectionEditPart partToRemove = null;
        for (Iterator iter = children.iterator(); iter.hasNext(); ) {
            ConnectionEditPart part = (ConnectionEditPart) iter.next();
            if (part.getModel() == oldValue) {
                partToRemove = part;
                break;
            }
        }
        if (partToRemove != null) {
            // the connection part should be removed both in source part and in target part
            removeTargetConnection(partToRemove);
            EditPart sourcePart = partToRemove.getSource();
            if (sourcePart instanceof AbstractBasicPart) {
                ((AbstractBasicPart) sourcePart).removeSourceConnection(partToRemove);
            }
        }
    }
    getContentPane().revalidate();
}
Also used : ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) Iterator(java.util.Iterator) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) List(java.util.List)

Example 40 with EditPart

use of org.eclipse.gef.EditPart in project cubrid-manager by CUBRID.

the class AbstractBasicPart method handleOutputChange.

private void handleOutputChange(PropertyChangeEvent evt) {
    Object newValue = evt.getNewValue();
    Object oldValue = evt.getOldValue();
    if ((oldValue == null) && (newValue == null)) {
        throw new IllegalStateException(Messages.errOldNewValueBothNull);
    }
    if (oldValue == null && newValue != null) {
        // add new connection
        ConnectionEditPart connPart = createOrFindConnection(newValue);
        int modelIndex = getModelSourceConnections().indexOf(newValue);
        addSourceConnection(connPart, modelIndex < 0 ? 0 : modelIndex);
    } else if (oldValue != null && newValue == null) {
        // remove connection
        List children = getSourceConnections();
        ConnectionEditPart partToRemove = null;
        for (Iterator iter = children.iterator(); iter.hasNext(); ) {
            ConnectionEditPart part = (ConnectionEditPart) iter.next();
            if (part.getModel() == oldValue) {
                partToRemove = part;
                break;
            }
        }
        if (partToRemove != null) {
            // the connection part should be removed both in source part and in target part
            removeSourceConnection(partToRemove);
            EditPart targetPart = partToRemove.getTarget();
            if (targetPart instanceof AbstractBasicPart) {
                ((AbstractBasicPart) targetPart).removeTargetConnection(partToRemove);
            }
        }
        getViewer().getEditPartRegistry().remove(oldValue);
    /*
			ConnectionEditPart connPart = (ConnectionEditPart) getViewer().getEditPartRegistry().get(oldValue);
			IFigure figure = connPart.getFigure();
			if(figure instanceof ConnectionFigure){
				ConnectionFigure connFigure = (ConnectionFigure)figure;
				if(connFigure.getConnectionRouter() == ConnectionRouter.NULL){
					connFigure.setConnectionRouter(new ERConnectionRouter());
				}
			}
			*/
    }
    getContentPane().revalidate();
}
Also used : ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) Iterator(java.util.Iterator) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) List(java.util.List)

Aggregations

EditPart (org.eclipse.gef.EditPart)291 List (java.util.List)58 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)55 ArrayList (java.util.ArrayList)51 Command (org.eclipse.gef.commands.Command)32 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)27 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)27 Point (org.eclipse.draw2d.geometry.Point)26 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)26 Test (org.junit.Test)26 EmptyEditPart (com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart)21 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)21 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)20 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)19 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)19 Iterator (java.util.Iterator)18 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)18 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)16 ConnectionContainerEditPart (org.knime.workbench.editor2.editparts.ConnectionContainerEditPart)14 DiagramConnectionEditPart (com.archimatetool.editor.diagram.editparts.DiagramConnectionEditPart)13