Search in sources :

Example 1 with TagFeatureExecOnAssign

use of com.biglybt.core.tag.TagFeatureExecOnAssign in project BiglyBT by BiglySoftware.

the class ColumnTagProperties method refresh.

@Override
public void refresh(TableCell cell) {
    Tag tag = (Tag) cell.getDataSource();
    String text = "";
    if (tag instanceof TagFeatureProperties) {
        TagFeatureProperties tp = (TagFeatureProperties) tag;
        TagFeatureProperties.TagProperty[] props = tp.getSupportedProperties();
        if (props.length > 0) {
            for (TagFeatureProperties.TagProperty prop : props) {
                String prop_str = prop.getString();
                if (prop_str.length() > 0) {
                    text += (text.length() == 0 ? "" : "; ") + prop_str;
                }
            }
        }
    }
    if (tag instanceof TagFeatureExecOnAssign) {
        TagFeatureExecOnAssign eoa = (TagFeatureExecOnAssign) tag;
        int actions = eoa.getSupportedActions();
        if (actions != TagFeatureExecOnAssign.ACTION_NONE) {
            String actions_str = "";
            int[] action_ids = { TagFeatureExecOnAssign.ACTION_APPLY_OPTIONS_TEMPLATE, TagFeatureExecOnAssign.ACTION_DESTROY, TagFeatureExecOnAssign.ACTION_START, TagFeatureExecOnAssign.ACTION_FORCE_START, TagFeatureExecOnAssign.ACTION_NOT_FORCE_START, TagFeatureExecOnAssign.ACTION_STOP, TagFeatureExecOnAssign.ACTION_SCRIPT, TagFeatureExecOnAssign.ACTION_PAUSE, TagFeatureExecOnAssign.ACTION_RESUME };
            String[] action_keys = { "label.apply.options.template", "v3.MainWindow.button.delete", "v3.MainWindow.button.start", "v3.MainWindow.button.forcestart", "v3.MainWindow.button.notforcestart", "v3.MainWindow.button.stop", "label.script", "v3.MainWindow.button.pause", "v3.MainWindow.button.resume" };
            for (int i = 0; i < action_ids.length; i++) {
                int action_id = action_ids[i];
                if (eoa.supportsAction(action_id)) {
                    boolean enabled = eoa.isActionEnabled(action_id);
                    if (enabled) {
                        if (action_id == TagFeatureExecOnAssign.ACTION_SCRIPT) {
                            String script = eoa.getActionScript();
                            if (script.length() > 63) {
                                script = script.substring(0, 60) + "...";
                            }
                            actions_str += (actions_str.length() == 0 ? "" : ",") + MessageText.getString(action_keys[i]) + "=" + script;
                        } else {
                            actions_str += (actions_str.length() == 0 ? "" : ",") + MessageText.getString(action_keys[i]) + "=Y";
                        }
                    }
                }
            }
            if (actions_str.length() > 0) {
                text += (text.length() == 0 ? "" : "; ") + MessageText.getString("label.exec.on.assign") + ": ";
                text += actions_str;
            }
        }
    }
    if (!cell.setSortValue(text) && cell.isValid()) {
        return;
    }
    if (!cell.isShown()) {
        return;
    }
    cell.setText(text);
}
Also used : Tag(com.biglybt.core.tag.Tag) TagFeatureProperties(com.biglybt.core.tag.TagFeatureProperties) TagFeatureExecOnAssign(com.biglybt.core.tag.TagFeatureExecOnAssign)

Aggregations

Tag (com.biglybt.core.tag.Tag)1 TagFeatureExecOnAssign (com.biglybt.core.tag.TagFeatureExecOnAssign)1 TagFeatureProperties (com.biglybt.core.tag.TagFeatureProperties)1