001: /*
002: *
003: * Copyright (c) 2003-2005, SeeBeyond Technology Corporation,
004: * All Rights Reserved
005: *
006: * This program, and all the routines referenced herein,
007: * are the proprietary properties and trade secrets of
008: * SEEBEYOND TECHNOLOGY CORPORATION.
009: *
010: * Except as provided for by license agreement, this
011: * program shall not be duplicated, used, or disclosed
012: * without written consent signed by an officer of
013: * SEEBEYOND TECHNOLOGY CORPORATION.
014: *
015: */
016: package org.netbeans.modules.etl.ui.view.graph.actions;
017:
018: import org.netbeans.modules.sql.framework.model.SQLDBTable;
019: import java.awt.event.ActionEvent;
020: import java.awt.event.InputEvent;
021: import java.net.URL;
022: import javax.swing.Action;
023: import java.util.Iterator;
024: import javax.swing.ImageIcon;
025: import javax.swing.KeyStroke;
026: import net.java.hulp.i18n.Logger;
027: import org.netbeans.modules.etl.logger.Localizer;
028: import org.netbeans.modules.etl.logger.LogUtil;
029: import org.netbeans.modules.sql.framework.model.DBMetaDataFactory;
030: import org.netbeans.modules.sql.framework.model.SQLDBModel;
031: import org.netbeans.modules.sql.framework.model.utils.SQLObjectUtil;
032: import org.openide.util.Exceptions;
033: import org.netbeans.modules.sql.framework.ui.graph.IGraphView;
034: import org.netbeans.modules.sql.framework.ui.model.CollabSQLUIModel;
035: import org.netbeans.modules.sql.framework.ui.graph.actions.GraphAction;
036: import org.openide.awt.StatusDisplayer;
037:
038: /**
039: * @author Nithya Radhakrishnan
040: * @version $Revision$
041: */
042: public class RemountCollaborationAction extends GraphAction {
043:
044: private static final URL remountImgUrl = RemountCollaborationAction.class
045: .getResource("/org/netbeans/modules/sql/framework/ui/resources/images/redo.png");
046: private static transient final Logger mLogger = LogUtil
047: .getLogger(RemountCollaborationAction.class.getName());
048: private static transient final Localizer mLoc = Localizer.get();
049:
050: public RemountCollaborationAction() {
051: //action name
052: String nbBundle1 = mLoc.t("PRSR001: Remount");
053: this .putValue(Action.NAME, Localizer.parse(nbBundle1));
054:
055: //action icon
056: this .putValue(Action.SMALL_ICON, new ImageIcon(remountImgUrl));
057:
058: //action tooltip
059: String nbBundle2 = mLoc
060: .t("PRSR001: Drops and re-creates all the tables. (Cntl-M)");
061: this .putValue(Action.SHORT_DESCRIPTION, Localizer
062: .parse(nbBundle2));
063: // Acceleratot Cntl-M
064: this .putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
065: 'M', InputEvent.CTRL_MASK));
066: }
067:
068: /**
069: * called when this action is performed in the ui
070: *
071: * @param ev event
072: */
073: public void actionPerformed(ActionEvent ev) {
074: IGraphView graphView = (IGraphView) ev.getSource();
075: CollabSQLUIModel model = (CollabSQLUIModel) graphView
076: .getGraphModel();
077: Iterator targetTables = model.getSQLDefinition()
078: .getTargetTables().iterator();
079: while (targetTables.hasNext()) {
080: try {
081: SQLDBTable table = (SQLDBTable) targetTables.next();
082: SQLDBModel dbmodel = (SQLDBModel) table.getParent();
083: if (dbmodel.getETLDBConnectionDefinition().getDBType()
084: .equals(DBMetaDataFactory.AXION)
085: || dbmodel.getETLDBConnectionDefinition()
086: .getDBType().equalsIgnoreCase(
087: "Internal")) {
088: SQLObjectUtil.dropTable(table, (SQLDBModel) table
089: .getParent());
090: SQLObjectUtil.createTable(table, (SQLDBModel) table
091: .getParent());
092: SQLObjectUtil.setOrgProperties(table);
093: }
094: } catch (Exception ex) {
095: Exceptions.printStackTrace(ex);
096: StatusDisplayer.getDefault().setStatusText(
097: "Unable to remount :" + ex.getMessage());
098: }
099: }
100:
101: Iterator sourceTables = model.getSQLDefinition()
102: .getSourceTables().iterator();
103: while (sourceTables.hasNext()) {
104: try {
105: SQLDBTable table = (SQLDBTable) sourceTables.next();
106: SQLDBModel dbmodel = (SQLDBModel) table.getParent();
107: if (dbmodel.getETLDBConnectionDefinition().getDBType()
108: .equals(DBMetaDataFactory.AXION)
109: || dbmodel.getETLDBConnectionDefinition()
110: .getDBType().equalsIgnoreCase(
111: "Internal")) {
112: SQLObjectUtil.dropTable(table, (SQLDBModel) table
113: .getParent());
114: SQLObjectUtil.createTable(table, (SQLDBModel) table
115: .getParent());
116: SQLObjectUtil.setOrgProperties(table);
117: }
118: } catch (Exception ex) {
119: Exceptions.printStackTrace(ex);
120: StatusDisplayer.getDefault().setStatusText(
121: "Unable to remount :" + ex.getMessage());
122: }
123: }
124: } // end of jOptionPane
125: }
|